Message ID | 20210830135716.67744-1-oleksandr.suvorov@foundries.io |
---|---|
State | Changes Requested |
Delegated to: | Tom Rini |
Headers | show |
Series | mx7ulp: add getting a board serial number | expand |
On Mon, Aug 30, 2021 at 04:57:16PM +0300, Oleksandr Suvorov wrote: > From: Ricardo Salveti <ricardo@foundries.io> > > Get Unique ID of SoC iMX7ULP, using the logic described in Fusemap > (IMX7ULPRMB2_Rev0_Fusemap) attached in the i.MX 7ULP APRM [1]. > > [1] > https://www.nxp.com/docs/en/reference-manual/IMX7ULPRMB2.pdf > > Signed-off-by: Ricardo Salveti <ricardo@foundries.io> > Co-developed-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io> > Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io> > --- > > arch/arm/mach-imx/mx7ulp/soc.c | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/arch/arm/mach-imx/mx7ulp/soc.c b/arch/arm/mach-imx/mx7ulp/soc.c > index 320f24dd29..d088ee093d 100644 > --- a/arch/arm/mach-imx/mx7ulp/soc.c > +++ b/arch/arm/mach-imx/mx7ulp/soc.c > @@ -13,6 +13,7 @@ > #include <asm/arch/sys_proto.h> > #include <asm/mach-imx/boot_mode.h> > #include <asm/mach-imx/hab.h> > +#include <asm/setup.h> > #include <linux/bitops.h> > > #define PMC0_BASE_ADDR 0x410a1000 > @@ -363,3 +364,25 @@ enum boot_device get_boot_device(void) > > return boot_dev; > } > + > +#ifdef CONFIG_SERIAL_TAG > +/* > + * OCOTP_CFG (SJC CHALLENGE, Unique ID) > + * i.MX 7ULP Applications Processor Reference Manual, Rev. 0, 09/2020 > + * > + * OCOTP_CFG0 offset 0x4B0: 15:0 -> 15:0 bits of Unique ID > + * OCOTP_CFG1 offset 0x4C0: 15:0 -> 31:16 bits of Unique ID > + * OCOTP_CFG2 offset 0x4D0: 15:0 -> 47:32 bits of Unique ID > + * OCOTP_CFG3 offset 0x4E0: 15:0 -> 63:48 bits of 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[1]; > + struct fuse_bank1_regs *fuse = > + (struct fuse_bank1_regs *)bank->fuse_regs; > + > + serialnr->low = (fuse->cfg0 & 0xFFFF) + ((fuse->cfg1 & 0xFFFF) << 16); > + serialnr->high = (fuse->cfg2 & 0xFFFF) + ((fuse->cfg3 & 0xFFFF) << 16); > +} > +#endif It's not either of your fault that CONFIG_SERIAL_TAG has been abused for so long. Please rework this on top of: https://patchwork.ozlabs.org/project/uboot/list/?series=260161 Or, since I plan to pull that in to -next soon, circle back to this problem in a week or two.
Hi Tom, On Mon, Aug 30, 2021 at 5:08 PM Tom Rini <trini@konsulko.com> wrote: > > On Mon, Aug 30, 2021 at 04:57:16PM +0300, Oleksandr Suvorov wrote: > > > From: Ricardo Salveti <ricardo@foundries.io> > > > > Get Unique ID of SoC iMX7ULP, using the logic described in Fusemap > > (IMX7ULPRMB2_Rev0_Fusemap) attached in the i.MX 7ULP APRM [1]. > > > > [1] > > https://www.nxp.com/docs/en/reference-manual/IMX7ULPRMB2.pdf > > > > Signed-off-by: Ricardo Salveti <ricardo@foundries.io> > > Co-developed-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io> > > Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io> > > --- > > > > arch/arm/mach-imx/mx7ulp/soc.c | 23 +++++++++++++++++++++++ > > 1 file changed, 23 insertions(+) > > > > diff --git a/arch/arm/mach-imx/mx7ulp/soc.c b/arch/arm/mach-imx/mx7ulp/soc.c > > index 320f24dd29..d088ee093d 100644 > > --- a/arch/arm/mach-imx/mx7ulp/soc.c > > +++ b/arch/arm/mach-imx/mx7ulp/soc.c > > @@ -13,6 +13,7 @@ > > #include <asm/arch/sys_proto.h> > > #include <asm/mach-imx/boot_mode.h> > > #include <asm/mach-imx/hab.h> > > +#include <asm/setup.h> > > #include <linux/bitops.h> > > > > #define PMC0_BASE_ADDR 0x410a1000 > > @@ -363,3 +364,25 @@ enum boot_device get_boot_device(void) > > > > return boot_dev; > > } > > + > > +#ifdef CONFIG_SERIAL_TAG > > +/* > > + * OCOTP_CFG (SJC CHALLENGE, Unique ID) > > + * i.MX 7ULP Applications Processor Reference Manual, Rev. 0, 09/2020 > > + * > > + * OCOTP_CFG0 offset 0x4B0: 15:0 -> 15:0 bits of Unique ID > > + * OCOTP_CFG1 offset 0x4C0: 15:0 -> 31:16 bits of Unique ID > > + * OCOTP_CFG2 offset 0x4D0: 15:0 -> 47:32 bits of Unique ID > > + * OCOTP_CFG3 offset 0x4E0: 15:0 -> 63:48 bits of 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[1]; > > + struct fuse_bank1_regs *fuse = > > + (struct fuse_bank1_regs *)bank->fuse_regs; > > + > > + serialnr->low = (fuse->cfg0 & 0xFFFF) + ((fuse->cfg1 & 0xFFFF) << 16); > > + serialnr->high = (fuse->cfg2 & 0xFFFF) + ((fuse->cfg3 & 0xFFFF) << 16); > > +} > > +#endif > > It's not either of your fault that CONFIG_SERIAL_TAG has been abused for > so long. Please rework this on top of: > https://patchwork.ozlabs.org/project/uboot/list/?series=260161 > Thanks for pointing me to the upcoming patches! I'm rebasing my patch on top of them. The new version is coming. > Or, since I plan to pull that in to -next soon, circle back to this > problem in a week or two. > > -- > Tom
diff --git a/arch/arm/mach-imx/mx7ulp/soc.c b/arch/arm/mach-imx/mx7ulp/soc.c index 320f24dd29..d088ee093d 100644 --- a/arch/arm/mach-imx/mx7ulp/soc.c +++ b/arch/arm/mach-imx/mx7ulp/soc.c @@ -13,6 +13,7 @@ #include <asm/arch/sys_proto.h> #include <asm/mach-imx/boot_mode.h> #include <asm/mach-imx/hab.h> +#include <asm/setup.h> #include <linux/bitops.h> #define PMC0_BASE_ADDR 0x410a1000 @@ -363,3 +364,25 @@ enum boot_device get_boot_device(void) return boot_dev; } + +#ifdef CONFIG_SERIAL_TAG +/* + * OCOTP_CFG (SJC CHALLENGE, Unique ID) + * i.MX 7ULP Applications Processor Reference Manual, Rev. 0, 09/2020 + * + * OCOTP_CFG0 offset 0x4B0: 15:0 -> 15:0 bits of Unique ID + * OCOTP_CFG1 offset 0x4C0: 15:0 -> 31:16 bits of Unique ID + * OCOTP_CFG2 offset 0x4D0: 15:0 -> 47:32 bits of Unique ID + * OCOTP_CFG3 offset 0x4E0: 15:0 -> 63:48 bits of 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[1]; + struct fuse_bank1_regs *fuse = + (struct fuse_bank1_regs *)bank->fuse_regs; + + serialnr->low = (fuse->cfg0 & 0xFFFF) + ((fuse->cfg1 & 0xFFFF) << 16); + serialnr->high = (fuse->cfg2 & 0xFFFF) + ((fuse->cfg3 & 0xFFFF) << 16); +} +#endif