From patchwork Wed Jun 24 15:32:13 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 32204 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n5OFXwoG030676 for ; Wed, 24 Jun 2009 15:33:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760576AbZFXPcQ (ORCPT ); Wed, 24 Jun 2009 11:32:16 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1760596AbZFXPcQ (ORCPT ); Wed, 24 Jun 2009 11:32:16 -0400 Received: from mail-px0-f190.google.com ([209.85.216.190]:58892 "EHLO mail-px0-f190.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760576AbZFXPcP (ORCPT ); Wed, 24 Jun 2009 11:32:15 -0400 Received: by pxi28 with SMTP id 28so438820pxi.33 for ; Wed, 24 Jun 2009 08:32:16 -0700 (PDT) Received: by 10.142.135.16 with SMTP id i16mr428456wfd.52.1245857536451; Wed, 24 Jun 2009 08:32:16 -0700 (PDT) Received: from localhost ([216.254.16.51]) by mx.google.com with ESMTPS id 24sm4352351wfc.17.2009.06.24.08.32.15 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 24 Jun 2009 08:32:15 -0700 (PDT) From: Kevin Hilman To: linux-omap@vger.kernel.org Subject: [PATCH v2] OMAP3: PM: reset USB OTG module on boot Date: Wed, 24 Jun 2009 08:32:13 -0700 Message-Id: <1245857533-2419-1-git-send-email-khilman@deeprootsystems.com> X-Mailer: git-send-email 1.6.3.2 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Rather than simply setting force-idle mode on boot, do a reset of the OTG module. This really ensures that any bootloader/bootstrap code that leaves it active will not prevent future retention. After reset, OTG module will be in force-idle, force-standby mode. In addition, ensure that the iclk is enabled before attempting a write to the module SYSCONFIG register. Problem reported by Mike Chan Tested-by: Mike Chan Signed-off-by: Kevin Hilman --- Updates from v1 - use ioremap()+__raw_write instead of deprecated omap_write() - Re: defines in omap2430.h, this header is not exported outside drivers/usb, so define it locally yere arch/arm/mach-omap2/usb-musb.c | 31 +++++++++++++++++++++++++++---- 1 files changed, 27 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c index d85296d..31adbe6 100644 --- a/arch/arm/mach-omap2/usb-musb.c +++ b/arch/arm/mach-omap2/usb-musb.c @@ -26,18 +26,41 @@ #include +#include + #include #include #include #include -#define OTG_SYSCONFIG (OMAP34XX_HSUSB_OTG_BASE + 0x404) +#define OTG_SYSCONFIG 0x404 +#define OTG_SYSC_SOFTRESET BIT(1) static void __init usb_musb_pm_init(void) { - /* Ensure force-idle mode for OTG controller */ - if (cpu_is_omap34xx()) - omap_writel(0, OTG_SYSCONFIG); + struct clk *iclk; + void __iomem *otg_base; + + if (!cpu_is_omap34xx()) + return; + + otg_base = ioremap(OMAP34XX_HSUSB_OTG_BASE, SZ_4K); + if (WARN_ON(!otg_base)) + return; + + iclk = clk_get(NULL, "hsotgusb_ick"); + if (WARN_ON(!iclk)) + return; + + clk_enable(iclk); + + /* Reset OTG controller. After reset, it will be in + * force-idle, force-standby mode. */ + __raw_writel(OTG_SYSC_SOFTRESET, otg_base + OTG_SYSCONFIG); + + clk_disable(iclk); + clk_put(iclk); + iounmap(otg_base); } #ifdef CONFIG_USB_MUSB_SOC