2 * Copyright (C) 2014 Broadcom Corporation
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation version 2.
8 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 * kind, whether express or implied; without even the implied warranty
10 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #include <linux/kernel.h>
15 #include <linux/err.h>
16 #include <linux/clk-provider.h>
19 #include <linux/clkdev.h>
20 #include <linux/of_address.h>
21 #include <linux/delay.h>
23 #include "clk-iproc.h"
25 #define PLL_VCO_HIGH_SHIFT 19
26 #define PLL_VCO_LOW_SHIFT 30
29 * PLL MACRO_SELECT modes 0 to 5 choose pre-calculated PLL output frequencies
30 * from a look-up table. Mode 7 allows user to manipulate PLL clock dividers
32 #define PLL_USER_MODE 7
34 /* number of delay loops waiting for PLL to lock */
35 #define LOCK_DELAY 100
37 /* number of VCO frequency bands */
38 #define NUM_FREQ_BANDS 8
40 #define NUM_KP_BANDS 3
47 static const unsigned int kp_table
[NUM_KP_BANDS
][NUM_FREQ_BANDS
] = {
48 { 5, 6, 6, 7, 7, 8, 9, 10 },
49 { 4, 4, 5, 5, 6, 7, 8, 9 },
50 { 4, 5, 5, 6, 7, 8, 9, 10 },
53 static const unsigned long ref_freq_table
[NUM_FREQ_BANDS
][2] = {
54 { 10000000, 12500000 },
55 { 12500000, 15000000 },
56 { 15000000, 20000000 },
57 { 20000000, 25000000 },
58 { 25000000, 50000000 },
59 { 50000000, 75000000 },
60 { 75000000, 100000000 },
61 { 100000000, 125000000 },
66 VCO_MID
= 1200000000U,
67 VCO_HIGH
= 2200000000U,
68 VCO_HIGH_HIGH
= 3100000000U,
69 VCO_MAX
= 4000000000U,
77 struct iproc_pll
*pll
;
79 const struct iproc_clk_ctrl
*ctrl
;
83 void __iomem
*status_base
;
84 void __iomem
*control_base
;
85 void __iomem
*pwr_base
;
86 void __iomem
*asiu_base
;
88 const struct iproc_pll_ctrl
*ctrl
;
89 const struct iproc_pll_vco_param
*vco_param
;
90 unsigned int num_vco_entries
;
92 struct clk_hw_onecell_data
*clk_data
;
93 struct iproc_clk
*clks
;
96 #define to_iproc_clk(hw) container_of(hw, struct iproc_clk, hw)
99 * Based on the target frequency, find a match from the VCO frequency parameter
100 * table and return its index
102 static int pll_get_rate_index(struct iproc_pll
*pll
, unsigned int target_rate
)
106 for (i
= 0; i
< pll
->num_vco_entries
; i
++)
107 if (target_rate
== pll
->vco_param
[i
].rate
)
110 if (i
>= pll
->num_vco_entries
)
116 static int get_kp(unsigned long ref_freq
, enum kp_band kp_index
)
120 if (ref_freq
< ref_freq_table
[0][0])
123 for (i
= 0; i
< NUM_FREQ_BANDS
; i
++) {
124 if (ref_freq
>= ref_freq_table
[i
][0] &&
125 ref_freq
< ref_freq_table
[i
][1])
126 return kp_table
[kp_index
][i
];
131 static int pll_wait_for_lock(struct iproc_pll
*pll
)
134 const struct iproc_pll_ctrl
*ctrl
= pll
->ctrl
;
136 for (i
= 0; i
< LOCK_DELAY
; i
++) {
137 u32 val
= readl(pll
->status_base
+ ctrl
->status
.offset
);
139 if (val
& (1 << ctrl
->status
.shift
))
147 static void iproc_pll_write(const struct iproc_pll
*pll
, void __iomem
*base
,
148 const u32 offset
, u32 val
)
150 const struct iproc_pll_ctrl
*ctrl
= pll
->ctrl
;
152 writel(val
, base
+ offset
);
154 if (unlikely(ctrl
->flags
& IPROC_CLK_NEEDS_READ_BACK
&&
155 (base
== pll
->status_base
|| base
== pll
->control_base
)))
156 val
= readl(base
+ offset
);
159 static void __pll_disable(struct iproc_pll
*pll
)
161 const struct iproc_pll_ctrl
*ctrl
= pll
->ctrl
;
164 if (ctrl
->flags
& IPROC_CLK_PLL_ASIU
) {
165 val
= readl(pll
->asiu_base
+ ctrl
->asiu
.offset
);
166 val
&= ~(1 << ctrl
->asiu
.en_shift
);
167 iproc_pll_write(pll
, pll
->asiu_base
, ctrl
->asiu
.offset
, val
);
170 if (ctrl
->flags
& IPROC_CLK_EMBED_PWRCTRL
) {
171 val
= readl(pll
->control_base
+ ctrl
->aon
.offset
);
172 val
|= bit_mask(ctrl
->aon
.pwr_width
) << ctrl
->aon
.pwr_shift
;
173 iproc_pll_write(pll
, pll
->control_base
, ctrl
->aon
.offset
, val
);
177 /* latch input value so core power can be shut down */
178 val
= readl(pll
->pwr_base
+ ctrl
->aon
.offset
);
179 val
|= 1 << ctrl
->aon
.iso_shift
;
180 iproc_pll_write(pll
, pll
->pwr_base
, ctrl
->aon
.offset
, val
);
182 /* power down the core */
183 val
&= ~(bit_mask(ctrl
->aon
.pwr_width
) << ctrl
->aon
.pwr_shift
);
184 iproc_pll_write(pll
, pll
->pwr_base
, ctrl
->aon
.offset
, val
);
188 static int __pll_enable(struct iproc_pll
*pll
)
190 const struct iproc_pll_ctrl
*ctrl
= pll
->ctrl
;
193 if (ctrl
->flags
& IPROC_CLK_EMBED_PWRCTRL
) {
194 val
= readl(pll
->control_base
+ ctrl
->aon
.offset
);
195 val
&= ~(bit_mask(ctrl
->aon
.pwr_width
) << ctrl
->aon
.pwr_shift
);
196 iproc_pll_write(pll
, pll
->control_base
, ctrl
->aon
.offset
, val
);
200 /* power up the PLL and make sure it's not latched */
201 val
= readl(pll
->pwr_base
+ ctrl
->aon
.offset
);
202 val
|= bit_mask(ctrl
->aon
.pwr_width
) << ctrl
->aon
.pwr_shift
;
203 val
&= ~(1 << ctrl
->aon
.iso_shift
);
204 iproc_pll_write(pll
, pll
->pwr_base
, ctrl
->aon
.offset
, val
);
207 /* certain PLLs also need to be ungated from the ASIU top level */
208 if (ctrl
->flags
& IPROC_CLK_PLL_ASIU
) {
209 val
= readl(pll
->asiu_base
+ ctrl
->asiu
.offset
);
210 val
|= (1 << ctrl
->asiu
.en_shift
);
211 iproc_pll_write(pll
, pll
->asiu_base
, ctrl
->asiu
.offset
, val
);
217 static void __pll_put_in_reset(struct iproc_pll
*pll
)
220 const struct iproc_pll_ctrl
*ctrl
= pll
->ctrl
;
221 const struct iproc_pll_reset_ctrl
*reset
= &ctrl
->reset
;
223 val
= readl(pll
->control_base
+ reset
->offset
);
224 if (ctrl
->flags
& IPROC_CLK_PLL_RESET_ACTIVE_LOW
)
225 val
|= BIT(reset
->reset_shift
) | BIT(reset
->p_reset_shift
);
227 val
&= ~(BIT(reset
->reset_shift
) | BIT(reset
->p_reset_shift
));
228 iproc_pll_write(pll
, pll
->control_base
, reset
->offset
, val
);
231 static void __pll_bring_out_reset(struct iproc_pll
*pll
, unsigned int kp
,
232 unsigned int ka
, unsigned int ki
)
235 const struct iproc_pll_ctrl
*ctrl
= pll
->ctrl
;
236 const struct iproc_pll_reset_ctrl
*reset
= &ctrl
->reset
;
237 const struct iproc_pll_dig_filter_ctrl
*dig_filter
= &ctrl
->dig_filter
;
239 val
= readl(pll
->control_base
+ dig_filter
->offset
);
240 val
&= ~(bit_mask(dig_filter
->ki_width
) << dig_filter
->ki_shift
|
241 bit_mask(dig_filter
->kp_width
) << dig_filter
->kp_shift
|
242 bit_mask(dig_filter
->ka_width
) << dig_filter
->ka_shift
);
243 val
|= ki
<< dig_filter
->ki_shift
| kp
<< dig_filter
->kp_shift
|
244 ka
<< dig_filter
->ka_shift
;
245 iproc_pll_write(pll
, pll
->control_base
, dig_filter
->offset
, val
);
247 val
= readl(pll
->control_base
+ reset
->offset
);
248 if (ctrl
->flags
& IPROC_CLK_PLL_RESET_ACTIVE_LOW
)
249 val
&= ~(BIT(reset
->reset_shift
) | BIT(reset
->p_reset_shift
));
251 val
|= BIT(reset
->reset_shift
) | BIT(reset
->p_reset_shift
);
252 iproc_pll_write(pll
, pll
->control_base
, reset
->offset
, val
);
255 static int pll_set_rate(struct iproc_clk
*clk
, unsigned int rate_index
,
256 unsigned long parent_rate
)
258 struct iproc_pll
*pll
= clk
->pll
;
259 const struct iproc_pll_vco_param
*vco
= &pll
->vco_param
[rate_index
];
260 const struct iproc_pll_ctrl
*ctrl
= pll
->ctrl
;
261 int ka
= 0, ki
, kp
, ret
;
262 unsigned long rate
= vco
->rate
;
264 enum kp_band kp_index
;
265 unsigned long ref_freq
;
268 * reference frequency = parent frequency / PDIV
269 * If PDIV = 0, then it becomes a multiplier (x2)
272 ref_freq
= parent_rate
* 2;
274 ref_freq
= parent_rate
/ vco
->pdiv
;
276 /* determine Ki and Kp index based on target VCO frequency */
277 if (rate
>= VCO_LOW
&& rate
< VCO_HIGH
) {
279 kp_index
= KP_BAND_MID
;
280 } else if (rate
>= VCO_HIGH
&& rate
&& rate
< VCO_HIGH_HIGH
) {
282 kp_index
= KP_BAND_HIGH
;
283 } else if (rate
>= VCO_HIGH_HIGH
&& rate
< VCO_MAX
) {
285 kp_index
= KP_BAND_HIGH_HIGH
;
287 pr_err("%s: pll: %s has invalid rate: %lu\n", __func__
,
292 kp
= get_kp(ref_freq
, kp_index
);
294 pr_err("%s: pll: %s has invalid kp\n", __func__
, clk
->name
);
298 ret
= __pll_enable(pll
);
300 pr_err("%s: pll: %s fails to enable\n", __func__
, clk
->name
);
304 /* put PLL in reset */
305 __pll_put_in_reset(pll
);
307 /* set PLL in user mode before modifying PLL controls */
308 if (ctrl
->flags
& IPROC_CLK_PLL_USER_MODE_ON
) {
309 val
= readl(pll
->control_base
+ ctrl
->macro_mode
.offset
);
310 val
&= ~(bit_mask(ctrl
->macro_mode
.width
) <<
311 ctrl
->macro_mode
.shift
);
312 val
|= PLL_USER_MODE
<< ctrl
->macro_mode
.shift
;
313 iproc_pll_write(pll
, pll
->control_base
,
314 ctrl
->macro_mode
.offset
, val
);
317 iproc_pll_write(pll
, pll
->control_base
, ctrl
->vco_ctrl
.u_offset
, 0);
319 val
= readl(pll
->control_base
+ ctrl
->vco_ctrl
.l_offset
);
321 if (rate
>= VCO_LOW
&& rate
< VCO_MID
)
322 val
|= (1 << PLL_VCO_LOW_SHIFT
);
325 val
&= ~(1 << PLL_VCO_HIGH_SHIFT
);
327 val
|= (1 << PLL_VCO_HIGH_SHIFT
);
329 iproc_pll_write(pll
, pll
->control_base
, ctrl
->vco_ctrl
.l_offset
, val
);
331 /* program integer part of NDIV */
332 val
= readl(pll
->control_base
+ ctrl
->ndiv_int
.offset
);
333 val
&= ~(bit_mask(ctrl
->ndiv_int
.width
) << ctrl
->ndiv_int
.shift
);
334 val
|= vco
->ndiv_int
<< ctrl
->ndiv_int
.shift
;
335 iproc_pll_write(pll
, pll
->control_base
, ctrl
->ndiv_int
.offset
, val
);
337 /* program fractional part of NDIV */
338 if (ctrl
->flags
& IPROC_CLK_PLL_HAS_NDIV_FRAC
) {
339 val
= readl(pll
->control_base
+ ctrl
->ndiv_frac
.offset
);
340 val
&= ~(bit_mask(ctrl
->ndiv_frac
.width
) <<
341 ctrl
->ndiv_frac
.shift
);
342 val
|= vco
->ndiv_frac
<< ctrl
->ndiv_frac
.shift
;
343 iproc_pll_write(pll
, pll
->control_base
, ctrl
->ndiv_frac
.offset
,
348 val
= readl(pll
->control_base
+ ctrl
->pdiv
.offset
);
349 val
&= ~(bit_mask(ctrl
->pdiv
.width
) << ctrl
->pdiv
.shift
);
350 val
|= vco
->pdiv
<< ctrl
->pdiv
.shift
;
351 iproc_pll_write(pll
, pll
->control_base
, ctrl
->pdiv
.offset
, val
);
353 __pll_bring_out_reset(pll
, kp
, ka
, ki
);
355 ret
= pll_wait_for_lock(pll
);
357 pr_err("%s: pll: %s failed to lock\n", __func__
, clk
->name
);
364 static int iproc_pll_enable(struct clk_hw
*hw
)
366 struct iproc_clk
*clk
= to_iproc_clk(hw
);
367 struct iproc_pll
*pll
= clk
->pll
;
369 return __pll_enable(pll
);
372 static void iproc_pll_disable(struct clk_hw
*hw
)
374 struct iproc_clk
*clk
= to_iproc_clk(hw
);
375 struct iproc_pll
*pll
= clk
->pll
;
376 const struct iproc_pll_ctrl
*ctrl
= pll
->ctrl
;
378 if (ctrl
->flags
& IPROC_CLK_AON
)
384 static unsigned long iproc_pll_recalc_rate(struct clk_hw
*hw
,
385 unsigned long parent_rate
)
387 struct iproc_clk
*clk
= to_iproc_clk(hw
);
388 struct iproc_pll
*pll
= clk
->pll
;
389 const struct iproc_pll_ctrl
*ctrl
= pll
->ctrl
;
391 u64 ndiv
, ndiv_int
, ndiv_frac
;
394 if (parent_rate
== 0)
397 /* PLL needs to be locked */
398 val
= readl(pll
->status_base
+ ctrl
->status
.offset
);
399 if ((val
& (1 << ctrl
->status
.shift
)) == 0) {
405 * PLL output frequency =
407 * ((ndiv_int + ndiv_frac / 2^20) * (parent clock rate / pdiv)
409 val
= readl(pll
->control_base
+ ctrl
->ndiv_int
.offset
);
410 ndiv_int
= (val
>> ctrl
->ndiv_int
.shift
) &
411 bit_mask(ctrl
->ndiv_int
.width
);
412 ndiv
= ndiv_int
<< 20;
414 if (ctrl
->flags
& IPROC_CLK_PLL_HAS_NDIV_FRAC
) {
415 val
= readl(pll
->control_base
+ ctrl
->ndiv_frac
.offset
);
416 ndiv_frac
= (val
>> ctrl
->ndiv_frac
.shift
) &
417 bit_mask(ctrl
->ndiv_frac
.width
);
421 val
= readl(pll
->control_base
+ ctrl
->pdiv
.offset
);
422 pdiv
= (val
>> ctrl
->pdiv
.shift
) & bit_mask(ctrl
->pdiv
.width
);
424 clk
->rate
= (ndiv
* parent_rate
) >> 20;
434 static long iproc_pll_round_rate(struct clk_hw
*hw
, unsigned long rate
,
435 unsigned long *parent_rate
)
438 struct iproc_clk
*clk
= to_iproc_clk(hw
);
439 struct iproc_pll
*pll
= clk
->pll
;
441 if (rate
== 0 || *parent_rate
== 0 || !pll
->vco_param
)
444 for (i
= 0; i
< pll
->num_vco_entries
; i
++) {
445 if (rate
<= pll
->vco_param
[i
].rate
)
449 if (i
== pll
->num_vco_entries
)
452 return pll
->vco_param
[i
].rate
;
455 static int iproc_pll_set_rate(struct clk_hw
*hw
, unsigned long rate
,
456 unsigned long parent_rate
)
458 struct iproc_clk
*clk
= to_iproc_clk(hw
);
459 struct iproc_pll
*pll
= clk
->pll
;
462 rate_index
= pll_get_rate_index(pll
, rate
);
466 ret
= pll_set_rate(clk
, rate_index
, parent_rate
);
470 static const struct clk_ops iproc_pll_ops
= {
471 .enable
= iproc_pll_enable
,
472 .disable
= iproc_pll_disable
,
473 .recalc_rate
= iproc_pll_recalc_rate
,
474 .round_rate
= iproc_pll_round_rate
,
475 .set_rate
= iproc_pll_set_rate
,
478 static int iproc_clk_enable(struct clk_hw
*hw
)
480 struct iproc_clk
*clk
= to_iproc_clk(hw
);
481 const struct iproc_clk_ctrl
*ctrl
= clk
->ctrl
;
482 struct iproc_pll
*pll
= clk
->pll
;
485 /* channel enable is active low */
486 val
= readl(pll
->control_base
+ ctrl
->enable
.offset
);
487 val
&= ~(1 << ctrl
->enable
.enable_shift
);
488 iproc_pll_write(pll
, pll
->control_base
, ctrl
->enable
.offset
, val
);
490 /* also make sure channel is not held */
491 val
= readl(pll
->control_base
+ ctrl
->enable
.offset
);
492 val
&= ~(1 << ctrl
->enable
.hold_shift
);
493 iproc_pll_write(pll
, pll
->control_base
, ctrl
->enable
.offset
, val
);
498 static void iproc_clk_disable(struct clk_hw
*hw
)
500 struct iproc_clk
*clk
= to_iproc_clk(hw
);
501 const struct iproc_clk_ctrl
*ctrl
= clk
->ctrl
;
502 struct iproc_pll
*pll
= clk
->pll
;
505 if (ctrl
->flags
& IPROC_CLK_AON
)
508 val
= readl(pll
->control_base
+ ctrl
->enable
.offset
);
509 val
|= 1 << ctrl
->enable
.enable_shift
;
510 iproc_pll_write(pll
, pll
->control_base
, ctrl
->enable
.offset
, val
);
513 static unsigned long iproc_clk_recalc_rate(struct clk_hw
*hw
,
514 unsigned long parent_rate
)
516 struct iproc_clk
*clk
= to_iproc_clk(hw
);
517 const struct iproc_clk_ctrl
*ctrl
= clk
->ctrl
;
518 struct iproc_pll
*pll
= clk
->pll
;
522 if (parent_rate
== 0)
525 val
= readl(pll
->control_base
+ ctrl
->mdiv
.offset
);
526 mdiv
= (val
>> ctrl
->mdiv
.shift
) & bit_mask(ctrl
->mdiv
.width
);
530 if (ctrl
->flags
& IPROC_CLK_MCLK_DIV_BY_2
)
531 clk
->rate
= parent_rate
/ (mdiv
* 2);
533 clk
->rate
= parent_rate
/ mdiv
;
538 static long iproc_clk_round_rate(struct clk_hw
*hw
, unsigned long rate
,
539 unsigned long *parent_rate
)
543 if (rate
== 0 || *parent_rate
== 0)
546 if (rate
== *parent_rate
)
549 div
= DIV_ROUND_UP(*parent_rate
, rate
);
556 return *parent_rate
/ div
;
559 static int iproc_clk_set_rate(struct clk_hw
*hw
, unsigned long rate
,
560 unsigned long parent_rate
)
562 struct iproc_clk
*clk
= to_iproc_clk(hw
);
563 const struct iproc_clk_ctrl
*ctrl
= clk
->ctrl
;
564 struct iproc_pll
*pll
= clk
->pll
;
568 if (rate
== 0 || parent_rate
== 0)
571 if (ctrl
->flags
& IPROC_CLK_MCLK_DIV_BY_2
)
572 div
= DIV_ROUND_UP(parent_rate
, rate
* 2);
574 div
= DIV_ROUND_UP(parent_rate
, rate
);
578 val
= readl(pll
->control_base
+ ctrl
->mdiv
.offset
);
580 val
&= ~(bit_mask(ctrl
->mdiv
.width
) << ctrl
->mdiv
.shift
);
582 val
&= ~(bit_mask(ctrl
->mdiv
.width
) << ctrl
->mdiv
.shift
);
583 val
|= div
<< ctrl
->mdiv
.shift
;
585 iproc_pll_write(pll
, pll
->control_base
, ctrl
->mdiv
.offset
, val
);
586 if (ctrl
->flags
& IPROC_CLK_MCLK_DIV_BY_2
)
587 clk
->rate
= parent_rate
/ (div
* 2);
589 clk
->rate
= parent_rate
/ div
;
594 static const struct clk_ops iproc_clk_ops
= {
595 .enable
= iproc_clk_enable
,
596 .disable
= iproc_clk_disable
,
597 .recalc_rate
= iproc_clk_recalc_rate
,
598 .round_rate
= iproc_clk_round_rate
,
599 .set_rate
= iproc_clk_set_rate
,
603 * Some PLLs require the PLL SW override bit to be set before changes can be
606 static void iproc_pll_sw_cfg(struct iproc_pll
*pll
)
608 const struct iproc_pll_ctrl
*ctrl
= pll
->ctrl
;
610 if (ctrl
->flags
& IPROC_CLK_PLL_NEEDS_SW_CFG
) {
613 val
= readl(pll
->control_base
+ ctrl
->sw_ctrl
.offset
);
614 val
|= BIT(ctrl
->sw_ctrl
.shift
);
615 iproc_pll_write(pll
, pll
->control_base
, ctrl
->sw_ctrl
.offset
,
620 void __init
iproc_pll_clk_setup(struct device_node
*node
,
621 const struct iproc_pll_ctrl
*pll_ctrl
,
622 const struct iproc_pll_vco_param
*vco
,
623 unsigned int num_vco_entries
,
624 const struct iproc_clk_ctrl
*clk_ctrl
,
625 unsigned int num_clks
)
628 struct iproc_pll
*pll
;
629 struct iproc_clk
*iclk
;
630 struct clk_init_data init
;
631 const char *parent_name
;
633 if (WARN_ON(!pll_ctrl
) || WARN_ON(!clk_ctrl
))
636 pll
= kzalloc(sizeof(*pll
), GFP_KERNEL
);
640 pll
->clk_data
= kzalloc(sizeof(*pll
->clk_data
->hws
) * num_clks
+
641 sizeof(*pll
->clk_data
), GFP_KERNEL
);
642 if (WARN_ON(!pll
->clk_data
))
644 pll
->clk_data
->num
= num_clks
;
646 pll
->clks
= kcalloc(num_clks
, sizeof(*pll
->clks
), GFP_KERNEL
);
647 if (WARN_ON(!pll
->clks
))
650 pll
->control_base
= of_iomap(node
, 0);
651 if (WARN_ON(!pll
->control_base
))
654 /* Some SoCs do not require the pwr_base, thus failing is not fatal */
655 pll
->pwr_base
= of_iomap(node
, 1);
657 /* some PLLs require gating control at the top ASIU level */
658 if (pll_ctrl
->flags
& IPROC_CLK_PLL_ASIU
) {
659 pll
->asiu_base
= of_iomap(node
, 2);
660 if (WARN_ON(!pll
->asiu_base
))
664 if (pll_ctrl
->flags
& IPROC_CLK_PLL_SPLIT_STAT_CTRL
) {
665 /* Some SoCs have a split status/control. If this does not
666 * exist, assume they are unified.
668 pll
->status_base
= of_iomap(node
, 2);
669 if (!pll
->status_base
)
670 goto err_status_iomap
;
672 pll
->status_base
= pll
->control_base
;
674 /* initialize and register the PLL itself */
675 pll
->ctrl
= pll_ctrl
;
677 iclk
= &pll
->clks
[0];
679 iclk
->name
= node
->name
;
681 init
.name
= node
->name
;
682 init
.ops
= &iproc_pll_ops
;
684 parent_name
= of_clk_get_parent_name(node
, 0);
685 init
.parent_names
= (parent_name
? &parent_name
: NULL
);
686 init
.num_parents
= (parent_name
? 1 : 0);
687 iclk
->hw
.init
= &init
;
690 pll
->num_vco_entries
= num_vco_entries
;
691 pll
->vco_param
= vco
;
694 iproc_pll_sw_cfg(pll
);
696 ret
= clk_hw_register(NULL
, &iclk
->hw
);
698 goto err_pll_register
;
700 pll
->clk_data
->hws
[0] = &iclk
->hw
;
702 /* now initialize and register all leaf clocks */
703 for (i
= 1; i
< num_clks
; i
++) {
704 const char *clk_name
;
706 memset(&init
, 0, sizeof(init
));
707 parent_name
= node
->name
;
709 ret
= of_property_read_string_index(node
, "clock-output-names",
712 goto err_clk_register
;
714 iclk
= &pll
->clks
[i
];
715 iclk
->name
= clk_name
;
717 iclk
->ctrl
= &clk_ctrl
[i
];
719 init
.name
= clk_name
;
720 init
.ops
= &iproc_clk_ops
;
722 init
.parent_names
= (parent_name
? &parent_name
: NULL
);
723 init
.num_parents
= (parent_name
? 1 : 0);
724 iclk
->hw
.init
= &init
;
726 ret
= clk_hw_register(NULL
, &iclk
->hw
);
728 goto err_clk_register
;
730 pll
->clk_data
->hws
[i
] = &iclk
->hw
;
733 ret
= of_clk_add_hw_provider(node
, of_clk_hw_onecell_get
,
736 goto err_clk_register
;
742 clk_hw_unregister(pll
->clk_data
->hws
[i
]);
745 if (pll
->status_base
!= pll
->control_base
)
746 iounmap(pll
->status_base
);
750 iounmap(pll
->asiu_base
);
754 iounmap(pll
->pwr_base
);
756 iounmap(pll
->control_base
);
762 kfree(pll
->clk_data
);