usb: make usb descriptor power options configurable
Add two new kconfig options USB_SELF_POWERED and USB_MAX_POWER. These can be set by the user to change the USB configuration descriptor. USB_MAX_POWER can be set to any value between 0 and 250, but practically should be 50 or 250. These values are half the ammount of mA that the device will tell the host that it needs. USB_SELF_POWERED sets the 7th bit in bmAttributes of the USB config descriptor. Should be set to y if the device has its own power source other than USB. Signed-off-by: Barry Solomon <barry.solomon@dexcom.com>
This commit is contained in:
parent
86dc23a15d
commit
6118ca2785
4 changed files with 24 additions and 11 deletions
|
@ -86,11 +86,6 @@
|
|||
#define BCDDEVICE_RELNUM (BCD(KERNEL_VERSION_MAJOR) << 8 | \
|
||||
BCD(KERNEL_VERSION_MINOR))
|
||||
|
||||
/* 100mA max power, per 2mA units */
|
||||
/* USB 1.1 spec indicates 100mA(max) per unit load, up to 5 loads */
|
||||
#define MAX_LOW_POWER 0x32
|
||||
#define MAX_HIGH_POWER 0xFA
|
||||
|
||||
/* Highest value of Frame Number in SOF packets. */
|
||||
#define USB_SOF_MAX 2047
|
||||
|
||||
|
@ -100,10 +95,13 @@
|
|||
* D5:Remote Wakeup -> 0,
|
||||
* D4...0:Reserved -> 0
|
||||
*/
|
||||
#define USB_CONFIGURATION_ATTRIBUTES_REMOTE_WAKEUP 0x20
|
||||
#define USB_CONFIGURATION_ATTRIBUTES 0xC0 \
|
||||
| (COND_CODE_1(CONFIG_USB_DEVICE_REMOTE_WAKEUP, \
|
||||
(USB_CONFIGURATION_ATTRIBUTES_REMOTE_WAKEUP), (0)))
|
||||
#define USB_CONFIGURATION_ATTRIBUTES_REMOTE_WAKEUP BIT(5)
|
||||
#define USB_CONFIGURATION_ATTRIBUTES_SELF_POWERED BIT(6)
|
||||
#define USB_CONFIGURATION_ATTRIBUTES BIT(7) \
|
||||
| ((COND_CODE_1(CONFIG_USB_SELF_POWERED, \
|
||||
(USB_CONFIGURATION_ATTRIBUTES_SELF_POWERED), (0))) \
|
||||
| (COND_CODE_1(CONFIG_USB_DEVICE_REMOTE_WAKEUP, \
|
||||
(USB_CONFIGURATION_ATTRIBUTES_REMOTE_WAKEUP), (0))))
|
||||
|
||||
/* Classes */
|
||||
#define COMMUNICATION_DEVICE_CLASS 0x02
|
||||
|
|
|
@ -90,6 +90,21 @@ config USB_DEVICE_BOS
|
|||
config USB_DEVICE_OS_DESC
|
||||
bool "Enable MS OS Descriptors support"
|
||||
|
||||
config USB_SELF_POWERED
|
||||
bool "Set Self-powered characteristic"
|
||||
default y
|
||||
help
|
||||
Set Self-powered characteristic in bmAttributes to indicate
|
||||
self powered USB device.
|
||||
|
||||
config USB_MAX_POWER
|
||||
int "Set bMaxPower value"
|
||||
default 50
|
||||
range 0 250
|
||||
help
|
||||
Set bMaxPower value in the Standard Configuration Descriptor,
|
||||
the result is 2mA times the value provided.
|
||||
|
||||
menuconfig USB_VBUS_GPIO
|
||||
bool "Control VBUS via GPIO pin"
|
||||
depends on GPIO
|
||||
|
|
|
@ -156,7 +156,7 @@ struct dev_dfu_mode_descriptor dfu_mode_desc = {
|
|||
.bConfigurationValue = 1,
|
||||
.iConfiguration = 0,
|
||||
.bmAttributes = USB_CONFIGURATION_ATTRIBUTES,
|
||||
.bMaxPower = MAX_LOW_POWER,
|
||||
.bMaxPower = CONFIG_USB_MAX_POWER,
|
||||
},
|
||||
.sec_dfu_cfg = {
|
||||
/* Interface descriptor */
|
||||
|
|
|
@ -89,7 +89,7 @@ USBD_DEVICE_DESCR_DEFINE(primary) struct common_descriptor common_desc = {
|
|||
.bConfigurationValue = 1,
|
||||
.iConfiguration = 0,
|
||||
.bmAttributes = USB_CONFIGURATION_ATTRIBUTES,
|
||||
.bMaxPower = MAX_LOW_POWER,
|
||||
.bMaxPower = CONFIG_USB_MAX_POWER,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue