aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-01 21:28:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-01 21:28:06 -0400
commit2a2bf85f05e42b12ea6bfe821e2d19221cf93555 (patch)
tree11abcdaef6e4f8307574056998d306d21558b6ed /drivers/clk
parent11801e9de26992d37cb869cc74f389b6a7677e0e (diff)
parent99261fbad0a16f105b262d7525801697588ba526 (diff)
Merge tag 'dt' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull ARM soc device tree updates from Olof Johansson: "Device tree conversion and enablement branch. Mostly a bunch of new bindings and setup for various platforms, but the Via/Winchip VT8500 platform is also converted over from being 100% legacy to now use device tree for probing. More of that will come for 3.8." Trivial conflicts due to removal of vt8500 files, and one documentation file that was added with slightly different contents both here and in the USb tree. * tag 'dt' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (212 commits) arm: vt8500: Fixup for missing gpio.h ARM: LPC32xx: LED fix in PHY3250 DTS file ARM: dt: mmp-dma: add binding file arm: vt8500: Update arch-vt8500 to devicetree support. arm: vt8500: gpio: Devicetree support for arch-vt8500 arm: vt8500: doc: Add device tree bindings for arch-vt8500 devices arm: vt8500: clk: Add Common Clock Framework support video: vt8500: Add devicetree support for vt8500-fb and wm8505-fb serial: vt8500: Add devicetree support for vt8500-serial rtc: vt8500: Add devicetree support for vt8500-rtc arm: vt8500: Add device tree files for VIA/Wondermedia SoC's ARM: tegra: Add Avionic Design Tamonten Evaluation Carrier support ARM: tegra: Add Avionic Design Medcom-Wide support ARM: tegra: Add Avionic Design Plutux support ARM: tegra: Add Avionic Design Tamonten support ARM: tegra: dts: Add pwm label ARM: ux500: Fix SSP register address format ARM: ux500: Apply tc3589x's GPIO/IRQ properties to HREF's DT ARM: ux500: Remove redundant #gpio-cell properties from Snowball DT ARM: ux500: Add all encompassing sound node to the HREF Device Tree ...
Diffstat (limited to 'drivers/clk')
-rw-r--r--drivers/clk/Makefile1
-rw-r--r--drivers/clk/clk-vt8500.c510
-rw-r--r--drivers/clk/mxs/clk-imx23.c55
-rw-r--r--drivers/clk/mxs/clk-imx28.c113
4 files changed, 531 insertions, 148 deletions
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 2b861625bda..71a25b91de0 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_ARCH_MMP) += mmp/
18endif 18endif
19obj-$(CONFIG_MACH_LOONGSON1) += clk-ls1x.o 19obj-$(CONFIG_MACH_LOONGSON1) += clk-ls1x.o
20obj-$(CONFIG_ARCH_U8500) += ux500/ 20obj-$(CONFIG_ARCH_U8500) += ux500/
21obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
21 22
22# Chip specific 23# Chip specific
23obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o 24obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c
new file mode 100644
index 00000000000..a885600f527
--- /dev/null
+++ b/drivers/clk/clk-vt8500.c
@@ -0,0 +1,510 @@
1/*
2 * Clock implementation for VIA/Wondermedia SoC's
3 * Copyright (C) 2012 Tony Prisk <linux@prisktech.co.nz>
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16#include <linux/io.h>
17#include <linux/of.h>
18#include <linux/slab.h>
19#include <linux/bitops.h>
20#include <linux/clkdev.h>
21#include <linux/clk-provider.h>
22
23/* All clocks share the same lock as none can be changed concurrently */
24static DEFINE_SPINLOCK(_lock);
25
26struct clk_device {
27 struct clk_hw hw;
28 void __iomem *div_reg;
29 unsigned int div_mask;
30 void __iomem *en_reg;
31 int en_bit;
32 spinlock_t *lock;
33};
34
35/*
36 * Add new PLL_TYPE_x definitions here as required. Use the first known model
37 * to support the new type as the name.
38 * Add case statements to vtwm_pll_recalc_rate(), vtwm_pll_round_round() and
39 * vtwm_pll_set_rate() to handle the new PLL_TYPE_x
40 */
41
42#define PLL_TYPE_VT8500 0
43#define PLL_TYPE_WM8650 1
44
45struct clk_pll {
46 struct clk_hw hw;
47 void __iomem *reg;
48 spinlock_t *lock;
49 int type;
50};
51
52static void __iomem *pmc_base;
53
54#define to_clk_device(_hw) container_of(_hw, struct clk_device, hw)
55
56#define VT8500_PMC_BUSY_MASK 0x18
57
58static void vt8500_pmc_wait_busy(void)
59{
60 while (readl(pmc_base) & VT8500_PMC_BUSY_MASK)
61 cpu_relax();
62}
63
64static int vt8500_dclk_enable(struct clk_hw *hw)
65{
66 struct clk_device *cdev = to_clk_device(hw);
67 u32 en_val;
68 unsigned long flags = 0;
69
70 spin_lock_irqsave(cdev->lock, flags);
71
72 en_val = readl(cdev->en_reg);
73 en_val |= BIT(cdev->en_bit);
74 writel(en_val, cdev->en_reg);
75
76 spin_unlock_irqrestore(cdev->lock, flags);
77 return 0;
78}
79
80static void vt8500_dclk_disable(struct clk_hw *hw)
81{
82 struct clk_device *cdev = to_clk_device(hw);
83 u32 en_val;
84 unsigned long flags = 0;
85
86 spin_lock_irqsave(cdev->lock, flags);
87
88 en_val = readl(cdev->en_reg);
89 en_val &= ~BIT(cdev->en_bit);
90 writel(en_val, cdev->en_reg);
91
92 spin_unlock_irqrestore(cdev->lock, flags);
93}
94
95static int vt8500_dclk_is_enabled(struct clk_hw *hw)
96{
97 struct clk_device *cdev = to_clk_device(hw);
98 u32 en_val = (readl(cdev->en_reg) & BIT(cdev->en_bit));
99
100 return en_val ? 1 : 0;
101}
102
103static unsigned long vt8500_dclk_recalc_rate(struct clk_hw *hw,
104 unsigned long parent_rate)
105{
106 struct clk_device *cdev = to_clk_device(hw);
107 u32 div = readl(cdev->div_reg) & cdev->div_mask;
108
109 /* Special case for SDMMC devices */
110 if ((cdev->div_mask == 0x3F) && (div & BIT(5)))
111 div = 64 * (div & 0x1f);
112
113 /* div == 0 is actually the highest divisor */
114 if (div == 0)
115 div = (cdev->div_mask + 1);
116
117 return parent_rate / div;
118}
119
120static long vt8500_dclk_round_rate(struct clk_hw *hw, unsigned long rate,
121 unsigned long *prate)
122{
123 u32 divisor = *prate / rate;
124
125 return *prate / divisor;
126}
127
128static int vt8500_dclk_set_rate(struct clk_hw *hw, unsigned long rate,
129 unsigned long parent_rate)
130{
131 struct clk_device *cdev = to_clk_device(hw);
132 u32 divisor = parent_rate / rate;
133 unsigned long flags = 0;
134
135 if (divisor == cdev->div_mask + 1)
136 divisor = 0;
137
138 if (divisor > cdev->div_mask) {
139 pr_err("%s: invalid divisor for clock\n", __func__);
140 return -EINVAL;
141 }
142
143 spin_lock_irqsave(cdev->lock, flags);
144
145 vt8500_pmc_wait_busy();
146 writel(divisor, cdev->div_reg);
147 vt8500_pmc_wait_busy();
148
149 spin_lock_irqsave(cdev->lock, flags);
150
151 return 0;
152}
153
154
155static const struct clk_ops vt8500_gated_clk_ops = {
156 .enable = vt8500_dclk_enable,
157 .disable = vt8500_dclk_disable,
158 .is_enabled = vt8500_dclk_is_enabled,
159};
160
161static const struct clk_ops vt8500_divisor_clk_ops = {
162 .round_rate = vt8500_dclk_round_rate,
163 .set_rate = vt8500_dclk_set_rate,
164 .recalc_rate = vt8500_dclk_recalc_rate,
165};
166
167static const struct clk_ops vt8500_gated_divisor_clk_ops = {
168 .enable = vt8500_dclk_enable,
169 .disable = vt8500_dclk_disable,
170 .is_enabled = vt8500_dclk_is_enabled,
171 .round_rate = vt8500_dclk_round_rate,
172 .set_rate = vt8500_dclk_set_rate,
173 .recalc_rate = vt8500_dclk_recalc_rate,
174};
175
176#define CLK_INIT_GATED BIT(0)
177#define CLK_INIT_DIVISOR BIT(1)
178#define CLK_INIT_GATED_DIVISOR (CLK_INIT_DIVISOR | CLK_INIT_GATED)
179
180static __init void vtwm_device_clk_init(struct device_node *node)
181{
182 u32 en_reg, div_reg;
183 struct clk *clk;
184 struct clk_device *dev_clk;
185 const char *clk_name = node->name;
186 const char *parent_name;
187 struct clk_init_data init;
188 int rc;
189 int clk_init_flags = 0;
190
191 dev_clk = kzalloc(sizeof(*dev_clk), GFP_KERNEL);
192 if (WARN_ON(!dev_clk))
193 return;
194
195 dev_clk->lock = &_lock;
196
197 rc = of_property_read_u32(node, "enable-reg", &en_reg);
198 if (!rc) {
199 dev_clk->en_reg = pmc_base + en_reg;
200 rc = of_property_read_u32(node, "enable-bit", &dev_clk->en_bit);
201 if (rc) {
202 pr_err("%s: enable-bit property required for gated clock\n",
203 __func__);
204 return;
205 }
206 clk_init_flags |= CLK_INIT_GATED;
207 }
208
209 rc = of_property_read_u32(node, "divisor-reg", &div_reg);
210 if (!rc) {
211 dev_clk->div_reg = pmc_base + div_reg;
212 /*
213 * use 0x1f as the default mask since it covers
214 * almost all the clocks and reduces dts properties
215 */
216 dev_clk->div_mask = 0x1f;
217
218 of_property_read_u32(node, "divisor-mask", &dev_clk->div_mask);
219 clk_init_flags |= CLK_INIT_DIVISOR;
220 }
221
222 of_property_read_string(node, "clock-output-names", &clk_name);
223
224 switch (clk_init_flags) {
225 case CLK_INIT_GATED:
226 init.ops = &vt8500_gated_clk_ops;
227 break;
228 case CLK_INIT_DIVISOR:
229 init.ops = &vt8500_divisor_clk_ops;
230 break;
231 case CLK_INIT_GATED_DIVISOR:
232 init.ops = &vt8500_gated_divisor_clk_ops;
233 break;
234 default:
235 pr_err("%s: Invalid clock description in device tree\n",
236 __func__);
237 kfree(dev_clk);
238 return;
239 }
240
241 init.name = clk_name;
242 init.flags = 0;
243 parent_name = of_clk_get_parent_name(node, 0);
244 init.parent_names = &parent_name;
245 init.num_parents = 1;
246
247 dev_clk->hw.init = &init;
248
249 clk = clk_register(NULL, &dev_clk->hw);
250 if (WARN_ON(IS_ERR(clk))) {
251 kfree(dev_clk);
252 return;
253 }
254 rc = of_clk_add_provider(node, of_clk_src_simple_get, clk);
255 clk_register_clkdev(clk, clk_name, NULL);
256}
257
258
259/* PLL clock related functions */
260
261#define to_clk_pll(_hw) container_of(_hw, struct clk_pll, hw)
262
263/* Helper macros for PLL_VT8500 */
264#define VT8500_PLL_MUL(x) ((x & 0x1F) << 1)
265#define VT8500_PLL_DIV(x) ((x & 0x100) ? 1 : 2)
266
267#define VT8500_BITS_TO_FREQ(r, m, d) \
268 ((r / d) * m)
269
270#define VT8500_BITS_TO_VAL(m, d) \
271 ((d == 2 ? 0 : 0x100) | ((m >> 1) & 0x1F))
272
273/* Helper macros for PLL_WM8650 */
274#define WM8650_PLL_MUL(x) (x & 0x3FF)
275#define WM8650_PLL_DIV(x) (((x >> 10) & 7) * (1 << ((x >> 13) & 3)))
276
277#define WM8650_BITS_TO_FREQ(r, m, d1, d2) \
278 (r * m / (d1 * (1 << d2)))
279
280#define WM8650_BITS_TO_VAL(m, d1, d2) \
281 ((d2 << 13) | (d1 << 10) | (m & 0x3FF))
282
283
284static void vt8500_find_pll_bits(unsigned long rate, unsigned long parent_rate,
285 u32 *multiplier, u32 *prediv)
286{
287 unsigned long tclk;
288
289 /* sanity check */
290 if ((rate < parent_rate * 4) || (rate > parent_rate * 62)) {
291 pr_err("%s: requested rate out of range\n", __func__);
292 *multiplier = 0;
293 *prediv = 1;
294 return;
295 }
296 if (rate <= parent_rate * 31)
297 /* use the prediv to double the resolution */
298 *prediv = 2;
299 else
300 *prediv = 1;
301
302 *multiplier = rate / (parent_rate / *prediv);
303 tclk = (parent_rate / *prediv) * *multiplier;
304
305 if (tclk != rate)
306 pr_warn("%s: requested rate %lu, found rate %lu\n", __func__,
307 rate, tclk);
308}
309
310static void wm8650_find_pll_bits(unsigned long rate, unsigned long parent_rate,
311 u32 *multiplier, u32 *divisor1, u32 *divisor2)
312{
313 u32 mul, div1, div2;
314 u32 best_mul, best_div1, best_div2;
315 unsigned long tclk, rate_err, best_err;
316
317 best_err = (unsigned long)-1;
318
319 /* Find the closest match (lower or equal to requested) */
320 for (div1 = 5; div1 >= 3; div1--)
321 for (div2 = 3; div2 >= 0; div2--)
322 for (mul = 3; mul <= 1023; mul++) {
323 tclk = parent_rate * mul / (div1 * (1 << div2));
324 if (tclk > rate)
325 continue;
326 /* error will always be +ve */
327 rate_err = rate - tclk;
328 if (rate_err == 0) {
329 *multiplier = mul;
330 *divisor1 = div1;
331 *divisor2 = div2;
332 return;
333 }
334
335 if (rate_err < best_err) {
336 best_err = rate_err;
337 best_mul = mul;
338 best_div1 = div1;
339 best_div2 = div2;
340 }
341 }
342
343 /* if we got here, it wasn't an exact match */
344 pr_warn("%s: requested rate %lu, found rate %lu\n", __func__, rate,
345 rate - best_err);
346 *multiplier = mul;
347 *divisor1 = div1;
348 *divisor2 = div2;
349}
350
351static int vtwm_pll_set_rate(struct clk_hw *hw, unsigned long rate,
352 unsigned long parent_rate)
353{
354 struct clk_pll *pll = to_clk_pll(hw);
355 u32 mul, div1, div2;
356 u32 pll_val;
357 unsigned long flags = 0;
358
359 /* sanity check */
360
361 switch (pll->type) {
362 case PLL_TYPE_VT8500:
363 vt8500_find_pll_bits(rate, parent_rate, &mul, &div1);
364 pll_val = VT8500_BITS_TO_VAL(mul, div1);
365 break;
366 case PLL_TYPE_WM8650:
367 wm8650_find_pll_bits(rate, parent_rate, &mul, &div1, &div2);
368 pll_val = WM8650_BITS_TO_VAL(mul, div1, div2);
369 break;
370 default:
371 pr_err("%s: invalid pll type\n", __func__);
372 return 0;
373 }
374
375 spin_lock_irqsave(pll->lock, flags);
376
377 vt8500_pmc_wait_busy();
378 writel(pll_val, pll->reg);
379 vt8500_pmc_wait_busy();
380
381 spin_unlock_irqrestore(pll->lock, flags);
382
383 return 0;
384}
385
386static long vtwm_pll_round_rate(struct clk_hw *hw, unsigned long rate,
387 unsigned long *prate)
388{
389 struct clk_pll *pll = to_clk_pll(hw);
390 u32 mul, div1, div2;
391 long round_rate;
392
393 switch (pll->type) {
394 case PLL_TYPE_VT8500:
395 vt8500_find_pll_bits(rate, *prate, &mul, &div1);
396 round_rate = VT8500_BITS_TO_FREQ(*prate, mul, div1);
397 break;
398 case PLL_TYPE_WM8650:
399 wm8650_find_pll_bits(rate, *prate, &mul, &div1, &div2);
400 round_rate = WM8650_BITS_TO_FREQ(*prate, mul, div1, div2);
401 break;
402 default:
403 round_rate = 0;
404 }
405
406 return round_rate;
407}
408
409static unsigned long vtwm_pll_recalc_rate(struct clk_hw *hw,
410 unsigned long parent_rate)
411{
412 struct clk_pll *pll = to_clk_pll(hw);
413 u32 pll_val = readl(pll->reg);
414 unsigned long pll_freq;
415
416 switch (pll->type) {
417 case PLL_TYPE_VT8500:
418 pll_freq = parent_rate * VT8500_PLL_MUL(pll_val);
419 pll_freq /= VT8500_PLL_DIV(pll_val);
420 break;
421 case PLL_TYPE_WM8650:
422 pll_freq = parent_rate * WM8650_PLL_MUL(pll_val);
423 pll_freq /= WM8650_PLL_DIV(pll_val);
424 break;
425 default:
426 pll_freq = 0;
427 }
428
429 return pll_freq;
430}
431
432const struct clk_ops vtwm_pll_ops = {
433 .round_rate = vtwm_pll_round_rate,
434 .set_rate = vtwm_pll_set_rate,
435 .recalc_rate = vtwm_pll_recalc_rate,
436};
437
438static __init void vtwm_pll_clk_init(struct device_node *node, int pll_type)
439{
440 u32 reg;
441 struct clk *clk;
442 struct clk_pll *pll_clk;
443 const char *clk_name = node->name;
444 const char *parent_name;
445 struct clk_init_data init;
446 int rc;
447
448 rc = of_property_read_u32(node, "reg", &reg);
449 if (WARN_ON(rc))
450 return;
451
452 pll_clk = kzalloc(sizeof(*pll_clk), GFP_KERNEL);
453 if (WARN_ON(!pll_clk))
454 return;
455
456 pll_clk->reg = pmc_base + reg;
457 pll_clk->lock = &_lock;
458 pll_clk->type = pll_type;
459
460 of_property_read_string(node, "clock-output-names", &clk_name);
461
462 init.name = clk_name;
463 init.ops = &vtwm_pll_ops;
464 init.flags = 0;
465 parent_name = of_clk_get_parent_name(node, 0);
466 init.parent_names = &parent_name;
467 init.num_parents = 1;
468
469 pll_clk->hw.init = &init;
470
471 clk = clk_register(NULL, &pll_clk->hw);
472 if (WARN_ON(IS_ERR(clk))) {
473 kfree(pll_clk);
474 return;
475 }
476 rc = of_clk_add_provider(node, of_clk_src_simple_get, clk);
477 clk_register_clkdev(clk, clk_name, NULL);
478}
479
480
481/* Wrappers for initialization functions */
482
483static void __init vt8500_pll_init(struct device_node *node)
484{
485 vtwm_pll_clk_init(node, PLL_TYPE_VT8500);
486}
487
488static void __init wm8650_pll_init(struct device_node *node)
489{
490 vtwm_pll_clk_init(node, PLL_TYPE_WM8650);
491}
492
493static const __initconst struct of_device_id clk_match[] = {
494 { .compatible = "fixed-clock", .data = of_fixed_clk_setup, },
495 { .compatible = "via,vt8500-pll-clock", .data = vt8500_pll_init, },
496 { .compatible = "wm,wm8650-pll-clock", .data = wm8650_pll_init, },
497 { .compatible = "via,vt8500-device-clock",
498 .data = vtwm_device_clk_init, },
499 { /* sentinel */ }
500};
501
502void __init vtwm_clk_init(void __iomem *base)
503{
504 if (!base)
505 return;
506
507 pmc_base = base;
508
509 of_clk_init(clk_match);
510}
diff --git a/drivers/clk/mxs/clk-imx23.c b/drivers/clk/mxs/clk-imx23.c
index 844043ad0fe..9f6d15546cb 100644
--- a/drivers/clk/mxs/clk-imx23.c
+++ b/drivers/clk/mxs/clk-imx23.c
@@ -14,6 +14,7 @@
14#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/of.h>
17#include <mach/common.h> 18#include <mach/common.h>
18#include <mach/mx23.h> 19#include <mach/mx23.h>
19#include "clk.h" 20#include "clk.h"
@@ -71,44 +72,6 @@ static void __init clk_misc_init(void)
71 __mxs_setl(30 << BP_FRAC_IOFRAC, FRAC); 72 __mxs_setl(30 << BP_FRAC_IOFRAC, FRAC);
72} 73}
73 74
74static struct clk_lookup uart_lookups[] = {
75 { .dev_id = "duart", },
76 { .dev_id = "mxs-auart.0", },
77 { .dev_id = "mxs-auart.1", },
78 { .dev_id = "8006c000.serial", },
79 { .dev_id = "8006e000.serial", },
80 { .dev_id = "80070000.serial", },
81};
82
83static struct clk_lookup hbus_lookups[] = {
84 { .dev_id = "imx23-dma-apbh", },
85 { .dev_id = "80004000.dma-apbh", },
86};
87
88static struct clk_lookup xbus_lookups[] = {
89 { .dev_id = "duart", .con_id = "apb_pclk"},
90 { .dev_id = "80070000.serial", .con_id = "apb_pclk"},
91 { .dev_id = "imx23-dma-apbx", },
92 { .dev_id = "80024000.dma-apbx", },
93};
94
95static struct clk_lookup ssp_lookups[] = {
96 { .dev_id = "imx23-mmc.0", },
97 { .dev_id = "imx23-mmc.1", },
98 { .dev_id = "80010000.ssp", },
99 { .dev_id = "80034000.ssp", },
100};
101
102static struct clk_lookup lcdif_lookups[] = {
103 { .dev_id = "imx23-fb", },
104 { .dev_id = "80030000.lcdif", },
105};
106
107static struct clk_lookup gpmi_lookups[] = {
108 { .dev_id = "imx23-gpmi-nand", },
109 { .dev_id = "8000c000.gpmi-nand", },
110};
111
112static const char *sel_pll[] __initconst = { "pll", "ref_xtal", }; 75static const char *sel_pll[] __initconst = { "pll", "ref_xtal", };
113static const char *sel_cpu[] __initconst = { "ref_cpu", "ref_xtal", }; 76static const char *sel_cpu[] __initconst = { "ref_cpu", "ref_xtal", };
114static const char *sel_pix[] __initconst = { "ref_pix", "ref_xtal", }; 77static const char *sel_pix[] __initconst = { "ref_pix", "ref_xtal", };
@@ -127,6 +90,7 @@ enum imx23_clk {
127}; 90};
128 91
129static struct clk *clks[clk_max]; 92static struct clk *clks[clk_max];
93static struct clk_onecell_data clk_data;
130 94
131static enum imx23_clk clks_init_on[] __initdata = { 95static enum imx23_clk clks_init_on[] __initdata = {
132 cpu, hbus, xbus, emi, uart, 96 cpu, hbus, xbus, emi, uart,
@@ -134,6 +98,7 @@ static enum imx23_clk clks_init_on[] __initdata = {
134 98
135int __init mx23_clocks_init(void) 99int __init mx23_clocks_init(void)
136{ 100{
101 struct device_node *np;
137 int i; 102 int i;
138 103
139 clk_misc_init(); 104 clk_misc_init();
@@ -188,14 +153,14 @@ int __init mx23_clocks_init(void)
188 return PTR_ERR(clks[i]); 153 return PTR_ERR(clks[i]);
189 } 154 }
190 155
156 np = of_find_compatible_node(NULL, NULL, "fsl,imx23-clkctrl");
157 if (np) {
158 clk_data.clks = clks;
159 clk_data.clk_num = ARRAY_SIZE(clks);
160 of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
161 }
162
191 clk_register_clkdev(clks[clk32k], NULL, "timrot"); 163 clk_register_clkdev(clks[clk32k], NULL, "timrot");
192 clk_register_clkdev(clks[pwm], NULL, "80064000.pwm");
193 clk_register_clkdevs(clks[hbus], hbus_lookups, ARRAY_SIZE(hbus_lookups));
194 clk_register_clkdevs(clks[xbus], xbus_lookups, ARRAY_SIZE(xbus_lookups));
195 clk_register_clkdevs(clks[uart], uart_lookups, ARRAY_SIZE(uart_lookups));
196 clk_register_clkdevs(clks[ssp], ssp_lookups, ARRAY_SIZE(ssp_lookups));
197 clk_register_clkdevs(clks[gpmi], gpmi_lookups, ARRAY_SIZE(gpmi_lookups));
198 clk_register_clkdevs(clks[lcdif], lcdif_lookups, ARRAY_SIZE(lcdif_lookups));
199 164
200 for (i = 0; i < ARRAY_SIZE(clks_init_on); i++) 165 for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
201 clk_prepare_enable(clks[clks_init_on[i]]); 166 clk_prepare_enable(clks[clks_init_on[i]]);
diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c
index e3aab67b3eb..613e76f3758 100644
--- a/drivers/clk/mxs/clk-imx28.c
+++ b/drivers/clk/mxs/clk-imx28.c
@@ -14,6 +14,7 @@
14#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/of.h>
17#include <mach/common.h> 18#include <mach/common.h>
18#include <mach/mx28.h> 19#include <mach/mx28.h>
19#include "clk.h" 20#include "clk.h"
@@ -120,90 +121,6 @@ static void __init clk_misc_init(void)
120 writel_relaxed(val, FRAC0); 121 writel_relaxed(val, FRAC0);
121} 122}
122 123
123static struct clk_lookup uart_lookups[] = {
124 { .dev_id = "duart", },
125 { .dev_id = "mxs-auart.0", },
126 { .dev_id = "mxs-auart.1", },
127 { .dev_id = "mxs-auart.2", },
128 { .dev_id = "mxs-auart.3", },
129 { .dev_id = "mxs-auart.4", },
130 { .dev_id = "8006a000.serial", },
131 { .dev_id = "8006c000.serial", },
132 { .dev_id = "8006e000.serial", },
133 { .dev_id = "80070000.serial", },
134 { .dev_id = "80072000.serial", },
135 { .dev_id = "80074000.serial", },
136};
137
138static struct clk_lookup hbus_lookups[] = {
139 { .dev_id = "imx28-dma-apbh", },
140 { .dev_id = "80004000.dma-apbh", },
141};
142
143static struct clk_lookup xbus_lookups[] = {
144 { .dev_id = "duart", .con_id = "apb_pclk"},
145 { .dev_id = "80074000.serial", .con_id = "apb_pclk"},
146 { .dev_id = "imx28-dma-apbx", },
147 { .dev_id = "80024000.dma-apbx", },
148};
149
150static struct clk_lookup ssp0_lookups[] = {
151 { .dev_id = "imx28-mmc.0", },
152 { .dev_id = "80010000.ssp", },
153};
154
155static struct clk_lookup ssp1_lookups[] = {
156 { .dev_id = "imx28-mmc.1", },
157 { .dev_id = "80012000.ssp", },
158};
159
160static struct clk_lookup ssp2_lookups[] = {
161 { .dev_id = "imx28-mmc.2", },
162 { .dev_id = "80014000.ssp", },
163};
164
165static struct clk_lookup ssp3_lookups[] = {
166 { .dev_id = "imx28-mmc.3", },
167 { .dev_id = "80016000.ssp", },
168};
169
170static struct clk_lookup lcdif_lookups[] = {
171 { .dev_id = "imx28-fb", },
172 { .dev_id = "80030000.lcdif", },
173};
174
175static struct clk_lookup gpmi_lookups[] = {
176 { .dev_id = "imx28-gpmi-nand", },
177 { .dev_id = "8000c000.gpmi-nand", },
178};
179
180static struct clk_lookup fec_lookups[] = {
181 { .dev_id = "imx28-fec.0", },
182 { .dev_id = "imx28-fec.1", },
183 { .dev_id = "800f0000.ethernet", },
184 { .dev_id = "800f4000.ethernet", },
185};
186
187static struct clk_lookup can0_lookups[] = {
188 { .dev_id = "flexcan.0", },
189 { .dev_id = "80032000.can", },
190};
191
192static struct clk_lookup can1_lookups[] = {
193 { .dev_id = "flexcan.1", },
194 { .dev_id = "80034000.can", },
195};
196
197static struct clk_lookup saif0_lookups[] = {
198 { .dev_id = "mxs-saif.0", },
199 { .dev_id = "80042000.saif", },
200};
201
202static struct clk_lookup saif1_lookups[] = {
203 { .dev_id = "mxs-saif.1", },
204 { .dev_id = "80046000.saif", },
205};
206
207static const char *sel_cpu[] __initconst = { "ref_cpu", "ref_xtal", }; 124static const char *sel_cpu[] __initconst = { "ref_cpu", "ref_xtal", };
208static const char *sel_io0[] __initconst = { "ref_io0", "ref_xtal", }; 125static const char *sel_io0[] __initconst = { "ref_io0", "ref_xtal", };
209static const char *sel_io1[] __initconst = { "ref_io1", "ref_xtal", }; 126static const char *sel_io1[] __initconst = { "ref_io1", "ref_xtal", };
@@ -228,6 +145,7 @@ enum imx28_clk {
228}; 145};
229 146
230static struct clk *clks[clk_max]; 147static struct clk *clks[clk_max];
148static struct clk_onecell_data clk_data;
231 149
232static enum imx28_clk clks_init_on[] __initdata = { 150static enum imx28_clk clks_init_on[] __initdata = {
233 cpu, hbus, xbus, emi, uart, 151 cpu, hbus, xbus, emi, uart,
@@ -235,6 +153,7 @@ static enum imx28_clk clks_init_on[] __initdata = {
235 153
236int __init mx28_clocks_init(void) 154int __init mx28_clocks_init(void)
237{ 155{
156 struct device_node *np;
238 int i; 157 int i;
239 158
240 clk_misc_init(); 159 clk_misc_init();
@@ -312,27 +231,15 @@ int __init mx28_clocks_init(void)
312 return PTR_ERR(clks[i]); 231 return PTR_ERR(clks[i]);
313 } 232 }
314 233
234 np = of_find_compatible_node(NULL, NULL, "fsl,imx28-clkctrl");
235 if (np) {
236 clk_data.clks = clks;
237 clk_data.clk_num = ARRAY_SIZE(clks);
238 of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
239 }
240
315 clk_register_clkdev(clks[clk32k], NULL, "timrot"); 241 clk_register_clkdev(clks[clk32k], NULL, "timrot");
316 clk_register_clkdev(clks[enet_out], NULL, "enet_out"); 242 clk_register_clkdev(clks[enet_out], NULL, "enet_out");
317 clk_register_clkdev(clks[pwm], NULL, "80064000.pwm");
318 clk_register_clkdevs(clks[hbus], hbus_lookups, ARRAY_SIZE(hbus_lookups));
319 clk_register_clkdevs(clks[xbus], xbus_lookups, ARRAY_SIZE(xbus_lookups));
320 clk_register_clkdevs(clks[uart], uart_lookups, ARRAY_SIZE(uart_lookups));
321 clk_register_clkdevs(clks[ssp0], ssp0_lookups, ARRAY_SIZE(ssp0_lookups));
322 clk_register_clkdevs(clks[ssp1], ssp1_lookups, ARRAY_SIZE(ssp1_lookups));
323 clk_register_clkdevs(clks[ssp2], ssp2_lookups, ARRAY_SIZE(ssp2_lookups));
324 clk_register_clkdevs(clks[ssp3], ssp3_lookups, ARRAY_SIZE(ssp3_lookups));
325 clk_register_clkdevs(clks[gpmi], gpmi_lookups, ARRAY_SIZE(gpmi_lookups));
326 clk_register_clkdevs(clks[saif0], saif0_lookups, ARRAY_SIZE(saif0_lookups));
327 clk_register_clkdevs(clks[saif1], saif1_lookups, ARRAY_SIZE(saif1_lookups));
328 clk_register_clkdevs(clks[lcdif], lcdif_lookups, ARRAY_SIZE(lcdif_lookups));
329 clk_register_clkdevs(clks[fec], fec_lookups, ARRAY_SIZE(fec_lookups));
330 clk_register_clkdevs(clks[can0], can0_lookups, ARRAY_SIZE(can0_lookups));
331 clk_register_clkdevs(clks[can1], can1_lookups, ARRAY_SIZE(can1_lookups));
332 clk_register_clkdev(clks[usb0_pwr], NULL, "8007c000.usbphy");
333 clk_register_clkdev(clks[usb1_pwr], NULL, "8007e000.usbphy");
334 clk_register_clkdev(clks[usb0], NULL, "80080000.usb");
335 clk_register_clkdev(clks[usb1], NULL, "80090000.usb");
336 243
337 for (i = 0; i < ARRAY_SIZE(clks_init_on); i++) 244 for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
338 clk_prepare_enable(clks[clks_init_on[i]]); 245 clk_prepare_enable(clks[clks_init_on[i]]);