OMAP: clockdomain: Arch specific funcs for sleep/wakeup of clkdm
authorRajendra Nayak <rnayak@ti.com>
Fri, 25 Feb 2011 23:06:47 +0000 (16:06 -0700)
committerPaul Walmsley <paul@pwsan.com>
Fri, 25 Feb 2011 23:06:47 +0000 (16:06 -0700)
Define the following architecture specific funtions for omap2/3/4
.clkdm_sleep
.clkdm_wakeup

Convert the platform-independent framework to call these functions.
Also rename the api's by removing the omap2_ preamble.
Hence call omap2_clkdm_wakeup as clkdm_wakeup and
omap2_clkdm_sleep as clkdm_sleep.

Signed-off-by: Rajendra Nayak <rnayak@ti.com>
[paul@pwsan.com: fixed omap3_clkdm_clear_all_sleepdeps() and
 omap2_clkdm_clear_all_wkdeps() to test against the correct
 loop termination condition; thanks to Kevin Hilman for finding and
 helping fix]
Cc: Kevin Hilman <khilman@ti.com>
Signed-off-by: Paul Walmsley <paul@pwsan.com>
arch/arm/mach-omap2/Makefile
arch/arm/mach-omap2/clockdomain.c
arch/arm/mach-omap2/clockdomain.h
arch/arm/mach-omap2/clockdomain2xxx_3xxx.c
arch/arm/mach-omap2/clockdomain44xx.c [new file with mode: 0644]
arch/arm/mach-omap2/clockdomains44xx_data.c
arch/arm/mach-omap2/pm.c
arch/arm/mach-omap2/pm24xx.c
arch/arm/mach-omap2/pm34xx.c

index 759d9ebd79c6bb9d3e575f12d50217a78edd5e6c..10c3c8f16eaac522aade584168b10196fb6bb73c 100644 (file)
@@ -108,6 +108,7 @@ obj-$(CONFIG_ARCH_OMAP3)            += clockdomain.o \
                                           clockdomain2xxx_3xxx.o \
                                           clockdomains2xxx_3xxx_data.o
 obj-$(CONFIG_ARCH_OMAP4)               += clockdomain.o \
+                                          clockdomain44xx.o \
                                           clockdomains44xx_data.o
 # Clock framework
 obj-$(CONFIG_ARCH_OMAP2)               += $(clock-common) clock2xxx.o \
index 895c153c18e0c3aec4c82ae957209c4be8a966f8..3035eb9eec3692b65125f83a7b4f90e51bb96369 100644 (file)
@@ -355,7 +355,7 @@ void clkdm_init(struct clockdomain **clkdms,
         */
        list_for_each_entry(clkdm, &clkdm_list, node) {
                if (clkdm->flags & CLKDM_CAN_FORCE_WAKEUP)
-                       omap2_clkdm_wakeup(clkdm);
+                       clkdm_wakeup(clkdm);
                else if (clkdm->flags & CLKDM_CAN_DISABLE_AUTO)
                        omap2_clkdm_deny_idle(clkdm);
 
@@ -765,7 +765,7 @@ int clkdm_clear_all_sleepdeps(struct clockdomain *clkdm)
 }
 
 /**
- * omap2_clkdm_sleep - force clockdomain sleep transition
+ * clkdm_sleep - force clockdomain sleep transition
  * @clkdm: struct clockdomain *
  *
  * Instruct the CM to force a sleep transition on the specified
@@ -773,7 +773,7 @@ int clkdm_clear_all_sleepdeps(struct clockdomain *clkdm)
  * clockdomain does not support software-initiated sleep; 0 upon
  * success.
  */
-int omap2_clkdm_sleep(struct clockdomain *clkdm)
+int clkdm_sleep(struct clockdomain *clkdm)
 {
        if (!clkdm)
                return -EINVAL;
@@ -784,33 +784,16 @@ int omap2_clkdm_sleep(struct clockdomain *clkdm)
                return -EINVAL;
        }
 
-       pr_debug("clockdomain: forcing sleep on %s\n", clkdm->name);
-
-       if (cpu_is_omap24xx()) {
-
-               omap2_cm_set_mod_reg_bits(OMAP24XX_FORCESTATE_MASK,
-                           clkdm->pwrdm.ptr->prcm_offs, OMAP2_PM_PWSTCTRL);
-
-       } else if (cpu_is_omap34xx()) {
-
-               omap3xxx_cm_clkdm_force_sleep(clkdm->pwrdm.ptr->prcm_offs,
-                                             clkdm->clktrctrl_mask);
-
-       } else if (cpu_is_omap44xx()) {
-
-               omap4_cminst_clkdm_force_sleep(clkdm->prcm_partition,
-                                              clkdm->cm_inst,
-                                              clkdm->clkdm_offs);
+       if (!arch_clkdm || !arch_clkdm->clkdm_sleep)
+               return -EINVAL;
 
-       } else {
-               BUG();
-       };
+       pr_debug("clockdomain: forcing sleep on %s\n", clkdm->name);
 
-       return 0;
+       return arch_clkdm->clkdm_sleep(clkdm);
 }
 
 /**
- * omap2_clkdm_wakeup - force clockdomain wakeup transition
+ * clkdm_wakeup - force clockdomain wakeup transition
  * @clkdm: struct clockdomain *
  *
  * Instruct the CM to force a wakeup transition on the specified
@@ -818,7 +801,7 @@ int omap2_clkdm_sleep(struct clockdomain *clkdm)
  * clockdomain does not support software-controlled wakeup; 0 upon
  * success.
  */
-int omap2_clkdm_wakeup(struct clockdomain *clkdm)
+int clkdm_wakeup(struct clockdomain *clkdm)
 {
        if (!clkdm)
                return -EINVAL;
@@ -829,29 +812,12 @@ int omap2_clkdm_wakeup(struct clockdomain *clkdm)
                return -EINVAL;
        }
 
-       pr_debug("clockdomain: forcing wakeup on %s\n", clkdm->name);
-
-       if (cpu_is_omap24xx()) {
-
-               omap2_cm_clear_mod_reg_bits(OMAP24XX_FORCESTATE_MASK,
-                             clkdm->pwrdm.ptr->prcm_offs, OMAP2_PM_PWSTCTRL);
-
-       } else if (cpu_is_omap34xx()) {
-
-               omap3xxx_cm_clkdm_force_wakeup(clkdm->pwrdm.ptr->prcm_offs,
-                                              clkdm->clktrctrl_mask);
-
-       } else if (cpu_is_omap44xx()) {
-
-               omap4_cminst_clkdm_force_wakeup(clkdm->prcm_partition,
-                                               clkdm->cm_inst,
-                                               clkdm->clkdm_offs);
+       if (!arch_clkdm || !arch_clkdm->clkdm_wakeup)
+               return -EINVAL;
 
-       } else {
-               BUG();
-       };
+       pr_debug("clockdomain: forcing wakeup on %s\n", clkdm->name);
 
-       return 0;
+       return arch_clkdm->clkdm_wakeup(clkdm);
 }
 
 /**
@@ -990,7 +956,7 @@ int omap2_clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk)
                _clkdm_add_autodeps(clkdm);
                _enable_hwsup(clkdm);
        } else {
-               omap2_clkdm_wakeup(clkdm);
+               clkdm_wakeup(clkdm);
        }
 
        pwrdm_wait_transition(clkdm->pwrdm.ptr);
@@ -1062,7 +1028,7 @@ int omap2_clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk)
                _clkdm_del_autodeps(clkdm);
                _enable_hwsup(clkdm);
        } else {
-               omap2_clkdm_sleep(clkdm);
+               clkdm_sleep(clkdm);
        }
 
        pwrdm_clkdm_state_switch(clkdm);
index 90b6d6a508620ab5580820aa9e004a376e852141..7a5cb5cf9949178c48c0eb399c67c92b155cc361 100644 (file)
@@ -170,8 +170,8 @@ int clkdm_clear_all_sleepdeps(struct clockdomain *clkdm);
 void omap2_clkdm_allow_idle(struct clockdomain *clkdm);
 void omap2_clkdm_deny_idle(struct clockdomain *clkdm);
 
-int omap2_clkdm_wakeup(struct clockdomain *clkdm);
-int omap2_clkdm_sleep(struct clockdomain *clkdm);
+int clkdm_wakeup(struct clockdomain *clkdm);
+int clkdm_sleep(struct clockdomain *clkdm);
 
 int omap2_clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk);
 int omap2_clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk);
@@ -182,5 +182,6 @@ extern void __init omap44xx_clockdomains_init(void);
 
 extern struct clkdm_ops omap2_clkdm_operations;
 extern struct clkdm_ops omap3_clkdm_operations;
+extern struct clkdm_ops omap4_clkdm_operations;
 
 #endif
index a1fd6fd5a4667a7c5bcab334ca40186009a341d2..08c87fe3da123ac99e26c85a9e4fa4a6777a61bd 100644 (file)
@@ -20,6 +20,7 @@
 #include "cm2xxx_3xxx.h"
 #include "cm-regbits-24xx.h"
 #include "cm-regbits-34xx.h"
+#include "prm-regbits-24xx.h"
 #include "clockdomain.h"
 
 static int omap2_clkdm_add_wkdep(struct clockdomain *clkdm1,
@@ -111,11 +112,43 @@ static int omap3_clkdm_clear_all_sleepdeps(struct clockdomain *clkdm)
        return 0;
 }
 
+static int omap2_clkdm_sleep(struct clockdomain *clkdm)
+{
+       omap2_cm_set_mod_reg_bits(OMAP24XX_FORCESTATE_MASK,
+                               clkdm->pwrdm.ptr->prcm_offs,
+                               OMAP2_PM_PWSTCTRL);
+       return 0;
+}
+
+static int omap2_clkdm_wakeup(struct clockdomain *clkdm)
+{
+       omap2_cm_clear_mod_reg_bits(OMAP24XX_FORCESTATE_MASK,
+                               clkdm->pwrdm.ptr->prcm_offs,
+                               OMAP2_PM_PWSTCTRL);
+       return 0;
+}
+
+static int omap3_clkdm_sleep(struct clockdomain *clkdm)
+{
+       omap3xxx_cm_clkdm_force_sleep(clkdm->pwrdm.ptr->prcm_offs,
+                               clkdm->clktrctrl_mask);
+       return 0;
+}
+
+static int omap3_clkdm_wakeup(struct clockdomain *clkdm)
+{
+       omap3xxx_cm_clkdm_force_wakeup(clkdm->pwrdm.ptr->prcm_offs,
+                               clkdm->clktrctrl_mask);
+       return 0;
+}
+
 struct clkdm_ops omap2_clkdm_operations = {
        .clkdm_add_wkdep        = omap2_clkdm_add_wkdep,
        .clkdm_del_wkdep        = omap2_clkdm_del_wkdep,
        .clkdm_read_wkdep       = omap2_clkdm_read_wkdep,
        .clkdm_clear_all_wkdeps = omap2_clkdm_clear_all_wkdeps,
+       .clkdm_sleep            = omap2_clkdm_sleep,
+       .clkdm_wakeup           = omap2_clkdm_wakeup,
 };
 
 struct clkdm_ops omap3_clkdm_operations = {
@@ -127,4 +160,6 @@ struct clkdm_ops omap3_clkdm_operations = {
        .clkdm_del_sleepdep     = omap3_clkdm_del_sleepdep,
        .clkdm_read_sleepdep    = omap3_clkdm_read_sleepdep,
        .clkdm_clear_all_sleepdeps      = omap3_clkdm_clear_all_sleepdeps,
+       .clkdm_sleep            = omap3_clkdm_sleep,
+       .clkdm_wakeup           = omap3_clkdm_wakeup,
 };
diff --git a/arch/arm/mach-omap2/clockdomain44xx.c b/arch/arm/mach-omap2/clockdomain44xx.c
new file mode 100644 (file)
index 0000000..9ccb406
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * OMAP4 clockdomain control
+ *
+ * Copyright (C) 2008-2010 Texas Instruments, Inc.
+ * Copyright (C) 2008-2010 Nokia Corporation
+ *
+ * Derived from mach-omap2/clockdomain.c written by Paul Walmsley
+ * Rajendra Nayak <rnayak@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "clockdomain.h"
+#include "cminst44xx.h"
+
+static int omap4_clkdm_sleep(struct clockdomain *clkdm)
+{
+       omap4_cminst_clkdm_force_sleep(clkdm->prcm_partition,
+                                       clkdm->cm_inst, clkdm->clkdm_offs);
+       return 0;
+}
+
+static int omap4_clkdm_wakeup(struct clockdomain *clkdm)
+{
+       omap4_cminst_clkdm_force_wakeup(clkdm->prcm_partition,
+                                       clkdm->cm_inst, clkdm->clkdm_offs);
+       return 0;
+}
+
+struct clkdm_ops omap4_clkdm_operations = {
+       .clkdm_sleep            = omap4_clkdm_sleep,
+       .clkdm_wakeup           = omap4_clkdm_wakeup,
+};
index a5000d473d457dbd2eefb99bda9904489d07094d..eea6f8e402890644f43571d479f30c45f8f20789 100644 (file)
@@ -305,5 +305,5 @@ static struct clockdomain *clockdomains_omap44xx[] __initdata = {
 
 void __init omap44xx_clockdomains_init(void)
 {
-       clkdm_init(clockdomains_omap44xx, NULL, NULL);
+       clkdm_init(clockdomains_omap44xx, NULL, &omap4_clkdm_operations);
 }
index d5a102c71989ae766ee99d9e543e041276823b69..74c31008079c020d4a59c8b170407c7414cd0fd8 100644 (file)
@@ -124,7 +124,7 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
                        (pwrdm->flags & PWRDM_HAS_LOWPOWERSTATECHANGE)) {
                        sleep_switch = LOWPOWERSTATE_SWITCH;
                } else {
-                       omap2_clkdm_wakeup(pwrdm->pwrdm_clkdms[0]);
+                       clkdm_wakeup(pwrdm->pwrdm_clkdms[0]);
                        pwrdm_wait_transition(pwrdm);
                        sleep_switch = FORCEWAKEUP_SWITCH;
                }
@@ -142,7 +142,7 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
                if (pwrdm->pwrdm_clkdms[0]->flags & CLKDM_CAN_ENABLE_AUTO)
                        omap2_clkdm_allow_idle(pwrdm->pwrdm_clkdms[0]);
                else
-                       omap2_clkdm_sleep(pwrdm->pwrdm_clkdms[0]);
+                       clkdm_sleep(pwrdm->pwrdm_clkdms[0]);
                break;
        case LOWPOWERSTATE_SWITCH:
                pwrdm_set_lowpwrstchange(pwrdm);
index 97feb3ab6a69e9842961a2da169be26f07c5f55a..4125621bf591855ddb93377a3c1e3c650198ccad 100644 (file)
@@ -370,7 +370,7 @@ static int __init clkdms_setup(struct clockdomain *clkdm, void *unused)
                omap2_clkdm_allow_idle(clkdm);
        else if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP &&
                 atomic_read(&clkdm->usecount) == 0)
-               omap2_clkdm_sleep(clkdm);
+               clkdm_sleep(clkdm);
        return 0;
 }
 
@@ -405,11 +405,11 @@ static void __init prcm_setup_regs(void)
 
        pwrdm = clkdm_get_pwrdm(dsp_clkdm);
        pwrdm_set_next_pwrst(pwrdm, PWRDM_POWER_OFF);
-       omap2_clkdm_sleep(dsp_clkdm);
+       clkdm_sleep(dsp_clkdm);
 
        pwrdm = clkdm_get_pwrdm(gfx_clkdm);
        pwrdm_set_next_pwrst(pwrdm, PWRDM_POWER_OFF);
-       omap2_clkdm_sleep(gfx_clkdm);
+       clkdm_sleep(gfx_clkdm);
 
        /*
         * Clear clockdomain wakeup dependencies and enable
index 2f864e4b085dba963f70b846afd835372b6ec5d1..81df2b169a56dfbbaceca11b4013a2b6a8e1db82 100644 (file)
@@ -993,7 +993,7 @@ static int __init clkdms_setup(struct clockdomain *clkdm, void *unused)
                omap2_clkdm_allow_idle(clkdm);
        else if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP &&
                 atomic_read(&clkdm->usecount) == 0)
-               omap2_clkdm_sleep(clkdm);
+               clkdm_sleep(clkdm);
        return 0;
 }