of: MSI: Simplify irqdomain lookup
[linux/fpc-iii.git] / drivers / clk / bcm / clk-iproc-pll.c
blobafd5891ac9e6aafeb6f429e487d5e06cbfd2f4f1
1 /*
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>
17 #include <linux/io.h>
18 #include <linux/of.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
28 /* number of delay loops waiting for PLL to lock */
29 #define LOCK_DELAY 100
31 /* number of VCO frequency bands */
32 #define NUM_FREQ_BANDS 8
34 #define NUM_KP_BANDS 3
35 enum kp_band {
36 KP_BAND_MID = 0,
37 KP_BAND_HIGH,
38 KP_BAND_HIGH_HIGH
41 static const unsigned int kp_table[NUM_KP_BANDS][NUM_FREQ_BANDS] = {
42 { 5, 6, 6, 7, 7, 8, 9, 10 },
43 { 4, 4, 5, 5, 6, 7, 8, 9 },
44 { 4, 5, 5, 6, 7, 8, 9, 10 },
47 static const unsigned long ref_freq_table[NUM_FREQ_BANDS][2] = {
48 { 10000000, 12500000 },
49 { 12500000, 15000000 },
50 { 15000000, 20000000 },
51 { 20000000, 25000000 },
52 { 25000000, 50000000 },
53 { 50000000, 75000000 },
54 { 75000000, 100000000 },
55 { 100000000, 125000000 },
58 enum vco_freq_range {
59 VCO_LOW = 700000000U,
60 VCO_MID = 1200000000U,
61 VCO_HIGH = 2200000000U,
62 VCO_HIGH_HIGH = 3100000000U,
63 VCO_MAX = 4000000000U,
66 struct iproc_pll;
68 struct iproc_clk {
69 struct clk_hw hw;
70 const char *name;
71 struct iproc_pll *pll;
72 unsigned long rate;
73 const struct iproc_clk_ctrl *ctrl;
76 struct iproc_pll {
77 void __iomem *status_base;
78 void __iomem *control_base;
79 void __iomem *pwr_base;
80 void __iomem *asiu_base;
82 const struct iproc_pll_ctrl *ctrl;
83 const struct iproc_pll_vco_param *vco_param;
84 unsigned int num_vco_entries;
86 struct clk_onecell_data clk_data;
87 struct iproc_clk *clks;
90 #define to_iproc_clk(hw) container_of(hw, struct iproc_clk, hw)
93 * Based on the target frequency, find a match from the VCO frequency parameter
94 * table and return its index
96 static int pll_get_rate_index(struct iproc_pll *pll, unsigned int target_rate)
98 int i;
100 for (i = 0; i < pll->num_vco_entries; i++)
101 if (target_rate == pll->vco_param[i].rate)
102 break;
104 if (i >= pll->num_vco_entries)
105 return -EINVAL;
107 return i;
110 static int get_kp(unsigned long ref_freq, enum kp_band kp_index)
112 int i;
114 if (ref_freq < ref_freq_table[0][0])
115 return -EINVAL;
117 for (i = 0; i < NUM_FREQ_BANDS; i++) {
118 if (ref_freq >= ref_freq_table[i][0] &&
119 ref_freq < ref_freq_table[i][1])
120 return kp_table[kp_index][i];
122 return -EINVAL;
125 static int pll_wait_for_lock(struct iproc_pll *pll)
127 int i;
128 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
130 for (i = 0; i < LOCK_DELAY; i++) {
131 u32 val = readl(pll->status_base + ctrl->status.offset);
133 if (val & (1 << ctrl->status.shift))
134 return 0;
135 udelay(10);
138 return -EIO;
141 static void iproc_pll_write(const struct iproc_pll *pll, void __iomem *base,
142 const u32 offset, u32 val)
144 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
146 writel(val, base + offset);
148 if (unlikely(ctrl->flags & IPROC_CLK_NEEDS_READ_BACK &&
149 (base == pll->status_base || base == pll->control_base)))
150 val = readl(base + offset);
153 static void __pll_disable(struct iproc_pll *pll)
155 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
156 u32 val;
158 if (ctrl->flags & IPROC_CLK_PLL_ASIU) {
159 val = readl(pll->asiu_base + ctrl->asiu.offset);
160 val &= ~(1 << ctrl->asiu.en_shift);
161 iproc_pll_write(pll, pll->asiu_base, ctrl->asiu.offset, val);
164 if (ctrl->flags & IPROC_CLK_EMBED_PWRCTRL) {
165 val = readl(pll->control_base + ctrl->aon.offset);
166 val |= bit_mask(ctrl->aon.pwr_width) << ctrl->aon.pwr_shift;
167 iproc_pll_write(pll, pll->control_base, ctrl->aon.offset, val);
170 if (pll->pwr_base) {
171 /* latch input value so core power can be shut down */
172 val = readl(pll->pwr_base + ctrl->aon.offset);
173 val |= 1 << ctrl->aon.iso_shift;
174 iproc_pll_write(pll, pll->pwr_base, ctrl->aon.offset, val);
176 /* power down the core */
177 val &= ~(bit_mask(ctrl->aon.pwr_width) << ctrl->aon.pwr_shift);
178 iproc_pll_write(pll, pll->pwr_base, ctrl->aon.offset, val);
182 static int __pll_enable(struct iproc_pll *pll)
184 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
185 u32 val;
187 if (ctrl->flags & IPROC_CLK_EMBED_PWRCTRL) {
188 val = readl(pll->control_base + ctrl->aon.offset);
189 val &= ~(bit_mask(ctrl->aon.pwr_width) << ctrl->aon.pwr_shift);
190 iproc_pll_write(pll, pll->control_base, ctrl->aon.offset, val);
193 if (pll->pwr_base) {
194 /* power up the PLL and make sure it's not latched */
195 val = readl(pll->pwr_base + ctrl->aon.offset);
196 val |= bit_mask(ctrl->aon.pwr_width) << ctrl->aon.pwr_shift;
197 val &= ~(1 << ctrl->aon.iso_shift);
198 iproc_pll_write(pll, pll->pwr_base, ctrl->aon.offset, val);
201 /* certain PLLs also need to be ungated from the ASIU top level */
202 if (ctrl->flags & IPROC_CLK_PLL_ASIU) {
203 val = readl(pll->asiu_base + ctrl->asiu.offset);
204 val |= (1 << ctrl->asiu.en_shift);
205 iproc_pll_write(pll, pll->asiu_base, ctrl->asiu.offset, val);
208 return 0;
211 static void __pll_put_in_reset(struct iproc_pll *pll)
213 u32 val;
214 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
215 const struct iproc_pll_reset_ctrl *reset = &ctrl->reset;
217 val = readl(pll->control_base + reset->offset);
218 val &= ~(1 << reset->reset_shift | 1 << reset->p_reset_shift);
219 iproc_pll_write(pll, pll->control_base, reset->offset, val);
222 static void __pll_bring_out_reset(struct iproc_pll *pll, unsigned int kp,
223 unsigned int ka, unsigned int ki)
225 u32 val;
226 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
227 const struct iproc_pll_reset_ctrl *reset = &ctrl->reset;
228 const struct iproc_pll_dig_filter_ctrl *dig_filter = &ctrl->dig_filter;
230 val = readl(pll->control_base + dig_filter->offset);
231 val &= ~(bit_mask(dig_filter->ki_width) << dig_filter->ki_shift |
232 bit_mask(dig_filter->kp_width) << dig_filter->kp_shift |
233 bit_mask(dig_filter->ka_width) << dig_filter->ka_shift);
234 val |= ki << dig_filter->ki_shift | kp << dig_filter->kp_shift |
235 ka << dig_filter->ka_shift;
236 iproc_pll_write(pll, pll->control_base, dig_filter->offset, val);
238 val = readl(pll->control_base + reset->offset);
239 val |= 1 << reset->reset_shift | 1 << reset->p_reset_shift;
240 iproc_pll_write(pll, pll->control_base, reset->offset, val);
243 static int pll_set_rate(struct iproc_clk *clk, unsigned int rate_index,
244 unsigned long parent_rate)
246 struct iproc_pll *pll = clk->pll;
247 const struct iproc_pll_vco_param *vco = &pll->vco_param[rate_index];
248 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
249 int ka = 0, ki, kp, ret;
250 unsigned long rate = vco->rate;
251 u32 val;
252 enum kp_band kp_index;
253 unsigned long ref_freq;
256 * reference frequency = parent frequency / PDIV
257 * If PDIV = 0, then it becomes a multiplier (x2)
259 if (vco->pdiv == 0)
260 ref_freq = parent_rate * 2;
261 else
262 ref_freq = parent_rate / vco->pdiv;
264 /* determine Ki and Kp index based on target VCO frequency */
265 if (rate >= VCO_LOW && rate < VCO_HIGH) {
266 ki = 4;
267 kp_index = KP_BAND_MID;
268 } else if (rate >= VCO_HIGH && rate && rate < VCO_HIGH_HIGH) {
269 ki = 3;
270 kp_index = KP_BAND_HIGH;
271 } else if (rate >= VCO_HIGH_HIGH && rate < VCO_MAX) {
272 ki = 3;
273 kp_index = KP_BAND_HIGH_HIGH;
274 } else {
275 pr_err("%s: pll: %s has invalid rate: %lu\n", __func__,
276 clk->name, rate);
277 return -EINVAL;
280 kp = get_kp(ref_freq, kp_index);
281 if (kp < 0) {
282 pr_err("%s: pll: %s has invalid kp\n", __func__, clk->name);
283 return kp;
286 ret = __pll_enable(pll);
287 if (ret) {
288 pr_err("%s: pll: %s fails to enable\n", __func__, clk->name);
289 return ret;
292 /* put PLL in reset */
293 __pll_put_in_reset(pll);
295 iproc_pll_write(pll, pll->control_base, ctrl->vco_ctrl.u_offset, 0);
297 val = readl(pll->control_base + ctrl->vco_ctrl.l_offset);
299 if (rate >= VCO_LOW && rate < VCO_MID)
300 val |= (1 << PLL_VCO_LOW_SHIFT);
302 if (rate < VCO_HIGH)
303 val &= ~(1 << PLL_VCO_HIGH_SHIFT);
304 else
305 val |= (1 << PLL_VCO_HIGH_SHIFT);
307 iproc_pll_write(pll, pll->control_base, ctrl->vco_ctrl.l_offset, val);
309 /* program integer part of NDIV */
310 val = readl(pll->control_base + ctrl->ndiv_int.offset);
311 val &= ~(bit_mask(ctrl->ndiv_int.width) << ctrl->ndiv_int.shift);
312 val |= vco->ndiv_int << ctrl->ndiv_int.shift;
313 iproc_pll_write(pll, pll->control_base, ctrl->ndiv_int.offset, val);
315 /* program fractional part of NDIV */
316 if (ctrl->flags & IPROC_CLK_PLL_HAS_NDIV_FRAC) {
317 val = readl(pll->control_base + ctrl->ndiv_frac.offset);
318 val &= ~(bit_mask(ctrl->ndiv_frac.width) <<
319 ctrl->ndiv_frac.shift);
320 val |= vco->ndiv_frac << ctrl->ndiv_frac.shift;
321 iproc_pll_write(pll, pll->control_base, ctrl->ndiv_frac.offset,
322 val);
325 /* program PDIV */
326 val = readl(pll->control_base + ctrl->pdiv.offset);
327 val &= ~(bit_mask(ctrl->pdiv.width) << ctrl->pdiv.shift);
328 val |= vco->pdiv << ctrl->pdiv.shift;
329 iproc_pll_write(pll, pll->control_base, ctrl->pdiv.offset, val);
331 __pll_bring_out_reset(pll, kp, ka, ki);
333 ret = pll_wait_for_lock(pll);
334 if (ret < 0) {
335 pr_err("%s: pll: %s failed to lock\n", __func__, clk->name);
336 return ret;
339 return 0;
342 static int iproc_pll_enable(struct clk_hw *hw)
344 struct iproc_clk *clk = to_iproc_clk(hw);
345 struct iproc_pll *pll = clk->pll;
347 return __pll_enable(pll);
350 static void iproc_pll_disable(struct clk_hw *hw)
352 struct iproc_clk *clk = to_iproc_clk(hw);
353 struct iproc_pll *pll = clk->pll;
354 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
356 if (ctrl->flags & IPROC_CLK_AON)
357 return;
359 __pll_disable(pll);
362 static unsigned long iproc_pll_recalc_rate(struct clk_hw *hw,
363 unsigned long parent_rate)
365 struct iproc_clk *clk = to_iproc_clk(hw);
366 struct iproc_pll *pll = clk->pll;
367 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
368 u32 val;
369 u64 ndiv, ndiv_int, ndiv_frac;
370 unsigned int pdiv;
372 if (parent_rate == 0)
373 return 0;
375 /* PLL needs to be locked */
376 val = readl(pll->status_base + ctrl->status.offset);
377 if ((val & (1 << ctrl->status.shift)) == 0) {
378 clk->rate = 0;
379 return 0;
383 * PLL output frequency =
385 * ((ndiv_int + ndiv_frac / 2^20) * (parent clock rate / pdiv)
387 val = readl(pll->control_base + ctrl->ndiv_int.offset);
388 ndiv_int = (val >> ctrl->ndiv_int.shift) &
389 bit_mask(ctrl->ndiv_int.width);
390 ndiv = ndiv_int << 20;
392 if (ctrl->flags & IPROC_CLK_PLL_HAS_NDIV_FRAC) {
393 val = readl(pll->control_base + ctrl->ndiv_frac.offset);
394 ndiv_frac = (val >> ctrl->ndiv_frac.shift) &
395 bit_mask(ctrl->ndiv_frac.width);
396 ndiv += ndiv_frac;
399 val = readl(pll->control_base + ctrl->pdiv.offset);
400 pdiv = (val >> ctrl->pdiv.shift) & bit_mask(ctrl->pdiv.width);
402 clk->rate = (ndiv * parent_rate) >> 20;
404 if (pdiv == 0)
405 clk->rate *= 2;
406 else
407 clk->rate /= pdiv;
409 return clk->rate;
412 static long iproc_pll_round_rate(struct clk_hw *hw, unsigned long rate,
413 unsigned long *parent_rate)
415 unsigned i;
416 struct iproc_clk *clk = to_iproc_clk(hw);
417 struct iproc_pll *pll = clk->pll;
419 if (rate == 0 || *parent_rate == 0 || !pll->vco_param)
420 return -EINVAL;
422 for (i = 0; i < pll->num_vco_entries; i++) {
423 if (rate <= pll->vco_param[i].rate)
424 break;
427 if (i == pll->num_vco_entries)
428 i--;
430 return pll->vco_param[i].rate;
433 static int iproc_pll_set_rate(struct clk_hw *hw, unsigned long rate,
434 unsigned long parent_rate)
436 struct iproc_clk *clk = to_iproc_clk(hw);
437 struct iproc_pll *pll = clk->pll;
438 int rate_index, ret;
440 rate_index = pll_get_rate_index(pll, rate);
441 if (rate_index < 0)
442 return rate_index;
444 ret = pll_set_rate(clk, rate_index, parent_rate);
445 return ret;
448 static const struct clk_ops iproc_pll_ops = {
449 .enable = iproc_pll_enable,
450 .disable = iproc_pll_disable,
451 .recalc_rate = iproc_pll_recalc_rate,
452 .round_rate = iproc_pll_round_rate,
453 .set_rate = iproc_pll_set_rate,
456 static int iproc_clk_enable(struct clk_hw *hw)
458 struct iproc_clk *clk = to_iproc_clk(hw);
459 const struct iproc_clk_ctrl *ctrl = clk->ctrl;
460 struct iproc_pll *pll = clk->pll;
461 u32 val;
463 /* channel enable is active low */
464 val = readl(pll->control_base + ctrl->enable.offset);
465 val &= ~(1 << ctrl->enable.enable_shift);
466 iproc_pll_write(pll, pll->control_base, ctrl->enable.offset, val);
468 /* also make sure channel is not held */
469 val = readl(pll->control_base + ctrl->enable.offset);
470 val &= ~(1 << ctrl->enable.hold_shift);
471 iproc_pll_write(pll, pll->control_base, ctrl->enable.offset, val);
473 return 0;
476 static void iproc_clk_disable(struct clk_hw *hw)
478 struct iproc_clk *clk = to_iproc_clk(hw);
479 const struct iproc_clk_ctrl *ctrl = clk->ctrl;
480 struct iproc_pll *pll = clk->pll;
481 u32 val;
483 if (ctrl->flags & IPROC_CLK_AON)
484 return;
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);
491 static unsigned long iproc_clk_recalc_rate(struct clk_hw *hw,
492 unsigned long parent_rate)
494 struct iproc_clk *clk = to_iproc_clk(hw);
495 const struct iproc_clk_ctrl *ctrl = clk->ctrl;
496 struct iproc_pll *pll = clk->pll;
497 u32 val;
498 unsigned int mdiv;
500 if (parent_rate == 0)
501 return 0;
503 val = readl(pll->control_base + ctrl->mdiv.offset);
504 mdiv = (val >> ctrl->mdiv.shift) & bit_mask(ctrl->mdiv.width);
505 if (mdiv == 0)
506 mdiv = 256;
508 clk->rate = parent_rate / mdiv;
510 return clk->rate;
513 static long iproc_clk_round_rate(struct clk_hw *hw, unsigned long rate,
514 unsigned long *parent_rate)
516 unsigned int div;
518 if (rate == 0 || *parent_rate == 0)
519 return -EINVAL;
521 if (rate == *parent_rate)
522 return *parent_rate;
524 div = DIV_ROUND_UP(*parent_rate, rate);
525 if (div < 2)
526 return *parent_rate;
528 if (div > 256)
529 div = 256;
531 return *parent_rate / div;
534 static int iproc_clk_set_rate(struct clk_hw *hw, unsigned long rate,
535 unsigned long parent_rate)
537 struct iproc_clk *clk = to_iproc_clk(hw);
538 const struct iproc_clk_ctrl *ctrl = clk->ctrl;
539 struct iproc_pll *pll = clk->pll;
540 u32 val;
541 unsigned int div;
543 if (rate == 0 || parent_rate == 0)
544 return -EINVAL;
546 div = DIV_ROUND_UP(parent_rate, rate);
547 if (div > 256)
548 return -EINVAL;
550 val = readl(pll->control_base + ctrl->mdiv.offset);
551 if (div == 256) {
552 val &= ~(bit_mask(ctrl->mdiv.width) << ctrl->mdiv.shift);
553 } else {
554 val &= ~(bit_mask(ctrl->mdiv.width) << ctrl->mdiv.shift);
555 val |= div << ctrl->mdiv.shift;
557 iproc_pll_write(pll, pll->control_base, ctrl->mdiv.offset, val);
558 clk->rate = parent_rate / div;
560 return 0;
563 static const struct clk_ops iproc_clk_ops = {
564 .enable = iproc_clk_enable,
565 .disable = iproc_clk_disable,
566 .recalc_rate = iproc_clk_recalc_rate,
567 .round_rate = iproc_clk_round_rate,
568 .set_rate = iproc_clk_set_rate,
572 * Some PLLs require the PLL SW override bit to be set before changes can be
573 * applied to the PLL
575 static void iproc_pll_sw_cfg(struct iproc_pll *pll)
577 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
579 if (ctrl->flags & IPROC_CLK_PLL_NEEDS_SW_CFG) {
580 u32 val;
582 val = readl(pll->control_base + ctrl->sw_ctrl.offset);
583 val |= BIT(ctrl->sw_ctrl.shift);
584 iproc_pll_write(pll, pll->control_base, ctrl->sw_ctrl.offset,
585 val);
589 void __init iproc_pll_clk_setup(struct device_node *node,
590 const struct iproc_pll_ctrl *pll_ctrl,
591 const struct iproc_pll_vco_param *vco,
592 unsigned int num_vco_entries,
593 const struct iproc_clk_ctrl *clk_ctrl,
594 unsigned int num_clks)
596 int i, ret;
597 struct clk *clk;
598 struct iproc_pll *pll;
599 struct iproc_clk *iclk;
600 struct clk_init_data init;
601 const char *parent_name;
603 if (WARN_ON(!pll_ctrl) || WARN_ON(!clk_ctrl))
604 return;
606 pll = kzalloc(sizeof(*pll), GFP_KERNEL);
607 if (WARN_ON(!pll))
608 return;
610 pll->clk_data.clk_num = num_clks;
611 pll->clk_data.clks = kcalloc(num_clks, sizeof(*pll->clk_data.clks),
612 GFP_KERNEL);
613 if (WARN_ON(!pll->clk_data.clks))
614 goto err_clk_data;
616 pll->clks = kcalloc(num_clks, sizeof(*pll->clks), GFP_KERNEL);
617 if (WARN_ON(!pll->clks))
618 goto err_clks;
620 pll->control_base = of_iomap(node, 0);
621 if (WARN_ON(!pll->control_base))
622 goto err_pll_iomap;
624 /* Some SoCs do not require the pwr_base, thus failing is not fatal */
625 pll->pwr_base = of_iomap(node, 1);
627 /* some PLLs require gating control at the top ASIU level */
628 if (pll_ctrl->flags & IPROC_CLK_PLL_ASIU) {
629 pll->asiu_base = of_iomap(node, 2);
630 if (WARN_ON(!pll->asiu_base))
631 goto err_asiu_iomap;
634 if (pll_ctrl->flags & IPROC_CLK_PLL_SPLIT_STAT_CTRL) {
635 /* Some SoCs have a split status/control. If this does not
636 * exist, assume they are unified.
638 pll->status_base = of_iomap(node, 2);
639 if (!pll->status_base)
640 goto err_status_iomap;
641 } else
642 pll->status_base = pll->control_base;
644 /* initialize and register the PLL itself */
645 pll->ctrl = pll_ctrl;
647 iclk = &pll->clks[0];
648 iclk->pll = pll;
649 iclk->name = node->name;
651 init.name = node->name;
652 init.ops = &iproc_pll_ops;
653 init.flags = 0;
654 parent_name = of_clk_get_parent_name(node, 0);
655 init.parent_names = (parent_name ? &parent_name : NULL);
656 init.num_parents = (parent_name ? 1 : 0);
657 iclk->hw.init = &init;
659 if (vco) {
660 pll->num_vco_entries = num_vco_entries;
661 pll->vco_param = vco;
664 iproc_pll_sw_cfg(pll);
666 clk = clk_register(NULL, &iclk->hw);
667 if (WARN_ON(IS_ERR(clk)))
668 goto err_pll_register;
670 pll->clk_data.clks[0] = clk;
672 /* now initialize and register all leaf clocks */
673 for (i = 1; i < num_clks; i++) {
674 const char *clk_name;
676 memset(&init, 0, sizeof(init));
677 parent_name = node->name;
679 ret = of_property_read_string_index(node, "clock-output-names",
680 i, &clk_name);
681 if (WARN_ON(ret))
682 goto err_clk_register;
684 iclk = &pll->clks[i];
685 iclk->name = clk_name;
686 iclk->pll = pll;
687 iclk->ctrl = &clk_ctrl[i];
689 init.name = clk_name;
690 init.ops = &iproc_clk_ops;
691 init.flags = 0;
692 init.parent_names = (parent_name ? &parent_name : NULL);
693 init.num_parents = (parent_name ? 1 : 0);
694 iclk->hw.init = &init;
696 clk = clk_register(NULL, &iclk->hw);
697 if (WARN_ON(IS_ERR(clk)))
698 goto err_clk_register;
700 pll->clk_data.clks[i] = clk;
703 ret = of_clk_add_provider(node, of_clk_src_onecell_get, &pll->clk_data);
704 if (WARN_ON(ret))
705 goto err_clk_register;
707 return;
709 err_clk_register:
710 for (i = 0; i < num_clks; i++)
711 clk_unregister(pll->clk_data.clks[i]);
713 err_pll_register:
714 if (pll->status_base != pll->control_base)
715 iounmap(pll->status_base);
717 err_status_iomap:
718 if (pll->asiu_base)
719 iounmap(pll->asiu_base);
721 err_asiu_iomap:
722 if (pll->pwr_base)
723 iounmap(pll->pwr_base);
725 iounmap(pll->control_base);
727 err_pll_iomap:
728 kfree(pll->clks);
730 err_clks:
731 kfree(pll->clk_data.clks);
733 err_clk_data:
734 kfree(pll);