Commit b3082f1b authored by Anson Huang's avatar Anson Huang Committed by Shawn Guo

ARM: imx: Add i.MX7ULP SoC serial number support

i.MX7ULP's unique ID layout in OCOTP is different from other
i.MX6/7 SoCs as below:

OCOTP layout		unique ID

0x4b0 bit[15:0]		bit[15:0]
0x4c0 bit[15:0]		bit[31:16]
0x4d0 bit[15:0]		bit[47:32]
0x4e0 bit[15:0]		bit[63:48]

Add support for reading serial number from OCOTP on i.MX7ULP.
Signed-off-by: default avatarAnson Huang <Anson.Huang@nxp.com>
Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
parent 7947e323
...@@ -15,6 +15,11 @@ ...@@ -15,6 +15,11 @@
#define OCOTP_UID_H 0x420 #define OCOTP_UID_H 0x420
#define OCOTP_UID_L 0x410 #define OCOTP_UID_L 0x410
#define OCOTP_ULP_UID_1 0x4b0
#define OCOTP_ULP_UID_2 0x4c0
#define OCOTP_ULP_UID_3 0x4d0
#define OCOTP_ULP_UID_4 0x4e0
unsigned int __mxc_cpu_type; unsigned int __mxc_cpu_type;
static unsigned int imx_soc_revision; static unsigned int imx_soc_revision;
...@@ -164,6 +169,7 @@ struct device * __init imx_soc_device_init(void) ...@@ -164,6 +169,7 @@ struct device * __init imx_soc_device_init(void)
soc_id = "i.MX7D"; soc_id = "i.MX7D";
break; break;
case MXC_CPU_IMX7ULP: case MXC_CPU_IMX7ULP:
ocotp_compat = "fsl,imx7ulp-ocotp";
soc_id = "i.MX7ULP"; soc_id = "i.MX7ULP";
break; break;
default: default:
...@@ -178,12 +184,26 @@ struct device * __init imx_soc_device_init(void) ...@@ -178,12 +184,26 @@ struct device * __init imx_soc_device_init(void)
} }
if (!IS_ERR_OR_NULL(ocotp)) { if (!IS_ERR_OR_NULL(ocotp)) {
if (__mxc_cpu_type == MXC_CPU_IMX7ULP) {
regmap_read(ocotp, OCOTP_ULP_UID_4, &val);
soc_uid = val & 0xffff;
regmap_read(ocotp, OCOTP_ULP_UID_3, &val);
soc_uid <<= 16;
soc_uid |= val & 0xffff;
regmap_read(ocotp, OCOTP_ULP_UID_2, &val);
soc_uid <<= 16;
soc_uid |= val & 0xffff;
regmap_read(ocotp, OCOTP_ULP_UID_1, &val);
soc_uid <<= 16;
soc_uid |= val & 0xffff;
} else {
regmap_read(ocotp, OCOTP_UID_H, &val); regmap_read(ocotp, OCOTP_UID_H, &val);
soc_uid = val; soc_uid = val;
regmap_read(ocotp, OCOTP_UID_L, &val); regmap_read(ocotp, OCOTP_UID_L, &val);
soc_uid <<= 32; soc_uid <<= 32;
soc_uid |= val; soc_uid |= val;
} }
}
soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d.%d", soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d.%d",
(imx_soc_revision >> 4) & 0xf, (imx_soc_revision >> 4) & 0xf,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment