]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
sh: clkfwk: Rework legacy CPG clock handling.
authorPaul Mundt <lethal@linux-sh.org>
Wed, 13 May 2009 08:38:11 +0000 (17:38 +0900)
committerPaul Mundt <lethal@linux-sh.org>
Wed, 13 May 2009 08:38:11 +0000 (17:38 +0900)
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>
13 files changed:
arch/sh/Kconfig
arch/sh/include/asm/clock.h
arch/sh/include/asm/machvec.h
arch/sh/kernel/cpu/Makefile
arch/sh/kernel/cpu/clock-cpg.c [new file with mode: 0644]
arch/sh/kernel/cpu/clock.c
arch/sh/kernel/cpu/sh4/clock-sh4-202.c
arch/sh/kernel/cpu/sh4a/clock-sh7722.c
arch/sh/kernel/cpu/sh4a/clock-sh7763.c
arch/sh/kernel/cpu/sh4a/clock-sh7780.c
arch/sh/kernel/cpu/sh4a/clock-sh7785.c
arch/sh/kernel/cpu/sh4a/clock-sh7786.c
arch/sh/kernel/cpu/sh4a/clock-shx3.c

index fb75c2d1928df539b7c779485c20a58b50b3c5d7..d7990cd2f8d4db6484b6700dce80a1bae65b5a5f 100644 (file)
@@ -513,6 +513,9 @@ config SH_PCLK_FREQ
          This is necessary for determining the reference clock value on
          platforms lacking an RTC.
 
+config SH_CLK_CPG_LEGACY
+       def_bool y
+
 config SH_CLK_MD
        int "CPU Mode Pin Setting"
        depends on CPU_SH2
index e2f5bf1b4a9c6c5805d316f6824545be3b0ac9c5..c27e844db0de378b01996ad2b1000fea8db72403 100644 (file)
@@ -47,7 +47,7 @@ struct clk_lookup {
 #define CLK_ENABLE_ON_INIT     (1 << 0)
 
 /* Should be defined by processor-specific code */
-void arch_init_clk_ops(struct clk_ops **, int type);
+void __deprecated arch_init_clk_ops(struct clk_ops **, int type);
 int __init arch_clk_init(void);
 
 /* arch/sh/kernel/cpu/clock.c */
@@ -59,6 +59,9 @@ int clk_reparent(struct clk *child, struct clk *parent);
 int clk_register(struct clk *);
 void clk_unregister(struct clk *);
 
+/* arch/sh/kernel/cpu/clock-cpg.c */
+int __init __deprecated cpg_clk_init(void);
+
 /* the exported API, in addition to clk_set_rate */
 /**
  * clk_set_rate_ex - set the clock rate for a clock source, with additional parameter
index 64b1c16a0f03559dc53695ccb572c8ca9643de57..73d6d16fa06b34ec61fc16215adf5c4fa9d81d34 100644 (file)
@@ -46,6 +46,8 @@ struct sh_machine_vector {
 
        void __iomem *(*mv_ioport_map)(unsigned long port, unsigned int size);
        void (*mv_ioport_unmap)(void __iomem *);
+
+       int (*mv_clk_init)(void);
 };
 
 extern struct sh_machine_vector sh_mv;
index 2600641a483f743ab7938f4daf9a42e58111733a..05105b980c21b62b2e47515289d142fcf4ffce1a 100644 (file)
@@ -17,5 +17,6 @@ obj-$(CONFIG_ARCH_SHMOBILE)   += shmobile/
 
 obj-$(CONFIG_UBC_WAKEUP)       += ubc.o
 obj-$(CONFIG_SH_ADC)           += adc.o
+obj-$(CONFIG_SH_CLK_CPG_LEGACY)        += clock-cpg.o
 
 obj-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 (file)
index 0000000..b4ca200
--- /dev/null
@@ -0,0 +1,60 @@
+#include <linux/clk.h>
+#include <linux/compiler.h>
+#include <asm/clock.h>
+
+static struct clk master_clk = {
+       .name           = "master_clk",
+       .flags          = CLK_ENABLE_ON_INIT,
+       .rate           = CONFIG_SH_PCLK_FREQ,
+};
+
+static struct clk peripheral_clk = {
+       .name           = "peripheral_clk",
+       .parent         = &master_clk,
+       .flags          = CLK_ENABLE_ON_INIT,
+};
+
+static struct clk bus_clk = {
+       .name           = "bus_clk",
+       .parent         = &master_clk,
+       .flags          = CLK_ENABLE_ON_INIT,
+};
+
+static struct clk cpu_clk = {
+       .name           = "cpu_clk",
+       .parent         = &master_clk,
+       .flags          = CLK_ENABLE_ON_INIT,
+};
+
+/*
+ * The ordering of these clocks matters, do not change it.
+ */
+static struct clk *onchip_clocks[] = {
+       &master_clk,
+       &peripheral_clk,
+       &bus_clk,
+       &cpu_clk,
+};
+
+int __init __deprecated cpg_clk_init(void)
+{
+       int i, ret = 0;
+
+       for (i = 0; i < ARRAY_SIZE(onchip_clocks); i++) {
+               struct clk *clk = onchip_clocks[i];
+               arch_init_clk_ops(&clk->ops, i);
+               if (clk->ops)
+                       ret |= clk_register(clk);
+       }
+
+       return ret;
+}
+
+/*
+ * Placeholder for compatability, until the lazy CPUs do this
+ * on their own.
+ */
+int __init __weak arch_clk_init(void)
+{
+       return cpg_clk_init();
+}
index 0a7755cc8a25b25115d755e0bfa5a5a10a41bd66..033f4662b59d9fa2843a723661149f8302d76948 100644 (file)
 #include <linux/platform_device.h>
 #include <linux/proc_fs.h>
 #include <asm/clock.h>
+#include <asm/machvec.h>
 
 static LIST_HEAD(clock_list);
 static DEFINE_SPINLOCK(clock_lock);
 static DEFINE_MUTEX(clock_list_sem);
 
-/*
- * Each subtype is expected to define the init routines for these clocks,
- * as each subtype (or processor family) will have these clocks at the
- * very least. These are all provided through the CPG, which even some of
- * the more quirky parts (such as ST40, SH4-202, etc.) still have.
- *
- * The processor-specific code is expected to register any additional
- * clock sources that are of interest.
- */
-static struct clk master_clk = {
-       .name           = "master_clk",
-       .flags          = CLK_ENABLE_ON_INIT,
-       .rate           = CONFIG_SH_PCLK_FREQ,
-};
-
-static struct clk peripheral_clk = {
-       .name           = "peripheral_clk",
-       .parent         = &master_clk,
-       .flags          = CLK_ENABLE_ON_INIT,
-};
-
-static struct clk bus_clk = {
-       .name           = "bus_clk",
-       .parent         = &master_clk,
-       .flags          = CLK_ENABLE_ON_INIT,
-};
-
-static struct clk cpu_clk = {
-       .name           = "cpu_clk",
-       .parent         = &master_clk,
-       .flags          = CLK_ENABLE_ON_INIT,
-};
-
-/*
- * The ordering of these clocks matters, do not change it.
- */
-static struct clk *onchip_clocks[] = {
-       &master_clk,
-       &peripheral_clk,
-       &bus_clk,
-       &cpu_clk,
-};
-
 /* Used for clocks that always have same value as the parent clock */
 unsigned long followparent_recalc(struct clk *clk)
 {
@@ -443,10 +401,6 @@ void clk_put(struct clk *clk)
 }
 EXPORT_SYMBOL_GPL(clk_put);
 
-int __init __weak arch_clk_init(void)
-{
-       return 0;
-}
 
 static int show_clocks(char *buf, char **start, off_t off,
                       int len, int *eof, void *data)
@@ -533,18 +487,22 @@ subsys_initcall(clk_sysdev_init);
 
 int __init clk_init(void)
 {
-       int i, ret = 0;
-
-       BUG_ON(!master_clk.rate);
-
-       for (i = 0; i < ARRAY_SIZE(onchip_clocks); i++) {
-               struct clk *clk = onchip_clocks[i];
+       int ret;
 
-               arch_init_clk_ops(&clk->ops, i);
-               ret |= clk_register(clk);
+       ret = arch_clk_init();
+       if (unlikely(ret)) {
+               pr_err("%s: CPU clock registration failed.\n", __func__);
+               return ret;
        }
 
-       ret |= arch_clk_init();
+       if (sh_mv.mv_clk_init) {
+               ret = sh_mv.mv_clk_init();
+               if (unlikely(ret)) {
+                       pr_err("%s: machvec clock initialization failed.\n",
+                              __func__);
+                       return ret;
+               }
+       }
 
        /* Kick the child clocks.. */
        recalculate_root_clocks();
index a72dc326d0b3351d995ddc7387f024b6860dc513..21421e34e7d5b92d2610b840dc59c201efbf6faa 100644 (file)
@@ -152,9 +152,12 @@ static struct clk *sh4202_onchip_clocks[] = {
 
 int __init arch_clk_init(void)
 {
-       struct clk *clk = clk_get(NULL, "master_clk");
+       struct clk *clk;
        int i, ret = 0;
 
+       cpg_clk_init();
+
+       clk = clk_get(NULL, "master_clk");
        for (i = 0; i < ARRAY_SIZE(sh4202_onchip_clocks); i++) {
                struct clk *clkp = sh4202_onchip_clocks[i];
 
index 426065b432694b68f13c33e69ade2ff089dcec9d..a98d7da67b97bfd948f2769f3951aa4929730b0d 100644 (file)
@@ -892,6 +892,8 @@ int __init arch_clk_init(void)
        struct clk *clk;
        int i;
 
+       clk_cpg_init();
+
        clk = clk_get(NULL, "master_clk");
        for (i = 0; i < ARRAY_SIZE(sh7722_clocks); i++) {
                pr_debug( "Registering clock '%s'\n", sh7722_clocks[i]->name);
index ce3d4e6319a315de3da6fc160fe217a6a019ab5d..370cd47642efcbfc3ec36827a3a581ba4bf7bc7a 100644 (file)
@@ -92,9 +92,12 @@ static struct clk *sh7763_onchip_clocks[] = {
 
 int __init arch_clk_init(void)
 {
-       struct clk *clk = clk_get(NULL, "master_clk");
+       struct clk *clk;
        int i, ret = 0;
 
+       cpg_clk_init();
+
+       clk = clk_get(NULL, "master_clk");
        for (i = 0; i < ARRAY_SIZE(sh7763_onchip_clocks); i++) {
                struct clk *clkp = sh7763_onchip_clocks[i];
 
index 38b8b1ddb283bf3a95746b9cb6145e5374e15f26..a249d823578ea1406468bfa75d4c84c9c0f0b24e 100644 (file)
@@ -98,9 +98,12 @@ static struct clk *sh7780_onchip_clocks[] = {
 
 int __init arch_clk_init(void)
 {
-       struct clk *clk = clk_get(NULL, "master_clk");
+       struct clk *clk;
        int i, ret = 0;
 
+       cpg_clk_init();
+
+       clk = clk_get(NULL, "master_clk");
        for (i = 0; i < ARRAY_SIZE(sh7780_onchip_clocks); i++) {
                struct clk *clkp = sh7780_onchip_clocks[i];
 
index fa14f35bc116d9142da65f97f9082f851aec4014..bf5a0dacf8e578e17479e8f0286d46010d41f5a3 100644 (file)
@@ -136,9 +136,12 @@ static struct clk *sh7785_onchip_clocks[] = {
 
 int __init arch_clk_init(void)
 {
-       struct clk *clk = clk_get(NULL, "master_clk");
+       struct clk *clk;
        int i, ret = 0;
 
+       cpg_clk_init();
+
+       clk = clk_get(NULL, "master_clk");
        for (i = 0; i < ARRAY_SIZE(sh7785_onchip_clocks); i++) {
                struct clk *clkp = sh7785_onchip_clocks[i];
 
index 7907002fa1df0ad32dc2616a2a8169f471da61d8..a0e8869071ace5480fa1d9f3857b5c8f9af102c5 100644 (file)
@@ -122,9 +122,12 @@ static struct clk *sh7786_onchip_clocks[] = {
 
 int __init arch_clk_init(void)
 {
-       struct clk *clk = clk_get(NULL, "master_clk");
+       struct clk *clk;
        int i, ret = 0;
 
+       cpg_clk_init();
+
+       clk = clk_get(NULL, "master_clk");
        for (i = 0; i < ARRAY_SIZE(sh7786_onchip_clocks); i++) {
                struct clk *clkp = sh7786_onchip_clocks[i];
 
index c14553e3e13f7c4f3459134a03e714aa9cfea56c..23c27d32d9823136e38f725dca53f6ffe92b76b5 100644 (file)
@@ -109,9 +109,12 @@ static struct clk *shx3_onchip_clocks[] = {
 
 int __init arch_clk_init(void)
 {
-       struct clk *clk = clk_get(NULL, "master_clk");
+       struct clk *clk;
        int i, ret = 0;
 
+       cpg_clk_init();
+
+       clk = clk_get(NULL, "master_clk");
        for (i = 0; i < ARRAY_SIZE(shx3_onchip_clocks); i++) {
                struct clk *clkp = shx3_onchip_clocks[i];