Re: [Update][PATCH 8/8] ARM / shmobile: Support for I/O power domains for SH7372 (v6)

From: Paul Mundt
Date: Sun Jun 19 2011 - 22:02:49 EST


On Mon, Jun 20, 2011 at 12:07:47AM +0200, Rafael J. Wysocki wrote:
> +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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/