blob: f8306f1c30f1ce7d03530ec2e941bde5930e039b [file] [log] [blame]
Tero Kristof38b0dd2013-06-12 16:04:34 +03001/*
2 * OMAP DPLL clock support
3 *
4 * Copyright (C) 2013 Texas Instruments, Inc.
5 *
6 * Tero Kristo <t-kristo@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
13 * kind, whether express or implied; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
Stephen Boyd1b29e602015-06-19 15:00:46 -070018#include <linux/clk.h>
Tero Kristof38b0dd2013-06-12 16:04:34 +030019#include <linux/clk-provider.h>
20#include <linux/slab.h>
21#include <linux/err.h>
22#include <linux/of.h>
23#include <linux/of_address.h>
24#include <linux/clk/ti.h>
Tero Kristoed405a22015-01-29 22:24:28 +020025#include "clock.h"
Tero Kristof38b0dd2013-06-12 16:04:34 +030026
27#undef pr_fmt
28#define pr_fmt(fmt) "%s: " fmt, __func__
29
Tero Kristof38b0dd2013-06-12 16:04:34 +030030#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
31 defined(CONFIG_SOC_DRA7XX)
32static const struct clk_ops dpll_m4xen_ck_ops = {
33 .enable = &omap3_noncore_dpll_enable,
34 .disable = &omap3_noncore_dpll_disable,
35 .recalc_rate = &omap4_dpll_regm4xen_recalc,
36 .round_rate = &omap4_dpll_regm4xen_round_rate,
37 .set_rate = &omap3_noncore_dpll_set_rate,
Tero Kristo2e1a7b02014-10-03 16:57:14 +030038 .set_parent = &omap3_noncore_dpll_set_parent,
39 .set_rate_and_parent = &omap3_noncore_dpll_set_rate_and_parent,
40 .determine_rate = &omap4_dpll_regm4xen_determine_rate,
Tero Kristof38b0dd2013-06-12 16:04:34 +030041 .get_parent = &omap2_init_dpll_parent,
42};
Tero Kristoaa76fcf2014-02-21 17:36:21 +020043#else
44static const struct clk_ops dpll_m4xen_ck_ops = {};
Tero Kristof38b0dd2013-06-12 16:04:34 +030045#endif
46
Tero Kristoaa76fcf2014-02-21 17:36:21 +020047#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) || \
48 defined(CONFIG_SOC_OMAP5) || defined(CONFIG_SOC_DRA7XX) || \
49 defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
Tero Kristof38b0dd2013-06-12 16:04:34 +030050static const struct clk_ops dpll_core_ck_ops = {
51 .recalc_rate = &omap3_dpll_recalc,
52 .get_parent = &omap2_init_dpll_parent,
53};
54
Tero Kristof38b0dd2013-06-12 16:04:34 +030055static const struct clk_ops dpll_ck_ops = {
56 .enable = &omap3_noncore_dpll_enable,
57 .disable = &omap3_noncore_dpll_disable,
58 .recalc_rate = &omap3_dpll_recalc,
59 .round_rate = &omap2_dpll_round_rate,
60 .set_rate = &omap3_noncore_dpll_set_rate,
Tero Kristo2e1a7b02014-10-03 16:57:14 +030061 .set_parent = &omap3_noncore_dpll_set_parent,
62 .set_rate_and_parent = &omap3_noncore_dpll_set_rate_and_parent,
63 .determine_rate = &omap3_noncore_dpll_determine_rate,
Tero Kristof38b0dd2013-06-12 16:04:34 +030064 .get_parent = &omap2_init_dpll_parent,
65};
66
67static const struct clk_ops dpll_no_gate_ck_ops = {
68 .recalc_rate = &omap3_dpll_recalc,
69 .get_parent = &omap2_init_dpll_parent,
70 .round_rate = &omap2_dpll_round_rate,
71 .set_rate = &omap3_noncore_dpll_set_rate,
Tero Kristo2e1a7b02014-10-03 16:57:14 +030072 .set_parent = &omap3_noncore_dpll_set_parent,
73 .set_rate_and_parent = &omap3_noncore_dpll_set_rate_and_parent,
74 .determine_rate = &omap3_noncore_dpll_determine_rate,
Tero Kristof38b0dd2013-06-12 16:04:34 +030075};
Tero Kristoaa76fcf2014-02-21 17:36:21 +020076#else
77static const struct clk_ops dpll_core_ck_ops = {};
78static const struct clk_ops dpll_ck_ops = {};
79static const struct clk_ops dpll_no_gate_ck_ops = {};
80const struct clk_hw_omap_ops clkhwops_omap3_dpll = {};
81#endif
82
83#ifdef CONFIG_ARCH_OMAP2
84static const struct clk_ops omap2_dpll_core_ck_ops = {
85 .get_parent = &omap2_init_dpll_parent,
86 .recalc_rate = &omap2_dpllcore_recalc,
87 .round_rate = &omap2_dpll_round_rate,
88 .set_rate = &omap2_reprogram_dpllcore,
89};
90#else
91static const struct clk_ops omap2_dpll_core_ck_ops = {};
92#endif
93
94#ifdef CONFIG_ARCH_OMAP3
95static const struct clk_ops omap3_dpll_core_ck_ops = {
96 .get_parent = &omap2_init_dpll_parent,
97 .recalc_rate = &omap3_dpll_recalc,
98 .round_rate = &omap2_dpll_round_rate,
99};
100#else
101static const struct clk_ops omap3_dpll_core_ck_ops = {};
102#endif
Tero Kristof38b0dd2013-06-12 16:04:34 +0300103
104#ifdef CONFIG_ARCH_OMAP3
105static const struct clk_ops omap3_dpll_ck_ops = {
106 .enable = &omap3_noncore_dpll_enable,
107 .disable = &omap3_noncore_dpll_disable,
108 .get_parent = &omap2_init_dpll_parent,
109 .recalc_rate = &omap3_dpll_recalc,
110 .set_rate = &omap3_noncore_dpll_set_rate,
Tero Kristo2e1a7b02014-10-03 16:57:14 +0300111 .set_parent = &omap3_noncore_dpll_set_parent,
112 .set_rate_and_parent = &omap3_noncore_dpll_set_rate_and_parent,
113 .determine_rate = &omap3_noncore_dpll_determine_rate,
Tero Kristof38b0dd2013-06-12 16:04:34 +0300114 .round_rate = &omap2_dpll_round_rate,
115};
116
117static const struct clk_ops omap3_dpll_per_ck_ops = {
118 .enable = &omap3_noncore_dpll_enable,
119 .disable = &omap3_noncore_dpll_disable,
120 .get_parent = &omap2_init_dpll_parent,
121 .recalc_rate = &omap3_dpll_recalc,
122 .set_rate = &omap3_dpll4_set_rate,
Tero Kristo2e1a7b02014-10-03 16:57:14 +0300123 .set_parent = &omap3_noncore_dpll_set_parent,
124 .set_rate_and_parent = &omap3_dpll4_set_rate_and_parent,
125 .determine_rate = &omap3_noncore_dpll_determine_rate,
Tero Kristof38b0dd2013-06-12 16:04:34 +0300126 .round_rate = &omap2_dpll_round_rate,
127};
128#endif
129
130static const struct clk_ops dpll_x2_ck_ops = {
131 .recalc_rate = &omap3_clkoutx2_recalc,
132};
133
134/**
Tero Kristoed405a22015-01-29 22:24:28 +0200135 * _register_dpll - low level registration of a DPLL clock
Tero Kristof38b0dd2013-06-12 16:04:34 +0300136 * @hw: hardware clock definition for the clock
137 * @node: device node for the clock
138 *
139 * Finalizes DPLL registration process. In case a failure (clk-ref or
140 * clk-bypass is missing), the clock is added to retry list and
141 * the initialization is retried on later stage.
142 */
Tero Kristoed405a22015-01-29 22:24:28 +0200143static void __init _register_dpll(struct clk_hw *hw,
144 struct device_node *node)
Tero Kristof38b0dd2013-06-12 16:04:34 +0300145{
146 struct clk_hw_omap *clk_hw = to_clk_hw_omap(hw);
147 struct dpll_data *dd = clk_hw->dpll_data;
148 struct clk *clk;
149
Tero Kristob6f51282016-02-20 13:24:26 +0200150 clk = of_clk_get(node, 0);
151 if (IS_ERR(clk)) {
152 pr_debug("clk-ref missing for %s, retry later\n",
Tero Kristof38b0dd2013-06-12 16:04:34 +0300153 node->name);
Tero Kristoed405a22015-01-29 22:24:28 +0200154 if (!ti_clk_retry_init(node, hw, _register_dpll))
Tero Kristof38b0dd2013-06-12 16:04:34 +0300155 return;
156
157 goto cleanup;
158 }
159
Tero Kristob6f51282016-02-20 13:24:26 +0200160 dd->clk_ref = __clk_get_hw(clk);
161
162 clk = of_clk_get(node, 1);
163
164 if (IS_ERR(clk)) {
165 pr_debug("clk-bypass missing for %s, retry later\n",
166 node->name);
167 if (!ti_clk_retry_init(node, hw, _register_dpll))
168 return;
169
170 goto cleanup;
171 }
172
173 dd->clk_bypass = __clk_get_hw(clk);
174
Tero Kristof38b0dd2013-06-12 16:04:34 +0300175 /* register the clock */
176 clk = clk_register(NULL, &clk_hw->hw);
177
178 if (!IS_ERR(clk)) {
Stephen Boyd98d8a602015-06-29 16:56:30 -0700179 omap2_init_clk_hw_omap_clocks(&clk_hw->hw);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300180 of_clk_add_provider(node, of_clk_src_simple_get, clk);
181 kfree(clk_hw->hw.init->parent_names);
182 kfree(clk_hw->hw.init);
183 return;
184 }
185
186cleanup:
187 kfree(clk_hw->dpll_data);
188 kfree(clk_hw->hw.init->parent_names);
189 kfree(clk_hw->hw.init);
190 kfree(clk_hw);
191}
192
Arnd Bergmann6793a30a2015-02-03 17:59:32 +0100193#if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_ATAGS)
Stephen Boyd412d6b42015-05-01 12:59:32 -0700194static void __iomem *_get_reg(u8 module, u16 offset)
Tero Kristoed405a22015-01-29 22:24:28 +0200195{
196 u32 reg;
197 struct clk_omap_reg *reg_setup;
198
199 reg_setup = (struct clk_omap_reg *)&reg;
200
201 reg_setup->index = module;
202 reg_setup->offset = offset;
203
204 return (void __iomem *)reg;
205}
206
207struct clk *ti_clk_register_dpll(struct ti_clk *setup)
208{
209 struct clk_hw_omap *clk_hw;
210 struct clk_init_data init = { NULL };
211 struct dpll_data *dd;
212 struct clk *clk;
213 struct ti_clk_dpll *dpll;
214 const struct clk_ops *ops = &omap3_dpll_ck_ops;
215 struct clk *clk_ref;
216 struct clk *clk_bypass;
217
218 dpll = setup->data;
219
220 if (dpll->num_parents < 2)
221 return ERR_PTR(-EINVAL);
222
223 clk_ref = clk_get_sys(NULL, dpll->parents[0]);
224 clk_bypass = clk_get_sys(NULL, dpll->parents[1]);
225
226 if (IS_ERR_OR_NULL(clk_ref) || IS_ERR_OR_NULL(clk_bypass))
227 return ERR_PTR(-EAGAIN);
228
229 dd = kzalloc(sizeof(*dd), GFP_KERNEL);
230 clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
231 if (!dd || !clk_hw) {
232 clk = ERR_PTR(-ENOMEM);
233 goto cleanup;
234 }
235
236 clk_hw->dpll_data = dd;
237 clk_hw->ops = &clkhwops_omap3_dpll;
238 clk_hw->hw.init = &init;
239 clk_hw->flags = MEMMAP_ADDRESSING;
240
241 init.name = setup->name;
242 init.ops = ops;
243
244 init.num_parents = dpll->num_parents;
245 init.parent_names = dpll->parents;
246
247 dd->control_reg = _get_reg(dpll->module, dpll->control_reg);
248 dd->idlest_reg = _get_reg(dpll->module, dpll->idlest_reg);
249 dd->mult_div1_reg = _get_reg(dpll->module, dpll->mult_div1_reg);
250 dd->autoidle_reg = _get_reg(dpll->module, dpll->autoidle_reg);
251
252 dd->modes = dpll->modes;
253 dd->div1_mask = dpll->div1_mask;
254 dd->idlest_mask = dpll->idlest_mask;
255 dd->mult_mask = dpll->mult_mask;
256 dd->autoidle_mask = dpll->autoidle_mask;
257 dd->enable_mask = dpll->enable_mask;
258 dd->sddiv_mask = dpll->sddiv_mask;
259 dd->dco_mask = dpll->dco_mask;
260 dd->max_divider = dpll->max_divider;
261 dd->min_divider = dpll->min_divider;
262 dd->max_multiplier = dpll->max_multiplier;
263 dd->auto_recal_bit = dpll->auto_recal_bit;
264 dd->recal_en_bit = dpll->recal_en_bit;
265 dd->recal_st_bit = dpll->recal_st_bit;
266
Tero Kristob6f51282016-02-20 13:24:26 +0200267 dd->clk_ref = __clk_get_hw(clk_ref);
268 dd->clk_bypass = __clk_get_hw(clk_bypass);
Tero Kristoed405a22015-01-29 22:24:28 +0200269
270 if (dpll->flags & CLKF_CORE)
271 ops = &omap3_dpll_core_ck_ops;
272
273 if (dpll->flags & CLKF_PER)
274 ops = &omap3_dpll_per_ck_ops;
275
276 if (dpll->flags & CLKF_J_TYPE)
277 dd->flags |= DPLL_J_TYPE;
278
279 clk = clk_register(NULL, &clk_hw->hw);
280
281 if (!IS_ERR(clk))
282 return clk;
283
284cleanup:
285 kfree(dd);
286 kfree(clk_hw);
287 return clk;
288}
Arnd Bergmann6793a30a2015-02-03 17:59:32 +0100289#endif
Tero Kristoed405a22015-01-29 22:24:28 +0200290
Tero Kristof38b0dd2013-06-12 16:04:34 +0300291#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
Roger Quadros4332ec12014-06-17 17:03:24 +0300292 defined(CONFIG_SOC_DRA7XX) || defined(CONFIG_SOC_AM33XX) || \
293 defined(CONFIG_SOC_AM43XX)
Tero Kristof38b0dd2013-06-12 16:04:34 +0300294/**
Tero Kristoed405a22015-01-29 22:24:28 +0200295 * _register_dpll_x2 - Registers a DPLLx2 clock
Tero Kristof38b0dd2013-06-12 16:04:34 +0300296 * @node: device node for this clock
297 * @ops: clk_ops for this clock
298 * @hw_ops: clk_hw_ops for this clock
299 *
300 * Initializes a DPLL x 2 clock from device tree data.
301 */
Tero Kristoed405a22015-01-29 22:24:28 +0200302static void _register_dpll_x2(struct device_node *node,
303 const struct clk_ops *ops,
304 const struct clk_hw_omap_ops *hw_ops)
Tero Kristof38b0dd2013-06-12 16:04:34 +0300305{
306 struct clk *clk;
307 struct clk_init_data init = { NULL };
308 struct clk_hw_omap *clk_hw;
309 const char *name = node->name;
310 const char *parent_name;
311
312 parent_name = of_clk_get_parent_name(node, 0);
313 if (!parent_name) {
314 pr_err("%s must have parent\n", node->name);
315 return;
316 }
317
318 clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
319 if (!clk_hw)
320 return;
321
322 clk_hw->ops = hw_ops;
323 clk_hw->hw.init = &init;
324
325 init.name = name;
326 init.ops = ops;
327 init.parent_names = &parent_name;
328 init.num_parents = 1;
329
330 /* register the clock */
331 clk = clk_register(NULL, &clk_hw->hw);
332
333 if (IS_ERR(clk)) {
334 kfree(clk_hw);
335 } else {
Stephen Boyd98d8a602015-06-29 16:56:30 -0700336 omap2_init_clk_hw_omap_clocks(&clk_hw->hw);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300337 of_clk_add_provider(node, of_clk_src_simple_get, clk);
338 }
339}
340#endif
341
342/**
343 * of_ti_dpll_setup - Setup function for OMAP DPLL clocks
344 * @node: device node containing the DPLL info
345 * @ops: ops for the DPLL
346 * @ddt: DPLL data template to use
Tero Kristof38b0dd2013-06-12 16:04:34 +0300347 *
348 * Initializes a DPLL clock from device tree data.
349 */
350static void __init of_ti_dpll_setup(struct device_node *node,
351 const struct clk_ops *ops,
Tero Kristoa6fe3772014-02-21 17:22:32 +0200352 const struct dpll_data *ddt)
Tero Kristof38b0dd2013-06-12 16:04:34 +0300353{
354 struct clk_hw_omap *clk_hw = NULL;
355 struct clk_init_data *init = NULL;
356 const char **parent_names = NULL;
357 struct dpll_data *dd = NULL;
Tero Kristof38b0dd2013-06-12 16:04:34 +0300358 u8 dpll_mode = 0;
359
360 dd = kzalloc(sizeof(*dd), GFP_KERNEL);
361 clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
362 init = kzalloc(sizeof(*init), GFP_KERNEL);
363 if (!dd || !clk_hw || !init)
364 goto cleanup;
365
366 memcpy(dd, ddt, sizeof(*dd));
367
368 clk_hw->dpll_data = dd;
369 clk_hw->ops = &clkhwops_omap3_dpll;
370 clk_hw->hw.init = init;
371 clk_hw->flags = MEMMAP_ADDRESSING;
372
373 init->name = node->name;
374 init->ops = ops;
375
376 init->num_parents = of_clk_get_parent_count(node);
377 if (init->num_parents < 1) {
378 pr_err("%s must have parent(s)\n", node->name);
379 goto cleanup;
380 }
381
382 parent_names = kzalloc(sizeof(char *) * init->num_parents, GFP_KERNEL);
383 if (!parent_names)
384 goto cleanup;
385
Dinh Nguyen9da9e762015-07-06 22:59:06 -0500386 of_clk_parent_fill(node, parent_names, init->num_parents);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300387
388 init->parent_names = parent_names;
389
390 dd->control_reg = ti_clk_get_reg_addr(node, 0);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300391
Tero Kristoaa76fcf2014-02-21 17:36:21 +0200392 /*
393 * Special case for OMAP2 DPLL, register order is different due to
394 * missing idlest_reg, also clkhwops is different. Detected from
395 * missing idlest_mask.
396 */
397 if (!dd->idlest_mask) {
398 dd->mult_div1_reg = ti_clk_get_reg_addr(node, 1);
399#ifdef CONFIG_ARCH_OMAP2
400 clk_hw->ops = &clkhwops_omap2xxx_dpll;
401 omap2xxx_clkt_dpllcore_init(&clk_hw->hw);
402#endif
403 } else {
404 dd->idlest_reg = ti_clk_get_reg_addr(node, 1);
Tero Kristoc807dbe2015-02-23 21:06:08 +0200405 if (IS_ERR(dd->idlest_reg))
Tero Kristoaa76fcf2014-02-21 17:36:21 +0200406 goto cleanup;
407
408 dd->mult_div1_reg = ti_clk_get_reg_addr(node, 2);
409 }
410
Tero Kristoc807dbe2015-02-23 21:06:08 +0200411 if (IS_ERR(dd->control_reg) || IS_ERR(dd->mult_div1_reg))
Tero Kristof38b0dd2013-06-12 16:04:34 +0300412 goto cleanup;
413
Tero Kristoa6fe3772014-02-21 17:22:32 +0200414 if (dd->autoidle_mask) {
Tero Kristof38b0dd2013-06-12 16:04:34 +0300415 dd->autoidle_reg = ti_clk_get_reg_addr(node, 3);
Tero Kristoc807dbe2015-02-23 21:06:08 +0200416 if (IS_ERR(dd->autoidle_reg))
Tero Kristof38b0dd2013-06-12 16:04:34 +0300417 goto cleanup;
418 }
419
420 if (of_property_read_bool(node, "ti,low-power-stop"))
421 dpll_mode |= 1 << DPLL_LOW_POWER_STOP;
422
423 if (of_property_read_bool(node, "ti,low-power-bypass"))
424 dpll_mode |= 1 << DPLL_LOW_POWER_BYPASS;
425
426 if (of_property_read_bool(node, "ti,lock"))
427 dpll_mode |= 1 << DPLL_LOCKED;
428
429 if (dpll_mode)
430 dd->modes = dpll_mode;
431
Tero Kristoed405a22015-01-29 22:24:28 +0200432 _register_dpll(&clk_hw->hw, node);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300433 return;
434
435cleanup:
436 kfree(dd);
437 kfree(parent_names);
438 kfree(init);
439 kfree(clk_hw);
440}
441
442#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
443 defined(CONFIG_SOC_DRA7XX)
444static void __init of_ti_omap4_dpll_x2_setup(struct device_node *node)
445{
Tero Kristoed405a22015-01-29 22:24:28 +0200446 _register_dpll_x2(node, &dpll_x2_ck_ops, &clkhwops_omap4_dpllmx);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300447}
448CLK_OF_DECLARE(ti_omap4_dpll_x2_clock, "ti,omap4-dpll-x2-clock",
449 of_ti_omap4_dpll_x2_setup);
450#endif
451
Roger Quadros4332ec12014-06-17 17:03:24 +0300452#if defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
Tero Kristof38b0dd2013-06-12 16:04:34 +0300453static void __init of_ti_am3_dpll_x2_setup(struct device_node *node)
454{
Tero Kristoed405a22015-01-29 22:24:28 +0200455 _register_dpll_x2(node, &dpll_x2_ck_ops, NULL);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300456}
457CLK_OF_DECLARE(ti_am3_dpll_x2_clock, "ti,am3-dpll-x2-clock",
458 of_ti_am3_dpll_x2_setup);
459#endif
460
461#ifdef CONFIG_ARCH_OMAP3
462static void __init of_ti_omap3_dpll_setup(struct device_node *node)
463{
464 const struct dpll_data dd = {
465 .idlest_mask = 0x1,
466 .enable_mask = 0x7,
467 .autoidle_mask = 0x7,
468 .mult_mask = 0x7ff << 8,
469 .div1_mask = 0x7f,
470 .max_multiplier = 2047,
471 .max_divider = 128,
472 .min_divider = 1,
473 .freqsel_mask = 0xf0,
474 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
475 };
476
Tero Kristoa6fe3772014-02-21 17:22:32 +0200477 of_ti_dpll_setup(node, &omap3_dpll_ck_ops, &dd);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300478}
479CLK_OF_DECLARE(ti_omap3_dpll_clock, "ti,omap3-dpll-clock",
480 of_ti_omap3_dpll_setup);
481
482static void __init of_ti_omap3_core_dpll_setup(struct device_node *node)
483{
484 const struct dpll_data dd = {
485 .idlest_mask = 0x1,
486 .enable_mask = 0x7,
487 .autoidle_mask = 0x7,
488 .mult_mask = 0x7ff << 16,
489 .div1_mask = 0x7f << 8,
490 .max_multiplier = 2047,
491 .max_divider = 128,
492 .min_divider = 1,
493 .freqsel_mask = 0xf0,
494 };
495
Tero Kristoa6fe3772014-02-21 17:22:32 +0200496 of_ti_dpll_setup(node, &omap3_dpll_core_ck_ops, &dd);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300497}
498CLK_OF_DECLARE(ti_omap3_core_dpll_clock, "ti,omap3-dpll-core-clock",
499 of_ti_omap3_core_dpll_setup);
500
501static void __init of_ti_omap3_per_dpll_setup(struct device_node *node)
502{
503 const struct dpll_data dd = {
504 .idlest_mask = 0x1 << 1,
505 .enable_mask = 0x7 << 16,
506 .autoidle_mask = 0x7 << 3,
507 .mult_mask = 0x7ff << 8,
508 .div1_mask = 0x7f,
509 .max_multiplier = 2047,
510 .max_divider = 128,
511 .min_divider = 1,
512 .freqsel_mask = 0xf00000,
513 .modes = (1 << DPLL_LOW_POWER_STOP) | (1 << DPLL_LOCKED),
514 };
515
Tero Kristoa6fe3772014-02-21 17:22:32 +0200516 of_ti_dpll_setup(node, &omap3_dpll_per_ck_ops, &dd);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300517}
518CLK_OF_DECLARE(ti_omap3_per_dpll_clock, "ti,omap3-dpll-per-clock",
519 of_ti_omap3_per_dpll_setup);
520
521static void __init of_ti_omap3_per_jtype_dpll_setup(struct device_node *node)
522{
523 const struct dpll_data dd = {
524 .idlest_mask = 0x1 << 1,
525 .enable_mask = 0x7 << 16,
526 .autoidle_mask = 0x7 << 3,
527 .mult_mask = 0xfff << 8,
528 .div1_mask = 0x7f,
529 .max_multiplier = 4095,
530 .max_divider = 128,
531 .min_divider = 1,
532 .sddiv_mask = 0xff << 24,
533 .dco_mask = 0xe << 20,
534 .flags = DPLL_J_TYPE,
535 .modes = (1 << DPLL_LOW_POWER_STOP) | (1 << DPLL_LOCKED),
536 };
537
Tero Kristoa6fe3772014-02-21 17:22:32 +0200538 of_ti_dpll_setup(node, &omap3_dpll_per_ck_ops, &dd);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300539}
540CLK_OF_DECLARE(ti_omap3_per_jtype_dpll_clock, "ti,omap3-dpll-per-j-type-clock",
541 of_ti_omap3_per_jtype_dpll_setup);
542#endif
543
544static void __init of_ti_omap4_dpll_setup(struct device_node *node)
545{
546 const struct dpll_data dd = {
547 .idlest_mask = 0x1,
548 .enable_mask = 0x7,
549 .autoidle_mask = 0x7,
550 .mult_mask = 0x7ff << 8,
551 .div1_mask = 0x7f,
552 .max_multiplier = 2047,
553 .max_divider = 128,
554 .min_divider = 1,
555 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
556 };
557
Tero Kristoa6fe3772014-02-21 17:22:32 +0200558 of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300559}
560CLK_OF_DECLARE(ti_omap4_dpll_clock, "ti,omap4-dpll-clock",
561 of_ti_omap4_dpll_setup);
562
Nishanth Menonb4be0182014-05-16 05:45:59 -0500563static void __init of_ti_omap5_mpu_dpll_setup(struct device_node *node)
564{
565 const struct dpll_data dd = {
566 .idlest_mask = 0x1,
567 .enable_mask = 0x7,
568 .autoidle_mask = 0x7,
569 .mult_mask = 0x7ff << 8,
570 .div1_mask = 0x7f,
571 .max_multiplier = 2047,
572 .max_divider = 128,
573 .dcc_mask = BIT(22),
574 .dcc_rate = 1400000000, /* DCC beyond 1.4GHz */
575 .min_divider = 1,
576 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
577 };
578
579 of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
580}
581CLK_OF_DECLARE(of_ti_omap5_mpu_dpll_clock, "ti,omap5-mpu-dpll-clock",
582 of_ti_omap5_mpu_dpll_setup);
583
Tero Kristof38b0dd2013-06-12 16:04:34 +0300584static void __init of_ti_omap4_core_dpll_setup(struct device_node *node)
585{
586 const struct dpll_data dd = {
587 .idlest_mask = 0x1,
588 .enable_mask = 0x7,
589 .autoidle_mask = 0x7,
590 .mult_mask = 0x7ff << 8,
591 .div1_mask = 0x7f,
592 .max_multiplier = 2047,
593 .max_divider = 128,
594 .min_divider = 1,
595 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
596 };
597
Tero Kristoa6fe3772014-02-21 17:22:32 +0200598 of_ti_dpll_setup(node, &dpll_core_ck_ops, &dd);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300599}
600CLK_OF_DECLARE(ti_omap4_core_dpll_clock, "ti,omap4-dpll-core-clock",
601 of_ti_omap4_core_dpll_setup);
602
603#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
604 defined(CONFIG_SOC_DRA7XX)
605static void __init of_ti_omap4_m4xen_dpll_setup(struct device_node *node)
606{
607 const struct dpll_data dd = {
608 .idlest_mask = 0x1,
609 .enable_mask = 0x7,
610 .autoidle_mask = 0x7,
611 .mult_mask = 0x7ff << 8,
612 .div1_mask = 0x7f,
613 .max_multiplier = 2047,
614 .max_divider = 128,
615 .min_divider = 1,
616 .m4xen_mask = 0x800,
617 .lpmode_mask = 1 << 10,
618 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
619 };
620
Tero Kristoa6fe3772014-02-21 17:22:32 +0200621 of_ti_dpll_setup(node, &dpll_m4xen_ck_ops, &dd);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300622}
623CLK_OF_DECLARE(ti_omap4_m4xen_dpll_clock, "ti,omap4-dpll-m4xen-clock",
624 of_ti_omap4_m4xen_dpll_setup);
625
626static void __init of_ti_omap4_jtype_dpll_setup(struct device_node *node)
627{
628 const struct dpll_data dd = {
629 .idlest_mask = 0x1,
630 .enable_mask = 0x7,
631 .autoidle_mask = 0x7,
632 .mult_mask = 0xfff << 8,
633 .div1_mask = 0xff,
634 .max_multiplier = 4095,
635 .max_divider = 256,
636 .min_divider = 1,
637 .sddiv_mask = 0xff << 24,
638 .flags = DPLL_J_TYPE,
639 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
640 };
641
Tero Kristoa6fe3772014-02-21 17:22:32 +0200642 of_ti_dpll_setup(node, &dpll_m4xen_ck_ops, &dd);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300643}
644CLK_OF_DECLARE(ti_omap4_jtype_dpll_clock, "ti,omap4-dpll-j-type-clock",
645 of_ti_omap4_jtype_dpll_setup);
646#endif
647
648static void __init of_ti_am3_no_gate_dpll_setup(struct device_node *node)
649{
650 const struct dpll_data dd = {
651 .idlest_mask = 0x1,
652 .enable_mask = 0x7,
Tero Kristof38b0dd2013-06-12 16:04:34 +0300653 .mult_mask = 0x7ff << 8,
654 .div1_mask = 0x7f,
655 .max_multiplier = 2047,
656 .max_divider = 128,
657 .min_divider = 1,
658 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
659 };
660
Tero Kristoa6fe3772014-02-21 17:22:32 +0200661 of_ti_dpll_setup(node, &dpll_no_gate_ck_ops, &dd);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300662}
663CLK_OF_DECLARE(ti_am3_no_gate_dpll_clock, "ti,am3-dpll-no-gate-clock",
664 of_ti_am3_no_gate_dpll_setup);
665
666static void __init of_ti_am3_jtype_dpll_setup(struct device_node *node)
667{
668 const struct dpll_data dd = {
669 .idlest_mask = 0x1,
670 .enable_mask = 0x7,
Tero Kristof38b0dd2013-06-12 16:04:34 +0300671 .mult_mask = 0x7ff << 8,
672 .div1_mask = 0x7f,
673 .max_multiplier = 4095,
674 .max_divider = 256,
675 .min_divider = 2,
676 .flags = DPLL_J_TYPE,
677 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
678 };
679
Tero Kristoa6fe3772014-02-21 17:22:32 +0200680 of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300681}
682CLK_OF_DECLARE(ti_am3_jtype_dpll_clock, "ti,am3-dpll-j-type-clock",
683 of_ti_am3_jtype_dpll_setup);
684
685static void __init of_ti_am3_no_gate_jtype_dpll_setup(struct device_node *node)
686{
687 const struct dpll_data dd = {
688 .idlest_mask = 0x1,
689 .enable_mask = 0x7,
Tero Kristof38b0dd2013-06-12 16:04:34 +0300690 .mult_mask = 0x7ff << 8,
691 .div1_mask = 0x7f,
692 .max_multiplier = 2047,
693 .max_divider = 128,
694 .min_divider = 1,
695 .flags = DPLL_J_TYPE,
696 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
697 };
698
Tero Kristoa6fe3772014-02-21 17:22:32 +0200699 of_ti_dpll_setup(node, &dpll_no_gate_ck_ops, &dd);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300700}
701CLK_OF_DECLARE(ti_am3_no_gate_jtype_dpll_clock,
702 "ti,am3-dpll-no-gate-j-type-clock",
703 of_ti_am3_no_gate_jtype_dpll_setup);
704
705static void __init of_ti_am3_dpll_setup(struct device_node *node)
706{
707 const struct dpll_data dd = {
708 .idlest_mask = 0x1,
709 .enable_mask = 0x7,
Tero Kristof38b0dd2013-06-12 16:04:34 +0300710 .mult_mask = 0x7ff << 8,
711 .div1_mask = 0x7f,
712 .max_multiplier = 2047,
713 .max_divider = 128,
714 .min_divider = 1,
715 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
716 };
717
Tero Kristoa6fe3772014-02-21 17:22:32 +0200718 of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300719}
720CLK_OF_DECLARE(ti_am3_dpll_clock, "ti,am3-dpll-clock", of_ti_am3_dpll_setup);
721
722static void __init of_ti_am3_core_dpll_setup(struct device_node *node)
723{
724 const struct dpll_data dd = {
725 .idlest_mask = 0x1,
726 .enable_mask = 0x7,
Tero Kristof38b0dd2013-06-12 16:04:34 +0300727 .mult_mask = 0x7ff << 8,
728 .div1_mask = 0x7f,
729 .max_multiplier = 2047,
730 .max_divider = 128,
731 .min_divider = 1,
732 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
733 };
734
Tero Kristoa6fe3772014-02-21 17:22:32 +0200735 of_ti_dpll_setup(node, &dpll_core_ck_ops, &dd);
Tero Kristof38b0dd2013-06-12 16:04:34 +0300736}
737CLK_OF_DECLARE(ti_am3_core_dpll_clock, "ti,am3-dpll-core-clock",
738 of_ti_am3_core_dpll_setup);
Tero Kristoaa76fcf2014-02-21 17:36:21 +0200739
740static void __init of_ti_omap2_core_dpll_setup(struct device_node *node)
741{
742 const struct dpll_data dd = {
743 .enable_mask = 0x3,
744 .mult_mask = 0x3ff << 12,
745 .div1_mask = 0xf << 8,
746 .max_divider = 16,
747 .min_divider = 1,
748 };
749
750 of_ti_dpll_setup(node, &omap2_dpll_core_ck_ops, &dd);
751}
752CLK_OF_DECLARE(ti_omap2_core_dpll_clock, "ti,omap2-dpll-core-clock",
753 of_ti_omap2_core_dpll_setup);