Lines Matching full:pll

3  * Toshiba Visconti PLL driver
17 #include "pll.h"
56 static void visconti_pll_get_params(struct visconti_pll *pll, in visconti_pll_get_params() argument
61 val = readl(pll->pll_base + PLL_FRACMODE_REG); in visconti_pll_get_params()
66 rate_table->fracin = readl(pll->pll_base + PLL_FRACIN_REG) & PLL_FRACIN_MASK; in visconti_pll_get_params()
67 rate_table->intin = readl(pll->pll_base + PLL_INTIN_REG) & PLL_INTIN_MASK; in visconti_pll_get_params()
68 rate_table->refdiv = readl(pll->pll_base + PLL_REFDIV_REG) & PLL_REFDIV_MASK; in visconti_pll_get_params()
70 postdiv = readl(pll->pll_base + PLL_POSTDIV_REG); in visconti_pll_get_params()
75 static const struct visconti_pll_rate_table *visconti_get_pll_settings(struct visconti_pll *pll, in visconti_get_pll_settings() argument
78 const struct visconti_pll_rate_table *rate_table = pll->rate_table; in visconti_get_pll_settings()
81 for (i = 0; i < pll->rate_count; i++) in visconti_get_pll_settings()
88 static unsigned long visconti_get_pll_rate_from_data(struct visconti_pll *pll, in visconti_get_pll_rate_from_data() argument
91 const struct visconti_pll_rate_table *rate_table = pll->rate_table; in visconti_get_pll_rate_from_data()
94 for (i = 0; i < pll->rate_count; i++) in visconti_get_pll_rate_from_data()
106 struct visconti_pll *pll = to_visconti_pll(hw); in visconti_pll_round_rate() local
107 const struct visconti_pll_rate_table *rate_table = pll->rate_table; in visconti_pll_round_rate()
111 for (i = 0; i < pll->rate_count; i++) in visconti_pll_round_rate()
122 struct visconti_pll *pll = to_visconti_pll(hw); in visconti_pll_recalc_rate() local
126 visconti_pll_get_params(pll, &rate_table); in visconti_pll_recalc_rate()
128 return visconti_get_pll_rate_from_data(pll, &rate_table); in visconti_pll_recalc_rate()
131 static int visconti_pll_set_params(struct visconti_pll *pll, in visconti_pll_set_params() argument
134 writel(PLL_CREATE_FRACMODE(rate_table), pll->pll_base + PLL_FRACMODE_REG); in visconti_pll_set_params()
135 writel(PLL_CREATE_OSTDIV(rate_table), pll->pll_base + PLL_POSTDIV_REG); in visconti_pll_set_params()
136 writel(rate_table->intin, pll->pll_base + PLL_INTIN_REG); in visconti_pll_set_params()
137 writel(rate_table->fracin, pll->pll_base + PLL_FRACIN_REG); in visconti_pll_set_params()
138 writel(rate_table->refdiv, pll->pll_base + PLL_REFDIV_REG); in visconti_pll_set_params()
146 struct visconti_pll *pll = to_visconti_pll(hw); in visconti_pll_set_rate() local
149 rate_table = visconti_get_pll_settings(pll, rate); in visconti_pll_set_rate()
153 return visconti_pll_set_params(pll, rate_table); in visconti_pll_set_rate()
158 struct visconti_pll *pll = to_visconti_pll(hw); in visconti_pll_is_enabled() local
161 reg = readl(pll->pll_base + PLL_CTRL_REG); in visconti_pll_is_enabled()
168 struct visconti_pll *pll = to_visconti_pll(hw); in visconti_pll_enable() local
169 const struct visconti_pll_rate_table *rate_table = pll->rate_table; in visconti_pll_enable()
176 spin_lock_irqsave(pll->lock, flags); in visconti_pll_enable()
178 writel(PLL_CONFIG_SEL, pll->pll_base + PLL_CONF_REG); in visconti_pll_enable()
180 reg = readl(pll->pll_base + PLL_CTRL_REG); in visconti_pll_enable()
182 writel(reg, pll->pll_base + PLL_CTRL_REG); in visconti_pll_enable()
184 visconti_pll_set_params(pll, &rate_table[0]); in visconti_pll_enable()
186 reg = readl(pll->pll_base + PLL_CTRL_REG); in visconti_pll_enable()
188 writel(reg, pll->pll_base + PLL_CTRL_REG); in visconti_pll_enable()
192 reg = readl(pll->pll_base + PLL_CTRL_REG); in visconti_pll_enable()
194 writel(reg, pll->pll_base + PLL_CTRL_REG); in visconti_pll_enable()
198 reg = readl(pll->pll_base + PLL_CTRL_REG); in visconti_pll_enable()
200 writel(reg, pll->pll_base + PLL_CTRL_REG); in visconti_pll_enable()
202 spin_unlock_irqrestore(pll->lock, flags); in visconti_pll_enable()
209 struct visconti_pll *pll = to_visconti_pll(hw); in visconti_pll_disable() local
216 spin_lock_irqsave(pll->lock, flags); in visconti_pll_disable()
218 writel(PLL_CONFIG_SEL, pll->pll_base + PLL_CONF_REG); in visconti_pll_disable()
220 reg = readl(pll->pll_base + PLL_CTRL_REG); in visconti_pll_disable()
222 writel(reg, pll->pll_base + PLL_CTRL_REG); in visconti_pll_disable()
224 reg = readl(pll->pll_base + PLL_CTRL_REG); in visconti_pll_disable()
226 writel(reg, pll->pll_base + PLL_CTRL_REG); in visconti_pll_disable()
228 spin_unlock_irqrestore(pll->lock, flags); in visconti_pll_disable()
248 struct visconti_pll *pll; in visconti_register_pll() local
253 pll = kzalloc(sizeof(*pll), GFP_KERNEL); in visconti_register_pll()
254 if (!pll) in visconti_register_pll()
264 pll->rate_count = len; in visconti_register_pll()
265 pll->rate_table = kmemdup_array(rate_table, in visconti_register_pll()
266 pll->rate_count, sizeof(*pll->rate_table), in visconti_register_pll()
268 WARN(!pll->rate_table, "%s: could not allocate rate table for %s\n", __func__, name); in visconti_register_pll()
271 pll->hw.init = &init; in visconti_register_pll()
272 pll->pll_base = ctx->reg_base + offset; in visconti_register_pll()
273 pll->lock = lock; in visconti_register_pll()
274 pll->ctx = ctx; in visconti_register_pll()
276 pll_hw_clk = &pll->hw; in visconti_register_pll()
277 ret = clk_hw_register(NULL, &pll->hw); in visconti_register_pll()
279 pr_err("failed to register pll clock %s : %d\n", name, ret); in visconti_register_pll()
280 kfree(pll->rate_table); in visconti_register_pll()
281 kfree(pll); in visconti_register_pll()