summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/cr50/board.h1
-rw-r--r--board/servo_micro/board.h3
-rw-r--r--board/servo_v4/board.h2
-rw-r--r--chip/g/usb.c12
-rw-r--r--chip/stm32/usb.c12
-rw-r--r--include/config.h6
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 */