Merge tag 'trace-v5.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
[linux/fpc-iii.git] / drivers / clk / clk-xgene.c
blob3fd53057c01fe2b6f3a5422e3640403d83b2849c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * clk-xgene.c - AppliedMicro X-Gene Clock Interface
5 * Copyright (c) 2013, Applied Micro Circuits Corporation
6 * Author: Loc Ho <lho@apm.com>
7 */
8 #include <linux/module.h>
9 #include <linux/spinlock.h>
10 #include <linux/io.h>
11 #include <linux/of.h>
12 #include <linux/clkdev.h>
13 #include <linux/clk-provider.h>
14 #include <linux/of_address.h>
16 /* Register SCU_PCPPLL bit fields */
17 #define N_DIV_RD(src) ((src) & 0x000001ff)
18 #define SC_N_DIV_RD(src) ((src) & 0x0000007f)
19 #define SC_OUTDIV2(src) (((src) & 0x00000100) >> 8)
21 /* Register SCU_SOCPLL bit fields */
22 #define CLKR_RD(src) (((src) & 0x07000000)>>24)
23 #define CLKOD_RD(src) (((src) & 0x00300000)>>20)
24 #define REGSPEC_RESET_F1_MASK 0x00010000
25 #define CLKF_RD(src) (((src) & 0x000001ff))
27 #define XGENE_CLK_DRIVER_VER "0.1"
29 static DEFINE_SPINLOCK(clk_lock);
31 static inline u32 xgene_clk_read(void __iomem *csr)
33 return readl_relaxed(csr);
36 static inline void xgene_clk_write(u32 data, void __iomem *csr)
38 writel_relaxed(data, csr);
41 /* PLL Clock */
42 enum xgene_pll_type {
43 PLL_TYPE_PCP = 0,
44 PLL_TYPE_SOC = 1,
47 struct xgene_clk_pll {
48 struct clk_hw hw;
49 void __iomem *reg;
50 spinlock_t *lock;
51 u32 pll_offset;
52 enum xgene_pll_type type;
53 int version;
56 #define to_xgene_clk_pll(_hw) container_of(_hw, struct xgene_clk_pll, hw)
58 static int xgene_clk_pll_is_enabled(struct clk_hw *hw)
60 struct xgene_clk_pll *pllclk = to_xgene_clk_pll(hw);
61 u32 data;
63 data = xgene_clk_read(pllclk->reg + pllclk->pll_offset);
64 pr_debug("%s pll %s\n", clk_hw_get_name(hw),
65 data & REGSPEC_RESET_F1_MASK ? "disabled" : "enabled");
67 return data & REGSPEC_RESET_F1_MASK ? 0 : 1;
70 static unsigned long xgene_clk_pll_recalc_rate(struct clk_hw *hw,
71 unsigned long parent_rate)
73 struct xgene_clk_pll *pllclk = to_xgene_clk_pll(hw);
74 unsigned long fref;
75 unsigned long fvco;
76 u32 pll;
77 u32 nref;
78 u32 nout;
79 u32 nfb;
81 pll = xgene_clk_read(pllclk->reg + pllclk->pll_offset);
83 if (pllclk->version <= 1) {
84 if (pllclk->type == PLL_TYPE_PCP) {
86 * PLL VCO = Reference clock * NF
87 * PCP PLL = PLL_VCO / 2
89 nout = 2;
90 fvco = parent_rate * (N_DIV_RD(pll) + 4);
91 } else {
93 * Fref = Reference Clock / NREF;
94 * Fvco = Fref * NFB;
95 * Fout = Fvco / NOUT;
97 nref = CLKR_RD(pll) + 1;
98 nout = CLKOD_RD(pll) + 1;
99 nfb = CLKF_RD(pll);
100 fref = parent_rate / nref;
101 fvco = fref * nfb;
103 } else {
105 * fvco = Reference clock * FBDIVC
106 * PLL freq = fvco / NOUT
108 nout = SC_OUTDIV2(pll) ? 2 : 3;
109 fvco = parent_rate * SC_N_DIV_RD(pll);
111 pr_debug("%s pll recalc rate %ld parent %ld version %d\n",
112 clk_hw_get_name(hw), fvco / nout, parent_rate,
113 pllclk->version);
115 return fvco / nout;
118 static const struct clk_ops xgene_clk_pll_ops = {
119 .is_enabled = xgene_clk_pll_is_enabled,
120 .recalc_rate = xgene_clk_pll_recalc_rate,
123 static struct clk *xgene_register_clk_pll(struct device *dev,
124 const char *name, const char *parent_name,
125 unsigned long flags, void __iomem *reg, u32 pll_offset,
126 u32 type, spinlock_t *lock, int version)
128 struct xgene_clk_pll *apmclk;
129 struct clk *clk;
130 struct clk_init_data init;
132 /* allocate the APM clock structure */
133 apmclk = kzalloc(sizeof(*apmclk), GFP_KERNEL);
134 if (!apmclk)
135 return ERR_PTR(-ENOMEM);
137 init.name = name;
138 init.ops = &xgene_clk_pll_ops;
139 init.flags = flags;
140 init.parent_names = parent_name ? &parent_name : NULL;
141 init.num_parents = parent_name ? 1 : 0;
143 apmclk->version = version;
144 apmclk->reg = reg;
145 apmclk->lock = lock;
146 apmclk->pll_offset = pll_offset;
147 apmclk->type = type;
148 apmclk->hw.init = &init;
150 /* Register the clock */
151 clk = clk_register(dev, &apmclk->hw);
152 if (IS_ERR(clk)) {
153 pr_err("%s: could not register clk %s\n", __func__, name);
154 kfree(apmclk);
155 return NULL;
157 return clk;
160 static int xgene_pllclk_version(struct device_node *np)
162 if (of_device_is_compatible(np, "apm,xgene-socpll-clock"))
163 return 1;
164 if (of_device_is_compatible(np, "apm,xgene-pcppll-clock"))
165 return 1;
166 return 2;
169 static void xgene_pllclk_init(struct device_node *np, enum xgene_pll_type pll_type)
171 const char *clk_name = np->full_name;
172 struct clk *clk;
173 void __iomem *reg;
174 int version = xgene_pllclk_version(np);
176 reg = of_iomap(np, 0);
177 if (!reg) {
178 pr_err("Unable to map CSR register for %pOF\n", np);
179 return;
181 of_property_read_string(np, "clock-output-names", &clk_name);
182 clk = xgene_register_clk_pll(NULL,
183 clk_name, of_clk_get_parent_name(np, 0),
184 0, reg, 0, pll_type, &clk_lock,
185 version);
186 if (!IS_ERR(clk)) {
187 of_clk_add_provider(np, of_clk_src_simple_get, clk);
188 clk_register_clkdev(clk, clk_name, NULL);
189 pr_debug("Add %s clock PLL\n", clk_name);
193 static void xgene_socpllclk_init(struct device_node *np)
195 xgene_pllclk_init(np, PLL_TYPE_SOC);
198 static void xgene_pcppllclk_init(struct device_node *np)
200 xgene_pllclk_init(np, PLL_TYPE_PCP);
204 * struct xgene_clk_pmd - PMD clock
206 * @hw: handle between common and hardware-specific interfaces
207 * @reg: register containing the fractional scale multiplier (scaler)
208 * @shift: shift to the unit bit field
209 * @denom: 1/denominator unit
210 * @lock: register lock
211 * Flags:
212 * XGENE_CLK_PMD_SCALE_INVERTED - By default the scaler is the value read
213 * from the register plus one. For example,
214 * 0 for (0 + 1) / denom,
215 * 1 for (1 + 1) / denom and etc.
216 * If this flag is set, it is
217 * 0 for (denom - 0) / denom,
218 * 1 for (denom - 1) / denom and etc.
221 struct xgene_clk_pmd {
222 struct clk_hw hw;
223 void __iomem *reg;
224 u8 shift;
225 u32 mask;
226 u64 denom;
227 u32 flags;
228 spinlock_t *lock;
231 #define to_xgene_clk_pmd(_hw) container_of(_hw, struct xgene_clk_pmd, hw)
233 #define XGENE_CLK_PMD_SCALE_INVERTED BIT(0)
234 #define XGENE_CLK_PMD_SHIFT 8
235 #define XGENE_CLK_PMD_WIDTH 3
237 static unsigned long xgene_clk_pmd_recalc_rate(struct clk_hw *hw,
238 unsigned long parent_rate)
240 struct xgene_clk_pmd *fd = to_xgene_clk_pmd(hw);
241 unsigned long flags = 0;
242 u64 ret, scale;
243 u32 val;
245 if (fd->lock)
246 spin_lock_irqsave(fd->lock, flags);
247 else
248 __acquire(fd->lock);
250 val = readl(fd->reg);
252 if (fd->lock)
253 spin_unlock_irqrestore(fd->lock, flags);
254 else
255 __release(fd->lock);
257 ret = (u64)parent_rate;
259 scale = (val & fd->mask) >> fd->shift;
260 if (fd->flags & XGENE_CLK_PMD_SCALE_INVERTED)
261 scale = fd->denom - scale;
262 else
263 scale++;
265 /* freq = parent_rate * scaler / denom */
266 do_div(ret, fd->denom);
267 ret *= scale;
268 if (ret == 0)
269 ret = (u64)parent_rate;
271 return ret;
274 static long xgene_clk_pmd_round_rate(struct clk_hw *hw, unsigned long rate,
275 unsigned long *parent_rate)
277 struct xgene_clk_pmd *fd = to_xgene_clk_pmd(hw);
278 u64 ret, scale;
280 if (!rate || rate >= *parent_rate)
281 return *parent_rate;
283 /* freq = parent_rate * scaler / denom */
284 ret = rate * fd->denom;
285 scale = DIV_ROUND_UP_ULL(ret, *parent_rate);
287 ret = (u64)*parent_rate * scale;
288 do_div(ret, fd->denom);
290 return ret;
293 static int xgene_clk_pmd_set_rate(struct clk_hw *hw, unsigned long rate,
294 unsigned long parent_rate)
296 struct xgene_clk_pmd *fd = to_xgene_clk_pmd(hw);
297 unsigned long flags = 0;
298 u64 scale, ret;
299 u32 val;
302 * Compute the scaler:
304 * freq = parent_rate * scaler / denom, or
305 * scaler = freq * denom / parent_rate
307 ret = rate * fd->denom;
308 scale = DIV_ROUND_UP_ULL(ret, (u64)parent_rate);
310 /* Check if inverted */
311 if (fd->flags & XGENE_CLK_PMD_SCALE_INVERTED)
312 scale = fd->denom - scale;
313 else
314 scale--;
316 if (fd->lock)
317 spin_lock_irqsave(fd->lock, flags);
318 else
319 __acquire(fd->lock);
321 val = readl(fd->reg);
322 val &= ~fd->mask;
323 val |= (scale << fd->shift);
324 writel(val, fd->reg);
326 if (fd->lock)
327 spin_unlock_irqrestore(fd->lock, flags);
328 else
329 __release(fd->lock);
331 return 0;
334 static const struct clk_ops xgene_clk_pmd_ops = {
335 .recalc_rate = xgene_clk_pmd_recalc_rate,
336 .round_rate = xgene_clk_pmd_round_rate,
337 .set_rate = xgene_clk_pmd_set_rate,
340 static struct clk *
341 xgene_register_clk_pmd(struct device *dev,
342 const char *name, const char *parent_name,
343 unsigned long flags, void __iomem *reg, u8 shift,
344 u8 width, u64 denom, u32 clk_flags, spinlock_t *lock)
346 struct xgene_clk_pmd *fd;
347 struct clk_init_data init;
348 struct clk *clk;
350 fd = kzalloc(sizeof(*fd), GFP_KERNEL);
351 if (!fd)
352 return ERR_PTR(-ENOMEM);
354 init.name = name;
355 init.ops = &xgene_clk_pmd_ops;
356 init.flags = flags;
357 init.parent_names = parent_name ? &parent_name : NULL;
358 init.num_parents = parent_name ? 1 : 0;
360 fd->reg = reg;
361 fd->shift = shift;
362 fd->mask = (BIT(width) - 1) << shift;
363 fd->denom = denom;
364 fd->flags = clk_flags;
365 fd->lock = lock;
366 fd->hw.init = &init;
368 clk = clk_register(dev, &fd->hw);
369 if (IS_ERR(clk)) {
370 pr_err("%s: could not register clk %s\n", __func__, name);
371 kfree(fd);
372 return NULL;
375 return clk;
378 static void xgene_pmdclk_init(struct device_node *np)
380 const char *clk_name = np->full_name;
381 void __iomem *csr_reg;
382 struct resource res;
383 struct clk *clk;
384 u64 denom;
385 u32 flags = 0;
386 int rc;
388 /* Check if the entry is disabled */
389 if (!of_device_is_available(np))
390 return;
392 /* Parse the DTS register for resource */
393 rc = of_address_to_resource(np, 0, &res);
394 if (rc != 0) {
395 pr_err("no DTS register for %pOF\n", np);
396 return;
398 csr_reg = of_iomap(np, 0);
399 if (!csr_reg) {
400 pr_err("Unable to map resource for %pOF\n", np);
401 return;
403 of_property_read_string(np, "clock-output-names", &clk_name);
405 denom = BIT(XGENE_CLK_PMD_WIDTH);
406 flags |= XGENE_CLK_PMD_SCALE_INVERTED;
408 clk = xgene_register_clk_pmd(NULL, clk_name,
409 of_clk_get_parent_name(np, 0), 0,
410 csr_reg, XGENE_CLK_PMD_SHIFT,
411 XGENE_CLK_PMD_WIDTH, denom,
412 flags, &clk_lock);
413 if (!IS_ERR(clk)) {
414 of_clk_add_provider(np, of_clk_src_simple_get, clk);
415 clk_register_clkdev(clk, clk_name, NULL);
416 pr_debug("Add %s clock\n", clk_name);
417 } else {
418 if (csr_reg)
419 iounmap(csr_reg);
423 /* IP Clock */
424 struct xgene_dev_parameters {
425 void __iomem *csr_reg; /* CSR for IP clock */
426 u32 reg_clk_offset; /* Offset to clock enable CSR */
427 u32 reg_clk_mask; /* Mask bit for clock enable */
428 u32 reg_csr_offset; /* Offset to CSR reset */
429 u32 reg_csr_mask; /* Mask bit for disable CSR reset */
430 void __iomem *divider_reg; /* CSR for divider */
431 u32 reg_divider_offset; /* Offset to divider register */
432 u32 reg_divider_shift; /* Bit shift to divider field */
433 u32 reg_divider_width; /* Width of the bit to divider field */
436 struct xgene_clk {
437 struct clk_hw hw;
438 spinlock_t *lock;
439 struct xgene_dev_parameters param;
442 #define to_xgene_clk(_hw) container_of(_hw, struct xgene_clk, hw)
444 static int xgene_clk_enable(struct clk_hw *hw)
446 struct xgene_clk *pclk = to_xgene_clk(hw);
447 unsigned long flags = 0;
448 u32 data;
450 if (pclk->lock)
451 spin_lock_irqsave(pclk->lock, flags);
453 if (pclk->param.csr_reg) {
454 pr_debug("%s clock enabled\n", clk_hw_get_name(hw));
455 /* First enable the clock */
456 data = xgene_clk_read(pclk->param.csr_reg +
457 pclk->param.reg_clk_offset);
458 data |= pclk->param.reg_clk_mask;
459 xgene_clk_write(data, pclk->param.csr_reg +
460 pclk->param.reg_clk_offset);
461 pr_debug("%s clk offset 0x%08X mask 0x%08X value 0x%08X\n",
462 clk_hw_get_name(hw),
463 pclk->param.reg_clk_offset, pclk->param.reg_clk_mask,
464 data);
466 /* Second enable the CSR */
467 data = xgene_clk_read(pclk->param.csr_reg +
468 pclk->param.reg_csr_offset);
469 data &= ~pclk->param.reg_csr_mask;
470 xgene_clk_write(data, pclk->param.csr_reg +
471 pclk->param.reg_csr_offset);
472 pr_debug("%s csr offset 0x%08X mask 0x%08X value 0x%08X\n",
473 clk_hw_get_name(hw),
474 pclk->param.reg_csr_offset, pclk->param.reg_csr_mask,
475 data);
478 if (pclk->lock)
479 spin_unlock_irqrestore(pclk->lock, flags);
481 return 0;
484 static void xgene_clk_disable(struct clk_hw *hw)
486 struct xgene_clk *pclk = to_xgene_clk(hw);
487 unsigned long flags = 0;
488 u32 data;
490 if (pclk->lock)
491 spin_lock_irqsave(pclk->lock, flags);
493 if (pclk->param.csr_reg) {
494 pr_debug("%s clock disabled\n", clk_hw_get_name(hw));
495 /* First put the CSR in reset */
496 data = xgene_clk_read(pclk->param.csr_reg +
497 pclk->param.reg_csr_offset);
498 data |= pclk->param.reg_csr_mask;
499 xgene_clk_write(data, pclk->param.csr_reg +
500 pclk->param.reg_csr_offset);
502 /* Second disable the clock */
503 data = xgene_clk_read(pclk->param.csr_reg +
504 pclk->param.reg_clk_offset);
505 data &= ~pclk->param.reg_clk_mask;
506 xgene_clk_write(data, pclk->param.csr_reg +
507 pclk->param.reg_clk_offset);
510 if (pclk->lock)
511 spin_unlock_irqrestore(pclk->lock, flags);
514 static int xgene_clk_is_enabled(struct clk_hw *hw)
516 struct xgene_clk *pclk = to_xgene_clk(hw);
517 u32 data = 0;
519 if (pclk->param.csr_reg) {
520 pr_debug("%s clock checking\n", clk_hw_get_name(hw));
521 data = xgene_clk_read(pclk->param.csr_reg +
522 pclk->param.reg_clk_offset);
523 pr_debug("%s clock is %s\n", clk_hw_get_name(hw),
524 data & pclk->param.reg_clk_mask ? "enabled" :
525 "disabled");
528 if (!pclk->param.csr_reg)
529 return 1;
530 return data & pclk->param.reg_clk_mask ? 1 : 0;
533 static unsigned long xgene_clk_recalc_rate(struct clk_hw *hw,
534 unsigned long parent_rate)
536 struct xgene_clk *pclk = to_xgene_clk(hw);
537 u32 data;
539 if (pclk->param.divider_reg) {
540 data = xgene_clk_read(pclk->param.divider_reg +
541 pclk->param.reg_divider_offset);
542 data >>= pclk->param.reg_divider_shift;
543 data &= (1 << pclk->param.reg_divider_width) - 1;
545 pr_debug("%s clock recalc rate %ld parent %ld\n",
546 clk_hw_get_name(hw),
547 parent_rate / data, parent_rate);
549 return parent_rate / data;
550 } else {
551 pr_debug("%s clock recalc rate %ld parent %ld\n",
552 clk_hw_get_name(hw), parent_rate, parent_rate);
553 return parent_rate;
557 static int xgene_clk_set_rate(struct clk_hw *hw, unsigned long rate,
558 unsigned long parent_rate)
560 struct xgene_clk *pclk = to_xgene_clk(hw);
561 unsigned long flags = 0;
562 u32 data;
563 u32 divider;
564 u32 divider_save;
566 if (pclk->lock)
567 spin_lock_irqsave(pclk->lock, flags);
569 if (pclk->param.divider_reg) {
570 /* Let's compute the divider */
571 if (rate > parent_rate)
572 rate = parent_rate;
573 divider_save = divider = parent_rate / rate; /* Rounded down */
574 divider &= (1 << pclk->param.reg_divider_width) - 1;
575 divider <<= pclk->param.reg_divider_shift;
577 /* Set new divider */
578 data = xgene_clk_read(pclk->param.divider_reg +
579 pclk->param.reg_divider_offset);
580 data &= ~(((1 << pclk->param.reg_divider_width) - 1)
581 << pclk->param.reg_divider_shift);
582 data |= divider;
583 xgene_clk_write(data, pclk->param.divider_reg +
584 pclk->param.reg_divider_offset);
585 pr_debug("%s clock set rate %ld\n", clk_hw_get_name(hw),
586 parent_rate / divider_save);
587 } else {
588 divider_save = 1;
591 if (pclk->lock)
592 spin_unlock_irqrestore(pclk->lock, flags);
594 return parent_rate / divider_save;
597 static long xgene_clk_round_rate(struct clk_hw *hw, unsigned long rate,
598 unsigned long *prate)
600 struct xgene_clk *pclk = to_xgene_clk(hw);
601 unsigned long parent_rate = *prate;
602 u32 divider;
604 if (pclk->param.divider_reg) {
605 /* Let's compute the divider */
606 if (rate > parent_rate)
607 rate = parent_rate;
608 divider = parent_rate / rate; /* Rounded down */
609 } else {
610 divider = 1;
613 return parent_rate / divider;
616 static const struct clk_ops xgene_clk_ops = {
617 .enable = xgene_clk_enable,
618 .disable = xgene_clk_disable,
619 .is_enabled = xgene_clk_is_enabled,
620 .recalc_rate = xgene_clk_recalc_rate,
621 .set_rate = xgene_clk_set_rate,
622 .round_rate = xgene_clk_round_rate,
625 static struct clk *xgene_register_clk(struct device *dev,
626 const char *name, const char *parent_name,
627 struct xgene_dev_parameters *parameters, spinlock_t *lock)
629 struct xgene_clk *apmclk;
630 struct clk *clk;
631 struct clk_init_data init;
632 int rc;
634 /* allocate the APM clock structure */
635 apmclk = kzalloc(sizeof(*apmclk), GFP_KERNEL);
636 if (!apmclk)
637 return ERR_PTR(-ENOMEM);
639 init.name = name;
640 init.ops = &xgene_clk_ops;
641 init.flags = 0;
642 init.parent_names = parent_name ? &parent_name : NULL;
643 init.num_parents = parent_name ? 1 : 0;
645 apmclk->lock = lock;
646 apmclk->hw.init = &init;
647 apmclk->param = *parameters;
649 /* Register the clock */
650 clk = clk_register(dev, &apmclk->hw);
651 if (IS_ERR(clk)) {
652 pr_err("%s: could not register clk %s\n", __func__, name);
653 kfree(apmclk);
654 return clk;
657 /* Register the clock for lookup */
658 rc = clk_register_clkdev(clk, name, NULL);
659 if (rc != 0) {
660 pr_err("%s: could not register lookup clk %s\n",
661 __func__, name);
663 return clk;
666 static void __init xgene_devclk_init(struct device_node *np)
668 const char *clk_name = np->full_name;
669 struct clk *clk;
670 struct resource res;
671 int rc;
672 struct xgene_dev_parameters parameters;
673 int i;
675 /* Check if the entry is disabled */
676 if (!of_device_is_available(np))
677 return;
679 /* Parse the DTS register for resource */
680 parameters.csr_reg = NULL;
681 parameters.divider_reg = NULL;
682 for (i = 0; i < 2; i++) {
683 void __iomem *map_res;
684 rc = of_address_to_resource(np, i, &res);
685 if (rc != 0) {
686 if (i == 0) {
687 pr_err("no DTS register for %pOF\n", np);
688 return;
690 break;
692 map_res = of_iomap(np, i);
693 if (!map_res) {
694 pr_err("Unable to map resource %d for %pOF\n", i, np);
695 goto err;
697 if (strcmp(res.name, "div-reg") == 0)
698 parameters.divider_reg = map_res;
699 else /* if (strcmp(res->name, "csr-reg") == 0) */
700 parameters.csr_reg = map_res;
702 if (of_property_read_u32(np, "csr-offset", &parameters.reg_csr_offset))
703 parameters.reg_csr_offset = 0;
704 if (of_property_read_u32(np, "csr-mask", &parameters.reg_csr_mask))
705 parameters.reg_csr_mask = 0xF;
706 if (of_property_read_u32(np, "enable-offset",
707 &parameters.reg_clk_offset))
708 parameters.reg_clk_offset = 0x8;
709 if (of_property_read_u32(np, "enable-mask", &parameters.reg_clk_mask))
710 parameters.reg_clk_mask = 0xF;
711 if (of_property_read_u32(np, "divider-offset",
712 &parameters.reg_divider_offset))
713 parameters.reg_divider_offset = 0;
714 if (of_property_read_u32(np, "divider-width",
715 &parameters.reg_divider_width))
716 parameters.reg_divider_width = 0;
717 if (of_property_read_u32(np, "divider-shift",
718 &parameters.reg_divider_shift))
719 parameters.reg_divider_shift = 0;
720 of_property_read_string(np, "clock-output-names", &clk_name);
722 clk = xgene_register_clk(NULL, clk_name,
723 of_clk_get_parent_name(np, 0), &parameters, &clk_lock);
724 if (IS_ERR(clk))
725 goto err;
726 pr_debug("Add %s clock\n", clk_name);
727 rc = of_clk_add_provider(np, of_clk_src_simple_get, clk);
728 if (rc != 0)
729 pr_err("%s: could register provider clk %pOF\n", __func__, np);
731 return;
733 err:
734 if (parameters.csr_reg)
735 iounmap(parameters.csr_reg);
736 if (parameters.divider_reg)
737 iounmap(parameters.divider_reg);
740 CLK_OF_DECLARE(xgene_socpll_clock, "apm,xgene-socpll-clock", xgene_socpllclk_init);
741 CLK_OF_DECLARE(xgene_pcppll_clock, "apm,xgene-pcppll-clock", xgene_pcppllclk_init);
742 CLK_OF_DECLARE(xgene_pmd_clock, "apm,xgene-pmd-clock", xgene_pmdclk_init);
743 CLK_OF_DECLARE(xgene_socpll_v2_clock, "apm,xgene-socpll-v2-clock",
744 xgene_socpllclk_init);
745 CLK_OF_DECLARE(xgene_pcppll_v2_clock, "apm,xgene-pcppll-v2-clock",
746 xgene_pcppllclk_init);
747 CLK_OF_DECLARE(xgene_dev_clock, "apm,xgene-device-clock", xgene_devclk_init);