Lines Matching full:pll
92 struct clk_pll14xx *pll, unsigned long rate) in imx_get_pll_settings() argument
94 const struct imx_pll14xx_rate_table *rate_table = pll->rate_table; in imx_get_pll_settings()
97 for (i = 0; i < pll->rate_count; i++) in imx_get_pll_settings()
104 static long pll14xx_calc_rate(struct clk_pll14xx *pll, int mdiv, int pdiv, in pll14xx_calc_rate() argument
129 static void imx_pll14xx_calc_settings(struct clk_pll14xx *pll, unsigned long rate, in imx_pll14xx_calc_settings() argument
138 * Fractional PLL constrains: in imx_pll14xx_calc_settings()
150 tt = imx_get_pll_settings(pll, rate); in imx_pll14xx_calc_settings()
152 pr_debug("%s: in=%ld, want=%ld, Using PLL setting from table\n", in imx_pll14xx_calc_settings()
153 clk_hw_get_name(&pll->hw), prate, rate); in imx_pll14xx_calc_settings()
162 pll_div_ctl0 = readl_relaxed(pll->base + DIV_CTL0); in imx_pll14xx_calc_settings()
166 pll_div_ctl1 = readl_relaxed(pll->base + DIV_CTL1); in imx_pll14xx_calc_settings()
169 rate_min = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, KDIV_MIN, prate); in imx_pll14xx_calc_settings()
170 rate_max = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, KDIV_MAX, prate); in imx_pll14xx_calc_settings()
175 clk_hw_get_name(&pll->hw), prate, rate, in imx_pll14xx_calc_settings()
177 fout = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate); in imx_pll14xx_calc_settings()
194 fout = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate); in imx_pll14xx_calc_settings()
213 clk_hw_get_name(&pll->hw), prate, rate, t->rate, t->pdiv, t->sdiv, in imx_pll14xx_calc_settings()
220 struct clk_pll14xx *pll = to_clk_pll14xx(hw); in clk_pll1416x_round_rate() local
221 const struct imx_pll14xx_rate_table *rate_table = pll->rate_table; in clk_pll1416x_round_rate()
225 for (i = 0; i < pll->rate_count; i++) in clk_pll1416x_round_rate()
230 return rate_table[pll->rate_count - 1].rate; in clk_pll1416x_round_rate()
236 struct clk_pll14xx *pll = to_clk_pll14xx(hw); in clk_pll1443x_round_rate() local
239 imx_pll14xx_calc_settings(pll, rate, *prate, &t); in clk_pll1443x_round_rate()
247 struct clk_pll14xx *pll = to_clk_pll14xx(hw); in clk_pll14xx_recalc_rate() local
250 pll_div_ctl0 = readl_relaxed(pll->base + DIV_CTL0); in clk_pll14xx_recalc_rate()
255 if (pll->type == PLL_1443X) { in clk_pll14xx_recalc_rate()
256 pll_div_ctl1 = readl_relaxed(pll->base + DIV_CTL1); in clk_pll14xx_recalc_rate()
262 return pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, parent_rate); in clk_pll14xx_recalc_rate()
276 static int clk_pll14xx_wait_lock(struct clk_pll14xx *pll) in clk_pll14xx_wait_lock() argument
280 return readl_poll_timeout(pll->base + GNRL_CTL, val, val & LOCK_STATUS, 0, in clk_pll14xx_wait_lock()
287 struct clk_pll14xx *pll = to_clk_pll14xx(hw); in clk_pll1416x_set_rate() local
292 rate = imx_get_pll_settings(pll, drate); in clk_pll1416x_set_rate()
294 pr_err("Invalid rate %lu for pll clk %s\n", drate, in clk_pll1416x_set_rate()
299 tmp = readl_relaxed(pll->base + DIV_CTL0); in clk_pll1416x_set_rate()
304 writel_relaxed(tmp, pll->base + DIV_CTL0); in clk_pll1416x_set_rate()
309 /* Bypass clock and set lock to pll output lock */ in clk_pll1416x_set_rate()
310 tmp = readl_relaxed(pll->base + GNRL_CTL); in clk_pll1416x_set_rate()
312 writel_relaxed(tmp, pll->base + GNRL_CTL); in clk_pll1416x_set_rate()
316 writel_relaxed(tmp, pll->base + GNRL_CTL); in clk_pll1416x_set_rate()
320 writel(tmp, pll->base + GNRL_CTL); in clk_pll1416x_set_rate()
324 writel_relaxed(div_val, pll->base + DIV_CTL0); in clk_pll1416x_set_rate()
336 writel_relaxed(tmp, pll->base + GNRL_CTL); in clk_pll1416x_set_rate()
339 ret = clk_pll14xx_wait_lock(pll); in clk_pll1416x_set_rate()
345 writel_relaxed(tmp, pll->base + GNRL_CTL); in clk_pll1416x_set_rate()
353 struct clk_pll14xx *pll = to_clk_pll14xx(hw); in clk_pll1443x_set_rate() local
358 imx_pll14xx_calc_settings(pll, drate, prate, &rate); in clk_pll1443x_set_rate()
360 div_ctl0 = readl_relaxed(pll->base + DIV_CTL0); in clk_pll1443x_set_rate()
363 /* only sdiv and/or kdiv changed - no need to RESET PLL */ in clk_pll1443x_set_rate()
366 writel_relaxed(div_ctl0, pll->base + DIV_CTL0); in clk_pll1443x_set_rate()
369 pll->base + DIV_CTL1); in clk_pll1443x_set_rate()
375 gnrl_ctl = readl_relaxed(pll->base + GNRL_CTL); in clk_pll1443x_set_rate()
377 writel_relaxed(gnrl_ctl, pll->base + GNRL_CTL); in clk_pll1443x_set_rate()
381 writel_relaxed(gnrl_ctl, pll->base + GNRL_CTL); in clk_pll1443x_set_rate()
386 writel_relaxed(div_ctl0, pll->base + DIV_CTL0); in clk_pll1443x_set_rate()
388 writel_relaxed(FIELD_PREP(KDIV_MASK, rate.kdiv), pll->base + DIV_CTL1); in clk_pll1443x_set_rate()
400 writel_relaxed(gnrl_ctl, pll->base + GNRL_CTL); in clk_pll1443x_set_rate()
403 ret = clk_pll14xx_wait_lock(pll); in clk_pll1443x_set_rate()
409 writel_relaxed(gnrl_ctl, pll->base + GNRL_CTL); in clk_pll1443x_set_rate()
416 struct clk_pll14xx *pll = to_clk_pll14xx(hw); in clk_pll14xx_prepare() local
421 * RESETB = 1 from 0, PLL starts its normal in clk_pll14xx_prepare()
424 val = readl_relaxed(pll->base + GNRL_CTL); in clk_pll14xx_prepare()
428 writel_relaxed(val, pll->base + GNRL_CTL); in clk_pll14xx_prepare()
430 writel_relaxed(val, pll->base + GNRL_CTL); in clk_pll14xx_prepare()
432 ret = clk_pll14xx_wait_lock(pll); in clk_pll14xx_prepare()
437 writel_relaxed(val, pll->base + GNRL_CTL); in clk_pll14xx_prepare()
444 struct clk_pll14xx *pll = to_clk_pll14xx(hw); in clk_pll14xx_is_prepared() local
447 val = readl_relaxed(pll->base + GNRL_CTL); in clk_pll14xx_is_prepared()
454 struct clk_pll14xx *pll = to_clk_pll14xx(hw); in clk_pll14xx_unprepare() local
461 val = readl_relaxed(pll->base + GNRL_CTL); in clk_pll14xx_unprepare()
463 writel_relaxed(val, pll->base + GNRL_CTL); in clk_pll14xx_unprepare()
492 struct clk_pll14xx *pll; in imx_dev_clk_hw_pll14xx() local
498 pll = kzalloc(sizeof(*pll), GFP_KERNEL); in imx_dev_clk_hw_pll14xx()
499 if (!pll) in imx_dev_clk_hw_pll14xx()
518 pr_err("Unknown pll type for pll clk %s\n", name); in imx_dev_clk_hw_pll14xx()
519 kfree(pll); in imx_dev_clk_hw_pll14xx()
523 pll->base = base; in imx_dev_clk_hw_pll14xx()
524 pll->hw.init = &init; in imx_dev_clk_hw_pll14xx()
525 pll->type = pll_clk->type; in imx_dev_clk_hw_pll14xx()
526 pll->rate_table = pll_clk->rate_table; in imx_dev_clk_hw_pll14xx()
527 pll->rate_count = pll_clk->rate_count; in imx_dev_clk_hw_pll14xx()
529 val = readl_relaxed(pll->base + GNRL_CTL); in imx_dev_clk_hw_pll14xx()
531 writel_relaxed(val, pll->base + GNRL_CTL); in imx_dev_clk_hw_pll14xx()
533 hw = &pll->hw; in imx_dev_clk_hw_pll14xx()
537 pr_err("failed to register pll %s %d\n", name, ret); in imx_dev_clk_hw_pll14xx()
538 kfree(pll); in imx_dev_clk_hw_pll14xx()