]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/mach-omap2/clockdomain.c
OMAP2/3 clock: mark the rest of the CM clocks as belonging to cm_clkdm
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / clockdomain.c
index ca944eccba975ad1a1c46686d6d00c818f7f183a..fa62f14de2a3a7f18ff51200aed3886eef877a51 100644 (file)
 
 #include <linux/bitops.h>
 
-#include <asm/arch/clock.h>
+#include <mach/clock.h>
 
 #include "prm.h"
 #include "prm-regbits-24xx.h"
 #include "cm.h"
 
-#include <asm/arch/powerdomain.h>
-#include <asm/arch/clockdomain.h>
+#include <mach/powerdomain.h>
+#include <mach/clockdomain.h>
 
 /* clkdm_list contains all registered struct clockdomains */
 static LIST_HEAD(clkdm_list);
@@ -71,14 +71,14 @@ static void _autodep_lookup(struct clkdm_pwrdm_autodep *autodep)
        if (!omap_chip_is(autodep->omap_chip))
                return;
 
-       pwrdm = pwrdm_lookup(autodep->pwrdm_name);
+       pwrdm = pwrdm_lookup(autodep->pwrdm.name);
        if (!pwrdm) {
                pr_debug("clockdomain: _autodep_lookup: powerdomain %s "
-                        "does not exist\n", autodep->pwrdm_name);
+                        "does not exist\n", autodep->pwrdm.name);
                WARN_ON(1);
                return;
        }
-       autodep->pwrdm = pwrdm;
+       autodep->pwrdm.ptr = pwrdm;
 
        return;
 }
@@ -95,16 +95,16 @@ static void _clkdm_add_autodeps(struct clockdomain *clkdm)
 {
        struct clkdm_pwrdm_autodep *autodep;
 
-       for (autodep = autodeps; autodep->pwrdm_name; autodep++) {
-               if (!autodep->pwrdm)
+       for (autodep = autodeps; autodep->pwrdm.ptr; autodep++) {
+               if (!omap_chip_is(autodep->omap_chip))
                        continue;
 
                pr_debug("clockdomain: adding %s sleepdep/wkdep for "
-                        "pwrdm %s\n", autodep->pwrdm_name,
-                        clkdm->pwrdm->name);
+                        "pwrdm %s\n", autodep->pwrdm.ptr->name,
+                        clkdm->pwrdm.ptr->name);
 
-               pwrdm_add_sleepdep(clkdm->pwrdm, autodep->pwrdm);
-               pwrdm_add_wkdep(clkdm->pwrdm, autodep->pwrdm);
+               pwrdm_add_sleepdep(clkdm->pwrdm.ptr, autodep->pwrdm.ptr);
+               pwrdm_add_wkdep(clkdm->pwrdm.ptr, autodep->pwrdm.ptr);
        }
 }
 
@@ -120,16 +120,16 @@ static void _clkdm_del_autodeps(struct clockdomain *clkdm)
 {
        struct clkdm_pwrdm_autodep *autodep;
 
-       for (autodep = autodeps; autodep->pwrdm_name; autodep++) {
-               if (!autodep->pwrdm)
+       for (autodep = autodeps; autodep->pwrdm.ptr; autodep++) {
+               if (!omap_chip_is(autodep->omap_chip))
                        continue;
 
                pr_debug("clockdomain: removing %s sleepdep/wkdep for "
-                        "pwrdm %s\n", autodep->pwrdm_name,
-                        clkdm->pwrdm->name);
+                        "pwrdm %s\n", autodep->pwrdm.ptr->name,
+                        clkdm->pwrdm.ptr->name);
 
-               pwrdm_del_sleepdep(clkdm->pwrdm, autodep->pwrdm);
-               pwrdm_del_wkdep(clkdm->pwrdm, autodep->pwrdm);
+               pwrdm_del_sleepdep(clkdm->pwrdm.ptr, autodep->pwrdm.ptr);
+               pwrdm_del_wkdep(clkdm->pwrdm.ptr, autodep->pwrdm.ptr);
        }
 }
 
@@ -179,7 +179,7 @@ void clkdm_init(struct clockdomain **clkdms,
 
        autodeps = init_autodeps;
        if (autodeps)
-               for (autodep = autodeps; autodep->pwrdm_name; autodep++)
+               for (autodep = autodeps; autodep->pwrdm.ptr; autodep++)
                        _autodep_lookup(autodep);
 }
 
@@ -202,13 +202,13 @@ int clkdm_register(struct clockdomain *clkdm)
        if (!omap_chip_is(clkdm->omap_chip))
                return -EINVAL;
 
-       pwrdm = pwrdm_lookup(clkdm->pwrdm_name);
+       pwrdm = pwrdm_lookup(clkdm->pwrdm.name);
        if (!pwrdm) {
                pr_debug("clockdomain: clkdm_register %s: powerdomain %s "
-                        "does not exist\n", clkdm->name, clkdm->pwrdm_name);
+                        "does not exist\n", clkdm->name, clkdm->pwrdm.name);
                return -EINVAL;
        }
-       clkdm->pwrdm = pwrdm;
+       clkdm->pwrdm.ptr = pwrdm;
 
        mutex_lock(&clkdm_mutex);
        /* Verify that the clockdomain is not already registered */
@@ -242,7 +242,7 @@ int clkdm_unregister(struct clockdomain *clkdm)
        if (!clkdm)
                return -EINVAL;
 
-       pwrdm_del_clkdm(clkdm->pwrdm, clkdm);
+       pwrdm_del_clkdm(clkdm->pwrdm.ptr, clkdm);
 
        mutex_lock(&clkdm_mutex);
        list_del(&clkdm->node);
@@ -315,6 +315,22 @@ int clkdm_for_each(int (*fn)(struct clockdomain *clkdm))
 }
 
 
+/**
+ * clkdm_get_pwrdm - return a ptr to the pwrdm that this clkdm resides in
+ * @clkdm: struct clockdomain *
+ *
+ * Return a pointer to the struct powerdomain that the specified clockdomain
+ * 'clkdm' exists in, or returns NULL if clkdm argument is NULL.
+ */
+struct powerdomain *clkdm_get_pwrdm(struct clockdomain *clkdm)
+{
+       if (!clkdm)
+               return NULL;
+
+       return clkdm->pwrdm.ptr;
+}
+
+
 /* Hardware clockdomain control */
 
 /**
@@ -332,7 +348,7 @@ static int omap2_clkdm_clktrctrl_read(struct clockdomain *clkdm)
        if (!clkdm)
                return -EINVAL;
 
-       v = cm_read_mod_reg(clkdm->pwrdm->prcm_offs, CM_CLKSTCTRL);
+       v = cm_read_mod_reg(clkdm->pwrdm.ptr->prcm_offs, CM_CLKSTCTRL);
        v &= clkdm->clktrctrl_mask;
        v >>= __ffs(clkdm->clktrctrl_mask);
 
@@ -364,7 +380,7 @@ int omap2_clkdm_sleep(struct clockdomain *clkdm)
        if (cpu_is_omap24xx()) {
 
                cm_set_mod_reg_bits(OMAP24XX_FORCESTATE,
-                                   clkdm->pwrdm->prcm_offs, PM_PWSTCTRL);
+                                   clkdm->pwrdm.ptr->prcm_offs, PM_PWSTCTRL);
 
        } else if (cpu_is_omap34xx()) {
 
@@ -372,7 +388,7 @@ int omap2_clkdm_sleep(struct clockdomain *clkdm)
                         __ffs(clkdm->clktrctrl_mask));
 
                cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask, v,
-                                   clkdm->pwrdm->prcm_offs, CM_CLKSTCTRL);
+                                   clkdm->pwrdm.ptr->prcm_offs, CM_CLKSTCTRL);
 
        } else {
                BUG();
@@ -406,7 +422,7 @@ int omap2_clkdm_wakeup(struct clockdomain *clkdm)
        if (cpu_is_omap24xx()) {
 
                cm_clear_mod_reg_bits(OMAP24XX_FORCESTATE,
-                                     clkdm->pwrdm->prcm_offs, PM_PWSTCTRL);
+                                     clkdm->pwrdm.ptr->prcm_offs, PM_PWSTCTRL);
 
        } else if (cpu_is_omap34xx()) {
 
@@ -414,7 +430,7 @@ int omap2_clkdm_wakeup(struct clockdomain *clkdm)
                         __ffs(clkdm->clktrctrl_mask));
 
                cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask, v,
-                                   clkdm->pwrdm->prcm_offs, CM_CLKSTCTRL);
+                                   clkdm->pwrdm.ptr->prcm_offs, CM_CLKSTCTRL);
 
        } else {
                BUG();
@@ -462,7 +478,7 @@ void omap2_clkdm_allow_idle(struct clockdomain *clkdm)
 
        cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask,
                            v << __ffs(clkdm->clktrctrl_mask),
-                           clkdm->pwrdm->prcm_offs,
+                           clkdm->pwrdm.ptr->prcm_offs,
                            CM_CLKSTCTRL);
 }
 
@@ -500,7 +516,7 @@ void omap2_clkdm_deny_idle(struct clockdomain *clkdm)
 
        cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask,
                            v << __ffs(clkdm->clktrctrl_mask),
-                           clkdm->pwrdm->prcm_offs, CM_CLKSTCTRL);
+                           clkdm->pwrdm.ptr->prcm_offs, CM_CLKSTCTRL);
 
        if (atomic_read(&clkdm->usecount) > 0)
                _clkdm_del_autodeps(clkdm);