]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
usb gadget: USB_GADGET_VBUS_DRAW Kconfig option
authorDavid Brownell <dbrownell@users.sourceforge.net>
Fri, 12 Sep 2008 16:39:06 +0000 (09:39 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 17 Oct 2008 21:40:58 +0000 (14:40 -0700)
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>
drivers/usb/gadget/Kconfig
drivers/usb/gadget/cdc2.c
drivers/usb/gadget/composite.c
drivers/usb/gadget/ether.c
drivers/usb/gadget/f_loopback.c
drivers/usb/gadget/f_sourcesink.c
drivers/usb/gadget/file_storage.c
drivers/usb/gadget/gmidi.c
drivers/usb/gadget/printer.c
drivers/usb/gadget/serial.c

index c0dfd9be31158a7e5b73bcca657e5f6501f7e439..1a72715bce8a4a6a63fe891c091b98432c94c093 100644 (file)
@@ -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
 
index a724fc149850ad30deef93e73b6da96879cadd99..5495b171cf29b11a89dbe1918cf2efbf854fb30a 100644 (file)
@@ -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 */
 };
 
 /*-------------------------------------------------------------------------*/
index f79fdb839cb8face68082e289d9d54cde4bee250..f2da0269e1b11fa8123e6b83eadbcbd689687a33 100644 (file)
@@ -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;
index 944c8e889ab4368bae56b96a679aeb590323648a..37252d0012a77ae6ef616c3db23065e0beee6b84 100644 (file)
@@ -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 */
 };
 
 /*-------------------------------------------------------------------------*/
index 87dde012dacc8d251e25fc1d23eb73eeb1cf684a..8affe1dfc2c11200a8a7962ffac1e6381af3124a 100644 (file)
@@ -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 */
 };
 
index f18c3a14d72a11096de4d4d3593c4524ba4cbc58..dc84d26d283575be85097611dc044b8e0aaa1374 100644 (file)
@@ -552,7 +552,6 @@ static struct usb_configuration sourcesink_driver = {
        .setup          = sourcesink_setup,
        .bConfigurationValue = 3,
        .bmAttributes   = USB_CONFIG_ATT_SELFPOWER,
-       .bMaxPower      = 1,    /* 2 mA, minimal */
        /* .iConfiguration = DYNAMIC */
 };
 
index e0f616f39ba0118fe4391dbfc5a25d0f437f5f18..c4e62a6297d7254b375c682e24e3c3d9c5d84e5d 100644 (file)
@@ -851,7 +851,7 @@ config_desc = {
        .bConfigurationValue =  CONFIG_VALUE,
        .iConfiguration =       STRING_CONFIG,
        .bmAttributes =         USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
-       .bMaxPower =            1,      // self-powered
+       .bMaxPower =            CONFIG_USB_GADGET_VBUS_DRAW / 2,
 };
 
 static struct usb_otg_descriptor
index 6eee760410d6c052492cc854ea11cbc1ac840ffa..60d3f9e9b51fdef421f239b3055b09325a30f74a 100644 (file)
@@ -222,7 +222,7 @@ static struct usb_config_descriptor config_desc = {
         * power properties of the device. Is it selfpowered?
         */
        .bmAttributes =         USB_CONFIG_ATT_ONE,
-       .bMaxPower =            1,
+       .bMaxPower =            CONFIG_USB_GADGET_VBUS_DRAW / 2,
 };
 
 /* B.3.1  Standard AC Interface Descriptor */
index 00b7ed5013a6a70a57a9c504aa84e96f95b1a18c..5a3034fdfe473f0f777e80bd426d2882a8e9fd53 100644 (file)
@@ -252,7 +252,7 @@ static struct usb_config_descriptor config_desc = {
        .bConfigurationValue =  DEV_CONFIG_VALUE,
        .iConfiguration =       0,
        .bmAttributes =         USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
-       .bMaxPower =            1       /* Self-Powered */
+       .bMaxPower =            CONFIG_USB_GADGET_VBUS_DRAW / 2,
 };
 
 static struct usb_interface_descriptor intf_desc = {
@@ -1476,7 +1476,6 @@ autoconf_fail:
        if (gadget->is_otg) {
                otg_desc.bmAttributes |= USB_OTG_HNP,
                config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
-               config_desc.bMaxPower = 4;
        }
 
        spin_lock_init(&dev->lock);
index 2dee848b2f59637dbc2cfebacfca1085eb4ff208..37879af1c4334c12090c0f544d1ae472f0c88540 100644 (file)
@@ -159,7 +159,6 @@ static struct usb_configuration serial_config_driver = {
        /* .bConfigurationValue = f(use_acm) */
        /* .iConfiguration = DYNAMIC */
        .bmAttributes   = USB_CONFIG_ATT_SELFPOWER,
-       .bMaxPower      = 1,    /* 2 mA, minimal */
 };
 
 static int __init gs_bind(struct usb_composite_dev *cdev)