diff options
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)))) |