Merge branch 'for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck...
[linux-2.6-block.git] / drivers / clk / sirf / clk-common.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * common clks module for all SiRF SoCs
4  *
5  * Copyright (c) 2011 - 2014 Cambridge Silicon Radio Limited, a CSR plc group
6  * company.
7  */
8
9 #include <linux/clk.h>
10
11 #define KHZ     1000
12 #define MHZ     (KHZ * KHZ)
13
14 static void __iomem *sirfsoc_clk_vbase;
15 static void __iomem *sirfsoc_rsc_vbase;
16 static struct clk_onecell_data clk_data;
17
18 /*
19  * SiRFprimaII clock controller
20  * - 2 oscillators: osc-26MHz, rtc-32.768KHz
21  * - 3 standard configurable plls: pll1, pll2 & pll3
22  * - 2 exclusive plls: usb phy pll and sata phy pll
23  * - 8 clock domains: cpu/cpudiv, mem/memdiv, sys/io, dsp, graphic, multimedia,
24  *     display and sdphy.
25  *     Each clock domain can select its own clock source from five clock sources,
26  *     X_XIN, X_XINW, PLL1, PLL2 and PLL3. The domain clock is used as the source
27  *     clock of the group clock.
28  *     - dsp domain: gps, mf
29  *     - io domain: dmac, nand, audio, uart, i2c, spi, usp, pwm, pulse
30  *     - sys domain: security
31  */
32
33 struct clk_pll {
34         struct clk_hw hw;
35         unsigned short regofs;  /* register offset */
36 };
37
38 #define to_pllclk(_hw) container_of(_hw, struct clk_pll, hw)
39
40 struct clk_dmn {
41         struct clk_hw hw;
42         signed char enable_bit; /* enable bit: 0 ~ 63 */
43         unsigned short regofs;  /* register offset */
44 };
45
46 #define to_dmnclk(_hw) container_of(_hw, struct clk_dmn, hw)
47
48 struct clk_std {
49         struct clk_hw hw;
50         signed char enable_bit; /* enable bit: 0 ~ 63 */
51 };
52
53 #define to_stdclk(_hw) container_of(_hw, struct clk_std, hw)
54
55 static int std_clk_is_enabled(struct clk_hw *hw);
56 static int std_clk_enable(struct clk_hw *hw);
57 static void std_clk_disable(struct clk_hw *hw);
58
59 static inline unsigned long clkc_readl(unsigned reg)
60 {
61         return readl(sirfsoc_clk_vbase + reg);
62 }
63
64 static inline void clkc_writel(u32 val, unsigned reg)
65 {
66         writel(val, sirfsoc_clk_vbase + reg);
67 }
68
69 /*
70  * std pll
71  */
72
73 static unsigned long pll_clk_recalc_rate(struct clk_hw *hw,
74         unsigned long parent_rate)
75 {
76         unsigned long fin = parent_rate;
77         struct clk_pll *clk = to_pllclk(hw);
78         u32 regcfg2 = clk->regofs + SIRFSOC_CLKC_PLL1_CFG2 -
79                 SIRFSOC_CLKC_PLL1_CFG0;
80
81         if (clkc_readl(regcfg2) & BIT(2)) {
82                 /* pll bypass mode */
83                 return fin;
84         } else {
85                 /* fout = fin * nf / nr / od */
86                 u32 cfg0 = clkc_readl(clk->regofs);
87                 u32 nf = (cfg0 & (BIT(13) - 1)) + 1;
88                 u32 nr = ((cfg0 >> 13) & (BIT(6) - 1)) + 1;
89                 u32 od = ((cfg0 >> 19) & (BIT(4) - 1)) + 1;
90                 WARN_ON(fin % MHZ);
91                 return fin / MHZ * nf / nr / od * MHZ;
92         }
93 }
94
95 static long pll_clk_round_rate(struct clk_hw *hw, unsigned long rate,
96         unsigned long *parent_rate)
97 {
98         unsigned long fin, nf, nr, od;
99         u64 dividend;
100
101         /*
102          * fout = fin * nf / (nr * od);
103          * set od = 1, nr = fin/MHz, so fout = nf * MHz
104          */
105         rate = rate - rate % MHZ;
106
107         nf = rate / MHZ;
108         if (nf > BIT(13))
109                 nf = BIT(13);
110         if (nf < 1)
111                 nf = 1;
112
113         fin = *parent_rate;
114
115         nr = fin / MHZ;
116         if (nr > BIT(6))
117                 nr = BIT(6);
118         od = 1;
119
120         dividend = (u64)fin * nf;
121         do_div(dividend, nr * od);
122
123         return (long)dividend;
124 }
125
126 static int pll_clk_set_rate(struct clk_hw *hw, unsigned long rate,
127         unsigned long parent_rate)
128 {
129         struct clk_pll *clk = to_pllclk(hw);
130         unsigned long fin, nf, nr, od, reg;
131
132         /*
133          * fout = fin * nf / (nr * od);
134          * set od = 1, nr = fin/MHz, so fout = nf * MHz
135          */
136
137         nf = rate / MHZ;
138         if (unlikely((rate % MHZ) || nf > BIT(13) || nf < 1))
139                 return -EINVAL;
140
141         fin = parent_rate;
142         BUG_ON(fin < MHZ);
143
144         nr = fin / MHZ;
145         BUG_ON((fin % MHZ) || nr > BIT(6));
146
147         od = 1;
148
149         reg = (nf - 1) | ((nr - 1) << 13) | ((od - 1) << 19);
150         clkc_writel(reg, clk->regofs);
151
152         reg = clk->regofs + SIRFSOC_CLKC_PLL1_CFG1 - SIRFSOC_CLKC_PLL1_CFG0;
153         clkc_writel((nf >> 1) - 1, reg);
154
155         reg = clk->regofs + SIRFSOC_CLKC_PLL1_CFG2 - SIRFSOC_CLKC_PLL1_CFG0;
156         while (!(clkc_readl(reg) & BIT(6)))
157                 cpu_relax();
158
159         return 0;
160 }
161
162 static long cpu_clk_round_rate(struct clk_hw *hw, unsigned long rate,
163         unsigned long *parent_rate)
164 {
165         /*
166          * SiRF SoC has not cpu clock control,
167          * So bypass to it's parent pll.
168          */
169         struct clk_hw *parent_clk = clk_hw_get_parent(hw);
170         struct clk_hw *pll_parent_clk = clk_hw_get_parent(parent_clk);
171         unsigned long pll_parent_rate = clk_hw_get_rate(pll_parent_clk);
172         return pll_clk_round_rate(parent_clk, rate, &pll_parent_rate);
173 }
174
175 static unsigned long cpu_clk_recalc_rate(struct clk_hw *hw,
176         unsigned long parent_rate)
177 {
178         /*
179          * SiRF SoC has not cpu clock control,
180          * So return the parent pll rate.
181          */
182         struct clk_hw *parent_clk = clk_hw_get_parent(hw);
183         return clk_hw_get_rate(parent_clk);
184 }
185
186 static const struct clk_ops std_pll_ops = {
187         .recalc_rate = pll_clk_recalc_rate,
188         .round_rate = pll_clk_round_rate,
189         .set_rate = pll_clk_set_rate,
190 };
191
192 static const char * const pll_clk_parents[] = {
193         "osc",
194 };
195
196 static const struct clk_init_data clk_pll1_init = {
197         .name = "pll1",
198         .ops = &std_pll_ops,
199         .parent_names = pll_clk_parents,
200         .num_parents = ARRAY_SIZE(pll_clk_parents),
201 };
202
203 static const struct clk_init_data clk_pll2_init = {
204         .name = "pll2",
205         .ops = &std_pll_ops,
206         .parent_names = pll_clk_parents,
207         .num_parents = ARRAY_SIZE(pll_clk_parents),
208 };
209
210 static const struct clk_init_data clk_pll3_init = {
211         .name = "pll3",
212         .ops = &std_pll_ops,
213         .parent_names = pll_clk_parents,
214         .num_parents = ARRAY_SIZE(pll_clk_parents),
215 };
216
217 static struct clk_pll clk_pll1 = {
218         .regofs = SIRFSOC_CLKC_PLL1_CFG0,
219         .hw = {
220                 .init = &clk_pll1_init,
221         },
222 };
223
224 static struct clk_pll clk_pll2 = {
225         .regofs = SIRFSOC_CLKC_PLL2_CFG0,
226         .hw = {
227                 .init = &clk_pll2_init,
228         },
229 };
230
231 static struct clk_pll clk_pll3 = {
232         .regofs = SIRFSOC_CLKC_PLL3_CFG0,
233         .hw = {
234                 .init = &clk_pll3_init,
235         },
236 };
237
238 /*
239  * usb uses specified pll
240  */
241
242 static int usb_pll_clk_enable(struct clk_hw *hw)
243 {
244         u32 reg = readl(sirfsoc_rsc_vbase + SIRFSOC_USBPHY_PLL_CTRL);
245         reg &= ~(SIRFSOC_USBPHY_PLL_POWERDOWN | SIRFSOC_USBPHY_PLL_BYPASS);
246         writel(reg, sirfsoc_rsc_vbase + SIRFSOC_USBPHY_PLL_CTRL);
247         while (!(readl(sirfsoc_rsc_vbase + SIRFSOC_USBPHY_PLL_CTRL) &
248                         SIRFSOC_USBPHY_PLL_LOCK))
249                 cpu_relax();
250
251         return 0;
252 }
253
254 static void usb_pll_clk_disable(struct clk_hw *clk)
255 {
256         u32 reg = readl(sirfsoc_rsc_vbase + SIRFSOC_USBPHY_PLL_CTRL);
257         reg |= (SIRFSOC_USBPHY_PLL_POWERDOWN | SIRFSOC_USBPHY_PLL_BYPASS);
258         writel(reg, sirfsoc_rsc_vbase + SIRFSOC_USBPHY_PLL_CTRL);
259 }
260
261 static unsigned long usb_pll_clk_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
262 {
263         u32 reg = readl(sirfsoc_rsc_vbase + SIRFSOC_USBPHY_PLL_CTRL);
264         return (reg & SIRFSOC_USBPHY_PLL_BYPASS) ? parent_rate : 48*MHZ;
265 }
266
267 static const struct clk_ops usb_pll_ops = {
268         .enable = usb_pll_clk_enable,
269         .disable = usb_pll_clk_disable,
270         .recalc_rate = usb_pll_clk_recalc_rate,
271 };
272
273 static const struct clk_init_data clk_usb_pll_init = {
274         .name = "usb_pll",
275         .ops = &usb_pll_ops,
276         .parent_names = pll_clk_parents,
277         .num_parents = ARRAY_SIZE(pll_clk_parents),
278 };
279
280 static struct clk_hw usb_pll_clk_hw = {
281         .init = &clk_usb_pll_init,
282 };
283
284 /*
285  * clock domains - cpu, mem, sys/io, dsp, gfx
286  */
287
288 static const char * const dmn_clk_parents[] = {
289         "rtc",
290         "osc",
291         "pll1",
292         "pll2",
293         "pll3",
294 };
295
296 static u8 dmn_clk_get_parent(struct clk_hw *hw)
297 {
298         struct clk_dmn *clk = to_dmnclk(hw);
299         u32 cfg = clkc_readl(clk->regofs);
300
301         /* parent of io domain can only be pll3 */
302         if (strcmp(hw->init->name, "io") == 0)
303                 return 4;
304
305         WARN_ON((cfg & (BIT(3) - 1)) > 4);
306
307         return cfg & (BIT(3) - 1);
308 }
309
310 static int dmn_clk_set_parent(struct clk_hw *hw, u8 parent)
311 {
312         struct clk_dmn *clk = to_dmnclk(hw);
313         u32 cfg = clkc_readl(clk->regofs);
314
315         /* parent of io domain can only be pll3 */
316         if (strcmp(hw->init->name, "io") == 0)
317                 return -EINVAL;
318
319         cfg &= ~(BIT(3) - 1);
320         clkc_writel(cfg | parent, clk->regofs);
321         /* BIT(3) - switching status: 1 - busy, 0 - done */
322         while (clkc_readl(clk->regofs) & BIT(3))
323                 cpu_relax();
324
325         return 0;
326 }
327
328 static unsigned long dmn_clk_recalc_rate(struct clk_hw *hw,
329         unsigned long parent_rate)
330
331 {
332         unsigned long fin = parent_rate;
333         struct clk_dmn *clk = to_dmnclk(hw);
334
335         u32 cfg = clkc_readl(clk->regofs);
336
337         if (cfg & BIT(24)) {
338                 /* fcd bypass mode */
339                 return fin;
340         } else {
341                 /*
342                  * wait count: bit[19:16], hold count: bit[23:20]
343                  */
344                 u32 wait = (cfg >> 16) & (BIT(4) - 1);
345                 u32 hold = (cfg >> 20) & (BIT(4) - 1);
346
347                 return fin / (wait + hold + 2);
348         }
349 }
350
351 static long dmn_clk_round_rate(struct clk_hw *hw, unsigned long rate,
352         unsigned long *parent_rate)
353 {
354         unsigned long fin;
355         unsigned ratio, wait, hold;
356         unsigned bits = (strcmp(hw->init->name, "mem") == 0) ? 3 : 4;
357
358         fin = *parent_rate;
359         ratio = fin / rate;
360
361         if (ratio < 2)
362                 ratio = 2;
363         if (ratio > BIT(bits + 1))
364                 ratio = BIT(bits + 1);
365
366         wait = (ratio >> 1) - 1;
367         hold = ratio - wait - 2;
368
369         return fin / (wait + hold + 2);
370 }
371
372 static int dmn_clk_set_rate(struct clk_hw *hw, unsigned long rate,
373         unsigned long parent_rate)
374 {
375         struct clk_dmn *clk = to_dmnclk(hw);
376         unsigned long fin;
377         unsigned ratio, wait, hold, reg;
378         unsigned bits = (strcmp(hw->init->name, "mem") == 0) ? 3 : 4;
379
380         fin = parent_rate;
381         ratio = fin / rate;
382
383         if (unlikely(ratio < 2 || ratio > BIT(bits + 1)))
384                 return -EINVAL;
385
386         WARN_ON(fin % rate);
387
388         wait = (ratio >> 1) - 1;
389         hold = ratio - wait - 2;
390
391         reg = clkc_readl(clk->regofs);
392         reg &= ~(((BIT(bits) - 1) << 16) | ((BIT(bits) - 1) << 20));
393         reg |= (wait << 16) | (hold << 20) | BIT(25);
394         clkc_writel(reg, clk->regofs);
395
396         /* waiting FCD been effective */
397         while (clkc_readl(clk->regofs) & BIT(25))
398                 cpu_relax();
399
400         return 0;
401 }
402
403 static int cpu_clk_set_rate(struct clk_hw *hw, unsigned long rate,
404                 unsigned long parent_rate)
405 {
406         int ret1, ret2;
407         struct clk *cur_parent;
408
409         if (rate == clk_get_rate(clk_pll1.hw.clk)) {
410                 ret1 = clk_set_parent(hw->clk, clk_pll1.hw.clk);
411                 return ret1;
412         }
413
414         if (rate == clk_get_rate(clk_pll2.hw.clk)) {
415                 ret1 = clk_set_parent(hw->clk, clk_pll2.hw.clk);
416                 return ret1;
417         }
418
419         if (rate == clk_get_rate(clk_pll3.hw.clk)) {
420                 ret1 = clk_set_parent(hw->clk, clk_pll3.hw.clk);
421                 return ret1;
422         }
423
424         cur_parent = clk_get_parent(hw->clk);
425
426         /* switch to tmp pll before setting parent clock's rate */
427         if (cur_parent ==  clk_pll1.hw.clk) {
428                 ret1 = clk_set_parent(hw->clk, clk_pll2.hw.clk);
429                 BUG_ON(ret1);
430         }
431
432         ret2 = clk_set_rate(clk_pll1.hw.clk, rate);
433
434         ret1 = clk_set_parent(hw->clk, clk_pll1.hw.clk);
435
436         return ret2 ? ret2 : ret1;
437 }
438
439 static const struct clk_ops msi_ops = {
440         .set_rate = dmn_clk_set_rate,
441         .round_rate = dmn_clk_round_rate,
442         .recalc_rate = dmn_clk_recalc_rate,
443         .set_parent = dmn_clk_set_parent,
444         .get_parent = dmn_clk_get_parent,
445 };
446
447 static const struct clk_init_data clk_mem_init = {
448         .name = "mem",
449         .ops = &msi_ops,
450         .parent_names = dmn_clk_parents,
451         .num_parents = ARRAY_SIZE(dmn_clk_parents),
452 };
453
454 static struct clk_dmn clk_mem = {
455         .regofs = SIRFSOC_CLKC_MEM_CFG,
456         .hw = {
457                 .init = &clk_mem_init,
458         },
459 };
460
461 static const struct clk_init_data clk_sys_init = {
462         .name = "sys",
463         .ops = &msi_ops,
464         .parent_names = dmn_clk_parents,
465         .num_parents = ARRAY_SIZE(dmn_clk_parents),
466         .flags = CLK_SET_RATE_GATE,
467 };
468
469 static struct clk_dmn clk_sys = {
470         .regofs = SIRFSOC_CLKC_SYS_CFG,
471         .hw = {
472                 .init = &clk_sys_init,
473         },
474 };
475
476 static const struct clk_init_data clk_io_init = {
477         .name = "io",
478         .ops = &msi_ops,
479         .parent_names = dmn_clk_parents,
480         .num_parents = ARRAY_SIZE(dmn_clk_parents),
481 };
482
483 static struct clk_dmn clk_io = {
484         .regofs = SIRFSOC_CLKC_IO_CFG,
485         .hw = {
486                 .init = &clk_io_init,
487         },
488 };
489
490 static const struct clk_ops cpu_ops = {
491         .set_parent = dmn_clk_set_parent,
492         .get_parent = dmn_clk_get_parent,
493         .set_rate = cpu_clk_set_rate,
494         .round_rate = cpu_clk_round_rate,
495         .recalc_rate = cpu_clk_recalc_rate,
496 };
497
498 static const struct clk_init_data clk_cpu_init = {
499         .name = "cpu",
500         .ops = &cpu_ops,
501         .parent_names = dmn_clk_parents,
502         .num_parents = ARRAY_SIZE(dmn_clk_parents),
503         .flags = CLK_SET_RATE_PARENT,
504 };
505
506 static struct clk_dmn clk_cpu = {
507         .regofs = SIRFSOC_CLKC_CPU_CFG,
508         .hw = {
509                 .init = &clk_cpu_init,
510         },
511 };
512
513 static const struct clk_ops dmn_ops = {
514         .is_enabled = std_clk_is_enabled,
515         .enable = std_clk_enable,
516         .disable = std_clk_disable,
517         .set_rate = dmn_clk_set_rate,
518         .round_rate = dmn_clk_round_rate,
519         .recalc_rate = dmn_clk_recalc_rate,
520         .set_parent = dmn_clk_set_parent,
521         .get_parent = dmn_clk_get_parent,
522 };
523
524 /* dsp, gfx, mm, lcd and vpp domain */
525
526 static const struct clk_init_data clk_dsp_init = {
527         .name = "dsp",
528         .ops = &dmn_ops,
529         .parent_names = dmn_clk_parents,
530         .num_parents = ARRAY_SIZE(dmn_clk_parents),
531 };
532
533 static struct clk_dmn clk_dsp = {
534         .regofs = SIRFSOC_CLKC_DSP_CFG,
535         .enable_bit = 0,
536         .hw = {
537                 .init = &clk_dsp_init,
538         },
539 };
540
541 static const struct clk_init_data clk_gfx_init = {
542         .name = "gfx",
543         .ops = &dmn_ops,
544         .parent_names = dmn_clk_parents,
545         .num_parents = ARRAY_SIZE(dmn_clk_parents),
546 };
547
548 static struct clk_dmn clk_gfx = {
549         .regofs = SIRFSOC_CLKC_GFX_CFG,
550         .enable_bit = 8,
551         .hw = {
552                 .init = &clk_gfx_init,
553         },
554 };
555
556 static const struct clk_init_data clk_mm_init = {
557         .name = "mm",
558         .ops = &dmn_ops,
559         .parent_names = dmn_clk_parents,
560         .num_parents = ARRAY_SIZE(dmn_clk_parents),
561 };
562
563 static struct clk_dmn clk_mm = {
564         .regofs = SIRFSOC_CLKC_MM_CFG,
565         .enable_bit = 9,
566         .hw = {
567                 .init = &clk_mm_init,
568         },
569 };
570
571 /*
572  * for atlas6, gfx2d holds the bit of prima2's clk_mm
573  */
574 #define clk_gfx2d clk_mm
575
576 static const struct clk_init_data clk_lcd_init = {
577         .name = "lcd",
578         .ops = &dmn_ops,
579         .parent_names = dmn_clk_parents,
580         .num_parents = ARRAY_SIZE(dmn_clk_parents),
581 };
582
583 static struct clk_dmn clk_lcd = {
584         .regofs = SIRFSOC_CLKC_LCD_CFG,
585         .enable_bit = 10,
586         .hw = {
587                 .init = &clk_lcd_init,
588         },
589 };
590
591 static const struct clk_init_data clk_vpp_init = {
592         .name = "vpp",
593         .ops = &dmn_ops,
594         .parent_names = dmn_clk_parents,
595         .num_parents = ARRAY_SIZE(dmn_clk_parents),
596 };
597
598 static struct clk_dmn clk_vpp = {
599         .regofs = SIRFSOC_CLKC_LCD_CFG,
600         .enable_bit = 11,
601         .hw = {
602                 .init = &clk_vpp_init,
603         },
604 };
605
606 static const struct clk_init_data clk_mmc01_init = {
607         .name = "mmc01",
608         .ops = &dmn_ops,
609         .parent_names = dmn_clk_parents,
610         .num_parents = ARRAY_SIZE(dmn_clk_parents),
611 };
612
613 static const struct clk_init_data clk_mmc23_init = {
614         .name = "mmc23",
615         .ops = &dmn_ops,
616         .parent_names = dmn_clk_parents,
617         .num_parents = ARRAY_SIZE(dmn_clk_parents),
618 };
619
620 static const struct clk_init_data clk_mmc45_init = {
621         .name = "mmc45",
622         .ops = &dmn_ops,
623         .parent_names = dmn_clk_parents,
624         .num_parents = ARRAY_SIZE(dmn_clk_parents),
625 };
626
627 /*
628  * peripheral controllers in io domain
629  */
630
631 static int std_clk_is_enabled(struct clk_hw *hw)
632 {
633         u32 reg;
634         int bit;
635         struct clk_std *clk = to_stdclk(hw);
636
637         bit = clk->enable_bit % 32;
638         reg = clk->enable_bit / 32;
639         reg = SIRFSOC_CLKC_CLK_EN0 + reg * sizeof(reg);
640
641         return !!(clkc_readl(reg) & BIT(bit));
642 }
643
644 static int std_clk_enable(struct clk_hw *hw)
645 {
646         u32 val, reg;
647         int bit;
648         struct clk_std *clk = to_stdclk(hw);
649
650         BUG_ON(clk->enable_bit < 0 || clk->enable_bit > 63);
651
652         bit = clk->enable_bit % 32;
653         reg = clk->enable_bit / 32;
654         reg = SIRFSOC_CLKC_CLK_EN0 + reg * sizeof(reg);
655
656         val = clkc_readl(reg) | BIT(bit);
657         clkc_writel(val, reg);
658         return 0;
659 }
660
661 static void std_clk_disable(struct clk_hw *hw)
662 {
663         u32 val, reg;
664         int bit;
665         struct clk_std *clk = to_stdclk(hw);
666
667         BUG_ON(clk->enable_bit < 0 || clk->enable_bit > 63);
668
669         bit = clk->enable_bit % 32;
670         reg = clk->enable_bit / 32;
671         reg = SIRFSOC_CLKC_CLK_EN0 + reg * sizeof(reg);
672
673         val = clkc_readl(reg) & ~BIT(bit);
674         clkc_writel(val, reg);
675 }
676
677 static const char * const std_clk_io_parents[] = {
678         "io",
679 };
680
681 static const struct clk_ops ios_ops = {
682         .is_enabled = std_clk_is_enabled,
683         .enable = std_clk_enable,
684         .disable = std_clk_disable,
685 };
686
687 static const struct clk_init_data clk_cphif_init = {
688         .name = "cphif",
689         .ops = &ios_ops,
690         .parent_names = std_clk_io_parents,
691         .num_parents = ARRAY_SIZE(std_clk_io_parents),
692 };
693
694 static struct clk_std clk_cphif = {
695         .enable_bit = 20,
696         .hw = {
697                 .init = &clk_cphif_init,
698         },
699 };
700
701 static const struct clk_init_data clk_dmac0_init = {
702         .name = "dmac0",
703         .ops = &ios_ops,
704         .parent_names = std_clk_io_parents,
705         .num_parents = ARRAY_SIZE(std_clk_io_parents),
706 };
707
708 static struct clk_std clk_dmac0 = {
709         .enable_bit = 32,
710         .hw = {
711                 .init = &clk_dmac0_init,
712         },
713 };
714
715 static const struct clk_init_data clk_dmac1_init = {
716         .name = "dmac1",
717         .ops = &ios_ops,
718         .parent_names = std_clk_io_parents,
719         .num_parents = ARRAY_SIZE(std_clk_io_parents),
720 };
721
722 static struct clk_std clk_dmac1 = {
723         .enable_bit = 33,
724         .hw = {
725                 .init = &clk_dmac1_init,
726         },
727 };
728
729 static const struct clk_init_data clk_audio_init = {
730         .name = "audio",
731         .ops = &ios_ops,
732         .parent_names = std_clk_io_parents,
733         .num_parents = ARRAY_SIZE(std_clk_io_parents),
734 };
735
736 static struct clk_std clk_audio = {
737         .enable_bit = 35,
738         .hw = {
739                 .init = &clk_audio_init,
740         },
741 };
742
743 static const struct clk_init_data clk_uart0_init = {
744         .name = "uart0",
745         .ops = &ios_ops,
746         .parent_names = std_clk_io_parents,
747         .num_parents = ARRAY_SIZE(std_clk_io_parents),
748 };
749
750 static struct clk_std clk_uart0 = {
751         .enable_bit = 36,
752         .hw = {
753                 .init = &clk_uart0_init,
754         },
755 };
756
757 static const struct clk_init_data clk_uart1_init = {
758         .name = "uart1",
759         .ops = &ios_ops,
760         .parent_names = std_clk_io_parents,
761         .num_parents = ARRAY_SIZE(std_clk_io_parents),
762 };
763
764 static struct clk_std clk_uart1 = {
765         .enable_bit = 37,
766         .hw = {
767                 .init = &clk_uart1_init,
768         },
769 };
770
771 static const struct clk_init_data clk_uart2_init = {
772         .name = "uart2",
773         .ops = &ios_ops,
774         .parent_names = std_clk_io_parents,
775         .num_parents = ARRAY_SIZE(std_clk_io_parents),
776 };
777
778 static struct clk_std clk_uart2 = {
779         .enable_bit = 38,
780         .hw = {
781                 .init = &clk_uart2_init,
782         },
783 };
784
785 static const struct clk_init_data clk_usp0_init = {
786         .name = "usp0",
787         .ops = &ios_ops,
788         .parent_names = std_clk_io_parents,
789         .num_parents = ARRAY_SIZE(std_clk_io_parents),
790 };
791
792 static struct clk_std clk_usp0 = {
793         .enable_bit = 39,
794         .hw = {
795                 .init = &clk_usp0_init,
796         },
797 };
798
799 static const struct clk_init_data clk_usp1_init = {
800         .name = "usp1",
801         .ops = &ios_ops,
802         .parent_names = std_clk_io_parents,
803         .num_parents = ARRAY_SIZE(std_clk_io_parents),
804 };
805
806 static struct clk_std clk_usp1 = {
807         .enable_bit = 40,
808         .hw = {
809                 .init = &clk_usp1_init,
810         },
811 };
812
813 static const struct clk_init_data clk_usp2_init = {
814         .name = "usp2",
815         .ops = &ios_ops,
816         .parent_names = std_clk_io_parents,
817         .num_parents = ARRAY_SIZE(std_clk_io_parents),
818 };
819
820 static struct clk_std clk_usp2 = {
821         .enable_bit = 41,
822         .hw = {
823                 .init = &clk_usp2_init,
824         },
825 };
826
827 static const struct clk_init_data clk_vip_init = {
828         .name = "vip",
829         .ops = &ios_ops,
830         .parent_names = std_clk_io_parents,
831         .num_parents = ARRAY_SIZE(std_clk_io_parents),
832 };
833
834 static struct clk_std clk_vip = {
835         .enable_bit = 42,
836         .hw = {
837                 .init = &clk_vip_init,
838         },
839 };
840
841 static const struct clk_init_data clk_spi0_init = {
842         .name = "spi0",
843         .ops = &ios_ops,
844         .parent_names = std_clk_io_parents,
845         .num_parents = ARRAY_SIZE(std_clk_io_parents),
846 };
847
848 static struct clk_std clk_spi0 = {
849         .enable_bit = 43,
850         .hw = {
851                 .init = &clk_spi0_init,
852         },
853 };
854
855 static const struct clk_init_data clk_spi1_init = {
856         .name = "spi1",
857         .ops = &ios_ops,
858         .parent_names = std_clk_io_parents,
859         .num_parents = ARRAY_SIZE(std_clk_io_parents),
860 };
861
862 static struct clk_std clk_spi1 = {
863         .enable_bit = 44,
864         .hw = {
865                 .init = &clk_spi1_init,
866         },
867 };
868
869 static const struct clk_init_data clk_tsc_init = {
870         .name = "tsc",
871         .ops = &ios_ops,
872         .parent_names = std_clk_io_parents,
873         .num_parents = ARRAY_SIZE(std_clk_io_parents),
874 };
875
876 static struct clk_std clk_tsc = {
877         .enable_bit = 45,
878         .hw = {
879                 .init = &clk_tsc_init,
880         },
881 };
882
883 static const struct clk_init_data clk_i2c0_init = {
884         .name = "i2c0",
885         .ops = &ios_ops,
886         .parent_names = std_clk_io_parents,
887         .num_parents = ARRAY_SIZE(std_clk_io_parents),
888 };
889
890 static struct clk_std clk_i2c0 = {
891         .enable_bit = 46,
892         .hw = {
893                 .init = &clk_i2c0_init,
894         },
895 };
896
897 static const struct clk_init_data clk_i2c1_init = {
898         .name = "i2c1",
899         .ops = &ios_ops,
900         .parent_names = std_clk_io_parents,
901         .num_parents = ARRAY_SIZE(std_clk_io_parents),
902 };
903
904 static struct clk_std clk_i2c1 = {
905         .enable_bit = 47,
906         .hw = {
907                 .init = &clk_i2c1_init,
908         },
909 };
910
911 static const struct clk_init_data clk_pwmc_init = {
912         .name = "pwmc",
913         .ops = &ios_ops,
914         .parent_names = std_clk_io_parents,
915         .num_parents = ARRAY_SIZE(std_clk_io_parents),
916 };
917
918 static struct clk_std clk_pwmc = {
919         .enable_bit = 48,
920         .hw = {
921                 .init = &clk_pwmc_init,
922         },
923 };
924
925 static const struct clk_init_data clk_efuse_init = {
926         .name = "efuse",
927         .ops = &ios_ops,
928         .parent_names = std_clk_io_parents,
929         .num_parents = ARRAY_SIZE(std_clk_io_parents),
930 };
931
932 static struct clk_std clk_efuse = {
933         .enable_bit = 49,
934         .hw = {
935                 .init = &clk_efuse_init,
936         },
937 };
938
939 static const struct clk_init_data clk_pulse_init = {
940         .name = "pulse",
941         .ops = &ios_ops,
942         .parent_names = std_clk_io_parents,
943         .num_parents = ARRAY_SIZE(std_clk_io_parents),
944 };
945
946 static struct clk_std clk_pulse = {
947         .enable_bit = 50,
948         .hw = {
949                 .init = &clk_pulse_init,
950         },
951 };
952
953 static const char * const std_clk_dsp_parents[] = {
954         "dsp",
955 };
956
957 static const struct clk_init_data clk_gps_init = {
958         .name = "gps",
959         .ops = &ios_ops,
960         .parent_names = std_clk_dsp_parents,
961         .num_parents = ARRAY_SIZE(std_clk_dsp_parents),
962 };
963
964 static struct clk_std clk_gps = {
965         .enable_bit = 1,
966         .hw = {
967                 .init = &clk_gps_init,
968         },
969 };
970
971 static const struct clk_init_data clk_mf_init = {
972         .name = "mf",
973         .ops = &ios_ops,
974         .parent_names = std_clk_io_parents,
975         .num_parents = ARRAY_SIZE(std_clk_io_parents),
976 };
977
978 static struct clk_std clk_mf = {
979         .enable_bit = 2,
980         .hw = {
981                 .init = &clk_mf_init,
982         },
983 };
984
985 static const char * const std_clk_sys_parents[] = {
986         "sys",
987 };
988
989 static const struct clk_init_data clk_security_init = {
990         .name = "security",
991         .ops = &ios_ops,
992         .parent_names = std_clk_sys_parents,
993         .num_parents = ARRAY_SIZE(std_clk_sys_parents),
994 };
995
996 static struct clk_std clk_security = {
997         .enable_bit = 19,
998         .hw = {
999                 .init = &clk_security_init,
1000         },
1001 };
1002
1003 static const char * const std_clk_usb_parents[] = {
1004         "usb_pll",
1005 };
1006
1007 static const struct clk_init_data clk_usb0_init = {
1008         .name = "usb0",
1009         .ops = &ios_ops,
1010         .parent_names = std_clk_usb_parents,
1011         .num_parents = ARRAY_SIZE(std_clk_usb_parents),
1012 };
1013
1014 static struct clk_std clk_usb0 = {
1015         .enable_bit = 16,
1016         .hw = {
1017                 .init = &clk_usb0_init,
1018         },
1019 };
1020
1021 static const struct clk_init_data clk_usb1_init = {
1022         .name = "usb1",
1023         .ops = &ios_ops,
1024         .parent_names = std_clk_usb_parents,
1025         .num_parents = ARRAY_SIZE(std_clk_usb_parents),
1026 };
1027
1028 static struct clk_std clk_usb1 = {
1029         .enable_bit = 17,
1030         .hw = {
1031                 .init = &clk_usb1_init,
1032         },
1033 };