diff options
author | Abhishek Sahu <absahu@codeaurora.org> | 2017-09-28 13:50:49 -0400 |
---|---|---|
committer | Stephen Boyd <sboyd@codeaurora.org> | 2017-12-13 19:54:09 -0500 |
commit | 1c3541145cbfd1cf631602bd7494dd03260e8533 (patch) | |
tree | 7eb2828cf9832619f8bc45c321fe05b1f18dec3a | |
parent | c23e8a1f6016bd35599c35052d39bb9e879351ad (diff) |
clk: qcom: support for 2 bit PLL post divider
Current PLL driver only supports 4 bit PLL post divider so
modified the PLL divider operations to support 2 bit PLL
post divider.
Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
-rw-r--r-- | drivers/clk/qcom/clk-alpha-pll.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/drivers/clk/qcom/clk-alpha-pll.c b/drivers/clk/qcom/clk-alpha-pll.c index 3a38861a7944..2de66b98e997 100644 --- a/drivers/clk/qcom/clk-alpha-pll.c +++ b/drivers/clk/qcom/clk-alpha-pll.c | |||
@@ -45,7 +45,7 @@ | |||
45 | 45 | ||
46 | #define PLL_USER_CTL(p) ((p)->offset + (p)->regs[PLL_OFF_USER_CTL]) | 46 | #define PLL_USER_CTL(p) ((p)->offset + (p)->regs[PLL_OFF_USER_CTL]) |
47 | # define PLL_POST_DIV_SHIFT 8 | 47 | # define PLL_POST_DIV_SHIFT 8 |
48 | # define PLL_POST_DIV_MASK 0xf | 48 | # define PLL_POST_DIV_MASK(p) GENMASK((p)->width, 0) |
49 | # define PLL_ALPHA_EN BIT(24) | 49 | # define PLL_ALPHA_EN BIT(24) |
50 | # define PLL_ALPHA_MODE BIT(25) | 50 | # define PLL_ALPHA_MODE BIT(25) |
51 | # define PLL_VCO_SHIFT 20 | 51 | # define PLL_VCO_SHIFT 20 |
@@ -750,7 +750,7 @@ clk_alpha_pll_postdiv_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) | |||
750 | regmap_read(pll->clkr.regmap, PLL_USER_CTL(pll), &ctl); | 750 | regmap_read(pll->clkr.regmap, PLL_USER_CTL(pll), &ctl); |
751 | 751 | ||
752 | ctl >>= PLL_POST_DIV_SHIFT; | 752 | ctl >>= PLL_POST_DIV_SHIFT; |
753 | ctl &= PLL_POST_DIV_MASK; | 753 | ctl &= PLL_POST_DIV_MASK(pll); |
754 | 754 | ||
755 | return parent_rate >> fls(ctl); | 755 | return parent_rate >> fls(ctl); |
756 | } | 756 | } |
@@ -764,13 +764,26 @@ static const struct clk_div_table clk_alpha_div_table[] = { | |||
764 | { } | 764 | { } |
765 | }; | 765 | }; |
766 | 766 | ||
767 | static const struct clk_div_table clk_alpha_2bit_div_table[] = { | ||
768 | { 0x0, 1 }, | ||
769 | { 0x1, 2 }, | ||
770 | { 0x3, 4 }, | ||
771 | { } | ||
772 | }; | ||
773 | |||
767 | static long | 774 | static long |
768 | clk_alpha_pll_postdiv_round_rate(struct clk_hw *hw, unsigned long rate, | 775 | clk_alpha_pll_postdiv_round_rate(struct clk_hw *hw, unsigned long rate, |
769 | unsigned long *prate) | 776 | unsigned long *prate) |
770 | { | 777 | { |
771 | struct clk_alpha_pll_postdiv *pll = to_clk_alpha_pll_postdiv(hw); | 778 | struct clk_alpha_pll_postdiv *pll = to_clk_alpha_pll_postdiv(hw); |
779 | const struct clk_div_table *table; | ||
780 | |||
781 | if (pll->width == 2) | ||
782 | table = clk_alpha_2bit_div_table; | ||
783 | else | ||
784 | table = clk_alpha_div_table; | ||
772 | 785 | ||
773 | return divider_round_rate(hw, rate, prate, clk_alpha_div_table, | 786 | return divider_round_rate(hw, rate, prate, table, |
774 | pll->width, CLK_DIVIDER_POWER_OF_TWO); | 787 | pll->width, CLK_DIVIDER_POWER_OF_TWO); |
775 | } | 788 | } |
776 | 789 | ||
@@ -784,7 +797,7 @@ static int clk_alpha_pll_postdiv_set_rate(struct clk_hw *hw, unsigned long rate, | |||
784 | div = DIV_ROUND_UP_ULL((u64)parent_rate, rate) - 1; | 797 | div = DIV_ROUND_UP_ULL((u64)parent_rate, rate) - 1; |
785 | 798 | ||
786 | return regmap_update_bits(pll->clkr.regmap, PLL_USER_CTL(pll), | 799 | return regmap_update_bits(pll->clkr.regmap, PLL_USER_CTL(pll), |
787 | PLL_POST_DIV_MASK << PLL_POST_DIV_SHIFT, | 800 | PLL_POST_DIV_MASK(pll) << PLL_POST_DIV_SHIFT, |
788 | div << PLL_POST_DIV_SHIFT); | 801 | div << PLL_POST_DIV_SHIFT); |
789 | } | 802 | } |
790 | 803 | ||