From patchwork Wed Jun 24 18:27:34 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 32223 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 n5OIRfMR027353 for ; Wed, 24 Jun 2009 18:27:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751683AbZFXS1e (ORCPT ); Wed, 24 Jun 2009 14:27:34 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751633AbZFXS1e (ORCPT ); Wed, 24 Jun 2009 14:27:34 -0400 Received: from mail-pz0-f189.google.com ([209.85.222.189]:56032 "EHLO mail-pz0-f189.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751333AbZFXS1d (ORCPT ); Wed, 24 Jun 2009 14:27:33 -0400 Received: by pzk27 with SMTP id 27so812216pzk.33 for ; Wed, 24 Jun 2009 11:27:36 -0700 (PDT) Received: by 10.115.32.8 with SMTP id k8mr2566638waj.15.1245868056585; Wed, 24 Jun 2009 11:27:36 -0700 (PDT) Received: from localhost ([216.254.16.51]) by mx.google.com with ESMTPS id j34sm2465071waf.64.2009.06.24.11.27.35 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 24 Jun 2009 11:27:36 -0700 (PDT) From: Kevin Hilman To: linux-omap@vger.kernel.org Subject: [PATCH v3] OMAP2/3/4: PM: reset USB OTG module on boot Date: Wed, 24 Jun 2009 11:27:34 -0700 Message-Id: <1245868054-20375-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 v2 - reset for OMAP2 as well (needs update for OMAP4, see FIXME) arch/arm/mach-omap2/usb-musb.c | 37 +++++++++++++++++++++++++++++++++---- 1 files changed, 33 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c index d85296d..1ea2ac7 100644 --- a/arch/arm/mach-omap2/usb-musb.c +++ b/arch/arm/mach-omap2/usb-musb.c @@ -26,18 +26,47 @@ #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; + u32 phys_base; + void __iomem *otg_base; + + if (cpu_is_omap243x()) + phys_base = OMAP2_OTG_BASE; + else if (cpu_is_omap34xx()) + phys_base = OMAP34XX_HSUSB_OTG_BASE; + else + /* FIXME: add OMAP4 support */ + return; + + otg_base = ioremap(phys_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