Loading drivers/usb/gadget/composite.c +14 −11 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,9 @@ #include <asm/unaligned.h> #include <asm/unaligned.h> #include "u_os_desc.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 static bool enable_l1_for_hs; static bool enable_l1_for_hs; module_param(enable_l1_for_hs, bool, S_IRUGO | S_IWUSR); module_param(enable_l1_for_hs, bool, S_IRUGO | S_IWUSR); Loading Loading @@ -459,19 +462,15 @@ EXPORT_SYMBOL_GPL(usb_func_ep_queue); static u8 encode_bMaxPower(enum usb_device_speed speed, static u8 encode_bMaxPower(enum usb_device_speed speed, struct usb_configuration *c) 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) { switch (speed) { case USB_SPEED_SUPER: 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: default: return DIV_ROUND_UP(val, 2); return DIV_ROUND_UP(val, HSUSB_GADGET_VBUS_DRAW_UNITS); } } } } Loading Loading @@ -858,8 +857,12 @@ static int set_config(struct usb_composite_dev *cdev, } } } } /* when we return, be sure our power usage is valid */ /* Allow 900mA to draw with Super-Speed */ power = c->MaxPower ? c->MaxPower : CONFIG_USB_GADGET_VBUS_DRAW; if (gadget->speed == USB_SPEED_SUPER) power = SSUSB_GADGET_VBUS_DRAW; else power = CONFIG_USB_GADGET_VBUS_DRAW; done: done: usb_gadget_vbus_draw(gadget, power); usb_gadget_vbus_draw(gadget, power); if (result >= 0 && cdev->delayed_status) if (result >= 0 && cdev->delayed_status) Loading Loading
drivers/usb/gadget/composite.c +14 −11 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,9 @@ #include <asm/unaligned.h> #include <asm/unaligned.h> #include "u_os_desc.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 static bool enable_l1_for_hs; static bool enable_l1_for_hs; module_param(enable_l1_for_hs, bool, S_IRUGO | S_IWUSR); module_param(enable_l1_for_hs, bool, S_IRUGO | S_IWUSR); Loading Loading @@ -459,19 +462,15 @@ EXPORT_SYMBOL_GPL(usb_func_ep_queue); static u8 encode_bMaxPower(enum usb_device_speed speed, static u8 encode_bMaxPower(enum usb_device_speed speed, struct usb_configuration *c) 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) { switch (speed) { case USB_SPEED_SUPER: 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: default: return DIV_ROUND_UP(val, 2); return DIV_ROUND_UP(val, HSUSB_GADGET_VBUS_DRAW_UNITS); } } } } Loading Loading @@ -858,8 +857,12 @@ static int set_config(struct usb_composite_dev *cdev, } } } } /* when we return, be sure our power usage is valid */ /* Allow 900mA to draw with Super-Speed */ power = c->MaxPower ? c->MaxPower : CONFIG_USB_GADGET_VBUS_DRAW; if (gadget->speed == USB_SPEED_SUPER) power = SSUSB_GADGET_VBUS_DRAW; else power = CONFIG_USB_GADGET_VBUS_DRAW; done: done: usb_gadget_vbus_draw(gadget, power); usb_gadget_vbus_draw(gadget, power); if (result >= 0 && cdev->delayed_status) if (result >= 0 && cdev->delayed_status) Loading