All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hema HK <hemahk-l0cyMroinI0@public.gmane.org>
To: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Hema HK <hemahk-l0cyMroinI0@public.gmane.org>,
	Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>,
	Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>,
	Kevin Hilman
	<khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>,
	"Cousson, Benoit" <b-cousson-l0cyMroinI0@public.gmane.org>,
	Paul Walmsley <paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org>
Subject: [PATCH 5/5 v5] usb: musb: Using runtime pm APIs for musb.
Date: Fri, 10 Dec 2010 20:05:39 +0530	[thread overview]
Message-ID: <1291991739-21705-6-git-send-email-hemahk@ti.com> (raw)
In-Reply-To: <1291991739-21705-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>

Calling runtime pm APIs pm_runtime_put_sync() and pm_runtime_get_sync()
for enabling/disabling the clocks, sysconfig settings.

enable clock, configure no-idle/standby when active and configure force idle/standby
and disable clock when idled. This is taken care by the runtime framework when 
driver calls the pm_runtime_get_sync and pm_runtime_put_sync APIs.
Need to configure MUSB into force standby and force idle mode when usb not used

Signed-off-by: Hema HK <hemahk-l0cyMroinI0@public.gmane.org>
Cc: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
Cc: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
Cc: Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
Cc: Cousson, Benoit <b-cousson-l0cyMroinI0@public.gmane.org>
Cc: Paul Walmsley <paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org>
---

 drivers/usb/musb/musb_core.h |    2 -
 drivers/usb/musb/omap2430.c  |   80 +++++++++++--------------------------------
 2 files changed, 23 insertions(+), 59 deletions(-)

Index: usb/drivers/usb/musb/omap2430.c
===================================================================
--- usb.orig/drivers/usb/musb/omap2430.c
+++ usb/drivers/usb/musb/omap2430.c
@@ -33,6 +33,8 @@
 #include <linux/io.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
+#include <linux/pm_runtime.h>
+#include <linux/err.h>
 
 #include "musb_core.h"
 #include "omap2430.h"
@@ -40,7 +42,6 @@
 struct omap2430_glue {
 	struct device		*dev;
 	struct platform_device	*musb;
-	struct clk		*clk;
 };
 #define glue_to_musb(g)		platform_get_drvdata(g->musb)
 
@@ -216,20 +217,12 @@ static inline void omap2430_low_level_ex
 	l = musb_readl(musb->mregs, OTG_FORCESTDBY);
 	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);
 }
 
 static inline void omap2430_low_level_init(struct musb *musb)
 {
 	u32 l;
 
-	l = musb_readl(musb->mregs, OTG_SYSCONFIG);
-	l &= ~ENABLEWAKEUP;	/* disable wakeup */
-	musb_writel(musb->mregs, OTG_SYSCONFIG, l);
-
 	l = musb_readl(musb->mregs, OTG_FORCESTDBY);
 	l &= ~ENABLEFORCE;	/* disable MSTANDBY */
 	musb_writel(musb->mregs, OTG_FORCESTDBY, l);
@@ -307,21 +300,6 @@ static int omap2430_musb_init(struct mus
 
 	omap2430_low_level_init(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) {
@@ -384,7 +362,7 @@ static int __init omap2430_probe(struct 
 	struct musb_hdrc_platform_data	*pdata = pdev->dev.platform_data;
 	struct platform_device		*musb;
 	struct omap2430_glue		*glue;
-	struct clk			*clk;
+	int				status = 0;
 
 	int				ret = -ENOMEM;
 
@@ -400,26 +378,12 @@ static int __init omap2430_probe(struct 
 		goto err1;
 	}
 
-	clk = clk_get(&pdev->dev, "ick");
-	if (IS_ERR(clk)) {
-		dev_err(&pdev->dev, "failed to get clock\n");
-		ret = PTR_ERR(clk);
-		goto err2;
-	}
-
-	ret = clk_enable(clk);
-	if (ret) {
-		dev_err(&pdev->dev, "failed to enable clock\n");
-		goto err3;
-	}
-
 	musb->dev.parent		= &pdev->dev;
 	musb->dev.dma_mask		= &omap2430_dmamask;
 	musb->dev.coherent_dma_mask	= omap2430_dmamask;
 
 	glue->dev			= &pdev->dev;
 	glue->musb			= musb;
-	glue->clk			= clk;
 
 	pdata->platform_ops		= &omap2430_ops;
 
@@ -429,28 +393,30 @@ static int __init omap2430_probe(struct 
 			pdev->num_resources);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to add resources\n");
-		goto err4;
+		goto err2;
 	}
 
 	ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
 	if (ret) {
 		dev_err(&pdev->dev, "failed to add platform_data\n");
-		goto err4;
+		goto err2;
 	}
 
 	ret = platform_device_add(musb);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to register musb device\n");
-		goto err4;
+		goto err2;
 	}
 
-	return 0;
+	pm_runtime_enable(&pdev->dev);
+	if (pm_runtime_get_sync(&pdev->dev)) {
+		dev_err(&pdev->dev, "pm_runtime_get_sync FAILED");
+		pm_runtime_disable(&pdev->dev);
+		goto err2;
+	}
 
-err4:
-	clk_disable(clk);
+	return 0;
 
-err3:
-	clk_put(clk);
 
 err2:
 	platform_device_put(musb);
@@ -468,8 +434,8 @@ static int __exit omap2430_remove(struct
 
 	platform_device_del(glue->musb);
 	platform_device_put(glue->musb);
-	clk_disable(glue->clk);
-	clk_put(glue->clk);
+	pm_runtime_put_sync(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 	kfree(glue);
 
 	return 0;
@@ -478,13 +444,11 @@ static int __exit omap2430_remove(struct
 #ifdef CONFIG_PM
 static void omap2430_save_context(struct musb *musb)
 {
-	musb->context.otg_sysconfig = musb_readl(musb->mregs, OTG_SYSCONFIG);
 	musb->context.otg_forcestandby = musb_readl(musb->mregs, OTG_FORCESTDBY);
 }
 
 static void omap2430_restore_context(struct musb *musb)
 {
-	musb_writel(musb->mregs, OTG_SYSCONFIG, musb->context.otg_sysconfig);
 	musb_writel(musb->mregs, OTG_FORCESTDBY, musb->context.otg_forcestandby);
 }
 
@@ -496,8 +460,11 @@ static int omap2430_suspend(struct devic
 	omap2430_low_level_exit(musb);
 	otg_set_suspend(musb->xceiv, 1);
 	omap2430_save_context(musb);
-	clk_disable(glue->clk);
 
+	if (pm_runtime_put_sync(dev)) {
+		dev_err(dev, "pm_runtime_put_sync FAILED");
+		return -EINVAL;
+	}
 	return 0;
 }
 
@@ -505,14 +472,11 @@ static int omap2430_resume(struct device
 {
 	struct omap2430_glue		*glue = dev_get_drvdata(dev);
 	struct musb			*musb = glue_to_musb(glue);
-	int				ret;
 
-	ret = clk_enable(glue->clk);
-	if (ret) {
-		dev_err(dev, "faled to enable clock\n");
-		return ret;
+	if (pm_runtime_get_sync(dev)) {
+		dev_err(dev, "pm_runtime_get_sync FAILED");
+		return -EINVAL;
 	}

  parent reply	other threads:[~2010-12-10 14:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-10 14:35 Subject: [PATCH 0/5 v5]usb: musb: hwmod and runtime pm support for musb Hema HK
2010-12-10 14:35 ` [PATCH 4/5 v5] OMAP2+: musb: HWMOD adaptation " Hema HK
2011-02-03  5:56   ` Hema Kalliguddi
2011-02-09  0:03   ` Kevin Hilman
2011-02-10 13:34     ` Hema Kalliguddi
2011-02-10 16:42       ` Kevin Hilman
     [not found] ` <1291991739-21705-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
2010-12-10 14:35   ` [PATCH 1/5 v5] OMAP2430: hwmod data: Add USBOTG Hema HK
     [not found]     ` <1291991739-21705-2-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
2011-02-03  5:54       ` Hema Kalliguddi
     [not found]         ` <3b6a23e346e75947e09f70dae78f2d88-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-02-03  9:25           ` Felipe Balbi
2011-02-09  0:55             ` Kevin Hilman
2010-12-10 14:35   ` [PATCH 2/5 v5] OMAP3xxx: " Hema HK
     [not found]     ` <1291991739-21705-3-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
2011-02-03  5:55       ` Hema Kalliguddi
2010-12-10 14:35   ` [PATCH 3/5 v5] OMAP4430: hwmod data: Adding USBOTG Hema HK
2011-02-03  5:55     ` Hema Kalliguddi
2010-12-10 14:35   ` Hema HK [this message]
     [not found]     ` <1291991739-21705-6-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
2010-12-10 14:38       ` [PATCH 5/5 v5] usb: musb: Using runtime pm APIs for musb Felipe Balbi
2010-12-11  2:58         ` Kalliguddi, Hema
2011-02-09  0:08     ` Kevin Hilman
2011-02-09  4:23       ` Hema Kalliguddi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1291991739-21705-6-git-send-email-hemahk@ti.com \
    --to=hemahk-l0cymroini0@public.gmane.org \
    --cc=b-cousson-l0cyMroinI0@public.gmane.org \
    --cc=balbi-l0cyMroinI0@public.gmane.org \
    --cc=khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org \
    --cc=tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.