Commit 36e893d2 authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman
Browse files

usb gadget: USB_GADGET_VBUS_DRAW Kconfig option



Offer a "how much VBUS power to request" configuration option
for USB gadgets that aren't using board-specific customization
of their gadget or (composite) configuration drivers.

Also remove a couple pointless "depends on USB_GADGET" bits
from the Kconfig text; booleans inside an "if USB_GADGET" will
already have that dependency.

Based on a patch from Justin Clacherty.

Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Cc: Justin Clacherty <justin@redfish-group.com>
Tested-by: default avatarRobert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 02582b92
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ if USB_GADGET

config USB_GADGET_DEBUG
	boolean "Debugging messages (DEVELOPMENT)"
	depends on USB_GADGET && DEBUG_KERNEL
	depends on DEBUG_KERNEL
	help
	   Many controller and gadget drivers will print some debugging
	   messages if you use this option to ask for those messages.
@@ -59,7 +59,7 @@ config USB_GADGET_DEBUG

config USB_GADGET_DEBUG_FILES
	boolean "Debugging information files (DEVELOPMENT)"
	depends on USB_GADGET && PROC_FS
	depends on PROC_FS
	help
	   Some of the drivers in the "gadget" framework can expose
	   debugging information in files such as /proc/driver/udc
@@ -70,7 +70,7 @@ config USB_GADGET_DEBUG_FILES

config USB_GADGET_DEBUG_FS
	boolean "Debugging information files in debugfs (DEVELOPMENT)"
	depends on USB_GADGET && DEBUG_FS
	depends on DEBUG_FS
	help
	   Some of the drivers in the "gadget" framework can expose
	   debugging information in files under /sys/kernel/debug/.
@@ -79,6 +79,23 @@ config USB_GADGET_DEBUG_FS
	   Enable these files by choosing "Y" here.  If in doubt, or
	   to conserve kernel memory, say "N".

config USB_GADGET_VBUS_DRAW
	int "Maximum VBUS Power usage (2-500 mA)"
	range 2 500
	default 2
	help
	   Some devices need to draw power from USB when they are
	   configured, perhaps to operate circuitry or to recharge
	   batteries.  This is in addition to any local power supply,
	   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;
	   0 mA would be legal, but can make some hosts misbehave.

	   This value will be used except for system-specific gadget
	   drivers that have more specific information.

config	USB_GADGET_SELECTED
	boolean

+0 −1
Original line number Diff line number Diff line
@@ -155,7 +155,6 @@ static struct usb_configuration cdc_config_driver = {
	.bConfigurationValue	= 1,
	/* .iConfiguration = DYNAMIC */
	.bmAttributes		= USB_CONFIG_ATT_SELFPOWER,
	.bMaxPower		= 1,	/* 2 mA, minimal */
};

/*-------------------------------------------------------------------------*/
+2 −2
Original line number Diff line number Diff line
@@ -245,7 +245,7 @@ static int config_buf(struct usb_configuration *config,
	c->bConfigurationValue = config->bConfigurationValue;
	c->iConfiguration = config->iConfiguration;
	c->bmAttributes = USB_CONFIG_ATT_ONE | config->bmAttributes;
	c->bMaxPower = config->bMaxPower;
	c->bMaxPower = config->bMaxPower ? : (CONFIG_USB_GADGET_VBUS_DRAW / 2);

	/* There may be e.g. OTG descriptors */
	if (config->descriptors) {
@@ -432,7 +432,7 @@ static int set_config(struct usb_composite_dev *cdev,
	}

	/* when we return, be sure our power usage is valid */
	power = 2 * c->bMaxPower;
	power = c->bMaxPower ? (2 * c->bMaxPower) : CONFIG_USB_GADGET_VBUS_DRAW;
done:
	usb_gadget_vbus_draw(gadget, power);
	return result;
+0 −2
Original line number Diff line number Diff line
@@ -242,7 +242,6 @@ static struct usb_configuration rndis_config_driver = {
	.bConfigurationValue	= 2,
	/* .iConfiguration = DYNAMIC */
	.bmAttributes		= USB_CONFIG_ATT_SELFPOWER,
	.bMaxPower		= 1,	/* 2 mA, minimal */
};

/*-------------------------------------------------------------------------*/
@@ -271,7 +270,6 @@ static struct usb_configuration eth_config_driver = {
	.bConfigurationValue	= 1,
	/* .iConfiguration = DYNAMIC */
	.bmAttributes		= USB_CONFIG_ATT_SELFPOWER,
	.bMaxPower		= 1,	/* 2 mA, minimal */
};

/*-------------------------------------------------------------------------*/
+0 −1
Original line number Diff line number Diff line
@@ -352,7 +352,6 @@ static struct usb_configuration loopback_driver = {
	.bind		= loopback_bind_config,
	.bConfigurationValue = 2,
	.bmAttributes	= USB_CONFIG_ATT_SELFPOWER,
	.bMaxPower	= 1,	/* 2 mA, minimal */
	/* .iConfiguration = DYNAMIC */
};

Loading