summaryrefslogtreecommitdiffstats
path: root/drivers/clk/bcm
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2014-04-21 17:11:40 -0400
committerMike Turquette <mturquette@linaro.org>2014-04-30 14:51:33 -0400
commitb12151ca5cd76e5ed9c75ef02b2f5d2aa5b45808 (patch)
tree9d652df3ddbffed17b6a7f9145534de7f727b56e /drivers/clk/bcm
parent9d3d87c750f30af0e8e268c122ffec4489bc9638 (diff)
clk: bcm281xx: initialize CCU structures statically
We know up front how many CCU's we'll support, so there's no need to allocate their data structures dynamically. Define a macro KONA_CCU_COMMON() to simplify the initialization of many of the fields in a ccu_data structure. Pass the address of a statically defined CCU structure to kona_dt_ccu_setup() rather than having that function allocate one. We also know at build time how many clocks a given CCU will provide, though the number of of them for each CCU is different. Record the number of clocks we need in the CCU's clk_onecell_data struct (which is used when we register the CCU with the common clock code as a clock provider). Rename that struct field "clk_data" (because "data" alone gets a little confusing). Use the known clock count to move the allocation of each CCU's clocks array into ccu_clks_setup() rather than having each CCU's setup callback function do it. (The real motivation behind all of this is that we'll be doing some static initialization of some additional CCU-specific data soon.) Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk/bcm')
-rw-r--r--drivers/clk/bcm/clk-bcm281xx.c144
-rw-r--r--drivers/clk/bcm/clk-kona-setup.c47
-rw-r--r--drivers/clk/bcm/clk-kona.c4
-rw-r--r--drivers/clk/bcm/clk-kona.h21
4 files changed, 97 insertions, 119 deletions
diff --git a/drivers/clk/bcm/clk-bcm281xx.c b/drivers/clk/bcm/clk-bcm281xx.c
index bb947afadb88..d72f2ae01493 100644
--- a/drivers/clk/bcm/clk-bcm281xx.c
+++ b/drivers/clk/bcm/clk-bcm281xx.c
@@ -15,6 +15,9 @@
15#include "clk-kona.h" 15#include "clk-kona.h"
16#include "dt-bindings/clock/bcm281xx.h" 16#include "dt-bindings/clock/bcm281xx.h"
17 17
18#define BCM281XX_CCU_COMMON(_name, _ucase_name) \
19 KONA_CCU_COMMON(BCM281XX, _name, _ucase_name)
20
18/* 21/*
19 * These are the bcm281xx CCU device tree "compatible" strings. 22 * These are the bcm281xx CCU device tree "compatible" strings.
20 * We're stuck with using "bcm11351" in the string because wild 23 * We're stuck with using "bcm11351" in the string because wild
@@ -27,7 +30,7 @@
27#define BCM281XX_DT_MASTER_CCU_COMPAT "brcm,bcm11351-master-ccu" 30#define BCM281XX_DT_MASTER_CCU_COMPAT "brcm,bcm11351-master-ccu"
28#define BCM281XX_DT_SLAVE_CCU_COMPAT "brcm,bcm11351-slave-ccu" 31#define BCM281XX_DT_SLAVE_CCU_COMPAT "brcm,bcm11351-slave-ccu"
29 32
30/* Root CCU clocks */ 33/* Root CCU */
31 34
32static struct peri_clk_data frac_1m_data = { 35static struct peri_clk_data frac_1m_data = {
33 .gate = HW_SW_GATE(0x214, 16, 0, 1), 36 .gate = HW_SW_GATE(0x214, 16, 0, 1),
@@ -36,7 +39,11 @@ static struct peri_clk_data frac_1m_data = {
36 .clocks = CLOCKS("ref_crystal"), 39 .clocks = CLOCKS("ref_crystal"),
37}; 40};
38 41
39/* AON CCU clocks */ 42static struct ccu_data root_ccu_data = {
43 BCM281XX_CCU_COMMON(root, ROOT),
44};
45
46/* AON CCU */
40 47
41static struct peri_clk_data hub_timer_data = { 48static struct peri_clk_data hub_timer_data = {
42 .gate = HW_SW_GATE(0x0414, 16, 0, 1), 49 .gate = HW_SW_GATE(0x0414, 16, 0, 1),
@@ -65,7 +72,11 @@ static struct peri_clk_data pmu_bsc_var_data = {
65 .trig = TRIGGER(0x0a40, 2), 72 .trig = TRIGGER(0x0a40, 2),
66}; 73};
67 74
68/* Hub CCU clocks */ 75static struct ccu_data aon_ccu_data = {
76 BCM281XX_CCU_COMMON(aon, AON),
77};
78
79/* Hub CCU */
69 80
70static struct peri_clk_data tmon_1m_data = { 81static struct peri_clk_data tmon_1m_data = {
71 .gate = HW_SW_GATE(0x04a4, 18, 2, 3), 82 .gate = HW_SW_GATE(0x04a4, 18, 2, 3),
@@ -75,7 +86,11 @@ static struct peri_clk_data tmon_1m_data = {
75 .trig = TRIGGER(0x0e84, 1), 86 .trig = TRIGGER(0x0e84, 1),
76}; 87};
77 88
78/* Master CCU clocks */ 89static struct ccu_data hub_ccu_data = {
90 BCM281XX_CCU_COMMON(hub, HUB),
91};
92
93/* Master CCU */
79 94
80static struct peri_clk_data sdio1_data = { 95static struct peri_clk_data sdio1_data = {
81 .gate = HW_SW_GATE(0x0358, 18, 2, 3), 96 .gate = HW_SW_GATE(0x0358, 18, 2, 3),
@@ -158,7 +173,11 @@ static struct peri_clk_data hsic2_12m_data = {
158 .trig = TRIGGER(0x0afc, 5), 173 .trig = TRIGGER(0x0afc, 5),
159}; 174};
160 175
161/* Slave CCU clocks */ 176static struct ccu_data master_ccu_data = {
177 BCM281XX_CCU_COMMON(master, MASTER),
178};
179
180/* Slave CCU */
162 181
163static struct peri_clk_data uartb_data = { 182static struct peri_clk_data uartb_data = {
164 .gate = HW_SW_GATE(0x0400, 18, 2, 3), 183 .gate = HW_SW_GATE(0x0400, 18, 2, 3),
@@ -266,6 +285,10 @@ static struct peri_clk_data pwm_data = {
266 .trig = TRIGGER(0x0afc, 15), 285 .trig = TRIGGER(0x0afc, 15),
267}; 286};
268 287
288static struct ccu_data slave_ccu_data = {
289 BCM281XX_CCU_COMMON(slave, SLAVE),
290};
291
269/* 292/*
270 * CCU setup routines 293 * CCU setup routines
271 * 294 *
@@ -277,107 +300,52 @@ static struct peri_clk_data pwm_data = {
277 */ 300 */
278static int __init bcm281xx_root_ccu_clks_setup(struct ccu_data *ccu) 301static int __init bcm281xx_root_ccu_clks_setup(struct ccu_data *ccu)
279{ 302{
280 struct clk **clks; 303 PERI_CLK_SETUP(ccu, BCM281XX_ROOT_CCU_FRAC_1M, frac_1m);
281 size_t count = BCM281XX_ROOT_CCU_CLOCK_COUNT;
282
283 clks = kzalloc(count * sizeof(*clks), GFP_KERNEL);
284 if (!clks) {
285 pr_err("%s: failed to allocate root clocks\n", __func__);
286 return -ENOMEM;
287 }
288 ccu->data.clks = clks;
289 ccu->data.clk_num = count;
290
291 PERI_CLK_SETUP(clks, ccu, BCM281XX_ROOT_CCU_FRAC_1M, frac_1m);
292 304
293 return 0; 305 return 0;
294} 306}
295 307
296static int __init bcm281xx_aon_ccu_clks_setup(struct ccu_data *ccu) 308static int __init bcm281xx_aon_ccu_clks_setup(struct ccu_data *ccu)
297{ 309{
298 struct clk **clks; 310 PERI_CLK_SETUP(ccu, BCM281XX_AON_CCU_HUB_TIMER, hub_timer);
299 size_t count = BCM281XX_AON_CCU_CLOCK_COUNT; 311 PERI_CLK_SETUP(ccu, BCM281XX_AON_CCU_PMU_BSC, pmu_bsc);
300 312 PERI_CLK_SETUP(ccu, BCM281XX_AON_CCU_PMU_BSC_VAR, pmu_bsc_var);
301 clks = kzalloc(count * sizeof(*clks), GFP_KERNEL);
302 if (!clks) {
303 pr_err("%s: failed to allocate aon clocks\n", __func__);
304 return -ENOMEM;
305 }
306 ccu->data.clks = clks;
307 ccu->data.clk_num = count;
308
309 PERI_CLK_SETUP(clks, ccu, BCM281XX_AON_CCU_HUB_TIMER, hub_timer);
310 PERI_CLK_SETUP(clks, ccu, BCM281XX_AON_CCU_PMU_BSC, pmu_bsc);
311 PERI_CLK_SETUP(clks, ccu, BCM281XX_AON_CCU_PMU_BSC_VAR, pmu_bsc_var);
312 313
313 return 0; 314 return 0;
314} 315}
315 316
316static int __init bcm281xx_hub_ccu_clks_setup(struct ccu_data *ccu) 317static int __init bcm281xx_hub_ccu_clks_setup(struct ccu_data *ccu)
317{ 318{
318 struct clk **clks; 319 PERI_CLK_SETUP(ccu, BCM281XX_HUB_CCU_TMON_1M, tmon_1m);
319 size_t count = BCM281XX_HUB_CCU_CLOCK_COUNT;
320
321 clks = kzalloc(count * sizeof(*clks), GFP_KERNEL);
322 if (!clks) {
323 pr_err("%s: failed to allocate hub clocks\n", __func__);
324 return -ENOMEM;
325 }
326 ccu->data.clks = clks;
327 ccu->data.clk_num = count;
328
329 PERI_CLK_SETUP(clks, ccu, BCM281XX_HUB_CCU_TMON_1M, tmon_1m);
330 320
331 return 0; 321 return 0;
332} 322}
333 323
334static int __init bcm281xx_master_ccu_clks_setup(struct ccu_data *ccu) 324static int __init bcm281xx_master_ccu_clks_setup(struct ccu_data *ccu)
335{ 325{
336 struct clk **clks; 326 PERI_CLK_SETUP(ccu, BCM281XX_MASTER_CCU_SDIO1, sdio1);
337 size_t count = BCM281XX_MASTER_CCU_CLOCK_COUNT; 327 PERI_CLK_SETUP(ccu, BCM281XX_MASTER_CCU_SDIO2, sdio2);
338 328 PERI_CLK_SETUP(ccu, BCM281XX_MASTER_CCU_SDIO3, sdio3);
339 clks = kzalloc(count * sizeof(*clks), GFP_KERNEL); 329 PERI_CLK_SETUP(ccu, BCM281XX_MASTER_CCU_SDIO4, sdio4);
340 if (!clks) { 330 PERI_CLK_SETUP(ccu, BCM281XX_MASTER_CCU_USB_IC, usb_ic);
341 pr_err("%s: failed to allocate master clocks\n", __func__); 331 PERI_CLK_SETUP(ccu, BCM281XX_MASTER_CCU_HSIC2_48M, hsic2_48m);
342 return -ENOMEM; 332 PERI_CLK_SETUP(ccu, BCM281XX_MASTER_CCU_HSIC2_12M, hsic2_12m);
343 }
344 ccu->data.clks = clks;
345 ccu->data.clk_num = count;
346
347 PERI_CLK_SETUP(clks, ccu, BCM281XX_MASTER_CCU_SDIO1, sdio1);
348 PERI_CLK_SETUP(clks, ccu, BCM281XX_MASTER_CCU_SDIO2, sdio2);
349 PERI_CLK_SETUP(clks, ccu, BCM281XX_MASTER_CCU_SDIO3, sdio3);
350 PERI_CLK_SETUP(clks, ccu, BCM281XX_MASTER_CCU_SDIO4, sdio4);
351 PERI_CLK_SETUP(clks, ccu, BCM281XX_MASTER_CCU_USB_IC, usb_ic);
352 PERI_CLK_SETUP(clks, ccu, BCM281XX_MASTER_CCU_HSIC2_48M, hsic2_48m);
353 PERI_CLK_SETUP(clks, ccu, BCM281XX_MASTER_CCU_HSIC2_12M, hsic2_12m);
354 333
355 return 0; 334 return 0;
356} 335}
357 336
358static int __init bcm281xx_slave_ccu_clks_setup(struct ccu_data *ccu) 337static int __init bcm281xx_slave_ccu_clks_setup(struct ccu_data *ccu)
359{ 338{
360 struct clk **clks; 339 PERI_CLK_SETUP(ccu, BCM281XX_SLAVE_CCU_UARTB, uartb);
361 size_t count = BCM281XX_SLAVE_CCU_CLOCK_COUNT; 340 PERI_CLK_SETUP(ccu, BCM281XX_SLAVE_CCU_UARTB2, uartb2);
362 341 PERI_CLK_SETUP(ccu, BCM281XX_SLAVE_CCU_UARTB3, uartb3);
363 clks = kzalloc(count * sizeof(*clks), GFP_KERNEL); 342 PERI_CLK_SETUP(ccu, BCM281XX_SLAVE_CCU_UARTB4, uartb4);
364 if (!clks) { 343 PERI_CLK_SETUP(ccu, BCM281XX_SLAVE_CCU_SSP0, ssp0);
365 pr_err("%s: failed to allocate slave clocks\n", __func__); 344 PERI_CLK_SETUP(ccu, BCM281XX_SLAVE_CCU_SSP2, ssp2);
366 return -ENOMEM; 345 PERI_CLK_SETUP(ccu, BCM281XX_SLAVE_CCU_BSC1, bsc1);
367 } 346 PERI_CLK_SETUP(ccu, BCM281XX_SLAVE_CCU_BSC2, bsc2);
368 ccu->data.clks = clks; 347 PERI_CLK_SETUP(ccu, BCM281XX_SLAVE_CCU_BSC3, bsc3);
369 ccu->data.clk_num = count; 348 PERI_CLK_SETUP(ccu, BCM281XX_SLAVE_CCU_PWM, pwm);
370
371 PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_UARTB, uartb);
372 PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_UARTB2, uartb2);
373 PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_UARTB3, uartb3);
374 PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_UARTB4, uartb4);
375 PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_SSP0, ssp0);
376 PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_SSP2, ssp2);
377 PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_BSC1, bsc1);
378 PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_BSC2, bsc2);
379 PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_BSC3, bsc3);
380 PERI_CLK_SETUP(clks, ccu, BCM281XX_SLAVE_CCU_PWM, pwm);
381 349
382 return 0; 350 return 0;
383} 351}
@@ -386,27 +354,29 @@ static int __init bcm281xx_slave_ccu_clks_setup(struct ccu_data *ccu)
386 354
387static void __init kona_dt_root_ccu_setup(struct device_node *node) 355static void __init kona_dt_root_ccu_setup(struct device_node *node)
388{ 356{
389 kona_dt_ccu_setup(node, bcm281xx_root_ccu_clks_setup); 357 kona_dt_ccu_setup(&root_ccu_data, node, bcm281xx_root_ccu_clks_setup);
390} 358}
391 359
392static void __init kona_dt_aon_ccu_setup(struct device_node *node) 360static void __init kona_dt_aon_ccu_setup(struct device_node *node)
393{ 361{
394 kona_dt_ccu_setup(node, bcm281xx_aon_ccu_clks_setup); 362 kona_dt_ccu_setup(&aon_ccu_data, node, bcm281xx_aon_ccu_clks_setup);
395} 363}
396 364
397static void __init kona_dt_hub_ccu_setup(struct device_node *node) 365static void __init kona_dt_hub_ccu_setup(struct device_node *node)
398{ 366{
399 kona_dt_ccu_setup(node, bcm281xx_hub_ccu_clks_setup); 367 kona_dt_ccu_setup(&hub_ccu_data, node, bcm281xx_hub_ccu_clks_setup);
400} 368}
401 369
402static void __init kona_dt_master_ccu_setup(struct device_node *node) 370static void __init kona_dt_master_ccu_setup(struct device_node *node)
403{ 371{
404 kona_dt_ccu_setup(node, bcm281xx_master_ccu_clks_setup); 372 kona_dt_ccu_setup(&master_ccu_data, node,
373 bcm281xx_master_ccu_clks_setup);
405} 374}
406 375
407static void __init kona_dt_slave_ccu_setup(struct device_node *node) 376static void __init kona_dt_slave_ccu_setup(struct device_node *node)
408{ 377{
409 kona_dt_ccu_setup(node, bcm281xx_slave_ccu_clks_setup); 378 kona_dt_ccu_setup(&slave_ccu_data, node,
379 bcm281xx_slave_ccu_clks_setup);
410} 380}
411 381
412CLK_OF_DECLARE(bcm281xx_root_ccu, BCM281XX_DT_ROOT_CCU_COMPAT, 382CLK_OF_DECLARE(bcm281xx_root_ccu, BCM281XX_DT_ROOT_CCU_COMPAT,
diff --git a/drivers/clk/bcm/clk-kona-setup.c b/drivers/clk/bcm/clk-kona-setup.c
index 9e7a9c11c951..4d1ca5372eff 100644
--- a/drivers/clk/bcm/clk-kona-setup.c
+++ b/drivers/clk/bcm/clk-kona-setup.c
@@ -675,50 +675,49 @@ static void ccu_clks_teardown(struct ccu_data *ccu)
675{ 675{
676 u32 i; 676 u32 i;
677 677
678 for (i = 0; i < ccu->data.clk_num; i++) 678 for (i = 0; i < ccu->clk_data.clk_num; i++)
679 kona_clk_teardown(ccu->data.clks[i]); 679 kona_clk_teardown(ccu->clk_data.clks[i]);
680 kfree(ccu->data.clks); 680 kfree(ccu->clk_data.clks);
681} 681}
682 682
683static void kona_ccu_teardown(struct ccu_data *ccu) 683static void kona_ccu_teardown(struct ccu_data *ccu)
684{ 684{
685 if (!ccu) 685 kfree(ccu->clk_data.clks);
686 return; 686 ccu->clk_data.clks = NULL;
687
688 if (!ccu->base) 687 if (!ccu->base)
689 goto done; 688 return;
690 689
691 of_clk_del_provider(ccu->node); /* safe if never added */ 690 of_clk_del_provider(ccu->node); /* safe if never added */
692 ccu_clks_teardown(ccu); 691 ccu_clks_teardown(ccu);
693 list_del(&ccu->links); 692 list_del(&ccu->links);
694 of_node_put(ccu->node); 693 of_node_put(ccu->node);
694 ccu->node = NULL;
695 iounmap(ccu->base); 695 iounmap(ccu->base);
696done: 696 ccu->base = NULL;
697 kfree(ccu->name);
698 kfree(ccu);
699} 697}
700 698
701/* 699/*
702 * Set up a CCU. Call the provided ccu_clks_setup callback to 700 * Set up a CCU. Call the provided ccu_clks_setup callback to
703 * initialize the array of clocks provided by the CCU. 701 * initialize the array of clocks provided by the CCU.
704 */ 702 */
705void __init kona_dt_ccu_setup(struct device_node *node, 703void __init kona_dt_ccu_setup(struct ccu_data *ccu,
704 struct device_node *node,
706 int (*ccu_clks_setup)(struct ccu_data *)) 705 int (*ccu_clks_setup)(struct ccu_data *))
707{ 706{
708 struct ccu_data *ccu;
709 struct resource res = { 0 }; 707 struct resource res = { 0 };
710 resource_size_t range; 708 resource_size_t range;
711 int ret; 709 int ret;
712 710
713 ccu = kzalloc(sizeof(*ccu), GFP_KERNEL); 711 if (ccu->clk_data.clk_num) {
714 if (ccu) 712 size_t size;
715 ccu->name = kstrdup(node->name, GFP_KERNEL);
716 if (!ccu || !ccu->name) {
717 pr_err("%s: unable to allocate CCU struct for %s\n",
718 __func__, node->name);
719 kfree(ccu);
720 713
721 return; 714 size = ccu->clk_data.clk_num * sizeof(*ccu->clk_data.clks);
715 ccu->clk_data.clks = kzalloc(size, GFP_KERNEL);
716 if (!ccu->clk_data.clks) {
717 pr_err("%s: unable to allocate %u clocks for %s\n",
718 __func__, ccu->clk_data.clk_num, node->name);
719 return;
720 }
722 } 721 }
723 722
724 ret = of_address_to_resource(node, 0, &res); 723 ret = of_address_to_resource(node, 0, &res);
@@ -742,18 +741,14 @@ void __init kona_dt_ccu_setup(struct device_node *node,
742 node->name); 741 node->name);
743 goto out_err; 742 goto out_err;
744 } 743 }
745
746 spin_lock_init(&ccu->lock);
747 INIT_LIST_HEAD(&ccu->links);
748 ccu->node = of_node_get(node); 744 ccu->node = of_node_get(node);
749
750 list_add_tail(&ccu->links, &ccu_list); 745 list_add_tail(&ccu->links, &ccu_list);
751 746
752 /* Set up clocks array (in ccu->data) */ 747 /* Set up clocks array (in ccu->clk_data) */
753 if (ccu_clks_setup(ccu)) 748 if (ccu_clks_setup(ccu))
754 goto out_err; 749 goto out_err;
755 750
756 ret = of_clk_add_provider(node, of_clk_src_onecell_get, &ccu->data); 751 ret = of_clk_add_provider(node, of_clk_src_onecell_get, &ccu->clk_data);
757 if (ret) { 752 if (ret) {
758 pr_err("%s: error adding ccu %s as provider (%d)\n", __func__, 753 pr_err("%s: error adding ccu %s as provider (%d)\n", __func__,
759 node->name, ret); 754 node->name, ret);
diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c
index bf0b70e87014..f8bc6bc0784f 100644
--- a/drivers/clk/bcm/clk-kona.c
+++ b/drivers/clk/bcm/clk-kona.c
@@ -1020,13 +1020,13 @@ bool __init kona_ccu_init(struct ccu_data *ccu)
1020{ 1020{
1021 unsigned long flags; 1021 unsigned long flags;
1022 unsigned int which; 1022 unsigned int which;
1023 struct clk **clks = ccu->data.clks; 1023 struct clk **clks = ccu->clk_data.clks;
1024 bool success = true; 1024 bool success = true;
1025 1025
1026 flags = ccu_lock(ccu); 1026 flags = ccu_lock(ccu);
1027 __ccu_write_enable(ccu); 1027 __ccu_write_enable(ccu);
1028 1028
1029 for (which = 0; which < ccu->data.clk_num; which++) { 1029 for (which = 0; which < ccu->clk_data.clk_num; which++) {
1030 struct kona_clk *bcm_clk; 1030 struct kona_clk *bcm_clk;
1031 1031
1032 if (!clks[which]) 1032 if (!clks[which])
diff --git a/drivers/clk/bcm/clk-kona.h b/drivers/clk/bcm/clk-kona.h
index 1a7eba4ac33a..108c2647ca28 100644
--- a/drivers/clk/bcm/clk-kona.h
+++ b/drivers/clk/bcm/clk-kona.h
@@ -85,11 +85,20 @@ struct ccu_data {
85 bool write_enabled; /* write access is currently enabled */ 85 bool write_enabled; /* write access is currently enabled */
86 struct list_head links; /* for ccu_list */ 86 struct list_head links; /* for ccu_list */
87 struct device_node *node; 87 struct device_node *node;
88 struct clk_onecell_data data; 88 struct clk_onecell_data clk_data;
89 const char *name; 89 const char *name;
90 u32 range; /* byte range of address space */ 90 u32 range; /* byte range of address space */
91}; 91};
92 92
93/* Initialization for common fields in a Kona ccu_data structure */
94#define KONA_CCU_COMMON(_prefix, _name, _ucase_name) \
95 .name = #_name "_ccu", \
96 .lock = __SPIN_LOCK_UNLOCKED(_name ## _ccu_data.lock), \
97 .links = LIST_HEAD_INIT(_name ## _ccu_data.links), \
98 .clk_data = { \
99 .clk_num = _prefix ## _ ## _ucase_name ## _CCU_CLOCK_COUNT, \
100 }
101
93/* 102/*
94 * Gating control and status is managed by a 32-bit gate register. 103 * Gating control and status is managed by a 32-bit gate register.
95 * 104 *
@@ -390,8 +399,11 @@ extern struct clk_ops kona_peri_clk_ops;
390 399
391/* Help functions */ 400/* Help functions */
392 401
393#define PERI_CLK_SETUP(clks, ccu, id, name) \ 402#define KONA_CLK_SETUP(_ccu, _type, _name) \
394 clks[id] = kona_clk_setup(ccu, #name, bcm_clk_peri, &name ## _data) 403 kona_clk_setup((_ccu), #_name, bcm_clk_## _type, &_name ## _data)
404
405#define PERI_CLK_SETUP(_ccu, _id, _name) \
406 (_ccu)->clk_data.clks[_id] = KONA_CLK_SETUP((_ccu), peri, _name)
395 407
396/* Externally visible functions */ 408/* Externally visible functions */
397 409
@@ -402,7 +414,8 @@ extern u64 scaled_div_build(struct bcm_clk_div *div, u32 div_value,
402 414
403extern struct clk *kona_clk_setup(struct ccu_data *ccu, const char *name, 415extern struct clk *kona_clk_setup(struct ccu_data *ccu, const char *name,
404 enum bcm_clk_type type, void *data); 416 enum bcm_clk_type type, void *data);
405extern void __init kona_dt_ccu_setup(struct device_node *node, 417extern void __init kona_dt_ccu_setup(struct ccu_data *ccu,
418 struct device_node *node,
406 int (*ccu_clks_setup)(struct ccu_data *)); 419 int (*ccu_clks_setup)(struct ccu_data *));
407extern bool __init kona_ccu_init(struct ccu_data *ccu); 420extern bool __init kona_ccu_init(struct ccu_data *ccu);
408 421