From patchwork Thu Sep 23 00:30:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalliguddi, Hema" X-Patchwork-Id: 199532 X-Patchwork-Delegate: me@felipebalbi.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o8MF09ED008637 for ; Wed, 22 Sep 2010 15:00:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754837Ab0IVPAE (ORCPT ); Wed, 22 Sep 2010 11:00:04 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:56141 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753276Ab0IVPAD (ORCPT ); Wed, 22 Sep 2010 11:00:03 -0400 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id o8MExwdP005566 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 22 Sep 2010 10:00:00 -0500 Received: from localhost.localdomain (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id o8MExswx019683; Wed, 22 Sep 2010 20:29:54 +0530 (IST) From: Hema HK To: linux-omap@vger.kernel.org, linux-usb@vger.kernel.org Cc: Hema HK , "Basak, Partha" , Felipe Balbi , Tony Lindgren , Kevin Hilman , "Cousson, Benoit" , Paul Walmsley Subject: [PATCH 8/9 v3] usb : musb: Using runtime pm apis for musb. Date: Wed, 22 Sep 2010 20:30:30 -0400 Message-Id: <1285201830-26561-1-git-send-email-hemahk@ti.com> X-Mailer: git-send-email 1.7.0.4 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 22 Sep 2010 15:00:09 +0000 (UTC) Index: linux-omap-pm/drivers/usb/musb/musb_core.c =================================================================== --- linux-omap-pm.orig/drivers/usb/musb/musb_core.c +++ linux-omap-pm/drivers/usb/musb/musb_core.c @@ -98,6 +98,7 @@ #include #include #include +#include #ifdef CONFIG_ARM #include @@ -2424,13 +2425,16 @@ static int musb_suspend(struct device *d * they will even be wakeup-enabled. */ } + pm_runtime_put_sync(dev); +#ifndef CONFIG_PM_RUNTIME musb_save_context(musb); if (musb->set_clock) musb->set_clock(musb->clock, 0); else clk_disable(musb->clock); +#endif spin_unlock_irqrestore(&musb->lock, flags); return 0; } @@ -2443,12 +2447,16 @@ static int musb_resume_noirq(struct devi if (!musb->clock) return 0; + pm_runtime_get_sync(dev); + +#ifndef CONFIG_PM_RUNTIME if (musb->set_clock) musb->set_clock(musb->clock, 1); else clk_enable(musb->clock); musb_restore_context(musb); +#endif /* for static cmos like DaVinci, register values were preserved * unless for some reason the whole soc powered down or the USB @@ -2457,9 +2465,26 @@ static int musb_resume_noirq(struct devi return 0; } +static int musb_runtime_suspend(struct device *dev) +{ + struct musb *musb = dev_to_musb(dev); + + musb_save_context(musb); + return 0; +} + +static int musb_runtime_resume(struct device *dev) +{ + struct musb *musb = dev_to_musb(dev); + + musb_restore_context(musb); + return 0; +} static const struct dev_pm_ops musb_dev_pm_ops = { .suspend = musb_suspend, .resume_noirq = musb_resume_noirq, + .runtime_suspend = musb_runtime_suspend, + .runtime_resume = musb_runtime_resume, }; #define MUSB_DEV_PM_OPS (&musb_dev_pm_ops) Index: linux-omap-pm/drivers/usb/musb/omap2430.c =================================================================== --- linux-omap-pm.orig/drivers/usb/musb/omap2430.c +++ linux-omap-pm/drivers/usb/musb/omap2430.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include "musb_core.h" #include "omap2430.h" @@ -206,21 +208,6 @@ int __init musb_platform_init(struct mus musb_platform_resume(musb); - l = musb_readl(musb->mregs, OTG_SYSCONFIG); - l &= ~ENABLEWAKEUP; /* disable wakeup */ - l &= ~NOSTDBY; /* remove possible nostdby */ - l |= SMARTSTDBY; /* enable smart standby */ - l &= ~AUTOIDLE; /* disable auto idle */ - l &= ~NOIDLE; /* remove possible noidle */ - l |= SMARTIDLE; /* enable smart idle */ - /* - * MUSB AUTOIDLE don't work in 3430. - * Workaround by Richard Woodruff/TI - */ - if (!cpu_is_omap3430()) - l |= AUTOIDLE; /* enable auto idle */ - musb_writel(musb->mregs, OTG_SYSCONFIG, l); - l = musb_readl(musb->mregs, OTG_INTERFSEL); if (data->interface_type == MUSB_INTERFACE_UTMI) { @@ -253,15 +240,13 @@ int __init musb_platform_init(struct mus void musb_platform_save_context(struct musb *musb, struct musb_context_registers *musb_context) { - musb_context->otg_sysconfig = musb_readl(musb->mregs, OTG_SYSCONFIG); - musb_context->otg_forcestandby = musb_readl(musb->mregs, OTG_FORCESTDBY); + musb_writel(musb->mregs, OTG_FORCESTDBY, ENABLEFORCE); } void musb_platform_restore_context(struct musb *musb, struct musb_context_registers *musb_context) { - musb_writel(musb->mregs, OTG_SYSCONFIG, musb_context->otg_sysconfig); - musb_writel(musb->mregs, OTG_FORCESTDBY, musb_context->otg_forcestandby); + musb_writel(musb->mregs, OTG_FORCESTDBY, 0); } #endif @@ -277,37 +262,23 @@ static int musb_platform_suspend(struct l |= ENABLEFORCE; /* enable MSTANDBY */ musb_writel(musb->mregs, OTG_FORCESTDBY, l); - l = musb_readl(musb->mregs, OTG_SYSCONFIG); - l |= ENABLEWAKEUP; /* enable wakeup */ - musb_writel(musb->mregs, OTG_SYSCONFIG, l); - otg_set_suspend(musb->xceiv, 1); - if (musb->set_clock) - musb->set_clock(musb->clock, 0); - else - clk_disable(musb->clock); - return 0; } static int musb_platform_resume(struct musb *musb) { u32 l; + struct device *dev = musb->controller; if (!musb->clock) return 0; otg_set_suspend(musb->xceiv, 0); - if (musb->set_clock) - musb->set_clock(musb->clock, 1); - else - clk_enable(musb->clock); - - l = musb_readl(musb->mregs, OTG_SYSCONFIG); - l &= ~ENABLEWAKEUP; /* disable wakeup */ - musb_writel(musb->mregs, OTG_SYSCONFIG, l); + pm_runtime_enable(dev); + pm_runtime_get_sync(dev); l = musb_readl(musb->mregs, OTG_FORCESTDBY); l &= ~ENABLEFORCE; /* disable MSTANDBY */