Skip to content

Commit fd0bf2b

Browse files
MrVanShawn Guo
authored andcommitted
soc: imx8m: Dump higher 64bits UID
i.MX8MP UID is actually 128bits and partitioned into two parts. The 1st 64bits are at 0x410 and 0x420, and 2nd 64bits are at 0xE00 and 0xE10. Dump the whole 128bits for i.MX8MP, by set soc_uid as an array with two u64. Signed-off-by: Peng Fan <[email protected]> Reviewed-by: Marco Felsch <[email protected]> Signed-off-by: Shawn Guo <[email protected]>
1 parent 6981050 commit fd0bf2b

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

drivers/soc/imx/soc-imx8m.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define OCOTP_UID_HIGH 0x420
2525

2626
#define IMX8MP_OCOTP_UID_OFFSET 0x10
27+
#define IMX8MP_OCOTP_UID_HIGH 0xE00
2728

2829
/* Same as ANADIG_DIGPROG_IMX7D */
2930
#define ANADIG_DIGPROG_IMX8MM 0x800
@@ -96,9 +97,13 @@ static int imx8mp_soc_uid(struct platform_device *pdev, u64 *socuid)
9697
struct imx8_soc_drvdata *drvdata = platform_get_drvdata(pdev);
9798
void __iomem *ocotp_base = drvdata->ocotp_base;
9899

99-
*socuid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH + IMX8MP_OCOTP_UID_OFFSET);
100-
*socuid <<= 32;
101-
*socuid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW + IMX8MP_OCOTP_UID_OFFSET);
100+
socuid[0] = readl_relaxed(ocotp_base + OCOTP_UID_HIGH + IMX8MP_OCOTP_UID_OFFSET);
101+
socuid[0] <<= 32;
102+
socuid[0] |= readl_relaxed(ocotp_base + OCOTP_UID_LOW + IMX8MP_OCOTP_UID_OFFSET);
103+
104+
socuid[1] = readl_relaxed(ocotp_base + IMX8MP_OCOTP_UID_HIGH + 0x10);
105+
socuid[1] <<= 32;
106+
socuid[1] |= readl_relaxed(ocotp_base + IMX8MP_OCOTP_UID_HIGH);
102107

103108
return 0;
104109
}
@@ -220,7 +225,7 @@ static int imx8m_soc_probe(struct platform_device *pdev)
220225
const struct of_device_id *id;
221226
struct soc_device *soc_dev;
222227
u32 soc_rev = 0;
223-
u64 soc_uid = 0;
228+
u64 soc_uid[2] = {0, 0};
224229
int ret;
225230

226231
soc_dev_attr = devm_kzalloc(dev, sizeof(*soc_dev_attr), GFP_KERNEL);
@@ -258,7 +263,7 @@ static int imx8m_soc_probe(struct platform_device *pdev)
258263
}
259264
}
260265
if (data->soc_uid) {
261-
ret = data->soc_uid(pdev, &soc_uid);
266+
ret = data->soc_uid(pdev, soc_uid);
262267
if (ret) {
263268
imx8m_soc_unprepare(pdev);
264269
return ret;
@@ -271,7 +276,12 @@ static int imx8m_soc_probe(struct platform_device *pdev)
271276
if (!soc_dev_attr->revision)
272277
return -ENOMEM;
273278

274-
soc_dev_attr->serial_number = devm_kasprintf(dev, GFP_KERNEL, "%016llX", soc_uid);
279+
if (soc_uid[1])
280+
soc_dev_attr->serial_number = devm_kasprintf(dev, GFP_KERNEL, "%016llX%016llX",
281+
soc_uid[1], soc_uid[0]);
282+
else
283+
soc_dev_attr->serial_number = devm_kasprintf(dev, GFP_KERNEL, "%016llX",
284+
soc_uid[0]);
275285
if (!soc_dev_attr->serial_number)
276286
return -ENOMEM;
277287

0 commit comments

Comments
 (0)