On Mon, Jun 20, 2011 at 12:07:47AM +0200, Rafael J. Wysocki wrote:
quoted hunk
+static int pd_power_down(struct generic_pm_domain *genpd)
+{
+ struct sh7372_pm_domain *sh7372_pd = to_sh7372_pd(genpd);
+ unsigned int mask = 1 << sh7372_pd->bit_shift;
+
+ if (__raw_readl(PSTR) & mask) {
+ __raw_writel(mask, SPDCR);
+
+ while (__raw_readl(SPDCR) & mask)
+ cpu_relax();
+
+ pr_debug("sh7372 power domain down 0x%08x -> PSTR = 0x%08x\n",
+ mask, __raw_readl(PSTR));
+ }
+
+ return 0;
+}
+
+static int pd_power_up(struct generic_pm_domain *genpd)
+{
+ struct sh7372_pm_domain *sh7372_pd = to_sh7372_pd(genpd);
+ unsigned int mask = 1 << sh7372_pd->bit_shift;
+
+ if (!(__raw_readl(PSTR) & mask)) {
+ __raw_writel(mask, SWUCR);
+
+ while (__raw_readl(SWUCR) & mask)
+ cpu_relax();
+
+ pr_debug("sh7372 power domain up 0x%08x -> PSTR = 0x%08x\n",
+ mask, __raw_readl(PSTR));
+ }
+
+ return 0;
+}
+
Given that these functions can return errors, it's probably more prudent
to implement some timeout logic on top of the busy loop. Hardware does
get stuck, after all.