aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2009-05-13 04:38:11 -0400
committerPaul Mundt <lethal@linux-sh.org>2009-05-13 04:38:11 -0400
commit253b0887b3736160feac9ccdcf146a2073e41463 (patch)
treefb7e0776555cff9275760293c10c13e8c8f365fe
parent100890c55e326a9acb4429593c5ad2012c194564 (diff)
sh: clkfwk: Rework legacy CPG clock handling.
This moves out the old legacy CPG clocks to their own file, and converts over the existing users. With these clocks going away and each CPU dealing with them on their own, CPUs can gradually move over to the new interface. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r--arch/sh/Kconfig3
-rw-r--r--arch/sh/include/asm/clock.h5
-rw-r--r--arch/sh/include/asm/machvec.h2
-rw-r--r--arch/sh/kernel/cpu/Makefile1
-rw-r--r--arch/sh/kernel/cpu/clock-cpg.c60
-rw-r--r--arch/sh/kernel/cpu/clock.c70
-rw-r--r--arch/sh/kernel/cpu/sh4/clock-sh4-202.c5
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7722.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7763.c5
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7780.c5
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7785.c5
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7786.c5
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-shx3.c5
13 files changed, 110 insertions, 63 deletions
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index fb75c2d1928d..d7990cd2f8d4 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -513,6 +513,9 @@ config SH_PCLK_FREQ
513 This is necessary for determining the reference clock value on 513 This is necessary for determining the reference clock value on
514 platforms lacking an RTC. 514 platforms lacking an RTC.
515 515
516config SH_CLK_CPG_LEGACY
517 def_bool y
518
516config SH_CLK_MD 519config SH_CLK_MD
517 int "CPU Mode Pin Setting" 520 int "CPU Mode Pin Setting"
518 depends on CPU_SH2 521 depends on CPU_SH2
diff --git a/arch/sh/include/asm/clock.h b/arch/sh/include/asm/clock.h
index e2f5bf1b4a9c..c27e844db0de 100644
--- a/arch/sh/include/asm/clock.h
+++ b/arch/sh/include/asm/clock.h
@@ -47,7 +47,7 @@ struct clk_lookup {
47#define CLK_ENABLE_ON_INIT (1 << 0) 47#define CLK_ENABLE_ON_INIT (1 << 0)
48 48
49/* Should be defined by processor-specific code */ 49/* Should be defined by processor-specific code */
50void arch_init_clk_ops(struct clk_ops **, int type); 50void __deprecated arch_init_clk_ops(struct clk_ops **, int type);
51int __init arch_clk_init(void); 51int __init arch_clk_init(void);
52 52
53/* arch/sh/kernel/cpu/clock.c */ 53/* arch/sh/kernel/cpu/clock.c */
@@ -59,6 +59,9 @@ int clk_reparent(struct clk *child, struct clk *parent);
59int clk_register(struct clk *); 59int clk_register(struct clk *);
60void clk_unregister(struct clk *); 60void clk_unregister(struct clk *);
61 61
62/* arch/sh/kernel/cpu/clock-cpg.c */
63int __init __deprecated cpg_clk_init(void);
64
62/* the exported API, in addition to clk_set_rate */ 65/* the exported API, in addition to clk_set_rate */
63/** 66/**
64 * clk_set_rate_ex - set the clock rate for a clock source, with additional parameter 67 * clk_set_rate_ex - set the clock rate for a clock source, with additional parameter
diff --git a/arch/sh/include/asm/machvec.h b/arch/sh/include/asm/machvec.h
index 64b1c16a0f03..73d6d16fa06b 100644
--- a/arch/sh/include/asm/machvec.h
+++ b/arch/sh/include/asm/machvec.h
@@ -46,6 +46,8 @@ struct sh_machine_vector {
46 46
47 void __iomem *(*mv_ioport_map)(unsigned long port, unsigned int size); 47 void __iomem *(*mv_ioport_map)(unsigned long port, unsigned int size);
48 void (*mv_ioport_unmap)(void __iomem *); 48 void (*mv_ioport_unmap)(void __iomem *);
49
50 int (*mv_clk_init)(void);
49}; 51};
50 52
51extern struct sh_machine_vector sh_mv; 53extern struct sh_machine_vector sh_mv;
diff --git a/arch/sh/kernel/cpu/Makefile b/arch/sh/kernel/cpu/Makefile
index 2600641a483f..05105b980c21 100644
--- a/arch/sh/kernel/cpu/Makefile
+++ b/arch/sh/kernel/cpu/Makefile
@@ -17,5 +17,6 @@ obj-$(CONFIG_ARCH_SHMOBILE) += shmobile/
17 17
18obj-$(CONFIG_UBC_WAKEUP) += ubc.o 18obj-$(CONFIG_UBC_WAKEUP) += ubc.o
19obj-$(CONFIG_SH_ADC) += adc.o 19obj-$(CONFIG_SH_ADC) += adc.o
20obj-$(CONFIG_SH_CLK_CPG_LEGACY) += clock-cpg.o
20 21
21obj-y += irq/ init.o clock.o 22obj-y += irq/ init.o clock.o
diff --git a/arch/sh/kernel/cpu/clock-cpg.c b/arch/sh/kernel/cpu/clock-cpg.c
new file mode 100644
index 000000000000..b4ca20048446
--- /dev/null
+++ b/arch/sh/kernel/cpu/clock-cpg.c
@@ -0,0 +1,60 @@
1#include <linux/clk.h>
2#include <linux/compiler.h>
3#include <asm/clock.h>
4
5static struct clk master_clk = {
6 .name = "master_clk",
7 .flags = CLK_ENABLE_ON_INIT,
8 .rate = CONFIG_SH_PCLK_FREQ,
9};
10
11static struct clk peripheral_clk = {
12 .name = "peripheral_clk",
13 .parent = &master_clk,
14 .flags = CLK_ENABLE_ON_INIT,
15};
16
17static struct clk bus_clk = {
18 .name = "bus_clk",
19 .parent = &master_clk,
20 .flags = CLK_ENABLE_ON_INIT,
21};
22
23static struct clk cpu_clk = {
24 .name = "cpu_clk",
25 .parent = &master_clk,
26 .flags = CLK_ENABLE_ON_INIT,
27};
28
29/*
30 * The ordering of these clocks matters, do not change it.
31 */
32static struct clk *onchip_clocks[] = {
33 &master_clk,
34 &peripheral_clk,
35 &bus_clk,
36 &cpu_clk,
37};
38
39int __init __deprecated cpg_clk_init(void)
40{
41 int i, ret = 0;
42
43 for (i = 0; i < ARRAY_SIZE(onchip_clocks); i++) {
44 struct clk *clk = onchip_clocks[i];
45 arch_init_clk_ops(&clk->ops, i);
46 if (clk->ops)
47 ret |= clk_register(clk);
48 }
49
50 return ret;
51}
52
53/*
54 * Placeholder for compatability, until the lazy CPUs do this
55 * on their own.
56 */
57int __init __weak arch_clk_init(void)
58{
59 return cpg_clk_init();
60}
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index 0a7755cc8a25..033f4662b59d 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -30,54 +30,12 @@
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/proc_fs.h> 31#include <linux/proc_fs.h>
32#include <asm/clock.h> 32#include <asm/clock.h>
33#include <asm/machvec.h>
33 34
34static LIST_HEAD(clock_list); 35static LIST_HEAD(clock_list);
35static DEFINE_SPINLOCK(clock_lock); 36static DEFINE_SPINLOCK(clock_lock);
36static DEFINE_MUTEX(clock_list_sem); 37static DEFINE_MUTEX(clock_list_sem);
37 38
38/*
39 * Each subtype is expected to define the init routines for these clocks,
40 * as each subtype (or processor family) will have these clocks at the
41 * very least. These are all provided through the CPG, which even some of
42 * the more quirky parts (such as ST40, SH4-202, etc.) still have.
43 *
44 * The processor-specific code is expected to register any additional
45 * clock sources that are of interest.
46 */
47static struct clk master_clk = {
48 .name = "master_clk",
49 .flags = CLK_ENABLE_ON_INIT,
50 .rate = CONFIG_SH_PCLK_FREQ,
51};
52
53static struct clk peripheral_clk = {
54 .name = "peripheral_clk",
55 .parent = &master_clk,
56 .flags = CLK_ENABLE_ON_INIT,
57};
58
59static struct clk bus_clk = {
60 .name = "bus_clk",
61 .parent = &master_clk,
62 .flags = CLK_ENABLE_ON_INIT,
63};
64
65static struct clk cpu_clk = {
66 .name = "cpu_clk",
67 .parent = &master_clk,
68 .flags = CLK_ENABLE_ON_INIT,
69};
70
71/*
72 * The ordering of these clocks matters, do not change it.
73 */
74static struct clk *onchip_clocks[] = {
75 &master_clk,
76 &peripheral_clk,
77 &bus_clk,
78 &cpu_clk,
79};
80
81/* Used for clocks that always have same value as the parent clock */ 39/* Used for clocks that always have same value as the parent clock */
82unsigned long followparent_recalc(struct clk *clk) 40unsigned long followparent_recalc(struct clk *clk)
83{ 41{
@@ -443,10 +401,6 @@ void clk_put(struct clk *clk)
443} 401}
444EXPORT_SYMBOL_GPL(clk_put); 402EXPORT_SYMBOL_GPL(clk_put);
445 403
446int __init __weak arch_clk_init(void)
447{
448 return 0;
449}
450 404
451static int show_clocks(char *buf, char **start, off_t off, 405static int show_clocks(char *buf, char **start, off_t off,
452 int len, int *eof, void *data) 406 int len, int *eof, void *data)
@@ -533,18 +487,22 @@ subsys_initcall(clk_sysdev_init);
533 487
534int __init clk_init(void) 488int __init clk_init(void)
535{ 489{
536 int i, ret = 0; 490 int ret;
537
538 BUG_ON(!master_clk.rate);
539
540 for (i = 0; i < ARRAY_SIZE(onchip_clocks); i++) {
541 struct clk *clk = onchip_clocks[i];
542 491
543 arch_init_clk_ops(&clk->ops, i); 492 ret = arch_clk_init();
544 ret |= clk_register(clk); 493 if (unlikely(ret)) {
494 pr_err("%s: CPU clock registration failed.\n", __func__);
495 return ret;
545 } 496 }
546 497
547 ret |= arch_clk_init(); 498 if (sh_mv.mv_clk_init) {
499 ret = sh_mv.mv_clk_init();
500 if (unlikely(ret)) {
501 pr_err("%s: machvec clock initialization failed.\n",
502 __func__);
503 return ret;
504 }
505 }
548 506
549 /* Kick the child clocks.. */ 507 /* Kick the child clocks.. */
550 recalculate_root_clocks(); 508 recalculate_root_clocks();
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
index a72dc326d0b3..21421e34e7d5 100644
--- a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
+++ b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
@@ -152,9 +152,12 @@ static struct clk *sh4202_onchip_clocks[] = {
152 152
153int __init arch_clk_init(void) 153int __init arch_clk_init(void)
154{ 154{
155 struct clk *clk = clk_get(NULL, "master_clk"); 155 struct clk *clk;
156 int i, ret = 0; 156 int i, ret = 0;
157 157
158 cpg_clk_init();
159
160 clk = clk_get(NULL, "master_clk");
158 for (i = 0; i < ARRAY_SIZE(sh4202_onchip_clocks); i++) { 161 for (i = 0; i < ARRAY_SIZE(sh4202_onchip_clocks); i++) {
159 struct clk *clkp = sh4202_onchip_clocks[i]; 162 struct clk *clkp = sh4202_onchip_clocks[i];
160 163
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
index 426065b43269..a98d7da67b97 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
@@ -892,6 +892,8 @@ int __init arch_clk_init(void)
892 struct clk *clk; 892 struct clk *clk;
893 int i; 893 int i;
894 894
895 clk_cpg_init();
896
895 clk = clk_get(NULL, "master_clk"); 897 clk = clk_get(NULL, "master_clk");
896 for (i = 0; i < ARRAY_SIZE(sh7722_clocks); i++) { 898 for (i = 0; i < ARRAY_SIZE(sh7722_clocks); i++) {
897 pr_debug( "Registering clock '%s'\n", sh7722_clocks[i]->name); 899 pr_debug( "Registering clock '%s'\n", sh7722_clocks[i]->name);
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7763.c b/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
index ce3d4e6319a3..370cd47642ef 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
@@ -92,9 +92,12 @@ static struct clk *sh7763_onchip_clocks[] = {
92 92
93int __init arch_clk_init(void) 93int __init arch_clk_init(void)
94{ 94{
95 struct clk *clk = clk_get(NULL, "master_clk"); 95 struct clk *clk;
96 int i, ret = 0; 96 int i, ret = 0;
97 97
98 cpg_clk_init();
99
100 clk = clk_get(NULL, "master_clk");
98 for (i = 0; i < ARRAY_SIZE(sh7763_onchip_clocks); i++) { 101 for (i = 0; i < ARRAY_SIZE(sh7763_onchip_clocks); i++) {
99 struct clk *clkp = sh7763_onchip_clocks[i]; 102 struct clk *clkp = sh7763_onchip_clocks[i];
100 103
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7780.c b/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
index 38b8b1ddb283..a249d823578e 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
@@ -98,9 +98,12 @@ static struct clk *sh7780_onchip_clocks[] = {
98 98
99int __init arch_clk_init(void) 99int __init arch_clk_init(void)
100{ 100{
101 struct clk *clk = clk_get(NULL, "master_clk"); 101 struct clk *clk;
102 int i, ret = 0; 102 int i, ret = 0;
103 103
104 cpg_clk_init();
105
106 clk = clk_get(NULL, "master_clk");
104 for (i = 0; i < ARRAY_SIZE(sh7780_onchip_clocks); i++) { 107 for (i = 0; i < ARRAY_SIZE(sh7780_onchip_clocks); i++) {
105 struct clk *clkp = sh7780_onchip_clocks[i]; 108 struct clk *clkp = sh7780_onchip_clocks[i];
106 109
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
index fa14f35bc116..bf5a0dacf8e5 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
@@ -136,9 +136,12 @@ static struct clk *sh7785_onchip_clocks[] = {
136 136
137int __init arch_clk_init(void) 137int __init arch_clk_init(void)
138{ 138{
139 struct clk *clk = clk_get(NULL, "master_clk"); 139 struct clk *clk;
140 int i, ret = 0; 140 int i, ret = 0;
141 141
142 cpg_clk_init();
143
144 clk = clk_get(NULL, "master_clk");
142 for (i = 0; i < ARRAY_SIZE(sh7785_onchip_clocks); i++) { 145 for (i = 0; i < ARRAY_SIZE(sh7785_onchip_clocks); i++) {
143 struct clk *clkp = sh7785_onchip_clocks[i]; 146 struct clk *clkp = sh7785_onchip_clocks[i];
144 147
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7786.c b/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
index 7907002fa1df..a0e8869071ac 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
@@ -122,9 +122,12 @@ static struct clk *sh7786_onchip_clocks[] = {
122 122
123int __init arch_clk_init(void) 123int __init arch_clk_init(void)
124{ 124{
125 struct clk *clk = clk_get(NULL, "master_clk"); 125 struct clk *clk;
126 int i, ret = 0; 126 int i, ret = 0;
127 127
128 cpg_clk_init();
129
130 clk = clk_get(NULL, "master_clk");
128 for (i = 0; i < ARRAY_SIZE(sh7786_onchip_clocks); i++) { 131 for (i = 0; i < ARRAY_SIZE(sh7786_onchip_clocks); i++) {
129 struct clk *clkp = sh7786_onchip_clocks[i]; 132 struct clk *clkp = sh7786_onchip_clocks[i];
130 133
diff --git a/arch/sh/kernel/cpu/sh4a/clock-shx3.c b/arch/sh/kernel/cpu/sh4a/clock-shx3.c
index c14553e3e13f..23c27d32d982 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-shx3.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-shx3.c
@@ -109,9 +109,12 @@ static struct clk *shx3_onchip_clocks[] = {
109 109
110int __init arch_clk_init(void) 110int __init arch_clk_init(void)
111{ 111{
112 struct clk *clk = clk_get(NULL, "master_clk"); 112 struct clk *clk;
113 int i, ret = 0; 113 int i, ret = 0;
114 114
115 cpg_clk_init();
116
117 clk = clk_get(NULL, "master_clk");
115 for (i = 0; i < ARRAY_SIZE(shx3_onchip_clocks); i++) { 118 for (i = 0; i < ARRAY_SIZE(shx3_onchip_clocks); i++) {
116 struct clk *clkp = shx3_onchip_clocks[i]; 119 struct clk *clkp = shx3_onchip_clocks[i];
117 120