diff options
author | Nick Sanders <nsanders@chromium.org> | 2016-07-26 08:22:34 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-08-08 18:22:30 -0700 |
commit | 3e42a3b059d35310fe41bcc55d2d1b5d0efe0bd4 (patch) | |
tree | fb568512db8acb0c9acc6a94344117ada540c6dc | |
parent | 1e7b5f3c071d219df2866004980662622ea810d8 (diff) | |
download | chrome-ec-3e42a3b059d35310fe41bcc55d2d1b5d0efe0bd4.tar.gz |
servo_v4: servo_micro: cr50: fix usb power declaration
Servo_micro sets usb config maxpower to 100mA.
Servo_v4 is set to self powered as it's powered by a
shared vbus and not be the bub it's connected to.
cr50 is self powered as no power is transmitted as part of CCD.
* Add CONFIG_USB_MAXPOWER_MA to define USB maximum power draw requested
per board.
* Add CONFIG_USB_SELF_POWERED to indicate that a device is not
powered by allocated USB power.
BUG=chromium:631302
TEST=lsusb reports 100mA bMaxPower (micro), Self powered (v4)
BRANCH=None
Change-Id: I79b8ce46f32d94f16104a4a8080104e30dce7f2c
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363153
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | board/cr50/board.h | 1 | ||||
-rw-r--r-- | board/servo_micro/board.h | 3 | ||||
-rw-r--r-- | board/servo_v4/board.h | 2 | ||||
-rw-r--r-- | chip/g/usb.c | 12 | ||||
-rw-r--r-- | chip/stm32/usb.c | 12 | ||||
-rw-r--r-- | include/config.h | 6 |
6 files changed, 32 insertions, 4 deletions
diff --git a/board/cr50/board.h b/board/cr50/board.h index c3b9066730..e74efb193f 100644 --- a/board/cr50/board.h +++ b/board/cr50/board.h @@ -57,6 +57,7 @@ #define CONFIG_CASE_CLOSED_DEBUG #define CONFIG_USB_PID 0x5014 +#define CONFIG_USB_SELF_POWERED /* Enable SPI Master (SPI) module */ #define CONFIG_SPI_MASTER diff --git a/board/servo_micro/board.h b/board/servo_micro/board.h index 03e583afeb..b2543c3ac3 100644 --- a/board/servo_micro/board.h +++ b/board/servo_micro/board.h @@ -35,6 +35,9 @@ #define CONFIG_USB_CONSOLE #define CONFIG_USB_UPDATE +#undef CONFIG_USB_MAXPOWER_MA +#define CONFIG_USB_MAXPOWER_MA 100 + #define CONFIG_USB_SERIALNO #define DEFAULT_SERIALNO "Uninitialized" diff --git a/board/servo_v4/board.h b/board/servo_v4/board.h index 623c688843..eaad6385b2 100644 --- a/board/servo_v4/board.h +++ b/board/servo_v4/board.h @@ -29,6 +29,8 @@ #define CONFIG_USB_CONSOLE #define CONFIG_USB_UPDATE +#define CONFIG_USB_SELF_POWERED + #define CONFIG_USB_SERIALNO #define DEFAULT_SERIALNO "Uninitialized" diff --git a/chip/g/usb.c b/chip/g/usb.c index b5dc8f08bc..809c1aefb0 100644 --- a/chip/g/usb.c +++ b/chip/g/usb.c @@ -191,6 +191,14 @@ static void showregs(void) #define CONFIG_USB_BCD_DEV 0x0100 /* 1.00 */ #endif +#ifndef USB_BMATTRIBUTES +#ifdef CONFIG_USB_SELF_POWERED +#define USB_BMATTRIBUTES 0xc0 /* Self powered. */ +#else +#define USB_BMATTRIBUTES 0x80 /* Bus powered. */ +#endif +#endif + /* USB Standard Device Descriptor */ static const struct usb_device_descriptor dev_desc = { .bLength = USB_DT_DEVICE_SIZE, @@ -217,8 +225,8 @@ const struct usb_config_descriptor USB_CONF_DESC(conf) = { .bNumInterfaces = USB_IFACE_COUNT, .bConfigurationValue = 1, /* Caution: hard-coded value */ .iConfiguration = USB_STR_VERSION, - .bmAttributes = 0x80, /* bus powered */ - .bMaxPower = 250, /* MaxPower 500 mA */ + .bmAttributes = USB_BMATTRIBUTES, /* bus or self powered */ + .bMaxPower = (CONFIG_USB_MAXPOWER_MA / 2), }; const uint8_t usb_string_desc[] = { diff --git a/chip/stm32/usb.c b/chip/stm32/usb.c index 85e2320642..82b0926702 100644 --- a/chip/stm32/usb.c +++ b/chip/stm32/usb.c @@ -35,6 +35,14 @@ #define CONFIG_USB_BCD_DEV 0x0100 /* 1.00 */ #endif +#ifndef USB_BMATTRIBUTES +#ifdef CONFIG_USB_SELF_POWERED +#define USB_BMATTRIBUTES 0xc0 /* Self powered. */ +#else +#define USB_BMATTRIBUTES 0x80 /* Bus powered. */ +#endif +#endif + #ifndef CONFIG_USB_SERIALNO #define USB_STR_SERIALNO 0 #else @@ -67,8 +75,8 @@ const struct usb_config_descriptor USB_CONF_DESC(conf) = { .bNumInterfaces = USB_IFACE_COUNT, .bConfigurationValue = 1, .iConfiguration = USB_STR_VERSION, - .bmAttributes = 0x80, /* bus powered */ - .bMaxPower = 250, /* MaxPower 500 mA */ + .bmAttributes = USB_BMATTRIBUTES, /* bus or self powered */ + .bMaxPower = (CONFIG_USB_MAXPOWER_MA / 2), }; const uint8_t usb_string_desc[] = { diff --git a/include/config.h b/include/config.h index 6a89266106..a752e4c4d1 100644 --- a/include/config.h +++ b/include/config.h @@ -2113,6 +2113,12 @@ /* Support programmable USB device iSerial field. */ #undef CONFIG_USB_SERIALNO +/* Support reporting of configuration bMaxPower in mA */ +#define CONFIG_USB_MAXPOWER_MA 500 + +/* Support reporting as self powered in USB configuration. */ +#undef CONFIG_USB_SELF_POWERED + /******************************************************************************/ /* USB port switch */ |