--- On Mon, 8/23/10, Praveena Nadahally <praveen.nadahally@xxxxxxxxxxxxxx> wrote: > From: Praveena Nadahally <praveen.nadahally@xxxxxxxxxxxxxx> > Subject: [PATCH] USB Gadget: Verify VBUS current before setting the device self-powered bit > To: linux-usb@xxxxxxxxxxxxxxx > Cc: STEricsson_nomadik_linux@xxxxxxxxxxx, linus.walleij@xxxxxxxxxxxxxx, "Parirajan Muthalagu" <parirajan.muthalagu@xxxxxxxxxxxxxx>, "Praveena Nadahally" <praveen.nadahally@xxxxxxxxxxxxxx> > Date: Monday, August 23, 2010, 1:25 AM > From: Parirajan Muthalagu <parirajan.muthalagu@xxxxxxxxxxxxxx> > > > Signed-off-by: Parirajan Muthalagu <parirajan.muthalagu@xxxxxxxxxxxxxx> > Signed-off-by: Praveena Nadahally <praveen.nadahally@xxxxxxxxxxxxxx> > Acked-by: Linus Walleij <linus.walleij@xxxxxxxxxxxxxx> Acked-by: David Brownell <dbrownell@xxxxxxxxxxxxxxxxxxxxx> ... given the issues I note ar resolved first. > --- > drivers/usb/gadget/composite.c | 11 > ++++++++++- > include/linux/usb/ch9.h | > 9 +++++++++ > 2 files changed, 19 insertions(+), 1 deletions(-) > > diff --git a/drivers/usb/gadget/composite.c > b/drivers/usb/gadget/composite.c > index e483f80..bfe0bd6 100644 > --- a/drivers/usb/gadget/composite.c > +++ b/drivers/usb/gadget/composite.c > @@ -1074,7 +1074,16 @@ static int composite_bind(struct > usb_gadget *gadget) > cdev->bufsiz = USB_BUFSIZ; > cdev->driver = composite; > > - usb_gadget_set_selfpowered(gadget); > + /* > + * According to USB spec, a > device that is actively drawing > + * more than 100mA from USB > must report itself as bus-powered in > + * the GetStatus(DEVICE) > call. > + * There is no clear > mentioning about the status when the device > + * draws exactly 100mA. so, Istoo. ... > to be on the safer side, the device is > + * self-powered only when > VBUS is 'less' than 100mA. > + */ > + if (CONFIG_USB_GADGET_VBUS_DRAW < Annoyingly, I can't find where that CONFIG_ var is defined in KConfig. References, yes. This seems to need fixing ... > USB_SELF_POWER_VBUS_MAX_DRAW) Make that "<= to match the USB-IF doc you reference. A device that is actively drawing more than 100mA from USB must report itself as bus-powered in the GetStatus(DEVICE) call. Peripherals that return "Self-powered" in the GetStatus(DEVICE) call are prohibited from drawing more than 100mA at any time. > usb_gadget_set_selfpowered(gadget); > > /* interface and string IDs start at > zero via kzalloc. > * we force endpoints to > start unassigned; few controller > diff --git a/include/linux/usb/ch9.h > b/include/linux/usb/ch9.h > index da2ed77..57cb2a6 100644 > --- a/include/linux/usb/ch9.h > +++ b/include/linux/usb/ch9.h > @@ -808,4 +808,13 @@ enum usb_device_state { > */ > }; > > +/*-------------------------------------------------------------------------*/ > + > +/* > + * USB compliance defines 'less' than 100mA is the > maximum > + * current a device can draw from Host, if it is > self-powered. > + * http://compliance.usb.org/index.asp?UpdateFile=Electrical&Format=Standard#34 > + */ > +#define USB_SELF_POWER_VBUS_MAX_DRAW > 100 > + > #endif /* __LINUX_USB_CH9_H */ > -- > 1.6.3.3 > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html