Re: PXA27x UDC Power

Justin Clacherty <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
Justin Clacherty wrote:
> Alan Stern wrote:
>> You might want to generalize this.  There's nothing special about the 
>> Ethernet gadget; other sorts might need high power too.
>>
>> And there's no reason to make it a boolean.  You might as well have
>> people specify the actual maximum mA value here, so that the drivers
>> can incorporate the number (divided by 2!) directly into their
>> descriptors.
>>   
>
> Is this better?

Actually, the range of the value should be constrained.  Here we go.

Justin.

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4

_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
usb_gadget_power.diff (text/x-patch, 3.4 KB)
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index f81d08d..e1a6593 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -81,6 +81,18 @@ config USB_GADGET_DEBUG_FS
 config	USB_GADGET_SELECTED
 	boolean
 
+config USB_GADGET_POWER
+	int "Maximum Power (2-500 mA)"
+	depends on USB_GADGET
+	range 2 500
+	default 2
+	help
+	   Some devices need to use a higher powered port to make it easier
+	   to recharge batteries, others might need less.  Put the maximum power
+	   your device will draw in mA here.
+
+	   The possible range of values is 2 - 500 mA.  Defaults to 2 mA (self-powered).
+
 #
 # USB Peripheral Controller Support
 #
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 9e732bf..16c288b 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -421,8 +421,6 @@ #define USB_BUFSIZ	256
  * NOTE:  Controllers like superh_udc should probably be able to use
  * an RNDIS-only configuration.
  *
- * FIXME define some higher-powered configurations to make it easier
- * to recharge batteries ...
  */
 
 #define DEV_CONFIG_VALUE	1	/* cdc or subset */
@@ -464,7 +462,7 @@ eth_config = {
 	.bConfigurationValue =	DEV_CONFIG_VALUE,
 	.iConfiguration =	STRING_CDC,
 	.bmAttributes =		USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
-	.bMaxPower =		50,
+	.bMaxPower =		CONFIG_USB_GADGET_POWER / 2,
 };
 
 #ifdef	CONFIG_USB_ETH_RNDIS
@@ -478,7 +476,7 @@ rndis_config = {
 	.bConfigurationValue =  DEV_RNDIS_CONFIG_VALUE,
 	.iConfiguration =       STRING_RNDIS,
 	.bmAttributes =		USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
-	.bMaxPower =            50,
+	.bMaxPower =		CONFIG_USB_GADGET_POWER / 2,
 };
 #endif
 
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 1d174dc..e8d8d96 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -843,7 +843,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_POWER / 2,
 };
 
 static struct usb_otg_descriptor
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c
index 0689189..9d3d312 100644
--- a/drivers/usb/gadget/gmidi.c
+++ b/drivers/usb/gadget/gmidi.c
@@ -210,7 +210,7 @@ static struct usb_config_descriptor conf
 	 * power properties of the device. Is it selfpowered?
 	 */
 	.bmAttributes =		USB_CONFIG_ATT_ONE,
-	.bMaxPower =		1,
+	.bMaxPower =		CONFIG_USB_GADGET_POWER / 2,
 };
 
 /* B.3.1  Standard AC Interface Descriptor */
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index f5738eb..ad8ce76 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -340,7 +340,7 @@ static struct usb_config_descriptor gs_b
 	.bConfigurationValue =	GS_BULK_CONFIG_ID,
 	.iConfiguration =	GS_BULK_CONFIG_STR_ID,
 	.bmAttributes =		USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
-	.bMaxPower =		1,
+	.bMaxPower =		CONFIG_USB_GADGET_POWER / 2,
 };
 
 static struct usb_config_descriptor gs_acm_config_desc = {
@@ -351,7 +351,7 @@ static struct usb_config_descriptor gs_a
 	.bConfigurationValue =	GS_ACM_CONFIG_ID,
 	.iConfiguration =	GS_ACM_CONFIG_STR_ID,
 	.bmAttributes =		USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
-	.bMaxPower =		1,
+	.bMaxPower =		CONFIG_USB_GADGET_POWER / 2,
 };
 
 static const struct usb_interface_descriptor gs_bulk_interface_desc = {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.