diff options
author | Nick Sanders <nsanders@chromium.org> | 2016-04-06 14:25:45 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-05-26 16:17:26 -0700 |
commit | 56ee8aefc33505a7df4e4148001a11ac461907a3 (patch) | |
tree | 9aa84b4f26d7396878757bb7ed79bebaa18f59a2 /include | |
parent | 5cc3cac589d3e869266c18ed7e538a769496478f (diff) | |
download | chrome-ec-56ee8aefc33505a7df4e4148001a11ac461907a3.tar.gz |
servo_micro: add programmable serial number
This change provides a console command for setting,
and loading a usb serial number from flash. This
feature adds CONFIG_USB_SERIALNO, and currently only
has a useful implementation when PSTATE is present.
BUG=chromium:571477
TEST=serialno set abcdef; serialno load; reboot
BRANCH=none
Change-Id: I3b24cfa2d52d54118bc3fd54b276e3d95412d245
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/337359
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/config.h | 3 | ||||
-rw-r--r-- | include/flash.h | 16 | ||||
-rw-r--r-- | include/usb_descriptor.h | 18 |
3 files changed, 37 insertions, 0 deletions
diff --git a/include/config.h b/include/config.h index 591af79c5f..3ecf920140 100644 --- a/include/config.h +++ b/include/config.h @@ -2011,6 +2011,9 @@ */ #undef CONFIG_USB_PORT_POWER_SMART_INVERTED +/* Support programmable USB device iSerial field. */ +#undef CONFIG_USB_SERIALNO + /******************************************************************************/ /* USB port switch */ diff --git a/include/flash.h b/include/flash.h index b065e7bb1b..03a6e89c25 100644 --- a/include/flash.h +++ b/include/flash.h @@ -245,4 +245,20 @@ uint32_t flash_get_protect(void); */ int flash_set_protect(uint32_t mask, uint32_t flags); +/** + * Get the serial number from flash. + * + * @return char * ascii serial number string. + */ +const char *flash_read_serial(void); + +/** + * Set the serial number in flash. + * + * @param serialno ascii serial number string < 30 char. + * + * @return success status. + */ +int flash_write_serial(const char *serialno); + #endif /* __CROS_EC_FLASH_H */ diff --git a/include/usb_descriptor.h b/include/usb_descriptor.h index baa6e6421b..a29b9eda76 100644 --- a/include/usb_descriptor.h +++ b/include/usb_descriptor.h @@ -233,6 +233,24 @@ struct usb_setup_packet { WIDESTR(str) \ } +#ifdef CONFIG_USB_SERIALNO +/* String Descriptor for USB, for editable strings. */ +#define USB_STRING_LEN 30 +struct usb_string_desc { + uint8_t _len; + uint8_t _type; + wchar_t _data[USB_STRING_LEN]; +}; +#define USB_WR_STRING_DESC(str) \ + (&(struct usb_string_desc) { \ + /* As above, two bytes metadata, no null terminator. */ \ + sizeof(WIDESTR(str)) + 2 - 2, \ + USB_DT_STRING, \ + WIDESTR(str) \ +}) +extern struct usb_string_desc *usb_serialno_desc; +#endif + /* Use these macros for declaring descriptors, to order them properly */ #define USB_CONF_DESC(name) CONCAT2(usb_desc_, name) \ __attribute__((section(".rodata.usb_desc_" STRINGIFY(name)))) |