Commit 852cc548b3fdf6d5b46e2a96f876d14608ccdcf4
Committed by
Stefano Babic
1 parent
1ab1ffded4
Exists in
smarc_8mq_lf_v2020.04
and in
11 other branches
warp7: Set u-boot serial# based on OTP value
u-boot has a standard "serial#" environment variable that is suitable for storing the iSerial number we will supply via the USB device descriptor. serial# is automatically picked up by the disk subsystem in u-boot - thus providing a handy unique identifier in /dev/disk/by-id as detailed below. Storing the hardware serial identifier in serial# means we can change the serial# if we want before USB enumeration - thus making iSerial automatic via OTP but overridable if necessary. This patch reads the defined OTP fuse and sets environment variable "serial#" to the value read. With this patch in place the USB mass storage device will appear in /dev/disk/by-id with a unique name based on the OTP value. For example /dev/disk/by-id/usb-Linux_UMS_disk_0_WaRP7-0xf42400d3000001d4-0:0 Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Cc: Fabio Estevam <fabio.estevam@nxp.com> Cc: Rui Miguel Silva <rui.silva@linaro.org> Cc: Ryan Harkin <ryan.harkin@linaro.org> Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
Showing 2 changed files with 17 additions and 0 deletions Side-by-side Diff
board/warp7/warp7.c
... | ... | @@ -23,6 +23,8 @@ |
23 | 23 | #include <power/pmic.h> |
24 | 24 | #include <power/pfuze3000_pmic.h> |
25 | 25 | #include "../freescale/common/pfuze.h" |
26 | +#include <asm/setup.h> | |
27 | +#include <asm/bootm.h> | |
26 | 28 | |
27 | 29 | DECLARE_GLOBAL_DATA_PTR; |
28 | 30 | |
... | ... | @@ -186,6 +188,10 @@ |
186 | 188 | int board_late_init(void) |
187 | 189 | { |
188 | 190 | struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; |
191 | +#ifdef CONFIG_SERIAL_TAG | |
192 | + struct tag_serialnr serialnr; | |
193 | + char serial_string[0x20]; | |
194 | +#endif | |
189 | 195 | |
190 | 196 | imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads)); |
191 | 197 | |
... | ... | @@ -196,6 +202,14 @@ |
196 | 202 | * since we use PMIC_PWRON to reset the board. |
197 | 203 | */ |
198 | 204 | clrsetbits_le16(&wdog->wcr, 0, 0x10); |
205 | + | |
206 | +#ifdef CONFIG_SERIAL_TAG | |
207 | + /* Set serial# standard environment variable based on OTP settings */ | |
208 | + get_board_serial(&serialnr); | |
209 | + snprintf(serial_string, sizeof(serial_string), "WaRP7-0x%08x%08x", | |
210 | + serialnr.low, serialnr.high); | |
211 | + env_set("serial#", serial_string); | |
212 | +#endif | |
199 | 213 | |
200 | 214 | return 0; |
201 | 215 | } |
include/configs/warp7.h