Lines Matching refs:rate

92 		struct clk_pll14xx *pll, unsigned long rate)
98 if (rate == rate_table[i].rate)
119 unsigned long rate, unsigned long prate)
123 /* calc kdiv = round(rate * pdiv * 65536 * 2^sdiv / prate) - (mdiv * 65536) */
124 kdiv = ((rate * ((pdiv * 65536) << sdiv) + prate / 2) / prate) - (mdiv * 65536);
129 static void imx_pll14xx_calc_settings(struct clk_pll14xx *pll, unsigned long rate,
148 /* First try if we can get the desired rate from one of the static entries */
149 tt = imx_get_pll_settings(pll, rate);
152 clk_hw_get_name(&pll->hw), prate, rate);
153 t->rate = tt->rate;
167 /* Then see if we can get the desired rate by only adjusting kdiv (glitch free) */
171 if (rate >= rate_min && rate <= rate_max) {
172 kdiv = pll1443x_calc_kdiv(mdiv, pdiv, sdiv, rate, prate);
174 clk_hw_get_name(&pll->hw), prate, rate,
177 t->rate = (unsigned int)fvco;
188 /* calc mdiv = round(rate * pdiv * 2^sdiv) / prate) */
189 mdiv = DIV_ROUND_CLOSEST(rate * (pdiv << sdiv), prate);
192 kdiv = pll1443x_calc_kdiv(mdiv, pdiv, sdiv, rate, prate);
196 dist = abs((long)rate - (long)fvco);
199 t->rate = (unsigned int)fvco;
212 clk_hw_get_name(&pll->hw), prate, rate, t->rate, t->pdiv, t->sdiv,
216 static long clk_pll1416x_round_rate(struct clk_hw *hw, unsigned long rate,
225 if (rate >= rate_table[i].rate)
226 return rate_table[i].rate;
229 return rate_table[pll->rate_count - 1].rate;
232 static long clk_pll1443x_round_rate(struct clk_hw *hw, unsigned long rate,
238 imx_pll14xx_calc_settings(pll, rate, *prate, &t);
240 return t.rate;
264 static inline bool clk_pll14xx_mp_change(const struct imx_pll14xx_rate_table *rate,
272 return rate->mdiv != old_mdiv || rate->pdiv != old_pdiv;
287 const struct imx_pll14xx_rate_table *rate;
291 rate = imx_get_pll_settings(pll, drate);
292 if (!rate) {
293 pr_err("Invalid rate %lu for pll clk %s\n", drate,
300 if (!clk_pll14xx_mp_change(rate, tmp)) {
302 tmp |= FIELD_PREP(SDIV_MASK, rate->sdiv);
321 div_val = FIELD_PREP(MDIV_MASK, rate->mdiv) | FIELD_PREP(PDIV_MASK, rate->pdiv) |
322 FIELD_PREP(SDIV_MASK, rate->sdiv);
353 struct imx_pll14xx_rate_table rate;
357 imx_pll14xx_calc_settings(pll, drate, prate, &rate);
361 if (!clk_pll14xx_mp_change(&rate, div_ctl0)) {
364 div_ctl0 |= FIELD_PREP(SDIV_MASK, rate.sdiv);
367 writel_relaxed(FIELD_PREP(KDIV_MASK, rate.kdiv),
382 div_ctl0 = FIELD_PREP(MDIV_MASK, rate.mdiv) |
383 FIELD_PREP(PDIV_MASK, rate.pdiv) |
384 FIELD_PREP(SDIV_MASK, rate.sdiv);
387 writel_relaxed(FIELD_PREP(KDIV_MASK, rate.kdiv), pll->base + DIV_CTL1);