aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget
diff options
context:
space:
mode:
authorDavid Brownell <dbrownell@users.sourceforge.net>2008-09-12 12:39:06 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-10-17 17:40:58 -0400
commit36e893d25aa2abcae0f11ef263de0e8322641386 (patch)
treef103a4c8e94dbd7bf5a04399e2a264893a3e1515 /drivers/usb/gadget
parent02582b92f60fa33b68b90263013e98550286db0a (diff)
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: David Brownell <dbrownell@users.sourceforge.net> Cc: Justin Clacherty <justin@redfish-group.com> Tested-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r--drivers/usb/gadget/Kconfig23
-rw-r--r--drivers/usb/gadget/cdc2.c1
-rw-r--r--drivers/usb/gadget/composite.c4
-rw-r--r--drivers/usb/gadget/ether.c2
-rw-r--r--drivers/usb/gadget/f_loopback.c1
-rw-r--r--drivers/usb/gadget/f_sourcesink.c1
-rw-r--r--drivers/usb/gadget/file_storage.c2
-rw-r--r--drivers/usb/gadget/gmidi.c2
-rw-r--r--drivers/usb/gadget/printer.c3
-rw-r--r--drivers/usb/gadget/serial.c1
10 files changed, 25 insertions, 15 deletions
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index c0dfd9be3115..1a72715bce8a 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -45,7 +45,7 @@ if USB_GADGET
45 45
46config USB_GADGET_DEBUG 46config USB_GADGET_DEBUG
47 boolean "Debugging messages (DEVELOPMENT)" 47 boolean "Debugging messages (DEVELOPMENT)"
48 depends on USB_GADGET && DEBUG_KERNEL 48 depends on DEBUG_KERNEL
49 help 49 help
50 Many controller and gadget drivers will print some debugging 50 Many controller and gadget drivers will print some debugging
51 messages if you use this option to ask for those messages. 51 messages if you use this option to ask for those messages.
@@ -59,7 +59,7 @@ config USB_GADGET_DEBUG
59 59
60config USB_GADGET_DEBUG_FILES 60config USB_GADGET_DEBUG_FILES
61 boolean "Debugging information files (DEVELOPMENT)" 61 boolean "Debugging information files (DEVELOPMENT)"
62 depends on USB_GADGET && PROC_FS 62 depends on PROC_FS
63 help 63 help
64 Some of the drivers in the "gadget" framework can expose 64 Some of the drivers in the "gadget" framework can expose
65 debugging information in files such as /proc/driver/udc 65 debugging information in files such as /proc/driver/udc
@@ -70,7 +70,7 @@ config USB_GADGET_DEBUG_FILES
70 70
71config USB_GADGET_DEBUG_FS 71config USB_GADGET_DEBUG_FS
72 boolean "Debugging information files in debugfs (DEVELOPMENT)" 72 boolean "Debugging information files in debugfs (DEVELOPMENT)"
73 depends on USB_GADGET && DEBUG_FS 73 depends on DEBUG_FS
74 help 74 help
75 Some of the drivers in the "gadget" framework can expose 75 Some of the drivers in the "gadget" framework can expose
76 debugging information in files under /sys/kernel/debug/. 76 debugging information in files under /sys/kernel/debug/.
@@ -79,6 +79,23 @@ config USB_GADGET_DEBUG_FS
79 Enable these files by choosing "Y" here. If in doubt, or 79 Enable these files by choosing "Y" here. If in doubt, or
80 to conserve kernel memory, say "N". 80 to conserve kernel memory, say "N".
81 81
82config USB_GADGET_VBUS_DRAW
83 int "Maximum VBUS Power usage (2-500 mA)"
84 range 2 500
85 default 2
86 help
87 Some devices need to draw power from USB when they are
88 configured, perhaps to operate circuitry or to recharge
89 batteries. This is in addition to any local power supply,
90 such as an AC adapter or batteries.
91
92 Enter the maximum power your device draws through USB, in
93 milliAmperes. The permitted range of values is 2 - 500 mA;
94 0 mA would be legal, but can make some hosts misbehave.
95
96 This value will be used except for system-specific gadget
97 drivers that have more specific information.
98
82config USB_GADGET_SELECTED 99config USB_GADGET_SELECTED
83 boolean 100 boolean
84 101
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index a724fc149850..5495b171cf29 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -155,7 +155,6 @@ static struct usb_configuration cdc_config_driver = {
155 .bConfigurationValue = 1, 155 .bConfigurationValue = 1,
156 /* .iConfiguration = DYNAMIC */ 156 /* .iConfiguration = DYNAMIC */
157 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 157 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
158 .bMaxPower = 1, /* 2 mA, minimal */
159}; 158};
160 159
161/*-------------------------------------------------------------------------*/ 160/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index f79fdb839cb8..f2da0269e1b1 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -245,7 +245,7 @@ static int config_buf(struct usb_configuration *config,
245 c->bConfigurationValue = config->bConfigurationValue; 245 c->bConfigurationValue = config->bConfigurationValue;
246 c->iConfiguration = config->iConfiguration; 246 c->iConfiguration = config->iConfiguration;
247 c->bmAttributes = USB_CONFIG_ATT_ONE | config->bmAttributes; 247 c->bmAttributes = USB_CONFIG_ATT_ONE | config->bmAttributes;
248 c->bMaxPower = config->bMaxPower; 248 c->bMaxPower = config->bMaxPower ? : (CONFIG_USB_GADGET_VBUS_DRAW / 2);
249 249
250 /* There may be e.g. OTG descriptors */ 250 /* There may be e.g. OTG descriptors */
251 if (config->descriptors) { 251 if (config->descriptors) {
@@ -432,7 +432,7 @@ static int set_config(struct usb_composite_dev *cdev,
432 } 432 }
433 433
434 /* when we return, be sure our power usage is valid */ 434 /* when we return, be sure our power usage is valid */
435 power = 2 * c->bMaxPower; 435 power = c->bMaxPower ? (2 * c->bMaxPower) : CONFIG_USB_GADGET_VBUS_DRAW;
436done: 436done:
437 usb_gadget_vbus_draw(gadget, power); 437 usb_gadget_vbus_draw(gadget, power);
438 return result; 438 return result;
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 944c8e889ab4..37252d0012a7 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -242,7 +242,6 @@ static struct usb_configuration rndis_config_driver = {
242 .bConfigurationValue = 2, 242 .bConfigurationValue = 2,
243 /* .iConfiguration = DYNAMIC */ 243 /* .iConfiguration = DYNAMIC */
244 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 244 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
245 .bMaxPower = 1, /* 2 mA, minimal */
246}; 245};
247 246
248/*-------------------------------------------------------------------------*/ 247/*-------------------------------------------------------------------------*/
@@ -271,7 +270,6 @@ static struct usb_configuration eth_config_driver = {
271 .bConfigurationValue = 1, 270 .bConfigurationValue = 1,
272 /* .iConfiguration = DYNAMIC */ 271 /* .iConfiguration = DYNAMIC */
273 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 272 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
274 .bMaxPower = 1, /* 2 mA, minimal */
275}; 273};
276 274
277/*-------------------------------------------------------------------------*/ 275/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c
index 87dde012dacc..8affe1dfc2c1 100644
--- a/drivers/usb/gadget/f_loopback.c
+++ b/drivers/usb/gadget/f_loopback.c
@@ -352,7 +352,6 @@ static struct usb_configuration loopback_driver = {
352 .bind = loopback_bind_config, 352 .bind = loopback_bind_config,
353 .bConfigurationValue = 2, 353 .bConfigurationValue = 2,
354 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 354 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
355 .bMaxPower = 1, /* 2 mA, minimal */
356 /* .iConfiguration = DYNAMIC */ 355 /* .iConfiguration = DYNAMIC */
357}; 356};
358 357
diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c
index f18c3a14d72a..dc84d26d2835 100644
--- a/drivers/usb/gadget/f_sourcesink.c
+++ b/drivers/usb/gadget/f_sourcesink.c
@@ -552,7 +552,6 @@ static struct usb_configuration sourcesink_driver = {
552 .setup = sourcesink_setup, 552 .setup = sourcesink_setup,
553 .bConfigurationValue = 3, 553 .bConfigurationValue = 3,
554 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 554 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
555 .bMaxPower = 1, /* 2 mA, minimal */
556 /* .iConfiguration = DYNAMIC */ 555 /* .iConfiguration = DYNAMIC */
557}; 556};
558 557
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index e0f616f39ba0..c4e62a6297d7 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -851,7 +851,7 @@ config_desc = {
851 .bConfigurationValue = CONFIG_VALUE, 851 .bConfigurationValue = CONFIG_VALUE,
852 .iConfiguration = STRING_CONFIG, 852 .iConfiguration = STRING_CONFIG,
853 .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, 853 .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
854 .bMaxPower = 1, // self-powered 854 .bMaxPower = CONFIG_USB_GADGET_VBUS_DRAW / 2,
855}; 855};
856 856
857static struct usb_otg_descriptor 857static struct usb_otg_descriptor
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c
index 6eee760410d6..60d3f9e9b51f 100644
--- a/drivers/usb/gadget/gmidi.c
+++ b/drivers/usb/gadget/gmidi.c
@@ -222,7 +222,7 @@ static struct usb_config_descriptor config_desc = {
222 * power properties of the device. Is it selfpowered? 222 * power properties of the device. Is it selfpowered?
223 */ 223 */
224 .bmAttributes = USB_CONFIG_ATT_ONE, 224 .bmAttributes = USB_CONFIG_ATT_ONE,
225 .bMaxPower = 1, 225 .bMaxPower = CONFIG_USB_GADGET_VBUS_DRAW / 2,
226}; 226};
227 227
228/* B.3.1 Standard AC Interface Descriptor */ 228/* B.3.1 Standard AC Interface Descriptor */
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
index 00b7ed5013a6..5a3034fdfe47 100644
--- a/drivers/usb/gadget/printer.c
+++ b/drivers/usb/gadget/printer.c
@@ -252,7 +252,7 @@ static struct usb_config_descriptor config_desc = {
252 .bConfigurationValue = DEV_CONFIG_VALUE, 252 .bConfigurationValue = DEV_CONFIG_VALUE,
253 .iConfiguration = 0, 253 .iConfiguration = 0,
254 .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, 254 .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
255 .bMaxPower = 1 /* Self-Powered */ 255 .bMaxPower = CONFIG_USB_GADGET_VBUS_DRAW / 2,
256}; 256};
257 257
258static struct usb_interface_descriptor intf_desc = { 258static struct usb_interface_descriptor intf_desc = {
@@ -1476,7 +1476,6 @@ autoconf_fail:
1476 if (gadget->is_otg) { 1476 if (gadget->is_otg) {
1477 otg_desc.bmAttributes |= USB_OTG_HNP, 1477 otg_desc.bmAttributes |= USB_OTG_HNP,
1478 config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP; 1478 config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
1479 config_desc.bMaxPower = 4;
1480 } 1479 }
1481 1480
1482 spin_lock_init(&dev->lock); 1481 spin_lock_init(&dev->lock);
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index 2dee848b2f59..37879af1c433 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -159,7 +159,6 @@ static struct usb_configuration serial_config_driver = {
159 /* .bConfigurationValue = f(use_acm) */ 159 /* .bConfigurationValue = f(use_acm) */
160 /* .iConfiguration = DYNAMIC */ 160 /* .iConfiguration = DYNAMIC */
161 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 161 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
162 .bMaxPower = 1, /* 2 mA, minimal */
163}; 162};
164 163
165static int __init gs_bind(struct usb_composite_dev *cdev) 164static int __init gs_bind(struct usb_composite_dev *cdev)