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)
98 static int pll_calc_param(unsigned long target_rate,
99 unsigned long parent_rate,
100 struct iproc_pll_vco_param *vco_out)
102 u64 ndiv_int, ndiv_frac, residual;
104 ndiv_int = target_rate / parent_rate;
106 if (!ndiv_int || (ndiv_int > 255))
109 residual = target_rate - (ndiv_int * parent_rate);
113 * Add half of the divisor so the result will be rounded to closest
114 * instead of rounded down.
116 residual += (parent_rate / 2);
117 ndiv_frac = div64_u64((u64)residual, (u64)parent_rate);
119 vco_out->ndiv_int = ndiv_int;
120 vco_out->ndiv_frac = ndiv_frac;
123 vco_out->rate = vco_out->ndiv_int * parent_rate;
124 residual = (u64)vco_out->ndiv_frac * (u64)parent_rate;
126 vco_out->rate += residual;
132 * Based on the target frequency, find a match from the VCO frequency parameter
133 * table and return its index
135 static int pll_get_rate_index(struct iproc_pll *pll, unsigned int target_rate)
139 for (i = 0; i < pll->num_vco_entries; i++)
140 if (target_rate == pll->vco_param[i].rate)
143 if (i >= pll->num_vco_entries)
149 static int get_kp(unsigned long ref_freq, enum kp_band kp_index)
153 if (ref_freq < ref_freq_table[0][0])
156 for (i = 0; i < NUM_FREQ_BANDS; i++) {
157 if (ref_freq >= ref_freq_table[i][0] &&
158 ref_freq < ref_freq_table[i][1])
159 return kp_table[kp_index][i];
164 static int pll_wait_for_lock(struct iproc_pll *pll)
167 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
169 for (i = 0; i < LOCK_DELAY; i++) {
170 u32 val = readl(pll->status_base + ctrl->status.offset);
172 if (val & (1 << ctrl->status.shift))
180 static void iproc_pll_write(const struct iproc_pll *pll, void __iomem *base,
181 const u32 offset, u32 val)
183 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
185 writel(val, base + offset);
187 if (unlikely(ctrl->flags & IPROC_CLK_NEEDS_READ_BACK &&
188 (base == pll->status_base || base == pll->control_base)))
189 val = readl(base + offset);
192 static void __pll_disable(struct iproc_pll *pll)
194 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
197 if (ctrl->flags & IPROC_CLK_PLL_ASIU) {
198 val = readl(pll->asiu_base + ctrl->asiu.offset);
199 val &= ~(1 << ctrl->asiu.en_shift);
200 iproc_pll_write(pll, pll->asiu_base, ctrl->asiu.offset, val);
203 if (ctrl->flags & IPROC_CLK_EMBED_PWRCTRL) {
204 val = readl(pll->control_base + ctrl->aon.offset);
205 val |= bit_mask(ctrl->aon.pwr_width) << ctrl->aon.pwr_shift;
206 iproc_pll_write(pll, pll->control_base, ctrl->aon.offset, val);
210 /* latch input value so core power can be shut down */
211 val = readl(pll->pwr_base + ctrl->aon.offset);
212 val |= 1 << ctrl->aon.iso_shift;
213 iproc_pll_write(pll, pll->pwr_base, ctrl->aon.offset, val);
215 /* power down the core */
216 val &= ~(bit_mask(ctrl->aon.pwr_width) << ctrl->aon.pwr_shift);
217 iproc_pll_write(pll, pll->pwr_base, ctrl->aon.offset, val);
221 static int __pll_enable(struct iproc_pll *pll)
223 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
226 if (ctrl->flags & IPROC_CLK_EMBED_PWRCTRL) {
227 val = readl(pll->control_base + ctrl->aon.offset);
228 val &= ~(bit_mask(ctrl->aon.pwr_width) << ctrl->aon.pwr_shift);
229 iproc_pll_write(pll, pll->control_base, ctrl->aon.offset, val);
233 /* power up the PLL and make sure it's not latched */
234 val = readl(pll->pwr_base + ctrl->aon.offset);
235 val |= bit_mask(ctrl->aon.pwr_width) << ctrl->aon.pwr_shift;
236 val &= ~(1 << ctrl->aon.iso_shift);
237 iproc_pll_write(pll, pll->pwr_base, ctrl->aon.offset, val);
240 /* certain PLLs also need to be ungated from the ASIU top level */
241 if (ctrl->flags & IPROC_CLK_PLL_ASIU) {
242 val = readl(pll->asiu_base + ctrl->asiu.offset);
243 val |= (1 << ctrl->asiu.en_shift);
244 iproc_pll_write(pll, pll->asiu_base, ctrl->asiu.offset, val);
250 static void __pll_put_in_reset(struct iproc_pll *pll)
253 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
254 const struct iproc_pll_reset_ctrl *reset = &ctrl->reset;
256 val = readl(pll->control_base + reset->offset);
257 if (ctrl->flags & IPROC_CLK_PLL_RESET_ACTIVE_LOW)
258 val |= BIT(reset->reset_shift) | BIT(reset->p_reset_shift);
260 val &= ~(BIT(reset->reset_shift) | BIT(reset->p_reset_shift));
261 iproc_pll_write(pll, pll->control_base, reset->offset, val);
264 static void __pll_bring_out_reset(struct iproc_pll *pll, unsigned int kp,
265 unsigned int ka, unsigned int ki)
268 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
269 const struct iproc_pll_reset_ctrl *reset = &ctrl->reset;
270 const struct iproc_pll_dig_filter_ctrl *dig_filter = &ctrl->dig_filter;
272 val = readl(pll->control_base + dig_filter->offset);
273 val &= ~(bit_mask(dig_filter->ki_width) << dig_filter->ki_shift |
274 bit_mask(dig_filter->kp_width) << dig_filter->kp_shift |
275 bit_mask(dig_filter->ka_width) << dig_filter->ka_shift);
276 val |= ki << dig_filter->ki_shift | kp << dig_filter->kp_shift |
277 ka << dig_filter->ka_shift;
278 iproc_pll_write(pll, pll->control_base, dig_filter->offset, val);
280 val = readl(pll->control_base + reset->offset);
281 if (ctrl->flags & IPROC_CLK_PLL_RESET_ACTIVE_LOW)
282 val &= ~(BIT(reset->reset_shift) | BIT(reset->p_reset_shift));
284 val |= BIT(reset->reset_shift) | BIT(reset->p_reset_shift);
285 iproc_pll_write(pll, pll->control_base, reset->offset, val);
288 static int pll_set_rate(struct iproc_clk *clk, struct iproc_pll_vco_param *vco,
289 unsigned long parent_rate)
291 struct iproc_pll *pll = clk->pll;
292 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
293 int ka = 0, ki, kp, ret;
294 unsigned long rate = vco->rate;
296 enum kp_band kp_index;
297 unsigned long ref_freq;
300 * reference frequency = parent frequency / PDIV
301 * If PDIV = 0, then it becomes a multiplier (x2)
304 ref_freq = parent_rate * 2;
306 ref_freq = parent_rate / vco->pdiv;
308 /* determine Ki and Kp index based on target VCO frequency */
309 if (rate >= VCO_LOW && rate < VCO_HIGH) {
311 kp_index = KP_BAND_MID;
312 } else if (rate >= VCO_HIGH && rate < VCO_HIGH_HIGH) {
314 kp_index = KP_BAND_HIGH;
315 } else if (rate >= VCO_HIGH_HIGH && rate < VCO_MAX) {
317 kp_index = KP_BAND_HIGH_HIGH;
319 pr_err("%s: pll: %s has invalid rate: %lu\n", __func__,
324 kp = get_kp(ref_freq, kp_index);
326 pr_err("%s: pll: %s has invalid kp\n", __func__, clk->name);
330 ret = __pll_enable(pll);
332 pr_err("%s: pll: %s fails to enable\n", __func__, clk->name);
336 /* put PLL in reset */
337 __pll_put_in_reset(pll);
339 /* set PLL in user mode before modifying PLL controls */
340 if (ctrl->flags & IPROC_CLK_PLL_USER_MODE_ON) {
341 val = readl(pll->control_base + ctrl->macro_mode.offset);
342 val &= ~(bit_mask(ctrl->macro_mode.width) <<
343 ctrl->macro_mode.shift);
344 val |= PLL_USER_MODE << ctrl->macro_mode.shift;
345 iproc_pll_write(pll, pll->control_base,
346 ctrl->macro_mode.offset, val);
349 iproc_pll_write(pll, pll->control_base, ctrl->vco_ctrl.u_offset, 0);
351 val = readl(pll->control_base + ctrl->vco_ctrl.l_offset);
353 if (rate >= VCO_LOW && rate < VCO_MID)
354 val |= (1 << PLL_VCO_LOW_SHIFT);
357 val &= ~(1 << PLL_VCO_HIGH_SHIFT);
359 val |= (1 << PLL_VCO_HIGH_SHIFT);
361 iproc_pll_write(pll, pll->control_base, ctrl->vco_ctrl.l_offset, val);
363 /* program integer part of NDIV */
364 val = readl(pll->control_base + ctrl->ndiv_int.offset);
365 val &= ~(bit_mask(ctrl->ndiv_int.width) << ctrl->ndiv_int.shift);
366 val |= vco->ndiv_int << ctrl->ndiv_int.shift;
367 iproc_pll_write(pll, pll->control_base, ctrl->ndiv_int.offset, val);
369 /* program fractional part of NDIV */
370 if (ctrl->flags & IPROC_CLK_PLL_HAS_NDIV_FRAC) {
371 val = readl(pll->control_base + ctrl->ndiv_frac.offset);
372 val &= ~(bit_mask(ctrl->ndiv_frac.width) <<
373 ctrl->ndiv_frac.shift);
374 val |= vco->ndiv_frac << ctrl->ndiv_frac.shift;
375 iproc_pll_write(pll, pll->control_base, ctrl->ndiv_frac.offset,
380 val = readl(pll->control_base + ctrl->pdiv.offset);
381 val &= ~(bit_mask(ctrl->pdiv.width) << ctrl->pdiv.shift);
382 val |= vco->pdiv << ctrl->pdiv.shift;
383 iproc_pll_write(pll, pll->control_base, ctrl->pdiv.offset, val);
385 __pll_bring_out_reset(pll, kp, ka, ki);
387 ret = pll_wait_for_lock(pll);
389 pr_err("%s: pll: %s failed to lock\n", __func__, clk->name);
396 static int iproc_pll_enable(struct clk_hw *hw)
398 struct iproc_clk *clk = to_iproc_clk(hw);
399 struct iproc_pll *pll = clk->pll;
401 return __pll_enable(pll);
404 static void iproc_pll_disable(struct clk_hw *hw)
406 struct iproc_clk *clk = to_iproc_clk(hw);
407 struct iproc_pll *pll = clk->pll;
408 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
410 if (ctrl->flags & IPROC_CLK_AON)
416 static unsigned long iproc_pll_recalc_rate(struct clk_hw *hw,
417 unsigned long parent_rate)
419 struct iproc_clk *clk = to_iproc_clk(hw);
420 struct iproc_pll *pll = clk->pll;
421 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
423 u64 ndiv, ndiv_int, ndiv_frac;
426 if (parent_rate == 0)
429 /* PLL needs to be locked */
430 val = readl(pll->status_base + ctrl->status.offset);
431 if ((val & (1 << ctrl->status.shift)) == 0) {
437 * PLL output frequency =
439 * ((ndiv_int + ndiv_frac / 2^20) * (parent clock rate / pdiv)
441 val = readl(pll->control_base + ctrl->ndiv_int.offset);
442 ndiv_int = (val >> ctrl->ndiv_int.shift) &
443 bit_mask(ctrl->ndiv_int.width);
444 ndiv = ndiv_int << 20;
446 if (ctrl->flags & IPROC_CLK_PLL_HAS_NDIV_FRAC) {
447 val = readl(pll->control_base + ctrl->ndiv_frac.offset);
448 ndiv_frac = (val >> ctrl->ndiv_frac.shift) &
449 bit_mask(ctrl->ndiv_frac.width);
453 val = readl(pll->control_base + ctrl->pdiv.offset);
454 pdiv = (val >> ctrl->pdiv.shift) & bit_mask(ctrl->pdiv.width);
456 clk->rate = (ndiv * parent_rate) >> 20;
466 static int iproc_pll_determine_rate(struct clk_hw *hw,
467 struct clk_rate_request *req)
470 struct iproc_clk *clk = to_iproc_clk(hw);
471 struct iproc_pll *pll = clk->pll;
472 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
473 unsigned long diff, best_diff;
474 unsigned int best_idx = 0;
477 if (req->rate == 0 || req->best_parent_rate == 0)
480 if (ctrl->flags & IPROC_CLK_PLL_CALC_PARAM) {
481 struct iproc_pll_vco_param vco_param;
483 ret = pll_calc_param(req->rate, req->best_parent_rate,
488 req->rate = vco_param.rate;
495 best_diff = ULONG_MAX;
496 for (i = 0; i < pll->num_vco_entries; i++) {
497 diff = abs(req->rate - pll->vco_param[i].rate);
498 if (diff <= best_diff) {
502 /* break now if perfect match */
507 req->rate = pll->vco_param[best_idx].rate;
512 static int iproc_pll_set_rate(struct clk_hw *hw, unsigned long rate,
513 unsigned long parent_rate)
515 struct iproc_clk *clk = to_iproc_clk(hw);
516 struct iproc_pll *pll = clk->pll;
517 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
518 struct iproc_pll_vco_param vco_param;
521 if (ctrl->flags & IPROC_CLK_PLL_CALC_PARAM) {
522 ret = pll_calc_param(rate, parent_rate, &vco_param);
526 rate_index = pll_get_rate_index(pll, rate);
530 vco_param = pll->vco_param[rate_index];
533 ret = pll_set_rate(clk, &vco_param, parent_rate);
537 static const struct clk_ops iproc_pll_ops = {
538 .enable = iproc_pll_enable,
539 .disable = iproc_pll_disable,
540 .recalc_rate = iproc_pll_recalc_rate,
541 .determine_rate = iproc_pll_determine_rate,
542 .set_rate = iproc_pll_set_rate,
545 static int iproc_clk_enable(struct clk_hw *hw)
547 struct iproc_clk *clk = to_iproc_clk(hw);
548 const struct iproc_clk_ctrl *ctrl = clk->ctrl;
549 struct iproc_pll *pll = clk->pll;
552 /* channel enable is active low */
553 val = readl(pll->control_base + ctrl->enable.offset);
554 val &= ~(1 << ctrl->enable.enable_shift);
555 iproc_pll_write(pll, pll->control_base, ctrl->enable.offset, val);
557 /* also make sure channel is not held */
558 val = readl(pll->control_base + ctrl->enable.offset);
559 val &= ~(1 << ctrl->enable.hold_shift);
560 iproc_pll_write(pll, pll->control_base, ctrl->enable.offset, val);
565 static void iproc_clk_disable(struct clk_hw *hw)
567 struct iproc_clk *clk = to_iproc_clk(hw);
568 const struct iproc_clk_ctrl *ctrl = clk->ctrl;
569 struct iproc_pll *pll = clk->pll;
572 if (ctrl->flags & IPROC_CLK_AON)
575 val = readl(pll->control_base + ctrl->enable.offset);
576 val |= 1 << ctrl->enable.enable_shift;
577 iproc_pll_write(pll, pll->control_base, ctrl->enable.offset, val);
580 static unsigned long iproc_clk_recalc_rate(struct clk_hw *hw,
581 unsigned long parent_rate)
583 struct iproc_clk *clk = to_iproc_clk(hw);
584 const struct iproc_clk_ctrl *ctrl = clk->ctrl;
585 struct iproc_pll *pll = clk->pll;
589 if (parent_rate == 0)
592 val = readl(pll->control_base + ctrl->mdiv.offset);
593 mdiv = (val >> ctrl->mdiv.shift) & bit_mask(ctrl->mdiv.width);
597 if (ctrl->flags & IPROC_CLK_MCLK_DIV_BY_2)
598 clk->rate = parent_rate / (mdiv * 2);
600 clk->rate = parent_rate / mdiv;
605 static int iproc_clk_determine_rate(struct clk_hw *hw,
606 struct clk_rate_request *req)
608 unsigned int bestdiv;
612 if (req->rate == req->best_parent_rate)
615 bestdiv = DIV_ROUND_CLOSEST(req->best_parent_rate, req->rate);
617 req->rate = req->best_parent_rate;
622 req->rate = req->best_parent_rate / bestdiv;
627 static int iproc_clk_set_rate(struct clk_hw *hw, unsigned long rate,
628 unsigned long parent_rate)
630 struct iproc_clk *clk = to_iproc_clk(hw);
631 const struct iproc_clk_ctrl *ctrl = clk->ctrl;
632 struct iproc_pll *pll = clk->pll;
636 if (rate == 0 || parent_rate == 0)
639 div = DIV_ROUND_CLOSEST(parent_rate, rate);
640 if (ctrl->flags & IPROC_CLK_MCLK_DIV_BY_2)
646 val = readl(pll->control_base + ctrl->mdiv.offset);
648 val &= ~(bit_mask(ctrl->mdiv.width) << ctrl->mdiv.shift);
650 val &= ~(bit_mask(ctrl->mdiv.width) << ctrl->mdiv.shift);
651 val |= div << ctrl->mdiv.shift;
653 iproc_pll_write(pll, pll->control_base, ctrl->mdiv.offset, val);
654 if (ctrl->flags & IPROC_CLK_MCLK_DIV_BY_2)
655 clk->rate = parent_rate / (div * 2);
657 clk->rate = parent_rate / div;
662 static const struct clk_ops iproc_clk_ops = {
663 .enable = iproc_clk_enable,
664 .disable = iproc_clk_disable,
665 .recalc_rate = iproc_clk_recalc_rate,
666 .determine_rate = iproc_clk_determine_rate,
667 .set_rate = iproc_clk_set_rate,
671 * Some PLLs require the PLL SW override bit to be set before changes can be
674 static void iproc_pll_sw_cfg(struct iproc_pll *pll)
676 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
678 if (ctrl->flags & IPROC_CLK_PLL_NEEDS_SW_CFG) {
681 val = readl(pll->control_base + ctrl->sw_ctrl.offset);
682 val |= BIT(ctrl->sw_ctrl.shift);
683 iproc_pll_write(pll, pll->control_base, ctrl->sw_ctrl.offset,
688 void iproc_pll_clk_setup(struct device_node *node,
689 const struct iproc_pll_ctrl *pll_ctrl,
690 const struct iproc_pll_vco_param *vco,
691 unsigned int num_vco_entries,
692 const struct iproc_clk_ctrl *clk_ctrl,
693 unsigned int num_clks)
696 struct iproc_pll *pll;
697 struct iproc_clk *iclk;
698 struct clk_init_data init;
699 const char *parent_name;
701 if (WARN_ON(!pll_ctrl) || WARN_ON(!clk_ctrl))
704 pll = kzalloc(sizeof(*pll), GFP_KERNEL);
708 pll->clk_data = kzalloc(sizeof(*pll->clk_data->hws) * num_clks +
709 sizeof(*pll->clk_data), GFP_KERNEL);
710 if (WARN_ON(!pll->clk_data))
712 pll->clk_data->num = num_clks;
714 pll->clks = kcalloc(num_clks, sizeof(*pll->clks), GFP_KERNEL);
715 if (WARN_ON(!pll->clks))
718 pll->control_base = of_iomap(node, 0);
719 if (WARN_ON(!pll->control_base))
722 /* Some SoCs do not require the pwr_base, thus failing is not fatal */
723 pll->pwr_base = of_iomap(node, 1);
725 /* some PLLs require gating control at the top ASIU level */
726 if (pll_ctrl->flags & IPROC_CLK_PLL_ASIU) {
727 pll->asiu_base = of_iomap(node, 2);
728 if (WARN_ON(!pll->asiu_base))
732 if (pll_ctrl->flags & IPROC_CLK_PLL_SPLIT_STAT_CTRL) {
733 /* Some SoCs have a split status/control. If this does not
734 * exist, assume they are unified.
736 pll->status_base = of_iomap(node, 2);
737 if (!pll->status_base)
738 goto err_status_iomap;
740 pll->status_base = pll->control_base;
742 /* initialize and register the PLL itself */
743 pll->ctrl = pll_ctrl;
745 iclk = &pll->clks[0];
747 iclk->name = node->name;
749 init.name = node->name;
750 init.ops = &iproc_pll_ops;
752 parent_name = of_clk_get_parent_name(node, 0);
753 init.parent_names = (parent_name ? &parent_name : NULL);
754 init.num_parents = (parent_name ? 1 : 0);
755 iclk->hw.init = &init;
758 pll->num_vco_entries = num_vco_entries;
759 pll->vco_param = vco;
762 iproc_pll_sw_cfg(pll);
764 ret = clk_hw_register(NULL, &iclk->hw);
766 goto err_pll_register;
768 pll->clk_data->hws[0] = &iclk->hw;
770 /* now initialize and register all leaf clocks */
771 for (i = 1; i < num_clks; i++) {
772 const char *clk_name;
774 memset(&init, 0, sizeof(init));
775 parent_name = node->name;
777 ret = of_property_read_string_index(node, "clock-output-names",
780 goto err_clk_register;
782 iclk = &pll->clks[i];
783 iclk->name = clk_name;
785 iclk->ctrl = &clk_ctrl[i];
787 init.name = clk_name;
788 init.ops = &iproc_clk_ops;
790 init.parent_names = (parent_name ? &parent_name : NULL);
791 init.num_parents = (parent_name ? 1 : 0);
792 iclk->hw.init = &init;
794 ret = clk_hw_register(NULL, &iclk->hw);
796 goto err_clk_register;
798 pll->clk_data->hws[i] = &iclk->hw;
801 ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get,
804 goto err_clk_register;
810 clk_hw_unregister(pll->clk_data->hws[i]);
813 if (pll->status_base != pll->control_base)
814 iounmap(pll->status_base);
818 iounmap(pll->asiu_base);
822 iounmap(pll->pwr_base);
824 iounmap(pll->control_base);
830 kfree(pll->clk_data);