Lines Matching +full:pll +full:- +full:out
1 // SPDX-License-Identifier: GPL-2.0-only
6 #define DSS_SUBSYS_NAME "PLL"
30 int dss_pll_register(struct dss_pll *pll) in dss_pll_register() argument
36 dss_plls[i] = pll; in dss_pll_register()
41 return -EBUSY; in dss_pll_register()
44 void dss_pll_unregister(struct dss_pll *pll) in dss_pll_unregister() argument
49 if (dss_plls[i] == pll) { in dss_pll_unregister()
61 if (dss_plls[i] && strcmp(dss_plls[i]->name, name) == 0) in dss_pll_find()
68 int dss_pll_enable(struct dss_pll *pll) in dss_pll_enable() argument
72 r = clk_prepare_enable(pll->clkin); in dss_pll_enable()
76 if (pll->regulator) { in dss_pll_enable()
77 r = regulator_enable(pll->regulator); in dss_pll_enable()
82 r = pll->ops->enable(pll); in dss_pll_enable()
89 if (pll->regulator) in dss_pll_enable()
90 regulator_disable(pll->regulator); in dss_pll_enable()
92 clk_disable_unprepare(pll->clkin); in dss_pll_enable()
96 void dss_pll_disable(struct dss_pll *pll) in dss_pll_disable() argument
98 pll->ops->disable(pll); in dss_pll_disable()
100 if (pll->regulator) in dss_pll_disable()
101 regulator_disable(pll->regulator); in dss_pll_disable()
103 clk_disable_unprepare(pll->clkin); in dss_pll_disable()
105 memset(&pll->cinfo, 0, sizeof(pll->cinfo)); in dss_pll_disable()
108 int dss_pll_set_config(struct dss_pll *pll, const struct dss_pll_clock_info *cinfo) in dss_pll_set_config() argument
112 r = pll->ops->set_config(pll, cinfo); in dss_pll_set_config()
116 pll->cinfo = *cinfo; in dss_pll_set_config()
121 bool dss_pll_hsdiv_calc(const struct dss_pll *pll, unsigned long clkdco, in dss_pll_hsdiv_calc() argument
125 const struct dss_pll_hw *hw = pll->hw; in dss_pll_hsdiv_calc()
127 unsigned long out; in dss_pll_hsdiv_calc() local
134 m_stop = min((unsigned)(clkdco / out_min), hw->mX_max); in dss_pll_hsdiv_calc()
137 out = clkdco / m; in dss_pll_hsdiv_calc()
139 if (func(m, out, data)) in dss_pll_hsdiv_calc()
146 bool dss_pll_calc(const struct dss_pll *pll, unsigned long clkin, in dss_pll_calc() argument
150 const struct dss_pll_hw *hw = pll->hw; in dss_pll_calc()
157 pll_hw_max = hw->clkdco_max; in dss_pll_calc()
159 fint_hw_min = hw->fint_min; in dss_pll_calc()
160 fint_hw_max = hw->fint_max; in dss_pll_calc()
163 n_stop = min((unsigned)(clkin / fint_hw_min), hw->n_max); in dss_pll_calc()
174 hw->m_max); in dss_pll_calc()
195 while (t-- > 0) { in wait_for_bit_change()
214 int dss_pll_wait_reset_done(struct dss_pll *pll) in dss_pll_wait_reset_done() argument
216 void __iomem *base = pll->base; in dss_pll_wait_reset_done()
219 return -ETIMEDOUT; in dss_pll_wait_reset_done()
224 static int dss_wait_hsdiv_ack(struct dss_pll *pll, u32 hsdiv_ack_mask) in dss_wait_hsdiv_ack() argument
228 while (t-- > 0) { in dss_wait_hsdiv_ack()
229 u32 v = readl_relaxed(pll->base + PLL_STATUS); in dss_wait_hsdiv_ack()
235 return -ETIMEDOUT; in dss_wait_hsdiv_ack()
238 int dss_pll_write_config_type_a(struct dss_pll *pll, in dss_pll_write_config_type_a() argument
241 const struct dss_pll_hw *hw = pll->hw; in dss_pll_write_config_type_a()
242 void __iomem *base = pll->base; in dss_pll_write_config_type_a()
247 if (hw->has_stopmode) in dss_pll_write_config_type_a()
249 l = FLD_MOD(l, cinfo->n - 1, hw->n_msb, hw->n_lsb); /* PLL_REGN */ in dss_pll_write_config_type_a()
250 l = FLD_MOD(l, cinfo->m, hw->m_msb, hw->m_lsb); /* PLL_REGM */ in dss_pll_write_config_type_a()
252 l = FLD_MOD(l, cinfo->mX[0] ? cinfo->mX[0] - 1 : 0, in dss_pll_write_config_type_a()
253 hw->mX_msb[0], hw->mX_lsb[0]); in dss_pll_write_config_type_a()
255 l = FLD_MOD(l, cinfo->mX[1] ? cinfo->mX[1] - 1 : 0, in dss_pll_write_config_type_a()
256 hw->mX_msb[1], hw->mX_lsb[1]); in dss_pll_write_config_type_a()
261 l = FLD_MOD(l, cinfo->mX[2] ? cinfo->mX[2] - 1 : 0, in dss_pll_write_config_type_a()
262 hw->mX_msb[2], hw->mX_lsb[2]); in dss_pll_write_config_type_a()
264 l = FLD_MOD(l, cinfo->mX[3] ? cinfo->mX[3] - 1 : 0, in dss_pll_write_config_type_a()
265 hw->mX_msb[3], hw->mX_lsb[3]); in dss_pll_write_config_type_a()
269 if (hw->has_freqsel) { in dss_pll_write_config_type_a()
270 u32 f = cinfo->fint < 1000000 ? 0x3 : in dss_pll_write_config_type_a()
271 cinfo->fint < 1250000 ? 0x4 : in dss_pll_write_config_type_a()
272 cinfo->fint < 1500000 ? 0x5 : in dss_pll_write_config_type_a()
273 cinfo->fint < 1750000 ? 0x6 : in dss_pll_write_config_type_a()
277 } else if (hw->has_selfreqdco) { in dss_pll_write_config_type_a()
278 u32 f = cinfo->clkdco < hw->clkdco_low ? 0x2 : 0x4; in dss_pll_write_config_type_a()
287 if (hw->has_refsel) in dss_pll_write_config_type_a()
297 r = -EIO; in dss_pll_write_config_type_a()
303 r = -EIO; in dss_pll_write_config_type_a()
309 l = FLD_MOD(l, cinfo->mX[0] ? 1 : 0, 16, 16); /* M4_CLOCK_EN */ in dss_pll_write_config_type_a()
310 l = FLD_MOD(l, cinfo->mX[1] ? 1 : 0, 18, 18); /* M5_CLOCK_EN */ in dss_pll_write_config_type_a()
312 l = FLD_MOD(l, cinfo->mX[2] ? 1 : 0, 23, 23); /* M6_CLOCK_EN */ in dss_pll_write_config_type_a()
313 l = FLD_MOD(l, cinfo->mX[3] ? 1 : 0, 25, 25); /* M7_CLOCK_EN */ in dss_pll_write_config_type_a()
316 r = dss_wait_hsdiv_ack(pll, in dss_pll_write_config_type_a()
317 (cinfo->mX[0] ? BIT(7) : 0) | in dss_pll_write_config_type_a()
318 (cinfo->mX[1] ? BIT(8) : 0) | in dss_pll_write_config_type_a()
319 (cinfo->mX[2] ? BIT(10) : 0) | in dss_pll_write_config_type_a()
320 (cinfo->mX[3] ? BIT(11) : 0)); in dss_pll_write_config_type_a()
330 int dss_pll_write_config_type_b(struct dss_pll *pll, in dss_pll_write_config_type_b() argument
333 const struct dss_pll_hw *hw = pll->hw; in dss_pll_write_config_type_b()
334 void __iomem *base = pll->base; in dss_pll_write_config_type_b()
338 l = FLD_MOD(l, cinfo->m, 20, 9); /* PLL_REGM */ in dss_pll_write_config_type_b()
339 l = FLD_MOD(l, cinfo->n - 1, 8, 1); /* PLL_REGN */ in dss_pll_write_config_type_b()
346 if (hw->has_refsel) in dss_pll_write_config_type_b()
350 if (cinfo->clkdco > hw->clkdco_low) in dss_pll_write_config_type_b()
357 l = FLD_MOD(l, cinfo->sd, 17, 10); /* PLL_REGSD */ in dss_pll_write_config_type_b()
361 l = FLD_MOD(l, cinfo->mX[0], 24, 18); /* PLL_REGM2 */ in dss_pll_write_config_type_b()
362 l = FLD_MOD(l, cinfo->mf, 17, 0); /* PLL_REGM_F */ in dss_pll_write_config_type_b()
369 return -EIO; in dss_pll_write_config_type_b()
374 return -ETIMEDOUT; in dss_pll_write_config_type_b()