summaryrefslogtreecommitdiffstats
path: root/drivers/clk/meson/clk-pll.c
diff options
context:
space:
mode:
authorJerome Brunet <jbrunet@baylibre.com>2018-01-19 16:55:25 +0100
committerJerome Brunet <jbrunet@baylibre.com>2018-02-12 09:49:23 +0100
commit7d3142e5d64a2bdcd382dac979407f6afc83d685 (patch)
tree43f41c31e6e7b5a1b16078ea883a3bf857fabf22 /drivers/clk/meson/clk-pll.c
parentclk: meson: use the frac parameter width instead of a constant (diff)
downloadlinux-7d3142e5d64a2bdcd382dac979407f6afc83d685.tar.xz
linux-7d3142e5d64a2bdcd382dac979407f6afc83d685.zip
clk: meson: add od3 to the pll driver
Some meson plls, such as the hdmi pll, are using a 3rd od parameter, which is yet another "power of 2" post divider. Add it to fix the calculation of the hdmi_pll rate Fixes: 738f66d3211d ("clk: gxbb: add AmLogic GXBB clk controller driver") Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Diffstat (limited to 'drivers/clk/meson/clk-pll.c')
-rw-r--r--drivers/clk/meson/clk-pll.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c
index 50923d004d96..1595f02f610f 100644
--- a/drivers/clk/meson/clk-pll.c
+++ b/drivers/clk/meson/clk-pll.c
@@ -53,7 +53,7 @@ static unsigned long meson_clk_pll_recalc_rate(struct clk_hw *hw,
struct meson_clk_pll *pll = to_meson_clk_pll(hw);
struct parm *p;
u64 rate;
- u16 n, m, frac = 0, od, od2 = 0;
+ u16 n, m, frac = 0, od, od2 = 0, od3 = 0;
u32 reg;
p = &pll->n;
@@ -74,7 +74,13 @@ static unsigned long meson_clk_pll_recalc_rate(struct clk_hw *hw,
od2 = PARM_GET(p->width, p->shift, reg);
}
- rate = (u64)parent_rate * m;
+ p = &pll->od3;
+ if (p->width) {
+ reg = readl(pll->base + p->reg_off);
+ od3 = PARM_GET(p->width, p->shift, reg);
+ }
+
+ rate = (u64)m * parent_rate;
p = &pll->frac;
if (p->width) {
@@ -85,7 +91,7 @@ static unsigned long meson_clk_pll_recalc_rate(struct clk_hw *hw,
rate *= 2;
}
- return div_u64(rate, n) >> od >> od2;
+ return div_u64(rate, n) >> od >> od2 >> od3;
}
static long meson_clk_pll_round_rate(struct clk_hw *hw, unsigned long rate,
@@ -226,6 +232,13 @@ static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
writel(reg, pll->base + p->reg_off);
}
+ p = &pll->od3;
+ if (p->width) {
+ reg = readl(pll->base + p->reg_off);
+ reg = PARM_SET(p->width, p->shift, reg, rate_set->od3);
+ writel(reg, pll->base + p->reg_off);
+ }
+
p = &pll->frac;
if (p->width) {
reg = readl(pll->base + p->reg_off);