xref: /openbmc/linux/drivers/clk/ti/dpll.c (revision 2e1a7b014f9c3d61fbf12b429f0479242264dbec)
1f38b0dd6STero Kristo /*
2f38b0dd6STero Kristo  * OMAP DPLL clock support
3f38b0dd6STero Kristo  *
4f38b0dd6STero Kristo  * Copyright (C) 2013 Texas Instruments, Inc.
5f38b0dd6STero Kristo  *
6f38b0dd6STero Kristo  * Tero Kristo <t-kristo@ti.com>
7f38b0dd6STero Kristo  *
8f38b0dd6STero Kristo  * This program is free software; you can redistribute it and/or modify
9f38b0dd6STero Kristo  * it under the terms of the GNU General Public License version 2 as
10f38b0dd6STero Kristo  * published by the Free Software Foundation.
11f38b0dd6STero Kristo  *
12f38b0dd6STero Kristo  * This program is distributed "as is" WITHOUT ANY WARRANTY of any
13f38b0dd6STero Kristo  * kind, whether express or implied; without even the implied warranty
14f38b0dd6STero Kristo  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15f38b0dd6STero Kristo  * GNU General Public License for more details.
16f38b0dd6STero Kristo  */
17f38b0dd6STero Kristo 
18f38b0dd6STero Kristo #include <linux/clk-provider.h>
19f38b0dd6STero Kristo #include <linux/slab.h>
20f38b0dd6STero Kristo #include <linux/err.h>
21f38b0dd6STero Kristo #include <linux/of.h>
22f38b0dd6STero Kristo #include <linux/of_address.h>
23f38b0dd6STero Kristo #include <linux/clk/ti.h>
24f38b0dd6STero Kristo 
25f38b0dd6STero Kristo #undef pr_fmt
26f38b0dd6STero Kristo #define pr_fmt(fmt) "%s: " fmt, __func__
27f38b0dd6STero Kristo 
28f38b0dd6STero Kristo #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
29f38b0dd6STero Kristo 	defined(CONFIG_SOC_DRA7XX)
30f38b0dd6STero Kristo static const struct clk_ops dpll_m4xen_ck_ops = {
31f38b0dd6STero Kristo 	.enable		= &omap3_noncore_dpll_enable,
32f38b0dd6STero Kristo 	.disable	= &omap3_noncore_dpll_disable,
33f38b0dd6STero Kristo 	.recalc_rate	= &omap4_dpll_regm4xen_recalc,
34f38b0dd6STero Kristo 	.round_rate	= &omap4_dpll_regm4xen_round_rate,
35f38b0dd6STero Kristo 	.set_rate	= &omap3_noncore_dpll_set_rate,
36*2e1a7b01STero Kristo 	.set_parent	= &omap3_noncore_dpll_set_parent,
37*2e1a7b01STero Kristo 	.set_rate_and_parent	= &omap3_noncore_dpll_set_rate_and_parent,
38*2e1a7b01STero Kristo 	.determine_rate	= &omap4_dpll_regm4xen_determine_rate,
39f38b0dd6STero Kristo 	.get_parent	= &omap2_init_dpll_parent,
40f38b0dd6STero Kristo };
41aa76fcf4STero Kristo #else
42aa76fcf4STero Kristo static const struct clk_ops dpll_m4xen_ck_ops = {};
43f38b0dd6STero Kristo #endif
44f38b0dd6STero Kristo 
45aa76fcf4STero Kristo #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) || \
46aa76fcf4STero Kristo 	defined(CONFIG_SOC_OMAP5) || defined(CONFIG_SOC_DRA7XX) || \
47aa76fcf4STero Kristo 	defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
48f38b0dd6STero Kristo static const struct clk_ops dpll_core_ck_ops = {
49f38b0dd6STero Kristo 	.recalc_rate	= &omap3_dpll_recalc,
50f38b0dd6STero Kristo 	.get_parent	= &omap2_init_dpll_parent,
51f38b0dd6STero Kristo };
52f38b0dd6STero Kristo 
53f38b0dd6STero Kristo static const struct clk_ops dpll_ck_ops = {
54f38b0dd6STero Kristo 	.enable		= &omap3_noncore_dpll_enable,
55f38b0dd6STero Kristo 	.disable	= &omap3_noncore_dpll_disable,
56f38b0dd6STero Kristo 	.recalc_rate	= &omap3_dpll_recalc,
57f38b0dd6STero Kristo 	.round_rate	= &omap2_dpll_round_rate,
58f38b0dd6STero Kristo 	.set_rate	= &omap3_noncore_dpll_set_rate,
59*2e1a7b01STero Kristo 	.set_parent	= &omap3_noncore_dpll_set_parent,
60*2e1a7b01STero Kristo 	.set_rate_and_parent	= &omap3_noncore_dpll_set_rate_and_parent,
61*2e1a7b01STero Kristo 	.determine_rate	= &omap3_noncore_dpll_determine_rate,
62f38b0dd6STero Kristo 	.get_parent	= &omap2_init_dpll_parent,
63f38b0dd6STero Kristo };
64f38b0dd6STero Kristo 
65f38b0dd6STero Kristo static const struct clk_ops dpll_no_gate_ck_ops = {
66f38b0dd6STero Kristo 	.recalc_rate	= &omap3_dpll_recalc,
67f38b0dd6STero Kristo 	.get_parent	= &omap2_init_dpll_parent,
68f38b0dd6STero Kristo 	.round_rate	= &omap2_dpll_round_rate,
69f38b0dd6STero Kristo 	.set_rate	= &omap3_noncore_dpll_set_rate,
70*2e1a7b01STero Kristo 	.set_parent	= &omap3_noncore_dpll_set_parent,
71*2e1a7b01STero Kristo 	.set_rate_and_parent	= &omap3_noncore_dpll_set_rate_and_parent,
72*2e1a7b01STero Kristo 	.determine_rate	= &omap3_noncore_dpll_determine_rate,
73f38b0dd6STero Kristo };
74aa76fcf4STero Kristo #else
75aa76fcf4STero Kristo static const struct clk_ops dpll_core_ck_ops = {};
76aa76fcf4STero Kristo static const struct clk_ops dpll_ck_ops = {};
77aa76fcf4STero Kristo static const struct clk_ops dpll_no_gate_ck_ops = {};
78aa76fcf4STero Kristo const struct clk_hw_omap_ops clkhwops_omap3_dpll = {};
79aa76fcf4STero Kristo #endif
80aa76fcf4STero Kristo 
81aa76fcf4STero Kristo #ifdef CONFIG_ARCH_OMAP2
82aa76fcf4STero Kristo static const struct clk_ops omap2_dpll_core_ck_ops = {
83aa76fcf4STero Kristo 	.get_parent	= &omap2_init_dpll_parent,
84aa76fcf4STero Kristo 	.recalc_rate	= &omap2_dpllcore_recalc,
85aa76fcf4STero Kristo 	.round_rate	= &omap2_dpll_round_rate,
86aa76fcf4STero Kristo 	.set_rate	= &omap2_reprogram_dpllcore,
87aa76fcf4STero Kristo };
88aa76fcf4STero Kristo #else
89aa76fcf4STero Kristo static const struct clk_ops omap2_dpll_core_ck_ops = {};
90aa76fcf4STero Kristo #endif
91aa76fcf4STero Kristo 
92aa76fcf4STero Kristo #ifdef CONFIG_ARCH_OMAP3
93aa76fcf4STero Kristo static const struct clk_ops omap3_dpll_core_ck_ops = {
94aa76fcf4STero Kristo 	.get_parent	= &omap2_init_dpll_parent,
95aa76fcf4STero Kristo 	.recalc_rate	= &omap3_dpll_recalc,
96aa76fcf4STero Kristo 	.round_rate	= &omap2_dpll_round_rate,
97aa76fcf4STero Kristo };
98aa76fcf4STero Kristo #else
99aa76fcf4STero Kristo static const struct clk_ops omap3_dpll_core_ck_ops = {};
100aa76fcf4STero Kristo #endif
101f38b0dd6STero Kristo 
102f38b0dd6STero Kristo #ifdef CONFIG_ARCH_OMAP3
103f38b0dd6STero Kristo static const struct clk_ops omap3_dpll_ck_ops = {
104f38b0dd6STero Kristo 	.enable		= &omap3_noncore_dpll_enable,
105f38b0dd6STero Kristo 	.disable	= &omap3_noncore_dpll_disable,
106f38b0dd6STero Kristo 	.get_parent	= &omap2_init_dpll_parent,
107f38b0dd6STero Kristo 	.recalc_rate	= &omap3_dpll_recalc,
108f38b0dd6STero Kristo 	.set_rate	= &omap3_noncore_dpll_set_rate,
109*2e1a7b01STero Kristo 	.set_parent	= &omap3_noncore_dpll_set_parent,
110*2e1a7b01STero Kristo 	.set_rate_and_parent	= &omap3_noncore_dpll_set_rate_and_parent,
111*2e1a7b01STero Kristo 	.determine_rate	= &omap3_noncore_dpll_determine_rate,
112f38b0dd6STero Kristo 	.round_rate	= &omap2_dpll_round_rate,
113f38b0dd6STero Kristo };
114f38b0dd6STero Kristo 
115f38b0dd6STero Kristo static const struct clk_ops omap3_dpll_per_ck_ops = {
116f38b0dd6STero Kristo 	.enable		= &omap3_noncore_dpll_enable,
117f38b0dd6STero Kristo 	.disable	= &omap3_noncore_dpll_disable,
118f38b0dd6STero Kristo 	.get_parent	= &omap2_init_dpll_parent,
119f38b0dd6STero Kristo 	.recalc_rate	= &omap3_dpll_recalc,
120f38b0dd6STero Kristo 	.set_rate	= &omap3_dpll4_set_rate,
121*2e1a7b01STero Kristo 	.set_parent	= &omap3_noncore_dpll_set_parent,
122*2e1a7b01STero Kristo 	.set_rate_and_parent	= &omap3_dpll4_set_rate_and_parent,
123*2e1a7b01STero Kristo 	.determine_rate	= &omap3_noncore_dpll_determine_rate,
124f38b0dd6STero Kristo 	.round_rate	= &omap2_dpll_round_rate,
125f38b0dd6STero Kristo };
126f38b0dd6STero Kristo #endif
127f38b0dd6STero Kristo 
128f38b0dd6STero Kristo static const struct clk_ops dpll_x2_ck_ops = {
129f38b0dd6STero Kristo 	.recalc_rate	= &omap3_clkoutx2_recalc,
130f38b0dd6STero Kristo };
131f38b0dd6STero Kristo 
132f38b0dd6STero Kristo /**
133f38b0dd6STero Kristo  * ti_clk_register_dpll - low level registration of a DPLL clock
134f38b0dd6STero Kristo  * @hw: hardware clock definition for the clock
135f38b0dd6STero Kristo  * @node: device node for the clock
136f38b0dd6STero Kristo  *
137f38b0dd6STero Kristo  * Finalizes DPLL registration process. In case a failure (clk-ref or
138f38b0dd6STero Kristo  * clk-bypass is missing), the clock is added to retry list and
139f38b0dd6STero Kristo  * the initialization is retried on later stage.
140f38b0dd6STero Kristo  */
141f38b0dd6STero Kristo static void __init ti_clk_register_dpll(struct clk_hw *hw,
142f38b0dd6STero Kristo 					struct device_node *node)
143f38b0dd6STero Kristo {
144f38b0dd6STero Kristo 	struct clk_hw_omap *clk_hw = to_clk_hw_omap(hw);
145f38b0dd6STero Kristo 	struct dpll_data *dd = clk_hw->dpll_data;
146f38b0dd6STero Kristo 	struct clk *clk;
147f38b0dd6STero Kristo 
148f38b0dd6STero Kristo 	dd->clk_ref = of_clk_get(node, 0);
149f38b0dd6STero Kristo 	dd->clk_bypass = of_clk_get(node, 1);
150f38b0dd6STero Kristo 
151f38b0dd6STero Kristo 	if (IS_ERR(dd->clk_ref) || IS_ERR(dd->clk_bypass)) {
152f38b0dd6STero Kristo 		pr_debug("clk-ref or clk-bypass missing for %s, retry later\n",
153f38b0dd6STero Kristo 			 node->name);
154f38b0dd6STero Kristo 		if (!ti_clk_retry_init(node, hw, ti_clk_register_dpll))
155f38b0dd6STero Kristo 			return;
156f38b0dd6STero Kristo 
157f38b0dd6STero Kristo 		goto cleanup;
158f38b0dd6STero Kristo 	}
159f38b0dd6STero Kristo 
160f38b0dd6STero Kristo 	/* register the clock */
161f38b0dd6STero Kristo 	clk = clk_register(NULL, &clk_hw->hw);
162f38b0dd6STero Kristo 
163f38b0dd6STero Kristo 	if (!IS_ERR(clk)) {
164f38b0dd6STero Kristo 		omap2_init_clk_hw_omap_clocks(clk);
165f38b0dd6STero Kristo 		of_clk_add_provider(node, of_clk_src_simple_get, clk);
166f38b0dd6STero Kristo 		kfree(clk_hw->hw.init->parent_names);
167f38b0dd6STero Kristo 		kfree(clk_hw->hw.init);
168f38b0dd6STero Kristo 		return;
169f38b0dd6STero Kristo 	}
170f38b0dd6STero Kristo 
171f38b0dd6STero Kristo cleanup:
172f38b0dd6STero Kristo 	kfree(clk_hw->dpll_data);
173f38b0dd6STero Kristo 	kfree(clk_hw->hw.init->parent_names);
174f38b0dd6STero Kristo 	kfree(clk_hw->hw.init);
175f38b0dd6STero Kristo 	kfree(clk_hw);
176f38b0dd6STero Kristo }
177f38b0dd6STero Kristo 
178f38b0dd6STero Kristo #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
1794332ec1aSRoger Quadros 	defined(CONFIG_SOC_DRA7XX) || defined(CONFIG_SOC_AM33XX) || \
1804332ec1aSRoger Quadros 	defined(CONFIG_SOC_AM43XX)
181f38b0dd6STero Kristo /**
182f38b0dd6STero Kristo  * ti_clk_register_dpll_x2 - Registers a DPLLx2 clock
183f38b0dd6STero Kristo  * @node: device node for this clock
184f38b0dd6STero Kristo  * @ops: clk_ops for this clock
185f38b0dd6STero Kristo  * @hw_ops: clk_hw_ops for this clock
186f38b0dd6STero Kristo  *
187f38b0dd6STero Kristo  * Initializes a DPLL x 2 clock from device tree data.
188f38b0dd6STero Kristo  */
189f38b0dd6STero Kristo static void ti_clk_register_dpll_x2(struct device_node *node,
190f38b0dd6STero Kristo 				    const struct clk_ops *ops,
191f38b0dd6STero Kristo 				    const struct clk_hw_omap_ops *hw_ops)
192f38b0dd6STero Kristo {
193f38b0dd6STero Kristo 	struct clk *clk;
194f38b0dd6STero Kristo 	struct clk_init_data init = { NULL };
195f38b0dd6STero Kristo 	struct clk_hw_omap *clk_hw;
196f38b0dd6STero Kristo 	const char *name = node->name;
197f38b0dd6STero Kristo 	const char *parent_name;
198f38b0dd6STero Kristo 
199f38b0dd6STero Kristo 	parent_name = of_clk_get_parent_name(node, 0);
200f38b0dd6STero Kristo 	if (!parent_name) {
201f38b0dd6STero Kristo 		pr_err("%s must have parent\n", node->name);
202f38b0dd6STero Kristo 		return;
203f38b0dd6STero Kristo 	}
204f38b0dd6STero Kristo 
205f38b0dd6STero Kristo 	clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
206f38b0dd6STero Kristo 	if (!clk_hw)
207f38b0dd6STero Kristo 		return;
208f38b0dd6STero Kristo 
209f38b0dd6STero Kristo 	clk_hw->ops = hw_ops;
210f38b0dd6STero Kristo 	clk_hw->hw.init = &init;
211f38b0dd6STero Kristo 
212f38b0dd6STero Kristo 	init.name = name;
213f38b0dd6STero Kristo 	init.ops = ops;
214f38b0dd6STero Kristo 	init.parent_names = &parent_name;
215f38b0dd6STero Kristo 	init.num_parents = 1;
216f38b0dd6STero Kristo 
217f38b0dd6STero Kristo 	/* register the clock */
218f38b0dd6STero Kristo 	clk = clk_register(NULL, &clk_hw->hw);
219f38b0dd6STero Kristo 
220f38b0dd6STero Kristo 	if (IS_ERR(clk)) {
221f38b0dd6STero Kristo 		kfree(clk_hw);
222f38b0dd6STero Kristo 	} else {
223f38b0dd6STero Kristo 		omap2_init_clk_hw_omap_clocks(clk);
224f38b0dd6STero Kristo 		of_clk_add_provider(node, of_clk_src_simple_get, clk);
225f38b0dd6STero Kristo 	}
226f38b0dd6STero Kristo }
227f38b0dd6STero Kristo #endif
228f38b0dd6STero Kristo 
229f38b0dd6STero Kristo /**
230f38b0dd6STero Kristo  * of_ti_dpll_setup - Setup function for OMAP DPLL clocks
231f38b0dd6STero Kristo  * @node: device node containing the DPLL info
232f38b0dd6STero Kristo  * @ops: ops for the DPLL
233f38b0dd6STero Kristo  * @ddt: DPLL data template to use
234f38b0dd6STero Kristo  *
235f38b0dd6STero Kristo  * Initializes a DPLL clock from device tree data.
236f38b0dd6STero Kristo  */
237f38b0dd6STero Kristo static void __init of_ti_dpll_setup(struct device_node *node,
238f38b0dd6STero Kristo 				    const struct clk_ops *ops,
239a6fe3771STero Kristo 				    const struct dpll_data *ddt)
240f38b0dd6STero Kristo {
241f38b0dd6STero Kristo 	struct clk_hw_omap *clk_hw = NULL;
242f38b0dd6STero Kristo 	struct clk_init_data *init = NULL;
243f38b0dd6STero Kristo 	const char **parent_names = NULL;
244f38b0dd6STero Kristo 	struct dpll_data *dd = NULL;
245f38b0dd6STero Kristo 	int i;
246f38b0dd6STero Kristo 	u8 dpll_mode = 0;
247f38b0dd6STero Kristo 
248f38b0dd6STero Kristo 	dd = kzalloc(sizeof(*dd), GFP_KERNEL);
249f38b0dd6STero Kristo 	clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
250f38b0dd6STero Kristo 	init = kzalloc(sizeof(*init), GFP_KERNEL);
251f38b0dd6STero Kristo 	if (!dd || !clk_hw || !init)
252f38b0dd6STero Kristo 		goto cleanup;
253f38b0dd6STero Kristo 
254f38b0dd6STero Kristo 	memcpy(dd, ddt, sizeof(*dd));
255f38b0dd6STero Kristo 
256f38b0dd6STero Kristo 	clk_hw->dpll_data = dd;
257f38b0dd6STero Kristo 	clk_hw->ops = &clkhwops_omap3_dpll;
258f38b0dd6STero Kristo 	clk_hw->hw.init = init;
259f38b0dd6STero Kristo 	clk_hw->flags = MEMMAP_ADDRESSING;
260f38b0dd6STero Kristo 
261f38b0dd6STero Kristo 	init->name = node->name;
262f38b0dd6STero Kristo 	init->ops = ops;
263f38b0dd6STero Kristo 
264f38b0dd6STero Kristo 	init->num_parents = of_clk_get_parent_count(node);
265f38b0dd6STero Kristo 	if (init->num_parents < 1) {
266f38b0dd6STero Kristo 		pr_err("%s must have parent(s)\n", node->name);
267f38b0dd6STero Kristo 		goto cleanup;
268f38b0dd6STero Kristo 	}
269f38b0dd6STero Kristo 
270f38b0dd6STero Kristo 	parent_names = kzalloc(sizeof(char *) * init->num_parents, GFP_KERNEL);
271f38b0dd6STero Kristo 	if (!parent_names)
272f38b0dd6STero Kristo 		goto cleanup;
273f38b0dd6STero Kristo 
274f38b0dd6STero Kristo 	for (i = 0; i < init->num_parents; i++)
275f38b0dd6STero Kristo 		parent_names[i] = of_clk_get_parent_name(node, i);
276f38b0dd6STero Kristo 
277f38b0dd6STero Kristo 	init->parent_names = parent_names;
278f38b0dd6STero Kristo 
279f38b0dd6STero Kristo 	dd->control_reg = ti_clk_get_reg_addr(node, 0);
280f38b0dd6STero Kristo 
281aa76fcf4STero Kristo 	/*
282aa76fcf4STero Kristo 	 * Special case for OMAP2 DPLL, register order is different due to
283aa76fcf4STero Kristo 	 * missing idlest_reg, also clkhwops is different. Detected from
284aa76fcf4STero Kristo 	 * missing idlest_mask.
285aa76fcf4STero Kristo 	 */
286aa76fcf4STero Kristo 	if (!dd->idlest_mask) {
287aa76fcf4STero Kristo 		dd->mult_div1_reg = ti_clk_get_reg_addr(node, 1);
288aa76fcf4STero Kristo #ifdef CONFIG_ARCH_OMAP2
289aa76fcf4STero Kristo 		clk_hw->ops = &clkhwops_omap2xxx_dpll;
290aa76fcf4STero Kristo 		omap2xxx_clkt_dpllcore_init(&clk_hw->hw);
291aa76fcf4STero Kristo #endif
292aa76fcf4STero Kristo 	} else {
293aa76fcf4STero Kristo 		dd->idlest_reg = ti_clk_get_reg_addr(node, 1);
294aa76fcf4STero Kristo 		if (!dd->idlest_reg)
295aa76fcf4STero Kristo 			goto cleanup;
296aa76fcf4STero Kristo 
297aa76fcf4STero Kristo 		dd->mult_div1_reg = ti_clk_get_reg_addr(node, 2);
298aa76fcf4STero Kristo 	}
299aa76fcf4STero Kristo 
300aa76fcf4STero Kristo 	if (!dd->control_reg || !dd->mult_div1_reg)
301f38b0dd6STero Kristo 		goto cleanup;
302f38b0dd6STero Kristo 
303a6fe3771STero Kristo 	if (dd->autoidle_mask) {
304f38b0dd6STero Kristo 		dd->autoidle_reg = ti_clk_get_reg_addr(node, 3);
305f38b0dd6STero Kristo 		if (!dd->autoidle_reg)
306f38b0dd6STero Kristo 			goto cleanup;
307f38b0dd6STero Kristo 	}
308f38b0dd6STero Kristo 
309f38b0dd6STero Kristo 	if (of_property_read_bool(node, "ti,low-power-stop"))
310f38b0dd6STero Kristo 		dpll_mode |= 1 << DPLL_LOW_POWER_STOP;
311f38b0dd6STero Kristo 
312f38b0dd6STero Kristo 	if (of_property_read_bool(node, "ti,low-power-bypass"))
313f38b0dd6STero Kristo 		dpll_mode |= 1 << DPLL_LOW_POWER_BYPASS;
314f38b0dd6STero Kristo 
315f38b0dd6STero Kristo 	if (of_property_read_bool(node, "ti,lock"))
316f38b0dd6STero Kristo 		dpll_mode |= 1 << DPLL_LOCKED;
317f38b0dd6STero Kristo 
318f38b0dd6STero Kristo 	if (dpll_mode)
319f38b0dd6STero Kristo 		dd->modes = dpll_mode;
320f38b0dd6STero Kristo 
321f38b0dd6STero Kristo 	ti_clk_register_dpll(&clk_hw->hw, node);
322f38b0dd6STero Kristo 	return;
323f38b0dd6STero Kristo 
324f38b0dd6STero Kristo cleanup:
325f38b0dd6STero Kristo 	kfree(dd);
326f38b0dd6STero Kristo 	kfree(parent_names);
327f38b0dd6STero Kristo 	kfree(init);
328f38b0dd6STero Kristo 	kfree(clk_hw);
329f38b0dd6STero Kristo }
330f38b0dd6STero Kristo 
331f38b0dd6STero Kristo #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
332f38b0dd6STero Kristo 	defined(CONFIG_SOC_DRA7XX)
333f38b0dd6STero Kristo static void __init of_ti_omap4_dpll_x2_setup(struct device_node *node)
334f38b0dd6STero Kristo {
335f38b0dd6STero Kristo 	ti_clk_register_dpll_x2(node, &dpll_x2_ck_ops, &clkhwops_omap4_dpllmx);
336f38b0dd6STero Kristo }
337f38b0dd6STero Kristo CLK_OF_DECLARE(ti_omap4_dpll_x2_clock, "ti,omap4-dpll-x2-clock",
338f38b0dd6STero Kristo 	       of_ti_omap4_dpll_x2_setup);
339f38b0dd6STero Kristo #endif
340f38b0dd6STero Kristo 
3414332ec1aSRoger Quadros #if defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
342f38b0dd6STero Kristo static void __init of_ti_am3_dpll_x2_setup(struct device_node *node)
343f38b0dd6STero Kristo {
344f38b0dd6STero Kristo 	ti_clk_register_dpll_x2(node, &dpll_x2_ck_ops, NULL);
345f38b0dd6STero Kristo }
346f38b0dd6STero Kristo CLK_OF_DECLARE(ti_am3_dpll_x2_clock, "ti,am3-dpll-x2-clock",
347f38b0dd6STero Kristo 	       of_ti_am3_dpll_x2_setup);
348f38b0dd6STero Kristo #endif
349f38b0dd6STero Kristo 
350f38b0dd6STero Kristo #ifdef CONFIG_ARCH_OMAP3
351f38b0dd6STero Kristo static void __init of_ti_omap3_dpll_setup(struct device_node *node)
352f38b0dd6STero Kristo {
353f38b0dd6STero Kristo 	const struct dpll_data dd = {
354f38b0dd6STero Kristo 		.idlest_mask = 0x1,
355f38b0dd6STero Kristo 		.enable_mask = 0x7,
356f38b0dd6STero Kristo 		.autoidle_mask = 0x7,
357f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
358f38b0dd6STero Kristo 		.div1_mask = 0x7f,
359f38b0dd6STero Kristo 		.max_multiplier = 2047,
360f38b0dd6STero Kristo 		.max_divider = 128,
361f38b0dd6STero Kristo 		.min_divider = 1,
362f38b0dd6STero Kristo 		.freqsel_mask = 0xf0,
363f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
364f38b0dd6STero Kristo 	};
365f38b0dd6STero Kristo 
366a6fe3771STero Kristo 	of_ti_dpll_setup(node, &omap3_dpll_ck_ops, &dd);
367f38b0dd6STero Kristo }
368f38b0dd6STero Kristo CLK_OF_DECLARE(ti_omap3_dpll_clock, "ti,omap3-dpll-clock",
369f38b0dd6STero Kristo 	       of_ti_omap3_dpll_setup);
370f38b0dd6STero Kristo 
371f38b0dd6STero Kristo static void __init of_ti_omap3_core_dpll_setup(struct device_node *node)
372f38b0dd6STero Kristo {
373f38b0dd6STero Kristo 	const struct dpll_data dd = {
374f38b0dd6STero Kristo 		.idlest_mask = 0x1,
375f38b0dd6STero Kristo 		.enable_mask = 0x7,
376f38b0dd6STero Kristo 		.autoidle_mask = 0x7,
377f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 16,
378f38b0dd6STero Kristo 		.div1_mask = 0x7f << 8,
379f38b0dd6STero Kristo 		.max_multiplier = 2047,
380f38b0dd6STero Kristo 		.max_divider = 128,
381f38b0dd6STero Kristo 		.min_divider = 1,
382f38b0dd6STero Kristo 		.freqsel_mask = 0xf0,
383f38b0dd6STero Kristo 	};
384f38b0dd6STero Kristo 
385a6fe3771STero Kristo 	of_ti_dpll_setup(node, &omap3_dpll_core_ck_ops, &dd);
386f38b0dd6STero Kristo }
387f38b0dd6STero Kristo CLK_OF_DECLARE(ti_omap3_core_dpll_clock, "ti,omap3-dpll-core-clock",
388f38b0dd6STero Kristo 	       of_ti_omap3_core_dpll_setup);
389f38b0dd6STero Kristo 
390f38b0dd6STero Kristo static void __init of_ti_omap3_per_dpll_setup(struct device_node *node)
391f38b0dd6STero Kristo {
392f38b0dd6STero Kristo 	const struct dpll_data dd = {
393f38b0dd6STero Kristo 		.idlest_mask = 0x1 << 1,
394f38b0dd6STero Kristo 		.enable_mask = 0x7 << 16,
395f38b0dd6STero Kristo 		.autoidle_mask = 0x7 << 3,
396f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
397f38b0dd6STero Kristo 		.div1_mask = 0x7f,
398f38b0dd6STero Kristo 		.max_multiplier = 2047,
399f38b0dd6STero Kristo 		.max_divider = 128,
400f38b0dd6STero Kristo 		.min_divider = 1,
401f38b0dd6STero Kristo 		.freqsel_mask = 0xf00000,
402f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_STOP) | (1 << DPLL_LOCKED),
403f38b0dd6STero Kristo 	};
404f38b0dd6STero Kristo 
405a6fe3771STero Kristo 	of_ti_dpll_setup(node, &omap3_dpll_per_ck_ops, &dd);
406f38b0dd6STero Kristo }
407f38b0dd6STero Kristo CLK_OF_DECLARE(ti_omap3_per_dpll_clock, "ti,omap3-dpll-per-clock",
408f38b0dd6STero Kristo 	       of_ti_omap3_per_dpll_setup);
409f38b0dd6STero Kristo 
410f38b0dd6STero Kristo static void __init of_ti_omap3_per_jtype_dpll_setup(struct device_node *node)
411f38b0dd6STero Kristo {
412f38b0dd6STero Kristo 	const struct dpll_data dd = {
413f38b0dd6STero Kristo 		.idlest_mask = 0x1 << 1,
414f38b0dd6STero Kristo 		.enable_mask = 0x7 << 16,
415f38b0dd6STero Kristo 		.autoidle_mask = 0x7 << 3,
416f38b0dd6STero Kristo 		.mult_mask = 0xfff << 8,
417f38b0dd6STero Kristo 		.div1_mask = 0x7f,
418f38b0dd6STero Kristo 		.max_multiplier = 4095,
419f38b0dd6STero Kristo 		.max_divider = 128,
420f38b0dd6STero Kristo 		.min_divider = 1,
421f38b0dd6STero Kristo 		.sddiv_mask = 0xff << 24,
422f38b0dd6STero Kristo 		.dco_mask = 0xe << 20,
423f38b0dd6STero Kristo 		.flags = DPLL_J_TYPE,
424f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_STOP) | (1 << DPLL_LOCKED),
425f38b0dd6STero Kristo 	};
426f38b0dd6STero Kristo 
427a6fe3771STero Kristo 	of_ti_dpll_setup(node, &omap3_dpll_per_ck_ops, &dd);
428f38b0dd6STero Kristo }
429f38b0dd6STero Kristo CLK_OF_DECLARE(ti_omap3_per_jtype_dpll_clock, "ti,omap3-dpll-per-j-type-clock",
430f38b0dd6STero Kristo 	       of_ti_omap3_per_jtype_dpll_setup);
431f38b0dd6STero Kristo #endif
432f38b0dd6STero Kristo 
433f38b0dd6STero Kristo static void __init of_ti_omap4_dpll_setup(struct device_node *node)
434f38b0dd6STero Kristo {
435f38b0dd6STero Kristo 	const struct dpll_data dd = {
436f38b0dd6STero Kristo 		.idlest_mask = 0x1,
437f38b0dd6STero Kristo 		.enable_mask = 0x7,
438f38b0dd6STero Kristo 		.autoidle_mask = 0x7,
439f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
440f38b0dd6STero Kristo 		.div1_mask = 0x7f,
441f38b0dd6STero Kristo 		.max_multiplier = 2047,
442f38b0dd6STero Kristo 		.max_divider = 128,
443f38b0dd6STero Kristo 		.min_divider = 1,
444f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
445f38b0dd6STero Kristo 	};
446f38b0dd6STero Kristo 
447a6fe3771STero Kristo 	of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
448f38b0dd6STero Kristo }
449f38b0dd6STero Kristo CLK_OF_DECLARE(ti_omap4_dpll_clock, "ti,omap4-dpll-clock",
450f38b0dd6STero Kristo 	       of_ti_omap4_dpll_setup);
451f38b0dd6STero Kristo 
452b4be0189SNishanth Menon static void __init of_ti_omap5_mpu_dpll_setup(struct device_node *node)
453b4be0189SNishanth Menon {
454b4be0189SNishanth Menon 	const struct dpll_data dd = {
455b4be0189SNishanth Menon 		.idlest_mask = 0x1,
456b4be0189SNishanth Menon 		.enable_mask = 0x7,
457b4be0189SNishanth Menon 		.autoidle_mask = 0x7,
458b4be0189SNishanth Menon 		.mult_mask = 0x7ff << 8,
459b4be0189SNishanth Menon 		.div1_mask = 0x7f,
460b4be0189SNishanth Menon 		.max_multiplier = 2047,
461b4be0189SNishanth Menon 		.max_divider = 128,
462b4be0189SNishanth Menon 		.dcc_mask = BIT(22),
463b4be0189SNishanth Menon 		.dcc_rate = 1400000000, /* DCC beyond 1.4GHz */
464b4be0189SNishanth Menon 		.min_divider = 1,
465b4be0189SNishanth Menon 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
466b4be0189SNishanth Menon 	};
467b4be0189SNishanth Menon 
468b4be0189SNishanth Menon 	of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
469b4be0189SNishanth Menon }
470b4be0189SNishanth Menon CLK_OF_DECLARE(of_ti_omap5_mpu_dpll_clock, "ti,omap5-mpu-dpll-clock",
471b4be0189SNishanth Menon 	       of_ti_omap5_mpu_dpll_setup);
472b4be0189SNishanth Menon 
473f38b0dd6STero Kristo static void __init of_ti_omap4_core_dpll_setup(struct device_node *node)
474f38b0dd6STero Kristo {
475f38b0dd6STero Kristo 	const struct dpll_data dd = {
476f38b0dd6STero Kristo 		.idlest_mask = 0x1,
477f38b0dd6STero Kristo 		.enable_mask = 0x7,
478f38b0dd6STero Kristo 		.autoidle_mask = 0x7,
479f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
480f38b0dd6STero Kristo 		.div1_mask = 0x7f,
481f38b0dd6STero Kristo 		.max_multiplier = 2047,
482f38b0dd6STero Kristo 		.max_divider = 128,
483f38b0dd6STero Kristo 		.min_divider = 1,
484f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
485f38b0dd6STero Kristo 	};
486f38b0dd6STero Kristo 
487a6fe3771STero Kristo 	of_ti_dpll_setup(node, &dpll_core_ck_ops, &dd);
488f38b0dd6STero Kristo }
489f38b0dd6STero Kristo CLK_OF_DECLARE(ti_omap4_core_dpll_clock, "ti,omap4-dpll-core-clock",
490f38b0dd6STero Kristo 	       of_ti_omap4_core_dpll_setup);
491f38b0dd6STero Kristo 
492f38b0dd6STero Kristo #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
493f38b0dd6STero Kristo 	defined(CONFIG_SOC_DRA7XX)
494f38b0dd6STero Kristo static void __init of_ti_omap4_m4xen_dpll_setup(struct device_node *node)
495f38b0dd6STero Kristo {
496f38b0dd6STero Kristo 	const struct dpll_data dd = {
497f38b0dd6STero Kristo 		.idlest_mask = 0x1,
498f38b0dd6STero Kristo 		.enable_mask = 0x7,
499f38b0dd6STero Kristo 		.autoidle_mask = 0x7,
500f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
501f38b0dd6STero Kristo 		.div1_mask = 0x7f,
502f38b0dd6STero Kristo 		.max_multiplier = 2047,
503f38b0dd6STero Kristo 		.max_divider = 128,
504f38b0dd6STero Kristo 		.min_divider = 1,
505f38b0dd6STero Kristo 		.m4xen_mask = 0x800,
506f38b0dd6STero Kristo 		.lpmode_mask = 1 << 10,
507f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
508f38b0dd6STero Kristo 	};
509f38b0dd6STero Kristo 
510a6fe3771STero Kristo 	of_ti_dpll_setup(node, &dpll_m4xen_ck_ops, &dd);
511f38b0dd6STero Kristo }
512f38b0dd6STero Kristo CLK_OF_DECLARE(ti_omap4_m4xen_dpll_clock, "ti,omap4-dpll-m4xen-clock",
513f38b0dd6STero Kristo 	       of_ti_omap4_m4xen_dpll_setup);
514f38b0dd6STero Kristo 
515f38b0dd6STero Kristo static void __init of_ti_omap4_jtype_dpll_setup(struct device_node *node)
516f38b0dd6STero Kristo {
517f38b0dd6STero Kristo 	const struct dpll_data dd = {
518f38b0dd6STero Kristo 		.idlest_mask = 0x1,
519f38b0dd6STero Kristo 		.enable_mask = 0x7,
520f38b0dd6STero Kristo 		.autoidle_mask = 0x7,
521f38b0dd6STero Kristo 		.mult_mask = 0xfff << 8,
522f38b0dd6STero Kristo 		.div1_mask = 0xff,
523f38b0dd6STero Kristo 		.max_multiplier = 4095,
524f38b0dd6STero Kristo 		.max_divider = 256,
525f38b0dd6STero Kristo 		.min_divider = 1,
526f38b0dd6STero Kristo 		.sddiv_mask = 0xff << 24,
527f38b0dd6STero Kristo 		.flags = DPLL_J_TYPE,
528f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
529f38b0dd6STero Kristo 	};
530f38b0dd6STero Kristo 
531a6fe3771STero Kristo 	of_ti_dpll_setup(node, &dpll_m4xen_ck_ops, &dd);
532f38b0dd6STero Kristo }
533f38b0dd6STero Kristo CLK_OF_DECLARE(ti_omap4_jtype_dpll_clock, "ti,omap4-dpll-j-type-clock",
534f38b0dd6STero Kristo 	       of_ti_omap4_jtype_dpll_setup);
535f38b0dd6STero Kristo #endif
536f38b0dd6STero Kristo 
537f38b0dd6STero Kristo static void __init of_ti_am3_no_gate_dpll_setup(struct device_node *node)
538f38b0dd6STero Kristo {
539f38b0dd6STero Kristo 	const struct dpll_data dd = {
540f38b0dd6STero Kristo 		.idlest_mask = 0x1,
541f38b0dd6STero Kristo 		.enable_mask = 0x7,
542f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
543f38b0dd6STero Kristo 		.div1_mask = 0x7f,
544f38b0dd6STero Kristo 		.max_multiplier = 2047,
545f38b0dd6STero Kristo 		.max_divider = 128,
546f38b0dd6STero Kristo 		.min_divider = 1,
547f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
548f38b0dd6STero Kristo 	};
549f38b0dd6STero Kristo 
550a6fe3771STero Kristo 	of_ti_dpll_setup(node, &dpll_no_gate_ck_ops, &dd);
551f38b0dd6STero Kristo }
552f38b0dd6STero Kristo CLK_OF_DECLARE(ti_am3_no_gate_dpll_clock, "ti,am3-dpll-no-gate-clock",
553f38b0dd6STero Kristo 	       of_ti_am3_no_gate_dpll_setup);
554f38b0dd6STero Kristo 
555f38b0dd6STero Kristo static void __init of_ti_am3_jtype_dpll_setup(struct device_node *node)
556f38b0dd6STero Kristo {
557f38b0dd6STero Kristo 	const struct dpll_data dd = {
558f38b0dd6STero Kristo 		.idlest_mask = 0x1,
559f38b0dd6STero Kristo 		.enable_mask = 0x7,
560f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
561f38b0dd6STero Kristo 		.div1_mask = 0x7f,
562f38b0dd6STero Kristo 		.max_multiplier = 4095,
563f38b0dd6STero Kristo 		.max_divider = 256,
564f38b0dd6STero Kristo 		.min_divider = 2,
565f38b0dd6STero Kristo 		.flags = DPLL_J_TYPE,
566f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
567f38b0dd6STero Kristo 	};
568f38b0dd6STero Kristo 
569a6fe3771STero Kristo 	of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
570f38b0dd6STero Kristo }
571f38b0dd6STero Kristo CLK_OF_DECLARE(ti_am3_jtype_dpll_clock, "ti,am3-dpll-j-type-clock",
572f38b0dd6STero Kristo 	       of_ti_am3_jtype_dpll_setup);
573f38b0dd6STero Kristo 
574f38b0dd6STero Kristo static void __init of_ti_am3_no_gate_jtype_dpll_setup(struct device_node *node)
575f38b0dd6STero Kristo {
576f38b0dd6STero Kristo 	const struct dpll_data dd = {
577f38b0dd6STero Kristo 		.idlest_mask = 0x1,
578f38b0dd6STero Kristo 		.enable_mask = 0x7,
579f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
580f38b0dd6STero Kristo 		.div1_mask = 0x7f,
581f38b0dd6STero Kristo 		.max_multiplier = 2047,
582f38b0dd6STero Kristo 		.max_divider = 128,
583f38b0dd6STero Kristo 		.min_divider = 1,
584f38b0dd6STero Kristo 		.flags = DPLL_J_TYPE,
585f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
586f38b0dd6STero Kristo 	};
587f38b0dd6STero Kristo 
588a6fe3771STero Kristo 	of_ti_dpll_setup(node, &dpll_no_gate_ck_ops, &dd);
589f38b0dd6STero Kristo }
590f38b0dd6STero Kristo CLK_OF_DECLARE(ti_am3_no_gate_jtype_dpll_clock,
591f38b0dd6STero Kristo 	       "ti,am3-dpll-no-gate-j-type-clock",
592f38b0dd6STero Kristo 	       of_ti_am3_no_gate_jtype_dpll_setup);
593f38b0dd6STero Kristo 
594f38b0dd6STero Kristo static void __init of_ti_am3_dpll_setup(struct device_node *node)
595f38b0dd6STero Kristo {
596f38b0dd6STero Kristo 	const struct dpll_data dd = {
597f38b0dd6STero Kristo 		.idlest_mask = 0x1,
598f38b0dd6STero Kristo 		.enable_mask = 0x7,
599f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
600f38b0dd6STero Kristo 		.div1_mask = 0x7f,
601f38b0dd6STero Kristo 		.max_multiplier = 2047,
602f38b0dd6STero Kristo 		.max_divider = 128,
603f38b0dd6STero Kristo 		.min_divider = 1,
604f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
605f38b0dd6STero Kristo 	};
606f38b0dd6STero Kristo 
607a6fe3771STero Kristo 	of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
608f38b0dd6STero Kristo }
609f38b0dd6STero Kristo CLK_OF_DECLARE(ti_am3_dpll_clock, "ti,am3-dpll-clock", of_ti_am3_dpll_setup);
610f38b0dd6STero Kristo 
611f38b0dd6STero Kristo static void __init of_ti_am3_core_dpll_setup(struct device_node *node)
612f38b0dd6STero Kristo {
613f38b0dd6STero Kristo 	const struct dpll_data dd = {
614f38b0dd6STero Kristo 		.idlest_mask = 0x1,
615f38b0dd6STero Kristo 		.enable_mask = 0x7,
616f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
617f38b0dd6STero Kristo 		.div1_mask = 0x7f,
618f38b0dd6STero Kristo 		.max_multiplier = 2047,
619f38b0dd6STero Kristo 		.max_divider = 128,
620f38b0dd6STero Kristo 		.min_divider = 1,
621f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
622f38b0dd6STero Kristo 	};
623f38b0dd6STero Kristo 
624a6fe3771STero Kristo 	of_ti_dpll_setup(node, &dpll_core_ck_ops, &dd);
625f38b0dd6STero Kristo }
626f38b0dd6STero Kristo CLK_OF_DECLARE(ti_am3_core_dpll_clock, "ti,am3-dpll-core-clock",
627f38b0dd6STero Kristo 	       of_ti_am3_core_dpll_setup);
628aa76fcf4STero Kristo 
629aa76fcf4STero Kristo static void __init of_ti_omap2_core_dpll_setup(struct device_node *node)
630aa76fcf4STero Kristo {
631aa76fcf4STero Kristo 	const struct dpll_data dd = {
632aa76fcf4STero Kristo 		.enable_mask = 0x3,
633aa76fcf4STero Kristo 		.mult_mask = 0x3ff << 12,
634aa76fcf4STero Kristo 		.div1_mask = 0xf << 8,
635aa76fcf4STero Kristo 		.max_divider = 16,
636aa76fcf4STero Kristo 		.min_divider = 1,
637aa76fcf4STero Kristo 	};
638aa76fcf4STero Kristo 
639aa76fcf4STero Kristo 	of_ti_dpll_setup(node, &omap2_dpll_core_ck_ops, &dd);
640aa76fcf4STero Kristo }
641aa76fcf4STero Kristo CLK_OF_DECLARE(ti_omap2_core_dpll_clock, "ti,omap2-dpll-core-clock",
642aa76fcf4STero Kristo 	       of_ti_omap2_core_dpll_setup);
643