]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
sh: clkfwk: Tidy up on-chip clock registration and rate propagation.
authorPaul Mundt <lethal@linux-sh.org>
Mon, 11 May 2009 20:59:27 +0000 (05:59 +0900)
committerPaul Mundt <lethal@linux-sh.org>
Mon, 11 May 2009 20:59:27 +0000 (05:59 +0900)
This tidies up the set_rate hack that the on-chip clocks were abusing to
trigger rate propagation, which is now handled generically.

Additionally, now that CLK_ENABLE_ON_INIT is wired up where it needs to
be for these clocks, the clk_enable() can go away. In some cases this was
bumping up the refcount higher than it should have been.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/kernel/cpu/sh4/clock-sh4-202.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 0caca9f99fe83bb96486250e6caec82c681dbf65..435f4f12ffb8b1423efd68afc945e33787963912 100644 (file)
@@ -127,7 +127,7 @@ static int shoc_clk_set_rate(struct clk *clk, unsigned long rate, int algo_id)
        frqcr3 |= tmp << 6;
        ctrl_outl(frqcr3, CPG2_FRQCR3);
 
-       return clk->parent->rate / frqcr3_divisors[tmp];
+       clk->rate = clk->parent->rate / frqcr3_divisors[tmp];
 
        return 0;
 }
@@ -153,28 +153,17 @@ static struct clk *sh4202_onchip_clocks[] = {
 static int __init sh4202_clk_init(void)
 {
        struct clk *clk = clk_get(NULL, "master_clk");
-       int i;
+       int i, ret = 0;
 
        for (i = 0; i < ARRAY_SIZE(sh4202_onchip_clocks); i++) {
                struct clk *clkp = sh4202_onchip_clocks[i];
 
                clkp->parent = clk;
-               clk_register(clkp);
-               clk_enable(clkp);
+               ret |= clk_register(clkp);
        }
 
-       /*
-        * Now that we have the rest of the clocks registered, we need to
-        * force the parent clock to propagate so that these clocks will
-        * automatically figure out their rate. We cheat by handing the
-        * parent clock its current rate and forcing child propagation.
-        */
-       clk_set_rate(clk, clk_get_rate(clk));
-
        clk_put(clk);
 
-       return 0;
+       return ret;
 }
-
 arch_initcall(sh4202_clk_init);
-
index 21bd70f9ee4573c2c2e27b39d79ba2ed4ccb30eb..0110da64a43b7a32ae4e3544ea584fe64e541afe 100644 (file)
@@ -93,28 +93,17 @@ static struct clk *sh7763_onchip_clocks[] = {
 static int __init sh7763_clk_init(void)
 {
        struct clk *clk = clk_get(NULL, "master_clk");
-       int i;
+       int i, ret = 0;
 
        for (i = 0; i < ARRAY_SIZE(sh7763_onchip_clocks); i++) {
                struct clk *clkp = sh7763_onchip_clocks[i];
 
                clkp->parent = clk;
-               clk_register(clkp);
-               clk_enable(clkp);
+               ret |= clk_register(clkp);
        }
 
-       /*
-        * Now that we have the rest of the clocks registered, we need to
-        * force the parent clock to propagate so that these clocks will
-        * automatically figure out their rate. We cheat by handing the
-        * parent clock its current rate and forcing child propagation.
-        */
-       clk_set_rate(clk, clk_get_rate(clk));
-
        clk_put(clk);
 
-       return 0;
+       return ret;
 }
-
 arch_initcall(sh7763_clk_init);
-
index 4c11f8917e4082ed51e60f44df9bf1bfe6966388..0a22d50b109f482ad66ddadb4c5b17476fa45a59 100644 (file)
@@ -99,28 +99,17 @@ static struct clk *sh7780_onchip_clocks[] = {
 static int __init sh7780_clk_init(void)
 {
        struct clk *clk = clk_get(NULL, "master_clk");
-       int i;
+       int i, ret = 0;
 
        for (i = 0; i < ARRAY_SIZE(sh7780_onchip_clocks); i++) {
                struct clk *clkp = sh7780_onchip_clocks[i];
 
                clkp->parent = clk;
-               clk_register(clkp);
-               clk_enable(clkp);
+               ret |= clk_register(clkp);
        }
 
-       /*
-        * Now that we have the rest of the clocks registered, we need to
-        * force the parent clock to propagate so that these clocks will
-        * automatically figure out their rate. We cheat by handing the
-        * parent clock its current rate and forcing child propagation.
-        */
-       clk_set_rate(clk, clk_get_rate(clk));
-
        clk_put(clk);
 
-       return 0;
+       return ret;
 }
-
 arch_initcall(sh7780_clk_init);
-
index edd432894bd937c4102c36e7071a875c559410da..4dcd1f6f0cbd6cceab3701da9680b58cc77ca063 100644 (file)
@@ -137,26 +137,17 @@ static struct clk *sh7785_onchip_clocks[] = {
 static int __init sh7785_clk_init(void)
 {
        struct clk *clk = clk_get(NULL, "master_clk");
-       int i;
+       int i, ret = 0;
 
        for (i = 0; i < ARRAY_SIZE(sh7785_onchip_clocks); i++) {
                struct clk *clkp = sh7785_onchip_clocks[i];
 
                clkp->parent = clk;
-               clk_register(clkp);
-               clk_enable(clkp);
+               ret |= clk_register(clkp);
        }
 
-       /*
-        * Now that we have the rest of the clocks registered, we need to
-        * force the parent clock to propagate so that these clocks will
-        * automatically figure out their rate. We cheat by handing the
-        * parent clock its current rate and forcing child propagation.
-        */
-       clk_set_rate(clk, clk_get_rate(clk));
-
        clk_put(clk);
 
-       return 0;
+       return ret;
 }
 arch_initcall(sh7785_clk_init);
index 2825494f85dca2131898354f68e19dabe2fc923c..825556fe23063ce5408fbc095411765fc7d6587d 100644 (file)
@@ -123,26 +123,17 @@ static struct clk *sh7786_onchip_clocks[] = {
 static int __init sh7786_clk_init(void)
 {
        struct clk *clk = clk_get(NULL, "master_clk");
-       int i;
+       int i, ret = 0;
 
        for (i = 0; i < ARRAY_SIZE(sh7786_onchip_clocks); i++) {
                struct clk *clkp = sh7786_onchip_clocks[i];
 
                clkp->parent = clk;
-               clk_register(clkp);
-               clk_enable(clkp);
+               ret |= clk_register(clkp);
        }
 
-       /*
-        * Now that we have the rest of the clocks registered, we need to
-        * force the parent clock to propagate so that these clocks will
-        * automatically figure out their rate. We cheat by handing the
-        * parent clock its current rate and forcing child propagation.
-        */
-       clk_set_rate(clk, clk_get_rate(clk));
-
        clk_put(clk);
 
-       return 0;
+       return ret;
 }
 arch_initcall(sh7786_clk_init);
index 6e5c864cf40f88828f3426c35d4cce388b7076b3..1eb149b0fe6e4585edbb3a6d88221adb1a9e065f 100644 (file)
@@ -110,26 +110,17 @@ static struct clk *shx3_onchip_clocks[] = {
 static int __init shx3_clk_init(void)
 {
        struct clk *clk = clk_get(NULL, "master_clk");
-       int i;
+       int i, ret = 0;
 
        for (i = 0; i < ARRAY_SIZE(shx3_onchip_clocks); i++) {
                struct clk *clkp = shx3_onchip_clocks[i];
 
                clkp->parent = clk;
-               clk_register(clkp);
-               clk_enable(clkp);
+               ret |= clk_register(clkp);
        }
 
-       /*
-        * Now that we have the rest of the clocks registered, we need to
-        * force the parent clock to propagate so that these clocks will
-        * automatically figure out their rate. We cheat by handing the
-        * parent clock its current rate and forcing child propagation.
-        */
-       clk_set_rate(clk, clk_get_rate(clk));
-
        clk_put(clk);
 
-       return 0;
+       return ret;
 }
 arch_initcall(shx3_clk_init);