Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752295Ab1FTCCk (ORCPT ); Sun, 19 Jun 2011 22:02:40 -0400 Received: from linux-sh.org ([111.68.239.195]:55663 "EHLO linux-sh.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750731Ab1FTCCh (ORCPT ); Sun, 19 Jun 2011 22:02:37 -0400 Date: Mon, 20 Jun 2011 11:01:32 +0900 From: Paul Mundt To: "Rafael J. Wysocki" Cc: Magnus Damm , Linux PM mailing list , Greg Kroah-Hartman , Paul Walmsley , Kevin Hilman , Alan Stern , LKML , linux-sh@vger.kernel.org Subject: Re: [Update][PATCH 8/8] ARM / shmobile: Support for I/O power domains for SH7372 (v6) Message-ID: <20110620020125.GA26125@linux-sh.org> References: <201106112223.04972.rjw@sisk.pl> <201106160106.40553.rjw@sisk.pl> <201106200007.47828.rjw@sisk.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201106200007.47828.rjw@sisk.pl> User-Agent: Mutt/1.4.1i Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1379 Lines: 45 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/