aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-pnx4008/clock.c55
1 files changed, 23 insertions, 32 deletions
diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
index 6f5d2e502654..f0cc91909090 100644
--- a/arch/arm/mach-pnx4008/clock.c
+++ b/arch/arm/mach-pnx4008/clock.c
@@ -808,49 +808,40 @@ static struct clk_lookup onchip_clkreg[] = {
808 { .clk = &wdt_ck, .con_id = "wdt_ck" }, 808 { .clk = &wdt_ck, .con_id = "wdt_ck" },
809}; 809};
810 810
811static int local_clk_enable(struct clk *clk)
812{
813 int ret = 0;
814
815 if (!(clk->flags & FIXED_RATE) && !clk->rate && clk->set_rate
816 && clk->user_rate)
817 ret = clk->set_rate(clk, clk->user_rate);
818 return ret;
819}
820
821static void local_clk_disable(struct clk *clk) 811static void local_clk_disable(struct clk *clk)
822{ 812{
823 if (!(clk->flags & FIXED_RATE) && clk->rate && clk->set_rate) 813 if (WARN_ON(clk->usecount == 0))
824 clk->set_rate(clk, 0); 814 return;
825}
826 815
827static void local_clk_unuse(struct clk *clk) 816 if (!(--clk->usecount)) {
828{ 817 if (!(clk->flags & FIXED_RATE) && clk->rate && clk->set_rate)
829 if (clk->usecount > 0 && !(--clk->usecount)) { 818 clk->set_rate(clk, 0);
830 local_clk_disable(clk);
831 if (clk->parent) 819 if (clk->parent)
832 local_clk_unuse(clk->parent); 820 local_clk_disable(clk->parent);
833 } 821 }
834} 822}
835 823
836static int local_clk_use(struct clk *clk) 824static int local_clk_enable(struct clk *clk)
837{ 825{
838 int ret = 0; 826 int ret = 0;
839 if (clk->usecount++ == 0) {
840 if (clk->parent)
841 ret = local_clk_use(clk->parent);
842 827
843 if (ret != 0) { 828 if (clk->usecount == 0) {
844 clk->usecount--; 829 if (clk->parent) {
845 goto out; 830 ret = local_clk_enable(clk->parent);
831 if (ret != 0)
832 goto out;
846 } 833 }
847 834
848 ret = local_clk_enable(clk); 835 if (!(clk->flags & FIXED_RATE) && !clk->rate && clk->set_rate
836 && clk->user_rate)
837 ret = clk->set_rate(clk, clk->user_rate);
849 838
850 if (ret != 0 && clk->parent) { 839 if (ret != 0 && clk->parent) {
851 local_clk_unuse(clk->parent); 840 local_clk_disable(clk->parent);
852 clk->usecount--; 841 goto out;
853 } 842 }
843
844 clk->usecount++;
854 } 845 }
855out: 846out:
856 return ret; 847 return ret;
@@ -909,10 +900,10 @@ EXPORT_SYMBOL(clk_get_rate);
909 900
910int clk_enable(struct clk *clk) 901int clk_enable(struct clk *clk)
911{ 902{
912 int ret = 0; 903 int ret;
913 904
914 clock_lock(); 905 clock_lock();
915 ret = local_clk_use(clk); 906 ret = local_clk_enable(clk);
916 clock_unlock(); 907 clock_unlock();
917 return ret; 908 return ret;
918} 909}
@@ -922,7 +913,7 @@ EXPORT_SYMBOL(clk_enable);
922void clk_disable(struct clk *clk) 913void clk_disable(struct clk *clk)
923{ 914{
924 clock_lock(); 915 clock_lock();
925 local_clk_unuse(clk); 916 local_clk_disable(clk);
926 clock_unlock(); 917 clock_unlock();
927} 918}
928 919
@@ -980,7 +971,7 @@ static int __init clk_init(void)
980 __func__, (*clkp)->name, (*clkp)->rate); 971 __func__, (*clkp)->name, (*clkp)->rate);
981 } 972 }
982 973
983 local_clk_use(&ck_pll4); 974 local_clk_enable(&ck_pll4);
984 975
985 /* if ck_13MHz is not used, disable it. */ 976 /* if ck_13MHz is not used, disable it. */
986 if (ck_13MHz.usecount == 0) 977 if (ck_13MHz.usecount == 0)