summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@google.com>2017-06-02 22:04:54 +0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2017-09-27 19:01:46 +0000
commit4165c750daeb48ac689d2d672eaef7a690e39c92 (patch)
treefd53606e8981f89396a3478166343002812664d4
parent7a16e40adb108eaedb3a46619fcdf99cdd9a1b9d (diff)
downloadchrome-ec-4165c750daeb48ac689d2d672eaef7a690e39c92.tar.gz
stm32: Add function to fetch unique id
BRANCH=none BUG=b:62280271 TEST=Flash hammer lsusb -d 18d1:5022 -v -v | grep iSerial shows different chip IDs on different boards. Change-Id: Id56b4509f184eb722d04fef94079c150dc2016e2 Reviewed-on: https://chromium-review.googlesource.com/523044 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Nick Sanders <nsanders@chromium.org> (cherry picked from commit aa15b8621d62b8926ca4853cdf9c336f0b892db9) Reviewed-on: https://chromium-review.googlesource.com/688234 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--chip/stm32/registers.h4
-rw-r--r--chip/stm32/system.c6
-rw-r--r--include/system.h9
3 files changed, 18 insertions, 1 deletions
diff --git a/chip/stm32/registers.h b/chip/stm32/registers.h
index ce73b4648b..d1e3758594 100644
--- a/chip/stm32/registers.h
+++ b/chip/stm32/registers.h
@@ -2316,7 +2316,9 @@ typedef volatile struct stm32_dma_regs stm32_dma_regs_t;
/* --- MISC --- */
-#define STM32_UNIQUE_ID 0x1ffff7ac
+#define STM32_UNIQUE_ID_ADDRESS REG32_ADDR(0x1ffff7ac)
+#define STM32_UNIQUE_ID_LENGTH (3 * 4)
+
#define STM32_CEC_BASE 0x40007800 /* STM32F373 */
#define STM32_LCD_BASE 0x40002400
diff --git a/chip/stm32/system.c b/chip/stm32/system.c
index 9f90d2db41..c40790be40 100644
--- a/chip/stm32/system.c
+++ b/chip/stm32/system.c
@@ -344,6 +344,12 @@ const char *system_get_chip_revision(void)
return "";
}
+int system_get_chip_unique_id(uint8_t **id)
+{
+ *id = (uint8_t *)STM32_UNIQUE_ID_ADDRESS;
+ return STM32_UNIQUE_ID_LENGTH;
+}
+
static int bkpdata_index_lookup(enum system_bbram_idx idx, int *msb)
{
*msb = 0;
diff --git a/include/system.h b/include/system.h
index 26a57d9d61..c7304a4d92 100644
--- a/include/system.h
+++ b/include/system.h
@@ -276,6 +276,15 @@ const char *system_get_chip_vendor(void);
const char *system_get_chip_name(void);
const char *system_get_chip_revision(void);
+/**
+ * Get a unique per-chip id.
+ *
+ * @param id Set to the address of the unique id data (statically
+ * allocated, or register-backed).
+ * @return Number of bytes available at the provided address.
+ */
+int system_get_chip_unique_id(uint8_t **id);
+
/*
* Common bbram entries. Chips don't necessarily need to implement
* all of these, error will be returned from system_get/set_bbram if