linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavankumar Kondeti <pkondeti@codeaurora.org>
To: linux-usb@vger.kernel.org, greg@kroah.com
Cc: linux-arm-msm@vger.kernel.org, swetland@google.com,
	arve@google.com, benoitgoby@google.com, lockwood@android.com,
	dima@android.com, Pavankumar Kondeti <pkondeti@codeaurora.org>
Subject: [PATCH V3 10/11] USB: gadget: Implement runtime PM for ci13xxx gadget
Date: Tue,  7 Dec 2010 17:54:04 +0530	[thread overview]
Message-ID: <1291724645-26074-11-git-send-email-pkondeti@codeaurora.org> (raw)
In-Reply-To: <1291724645-26074-1-git-send-email-pkondeti@codeaurora.org>

The actual suspend/resume work is delegated to bus glue driver, which
is responsible for putting hardware in low power mode.

Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
---
 drivers/usb/gadget/ci13xxx_udc.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c
index c10d1ae..f200e47 100644
--- a/drivers/usb/gadget/ci13xxx_udc.c
+++ b/drivers/usb/gadget/ci13xxx_udc.c
@@ -60,6 +60,7 @@
 #include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
+#include <linux/pm_runtime.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
 #include <linux/usb/otg.h>
@@ -2348,6 +2349,7 @@ static int ci13xxx_vbus_session(struct usb_gadget *_gadget, int is_active)
 
 	if (gadget_ready) {
 		if (is_active) {
+			pm_runtime_get_sync(&_gadget->dev);
 			hw_device_reset(udc);
 			hw_device_state(udc->ci13xxx_ep[0].qh[RX].dma);
 		} else {
@@ -2356,6 +2358,7 @@ static int ci13xxx_vbus_session(struct usb_gadget *_gadget, int is_active)
 				udc->udc_driver->notify_event(udc,
 				CI13XXX_CONTROLLER_STOPPED_EVENT);
 			_gadget_stop_activity(&udc->gadget);
+			pm_runtime_put_sync(&_gadget->dev);
 		}
 	}
 
@@ -2473,16 +2476,20 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
 		goto done;
 	}
 
+	pm_runtime_get_sync(&udc->gadget.dev);
 	if (udc->udc_driver->flags & CI13XXX_PULLUP_ON_VBUS) {
 		if (udc->vbus_active) {
 			if (udc->udc_driver->flags & CI13XXX_REGS_SHARED)
 				hw_device_reset(udc);
 		} else {
+			pm_runtime_put_sync(&udc->gadget.dev);
 			goto done;
 		}
 	}
 
 	retval = hw_device_state(udc->ci13xxx_ep[0].qh[RX].dma);
+	if (retval)
+		pm_runtime_put_sync(&udc->gadget.dev);
 
  done:
 	spin_unlock_irqrestore(udc->lock, flags);
@@ -2522,6 +2529,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
 			udc->udc_driver->notify_event(udc,
 			CI13XXX_CONTROLLER_STOPPED_EVENT);
 		_gadget_stop_activity(&udc->gadget);
+		pm_runtime_put(&udc->gadget.dev);
 	}
 
 	/* unbind gadget */
@@ -2723,6 +2731,8 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev,
 		if (retval)
 			goto remove_dbg;
 	}
+	pm_runtime_no_callbacks(&udc->gadget.dev);
+	pm_runtime_enable(&udc->gadget.dev);
 
 	_udc = udc;
 	return retval;
-- 
1.7.1
--
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.


  parent reply	other threads:[~2010-12-07 12:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-07 12:23 [PATCH V3 00/11] Add MSM USB controller driver Pavankumar Kondeti
2010-12-07 12:23 ` [PATCH V3 01/11] USB: Add MSM OTG Controller driver Pavankumar Kondeti
2010-12-07 12:23 ` [PATCH V3 02/11] USB: EHCI: Add MSM Host " Pavankumar Kondeti
2010-12-07 12:23 ` [PATCH V3 03/11] USB: EHCI: msm: Add support for power management Pavankumar Kondeti
2010-12-07 12:23 ` [PATCH V3 04/11] USB: OTG: " Pavankumar Kondeti
2010-12-07 12:23 ` [PATCH V3 05/11] USB: gadget: Separate out PCI bus code from ci13xxx_udc Pavankumar Kondeti
2010-12-07 12:24 ` [PATCH V3 06/11] USB: gadget: Fix "scheduling while atomic" bugs in ci13xxx_udc Pavankumar Kondeti
2010-12-07 12:24 ` [PATCH V3 07/11] USB: gadget: Initialize ci13xxx gadget device's coherent DMA mask Pavankumar Kondeti
2010-12-07 12:24 ` [PATCH V3 08/11] USB: gadget: Introduce ci13xxx_udc_driver struct Pavankumar Kondeti
2010-12-07 12:24 ` [PATCH V3 09/11] USB: gadget: Add USB controller driver for MSM SoC Pavankumar Kondeti
2010-12-07 12:24 ` Pavankumar Kondeti [this message]
2010-12-07 12:24 ` [PATCH V3 11/11] USB: gadget: Implement runtime PM for MSM bus glue driver Pavankumar Kondeti
2010-12-09  7:07 ` [PATCH V3 00/11] Add MSM USB controller driver Pavan Kondeti

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=1291724645-26074-11-git-send-email-pkondeti@codeaurora.org \
    --to=pkondeti@codeaurora.org \
    --cc=arve@google.com \
    --cc=benoitgoby@google.com \
    --cc=dima@android.com \
    --cc=greg@kroah.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lockwood@android.com \
    --cc=swetland@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).