summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chip/stm32/usb.c9
-rw-r--r--chip/stm32/usb_dwc.c9
-rw-r--r--include/system.h6
3 files changed, 22 insertions, 2 deletions
diff --git a/chip/stm32/usb.c b/chip/stm32/usb.c
index 018a26ce03..5788873df0 100644
--- a/chip/stm32/usb.c
+++ b/chip/stm32/usb.c
@@ -657,13 +657,20 @@ static int usb_set_serial(const char *serialno)
return EC_SUCCESS;
}
+/* By default, read serial number from flash, can be overridden. */
+__attribute__((weak))
+const char *board_read_serial(void)
+{
+ return flash_read_serial();
+}
+
/* Retrieve serial number from pstate flash. */
static int usb_load_serial(void)
{
const char *serialno;
int rv;
- serialno = flash_read_serial();
+ serialno = board_read_serial();
if (!serialno)
return EC_ERROR_ACCESS_DENIED;
diff --git a/chip/stm32/usb_dwc.c b/chip/stm32/usb_dwc.c
index 7ed0c20c60..fa5797079a 100644
--- a/chip/stm32/usb_dwc.c
+++ b/chip/stm32/usb_dwc.c
@@ -1371,13 +1371,20 @@ static int usb_set_serial(const char *serialno)
return EC_SUCCESS;
}
+/* By default, read serial number from flash, can be overridden. */
+__attribute__((weak))
+const char *board_read_serial(void)
+{
+ return flash_read_serial();
+}
+
/* Retrieve serial number from pstate flash. */
static int usb_load_serial(void)
{
const char *serialno;
int rv;
- serialno = flash_read_serial();
+ serialno = board_read_serial();
if (!serialno)
return EC_ERROR_ACCESS_DENIED;
diff --git a/include/system.h b/include/system.h
index c7304a4d92..0f01907574 100644
--- a/include/system.h
+++ b/include/system.h
@@ -285,6 +285,12 @@ const char *system_get_chip_revision(void);
*/
int system_get_chip_unique_id(uint8_t **id);
+/**
+ * Optional board-level callback functions to read a unique serial number per
+ * chip. Default implementation reads from flash (flash_read_serial).
+ */
+const char *board_read_serial(void) __attribute__((weak));
+
/*
* Common bbram entries. Chips don't necessarily need to implement
* all of these, error will be returned from system_get/set_bbram if