Skip to content

Commit f497313

Browse files
Satya Priya Kakitapalliandersson
authored andcommitted
clk: qcom: clk-alpha-pll: Update set_rate for Zonda PLL
The Zonda PLL has a 16 bit signed alpha and in the cases where the alpha value is greater than 0.5, the L value needs to be adjusted accordingly. Thus update the logic to handle the signed alpha val. Fixes: f21b6bf ("clk: qcom: clk-alpha-pll: add support for zonda pll") Cc: [email protected] Signed-off-by: Satya Priya Kakitapalli <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 85e8ee5 commit f497313

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

drivers/clk/qcom/clk-alpha-pll.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#define PLL_USER_CTL(p) ((p)->offset + (p)->regs[PLL_OFF_USER_CTL])
4242
# define PLL_POST_DIV_SHIFT 8
4343
# define PLL_POST_DIV_MASK(p) GENMASK((p)->width - 1, 0)
44+
# define PLL_ALPHA_MSB BIT(15)
4445
# define PLL_ALPHA_EN BIT(24)
4546
# define PLL_ALPHA_MODE BIT(25)
4647
# define PLL_VCO_SHIFT 20
@@ -2117,6 +2118,18 @@ static void clk_zonda_pll_disable(struct clk_hw *hw)
21172118
regmap_write(regmap, PLL_OPMODE(pll), 0x0);
21182119
}
21192120

2121+
static void zonda_pll_adjust_l_val(unsigned long rate, unsigned long prate, u32 *l)
2122+
{
2123+
u64 remainder, quotient;
2124+
2125+
quotient = rate;
2126+
remainder = do_div(quotient, prate);
2127+
*l = quotient;
2128+
2129+
if ((remainder * 2) / prate)
2130+
*l = *l + 1;
2131+
}
2132+
21202133
static int clk_zonda_pll_set_rate(struct clk_hw *hw, unsigned long rate,
21212134
unsigned long prate)
21222135
{
@@ -2133,6 +2146,9 @@ static int clk_zonda_pll_set_rate(struct clk_hw *hw, unsigned long rate,
21332146
if (ret < 0)
21342147
return ret;
21352148

2149+
if (a & PLL_ALPHA_MSB)
2150+
zonda_pll_adjust_l_val(rate, prate, &l);
2151+
21362152
regmap_write(pll->clkr.regmap, PLL_ALPHA_VAL(pll), a);
21372153
regmap_write(pll->clkr.regmap, PLL_L_VAL(pll), l);
21382154

0 commit comments

Comments
 (0)