ARM: mx6: Add function to set serial#
Subsystems (3)
PATCH v2 1/1 ARM: mx6: Add function to set serial#
The serial number OTP is similar to the imx7 version, except that the register names are different. This also sets serial# directly, instead of providing board_get_serial.
---
Changes in v2:
- Populate serial# directly and call this from arch_misc_init
arch/arm/mach-imx/mx6/soc.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
arch/arm/mach-imx/mx6/soc.c +37 -0
@@ -7,6 +7,7 @@*/ #include <common.h> +#include <env.h> #include <init.h> #include <linux/delay.h> #include <linux/errno.h>
@@ -696,11 +697,47 @@ void imx_setup_hdmi(void)#endif #ifdef CONFIG_ARCH_MISC_INIT +/* +* 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 +*/ +static void setup_serial_number (void ) +{ +char serial_string[17 ]; +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; + +if (env_get ("serial#" )) +return ; + +snprintf (serial_string,sizeof (serial_string),"%08x%08x" , + fuse->uid_low, fuse->uid_high); +env_set ("serial#" , serial_string); +} +int arch_misc_init (void ) {#ifdef CONFIG_FSL_CAAM sec_init ();#endif +setup_serial_number ();return 0 ; }#endif
Signature · 1 line
2.25.1
PATCH v2 1/1 ARM: mx6: Add function to set serial#
Quoted 5 lines · Sean Anderson
The serial number OTP is similar to the imx7 version, except that the register names are different. This also sets serial# directly, instead of providing
board_get_serial.Signed-off-by Sean Anderson <[email protected]>
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/6fce3ea6/attachment.sig>
PATCH v2 1/1 ARM: mx6: Add function to set serial#
Quoted 10 lines · Tom Rini
Quoted 5 lines · Sean Anderson
The serial number OTP is similar to the imx7 version, except that the register names are different. This also sets serial# directly, instead of providing
board_get_serial.Signed-off-by Sean Anderson <[email protected]>Reviewed-by Tom Rini <[email protected]>
The current patch is without effect.
We need to enable CONFIG_ARCH_MISC_INIT on i.MX6 by default, e.g.
arch/arm/Kconfig +1 -0
@@ -901,6 +901,7 @@ config ARCH_MX6 select SYS_FSL_HAS_SEC select SYS_FSL_SEC_COMPAT_4 select SYS_FSL_SEC_LE + select ARCH_MISC_INIT imply MXC_GPIO imply SYS_THUMB_BUILD
Best regards
Heinrich
PATCH v2 1/1 ARM: mx6: Add function to set serial#
Quoted 31 lines · Heinrich Schuchardt
Quoted 11 lines · Tom Rini
Quoted 6 lines · Sean Anderson
The serial number OTP is similar to the imx7 version, except that the register names are different. This also sets serial# directly, instead of
providingboard_get_serial.Signed-off-by Sean Anderson <[email protected]>Reviewed-by Tom Rini <[email protected]>The current patch is without effect.
We need to enable
CONFIG_ARCH_MISC_INITon i.MX6 by default, e.g.arch/arm/Kconfig +1
-0@@ -901,6 +901,7 @@ config ARCH_MX6 select SYS_FSL_HAS_SEC select SYS_FSL_SEC_COMPAT_4 select SYS_FSL_SEC_LE + select ARCH_MISC_INIT imply MXC_GPIO imply SYS_THUMB_BUILDBest regards
Quoted 1 line
Heinrich
Do any boards on i.MX6 currently set serial# themselves? arch_misc_init is called before board_late_init, which is (AFACT) typically where boards set serial#. Any boards which conditionally set serial# (e.g. from an eeprom) will not set things up properly. I looked over things quickly, and I didn't see anything. So it may be fine to enable this.
Though by this logic, shouldn't you have implied ARCH_MISC_INIT back in 90865614b4 ("ARM: mx6: make CAAM usable on the i.MX6 boards")?
--Sean
PATCH v2 1/1 ARM: mx6: Add function to set serial#
Quoted 42 lines · Sean Anderson
Quoted 29 lines · Heinrich Schuchardt
Quoted 11 lines · Tom Rini
Quoted 6 lines · Sean Anderson
The serial number OTP is similar to the imx7 version, except that the register names are different. This also sets serial# directly, instead of
providingboard_get_serial.Signed-off-by Sean Anderson <[email protected]>Reviewed-by Tom Rini <[email protected]>The current patch is without effect.
We need to enable
CONFIG_ARCH_MISC_INITon i.MX6 by default, e.g.arch/arm/Kconfig +0
-0@@ -901,6 +901,7 @@ config ARCH_MX6????????? select
SYS_FSL_HAS_SEC
????????? selectSYS_FSL_SEC_COMPAT_4
????????? selectSYS_FSL_SEC_LE
+?????? selectARCH_MISC_INIT
????????? implyMXC_GPIO
????????? implySYS_THUMB_BUILDQuoted 3 lines
Best regards
Heinrich
Do any boards on i.MX6 currently set serial# themselves?
arch_misc_initis called beforeboard_late_init, which is (AFACT) typically where boards set serial#. Any boards which conditionally set serial# (e.g. from an eeprom) will not set things up properly. I looked over things quickly, and I didn't see anything. So it may be fine to enable this.
Quoted 2 lines
Though by this logic, shouldn't you have implied
ARCH_MISC_INITback in90865614b4("ARM: mx6: make CAAM usable on the i.MX6 boards")?
+1 to activate the flag.
I was already wondering why the random number generator on my Wandboard was not working.
The three i.MX6 boards with misc_init_r() don's set serial#:
board/congatec/cgtqmx6eval/cgtqmx6eval.c:755:int misc_init_r(void) board/toradex/apalis_imx6/apalis_imx6.c:786:int misc_init_r(void) board/toradex/colibri_imx6/colibri_imx6.c:679:int misc_init_r(void)
git grep -n 'serial#' | grep mx6
finds nothing.
Best regards
Heinrich
Quoted 2 lines
--Sean
PATCH v2 1/1 ARM: mx6: Add function to set serial#
Quoted 52 lines · Heinrich Schuchardt
Quoted 42 lines · Sean Anderson
Quoted 29 lines · Heinrich Schuchardt
Quoted 11 lines · Tom Rini
Quoted 6 lines · Sean Anderson
The serial number OTP is similar to the imx7 version, except that the register names are different. This also sets serial# directly, instead of
providingboard_get_serial.Signed-off-by Sean Anderson <[email protected]>Reviewed-by Tom Rini <[email protected]>The current patch is without effect.
We need to enable
CONFIG_ARCH_MISC_INITon i.MX6 by default, e.g.arch/arm/Kconfig +0
-0@@ -901,6 +901,7 @@ config ARCH_MX6????????? select
SYS_FSL_HAS_SEC
????????? selectSYS_FSL_SEC_COMPAT_4
????????? selectSYS_FSL_SEC_LE
+?????? selectARCH_MISC_INIT
????????? implyMXC_GPIO
????????? implySYS_THUMB_BUILDQuoted 3 lines
Best regards
Heinrich
Do any boards on i.MX6 currently set serial# themselves?
arch_misc_initis called beforeboard_late_init, which is (AFACT) typically where boards set serial#. Any boards which conditionally set serial# (e.g. from an eeprom) will not set things up properly. I looked over things quickly, and I didn't see anything. So it may be fine to enable this.Quoted 2 lines
Though by this logic, shouldn't you have implied
ARCH_MISC_INITback in90865614b4("ARM: mx6: make CAAM usable on the i.MX6 boards")?+1 to activate the flag.
I was already wondering why the random number generator on my Wandboard was not working.The three i.MX6 boards with
misc_init_r()don's set serial#:
Quoted 7 lines
board/congatec/cgtqmx6eval/cgtqmx6eval.c:755:int
misc_init_r(void)board/toradex/apalis_imx6/apalis_imx6.c:786:intmisc_init_r(void)board/toradex/colibri_imx6/colibri_imx6.c:679:intmisc_init_r(void)git grep -n 'serial#' | grep mx6
finds nothing.
No. We have things in Kconfig so that boards can enable what they want without having to go and change the config.h file. We only use select/imply for things that it's between required (if you don't have this, your platform does not function at all) and strongly encouraged (it should be hard to opt out of distro defaults for example because this is what makes almost any distribution turn-key to use on a given platform). Everything else should be something easily turned on/off in the defconfig. Is "serial#" and in turn the serial-number property in the device tree handy? Sure is. Has i.MX6 been going fine without it for it's long lifespan? Yup. Is there an argument that it should be easier to opt-out of on all the other platforms? Probably so, yes (I think there's some cases where Linux userspace expects it for some stuff, I want to say allwinner? Maybe Pi?).
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/6516b4da/attachment.sig>
PATCH v2 1/1 ARM: mx6: Add function to set serial#
In reply to Heinrich SchuchardtQuoted 21 lines · Heinrich Schuchardt
Quoted 10 lines · Tom Rini
Quoted 5 lines · Sean Anderson
The serial number OTP is similar to the imx7 version, except that the register names are different. This also sets serial# directly, instead of providing
board_get_serial.Signed-off-by Sean Anderson <[email protected]>Reviewed-by Tom Rini <[email protected]>The current patch is without effect.
We need to enable
CONFIG_ARCH_MISC_INITon i.MX6 by default, e.g.arch/arm/Kconfig +0
-0
arch/arm/Kconfig config ARCH_MX6 · line 906
Quoted 6 lines
arch/arm/Kconfig +1
-0@@ -901,6 +901,7 @@ config ARCH_MX6 select SYS_FSL_HAS_SEC select SYS_FSL_SEC_COMPAT_4 select SYS_FSL_SEC_LE + select ARCH_MISC_INIT imply MXC_GPIO imply SYS_THUMB_BUILD
No, we don't need to enable it by default. If boards want it, they can enable it.
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/763e223b/attachment.sig>
PATCH v2 1/1 ARM: mx6: Add function to set serial#
In reply to Sean AndersonQuoted 5 lines
The serial number OTP is similar to the imx7 version, except that the register names are different. This also sets serial# directly, instead of providing
board_get_serial.Signed-off-by Sean Anderson <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================