summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorMayank Rana <mrana@codeaurora.org>2015-10-15 17:51:32 -0700
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-22 11:02:56 -0700
commitf67850e9f078fa98be92b7f74e6d3c377289a97e (patch)
tree5eff014042b34505ecf166c4b5eac3d276afe687 /drivers/usb
parent2c9b669728b17a1bd9ac8cf2d7e78501da9a8b10 (diff)
usb: gadget: Draw 900mA current when enumerating in super speed mode
Currently 500mA is used as max allowable current to draw with USB SDP case in both super speed and high speed mode. In super speed mode it is allowed to draw 900mA current. Hence update allowable current to draw based on USB connection speed. This change doesn't consider any configuration based allowable max current. Change-Id: Iae9ecf586135b0a2064e7d5e6e8fa3d8e7e4fb70 Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/composite.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index b8c8e1daca7d..ab405a96fb7b 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -23,6 +23,9 @@
#include <asm/unaligned.h>
#include "u_os_desc.h"
+#define SSUSB_GADGET_VBUS_DRAW 900 /* in mA */
+#define SSUSB_GADGET_VBUS_DRAW_UNITS 8
+#define HSUSB_GADGET_VBUS_DRAW_UNITS 2
/**
* struct usb_os_string - represents OS String to be reported by a gadget
@@ -461,19 +464,15 @@ done:
static u8 encode_bMaxPower(enum usb_device_speed speed,
struct usb_configuration *c)
{
- unsigned val;
+ unsigned val = CONFIG_USB_GADGET_VBUS_DRAW;
- if (c->MaxPower)
- val = c->MaxPower;
- else
- val = CONFIG_USB_GADGET_VBUS_DRAW;
- if (!val)
- return 0;
switch (speed) {
case USB_SPEED_SUPER:
- return DIV_ROUND_UP(val, 8);
+ /* with super-speed report 900mA */
+ val = SSUSB_GADGET_VBUS_DRAW;
+ return (u8)(val / SSUSB_GADGET_VBUS_DRAW_UNITS);
default:
- return DIV_ROUND_UP(val, 2);
+ return DIV_ROUND_UP(val, HSUSB_GADGET_VBUS_DRAW_UNITS);
}
}
@@ -849,8 +848,12 @@ static int set_config(struct usb_composite_dev *cdev,
}
}
- /* when we return, be sure our power usage is valid */
- power = c->MaxPower ? c->MaxPower : CONFIG_USB_GADGET_VBUS_DRAW;
+ /* Allow 900mA to draw with Super-Speed */
+ if (gadget->speed == USB_SPEED_SUPER)
+ power = SSUSB_GADGET_VBUS_DRAW;
+ else
+ power = CONFIG_USB_GADGET_VBUS_DRAW;
+
done:
usb_gadget_vbus_draw(gadget, power);
if (result >= 0 && cdev->delayed_status)