omap4: Fix build break by moving omap_smc1 into a separate .S
[safe/jmp/linux-2.6] / arch / arm / mach-omap2 / powerdomain.c
index c0de050..9a0fb38 100644 (file)
@@ -2,7 +2,7 @@
  * OMAP powerdomain control
  *
  * Copyright (C) 2007-2008 Texas Instruments, Inc.
- * Copyright (C) 2007-2008 Nokia Corporation
+ * Copyright (C) 2007-2009 Nokia Corporation
  *
  * Written by Paul Walmsley
  *
@@ -36,6 +36,7 @@
 #include <plat/cpu.h>
 #include <plat/powerdomain.h>
 #include <plat/clockdomain.h>
+#include <plat/prcm.h>
 
 #include "pm.h"
 
@@ -79,26 +80,8 @@ static u16 pwrstst_reg_offs;
 /* pwrdm_list contains all registered struct powerdomains */
 static LIST_HEAD(pwrdm_list);
 
-/*
- * pwrdm_rwlock protects pwrdm_list add and del ops - also reused to
- * protect pwrdm_clkdms[] during clkdm add/del ops
- */
-static DEFINE_RWLOCK(pwrdm_rwlock);
-
-
 /* Private functions */
 
-static u32 prm_read_mod_bits_shift(s16 domain, s16 idx, u32 mask)
-{
-       u32 v;
-
-       v = prm_read_mod_reg(domain, idx);
-       v &= mask;
-       v >>= __ffs(mask);
-
-       return v;
-}
-
 static struct powerdomain *_pwrdm_lookup(const char *name)
 {
        struct powerdomain *pwrdm, *temp_pwrdm;
@@ -115,32 +98,63 @@ static struct powerdomain *_pwrdm_lookup(const char *name)
        return pwrdm;
 }
 
-/* _pwrdm_deps_lookup - look up the specified powerdomain in a pwrdm list */
-static struct powerdomain *_pwrdm_deps_lookup(struct powerdomain *pwrdm,
-                                             struct pwrdm_dep *deps)
+/**
+ * _pwrdm_register - register a powerdomain
+ * @pwrdm: struct powerdomain * to register
+ *
+ * Adds a powerdomain to the internal powerdomain list.  Returns
+ * -EINVAL if given a null pointer, -EEXIST if a powerdomain is
+ * already registered by the provided name, or 0 upon success.
+ */
+static int _pwrdm_register(struct powerdomain *pwrdm)
 {
-       struct pwrdm_dep *pd;
+       int i;
+
+       if (!pwrdm)
+               return -EINVAL;
 
-       if (!pwrdm || !deps || !omap_chip_is(pwrdm->omap_chip))
-               return ERR_PTR(-EINVAL);
+       if (!omap_chip_is(pwrdm->omap_chip))
+               return -EINVAL;
 
-       for (pd = deps; pd->pwrdm_name; pd++) {
+       if (_pwrdm_lookup(pwrdm->name))
+               return -EEXIST;
 
-               if (!omap_chip_is(pd->omap_chip))
-                       continue;
+       list_add(&pwrdm->node, &pwrdm_list);
 
-               if (!pd->pwrdm && pd->pwrdm_name)
-                       pd->pwrdm = pwrdm_lookup(pd->pwrdm_name);
+       /* Initialize the powerdomain's state counter */
+       for (i = 0; i < PWRDM_MAX_PWRSTS; i++)
+               pwrdm->state_counter[i] = 0;
 
-               if (pd->pwrdm == pwrdm)
-                       break;
+       pwrdm->ret_logic_off_counter = 0;
+       for (i = 0; i < pwrdm->banks; i++)
+               pwrdm->ret_mem_off_counter[i] = 0;
 
-       }
+       pwrdm_wait_transition(pwrdm);
+       pwrdm->state = pwrdm_read_pwrst(pwrdm);
+       pwrdm->state_counter[pwrdm->state] = 1;
 
-       if (!pd->pwrdm_name)
-               return ERR_PTR(-ENOENT);
+       pr_debug("powerdomain: registered %s\n", pwrdm->name);
 
-       return pd->pwrdm;
+       return 0;
+}
+
+static void _update_logic_membank_counters(struct powerdomain *pwrdm)
+{
+       int i;
+       u8 prev_logic_pwrst, prev_mem_pwrst;
+
+       prev_logic_pwrst = pwrdm_read_prev_logic_pwrst(pwrdm);
+       if ((pwrdm->pwrsts_logic_ret == PWRSTS_OFF_RET) &&
+           (prev_logic_pwrst == PWRDM_POWER_OFF))
+               pwrdm->ret_logic_off_counter++;
+
+       for (i = 0; i < pwrdm->banks; i++) {
+               prev_mem_pwrst = pwrdm_read_prev_mem_pwrst(pwrdm, i);
+
+               if ((pwrdm->pwrsts_mem_ret[i] == PWRSTS_OFF_RET) &&
+                   (prev_mem_pwrst == PWRDM_POWER_OFF))
+                       pwrdm->ret_mem_off_counter[i]++;
+       }
 }
 
 static int _pwrdm_state_switch(struct powerdomain *pwrdm, int flag)
@@ -162,6 +176,8 @@ static int _pwrdm_state_switch(struct powerdomain *pwrdm, int flag)
                prev = pwrdm_read_prev_pwrst(pwrdm);
                if (pwrdm->state != prev)
                        pwrdm->state_counter[prev]++;
+               if (prev == PWRDM_POWER_RET)
+                       _update_logic_membank_counters(pwrdm);
                break;
        default:
                return -EINVAL;
@@ -190,28 +206,17 @@ static int _pwrdm_post_transition_cb(struct powerdomain *pwrdm, void *unused)
        return 0;
 }
 
-static __init void _pwrdm_setup(struct powerdomain *pwrdm)
-{
-       int i;
-
-       for (i = 0; i < PWRDM_MAX_PWRSTS; i++)
-               pwrdm->state_counter[i] = 0;
-
-       pwrdm_wait_transition(pwrdm);
-       pwrdm->state = pwrdm_read_pwrst(pwrdm);
-       pwrdm->state_counter[pwrdm->state] = 1;
-
-}
-
 /* Public functions */
 
 /**
  * pwrdm_init - set up the powerdomain layer
+ * @pwrdm_list: array of struct powerdomain pointers to register
  *
- * Loop through the list of powerdomains, registering all that are
- * available on the current CPU. If pwrdm_list is supplied and not
- * null, all of the referenced powerdomains will be registered.  No
- * return value.
+ * Loop through the array of powerdomains @pwrdm_list, registering all
+ * that are available on the current CPU. If pwrdm_list is supplied
+ * and not null, all of the referenced powerdomains will be
+ * registered.  No return value.  XXX pwrdm_list is not really a
+ * "list"; it is an array.  Rename appropriately.
  */
 void pwrdm_init(struct powerdomain **pwrdm_list)
 {
@@ -230,106 +235,42 @@ void pwrdm_init(struct powerdomain **pwrdm_list)
        }
 
        if (pwrdm_list) {
-               for (p = pwrdm_list; *p; p++) {
-                       pwrdm_register(*p);
-                       _pwrdm_setup(*p);
-               }
+               for (p = pwrdm_list; *p; p++)
+                       _pwrdm_register(*p);
        }
 }
 
 /**
- * pwrdm_register - register a powerdomain
- * @pwrdm: struct powerdomain * to register
- *
- * Adds a powerdomain to the internal powerdomain list.  Returns
- * -EINVAL if given a null pointer, -EEXIST if a powerdomain is
- * already registered by the provided name, or 0 upon success.
- */
-int pwrdm_register(struct powerdomain *pwrdm)
-{
-       unsigned long flags;
-       int ret = -EINVAL;
-
-       if (!pwrdm)
-               return -EINVAL;
-
-       if (!omap_chip_is(pwrdm->omap_chip))
-               return -EINVAL;
-
-       write_lock_irqsave(&pwrdm_rwlock, flags);
-       if (_pwrdm_lookup(pwrdm->name)) {
-               ret = -EEXIST;
-               goto pr_unlock;
-       }
-
-       list_add(&pwrdm->node, &pwrdm_list);
-
-       pr_debug("powerdomain: registered %s\n", pwrdm->name);
-       ret = 0;
-
-pr_unlock:
-       write_unlock_irqrestore(&pwrdm_rwlock, flags);
-
-       return ret;
-}
-
-/**
- * pwrdm_unregister - unregister a powerdomain
- * @pwrdm: struct powerdomain * to unregister
- *
- * Removes a powerdomain from the internal powerdomain list.  Returns
- * -EINVAL if pwrdm argument is NULL.
- */
-int pwrdm_unregister(struct powerdomain *pwrdm)
-{
-       unsigned long flags;
-
-       if (!pwrdm)
-               return -EINVAL;
-
-       write_lock_irqsave(&pwrdm_rwlock, flags);
-       list_del(&pwrdm->node);
-       write_unlock_irqrestore(&pwrdm_rwlock, flags);
-
-       pr_debug("powerdomain: unregistered %s\n", pwrdm->name);
-
-       return 0;
-}
-
-/**
  * pwrdm_lookup - look up a powerdomain by name, return a pointer
  * @name: name of powerdomain
  *
- * Find a registered powerdomain by its name.  Returns a pointer to the
- * struct powerdomain if found, or NULL otherwise.
+ * Find a registered powerdomain by its name @name.  Returns a pointer
+ * to the struct powerdomain if found, or NULL otherwise.
  */
 struct powerdomain *pwrdm_lookup(const char *name)
 {
        struct powerdomain *pwrdm;
-       unsigned long flags;
 
        if (!name)
                return NULL;
 
-       read_lock_irqsave(&pwrdm_rwlock, flags);
        pwrdm = _pwrdm_lookup(name);
-       read_unlock_irqrestore(&pwrdm_rwlock, flags);
 
        return pwrdm;
 }
 
 /**
- * pwrdm_for_each_nolock - call function on each registered clockdomain
+ * pwrdm_for_each - call function on each registered clockdomain
  * @fn: callback function *
  *
- * Call the supplied function for each registered powerdomain.  The
- * callback function can return anything but 0 to bail out early from
- * the iterator.  Returns the last return value of the callback function, which
- * should be 0 for success or anything else to indicate failure; or -EINVAL if
- * the function pointer is null.
+ * Call the supplied function @fn for each registered powerdomain.
+ * The callback function @fn can return anything but 0 to bail out
+ * early from the iterator.  Returns the last return value of the
+ * callback function, which should be 0 for success or anything else
+ * to indicate failure; or -EINVAL if the function pointer is null.
  */
-int pwrdm_for_each_nolock(int (*fn)(struct powerdomain *pwrdm, void *user),
-                               void *user)
+int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm, void *user),
+                  void *user)
 {
        struct powerdomain *temp_pwrdm;
        int ret = 0;
@@ -347,40 +288,17 @@ int pwrdm_for_each_nolock(int (*fn)(struct powerdomain *pwrdm, void *user),
 }
 
 /**
- * pwrdm_for_each - call function on each registered clockdomain
- * @fn: callback function *
- *
- * This function is the same as 'pwrdm_for_each_nolock()', but keeps the
- * &pwrdm_rwlock locked for reading, so no powerdomain structure manipulation
- * functions should be called from the callback, although hardware powerdomain
- * control functions are fine.
- */
-int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm, void *user),
-                       void *user)
-{
-       unsigned long flags;
-       int ret;
-
-       read_lock_irqsave(&pwrdm_rwlock, flags);
-       ret = pwrdm_for_each_nolock(fn, user);
-       read_unlock_irqrestore(&pwrdm_rwlock, flags);
-
-       return ret;
-}
-
-/**
  * pwrdm_add_clkdm - add a clockdomain to a powerdomain
  * @pwrdm: struct powerdomain * to add the clockdomain to
  * @clkdm: struct clockdomain * to associate with a powerdomain
  *
- * Associate the clockdomain 'clkdm' with a powerdomain 'pwrdm'.  This
+ * Associate the clockdomain @clkdm with a powerdomain @pwrdm.  This
  * enables the use of pwrdm_for_each_clkdm().  Returns -EINVAL if
  * presented with invalid pointers; -ENOMEM if memory could not be allocated;
  * or 0 upon success.
  */
 int pwrdm_add_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm)
 {
-       unsigned long flags;
        int i;
        int ret = -EINVAL;
 
@@ -390,8 +308,6 @@ int pwrdm_add_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm)
        pr_debug("powerdomain: associating clockdomain %s with powerdomain "
                 "%s\n", clkdm->name, pwrdm->name);
 
-       write_lock_irqsave(&pwrdm_rwlock, flags);
-
        for (i = 0; i < PWRDM_MAX_CLKDMS; i++) {
                if (!pwrdm->pwrdm_clkdms[i])
                        break;
@@ -416,8 +332,6 @@ int pwrdm_add_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm)
        ret = 0;
 
 pac_exit:
-       write_unlock_irqrestore(&pwrdm_rwlock, flags);
-
        return ret;
 }
 
@@ -426,14 +340,13 @@ pac_exit:
  * @pwrdm: struct powerdomain * to add the clockdomain to
  * @clkdm: struct clockdomain * to associate with a powerdomain
  *
- * Dissociate the clockdomain 'clkdm' from the powerdomain
- * 'pwrdm'. Returns -EINVAL if presented with invalid pointers;
- * -ENOENT if the clkdm was not associated with the powerdomain, or 0
- * upon success.
+ * Dissociate the clockdomain @clkdm from the powerdomain
+ * @pwrdm. Returns -EINVAL if presented with invalid pointers; -ENOENT
+ * if @clkdm was not associated with the powerdomain, or 0 upon
+ * success.
  */
 int pwrdm_del_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm)
 {
-       unsigned long flags;
        int ret = -EINVAL;
        int i;
 
@@ -443,8 +356,6 @@ int pwrdm_del_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm)
        pr_debug("powerdomain: dissociating clockdomain %s from powerdomain "
                 "%s\n", clkdm->name, pwrdm->name);
 
-       write_lock_irqsave(&pwrdm_rwlock, flags);
-
        for (i = 0; i < PWRDM_MAX_CLKDMS; i++)
                if (pwrdm->pwrdm_clkdms[i] == clkdm)
                        break;
@@ -461,8 +372,6 @@ int pwrdm_del_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm)
        ret = 0;
 
 pdc_exit:
-       write_unlock_irqrestore(&pwrdm_rwlock, flags);
-
        return ret;
 }
 
@@ -471,259 +380,34 @@ pdc_exit:
  * @pwrdm: struct powerdomain * to iterate over
  * @fn: callback function *
  *
- * Call the supplied function for each clockdomain in the powerdomain
- * 'pwrdm'.  The callback function can return anything but 0 to bail
- * out early from the iterator.  The callback function is called with
- * the pwrdm_rwlock held for reading, so no powerdomain structure
- * manipulation functions should be called from the callback, although
- * hardware powerdomain control functions are fine.  Returns -EINVAL
- * if presented with invalid pointers; or passes along the last return
- * value of the callback function, which should be 0 for success or
- * anything else to indicate failure.
+ * Call the supplied function @fn for each clockdomain in the powerdomain
+ * @pwrdm.  The callback function can return anything but 0 to bail
+ * out early from the iterator.  Returns -EINVAL if presented with
+ * invalid pointers; or passes along the last return value of the
+ * callback function, which should be 0 for success or anything else
+ * to indicate failure.
  */
 int pwrdm_for_each_clkdm(struct powerdomain *pwrdm,
                         int (*fn)(struct powerdomain *pwrdm,
                                   struct clockdomain *clkdm))
 {
-       unsigned long flags;
        int ret = 0;
        int i;
 
        if (!fn)
                return -EINVAL;
 
-       read_lock_irqsave(&pwrdm_rwlock, flags);
-
        for (i = 0; i < PWRDM_MAX_CLKDMS && !ret; i++)
                ret = (*fn)(pwrdm, pwrdm->pwrdm_clkdms[i]);
 
-       read_unlock_irqrestore(&pwrdm_rwlock, flags);
-
        return ret;
 }
 
-
-/**
- * pwrdm_add_wkdep - add a wakeup dependency from pwrdm2 to pwrdm1
- * @pwrdm1: wake this struct powerdomain * up (dependent)
- * @pwrdm2: when this struct powerdomain * wakes up (source)
- *
- * When the powerdomain represented by pwrdm2 wakes up (due to an
- * interrupt), wake up pwrdm1. Implemented in hardware on the OMAP,
- * this feature is designed to reduce wakeup latency of the dependent
- * powerdomain.  Returns -EINVAL if presented with invalid powerdomain
- * pointers, -ENOENT if pwrdm2 cannot wake up pwrdm1 in hardware, or
- * 0 upon success.
- */
-int pwrdm_add_wkdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2)
-{
-       struct powerdomain *p;
-
-       if (!pwrdm1)
-               return -EINVAL;
-
-       p = _pwrdm_deps_lookup(pwrdm2, pwrdm1->wkdep_srcs);
-       if (IS_ERR(p)) {
-               pr_debug("powerdomain: hardware cannot set/clear wake up of "
-                        "%s when %s wakes up\n", pwrdm1->name, pwrdm2->name);
-               return PTR_ERR(p);
-       }
-
-       pr_debug("powerdomain: hardware will wake up %s when %s wakes up\n",
-                pwrdm1->name, pwrdm2->name);
-
-       prm_set_mod_reg_bits((1 << pwrdm2->dep_bit),
-                            pwrdm1->prcm_offs, PM_WKDEP);
-
-       return 0;
-}
-
-/**
- * pwrdm_del_wkdep - remove a wakeup dependency from pwrdm2 to pwrdm1
- * @pwrdm1: wake this struct powerdomain * up (dependent)
- * @pwrdm2: when this struct powerdomain * wakes up (source)
- *
- * Remove a wakeup dependency that causes pwrdm1 to wake up when pwrdm2
- * wakes up.  Returns -EINVAL if presented with invalid powerdomain
- * pointers, -ENOENT if pwrdm2 cannot wake up pwrdm1 in hardware, or
- * 0 upon success.
- */
-int pwrdm_del_wkdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2)
-{
-       struct powerdomain *p;
-
-       if (!pwrdm1)
-               return -EINVAL;
-
-       p = _pwrdm_deps_lookup(pwrdm2, pwrdm1->wkdep_srcs);
-       if (IS_ERR(p)) {
-               pr_debug("powerdomain: hardware cannot set/clear wake up of "
-                        "%s when %s wakes up\n", pwrdm1->name, pwrdm2->name);
-               return PTR_ERR(p);
-       }
-
-       pr_debug("powerdomain: hardware will no longer wake up %s after %s "
-                "wakes up\n", pwrdm1->name, pwrdm2->name);
-
-       prm_clear_mod_reg_bits((1 << pwrdm2->dep_bit),
-                              pwrdm1->prcm_offs, PM_WKDEP);
-
-       return 0;
-}
-
-/**
- * pwrdm_read_wkdep - read wakeup dependency state from pwrdm2 to pwrdm1
- * @pwrdm1: wake this struct powerdomain * up (dependent)
- * @pwrdm2: when this struct powerdomain * wakes up (source)
- *
- * Return 1 if a hardware wakeup dependency exists wherein pwrdm1 will be
- * awoken when pwrdm2 wakes up; 0 if dependency is not set; -EINVAL
- * if either powerdomain pointer is invalid; or -ENOENT if the hardware
- * is incapable.
- *
- * REVISIT: Currently this function only represents software-controllable
- * wakeup dependencies.  Wakeup dependencies fixed in hardware are not
- * yet handled here.
- */
-int pwrdm_read_wkdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2)
-{
-       struct powerdomain *p;
-
-       if (!pwrdm1)
-               return -EINVAL;
-
-       p = _pwrdm_deps_lookup(pwrdm2, pwrdm1->wkdep_srcs);
-       if (IS_ERR(p)) {
-               pr_debug("powerdomain: hardware cannot set/clear wake up of "
-                        "%s when %s wakes up\n", pwrdm1->name, pwrdm2->name);
-               return PTR_ERR(p);
-       }
-
-       return prm_read_mod_bits_shift(pwrdm1->prcm_offs, PM_WKDEP,
-                                       (1 << pwrdm2->dep_bit));
-}
-
-/**
- * pwrdm_add_sleepdep - add a sleep dependency from pwrdm2 to pwrdm1
- * @pwrdm1: prevent this struct powerdomain * from sleeping (dependent)
- * @pwrdm2: when this struct powerdomain * is active (source)
- *
- * Prevent pwrdm1 from automatically going inactive (and then to
- * retention or off) if pwrdm2 is still active.         Returns -EINVAL if
- * presented with invalid powerdomain pointers or called on a machine
- * that does not support software-configurable hardware sleep dependencies,
- * -ENOENT if the specified dependency cannot be set in hardware, or
- * 0 upon success.
- */
-int pwrdm_add_sleepdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2)
-{
-       struct powerdomain *p;
-
-       if (!cpu_is_omap34xx())
-               return -EINVAL;
-
-       if (!pwrdm1)
-               return -EINVAL;
-
-       p = _pwrdm_deps_lookup(pwrdm2, pwrdm1->sleepdep_srcs);
-       if (IS_ERR(p)) {
-               pr_debug("powerdomain: hardware cannot set/clear sleep "
-                        "dependency affecting %s from %s\n", pwrdm1->name,
-                        pwrdm2->name);
-               return PTR_ERR(p);
-       }
-
-       pr_debug("powerdomain: will prevent %s from sleeping if %s is active\n",
-                pwrdm1->name, pwrdm2->name);
-
-       cm_set_mod_reg_bits((1 << pwrdm2->dep_bit),
-                           pwrdm1->prcm_offs, OMAP3430_CM_SLEEPDEP);
-
-       return 0;
-}
-
-/**
- * pwrdm_del_sleepdep - remove a sleep dependency from pwrdm2 to pwrdm1
- * @pwrdm1: prevent this struct powerdomain * from sleeping (dependent)
- * @pwrdm2: when this struct powerdomain * is active (source)
- *
- * Allow pwrdm1 to automatically go inactive (and then to retention or
- * off), independent of the activity state of pwrdm2.  Returns -EINVAL
- * if presented with invalid powerdomain pointers or called on a machine
- * that does not support software-configurable hardware sleep dependencies,
- * -ENOENT if the specified dependency cannot be cleared in hardware, or
- * 0 upon success.
- */
-int pwrdm_del_sleepdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2)
-{
-       struct powerdomain *p;
-
-       if (!cpu_is_omap34xx())
-               return -EINVAL;
-
-       if (!pwrdm1)
-               return -EINVAL;
-
-       p = _pwrdm_deps_lookup(pwrdm2, pwrdm1->sleepdep_srcs);
-       if (IS_ERR(p)) {
-               pr_debug("powerdomain: hardware cannot set/clear sleep "
-                        "dependency affecting %s from %s\n", pwrdm1->name,
-                        pwrdm2->name);
-               return PTR_ERR(p);
-       }
-
-       pr_debug("powerdomain: will no longer prevent %s from sleeping if "
-                "%s is active\n", pwrdm1->name, pwrdm2->name);
-
-       cm_clear_mod_reg_bits((1 << pwrdm2->dep_bit),
-                             pwrdm1->prcm_offs, OMAP3430_CM_SLEEPDEP);
-
-       return 0;
-}
-
-/**
- * pwrdm_read_sleepdep - read sleep dependency state from pwrdm2 to pwrdm1
- * @pwrdm1: prevent this struct powerdomain * from sleeping (dependent)
- * @pwrdm2: when this struct powerdomain * is active (source)
- *
- * Return 1 if a hardware sleep dependency exists wherein pwrdm1 will
- * not be allowed to automatically go inactive if pwrdm2 is active;
- * 0 if pwrdm1's automatic power state inactivity transition is independent
- * of pwrdm2's; -EINVAL if either powerdomain pointer is invalid or called
- * on a machine that does not support software-configurable hardware sleep
- * dependencies; or -ENOENT if the hardware is incapable.
- *
- * REVISIT: Currently this function only represents software-controllable
- * sleep dependencies. Sleep dependencies fixed in hardware are not
- * yet handled here.
- */
-int pwrdm_read_sleepdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2)
-{
-       struct powerdomain *p;
-
-       if (!cpu_is_omap34xx())
-               return -EINVAL;
-
-       if (!pwrdm1)
-               return -EINVAL;
-
-       p = _pwrdm_deps_lookup(pwrdm2, pwrdm1->sleepdep_srcs);
-       if (IS_ERR(p)) {
-               pr_debug("powerdomain: hardware cannot set/clear sleep "
-                        "dependency affecting %s from %s\n", pwrdm1->name,
-                        pwrdm2->name);
-               return PTR_ERR(p);
-       }
-
-       return prm_read_mod_bits_shift(pwrdm1->prcm_offs, OMAP3430_CM_SLEEPDEP,
-                                       (1 << pwrdm2->dep_bit));
-}
-
 /**
  * pwrdm_get_mem_bank_count - get number of memory banks in this powerdomain
  * @pwrdm: struct powerdomain *
  *
- * Return the number of controllable memory banks in powerdomain pwrdm,
+ * Return the number of controllable memory banks in powerdomain @pwrdm,
  * starting with 1.  Returns -EINVAL if the powerdomain pointer is null.
  */
 int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm)
@@ -739,7 +423,7 @@ int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm)
  * @pwrdm: struct powerdomain * to set
  * @pwrst: one of the PWRDM_POWER_* macros
  *
- * Set the powerdomain pwrdm's next power state to pwrst.  The powerdomain
+ * Set the powerdomain @pwrdm's next power state to @pwrst.  The powerdomain
  * may not enter this state immediately if the preconditions for this state
  * have not been satisfied.  Returns -EINVAL if the powerdomain pointer is
  * null or if the power state is invalid for the powerdomin, or returns 0
@@ -767,7 +451,7 @@ int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst)
  * pwrdm_read_next_pwrst - get next powerdomain power state
  * @pwrdm: struct powerdomain * to get power state
  *
- * Return the powerdomain pwrdm's next power state.  Returns -EINVAL
+ * Return the powerdomain @pwrdm's next power state.  Returns -EINVAL
  * if the powerdomain pointer is null or returns the next power state
  * upon success.
  */
@@ -784,7 +468,7 @@ int pwrdm_read_next_pwrst(struct powerdomain *pwrdm)
  * pwrdm_read_pwrst - get current powerdomain power state
  * @pwrdm: struct powerdomain * to get power state
  *
- * Return the powerdomain pwrdm's current power state. Returns -EINVAL
+ * Return the powerdomain @pwrdm's current power state.        Returns -EINVAL
  * if the powerdomain pointer is null or returns the current power state
  * upon success.
  */
@@ -801,7 +485,7 @@ int pwrdm_read_pwrst(struct powerdomain *pwrdm)
  * pwrdm_read_prev_pwrst - get previous powerdomain power state
  * @pwrdm: struct powerdomain * to get previous power state
  *
- * Return the powerdomain pwrdm's previous power state.  Returns -EINVAL
+ * Return the powerdomain @pwrdm's previous power state.  Returns -EINVAL
  * if the powerdomain pointer is null or returns the previous power state
  * upon success.
  */
@@ -819,11 +503,11 @@ int pwrdm_read_prev_pwrst(struct powerdomain *pwrdm)
  * @pwrdm: struct powerdomain * to set
  * @pwrst: one of the PWRDM_POWER_* macros
  *
- * Set the next power state that the logic portion of the powerdomain
- * pwrdm will enter when the powerdomain enters retention.  This will
- * be either RETENTION or OFF, if supported.  Returns -EINVAL if the
- * powerdomain pointer is null or the target power state is not not
- * supported, or returns 0 upon success.
+ * Set the next power state @pwrst that the logic portion of the
+ * powerdomain @pwrdm will enter when the powerdomain enters retention.
+ * This will be either RETENTION or OFF, if supported.  Returns
+ * -EINVAL if the powerdomain pointer is null or the target power
+ * state is not not supported, or returns 0 upon success.
  */
 int pwrdm_set_logic_retst(struct powerdomain *pwrdm, u8 pwrst)
 {
@@ -855,13 +539,14 @@ int pwrdm_set_logic_retst(struct powerdomain *pwrdm, u8 pwrst)
  * @bank: memory bank number to set (0-3)
  * @pwrst: one of the PWRDM_POWER_* macros
  *
- * Set the next power state that memory bank x of the powerdomain
- * pwrdm will enter when the powerdomain enters the ON state.  Bank
- * will be a number from 0 to 3, and represents different types of
- * memory, depending on the powerdomain.  Returns -EINVAL if the
- * powerdomain pointer is null or the target power state is not not
- * supported for this memory bank, -EEXIST if the target memory bank
- * does not exist or is not controllable, or returns 0 upon success.
+ * Set the next power state @pwrst that memory bank @bank of the
+ * powerdomain @pwrdm will enter when the powerdomain enters the ON
+ * state.  @bank will be a number from 0 to 3, and represents different
+ * types of memory, depending on the powerdomain.  Returns -EINVAL if
+ * the powerdomain pointer is null or the target power state is not
+ * not supported for this memory bank, -EEXIST if the target memory
+ * bank does not exist or is not controllable, or returns 0 upon
+ * success.
  */
 int pwrdm_set_mem_onst(struct powerdomain *pwrdm, u8 bank, u8 pwrst)
 {
@@ -918,14 +603,15 @@ int pwrdm_set_mem_onst(struct powerdomain *pwrdm, u8 bank, u8 pwrst)
  * @bank: memory bank number to set (0-3)
  * @pwrst: one of the PWRDM_POWER_* macros
  *
- * Set the next power state that memory bank x of the powerdomain
- * pwrdm will enter when the powerdomain enters the RETENTION state.
- * Bank will be a number from 0 to 3, and represents different types
- * of memory, depending on the powerdomain.  pwrst will be either
- * RETENTION or OFF, if supported. Returns -EINVAL if the powerdomain
- * pointer is null or the target power state is not not supported for
- * this memory bank, -EEXIST if the target memory bank does not exist
- * or is not controllable, or returns 0 upon success.
+ * Set the next power state @pwrst that memory bank @bank of the
+ * powerdomain @pwrdm will enter when the powerdomain enters the
+ * RETENTION state.  Bank will be a number from 0 to 3, and represents
+ * different types of memory, depending on the powerdomain.  @pwrst
+ * will be either RETENTION or OFF, if supported.  Returns -EINVAL if
+ * the powerdomain pointer is null or the target power state is not
+ * not supported for this memory bank, -EEXIST if the target memory
+ * bank does not exist or is not controllable, or returns 0 upon
+ * success.
  */
 int pwrdm_set_mem_retst(struct powerdomain *pwrdm, u8 bank, u8 pwrst)
 {
@@ -980,10 +666,10 @@ int pwrdm_set_mem_retst(struct powerdomain *pwrdm, u8 bank, u8 pwrst)
  * pwrdm_read_logic_pwrst - get current powerdomain logic retention power state
  * @pwrdm: struct powerdomain * to get current logic retention power state
  *
- * Return the current power state that the logic portion of
- * powerdomain pwrdm will enter
- * Returns -EINVAL if the powerdomain pointer is null or returns the
- * current logic retention power state upon success.
+ * Return the power state that the logic portion of powerdomain @pwrdm
+ * will enter when the powerdomain enters retention.  Returns -EINVAL
+ * if the powerdomain pointer is null or returns the logic retention
+ * power state upon success.
  */
 int pwrdm_read_logic_pwrst(struct powerdomain *pwrdm)
 {
@@ -998,9 +684,9 @@ int pwrdm_read_logic_pwrst(struct powerdomain *pwrdm)
  * pwrdm_read_prev_logic_pwrst - get previous powerdomain logic power state
  * @pwrdm: struct powerdomain * to get previous logic power state
  *
- * Return the powerdomain pwrdm's logic power state.  Returns -EINVAL
- * if the powerdomain pointer is null or returns the previous logic
- * power state upon success.
+ * Return the powerdomain @pwrdm's previous logic power state.  Returns
+ * -EINVAL if the powerdomain pointer is null or returns the previous
+ * logic power state upon success.
  */
 int pwrdm_read_prev_logic_pwrst(struct powerdomain *pwrdm)
 {
@@ -1018,12 +704,35 @@ int pwrdm_read_prev_logic_pwrst(struct powerdomain *pwrdm)
 }
 
 /**
+ * pwrdm_read_logic_retst - get next powerdomain logic power state
+ * @pwrdm: struct powerdomain * to get next logic power state
+ *
+ * Return the powerdomain pwrdm's logic power state.  Returns -EINVAL
+ * if the powerdomain pointer is null or returns the next logic
+ * power state upon success.
+ */
+int pwrdm_read_logic_retst(struct powerdomain *pwrdm)
+{
+       if (!pwrdm)
+               return -EINVAL;
+
+       /*
+        * The register bit names below may not correspond to the
+        * actual names of the bits in each powerdomain's register,
+        * but the type of value returned is the same for each
+        * powerdomain.
+        */
+       return prm_read_mod_bits_shift(pwrdm->prcm_offs, pwrstctrl_reg_offs,
+                                       OMAP3430_LOGICSTATEST);
+}
+
+/**
  * pwrdm_read_mem_pwrst - get current memory bank power state
  * @pwrdm: struct powerdomain * to get current memory bank power state
  * @bank: memory bank number (0-3)
  *
- * Return the powerdomain pwrdm's current memory power state for bank
- * x.  Returns -EINVAL if the powerdomain pointer is null, -EEXIST if
+ * Return the powerdomain @pwrdm's current memory power state for bank
+ * @bank.  Returns -EINVAL if the powerdomain pointer is null, -EEXIST if
  * the target memory bank does not exist or is not controllable, or
  * returns the current memory power state upon success.
  */
@@ -1076,10 +785,11 @@ int pwrdm_read_mem_pwrst(struct powerdomain *pwrdm, u8 bank)
  * @pwrdm: struct powerdomain * to get previous memory bank power state
  * @bank: memory bank number (0-3)
  *
- * Return the powerdomain pwrdm's previous memory power state for bank
- * x.  Returns -EINVAL if the powerdomain pointer is null, -EEXIST if
- * the target memory bank does not exist or is not controllable, or
- * returns the previous memory power state upon success.
+ * Return the powerdomain @pwrdm's previous memory power state for
+ * bank @bank.  Returns -EINVAL if the powerdomain pointer is null,
+ * -EEXIST if the target memory bank does not exist or is not
+ * controllable, or returns the previous memory power state upon
+ * success.
  */
 int pwrdm_read_prev_mem_pwrst(struct powerdomain *pwrdm, u8 bank)
 {
@@ -1123,13 +833,63 @@ int pwrdm_read_prev_mem_pwrst(struct powerdomain *pwrdm, u8 bank)
 }
 
 /**
+ * pwrdm_read_mem_retst - get next memory bank power state
+ * @pwrdm: struct powerdomain * to get mext memory bank power state
+ * @bank: memory bank number (0-3)
+ *
+ * Return the powerdomain pwrdm's next memory power state for bank
+ * x.  Returns -EINVAL if the powerdomain pointer is null, -EEXIST if
+ * the target memory bank does not exist or is not controllable, or
+ * returns the next memory power state upon success.
+ */
+int pwrdm_read_mem_retst(struct powerdomain *pwrdm, u8 bank)
+{
+       u32 m;
+
+       if (!pwrdm)
+               return -EINVAL;
+
+       if (pwrdm->banks < (bank + 1))
+               return -EEXIST;
+
+       /*
+        * The register bit names below may not correspond to the
+        * actual names of the bits in each powerdomain's register,
+        * but the type of value returned is the same for each
+        * powerdomain.
+        */
+       switch (bank) {
+       case 0:
+               m = OMAP_MEM0_RETSTATE_MASK;
+               break;
+       case 1:
+               m = OMAP_MEM1_RETSTATE_MASK;
+               break;
+       case 2:
+               m = OMAP_MEM2_RETSTATE_MASK;
+               break;
+       case 3:
+               m = OMAP_MEM3_RETSTATE_MASK;
+               break;
+       case 4:
+               m = OMAP_MEM4_RETSTATE_MASK;
+       default:
+               WARN_ON(1); /* should never happen */
+               return -EEXIST;
+       }
+
+       return prm_read_mod_bits_shift(pwrdm->prcm_offs,
+                                       pwrstctrl_reg_offs, m);
+}
+
+/**
  * pwrdm_clear_all_prev_pwrst - clear previous powerstate register for a pwrdm
  * @pwrdm: struct powerdomain * to clear
  *
- * Clear the powerdomain's previous power state register.  Clears the
- * entire register, including logic and memory bank previous power states.
- * Returns -EINVAL if the powerdomain pointer is null, or returns 0 upon
- * success.
+ * Clear the powerdomain's previous power state register @pwrdm.
+ * Clears the entire register, including logic and memory bank
+ * previous power states.  Returns -EINVAL if the powerdomain pointer
+ * is null, or returns 0 upon success.
  */
 int pwrdm_clear_all_prev_pwrst(struct powerdomain *pwrdm)
 {
@@ -1154,11 +914,11 @@ int pwrdm_clear_all_prev_pwrst(struct powerdomain *pwrdm)
  * @pwrdm: struct powerdomain *
  *
  * Enable automatic context save-and-restore upon power state change
- * for some devices in a powerdomain.  Warning: this only affects a
- * subset of devices in a powerdomain; check the TRM closely.  Returns
- * -EINVAL if the powerdomain pointer is null or if the powerdomain
- * does not support automatic save-and-restore, or returns 0 upon
- * success.
+ * for some devices in the powerdomain @pwrdm.  Warning: this only
+ * affects a subset of devices in a powerdomain; check the TRM
+ * closely.  Returns -EINVAL if the powerdomain pointer is null or if
+ * the powerdomain does not support automatic save-and-restore, or
+ * returns 0 upon success.
  */
 int pwrdm_enable_hdwr_sar(struct powerdomain *pwrdm)
 {
@@ -1182,11 +942,11 @@ int pwrdm_enable_hdwr_sar(struct powerdomain *pwrdm)
  * @pwrdm: struct powerdomain *
  *
  * Disable automatic context save-and-restore upon power state change
- * for some devices in a powerdomain.  Warning: this only affects a
- * subset of devices in a powerdomain; check the TRM closely.  Returns
- * -EINVAL if the powerdomain pointer is null or if the powerdomain
- * does not support automatic save-and-restore, or returns 0 upon
- * success.
+ * for some devices in the powerdomain @pwrdm.  Warning: this only
+ * affects a subset of devices in a powerdomain; check the TRM
+ * closely.  Returns -EINVAL if the powerdomain pointer is null or if
+ * the powerdomain does not support automatic save-and-restore, or
+ * returns 0 upon success.
  */
 int pwrdm_disable_hdwr_sar(struct powerdomain *pwrdm)
 {
@@ -1209,7 +969,7 @@ int pwrdm_disable_hdwr_sar(struct powerdomain *pwrdm)
  * pwrdm_has_hdwr_sar - test whether powerdomain supports hardware SAR
  * @pwrdm: struct powerdomain *
  *
- * Returns 1 if powerdomain 'pwrdm' supports hardware save-and-restore
+ * Returns 1 if powerdomain @pwrdm supports hardware save-and-restore
  * for some devices, or 0 if it does not.
  */
 bool pwrdm_has_hdwr_sar(struct powerdomain *pwrdm)
@@ -1221,7 +981,7 @@ bool pwrdm_has_hdwr_sar(struct powerdomain *pwrdm)
  * pwrdm_wait_transition - wait for powerdomain power transition to finish
  * @pwrdm: struct powerdomain * to wait for
  *
- * If the powerdomain pwrdm is in the process of a state transition,
+ * If the powerdomain @pwrdm is in the process of a state transition,
  * spin until it completes the power transition, or until an iteration
  * bailout value is reached. Returns -EINVAL if the powerdomain
  * pointer is null, -EAGAIN if the bailout value was reached, or
@@ -1271,12 +1031,6 @@ int pwrdm_clkdm_state_switch(struct clockdomain *clkdm)
 
        return -EINVAL;
 }
-int pwrdm_clk_state_switch(struct clk *clk)
-{
-       if (clk != NULL && clk->clkdm != NULL)
-               return pwrdm_clkdm_state_switch(clk->clkdm);
-       return -EINVAL;
-}
 
 int pwrdm_pre_transition(void)
 {