Hello,
As per USB compliance update, a device that is actively drawing more
than 100mA from USB must report itself as bus-powered. But currently
in android composite device, the bMaxPower is set to 500 mA and in
bmAttributes, it's set to Self Powered. This is wrong as per the UsB
spec and USBCV throws error as :
A SELF POWERED device cannot draw more than 100ma from the USB bus.
Device consumes > 100ma when SELF POWERED : 500mA
The following patch corrects this.
diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/
android.c
index 5e778e6..d8cf4c9 100644
--- a/drivers/usb/gadget/android.c
+++ b/drivers/usb/gadget/android.c
@@ -183,7 +183,7 @@ static struct usb_configuration
android_config_driver = {
.setup = android_setup_config,
.bConfigurationValue = 1,
.bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
- .bMaxPower = 0xFA, /* 500ma */
+ .bMaxPower = CONFIG_USB_GADGET_VBUS_DRAW / 2,
};
static int android_setup_config(struct usb_configuration *c,
@@ -273,6 +273,19 @@ static int android_bind(struct usb_composite_dev
*cdev)
strings_dev[STRING_SERIAL_IDX].id = id;
device_desc.iSerialNumber = id;
+ /*
+ * As per USB compliance update, a device that is actively drawing
+ * more than 100mA from USB must report itself as bus-powered in
+ * the GetStatus(DEVICE) call.
+ */
+ if (android_config_driver.bMaxPower <=
+ (USB_SELF_POWER_VBUS_MAX_DRAW / 2)) {
+ android_config_driver.bmAttributes =
+ USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER;
+ usb_gadget_set_selfpowered(gadget);
+ } else
+ android_config_driver.bmAttributes = USB_CONFIG_ATT_ONE;
+
/* register our configuration */
ret = usb_add_config(cdev, &android_config_driver);
if (ret) {
@@ -296,7 +309,6 @@ static int android_bind(struct usb_composite_dev
*cdev)
device_desc.bcdDevice = __constant_cpu_to_le16(0x9999);
}
- usb_gadget_set_selfpowered(gadget);
dev->cdev = cdev;
product_id = get_product_id(dev);
device_desc.idProduct = __constant_cpu_to_le16(product_id);
--
unsubscribe: [email protected]
website: http://groups.google.com/group/android-kernel