From mboxrd@z Thu Jan 1 00:00:00 1970 From: alexandre.belloni@free-electrons.com (Alexandre Belloni) Date: Mon, 19 Jan 2015 01:18:30 +0100 Subject: [PATCHv2 2/2] USB: host: ohci_at91: Stop/start USB PLL for all sleep modes In-Reply-To: <1421508995-21290-2-git-send-email-sylvain.rochet@finsecur.com> References: <20150117135857.71dae08f@bbrezillon> <1421508995-21290-1-git-send-email-sylvain.rochet@finsecur.com> <1421508995-21290-2-git-send-email-sylvain.rochet@finsecur.com> Message-ID: <20150119001830.GB5014@piout.net> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On 17/01/2015 at 16:36:35 +0100, Sylvain Rochet wrote : > Disable/unprepare clocks without testing the sleep target_state, removed > the at91_suspend_entering_slow_clock() call (which is only a > target_state == PM_SUSPEND_MEM). > > Other kind of suspend now benefit from the power save induced by this > PLL deactivation. The resume penalty is about 500 us, which is not > negligible but acceptable considering the amount of power we are saving. > > Signed-off-by: Sylvain Rochet > Reported-by: Boris Brezillon Acked-by: Alexandre Belloni > --- > drivers/usb/host/ohci-at91.c | 25 +++++++++++++------------ > 1 file changed, 13 insertions(+), 12 deletions(-) > > diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c > index dc9e4e6..f0da734 100644 > --- a/drivers/usb/host/ohci-at91.c > +++ b/drivers/usb/host/ohci-at91.c > @@ -49,6 +49,8 @@ extern int usb_disabled(void); > > static void at91_start_clock(void) > { > + if (clocked) > + return; > if (IS_ENABLED(CONFIG_COMMON_CLK)) { > clk_set_rate(uclk, 48000000); > clk_prepare_enable(uclk); > @@ -61,6 +63,8 @@ static void at91_start_clock(void) > > static void at91_stop_clock(void) > { > + if (!clocked) > + return; > clk_disable_unprepare(fclk); > clk_disable_unprepare(iclk); > clk_disable_unprepare(hclk); > @@ -615,16 +619,14 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg) > * > * REVISIT: some boards will be able to turn VBUS off... > */ > - if (at91_suspend_entering_slow_clock()) { > - ohci->hc_control = ohci_readl(ohci, &ohci->regs->control); > - ohci->hc_control &= OHCI_CTRL_RWC; > - ohci_writel(ohci, ohci->hc_control, &ohci->regs->control); > - ohci->rh_state = OHCI_RH_HALTED; > - > - /* flush the writes */ > - (void) ohci_readl (ohci, &ohci->regs->control); > - at91_stop_clock(); > - } > + ohci->hc_control = ohci_readl(ohci, &ohci->regs->control); > + ohci->hc_control &= OHCI_CTRL_RWC; > + ohci_writel(ohci, ohci->hc_control, &ohci->regs->control); > + ohci->rh_state = OHCI_RH_HALTED; > + > + /* flush the writes */ > + (void) ohci_readl (ohci, &ohci->regs->control); > + at91_stop_clock(); > > return ret; > } > @@ -636,8 +638,7 @@ static int ohci_hcd_at91_drv_resume(struct platform_device *pdev) > if (device_may_wakeup(&pdev->dev)) > disable_irq_wake(hcd->irq); > > - if (!clocked) > - at91_start_clock(); > + at91_start_clock(); > > ohci_resume(hcd, false); > return 0; > -- > 2.1.4 > -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com