ARM: mach-imx: set system_serial from ocotp registers
Subsystems (3)
PATCH 1/1 ARM: mach-imx: set system_serial from ocotp registers
From: Stefan Christ <[email protected]>
The i.MX6 fuses have two 32 bit registers (OCOTP_CFG0 and OCOTP_CFG1) that contain an 64 bit unique id. Use them to setup the system serial, which can be seen in '/proc/cpuinfo'.
---
Hello,
I've noticed that arch/arm/mach-imx/ocotp.c duplicates functionality of drivers/soc/imx/soc-imx.c . Should this be resolved?
Thanks.
arch/arm/mach-imx/Makefile | 1 + arch/arm/mach-imx/common.h | 1 + arch/arm/mach-imx/mach-imx6q.c | 1 + arch/arm/mach-imx/mach-imx6sl.c | 1 + arch/arm/mach-imx/mach-imx6sx.c | 1 + arch/arm/mach-imx/mach-imx6ul.c | 3 +++ arch/arm/mach-imx/ocotp.c | 40 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 48 insertions(+) create mode 100644 arch/arm/mach-imx/ocotp.c
arch/arm/mach-imx/Makefile +1 -0
@@ -48,6 +48,7 @@ obj-$(CONFIG_SOC_IMX6UL) += mach-imx6ul.o obj-$(CONFIG_SOC_IMX7D_CA7) += mach-imx7d.o obj-$(CONFIG_SOC_IMX7D_CM4) += mach-imx7d-cm4.o obj-$(CONFIG_SOC_IMX7ULP) += mach-imx7ulp.o pm-imx7ulp.o +obj-$(CONFIG_SOC_IMX6) += ocotp.o ifeq ($(CONFIG_SUSPEND),y) AFLAGS_suspend-imx6.o :=-Wa,-march=armv7-a
arch/arm/mach-imx/common.h +1 -0
@@ -34,6 +34,7 @@ void imx_aips_allow_unprivileged_access(const char *compat);int mxc_device_init (void );void imx_set_soc_revision (unsigned int rev);void imx_init_revision_from_anatop (void ); +void imx_init_serial_from_ocotp (const char *ocotp_compat);void imx6_enable_rbc (bool enable);void imx_gpc_check_dt (void );void imx_gpc_set_arm_power_in_lpm (bool power_off);
arch/arm/mach-imx/mach-imx6q.c +1 -0
@@ -292,6 +292,7 @@ static void __init imx6q_init_irq(void) {imx_gpc_check_dt ();imx_init_revision_from_anatop (); +imx_init_serial_from_ocotp ("fsl,imx6q-ocotp" );imx_init_l2cache ();imx_src_init ();irqchip_init ();
arch/arm/mach-imx/mach-imx6sl.c +1 -0
@@ -57,6 +57,7 @@ static void __init imx6sl_init_irq(void) {imx_gpc_check_dt ();imx_init_revision_from_anatop (); +imx_init_serial_from_ocotp ("fsl,imx6sl-ocotp" );imx_init_l2cache ();imx_src_init ();irqchip_init ();
arch/arm/mach-imx/mach-imx6sx.c +1 -0
@@ -74,6 +74,7 @@ static void __init imx6sx_init_irq(void) {imx_gpc_check_dt ();imx_init_revision_from_anatop (); +imx_init_serial_from_ocotp ("fsl,imx6sx-ocotp" );imx_init_l2cache ();imx_src_init ();irqchip_init ();
arch/arm/mach-imx/mach-imx6ul.c +3 -0
@@ -14,6 +14,7 @@#include "common.h" #include "cpuidle.h" +#include "hardware.h" static void __init imx6ul_enet_clk_init (void ) {
@@ -64,6 +65,8 @@ static void __init imx6ul_init_machine(void)static void __init imx6ul_init_irq (void ) {imx_init_revision_from_anatop (); +imx_init_serial_from_ocotp (cpu_is_imx6ull () ?"fsl,imx6ull-ocotp" : +"fsl,imx6ul-ocotp" );imx_src_init ();irqchip_init ();imx6_pm_ccm_init ("fsl,imx6ul-ccm" );
arch/arm/mach-imx/ocotp.c new file +40 -0
@@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2018 PHYTEC Messtechnik GmbH, +* Author: Stefan Christ <[email protected]> +*/ + +#include <linux/io.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <asm/system_info.h> + +#include "common.h" + +#define OCOTP_CFG0 0x410 +#define OCOTP_CFG1 0x420 + +void __init imx_init_serial_from_ocotp (const char *ocotp_compat) +{ +struct device_node *np; +void __iomem *base; + + np =of_find_compatible_node (NULL ,NULL , ocotp_compat); +if (!np) { +pr_warn ("failed to find ocotp node in dtb!\n" ); +return ; + } + + base =of_iomap (np,0 ); +if (!base) { +pr_warn ("failed to map ocotp\n" ); + goto put_node; + } + + system_serial_low =readl_relaxed (base +OCOTP_CFG0 ); + system_serial_high =readl_relaxed (base +OCOTP_CFG1 ); + +iounmap (base); +put_node: +of_node_put (np); +}
Signature · 7 lines
2.7.4 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 11 lines · Robert Karszniewicz
From: Stefan Christ <[email protected]>
The i.MX6 fuses have two 32 bit registers (
OCOTP_CFG0andOCOTP_CFG1) that contain an 64 bit unique id. Use them to setup the system serial, which can be seen in '/proc/cpuinfo'.Signed-off-by Stefan Christ <[email protected]>Signed-off-by Yunus Bas <[email protected]>Cc Stefan Lengfeld <[email protected]>Signed-off-by Robert Karszniewicz <[email protected]>
Quoted 5 lines
---
Hello,I've noticed that
arch/arm/mach-imx/ocotp.cduplicates functionality ofdrivers/soc/imx/soc-imx.c. Should this be resolved?
I think it would be best to just have drivers/soc/imx/soc-imx.c and not add another one. In particular, the serial number is not normally exposed through system_serial_low/system_serial_high these days, but rather the architecture-independent soc device.
Looking at that driver though, I see it still has a bug in that it creates a bogus soc_device on most (non-imx) machines. I think there was a fix a while ago, but it never got merged.
Arnd
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Arnd and Robert,
Quoted 16 lines · Arnd Bergmann
Quoted 14 lines · Robert Karszniewicz
From: Stefan Christ <[email protected]>
The i.MX6 fuses have two 32 bit registers (
OCOTP_CFG0andOCOTP_CFG1) that contain an 64 bit unique id. Use them to setup the system serial, which can be seen in '/proc/cpuinfo'.Signed-off-by Stefan Christ <[email protected]>Signed-off-by Yunus Bas <[email protected]>Cc Stefan Lengfeld <[email protected]>Signed-off-by Robert Karszniewicz <[email protected]>---
Hello,
Quoted 7 lines
Quoted 2 lines
I've noticed that
arch/arm/mach-imx/ocotp.cduplicates functionality ofdrivers/soc/imx/soc-imx.c. Should this be resolved?I think it would be best to just have
drivers/soc/imx/soc-imx.cand not add another one. In particular, the serial number is not normally exposed through system_serial_low/system_serial_high these days, but rather the architecture-independent soc device.
I would also suggest to just drop the patch.
Reading the serial number was added in 2019/v5.5 to the mainline kernel. See commit 8267ff89b7131 ("ARM: imx: Add serial number support for i.MX6/7 SoCs"):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8267ff89b7131
It's just exposed at "/sys/devices/soc0/serial_number" instead of in "/proc/cpuinfo" to userspace.
Kind regards,
Stefan
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hello Arnd and Stefan,
Quoted 16 lines · Arnd Bergmann
Quoted 14 lines · Robert Karszniewicz
From: Stefan Christ <[email protected]>
The i.MX6 fuses have two 32 bit registers (
OCOTP_CFG0andOCOTP_CFG1) that contain an 64 bit unique id. Use them to setup the system serial, which can be seen in '/proc/cpuinfo'.Signed-off-by Stefan Christ <[email protected]>Signed-off-by Yunus Bas <[email protected]>Cc Stefan Lengfeld <[email protected]>Signed-off-by Robert Karszniewicz <[email protected]>---
Hello,
Quoted 7 lines
Quoted 2 lines
I've noticed that
arch/arm/mach-imx/ocotp.cduplicates functionality ofdrivers/soc/imx/soc-imx.c. Should this be resolved?I think it would be best to just have
drivers/soc/imx/soc-imx.cand not add another one. In particular, the serial number is not normally exposed through system_serial_low/system_serial_high these days, but rather the architecture-independent soc device.
I've done a bit more research and I think I understand better now.
In the same vein, our patch
"[PATCH 1/2] ARM: mach-imx: imx6ul: Print SOC revision on boot and set system_rev"[1]
should drop the line where system_rev is set, and only imx_print_silicon_rev() should be kept? And the second patch in that series should be dropped, too.
Thank you for your replies, the both of you.
[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2020-November/620524.html
Quoted 3 lines
Looking at that driver though, I see it still has a bug in that it creates a bogus
soc_deviceon most (non-imx) machines. I think there was a fix a while ago, but it never got merged.
Just interested; Is there somewhere I can read more about that bug/fix?
Regards,
Robert
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel