i.MX: Introduce imx_ocotp_read_uid()
Subsystems (3)
PATCH 1/2 i.MX: Introduce imx_ocotp_read_uid()
UID information in OCOTP is located in the same place on at least i.MX6, i.MX7 and i.MX8MQ. Create an SoC-agnostic helper to do all the work and convert i.MX6 to use it.
Signed-off-by Andrey Smirnov <[email protected]>
Cc Chris Healy <[email protected]>
Cc Lucas Stach <[email protected]>
--- arch/arm/mach-imx/imx6.c | 8 +------- arch/arm/mach-imx/include/mach/ocotp.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 7 deletions(-)
arch/arm/mach-imx/imx6.c +1 -7
@@ -192,13 +192,7 @@ int imx6_cpu_revision(void)u64 imx6_uid (void ) { -void __iomem *ocotpbase =IOMEM (MX6_OCOTP_BASE_ADDR ); -u64 uid; - - uid = ((u64 )readl (ocotpbase +MX6_OCOTP_CFG0 ) <<32 ); - uid |= (u64 )readl (ocotpbase +MX6_OCOTP_CFG1 ); - -return uid; +return imx_ocotp_read_uid (IOMEM (MX6_OCOTP_BASE_ADDR )); }int imx6_init (void )
arch/arm/mach-imx/include/mach/ocotp.h +14 -0
@@ -26,10 +26,24 @@#define OCOTP_BIT (n) FIELD_PREP(OCOTP_BIT_MASK, n)#define OCOTP_WIDTH (n) FIELD_PREP(OCOTP_WIDTH_MASK, (n) - 1) +#define OCOTP_OFFSET_CFG0 0x410 +#define OCOTP_OFFSET_CFG1 0x420 +int imx_ocotp_read_field (uint32_t field,unsigned *value);int imx_ocotp_write_field (uint32_t field,unsigned value);int imx_ocotp_permanent_write (int enable);bool imx_ocotp_sense_enable (bool enable); +static inline u64 imx_ocotp_read_uid (void __iomem *ocotp) +{ +u64 uid; + + uid =readl (ocotp +OCOTP_OFFSET_CFG0 ); + uid <<=32 ; + uid |=readl (ocotp +OCOTP_OFFSET_CFG1 ); + +return uid; +} +#endif /* __MACH_IMX_OCOTP_H */
Signature · 7 lines
2.21.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/2 ARM: i.MX8MQ: Display UID information on boot
Signed-off-by Andrey Smirnov <[email protected]>
Cc Chris Healy <[email protected]>
Cc Lucas Stach <[email protected]>
--- arch/arm/mach-imx/imx8mq.c | 7 +++++++ arch/arm/mach-imx/include/mach/imx8mq.h | 2 ++ 2 files changed, 9 insertions(+)
arch/arm/mach-imx/imx8mq.c +7 -0
@@ -20,6 +20,7 @@#include <mach/revision.h> #include <mach/imx8mq.h> #include <mach/reset-reason.h> +#include <mach/ocotp.h> #include <linux/iopoll.h> #include <linux/arm-smccc.h>
@@ -27,6 +28,11 @@#define FSL_SIP_BUILDINFO 0xC2000003#define FSL_SIP_BUILDINFO_GET_COMMITHASH 0x00 +u64 imx8mq_uid (void ) +{ +return imx_ocotp_read_uid (IOMEM (MX8MQ_OCOTP_BASE_ADDR )); +} +int imx8mq_init (void ) {void __iomem *anatop =IOMEM (MX8MQ_ANATOP_BASE_ADDR );
@@ -52,6 +58,7 @@ int imx8mq_init(void)* Reset reasons seem to be identical to that of i.MX7 */ imx_set_reset_reason (src +IMX7_SRC_SRSR , imx7_reset_reasons); +pr_info ("%s unique ID: %llx\n" , cputypestr,imx8mq_uid ());if (IS_ENABLED (CONFIG_ARM_SMCCC ) &&IS_ENABLED (CONFIG_FIRMWARE_IMX8MQ_ATF )) {
arch/arm/mach-imx/include/mach/imx8mq.h +2 -0
@@ -49,4 +49,6 @@ static inline int imx8mq_cpu_revision(void) return revision; } +u64 imx8mq_uid (void ); +#endif /* __MACH_IMX8_H */
Signature · 7 lines
2.21.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 8 lines · Andrey Smirnov
UID information in OCOTP is located in the same place on at least i.MX6, i.MX7 and i.MX8MQ. Create an SoC-agnostic helper to do all the work and convert i.MX6 to use it.
Signed-off-by Andrey Smirnov <[email protected]>Cc Chris Healy <[email protected]>Cc Lucas Stach <[email protected]>---
Applied, thanks
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox