From: Sean Anderson Date: Thu, 4 Feb 2021 15:56:23 -0500 Subject: [PATCH] ARM: mx6: Add function to read UNIQUE_ID In-Reply-To: <545e1b5b-3d12-b98a-6167-c3095b96436e@gmx.de> References: <20210204202948.1609959-1-sean.anderson@seco.com> <545e1b5b-3d12-b98a-6167-c3095b96436e@gmx.de> Message-ID: <77d17133-8fe9-3560-6f18-91bd79c439d2@seco.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 2/4/21 3:52 PM, Heinrich Schuchardt wrote: > On 2/4/21 9:29 PM, Sean Anderson wrote: >> This is almost identical to the imx7 version, except that the register >> names are different. >> >> Signed-off-by: Sean Anderson > > Hello Sean, > > I tried to understand where this serial number is ending up. > > It seems to be used by the bootm command. But shouldn't we use it to > define environment variable #serial instead? Yes. Typically boards will use get_board_serial to set serial#. For example, the warp7 board does int board_late_init(void) { /* ... snip ... */ #ifdef CONFIG_SERIAL_TAG /* Set serial# standard environment variable based on OTP settings */ get_board_serial(&serialnr); snprintf(serial_string, sizeof(serial_string), "WaRP7-0x%08x%08x", serialnr.low, serialnr.high); env_set("serial#", serial_string); #endif return 0; } I would like to do the same on an i.MX6-based board. --Sean > > Best regards > > Heinrich > >> --- >> >> arch/arm/mach-imx/mx6/soc.c | 33 +++++++++++++++++++++++++++++++++ >> 1 file changed, 33 insertions(+) >> >> diff --git a/arch/arm/mach-imx/mx6/soc.c b/arch/arm/mach-imx/mx6/soc.c >> index bf6dddfdc9..cb729be46f 100644 >> --- a/arch/arm/mach-imx/mx6/soc.c >> +++ b/arch/arm/mach-imx/mx6/soc.c >> @@ -11,6 +11,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -705,6 +706,38 @@ int arch_misc_init(void) >> } >> #endif >> >> +#ifdef CONFIG_SERIAL_TAG >> +/* >> + * UNIQUE_ID describes a unique ID based on silicon wafer >> + * and die X/Y position >> + * >> + * UNIQUE_ID offset 0x410 >> + * 31:0 fuse 0 >> + * FSL-wide unique, encoded LOT ID STD II/SJC CHALLENGE/ Unique ID >> + * >> + * UNIQUE_ID offset 0x420 >> + * 31:24 fuse 1 >> + * The X-coordinate of the die location on the wafer/SJC CHALLENGE/ >> Unique ID >> + * 23:16 fuse 1 >> + * The Y-coordinate of the die location on the wafer/SJC CHALLENGE/ >> Unique ID >> + * 15:11 fuse 1 >> + * The wafer number of the wafer on which the device was fabricated/SJC >> + * CHALLENGE/ Unique ID >> + * 10:0 fuse 1 >> + * FSL-wide unique, encoded LOT ID STD II/SJC CHALLENGE/ Unique ID >> + */ >> +void get_board_serial(struct tag_serialnr *serialnr) >> +{ >> + struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR; >> + struct fuse_bank *bank = &ocotp->bank[0]; >> + struct fuse_bank0_regs *fuse = >> + (struct fuse_bank0_regs *)bank->fuse_regs; >> + >> + serialnr->low = fuse->uid_low; >> + serialnr->high = fuse->uid_high; >> +} >> +#endif >> + >> /* >> * gpr_init() function is common for boards using MX6S, MX6DL, MX6D, >> * MX6Q and MX6QP processors >> >