xref: /openbmc/linux/drivers/clk/ti/dpll.c (revision ffb009b24388b896d9ca8b54e39a879302142518)
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 
181b29e601SStephen Boyd #include <linux/clk.h>
19f38b0dd6STero Kristo #include <linux/clk-provider.h>
20f38b0dd6STero Kristo #include <linux/slab.h>
21f38b0dd6STero Kristo #include <linux/err.h>
22f38b0dd6STero Kristo #include <linux/of.h>
23f38b0dd6STero Kristo #include <linux/of_address.h>
24f38b0dd6STero Kristo #include <linux/clk/ti.h>
25ed405a23STero Kristo #include "clock.h"
26f38b0dd6STero Kristo 
27f38b0dd6STero Kristo #undef pr_fmt
28f38b0dd6STero Kristo #define pr_fmt(fmt) "%s: " fmt, __func__
29f38b0dd6STero Kristo 
30f38b0dd6STero Kristo #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
31f38b0dd6STero Kristo 	defined(CONFIG_SOC_DRA7XX)
32f38b0dd6STero Kristo static const struct clk_ops dpll_m4xen_ck_ops = {
33f38b0dd6STero Kristo 	.enable		= &omap3_noncore_dpll_enable,
34f38b0dd6STero Kristo 	.disable	= &omap3_noncore_dpll_disable,
35f38b0dd6STero Kristo 	.recalc_rate	= &omap4_dpll_regm4xen_recalc,
36f38b0dd6STero Kristo 	.round_rate	= &omap4_dpll_regm4xen_round_rate,
37f38b0dd6STero Kristo 	.set_rate	= &omap3_noncore_dpll_set_rate,
382e1a7b01STero Kristo 	.set_parent	= &omap3_noncore_dpll_set_parent,
392e1a7b01STero Kristo 	.set_rate_and_parent	= &omap3_noncore_dpll_set_rate_and_parent,
402e1a7b01STero Kristo 	.determine_rate	= &omap4_dpll_regm4xen_determine_rate,
41f38b0dd6STero Kristo 	.get_parent	= &omap2_init_dpll_parent,
42f38b0dd6STero Kristo };
43aa76fcf4STero Kristo #else
44aa76fcf4STero Kristo static const struct clk_ops dpll_m4xen_ck_ops = {};
45f38b0dd6STero Kristo #endif
46f38b0dd6STero Kristo 
47aa76fcf4STero Kristo #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) || \
48aa76fcf4STero Kristo 	defined(CONFIG_SOC_OMAP5) || defined(CONFIG_SOC_DRA7XX) || \
49aa76fcf4STero Kristo 	defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
50f38b0dd6STero Kristo static const struct clk_ops dpll_core_ck_ops = {
51f38b0dd6STero Kristo 	.recalc_rate	= &omap3_dpll_recalc,
52f38b0dd6STero Kristo 	.get_parent	= &omap2_init_dpll_parent,
53f38b0dd6STero Kristo };
54f38b0dd6STero Kristo 
55f38b0dd6STero Kristo static const struct clk_ops dpll_ck_ops = {
56f38b0dd6STero Kristo 	.enable		= &omap3_noncore_dpll_enable,
57f38b0dd6STero Kristo 	.disable	= &omap3_noncore_dpll_disable,
58f38b0dd6STero Kristo 	.recalc_rate	= &omap3_dpll_recalc,
59f38b0dd6STero Kristo 	.round_rate	= &omap2_dpll_round_rate,
60f38b0dd6STero Kristo 	.set_rate	= &omap3_noncore_dpll_set_rate,
612e1a7b01STero Kristo 	.set_parent	= &omap3_noncore_dpll_set_parent,
622e1a7b01STero Kristo 	.set_rate_and_parent	= &omap3_noncore_dpll_set_rate_and_parent,
632e1a7b01STero Kristo 	.determine_rate	= &omap3_noncore_dpll_determine_rate,
64f38b0dd6STero Kristo 	.get_parent	= &omap2_init_dpll_parent,
65f38b0dd6STero Kristo };
66f38b0dd6STero Kristo 
67f38b0dd6STero Kristo static const struct clk_ops dpll_no_gate_ck_ops = {
68f38b0dd6STero Kristo 	.recalc_rate	= &omap3_dpll_recalc,
69f38b0dd6STero Kristo 	.get_parent	= &omap2_init_dpll_parent,
70f38b0dd6STero Kristo 	.round_rate	= &omap2_dpll_round_rate,
71f38b0dd6STero Kristo 	.set_rate	= &omap3_noncore_dpll_set_rate,
722e1a7b01STero Kristo 	.set_parent	= &omap3_noncore_dpll_set_parent,
732e1a7b01STero Kristo 	.set_rate_and_parent	= &omap3_noncore_dpll_set_rate_and_parent,
742e1a7b01STero Kristo 	.determine_rate	= &omap3_noncore_dpll_determine_rate,
75f38b0dd6STero Kristo };
76aa76fcf4STero Kristo #else
77aa76fcf4STero Kristo static const struct clk_ops dpll_core_ck_ops = {};
78aa76fcf4STero Kristo static const struct clk_ops dpll_ck_ops = {};
79aa76fcf4STero Kristo static const struct clk_ops dpll_no_gate_ck_ops = {};
80aa76fcf4STero Kristo const struct clk_hw_omap_ops clkhwops_omap3_dpll = {};
81aa76fcf4STero Kristo #endif
82aa76fcf4STero Kristo 
83aa76fcf4STero Kristo #ifdef CONFIG_ARCH_OMAP2
84aa76fcf4STero Kristo static const struct clk_ops omap2_dpll_core_ck_ops = {
85aa76fcf4STero Kristo 	.get_parent	= &omap2_init_dpll_parent,
86aa76fcf4STero Kristo 	.recalc_rate	= &omap2_dpllcore_recalc,
87aa76fcf4STero Kristo 	.round_rate	= &omap2_dpll_round_rate,
88aa76fcf4STero Kristo 	.set_rate	= &omap2_reprogram_dpllcore,
89aa76fcf4STero Kristo };
90aa76fcf4STero Kristo #else
91aa76fcf4STero Kristo static const struct clk_ops omap2_dpll_core_ck_ops = {};
92aa76fcf4STero Kristo #endif
93aa76fcf4STero Kristo 
94aa76fcf4STero Kristo #ifdef CONFIG_ARCH_OMAP3
95aa76fcf4STero Kristo static const struct clk_ops omap3_dpll_core_ck_ops = {
96aa76fcf4STero Kristo 	.get_parent	= &omap2_init_dpll_parent,
97aa76fcf4STero Kristo 	.recalc_rate	= &omap3_dpll_recalc,
98aa76fcf4STero Kristo 	.round_rate	= &omap2_dpll_round_rate,
99aa76fcf4STero Kristo };
100aa76fcf4STero Kristo #else
101aa76fcf4STero Kristo static const struct clk_ops omap3_dpll_core_ck_ops = {};
102aa76fcf4STero Kristo #endif
103f38b0dd6STero Kristo 
104f38b0dd6STero Kristo #ifdef CONFIG_ARCH_OMAP3
105f38b0dd6STero Kristo static const struct clk_ops omap3_dpll_ck_ops = {
106f38b0dd6STero Kristo 	.enable		= &omap3_noncore_dpll_enable,
107f38b0dd6STero Kristo 	.disable	= &omap3_noncore_dpll_disable,
108f38b0dd6STero Kristo 	.get_parent	= &omap2_init_dpll_parent,
109f38b0dd6STero Kristo 	.recalc_rate	= &omap3_dpll_recalc,
110f38b0dd6STero Kristo 	.set_rate	= &omap3_noncore_dpll_set_rate,
1112e1a7b01STero Kristo 	.set_parent	= &omap3_noncore_dpll_set_parent,
1122e1a7b01STero Kristo 	.set_rate_and_parent	= &omap3_noncore_dpll_set_rate_and_parent,
1132e1a7b01STero Kristo 	.determine_rate	= &omap3_noncore_dpll_determine_rate,
114f38b0dd6STero Kristo 	.round_rate	= &omap2_dpll_round_rate,
115f38b0dd6STero Kristo };
116f38b0dd6STero Kristo 
117035cd485SRichard Watts static const struct clk_ops omap3_dpll5_ck_ops = {
118035cd485SRichard Watts 	.enable		= &omap3_noncore_dpll_enable,
119035cd485SRichard Watts 	.disable	= &omap3_noncore_dpll_disable,
120035cd485SRichard Watts 	.get_parent	= &omap2_init_dpll_parent,
121035cd485SRichard Watts 	.recalc_rate	= &omap3_dpll_recalc,
122035cd485SRichard Watts 	.set_rate	= &omap3_dpll5_set_rate,
123035cd485SRichard Watts 	.set_parent	= &omap3_noncore_dpll_set_parent,
124035cd485SRichard Watts 	.set_rate_and_parent	= &omap3_noncore_dpll_set_rate_and_parent,
125035cd485SRichard Watts 	.determine_rate	= &omap3_noncore_dpll_determine_rate,
126035cd485SRichard Watts 	.round_rate	= &omap2_dpll_round_rate,
127035cd485SRichard Watts };
128035cd485SRichard Watts 
129f38b0dd6STero Kristo static const struct clk_ops omap3_dpll_per_ck_ops = {
130f38b0dd6STero Kristo 	.enable		= &omap3_noncore_dpll_enable,
131f38b0dd6STero Kristo 	.disable	= &omap3_noncore_dpll_disable,
132f38b0dd6STero Kristo 	.get_parent	= &omap2_init_dpll_parent,
133f38b0dd6STero Kristo 	.recalc_rate	= &omap3_dpll_recalc,
134f38b0dd6STero Kristo 	.set_rate	= &omap3_dpll4_set_rate,
1352e1a7b01STero Kristo 	.set_parent	= &omap3_noncore_dpll_set_parent,
1362e1a7b01STero Kristo 	.set_rate_and_parent	= &omap3_dpll4_set_rate_and_parent,
1372e1a7b01STero Kristo 	.determine_rate	= &omap3_noncore_dpll_determine_rate,
138f38b0dd6STero Kristo 	.round_rate	= &omap2_dpll_round_rate,
139f38b0dd6STero Kristo };
140f38b0dd6STero Kristo #endif
141f38b0dd6STero Kristo 
142f38b0dd6STero Kristo static const struct clk_ops dpll_x2_ck_ops = {
143f38b0dd6STero Kristo 	.recalc_rate	= &omap3_clkoutx2_recalc,
144f38b0dd6STero Kristo };
145f38b0dd6STero Kristo 
146f38b0dd6STero Kristo /**
147ed405a23STero Kristo  * _register_dpll - low level registration of a DPLL clock
148f38b0dd6STero Kristo  * @hw: hardware clock definition for the clock
149f38b0dd6STero Kristo  * @node: device node for the clock
150f38b0dd6STero Kristo  *
151f38b0dd6STero Kristo  * Finalizes DPLL registration process. In case a failure (clk-ref or
152f38b0dd6STero Kristo  * clk-bypass is missing), the clock is added to retry list and
153f38b0dd6STero Kristo  * the initialization is retried on later stage.
154f38b0dd6STero Kristo  */
155*ffb009b2STero Kristo static void __init _register_dpll(void *user,
156f38b0dd6STero Kristo 				  struct device_node *node)
157f38b0dd6STero Kristo {
158*ffb009b2STero Kristo 	struct clk_hw *hw = user;
159f38b0dd6STero Kristo 	struct clk_hw_omap *clk_hw = to_clk_hw_omap(hw);
160f38b0dd6STero Kristo 	struct dpll_data *dd = clk_hw->dpll_data;
161f38b0dd6STero Kristo 	struct clk *clk;
162f38b0dd6STero Kristo 
163b6f51284STero Kristo 	clk = of_clk_get(node, 0);
164b6f51284STero Kristo 	if (IS_ERR(clk)) {
165b6f51284STero Kristo 		pr_debug("clk-ref missing for %s, retry later\n",
166f38b0dd6STero Kristo 			 node->name);
167ed405a23STero Kristo 		if (!ti_clk_retry_init(node, hw, _register_dpll))
168f38b0dd6STero Kristo 			return;
169f38b0dd6STero Kristo 
170f38b0dd6STero Kristo 		goto cleanup;
171f38b0dd6STero Kristo 	}
172f38b0dd6STero Kristo 
173b6f51284STero Kristo 	dd->clk_ref = __clk_get_hw(clk);
174b6f51284STero Kristo 
175b6f51284STero Kristo 	clk = of_clk_get(node, 1);
176b6f51284STero Kristo 
177b6f51284STero Kristo 	if (IS_ERR(clk)) {
178b6f51284STero Kristo 		pr_debug("clk-bypass missing for %s, retry later\n",
179b6f51284STero Kristo 			 node->name);
180b6f51284STero Kristo 		if (!ti_clk_retry_init(node, hw, _register_dpll))
181b6f51284STero Kristo 			return;
182b6f51284STero Kristo 
183b6f51284STero Kristo 		goto cleanup;
184b6f51284STero Kristo 	}
185b6f51284STero Kristo 
186b6f51284STero Kristo 	dd->clk_bypass = __clk_get_hw(clk);
187b6f51284STero Kristo 
188f38b0dd6STero Kristo 	/* register the clock */
1891ae79c46STero Kristo 	clk = ti_clk_register(NULL, &clk_hw->hw, node->name);
190f38b0dd6STero Kristo 
191f38b0dd6STero Kristo 	if (!IS_ERR(clk)) {
19298d8a60eSStephen Boyd 		omap2_init_clk_hw_omap_clocks(&clk_hw->hw);
193f38b0dd6STero Kristo 		of_clk_add_provider(node, of_clk_src_simple_get, clk);
194f38b0dd6STero Kristo 		kfree(clk_hw->hw.init->parent_names);
195f38b0dd6STero Kristo 		kfree(clk_hw->hw.init);
196f38b0dd6STero Kristo 		return;
197f38b0dd6STero Kristo 	}
198f38b0dd6STero Kristo 
199f38b0dd6STero Kristo cleanup:
200f38b0dd6STero Kristo 	kfree(clk_hw->dpll_data);
201f38b0dd6STero Kristo 	kfree(clk_hw->hw.init->parent_names);
202f38b0dd6STero Kristo 	kfree(clk_hw->hw.init);
203f38b0dd6STero Kristo 	kfree(clk_hw);
204f38b0dd6STero Kristo }
205f38b0dd6STero Kristo 
2066793a30aSArnd Bergmann #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_ATAGS)
2076c0afb50STero Kristo void _get_reg(u8 module, u16 offset, struct clk_omap_reg *reg)
208ed405a23STero Kristo {
2096c0afb50STero Kristo 	reg->index = module;
2106c0afb50STero Kristo 	reg->offset = offset;
211ed405a23STero Kristo }
212ed405a23STero Kristo 
213ed405a23STero Kristo struct clk *ti_clk_register_dpll(struct ti_clk *setup)
214ed405a23STero Kristo {
215ed405a23STero Kristo 	struct clk_hw_omap *clk_hw;
216ed405a23STero Kristo 	struct clk_init_data init = { NULL };
217ed405a23STero Kristo 	struct dpll_data *dd;
218ed405a23STero Kristo 	struct clk *clk;
219ed405a23STero Kristo 	struct ti_clk_dpll *dpll;
220ed405a23STero Kristo 	const struct clk_ops *ops = &omap3_dpll_ck_ops;
221ed405a23STero Kristo 	struct clk *clk_ref;
222ed405a23STero Kristo 	struct clk *clk_bypass;
223ed405a23STero Kristo 
224ed405a23STero Kristo 	dpll = setup->data;
225ed405a23STero Kristo 
226ed405a23STero Kristo 	if (dpll->num_parents < 2)
227ed405a23STero Kristo 		return ERR_PTR(-EINVAL);
228ed405a23STero Kristo 
229ed405a23STero Kristo 	clk_ref = clk_get_sys(NULL, dpll->parents[0]);
230ed405a23STero Kristo 	clk_bypass = clk_get_sys(NULL, dpll->parents[1]);
231ed405a23STero Kristo 
232ed405a23STero Kristo 	if (IS_ERR_OR_NULL(clk_ref) || IS_ERR_OR_NULL(clk_bypass))
233ed405a23STero Kristo 		return ERR_PTR(-EAGAIN);
234ed405a23STero Kristo 
235ed405a23STero Kristo 	dd = kzalloc(sizeof(*dd), GFP_KERNEL);
236ed405a23STero Kristo 	clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
237ed405a23STero Kristo 	if (!dd || !clk_hw) {
238ed405a23STero Kristo 		clk = ERR_PTR(-ENOMEM);
239ed405a23STero Kristo 		goto cleanup;
240ed405a23STero Kristo 	}
241ed405a23STero Kristo 
242ed405a23STero Kristo 	clk_hw->dpll_data = dd;
243ed405a23STero Kristo 	clk_hw->ops = &clkhwops_omap3_dpll;
244ed405a23STero Kristo 	clk_hw->hw.init = &init;
245ed405a23STero Kristo 
246ed405a23STero Kristo 	init.name = setup->name;
247ed405a23STero Kristo 	init.ops = ops;
248ed405a23STero Kristo 
249ed405a23STero Kristo 	init.num_parents = dpll->num_parents;
250ed405a23STero Kristo 	init.parent_names = dpll->parents;
251ed405a23STero Kristo 
2526c0afb50STero Kristo 	_get_reg(dpll->module, dpll->control_reg, &dd->control_reg);
2536c0afb50STero Kristo 	_get_reg(dpll->module, dpll->idlest_reg, &dd->idlest_reg);
2546c0afb50STero Kristo 	_get_reg(dpll->module, dpll->mult_div1_reg, &dd->mult_div1_reg);
2556c0afb50STero Kristo 	_get_reg(dpll->module, dpll->autoidle_reg, &dd->autoidle_reg);
256ed405a23STero Kristo 
257ed405a23STero Kristo 	dd->modes = dpll->modes;
258ed405a23STero Kristo 	dd->div1_mask = dpll->div1_mask;
259ed405a23STero Kristo 	dd->idlest_mask = dpll->idlest_mask;
260ed405a23STero Kristo 	dd->mult_mask = dpll->mult_mask;
261ed405a23STero Kristo 	dd->autoidle_mask = dpll->autoidle_mask;
262ed405a23STero Kristo 	dd->enable_mask = dpll->enable_mask;
263ed405a23STero Kristo 	dd->sddiv_mask = dpll->sddiv_mask;
264ed405a23STero Kristo 	dd->dco_mask = dpll->dco_mask;
265ed405a23STero Kristo 	dd->max_divider = dpll->max_divider;
266ed405a23STero Kristo 	dd->min_divider = dpll->min_divider;
267ed405a23STero Kristo 	dd->max_multiplier = dpll->max_multiplier;
268ed405a23STero Kristo 	dd->auto_recal_bit = dpll->auto_recal_bit;
269ed405a23STero Kristo 	dd->recal_en_bit = dpll->recal_en_bit;
270ed405a23STero Kristo 	dd->recal_st_bit = dpll->recal_st_bit;
271ed405a23STero Kristo 
272b6f51284STero Kristo 	dd->clk_ref = __clk_get_hw(clk_ref);
273b6f51284STero Kristo 	dd->clk_bypass = __clk_get_hw(clk_bypass);
274ed405a23STero Kristo 
275ed405a23STero Kristo 	if (dpll->flags & CLKF_CORE)
276ed405a23STero Kristo 		ops = &omap3_dpll_core_ck_ops;
277ed405a23STero Kristo 
278ed405a23STero Kristo 	if (dpll->flags & CLKF_PER)
279ed405a23STero Kristo 		ops = &omap3_dpll_per_ck_ops;
280ed405a23STero Kristo 
281ed405a23STero Kristo 	if (dpll->flags & CLKF_J_TYPE)
282ed405a23STero Kristo 		dd->flags |= DPLL_J_TYPE;
283ed405a23STero Kristo 
2841ae79c46STero Kristo 	clk = ti_clk_register(NULL, &clk_hw->hw, setup->name);
285ed405a23STero Kristo 
286ed405a23STero Kristo 	if (!IS_ERR(clk))
287ed405a23STero Kristo 		return clk;
288ed405a23STero Kristo 
289ed405a23STero Kristo cleanup:
290ed405a23STero Kristo 	kfree(dd);
291ed405a23STero Kristo 	kfree(clk_hw);
292ed405a23STero Kristo 	return clk;
293ed405a23STero Kristo }
2946793a30aSArnd Bergmann #endif
295ed405a23STero Kristo 
296f38b0dd6STero Kristo #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
2974332ec1aSRoger Quadros 	defined(CONFIG_SOC_DRA7XX) || defined(CONFIG_SOC_AM33XX) || \
2984332ec1aSRoger Quadros 	defined(CONFIG_SOC_AM43XX)
299f38b0dd6STero Kristo /**
300ed405a23STero Kristo  * _register_dpll_x2 - Registers a DPLLx2 clock
301f38b0dd6STero Kristo  * @node: device node for this clock
302f38b0dd6STero Kristo  * @ops: clk_ops for this clock
303f38b0dd6STero Kristo  * @hw_ops: clk_hw_ops for this clock
304f38b0dd6STero Kristo  *
305f38b0dd6STero Kristo  * Initializes a DPLL x 2 clock from device tree data.
306f38b0dd6STero Kristo  */
307ed405a23STero Kristo static void _register_dpll_x2(struct device_node *node,
308f38b0dd6STero Kristo 			      const struct clk_ops *ops,
309f38b0dd6STero Kristo 			      const struct clk_hw_omap_ops *hw_ops)
310f38b0dd6STero Kristo {
311f38b0dd6STero Kristo 	struct clk *clk;
312f38b0dd6STero Kristo 	struct clk_init_data init = { NULL };
313f38b0dd6STero Kristo 	struct clk_hw_omap *clk_hw;
314f38b0dd6STero Kristo 	const char *name = node->name;
315f38b0dd6STero Kristo 	const char *parent_name;
316f38b0dd6STero Kristo 
317f38b0dd6STero Kristo 	parent_name = of_clk_get_parent_name(node, 0);
318f38b0dd6STero Kristo 	if (!parent_name) {
319f38b0dd6STero Kristo 		pr_err("%s must have parent\n", node->name);
320f38b0dd6STero Kristo 		return;
321f38b0dd6STero Kristo 	}
322f38b0dd6STero Kristo 
323f38b0dd6STero Kristo 	clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
324f38b0dd6STero Kristo 	if (!clk_hw)
325f38b0dd6STero Kristo 		return;
326f38b0dd6STero Kristo 
327f38b0dd6STero Kristo 	clk_hw->ops = hw_ops;
328f38b0dd6STero Kristo 	clk_hw->hw.init = &init;
329f38b0dd6STero Kristo 
330f38b0dd6STero Kristo 	init.name = name;
331f38b0dd6STero Kristo 	init.ops = ops;
332f38b0dd6STero Kristo 	init.parent_names = &parent_name;
333f38b0dd6STero Kristo 	init.num_parents = 1;
334f38b0dd6STero Kristo 
3352158a093SArnd Bergmann #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
3362158a093SArnd Bergmann 	defined(CONFIG_SOC_DRA7XX)
337473adbf4STero Kristo 	if (hw_ops == &clkhwops_omap4_dpllmx) {
3382158a093SArnd Bergmann 		int ret;
3392158a093SArnd Bergmann 
340473adbf4STero Kristo 		/* Check if register defined, if not, drop hw-ops */
341473adbf4STero Kristo 		ret = of_property_count_elems_of_size(node, "reg", 1);
342473adbf4STero Kristo 		if (ret <= 0) {
3432158a093SArnd Bergmann 			clk_hw->ops = NULL;
3446c0afb50STero Kristo 		} else if (ti_clk_get_reg_addr(node, 0, &clk_hw->clksel_reg)) {
345473adbf4STero Kristo 			kfree(clk_hw);
346473adbf4STero Kristo 			return;
347473adbf4STero Kristo 		}
348473adbf4STero Kristo 	}
3492158a093SArnd Bergmann #endif
350473adbf4STero Kristo 
351f38b0dd6STero Kristo 	/* register the clock */
3521ae79c46STero Kristo 	clk = ti_clk_register(NULL, &clk_hw->hw, name);
353f38b0dd6STero Kristo 
354f38b0dd6STero Kristo 	if (IS_ERR(clk)) {
355f38b0dd6STero Kristo 		kfree(clk_hw);
356f38b0dd6STero Kristo 	} else {
35798d8a60eSStephen Boyd 		omap2_init_clk_hw_omap_clocks(&clk_hw->hw);
358f38b0dd6STero Kristo 		of_clk_add_provider(node, of_clk_src_simple_get, clk);
359f38b0dd6STero Kristo 	}
360f38b0dd6STero Kristo }
361f38b0dd6STero Kristo #endif
362f38b0dd6STero Kristo 
363f38b0dd6STero Kristo /**
364f38b0dd6STero Kristo  * of_ti_dpll_setup - Setup function for OMAP DPLL clocks
365f38b0dd6STero Kristo  * @node: device node containing the DPLL info
366f38b0dd6STero Kristo  * @ops: ops for the DPLL
367f38b0dd6STero Kristo  * @ddt: DPLL data template to use
368f38b0dd6STero Kristo  *
369f38b0dd6STero Kristo  * Initializes a DPLL clock from device tree data.
370f38b0dd6STero Kristo  */
371f38b0dd6STero Kristo static void __init of_ti_dpll_setup(struct device_node *node,
372f38b0dd6STero Kristo 				    const struct clk_ops *ops,
373a6fe3771STero Kristo 				    const struct dpll_data *ddt)
374f38b0dd6STero Kristo {
375f38b0dd6STero Kristo 	struct clk_hw_omap *clk_hw = NULL;
376f38b0dd6STero Kristo 	struct clk_init_data *init = NULL;
377f38b0dd6STero Kristo 	const char **parent_names = NULL;
378f38b0dd6STero Kristo 	struct dpll_data *dd = NULL;
379f38b0dd6STero Kristo 	u8 dpll_mode = 0;
380f38b0dd6STero Kristo 
381f38b0dd6STero Kristo 	dd = kzalloc(sizeof(*dd), GFP_KERNEL);
382f38b0dd6STero Kristo 	clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
383f38b0dd6STero Kristo 	init = kzalloc(sizeof(*init), GFP_KERNEL);
384f38b0dd6STero Kristo 	if (!dd || !clk_hw || !init)
385f38b0dd6STero Kristo 		goto cleanup;
386f38b0dd6STero Kristo 
387f38b0dd6STero Kristo 	memcpy(dd, ddt, sizeof(*dd));
388f38b0dd6STero Kristo 
389f38b0dd6STero Kristo 	clk_hw->dpll_data = dd;
390f38b0dd6STero Kristo 	clk_hw->ops = &clkhwops_omap3_dpll;
391f38b0dd6STero Kristo 	clk_hw->hw.init = init;
392f38b0dd6STero Kristo 
393f38b0dd6STero Kristo 	init->name = node->name;
394f38b0dd6STero Kristo 	init->ops = ops;
395f38b0dd6STero Kristo 
396f38b0dd6STero Kristo 	init->num_parents = of_clk_get_parent_count(node);
397921bacfaSStephen Boyd 	if (!init->num_parents) {
398f38b0dd6STero Kristo 		pr_err("%s must have parent(s)\n", node->name);
399f38b0dd6STero Kristo 		goto cleanup;
400f38b0dd6STero Kristo 	}
401f38b0dd6STero Kristo 
402f38b0dd6STero Kristo 	parent_names = kzalloc(sizeof(char *) * init->num_parents, GFP_KERNEL);
403f38b0dd6STero Kristo 	if (!parent_names)
404f38b0dd6STero Kristo 		goto cleanup;
405f38b0dd6STero Kristo 
4069da9e761SDinh Nguyen 	of_clk_parent_fill(node, parent_names, init->num_parents);
407f38b0dd6STero Kristo 
408f38b0dd6STero Kristo 	init->parent_names = parent_names;
409f38b0dd6STero Kristo 
4106c0afb50STero Kristo 	if (ti_clk_get_reg_addr(node, 0, &dd->control_reg))
4116c0afb50STero Kristo 		goto cleanup;
412f38b0dd6STero Kristo 
413aa76fcf4STero Kristo 	/*
414aa76fcf4STero Kristo 	 * Special case for OMAP2 DPLL, register order is different due to
415aa76fcf4STero Kristo 	 * missing idlest_reg, also clkhwops is different. Detected from
416aa76fcf4STero Kristo 	 * missing idlest_mask.
417aa76fcf4STero Kristo 	 */
418aa76fcf4STero Kristo 	if (!dd->idlest_mask) {
4196c0afb50STero Kristo 		if (ti_clk_get_reg_addr(node, 1, &dd->mult_div1_reg))
4206c0afb50STero Kristo 			goto cleanup;
421aa76fcf4STero Kristo #ifdef CONFIG_ARCH_OMAP2
422aa76fcf4STero Kristo 		clk_hw->ops = &clkhwops_omap2xxx_dpll;
423aa76fcf4STero Kristo 		omap2xxx_clkt_dpllcore_init(&clk_hw->hw);
424aa76fcf4STero Kristo #endif
425aa76fcf4STero Kristo 	} else {
4266c0afb50STero Kristo 		if (ti_clk_get_reg_addr(node, 1, &dd->idlest_reg))
427aa76fcf4STero Kristo 			goto cleanup;
428aa76fcf4STero Kristo 
4296c0afb50STero Kristo 		if (ti_clk_get_reg_addr(node, 2, &dd->mult_div1_reg))
4306c0afb50STero Kristo 			goto cleanup;
431aa76fcf4STero Kristo 	}
432aa76fcf4STero Kristo 
433a6fe3771STero Kristo 	if (dd->autoidle_mask) {
4346c0afb50STero Kristo 		if (ti_clk_get_reg_addr(node, 3, &dd->autoidle_reg))
435f38b0dd6STero Kristo 			goto cleanup;
436f38b0dd6STero Kristo 	}
437f38b0dd6STero Kristo 
438f38b0dd6STero Kristo 	if (of_property_read_bool(node, "ti,low-power-stop"))
439f38b0dd6STero Kristo 		dpll_mode |= 1 << DPLL_LOW_POWER_STOP;
440f38b0dd6STero Kristo 
441f38b0dd6STero Kristo 	if (of_property_read_bool(node, "ti,low-power-bypass"))
442f38b0dd6STero Kristo 		dpll_mode |= 1 << DPLL_LOW_POWER_BYPASS;
443f38b0dd6STero Kristo 
444f38b0dd6STero Kristo 	if (of_property_read_bool(node, "ti,lock"))
445f38b0dd6STero Kristo 		dpll_mode |= 1 << DPLL_LOCKED;
446f38b0dd6STero Kristo 
447f38b0dd6STero Kristo 	if (dpll_mode)
448f38b0dd6STero Kristo 		dd->modes = dpll_mode;
449f38b0dd6STero Kristo 
450ed405a23STero Kristo 	_register_dpll(&clk_hw->hw, node);
451f38b0dd6STero Kristo 	return;
452f38b0dd6STero Kristo 
453f38b0dd6STero Kristo cleanup:
454f38b0dd6STero Kristo 	kfree(dd);
455f38b0dd6STero Kristo 	kfree(parent_names);
456f38b0dd6STero Kristo 	kfree(init);
457f38b0dd6STero Kristo 	kfree(clk_hw);
458f38b0dd6STero Kristo }
459f38b0dd6STero Kristo 
460f38b0dd6STero Kristo #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
461f38b0dd6STero Kristo 	defined(CONFIG_SOC_DRA7XX)
462f38b0dd6STero Kristo static void __init of_ti_omap4_dpll_x2_setup(struct device_node *node)
463f38b0dd6STero Kristo {
464ed405a23STero Kristo 	_register_dpll_x2(node, &dpll_x2_ck_ops, &clkhwops_omap4_dpllmx);
465f38b0dd6STero Kristo }
466f38b0dd6STero Kristo CLK_OF_DECLARE(ti_omap4_dpll_x2_clock, "ti,omap4-dpll-x2-clock",
467f38b0dd6STero Kristo 	       of_ti_omap4_dpll_x2_setup);
468f38b0dd6STero Kristo #endif
469f38b0dd6STero Kristo 
4704332ec1aSRoger Quadros #if defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
471f38b0dd6STero Kristo static void __init of_ti_am3_dpll_x2_setup(struct device_node *node)
472f38b0dd6STero Kristo {
473ed405a23STero Kristo 	_register_dpll_x2(node, &dpll_x2_ck_ops, NULL);
474f38b0dd6STero Kristo }
475f38b0dd6STero Kristo CLK_OF_DECLARE(ti_am3_dpll_x2_clock, "ti,am3-dpll-x2-clock",
476f38b0dd6STero Kristo 	       of_ti_am3_dpll_x2_setup);
477f38b0dd6STero Kristo #endif
478f38b0dd6STero Kristo 
479f38b0dd6STero Kristo #ifdef CONFIG_ARCH_OMAP3
480f38b0dd6STero Kristo static void __init of_ti_omap3_dpll_setup(struct device_node *node)
481f38b0dd6STero Kristo {
482f38b0dd6STero Kristo 	const struct dpll_data dd = {
483f38b0dd6STero Kristo 		.idlest_mask = 0x1,
484f38b0dd6STero Kristo 		.enable_mask = 0x7,
485f38b0dd6STero Kristo 		.autoidle_mask = 0x7,
486f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
487f38b0dd6STero Kristo 		.div1_mask = 0x7f,
488f38b0dd6STero Kristo 		.max_multiplier = 2047,
489f38b0dd6STero Kristo 		.max_divider = 128,
490f38b0dd6STero Kristo 		.min_divider = 1,
491f38b0dd6STero Kristo 		.freqsel_mask = 0xf0,
492f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
493f38b0dd6STero Kristo 	};
494f38b0dd6STero Kristo 
495035cd485SRichard Watts 	if ((of_machine_is_compatible("ti,omap3630") ||
496035cd485SRichard Watts 	     of_machine_is_compatible("ti,omap36xx")) &&
497035cd485SRichard Watts 	    !strcmp(node->name, "dpll5_ck"))
498035cd485SRichard Watts 		of_ti_dpll_setup(node, &omap3_dpll5_ck_ops, &dd);
499035cd485SRichard Watts 	else
500a6fe3771STero Kristo 		of_ti_dpll_setup(node, &omap3_dpll_ck_ops, &dd);
501f38b0dd6STero Kristo }
502f38b0dd6STero Kristo CLK_OF_DECLARE(ti_omap3_dpll_clock, "ti,omap3-dpll-clock",
503f38b0dd6STero Kristo 	       of_ti_omap3_dpll_setup);
504f38b0dd6STero Kristo 
505f38b0dd6STero Kristo static void __init of_ti_omap3_core_dpll_setup(struct device_node *node)
506f38b0dd6STero Kristo {
507f38b0dd6STero Kristo 	const struct dpll_data dd = {
508f38b0dd6STero Kristo 		.idlest_mask = 0x1,
509f38b0dd6STero Kristo 		.enable_mask = 0x7,
510f38b0dd6STero Kristo 		.autoidle_mask = 0x7,
511f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 16,
512f38b0dd6STero Kristo 		.div1_mask = 0x7f << 8,
513f38b0dd6STero Kristo 		.max_multiplier = 2047,
514f38b0dd6STero Kristo 		.max_divider = 128,
515f38b0dd6STero Kristo 		.min_divider = 1,
516f38b0dd6STero Kristo 		.freqsel_mask = 0xf0,
517f38b0dd6STero Kristo 	};
518f38b0dd6STero Kristo 
519a6fe3771STero Kristo 	of_ti_dpll_setup(node, &omap3_dpll_core_ck_ops, &dd);
520f38b0dd6STero Kristo }
521f38b0dd6STero Kristo CLK_OF_DECLARE(ti_omap3_core_dpll_clock, "ti,omap3-dpll-core-clock",
522f38b0dd6STero Kristo 	       of_ti_omap3_core_dpll_setup);
523f38b0dd6STero Kristo 
524f38b0dd6STero Kristo static void __init of_ti_omap3_per_dpll_setup(struct device_node *node)
525f38b0dd6STero Kristo {
526f38b0dd6STero Kristo 	const struct dpll_data dd = {
527f38b0dd6STero Kristo 		.idlest_mask = 0x1 << 1,
528f38b0dd6STero Kristo 		.enable_mask = 0x7 << 16,
529f38b0dd6STero Kristo 		.autoidle_mask = 0x7 << 3,
530f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
531f38b0dd6STero Kristo 		.div1_mask = 0x7f,
532f38b0dd6STero Kristo 		.max_multiplier = 2047,
533f38b0dd6STero Kristo 		.max_divider = 128,
534f38b0dd6STero Kristo 		.min_divider = 1,
535f38b0dd6STero Kristo 		.freqsel_mask = 0xf00000,
536f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_STOP) | (1 << DPLL_LOCKED),
537f38b0dd6STero Kristo 	};
538f38b0dd6STero Kristo 
539a6fe3771STero Kristo 	of_ti_dpll_setup(node, &omap3_dpll_per_ck_ops, &dd);
540f38b0dd6STero Kristo }
541f38b0dd6STero Kristo CLK_OF_DECLARE(ti_omap3_per_dpll_clock, "ti,omap3-dpll-per-clock",
542f38b0dd6STero Kristo 	       of_ti_omap3_per_dpll_setup);
543f38b0dd6STero Kristo 
544f38b0dd6STero Kristo static void __init of_ti_omap3_per_jtype_dpll_setup(struct device_node *node)
545f38b0dd6STero Kristo {
546f38b0dd6STero Kristo 	const struct dpll_data dd = {
547f38b0dd6STero Kristo 		.idlest_mask = 0x1 << 1,
548f38b0dd6STero Kristo 		.enable_mask = 0x7 << 16,
549f38b0dd6STero Kristo 		.autoidle_mask = 0x7 << 3,
550f38b0dd6STero Kristo 		.mult_mask = 0xfff << 8,
551f38b0dd6STero Kristo 		.div1_mask = 0x7f,
552f38b0dd6STero Kristo 		.max_multiplier = 4095,
553f38b0dd6STero Kristo 		.max_divider = 128,
554f38b0dd6STero Kristo 		.min_divider = 1,
555f38b0dd6STero Kristo 		.sddiv_mask = 0xff << 24,
556f38b0dd6STero Kristo 		.dco_mask = 0xe << 20,
557f38b0dd6STero Kristo 		.flags = DPLL_J_TYPE,
558f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_STOP) | (1 << DPLL_LOCKED),
559f38b0dd6STero Kristo 	};
560f38b0dd6STero Kristo 
561a6fe3771STero Kristo 	of_ti_dpll_setup(node, &omap3_dpll_per_ck_ops, &dd);
562f38b0dd6STero Kristo }
563f38b0dd6STero Kristo CLK_OF_DECLARE(ti_omap3_per_jtype_dpll_clock, "ti,omap3-dpll-per-j-type-clock",
564f38b0dd6STero Kristo 	       of_ti_omap3_per_jtype_dpll_setup);
565f38b0dd6STero Kristo #endif
566f38b0dd6STero Kristo 
567f38b0dd6STero Kristo static void __init of_ti_omap4_dpll_setup(struct device_node *node)
568f38b0dd6STero Kristo {
569f38b0dd6STero Kristo 	const struct dpll_data dd = {
570f38b0dd6STero Kristo 		.idlest_mask = 0x1,
571f38b0dd6STero Kristo 		.enable_mask = 0x7,
572f38b0dd6STero Kristo 		.autoidle_mask = 0x7,
573f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
574f38b0dd6STero Kristo 		.div1_mask = 0x7f,
575f38b0dd6STero Kristo 		.max_multiplier = 2047,
576f38b0dd6STero Kristo 		.max_divider = 128,
577f38b0dd6STero Kristo 		.min_divider = 1,
578f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
579f38b0dd6STero Kristo 	};
580f38b0dd6STero Kristo 
581a6fe3771STero Kristo 	of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
582f38b0dd6STero Kristo }
583f38b0dd6STero Kristo CLK_OF_DECLARE(ti_omap4_dpll_clock, "ti,omap4-dpll-clock",
584f38b0dd6STero Kristo 	       of_ti_omap4_dpll_setup);
585f38b0dd6STero Kristo 
586b4be0189SNishanth Menon static void __init of_ti_omap5_mpu_dpll_setup(struct device_node *node)
587b4be0189SNishanth Menon {
588b4be0189SNishanth Menon 	const struct dpll_data dd = {
589b4be0189SNishanth Menon 		.idlest_mask = 0x1,
590b4be0189SNishanth Menon 		.enable_mask = 0x7,
591b4be0189SNishanth Menon 		.autoidle_mask = 0x7,
592b4be0189SNishanth Menon 		.mult_mask = 0x7ff << 8,
593b4be0189SNishanth Menon 		.div1_mask = 0x7f,
594b4be0189SNishanth Menon 		.max_multiplier = 2047,
595b4be0189SNishanth Menon 		.max_divider = 128,
596b4be0189SNishanth Menon 		.dcc_mask = BIT(22),
597b4be0189SNishanth Menon 		.dcc_rate = 1400000000, /* DCC beyond 1.4GHz */
598b4be0189SNishanth Menon 		.min_divider = 1,
599b4be0189SNishanth Menon 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
600b4be0189SNishanth Menon 	};
601b4be0189SNishanth Menon 
602b4be0189SNishanth Menon 	of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
603b4be0189SNishanth Menon }
604b4be0189SNishanth Menon CLK_OF_DECLARE(of_ti_omap5_mpu_dpll_clock, "ti,omap5-mpu-dpll-clock",
605b4be0189SNishanth Menon 	       of_ti_omap5_mpu_dpll_setup);
606b4be0189SNishanth Menon 
607f38b0dd6STero Kristo static void __init of_ti_omap4_core_dpll_setup(struct device_node *node)
608f38b0dd6STero Kristo {
609f38b0dd6STero Kristo 	const struct dpll_data dd = {
610f38b0dd6STero Kristo 		.idlest_mask = 0x1,
611f38b0dd6STero Kristo 		.enable_mask = 0x7,
612f38b0dd6STero Kristo 		.autoidle_mask = 0x7,
613f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
614f38b0dd6STero Kristo 		.div1_mask = 0x7f,
615f38b0dd6STero Kristo 		.max_multiplier = 2047,
616f38b0dd6STero Kristo 		.max_divider = 128,
617f38b0dd6STero Kristo 		.min_divider = 1,
618f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
619f38b0dd6STero Kristo 	};
620f38b0dd6STero Kristo 
621a6fe3771STero Kristo 	of_ti_dpll_setup(node, &dpll_core_ck_ops, &dd);
622f38b0dd6STero Kristo }
623f38b0dd6STero Kristo CLK_OF_DECLARE(ti_omap4_core_dpll_clock, "ti,omap4-dpll-core-clock",
624f38b0dd6STero Kristo 	       of_ti_omap4_core_dpll_setup);
625f38b0dd6STero Kristo 
626f38b0dd6STero Kristo #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
627f38b0dd6STero Kristo 	defined(CONFIG_SOC_DRA7XX)
628f38b0dd6STero Kristo static void __init of_ti_omap4_m4xen_dpll_setup(struct device_node *node)
629f38b0dd6STero Kristo {
630f38b0dd6STero Kristo 	const struct dpll_data dd = {
631f38b0dd6STero Kristo 		.idlest_mask = 0x1,
632f38b0dd6STero Kristo 		.enable_mask = 0x7,
633f38b0dd6STero Kristo 		.autoidle_mask = 0x7,
634f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
635f38b0dd6STero Kristo 		.div1_mask = 0x7f,
636f38b0dd6STero Kristo 		.max_multiplier = 2047,
637f38b0dd6STero Kristo 		.max_divider = 128,
638f38b0dd6STero Kristo 		.min_divider = 1,
639f38b0dd6STero Kristo 		.m4xen_mask = 0x800,
640f38b0dd6STero Kristo 		.lpmode_mask = 1 << 10,
641f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
642f38b0dd6STero Kristo 	};
643f38b0dd6STero Kristo 
644a6fe3771STero Kristo 	of_ti_dpll_setup(node, &dpll_m4xen_ck_ops, &dd);
645f38b0dd6STero Kristo }
646f38b0dd6STero Kristo CLK_OF_DECLARE(ti_omap4_m4xen_dpll_clock, "ti,omap4-dpll-m4xen-clock",
647f38b0dd6STero Kristo 	       of_ti_omap4_m4xen_dpll_setup);
648f38b0dd6STero Kristo 
649f38b0dd6STero Kristo static void __init of_ti_omap4_jtype_dpll_setup(struct device_node *node)
650f38b0dd6STero Kristo {
651f38b0dd6STero Kristo 	const struct dpll_data dd = {
652f38b0dd6STero Kristo 		.idlest_mask = 0x1,
653f38b0dd6STero Kristo 		.enable_mask = 0x7,
654f38b0dd6STero Kristo 		.autoidle_mask = 0x7,
655f38b0dd6STero Kristo 		.mult_mask = 0xfff << 8,
656f38b0dd6STero Kristo 		.div1_mask = 0xff,
657f38b0dd6STero Kristo 		.max_multiplier = 4095,
658f38b0dd6STero Kristo 		.max_divider = 256,
659f38b0dd6STero Kristo 		.min_divider = 1,
660f38b0dd6STero Kristo 		.sddiv_mask = 0xff << 24,
661f38b0dd6STero Kristo 		.flags = DPLL_J_TYPE,
662f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
663f38b0dd6STero Kristo 	};
664f38b0dd6STero Kristo 
665a6fe3771STero Kristo 	of_ti_dpll_setup(node, &dpll_m4xen_ck_ops, &dd);
666f38b0dd6STero Kristo }
667f38b0dd6STero Kristo CLK_OF_DECLARE(ti_omap4_jtype_dpll_clock, "ti,omap4-dpll-j-type-clock",
668f38b0dd6STero Kristo 	       of_ti_omap4_jtype_dpll_setup);
669f38b0dd6STero Kristo #endif
670f38b0dd6STero Kristo 
671f38b0dd6STero Kristo static void __init of_ti_am3_no_gate_dpll_setup(struct device_node *node)
672f38b0dd6STero Kristo {
673f38b0dd6STero Kristo 	const struct dpll_data dd = {
674f38b0dd6STero Kristo 		.idlest_mask = 0x1,
675f38b0dd6STero Kristo 		.enable_mask = 0x7,
676f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
677f38b0dd6STero Kristo 		.div1_mask = 0x7f,
678f38b0dd6STero Kristo 		.max_multiplier = 2047,
679f38b0dd6STero Kristo 		.max_divider = 128,
680f38b0dd6STero Kristo 		.min_divider = 1,
6813db5ca27STero Kristo 		.max_rate = 1000000000,
682f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
683f38b0dd6STero Kristo 	};
684f38b0dd6STero Kristo 
685a6fe3771STero Kristo 	of_ti_dpll_setup(node, &dpll_no_gate_ck_ops, &dd);
686f38b0dd6STero Kristo }
687f38b0dd6STero Kristo CLK_OF_DECLARE(ti_am3_no_gate_dpll_clock, "ti,am3-dpll-no-gate-clock",
688f38b0dd6STero Kristo 	       of_ti_am3_no_gate_dpll_setup);
689f38b0dd6STero Kristo 
690f38b0dd6STero Kristo static void __init of_ti_am3_jtype_dpll_setup(struct device_node *node)
691f38b0dd6STero Kristo {
692f38b0dd6STero Kristo 	const struct dpll_data dd = {
693f38b0dd6STero Kristo 		.idlest_mask = 0x1,
694f38b0dd6STero Kristo 		.enable_mask = 0x7,
695f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
696f38b0dd6STero Kristo 		.div1_mask = 0x7f,
697f38b0dd6STero Kristo 		.max_multiplier = 4095,
698f38b0dd6STero Kristo 		.max_divider = 256,
699f38b0dd6STero Kristo 		.min_divider = 2,
700f38b0dd6STero Kristo 		.flags = DPLL_J_TYPE,
7013db5ca27STero Kristo 		.max_rate = 2000000000,
702f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
703f38b0dd6STero Kristo 	};
704f38b0dd6STero Kristo 
705a6fe3771STero Kristo 	of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
706f38b0dd6STero Kristo }
707f38b0dd6STero Kristo CLK_OF_DECLARE(ti_am3_jtype_dpll_clock, "ti,am3-dpll-j-type-clock",
708f38b0dd6STero Kristo 	       of_ti_am3_jtype_dpll_setup);
709f38b0dd6STero Kristo 
710f38b0dd6STero Kristo static void __init of_ti_am3_no_gate_jtype_dpll_setup(struct device_node *node)
711f38b0dd6STero Kristo {
712f38b0dd6STero Kristo 	const struct dpll_data dd = {
713f38b0dd6STero Kristo 		.idlest_mask = 0x1,
714f38b0dd6STero Kristo 		.enable_mask = 0x7,
715f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
716f38b0dd6STero Kristo 		.div1_mask = 0x7f,
717f38b0dd6STero Kristo 		.max_multiplier = 2047,
718f38b0dd6STero Kristo 		.max_divider = 128,
719f38b0dd6STero Kristo 		.min_divider = 1,
7203db5ca27STero Kristo 		.max_rate = 2000000000,
721f38b0dd6STero Kristo 		.flags = DPLL_J_TYPE,
722f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
723f38b0dd6STero Kristo 	};
724f38b0dd6STero Kristo 
725a6fe3771STero Kristo 	of_ti_dpll_setup(node, &dpll_no_gate_ck_ops, &dd);
726f38b0dd6STero Kristo }
727f38b0dd6STero Kristo CLK_OF_DECLARE(ti_am3_no_gate_jtype_dpll_clock,
728f38b0dd6STero Kristo 	       "ti,am3-dpll-no-gate-j-type-clock",
729f38b0dd6STero Kristo 	       of_ti_am3_no_gate_jtype_dpll_setup);
730f38b0dd6STero Kristo 
731f38b0dd6STero Kristo static void __init of_ti_am3_dpll_setup(struct device_node *node)
732f38b0dd6STero Kristo {
733f38b0dd6STero Kristo 	const struct dpll_data dd = {
734f38b0dd6STero Kristo 		.idlest_mask = 0x1,
735f38b0dd6STero Kristo 		.enable_mask = 0x7,
736f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
737f38b0dd6STero Kristo 		.div1_mask = 0x7f,
738f38b0dd6STero Kristo 		.max_multiplier = 2047,
739f38b0dd6STero Kristo 		.max_divider = 128,
740f38b0dd6STero Kristo 		.min_divider = 1,
7413db5ca27STero Kristo 		.max_rate = 1000000000,
742f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
743f38b0dd6STero Kristo 	};
744f38b0dd6STero Kristo 
745a6fe3771STero Kristo 	of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
746f38b0dd6STero Kristo }
747f38b0dd6STero Kristo CLK_OF_DECLARE(ti_am3_dpll_clock, "ti,am3-dpll-clock", of_ti_am3_dpll_setup);
748f38b0dd6STero Kristo 
749f38b0dd6STero Kristo static void __init of_ti_am3_core_dpll_setup(struct device_node *node)
750f38b0dd6STero Kristo {
751f38b0dd6STero Kristo 	const struct dpll_data dd = {
752f38b0dd6STero Kristo 		.idlest_mask = 0x1,
753f38b0dd6STero Kristo 		.enable_mask = 0x7,
754f38b0dd6STero Kristo 		.mult_mask = 0x7ff << 8,
755f38b0dd6STero Kristo 		.div1_mask = 0x7f,
756f38b0dd6STero Kristo 		.max_multiplier = 2047,
757f38b0dd6STero Kristo 		.max_divider = 128,
758f38b0dd6STero Kristo 		.min_divider = 1,
7593db5ca27STero Kristo 		.max_rate = 1000000000,
760f38b0dd6STero Kristo 		.modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
761f38b0dd6STero Kristo 	};
762f38b0dd6STero Kristo 
763a6fe3771STero Kristo 	of_ti_dpll_setup(node, &dpll_core_ck_ops, &dd);
764f38b0dd6STero Kristo }
765f38b0dd6STero Kristo CLK_OF_DECLARE(ti_am3_core_dpll_clock, "ti,am3-dpll-core-clock",
766f38b0dd6STero Kristo 	       of_ti_am3_core_dpll_setup);
767aa76fcf4STero Kristo 
768aa76fcf4STero Kristo static void __init of_ti_omap2_core_dpll_setup(struct device_node *node)
769aa76fcf4STero Kristo {
770aa76fcf4STero Kristo 	const struct dpll_data dd = {
771aa76fcf4STero Kristo 		.enable_mask = 0x3,
772aa76fcf4STero Kristo 		.mult_mask = 0x3ff << 12,
773aa76fcf4STero Kristo 		.div1_mask = 0xf << 8,
774aa76fcf4STero Kristo 		.max_divider = 16,
775aa76fcf4STero Kristo 		.min_divider = 1,
776aa76fcf4STero Kristo 	};
777aa76fcf4STero Kristo 
778aa76fcf4STero Kristo 	of_ti_dpll_setup(node, &omap2_dpll_core_ck_ops, &dd);
779aa76fcf4STero Kristo }
780aa76fcf4STero Kristo CLK_OF_DECLARE(ti_omap2_core_dpll_clock, "ti,omap2-dpll-core-clock",
781aa76fcf4STero Kristo 	       of_ti_omap2_core_dpll_setup);
782