1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2014 STMicroelectronics (R&D) Limited
8 * Stephen Gallimore <stephen.gallimore@st.com>,
9 * Pankaj Dev <pankaj.dev@st.com>.
12 #include <linux/slab.h>
13 #include <linux/of_address.h>
14 #include <linux/clk.h>
15 #include <linux/clk-provider.h>
16 #include <linux/iopoll.h>
20 static DEFINE_SPINLOCK(clkgena_c32_odf_lock
);
21 DEFINE_SPINLOCK(clkgen_a9_lock
);
24 * PLL configuration register bits for PLL3200 C32
26 #define C32_NDIV_MASK (0xff)
27 #define C32_IDF_MASK (0x7)
28 #define C32_ODF_MASK (0x3f)
29 #define C32_LDF_MASK (0x7f)
30 #define C32_CP_MASK (0x1f)
32 #define C32_MAX_ODFS (4)
35 * PLL configuration register bits for PLL4600 C28
37 #define C28_NDIV_MASK (0xff)
38 #define C28_IDF_MASK (0x7)
39 #define C28_ODF_MASK (0x3f)
41 struct clkgen_pll_data
{
42 struct clkgen_field pdn_status
;
43 struct clkgen_field pdn_ctrl
;
44 struct clkgen_field locked_status
;
45 struct clkgen_field mdiv
;
46 struct clkgen_field ndiv
;
47 struct clkgen_field pdiv
;
48 struct clkgen_field idf
;
49 struct clkgen_field ldf
;
50 struct clkgen_field cp
;
51 unsigned int num_odfs
;
52 struct clkgen_field odf
[C32_MAX_ODFS
];
53 struct clkgen_field odf_gate
[C32_MAX_ODFS
];
55 struct clkgen_field switch2pll
;
57 const struct clk_ops
*ops
;
60 struct clkgen_clk_out
{
65 struct clkgen_pll_data_clks
{
66 struct clkgen_pll_data
*data
;
67 const struct clkgen_clk_out
*outputs
;
71 static const struct clk_ops stm_pll3200c32_ops
;
72 static const struct clk_ops stm_pll3200c32_a9_ops
;
73 static const struct clk_ops stm_pll4600c28_ops
;
75 static const struct clkgen_pll_data st_pll3200c32_cx_0
= {
77 .pdn_status
= CLKGEN_FIELD(0x2a0, 0x1, 8),
78 .pdn_ctrl
= CLKGEN_FIELD(0x2a0, 0x1, 8),
79 .locked_status
= CLKGEN_FIELD(0x2a0, 0x1, 24),
80 .ndiv
= CLKGEN_FIELD(0x2a4, C32_NDIV_MASK
, 16),
81 .idf
= CLKGEN_FIELD(0x2a4, C32_IDF_MASK
, 0x0),
83 .odf
= { CLKGEN_FIELD(0x2b4, C32_ODF_MASK
, 0) },
84 .odf_gate
= { CLKGEN_FIELD(0x2b4, 0x1, 6) },
85 .ops
= &stm_pll3200c32_ops
,
88 static const struct clkgen_pll_data_clks st_pll3200c32_cx_0_legacy_data
= {
89 .data
= (struct clkgen_pll_data
*)&st_pll3200c32_cx_0
,
92 static const struct clkgen_clk_out st_pll3200c32_ax_0_clks
[] = {
93 { .name
= "clk-s-a0-pll-odf-0", },
96 static const struct clkgen_pll_data_clks st_pll3200c32_a0_data
= {
97 .data
= (struct clkgen_pll_data
*)&st_pll3200c32_cx_0
,
98 .outputs
= st_pll3200c32_ax_0_clks
,
101 static const struct clkgen_clk_out st_pll3200c32_cx_0_clks
[] = {
102 { .name
= "clk-s-c0-pll0-odf-0", },
105 static const struct clkgen_pll_data_clks st_pll3200c32_c0_data
= {
106 .data
= (struct clkgen_pll_data
*)&st_pll3200c32_cx_0
,
107 .outputs
= st_pll3200c32_cx_0_clks
,
110 static const struct clkgen_pll_data st_pll3200c32_cx_1
= {
112 .pdn_status
= CLKGEN_FIELD(0x2c8, 0x1, 8),
113 .pdn_ctrl
= CLKGEN_FIELD(0x2c8, 0x1, 8),
114 .locked_status
= CLKGEN_FIELD(0x2c8, 0x1, 24),
115 .ndiv
= CLKGEN_FIELD(0x2cc, C32_NDIV_MASK
, 16),
116 .idf
= CLKGEN_FIELD(0x2cc, C32_IDF_MASK
, 0x0),
118 .odf
= { CLKGEN_FIELD(0x2dc, C32_ODF_MASK
, 0) },
119 .odf_gate
= { CLKGEN_FIELD(0x2dc, 0x1, 6) },
120 .ops
= &stm_pll3200c32_ops
,
123 static const struct clkgen_pll_data_clks st_pll3200c32_cx_1_legacy_data
= {
124 .data
= (struct clkgen_pll_data
*)&st_pll3200c32_cx_1
,
127 static const struct clkgen_clk_out st_pll3200c32_cx_1_clks
[] = {
128 { .name
= "clk-s-c0-pll1-odf-0", },
131 static const struct clkgen_pll_data_clks st_pll3200c32_c1_data
= {
132 .data
= (struct clkgen_pll_data
*)&st_pll3200c32_cx_1
,
133 .outputs
= st_pll3200c32_cx_1_clks
,
136 static const struct clkgen_pll_data st_pll3200c32_407_a9
= {
138 .pdn_status
= CLKGEN_FIELD(0x1a8, 0x1, 0),
139 .pdn_ctrl
= CLKGEN_FIELD(0x1a8, 0x1, 0),
140 .locked_status
= CLKGEN_FIELD(0x87c, 0x1, 0),
141 .ndiv
= CLKGEN_FIELD(0x1b0, C32_NDIV_MASK
, 0),
142 .idf
= CLKGEN_FIELD(0x1a8, C32_IDF_MASK
, 25),
144 .odf
= { CLKGEN_FIELD(0x1b0, C32_ODF_MASK
, 8) },
145 .odf_gate
= { CLKGEN_FIELD(0x1ac, 0x1, 28) },
146 .switch2pll_en
= true,
147 .cp
= CLKGEN_FIELD(0x1a8, C32_CP_MASK
, 1),
148 .switch2pll
= CLKGEN_FIELD(0x1a4, 0x1, 1),
149 .lock
= &clkgen_a9_lock
,
150 .ops
= &stm_pll3200c32_a9_ops
,
153 static const struct clkgen_clk_out st_pll3200c32_407_a9_clks
[] = {
154 { .name
= "clockgen-a9-pll-odf", },
157 static const struct clkgen_pll_data_clks st_pll3200c32_407_a9_data
= {
158 .data
= (struct clkgen_pll_data
*)&st_pll3200c32_407_a9
,
159 .outputs
= st_pll3200c32_407_a9_clks
,
162 static struct clkgen_pll_data st_pll4600c28_418_a9
= {
164 .pdn_status
= CLKGEN_FIELD(0x1a8, 0x1, 0),
165 .pdn_ctrl
= CLKGEN_FIELD(0x1a8, 0x1, 0),
166 .locked_status
= CLKGEN_FIELD(0x87c, 0x1, 0),
167 .ndiv
= CLKGEN_FIELD(0x1b0, C28_NDIV_MASK
, 0),
168 .idf
= CLKGEN_FIELD(0x1a8, C28_IDF_MASK
, 25),
170 .odf
= { CLKGEN_FIELD(0x1b0, C28_ODF_MASK
, 8) },
171 .odf_gate
= { CLKGEN_FIELD(0x1ac, 0x1, 28) },
172 .switch2pll_en
= true,
173 .switch2pll
= CLKGEN_FIELD(0x1a4, 0x1, 1),
174 .lock
= &clkgen_a9_lock
,
175 .ops
= &stm_pll4600c28_ops
,
178 static const struct clkgen_clk_out st_pll4600c28_418_a9_clks
[] = {
179 { .name
= "clockgen-a9-pll-odf", },
182 static const struct clkgen_pll_data_clks st_pll4600c28_418_a9_data
= {
183 .data
= (struct clkgen_pll_data
*)&st_pll4600c28_418_a9
,
184 .outputs
= st_pll4600c28_418_a9_clks
,
188 * DOC: Clock Generated by PLL, rate set and enabled by bootloader
190 * Traits of this clock:
191 * prepare - clk_(un)prepare only ensures parent is (un)prepared
192 * enable - clk_enable/disable only ensures parent is enabled
193 * rate - rate is fixed. No clk_set_rate support
194 * parent - fixed parent. No clk_set_parent support
198 * PLL clock that is integrated in the ClockGenA instances on the STiH415
201 * @hw: handle between common and hardware-specific interfaces.
202 * @regs_base: base of the PLL configuration register(s).
207 struct clkgen_pll_data
*data
;
208 void __iomem
*regs_base
;
216 #define to_clkgen_pll(_hw) container_of(_hw, struct clkgen_pll, hw)
228 static int clkgen_pll_is_locked(struct clk_hw
*hw
)
230 struct clkgen_pll
*pll
= to_clkgen_pll(hw
);
231 u32 locked
= CLKGEN_READ(pll
, locked_status
);
236 static int clkgen_pll_is_enabled(struct clk_hw
*hw
)
238 struct clkgen_pll
*pll
= to_clkgen_pll(hw
);
239 u32 poweroff
= CLKGEN_READ(pll
, pdn_status
);
243 static int __clkgen_pll_enable(struct clk_hw
*hw
)
245 struct clkgen_pll
*pll
= to_clkgen_pll(hw
);
246 void __iomem
*base
= pll
->regs_base
;
247 struct clkgen_field
*field
= &pll
->data
->locked_status
;
251 if (clkgen_pll_is_enabled(hw
))
254 CLKGEN_WRITE(pll
, pdn_ctrl
, 0);
256 ret
= readl_relaxed_poll_timeout(base
+ field
->offset
, reg
,
257 !!((reg
>> field
->shift
) & field
->mask
), 0, 10000);
260 if (pll
->data
->switch2pll_en
)
261 CLKGEN_WRITE(pll
, switch2pll
, 0);
263 pr_debug("%s:%s enabled\n", __clk_get_name(hw
->clk
), __func__
);
269 static int clkgen_pll_enable(struct clk_hw
*hw
)
271 struct clkgen_pll
*pll
= to_clkgen_pll(hw
);
272 unsigned long flags
= 0;
276 spin_lock_irqsave(pll
->lock
, flags
);
278 ret
= __clkgen_pll_enable(hw
);
281 spin_unlock_irqrestore(pll
->lock
, flags
);
286 static void __clkgen_pll_disable(struct clk_hw
*hw
)
288 struct clkgen_pll
*pll
= to_clkgen_pll(hw
);
290 if (!clkgen_pll_is_enabled(hw
))
293 if (pll
->data
->switch2pll_en
)
294 CLKGEN_WRITE(pll
, switch2pll
, 1);
296 CLKGEN_WRITE(pll
, pdn_ctrl
, 1);
298 pr_debug("%s:%s disabled\n", __clk_get_name(hw
->clk
), __func__
);
301 static void clkgen_pll_disable(struct clk_hw
*hw
)
303 struct clkgen_pll
*pll
= to_clkgen_pll(hw
);
304 unsigned long flags
= 0;
307 spin_lock_irqsave(pll
->lock
, flags
);
309 __clkgen_pll_disable(hw
);
312 spin_unlock_irqrestore(pll
->lock
, flags
);
315 static int clk_pll3200c32_get_params(unsigned long input
, unsigned long output
,
319 unsigned long deviation
= ~0;
320 unsigned long new_freq
;
322 /* Charge pump table: highest ndiv value for cp=6 to 25 */
323 static const unsigned char cp_table
[] = {
324 48, 56, 64, 72, 80, 88, 96, 104, 112, 120,
325 128, 136, 144, 152, 160, 168, 176, 184, 192
328 /* Output clock range: 800Mhz to 1600Mhz */
329 if (output
< 800000000 || output
> 1600000000)
335 for (i
= 1; i
<= 7 && deviation
; i
++) {
336 n
= i
* output
/ (2 * input
);
344 new_freq
= (input
* 2 * n
) / i
;
346 new_deviation
= abs(new_freq
- output
);
348 if (!new_deviation
|| new_deviation
< deviation
) {
351 deviation
= new_deviation
;
355 if (deviation
== ~0) /* No solution found */
358 /* Computing recommended charge pump value */
359 for (pll
->cp
= 6; pll
->ndiv
> cp_table
[pll
->cp
-6]; (pll
->cp
)++)
365 static int clk_pll3200c32_get_rate(unsigned long input
, struct stm_pll
*pll
,
371 *rate
= ((2 * (input
/ 1000) * pll
->ndiv
) / pll
->idf
) * 1000;
376 static unsigned long recalc_stm_pll3200c32(struct clk_hw
*hw
,
377 unsigned long parent_rate
)
379 struct clkgen_pll
*pll
= to_clkgen_pll(hw
);
380 unsigned long ndiv
, idf
;
381 unsigned long rate
= 0;
383 if (!clkgen_pll_is_enabled(hw
) || !clkgen_pll_is_locked(hw
))
386 ndiv
= CLKGEN_READ(pll
, ndiv
);
387 idf
= CLKGEN_READ(pll
, idf
);
390 /* Note: input is divided to avoid overflow */
391 rate
= ((2 * (parent_rate
/1000) * ndiv
) / idf
) * 1000;
393 pr_debug("%s:%s rate %lu\n", clk_hw_get_name(hw
), __func__
, rate
);
398 static long round_rate_stm_pll3200c32(struct clk_hw
*hw
, unsigned long rate
,
399 unsigned long *prate
)
401 struct stm_pll params
;
403 if (!clk_pll3200c32_get_params(*prate
, rate
, ¶ms
))
404 clk_pll3200c32_get_rate(*prate
, ¶ms
, &rate
);
406 pr_debug("%s: %s rate %ld Invalid\n", __func__
,
407 __clk_get_name(hw
->clk
), rate
);
411 pr_debug("%s: %s new rate %ld [ndiv=%u] [idf=%u]\n",
412 __func__
, __clk_get_name(hw
->clk
),
413 rate
, (unsigned int)params
.ndiv
,
414 (unsigned int)params
.idf
);
419 static int set_rate_stm_pll3200c32(struct clk_hw
*hw
, unsigned long rate
,
420 unsigned long parent_rate
)
422 struct clkgen_pll
*pll
= to_clkgen_pll(hw
);
423 struct stm_pll params
;
425 unsigned long flags
= 0;
427 if (!rate
|| !parent_rate
)
430 if (!clk_pll3200c32_get_params(parent_rate
, rate
, ¶ms
))
431 clk_pll3200c32_get_rate(parent_rate
, ¶ms
, &hwrate
);
433 pr_debug("%s: %s new rate %ld [ndiv=0x%x] [idf=0x%x]\n",
434 __func__
, __clk_get_name(hw
->clk
),
435 hwrate
, (unsigned int)params
.ndiv
,
436 (unsigned int)params
.idf
);
441 pll
->ndiv
= params
.ndiv
;
442 pll
->idf
= params
.idf
;
445 __clkgen_pll_disable(hw
);
448 spin_lock_irqsave(pll
->lock
, flags
);
450 CLKGEN_WRITE(pll
, ndiv
, pll
->ndiv
);
451 CLKGEN_WRITE(pll
, idf
, pll
->idf
);
452 CLKGEN_WRITE(pll
, cp
, pll
->cp
);
455 spin_unlock_irqrestore(pll
->lock
, flags
);
457 __clkgen_pll_enable(hw
);
462 /* PLL output structure
463 * FVCO >> /2 >> FVCOBY2 (no output)
464 * |> Divider (ODF) >> PHI
466 * FVCOby2 output = (input * 2 * NDIV) / IDF (assuming FRAC_CONTROL==L)
469 * 4Mhz <= INFF input <= 350Mhz
470 * 4Mhz <= INFIN (INFF / IDF) <= 50Mhz
471 * 19.05Mhz <= FVCOby2 output (PHI w ODF=1) <= 3000Mhz
472 * 1 <= i (register/dec value for IDF) <= 7
473 * 8 <= n (register/dec value for NDIV) <= 246
476 static int clk_pll4600c28_get_params(unsigned long input
, unsigned long output
,
480 unsigned long i
, infin
, n
;
481 unsigned long deviation
= ~0;
482 unsigned long new_freq
, new_deviation
;
484 /* Output clock range: 19Mhz to 3000Mhz */
485 if (output
< 19000000 || output
> 3000000000u)
488 /* For better jitter, IDF should be smallest and NDIV must be maximum */
489 for (i
= 1; i
<= 7 && deviation
; i
++) {
492 if (infin
< 4000000 || infin
> 50000000)
493 continue; /* Invalid case */
495 n
= output
/ (infin
* 2);
496 if (n
< 8 || n
> 246)
497 continue; /* Invalid case */
499 n
++; /* To work around 'y' when n=x.y */
501 for (; n
>= 8 && deviation
; n
--) {
502 new_freq
= infin
* 2 * n
;
503 if (new_freq
< output
)
504 break; /* Optimization: shorting loop */
506 new_deviation
= new_freq
- output
;
507 if (!new_deviation
|| new_deviation
< deviation
) {
510 deviation
= new_deviation
;
515 if (deviation
== ~0) /* No solution found */
521 static int clk_pll4600c28_get_rate(unsigned long input
, struct stm_pll
*pll
,
527 *rate
= (input
/ pll
->idf
) * 2 * pll
->ndiv
;
532 static unsigned long recalc_stm_pll4600c28(struct clk_hw
*hw
,
533 unsigned long parent_rate
)
535 struct clkgen_pll
*pll
= to_clkgen_pll(hw
);
536 struct stm_pll params
;
539 if (!clkgen_pll_is_enabled(hw
) || !clkgen_pll_is_locked(hw
))
542 params
.ndiv
= CLKGEN_READ(pll
, ndiv
);
543 params
.idf
= CLKGEN_READ(pll
, idf
);
545 clk_pll4600c28_get_rate(parent_rate
, ¶ms
, &rate
);
547 pr_debug("%s:%s rate %lu\n", __clk_get_name(hw
->clk
), __func__
, rate
);
552 static long round_rate_stm_pll4600c28(struct clk_hw
*hw
, unsigned long rate
,
553 unsigned long *prate
)
555 struct stm_pll params
;
557 if (!clk_pll4600c28_get_params(*prate
, rate
, ¶ms
)) {
558 clk_pll4600c28_get_rate(*prate
, ¶ms
, &rate
);
560 pr_debug("%s: %s rate %ld Invalid\n", __func__
,
561 __clk_get_name(hw
->clk
), rate
);
565 pr_debug("%s: %s new rate %ld [ndiv=%u] [idf=%u]\n",
566 __func__
, __clk_get_name(hw
->clk
),
567 rate
, (unsigned int)params
.ndiv
,
568 (unsigned int)params
.idf
);
573 static int set_rate_stm_pll4600c28(struct clk_hw
*hw
, unsigned long rate
,
574 unsigned long parent_rate
)
576 struct clkgen_pll
*pll
= to_clkgen_pll(hw
);
577 struct stm_pll params
;
579 unsigned long flags
= 0;
581 if (!rate
|| !parent_rate
)
584 if (!clk_pll4600c28_get_params(parent_rate
, rate
, ¶ms
)) {
585 clk_pll4600c28_get_rate(parent_rate
, ¶ms
, &hwrate
);
587 pr_debug("%s: %s rate %ld Invalid\n", __func__
,
588 __clk_get_name(hw
->clk
), rate
);
592 pr_debug("%s: %s new rate %ld [ndiv=0x%x] [idf=0x%x]\n",
593 __func__
, __clk_get_name(hw
->clk
),
594 hwrate
, (unsigned int)params
.ndiv
,
595 (unsigned int)params
.idf
);
600 pll
->ndiv
= params
.ndiv
;
601 pll
->idf
= params
.idf
;
603 __clkgen_pll_disable(hw
);
606 spin_lock_irqsave(pll
->lock
, flags
);
608 CLKGEN_WRITE(pll
, ndiv
, pll
->ndiv
);
609 CLKGEN_WRITE(pll
, idf
, pll
->idf
);
612 spin_unlock_irqrestore(pll
->lock
, flags
);
614 __clkgen_pll_enable(hw
);
619 static const struct clk_ops stm_pll3200c32_ops
= {
620 .enable
= clkgen_pll_enable
,
621 .disable
= clkgen_pll_disable
,
622 .is_enabled
= clkgen_pll_is_enabled
,
623 .recalc_rate
= recalc_stm_pll3200c32
,
626 static const struct clk_ops stm_pll3200c32_a9_ops
= {
627 .enable
= clkgen_pll_enable
,
628 .disable
= clkgen_pll_disable
,
629 .is_enabled
= clkgen_pll_is_enabled
,
630 .recalc_rate
= recalc_stm_pll3200c32
,
631 .round_rate
= round_rate_stm_pll3200c32
,
632 .set_rate
= set_rate_stm_pll3200c32
,
635 static const struct clk_ops stm_pll4600c28_ops
= {
636 .enable
= clkgen_pll_enable
,
637 .disable
= clkgen_pll_disable
,
638 .is_enabled
= clkgen_pll_is_enabled
,
639 .recalc_rate
= recalc_stm_pll4600c28
,
640 .round_rate
= round_rate_stm_pll4600c28
,
641 .set_rate
= set_rate_stm_pll4600c28
,
644 static struct clk
* __init
clkgen_pll_register(const char *parent_name
,
645 struct clkgen_pll_data
*pll_data
,
646 void __iomem
*reg
, unsigned long pll_flags
,
647 const char *clk_name
, spinlock_t
*lock
)
649 struct clkgen_pll
*pll
;
651 struct clk_init_data init
;
653 pll
= kzalloc(sizeof(*pll
), GFP_KERNEL
);
655 return ERR_PTR(-ENOMEM
);
657 init
.name
= clk_name
;
658 init
.ops
= pll_data
->ops
;
660 init
.flags
= pll_flags
| CLK_GET_RATE_NOCACHE
;
661 init
.parent_names
= &parent_name
;
662 init
.num_parents
= 1;
664 pll
->data
= pll_data
;
665 pll
->regs_base
= reg
;
666 pll
->hw
.init
= &init
;
669 clk
= clk_register(NULL
, &pll
->hw
);
675 pr_debug("%s: parent %s rate %lu\n",
677 __clk_get_name(clk_get_parent(clk
)),
683 static void __iomem
* __init
clkgen_get_register_base(
684 struct device_node
*np
)
686 struct device_node
*pnode
;
687 void __iomem
*reg
= NULL
;
689 pnode
= of_get_parent(np
);
693 reg
= of_iomap(pnode
, 0);
699 static struct clk
* __init
clkgen_odf_register(const char *parent_name
,
701 struct clkgen_pll_data
*pll_data
,
702 unsigned long pll_flags
, int odf
,
703 spinlock_t
*odf_lock
,
704 const char *odf_name
)
708 struct clk_gate
*gate
;
709 struct clk_divider
*div
;
711 flags
= pll_flags
| CLK_GET_RATE_NOCACHE
| CLK_SET_RATE_PARENT
;
713 gate
= kzalloc(sizeof(*gate
), GFP_KERNEL
);
715 return ERR_PTR(-ENOMEM
);
717 gate
->flags
= CLK_GATE_SET_TO_DISABLE
;
718 gate
->reg
= reg
+ pll_data
->odf_gate
[odf
].offset
;
719 gate
->bit_idx
= pll_data
->odf_gate
[odf
].shift
;
720 gate
->lock
= odf_lock
;
722 div
= kzalloc(sizeof(*div
), GFP_KERNEL
);
725 return ERR_PTR(-ENOMEM
);
728 div
->flags
= CLK_DIVIDER_ONE_BASED
| CLK_DIVIDER_ALLOW_ZERO
;
729 div
->reg
= reg
+ pll_data
->odf
[odf
].offset
;
730 div
->shift
= pll_data
->odf
[odf
].shift
;
731 div
->width
= fls(pll_data
->odf
[odf
].mask
);
732 div
->lock
= odf_lock
;
734 clk
= clk_register_composite(NULL
, odf_name
, &parent_name
, 1,
736 &div
->hw
, &clk_divider_ops
,
737 &gate
->hw
, &clk_gate_ops
,
742 pr_debug("%s: parent %s rate %lu\n",
744 __clk_get_name(clk_get_parent(clk
)),
750 static void __init
clkgen_c32_pll_setup(struct device_node
*np
,
751 struct clkgen_pll_data_clks
*datac
)
754 const char *parent_name
, *pll_name
;
755 void __iomem
*pll_base
;
757 struct clk_onecell_data
*clk_data
;
758 unsigned long pll_flags
= 0;
761 parent_name
= of_clk_get_parent_name(np
, 0);
765 pll_base
= clkgen_get_register_base(np
);
769 of_clk_detect_critical(np
, 0, &pll_flags
);
771 clk
= clkgen_pll_register(parent_name
, datac
->data
, pll_base
, pll_flags
,
772 np
->name
, datac
->data
->lock
);
776 pll_name
= __clk_get_name(clk
);
778 num_odfs
= datac
->data
->num_odfs
;
780 clk_data
= kzalloc(sizeof(*clk_data
), GFP_KERNEL
);
784 clk_data
->clk_num
= num_odfs
;
785 clk_data
->clks
= kcalloc(clk_data
->clk_num
, sizeof(struct clk
*),
791 for (odf
= 0; odf
< num_odfs
; odf
++) {
793 const char *clk_name
;
794 unsigned long odf_flags
= 0;
796 if (datac
->outputs
) {
797 clk_name
= datac
->outputs
[odf
].name
;
798 odf_flags
= datac
->outputs
[odf
].flags
;
800 if (of_property_read_string_index(np
,
801 "clock-output-names",
805 of_clk_detect_critical(np
, odf
, &odf_flags
);
808 clk
= clkgen_odf_register(pll_name
, pll_base
, datac
->data
,
809 odf_flags
, odf
, &clkgena_c32_odf_lock
,
814 clk_data
->clks
[odf
] = clk
;
817 of_clk_add_provider(np
, of_clk_src_onecell_get
, clk_data
);
822 kfree(clk_data
->clks
);
825 static void __init
clkgen_c32_pll0_setup(struct device_node
*np
)
827 clkgen_c32_pll_setup(np
,
828 (struct clkgen_pll_data_clks
*) &st_pll3200c32_cx_0_legacy_data
);
830 CLK_OF_DECLARE(c32_pll0
, "st,clkgen-pll0", clkgen_c32_pll0_setup
);
832 static void __init
clkgen_c32_pll0_a0_setup(struct device_node
*np
)
834 clkgen_c32_pll_setup(np
,
835 (struct clkgen_pll_data_clks
*) &st_pll3200c32_a0_data
);
837 CLK_OF_DECLARE(c32_pll0_a0
, "st,clkgen-pll0-a0", clkgen_c32_pll0_a0_setup
);
839 static void __init
clkgen_c32_pll0_c0_setup(struct device_node
*np
)
841 clkgen_c32_pll_setup(np
,
842 (struct clkgen_pll_data_clks
*) &st_pll3200c32_c0_data
);
844 CLK_OF_DECLARE(c32_pll0_c0
, "st,clkgen-pll0-c0", clkgen_c32_pll0_c0_setup
);
846 static void __init
clkgen_c32_pll1_setup(struct device_node
*np
)
848 clkgen_c32_pll_setup(np
,
849 (struct clkgen_pll_data_clks
*) &st_pll3200c32_cx_1_legacy_data
);
851 CLK_OF_DECLARE(c32_pll1
, "st,clkgen-pll1", clkgen_c32_pll1_setup
);
853 static void __init
clkgen_c32_pll1_c0_setup(struct device_node
*np
)
855 clkgen_c32_pll_setup(np
,
856 (struct clkgen_pll_data_clks
*) &st_pll3200c32_c1_data
);
858 CLK_OF_DECLARE(c32_pll1_c0
, "st,clkgen-pll1-c0", clkgen_c32_pll1_c0_setup
);
860 static void __init
clkgen_c32_plla9_setup(struct device_node
*np
)
862 clkgen_c32_pll_setup(np
,
863 (struct clkgen_pll_data_clks
*) &st_pll3200c32_407_a9_data
);
865 CLK_OF_DECLARE(c32_plla9
, "st,stih407-clkgen-plla9", clkgen_c32_plla9_setup
);
867 static void __init
clkgen_c28_plla9_setup(struct device_node
*np
)
869 clkgen_c32_pll_setup(np
,
870 (struct clkgen_pll_data_clks
*) &st_pll4600c28_418_a9_data
);
872 CLK_OF_DECLARE(c28_plla9
, "st,stih418-clkgen-plla9", clkgen_c28_plla9_setup
);