USB: pxa27x_udc: add vbus_draw callback

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Thursday, March 26, 2009 - 12:28 pm

Gitweb:     http://git.kernel.org/linus/ee069fb1185895e725ad942c7a529f947e25166d
Commit:     ee069fb1185895e725ad942c7a529f947e25166d
Parent:     7fec3c25b773883bd50c4078bcccdd23d3dadeac
Author:     Robert Jarzmik <robert.jarzmik@free.fr>
AuthorDate: Sat Jan 24 23:59:38 2009 -0800
Committer:  Greg Kroah-Hartman <gregkh@suse.de>
CommitDate: Tue Mar 24 16:20:27 2009 -0700

    USB: pxa27x_udc: add vbus_draw callback
    
    Add the vbus_draw() callback to inform the transceiver, if
    it exists, how much current may be drawn. The decision is
    taken on gadget driver side using the configuration chosen
    by the host and its bMaxPower field.  Some systems can use
    the host's VBUS supply to augment or recharge a battery.
    (There's also a default of 100 mA for unconfigured devices,
    or 8 mA if they're OTG devices.)
    
    Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
    Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/usb/gadget/pxa27x_udc.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 1151047..e50419d 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -1623,12 +1623,34 @@ static int pxa_udc_vbus_session(struct usb_gadget *_gadget, int is_active)
 	return 0;
 }
 
+/**
+ * pxa_udc_vbus_draw - Called by gadget driver after SET_CONFIGURATION completed
+ * @_gadget: usb gadget
+ * @mA: current drawn
+ *
+ * Context: !in_interrupt()
+ *
+ * Called after a configuration was chosen by a USB host, to inform how much
+ * current can be drawn by the device from VBus line.
+ *
+ * Returns 0 or -EOPNOTSUPP if no transceiver is handling the udc
+ */
+static int pxa_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
+{
+	struct pxa_udc *udc;
+
+	udc = to_gadget_udc(_gadget);
+	if (udc->transceiver)
+		return otg_set_power(udc->transceiver, mA);
+	return -EOPNOTSUPP;
+}
+
 static const struct usb_gadget_ops pxa_udc_ops = {
 	.get_frame	= pxa_udc_get_frame,
 	.wakeup		= pxa_udc_wakeup,
 	.pullup		= pxa_udc_pullup,
 	.vbus_session	= pxa_udc_vbus_session,
-	/* current versions must always be self-powered */
+	.vbus_draw	= pxa_udc_vbus_draw,
 };
 
 /**
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
USB: pxa27x_udc: add vbus_draw callback, Linux Kernel Mailing ..., (Thu Mar 26, 12:28 pm)