Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c17588ee authored by Jack Pham's avatar Jack Pham Committed by Hemant Kumar
Browse files

usb: gadget: Allow up to 900mA current draw for SuperSpeed



Currently 500mA is used as max allowable current to draw over
USB VBUS. However in SuperSpeed a gadget may draw up to 900mA
Update the CONFIG_USB_GADGET_VBUS_DRAW's allowable range to
be up to 900. But depending on connection speed, ensure that
high speed and slower are capped to 500mA when encoding the
bMaxPower value in the configuration descriptor.

Change-Id: Iae9ecf586135b0a2064e7d5e6e8fa3d8e7e4fb70
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
parent d6c40da2
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -96,8 +96,8 @@ config USB_GADGET_DEBUG_FS
	   to conserve kernel memory, say "N".

config USB_GADGET_VBUS_DRAW
	int "Maximum VBUS Power usage (2-500 mA)"
	range 2 500
	int "Maximum VBUS Power usage (2-900 mA)"
	range 2 900
	default 2
	help
	   Some devices need to draw power from USB when they are
@@ -106,7 +106,9 @@ config USB_GADGET_VBUS_DRAW
	   such as an AC adapter or batteries.

	   Enter the maximum power your device draws through USB, in
	   milliAmperes.  The permitted range of values is 2 - 500 mA;
	   milliAmperes.  The permitted range of values depends on the
	   connected speed: for SuperSpeed and up it is 2 - 900 mA, but
	   connections at High Speed or slower will be capped at 500 mA;
	   0 mA would be legal, but can make some hosts misbehave.

	   This value will be used except for system-specific gadget
+2 −1
Original line number Diff line number Diff line
@@ -539,7 +539,8 @@ static u8 encode_bMaxPower(enum usb_device_speed speed,
	case USB_SPEED_SUPER:
		return DIV_ROUND_UP(val, 8);
	default:
		return DIV_ROUND_UP(val, 2);
		/* only SuperSpeed and faster support > 500mA */
		return DIV_ROUND_UP(min(val, 500U), 2);
	}
}