aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRobert Jarzmik <robert.jarzmik@free.fr>2009-01-25 02:59:38 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-03-24 19:20:27 -0400
commitee069fb1185895e725ad942c7a529f947e25166d (patch)
tree0aba6c381156e151d7153b79f2497c3cdce9259f /drivers
parent7fec3c25b773883bd50c4078bcccdd23d3dadeac (diff)
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/gadget/pxa27x_udc.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 11510472ee0..e50419d0899 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)
1623 return 0; 1623 return 0;
1624} 1624}
1625 1625
1626/**
1627 * pxa_udc_vbus_draw - Called by gadget driver after SET_CONFIGURATION completed
1628 * @_gadget: usb gadget
1629 * @mA: current drawn
1630 *
1631 * Context: !in_interrupt()
1632 *
1633 * Called after a configuration was chosen by a USB host, to inform how much
1634 * current can be drawn by the device from VBus line.
1635 *
1636 * Returns 0 or -EOPNOTSUPP if no transceiver is handling the udc
1637 */
1638static int pxa_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
1639{
1640 struct pxa_udc *udc;
1641
1642 udc = to_gadget_udc(_gadget);
1643 if (udc->transceiver)
1644 return otg_set_power(udc->transceiver, mA);
1645 return -EOPNOTSUPP;
1646}
1647
1626static const struct usb_gadget_ops pxa_udc_ops = { 1648static const struct usb_gadget_ops pxa_udc_ops = {
1627 .get_frame = pxa_udc_get_frame, 1649 .get_frame = pxa_udc_get_frame,
1628 .wakeup = pxa_udc_wakeup, 1650 .wakeup = pxa_udc_wakeup,
1629 .pullup = pxa_udc_pullup, 1651 .pullup = pxa_udc_pullup,
1630 .vbus_session = pxa_udc_vbus_session, 1652 .vbus_session = pxa_udc_vbus_session,
1631 /* current versions must always be self-powered */ 1653 .vbus_draw = pxa_udc_vbus_draw,
1632}; 1654};
1633 1655
1634/** 1656/**