Skip to contentSkip to conversation

ARM: mx6: Add function to read UNIQUE_ID

PATCH New Sean Anderson 3 participants 11 messages Feb 4, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: mx6: Add function to read UNIQUE_ID

This is almost identical to the imx7 version, except that the register names are different.

---

 arch/arm/mach-imx/mx6/soc.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
arch/arm/mach-imx/mx6/soc.c +33 -0
index bf6dddfdc9..cb729be46f 100644
@@ -11,6 +11,7 @@
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <asm/io.h>
+#include <asm/setup.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/sys_proto.h>
@@ -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
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/1 ARM: mx6: Add function to read UNIQUE_ID

Quoted 50 lines · Sean Anderson

This is almost identical to the imx7 version, except that the register names are different.

---

 arch/arm/mach-imx/mx6/soc.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
arch/arm/mach-imx/mx6/soc.c +26 -0
index bf6dddfdc9..cb729be46f 100644
@@ -11,6 +11,7 @@
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <asm/io.h>
+#include <asm/setup.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/sys_proto.h>
@@ -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 =

arch/arm/mach-imx/mx6/soc.c int arch_misc_init(void) · line 743

Quoted 10 lines
arch/arm/mach-imx/mx6/soc.c +7 -0
+		(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

NAK. This needs to use the normal mechanism to populate "serial#" directly and not abuse the old ATAG infrastructure.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210204/d63e1f4e/attachment.sig>
#2 lore raw

PATCH 1/1 ARM: mx6: Add function to read UNIQUE_ID

Quoted 27 lines · Tom Rini
Quoted 25 lines · Sean Anderson

This is almost identical to the imx7 version, except that the register names are different.

---

  arch/arm/mach-imx/mx6/soc.c | 33 +++++++++++++++++++++++++++++++++
  1 file changed, 33 insertions(+)
arch/arm/mach-imx/mx6/soc.c +1 -0
index bf6dddfdc9..cb729be46f 100644
@@ -11,6 +11,7 @@
  #include <linux/delay.h>
  #include <linux/errno.h>
  #include <asm/io.h>
+#include <asm/setup.h>
  #include <asm/arch/imx-regs.h>
  #include <asm/arch/clock.h>
  #include <asm/arch/sys_proto.h>
@@ -705,6 +706,38 @@ int arch_misc_init(void)
  }
  #endif
 
Quoted 12 lines

arch/arm/mach-imx/mx6/soc.c int arch_misc_init(void)

Quoted 12 lines
arch/arm/mach-imx/mx6/soc.c +12 -0
+#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

Quoted 2 lines

arch/arm/mach-imx/mx6/soc.c int arch_misc_init(void) · line 722

Quoted 2 lines
arch/arm/mach-imx/mx6/soc.c +2 -0
+ * 23:16 fuse 1
+ * The Y-coordinate of the die location on the wafer/SJC CHALLENGE/ 

Unique ID

Quoted 16 lines
Quoted 16 lines
arch/arm/mach-imx/mx6/soc.c +16 -0
+ * 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;
+}
Quoted 8 lines

arch/arm/mach-imx/mx6/soc.c int arch_misc_init(void) · line 743

Quoted 5 lines
arch/arm/mach-imx/mx6/soc.c +2 -0
+#endif
+
  /*
   * gpr_init() function is common for boards using MX6S, MX6DL, MX6D,
   * MX6Q and MX6QP processors

NAK. This needs to use the normal mechanism to populate "serial#" directly and not abuse the old ATAG infrastructure.

What is the "normal" mechanism? Define something like omap_die_id_serial which sets serial# directly? From what I can tell, get_board_serial is the "generic" function for separating the getting of the serial from the setting of serial#.

--Sean

#3 lore raw

PATCH 1/1 ARM: mx6: Add function to read UNIQUE_ID

Quoted 71 lines · Sean Anderson
Quoted 27 lines · Tom Rini
Quoted 25 lines · Sean Anderson

This is almost identical to the imx7 version, except that the register names are different.

---

  arch/arm/mach-imx/mx6/soc.c | 33 +++++++++++++++++++++++++++++++++
  1 file changed, 33 insertions(+)
arch/arm/mach-imx/mx6/soc.c +1 -0
index bf6dddfdc9..cb729be46f 100644
@@ -11,6 +11,7 @@
  #include <linux/delay.h>
  #include <linux/errno.h>
  #include <asm/io.h>
+#include <asm/setup.h>
  #include <asm/arch/imx-regs.h>
  #include <asm/arch/clock.h>
  #include <asm/arch/sys_proto.h>
@@ -705,6 +706,38 @@ int arch_misc_init(void)
  }
  #endif
 
Quoted 12 lines

arch/arm/mach-imx/mx6/soc.c int arch_misc_init(void)

Quoted 12 lines
arch/arm/mach-imx/mx6/soc.c +12 -0
+#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

Quoted 2 lines

arch/arm/mach-imx/mx6/soc.c int arch_misc_init(void) · line 722

Quoted 2 lines
arch/arm/mach-imx/mx6/soc.c +2 -0
+ * 23:16 fuse 1
+ * The Y-coordinate of the die location on the wafer/SJC CHALLENGE/

Unique ID

Quoted 16 lines
Quoted 16 lines
arch/arm/mach-imx/mx6/soc.c +16 -0
+ * 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;
+}
Quoted 8 lines

arch/arm/mach-imx/mx6/soc.c int arch_misc_init(void) · line 743

Quoted 5 lines
arch/arm/mach-imx/mx6/soc.c +2 -0
+#endif
+
  /*
   * gpr_init() function is common for boards using MX6S, MX6DL, MX6D,
   * MX6Q and MX6QP processors

NAK. This needs to use the normal mechanism to populate "serial#" directly and not abuse the old ATAG infrastructure.

Quoted 4 lines

What is the "normal" mechanism? Define something like omap_die_id_serial which sets serial# directly? From what I can tell, get_board_serial is the "generic" function for separating the getting of the serial from the setting of serial#.

The normal method is more like stm32 (arch/arm/mach-stm32mp/cpu.c) or rockchip (arch/arm/mach-rockchip/misc.c) where there's no ATAGs legacy design (which is where omap_die_id_serial is).

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210204/c98d5fc1/attachment.sig>
#4 lore raw

PATCH 1/1 ARM: mx6: Add function to read UNIQUE_ID

Quoted 44 lines · Tom Rini
Quoted 43 lines · Sean Anderson
Quoted 27 lines · Tom Rini
Quoted 25 lines · Sean Anderson

This is almost identical to the imx7 version, except that the register names are different.

---

   arch/arm/mach-imx/mx6/soc.c | 33 +++++++++++++++++++++++++++++++++
   1 file changed, 33 insertions(+)
arch/arm/mach-imx/mx6/soc.c +1 -0
index bf6dddfdc9..cb729be46f 100644
@@ -11,6 +11,7 @@
   #include <linux/delay.h>
   #include <linux/errno.h>
   #include <asm/io.h>
+#include <asm/setup.h>
   #include <asm/arch/imx-regs.h>
   #include <asm/arch/clock.h>
   #include <asm/arch/sys_proto.h>
@@ -705,6 +706,38 @@ int arch_misc_init(void)
   }
   #endif
 
Quoted 12 lines

arch/arm/mach-imx/mx6/soc.c int arch_misc_init(void)

Quoted 12 lines
arch/arm/mach-imx/mx6/soc.c +12 -0
+#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

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

arch/arm/mach-imx/mx6/soc.c int arch_misc_init(void) · line 722

Quoted 2 lines
arch/arm/mach-imx/mx6/soc.c +2 -0
+ * 23:16 fuse 1
+ * The Y-coordinate of the die location on the wafer/SJC CHALLENGE/

Unique ID

Quoted 2 lines
Quoted 2 lines
arch/arm/mach-imx/mx6/soc.c +2 -0
+ * 15:11 fuse 1
+ * The wafer number of the wafer on which the device was 

fabricated/SJC

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
arch/arm/mach-imx/mx6/soc.c +10 -0
+ * 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;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

arch/arm/mach-imx/mx6/soc.c int arch_misc_init(void)

Quoted 8 lines
arch/arm/mach-imx/mx6/soc.c +6 -0
+
+	serialnr->low = fuse->uid_low;
+	serialnr->high = fuse->uid_high;
+}
+#endif
+
   /*
    * gpr_init() function is common for boards using MX6S, MX6DL, 

MX6D,

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

arch/arm/mach-imx/mx6/soc.c int arch_misc_init(void) · line 743

Quoted 1 line
arch/arm/mach-imx/mx6/soc.c +0 -0
    * MX6Q and MX6QP processors

NAK. This needs to use the normal mechanism to populate "serial#" directly and not abuse the old ATAG infrastructure.

Quoted 9 lines
Quoted 4 lines

What is the "normal" mechanism? Define something like omap_die_id_serial which sets serial# directly? From what I can tell, get_board_serial is the "generic" function for separating the getting of the serial from the setting of serial#.

The normal method is more like stm32 (arch/arm/mach-stm32mp/cpu.c) or rockchip (arch/arm/mach-rockchip/misc.c) where there's no ATAGs legacy design (which is where omap_die_id_serial is).

Thanks for the reference. It's often difficult to figure out what the "best practice" is with so many boards added at different times.

--Sean

#5 lore raw

PATCH 1/1 ARM: mx6: Add function to read UNIQUE_ID

In reply to Sean Anderson
Quoted 72 lines · Sean Anderson
Quoted 27 lines · Tom Rini
Quoted 25 lines · Sean Anderson

This is almost identical to the imx7 version, except that the register names are different.

---

?? arch/arm/mach-imx/mx6/soc.c | 33 +++++++++++++++++++++++++++++++++ ?? 1 file changed, 33 insertions(+)

arch/arm/mach-imx/mx6/soc.c +0 -0
index bf6dddfdc9..cb729be46f 100644
@@ -11,6 +11,7 @@

?? #include <linux/delay.h>
?? #include <linux/errno.h>
?? #include <asm/io.h>
+#include <asm/setup.h>
?? #include <asm/arch/imx-regs.h>
?? #include <asm/arch/clock.h>
?? #include <asm/arch/sys_proto.h>

arch/arm/mach-imx/mx6/soc.c +0 -0
@@ -705,6 +706,38 @@ int arch_misc_init(void)
 ?? }

?? #endif

Quoted 12 lines

arch/arm/mach-imx/mx6/soc.c int arch_misc_init(void)

Quoted 12 lines
arch/arm/mach-imx/mx6/soc.c +12 -0
+#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

Quoted 2 lines
Quoted 2 lines

+ * 23:16 fuse 1
+ * The Y-coordinate of the die location on the wafer/SJC CHALLENGE/

Unique ID

Quoted 2 lines
Quoted 2 lines

+ * 15:11 fuse 1
+ * The wafer number of the wafer on which the device was

fabricated/SJC

Quoted 14 lines
Quoted 14 lines

+ * CHALLENGE/ Unique ID
+ * 10:0 fuse 1
+ * FSL-wide unique, encoded LOT ID STD II/SJC CHALLENGE/ Unique ID
+ */

arch/arm/mach-imx/mx6/soc.c +10 -0
+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;
+}
Quoted 8 lines
Quoted 5 lines
arch/arm/mach-imx/mx6/soc.c +2 -0
+#endif
+

?? /*
??? * gpr_init() function is common for boards using MX6S, MX6DL, MX6D, ??? * MX6Q and MX6QP processors

NAK.? This needs to use the normal mechanism to populate "serial#" directly and not abuse the old ATAG infrastructure.

Quoted 6 lines

What is the "normal" mechanism? Define something like omap_die_id_serial which sets serial# directly? From what I can tell, get_board_serial is the "generic" function for separating the getting of the serial from the setting of serial#.

--Sean

get_board_serial() is defined as empty function in bootm.h if CONFIG_SERIAL_TAG=n. But CONFIG_SERIAL_TAG is not documented anywhere.

board/gateworks/gw_ventana/gw_ventana.c has this comment:

#ifdef CONFIG_SERIAL_TAG
/*
* called when setting up ATAGS before booting kernel
* populate serialnum from the following (in order of priority):
* serial# env var
* eeprom
*/
void get_board_serial(struct tag_serialnr *serialnr)

serial# seems to be set generally in misc_init_r().
But doing this on a per board level seems to be an inadequate design for i.mx6. The best place for i.mx6 seems to be arch_misc_init().

@Tom:
Linux Kconfig has:

CONFIG_ATAGS:
This is the traditional way of passing data to the kernel at boot time. If you are solely relying on the flattened device tree (or the ARM_ATAG_DTB_COMPAT option) then you may unselect this option to remove ATAGS support from your kernel binary. If unsure, leave this to y.

CONFIG_DEPRECATED_PARAM_STRUCT
depends on ATAGS
This was deprecated in 2001 and announced to live on for 5 years. Some old boot loaders still use this way.

As this has been deprecated 20 years ago, why don't we remove it from U-Boot?

Best regards

Heinrich

#6 lore raw

PATCH 1/1 ARM: mx6: Add function to read UNIQUE_ID

Quoted 78 lines · Heinrich Schuchardt
Quoted 77 lines · Sean Anderson
Quoted 27 lines · Tom Rini
Quoted 25 lines · Sean Anderson

This is almost identical to the imx7 version, except that the register names are different.

---

?? arch/arm/mach-imx/mx6/soc.c | 33 +++++++++++++++++++++++++++++++++ ?? 1 file changed, 33 insertions(+)

arch/arm/mach-imx/mx6/soc.c +0 -0
index bf6dddfdc9..cb729be46f 100644
@@ -11,6 +11,7 @@

?? #include <linux/delay.h>
?? #include <linux/errno.h>
?? #include <asm/io.h>
+#include <asm/setup.h>
?? #include <asm/arch/imx-regs.h>
?? #include <asm/arch/clock.h>
?? #include <asm/arch/sys_proto.h>

arch/arm/mach-imx/mx6/soc.c +0 -0
@@ -705,6 +706,38 @@ int arch_misc_init(void)
 ?? }

?? #endif

Quoted 12 lines

arch/arm/mach-imx/mx6/soc.c int arch_misc_init(void)

Quoted 12 lines
arch/arm/mach-imx/mx6/soc.c +12 -0
+#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

Quoted 2 lines
Quoted 2 lines

+ * 23:16 fuse 1
+ * The Y-coordinate of the die location on the wafer/SJC CHALLENGE/

Unique ID

Quoted 2 lines
Quoted 2 lines

+ * 15:11 fuse 1
+ * The wafer number of the wafer on which the device was

fabricated/SJC

Quoted 14 lines
Quoted 14 lines

+ * CHALLENGE/ Unique ID
+ * 10:0 fuse 1
+ * FSL-wide unique, encoded LOT ID STD II/SJC CHALLENGE/ Unique ID
+ */

arch/arm/mach-imx/mx6/soc.c +10 -0
+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;
+}
Quoted 8 lines
Quoted 5 lines
arch/arm/mach-imx/mx6/soc.c +2 -0
+#endif
+

?? /*
??? * gpr_init() function is common for boards using MX6S, MX6DL, MX6D, ??? * MX6Q and MX6QP processors

NAK.? This needs to use the normal mechanism to populate "serial#" directly and not abuse the old ATAG infrastructure.

What is the "normal" mechanism? Define something like omap_die_id_serial which sets serial# directly? From what I can tell, get_board_serial is the "generic" function for separating the getting of the serial from the setting of serial#.

Quoted 4 lines
Quoted 1 line

--Sean

get_board_serial() is defined as empty function in bootm.h if CONFIG_SERIAL_TAG=n. But CONFIG_SERIAL_TAG is not documented anywhere.

Correct, it's ATAGs related stuff, so quite old and at best may have been documented in the README at some point.

Quoted 10 lines

board/gateworks/gw_ventana/gw_ventana.c has this comment:

#ifdef CONFIG_SERIAL_TAG
/*
* called when setting up ATAGS before booting kernel
* populate serialnum from the following (in order of priority):
* serial# env var
* eeprom
*/
void get_board_serial(struct tag_serialnr *serialnr)

Right.

Quoted 3 lines

serial# seems to be set generally in misc_init_r().
But doing this on a per board level seems to be an inadequate design for i.mx6. The best place for i.mx6 seems to be arch_misc_init().

Yes, there's a number of reasonable examples of where to populate serial# from, and a few examples from when we had to support the kernel with it.

Quoted 10 lines

@Tom:
Linux Kconfig has:

CONFIG_ATAGS:
This is the traditional way of passing data to the kernel at boot time. If you are solely relying on the flattened device tree (or the ARM_ATAG_DTB_COMPAT option) then you may unselect this option to remove ATAGS support from your kernel binary. If unsure, leave this to y.

Quoted 7 lines

CONFIG_DEPRECATED_PARAM_STRUCT
depends on ATAGS
This was deprecated in 2001 and announced to live on for 5 years. Some old boot loaders still use this way.

As this has been deprecated 20 years ago, why don't we remove it from U-Boot?

The history is a lot more complex than that. The earliest starting date for "ATAGs is dead, use DT" would be 2010 or so when Linaro started real work on migrating ARM to DT. I also _think_ that deprecated param struct note is about what predated ATAGs actually.

But, we can't universally drop ATAGs support from U-Boot as we support hardware that runs on pre-device tree kernels only (Nokia N900) or older VxWorks that also used ATAGs I _think__. But we certainly have some cases that should be cleaned up and disabled, hence my series yesterday.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210204/50990f58/attachment.sig>
#7 lore raw

PATCH 1/1 ARM: mx6: Add function to read UNIQUE_ID

In reply to Sean Anderson
Quoted 4 lines · Sean Anderson

This is almost identical to the imx7 version, except that the register names are different.

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?

Best regards

Heinrich

Quoted 57 lines

---

  arch/arm/mach-imx/mx6/soc.c | 33 +++++++++++++++++++++++++++++++++
  1 file changed, 33 insertions(+)
arch/arm/mach-imx/mx6/soc.c +33 -0
index bf6dddfdc9..cb729be46f 100644
@@ -11,6 +11,7 @@
  #include <linux/delay.h>
  #include <linux/errno.h>
  #include <asm/io.h>
+#include <asm/setup.h>
  #include <asm/arch/imx-regs.h>
  #include <asm/arch/clock.h>
  #include <asm/arch/sys_proto.h>
@@ -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
#8 lore raw

PATCH 1/1 ARM: mx6: Add function to read UNIQUE_ID

Quoted 4 lines · Heinrich Schuchardt
Quoted 3 lines · Sean Anderson

This is almost identical to the imx7 version, except that the register names are different.

Quoted 8 lines
Quoted 1 line

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

Quoted 65 lines

Best regards

Heinrich

Quoted 59 lines

---

  arch/arm/mach-imx/mx6/soc.c | 33 +++++++++++++++++++++++++++++++++
  1 file changed, 33 insertions(+)
arch/arm/mach-imx/mx6/soc.c +13 -0
index bf6dddfdc9..cb729be46f 100644
@@ -11,6 +11,7 @@
  #include <linux/delay.h>
  #include <linux/errno.h>
  #include <asm/io.h>
+#include <asm/setup.h>
  #include <asm/arch/imx-regs.h>
  #include <asm/arch/clock.h>
  #include <asm/arch/sys_proto.h>
@@ -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
+ */

arch/arm/mach-imx/mx6/soc.c +12 -0
+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
#9 lore raw

PATCH 1/1 ARM: mx6: Add function to read UNIQUE_ID

Quoted 4 lines · Sean Anderson
Quoted 1 line · Heinrich Schuchardt

On 2/4/21 9:29 PM, Sean Anderson wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

This is almost identical to the imx7 version, except that the register names are different.

Hello Sean,

I tried to understand where this serial number is ending up.

See common/fdt_support.c and fdt_root(). That's the common use and way it's populated and passed on.

Quoted 16 lines
Quoted 2 lines

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);
Quoted 6 lines

#endif

	return 0;
}

I would like to do the same on an i.MX6-based board.

Please note that the WaRP7 case of mixing the serial# with some other string is not the common / best practices case. It's typically just the die-ID or similar value without other text around it, which makes for an easy generic function. The WaRP7 case makes it harder for imx7 to have a generic everyone gets it populated function like imx6 could have with your patch and a few changes, and like I want to go adjust the currently unused imx8 code to do.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210204/0cc448ab/attachment.sig>
#10 lore raw

PATCH 1/1 ARM: mx6: Add function to read UNIQUE_ID

Quoted 8 lines · Tom Rini
Quoted 7 lines · Sean Anderson
Quoted 4 lines · Heinrich Schuchardt
Quoted 3 lines · Sean Anderson

This is almost identical to the imx7 version, except that the register names are different.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

Hello Sean,

I tried to understand where this serial number is ending up.

See common/fdt_support.c and fdt_root(). That's the common use and way it's populated and passed on.

This is where the environment variable serial# ends up. But get_board_serial() which Sean is implementing does not populate serial#. That is why I asked.

Best regards

Heinrich