mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00
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 <peng.fan@nxp.com> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Shawn Guo <shawnguo@kernel.org>
This commit is contained in:
parent
6981050139
commit
fd0bf2bb32
@ -24,6 +24,7 @@
|
|||||||
#define OCOTP_UID_HIGH 0x420
|
#define OCOTP_UID_HIGH 0x420
|
||||||
|
|
||||||
#define IMX8MP_OCOTP_UID_OFFSET 0x10
|
#define IMX8MP_OCOTP_UID_OFFSET 0x10
|
||||||
|
#define IMX8MP_OCOTP_UID_HIGH 0xE00
|
||||||
|
|
||||||
/* Same as ANADIG_DIGPROG_IMX7D */
|
/* Same as ANADIG_DIGPROG_IMX7D */
|
||||||
#define ANADIG_DIGPROG_IMX8MM 0x800
|
#define ANADIG_DIGPROG_IMX8MM 0x800
|
||||||
@ -96,9 +97,13 @@ static int imx8mp_soc_uid(struct platform_device *pdev, u64 *socuid)
|
|||||||
struct imx8_soc_drvdata *drvdata = platform_get_drvdata(pdev);
|
struct imx8_soc_drvdata *drvdata = platform_get_drvdata(pdev);
|
||||||
void __iomem *ocotp_base = drvdata->ocotp_base;
|
void __iomem *ocotp_base = drvdata->ocotp_base;
|
||||||
|
|
||||||
*socuid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH + IMX8MP_OCOTP_UID_OFFSET);
|
socuid[0] = readl_relaxed(ocotp_base + OCOTP_UID_HIGH + IMX8MP_OCOTP_UID_OFFSET);
|
||||||
*socuid <<= 32;
|
socuid[0] <<= 32;
|
||||||
*socuid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW + IMX8MP_OCOTP_UID_OFFSET);
|
socuid[0] |= readl_relaxed(ocotp_base + OCOTP_UID_LOW + IMX8MP_OCOTP_UID_OFFSET);
|
||||||
|
|
||||||
|
socuid[1] = readl_relaxed(ocotp_base + IMX8MP_OCOTP_UID_HIGH + 0x10);
|
||||||
|
socuid[1] <<= 32;
|
||||||
|
socuid[1] |= readl_relaxed(ocotp_base + IMX8MP_OCOTP_UID_HIGH);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -220,7 +225,7 @@ static int imx8m_soc_probe(struct platform_device *pdev)
|
|||||||
const struct of_device_id *id;
|
const struct of_device_id *id;
|
||||||
struct soc_device *soc_dev;
|
struct soc_device *soc_dev;
|
||||||
u32 soc_rev = 0;
|
u32 soc_rev = 0;
|
||||||
u64 soc_uid = 0;
|
u64 soc_uid[2] = {0, 0};
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
soc_dev_attr = devm_kzalloc(dev, sizeof(*soc_dev_attr), GFP_KERNEL);
|
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)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data->soc_uid) {
|
if (data->soc_uid) {
|
||||||
ret = data->soc_uid(pdev, &soc_uid);
|
ret = data->soc_uid(pdev, soc_uid);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
imx8m_soc_unprepare(pdev);
|
imx8m_soc_unprepare(pdev);
|
||||||
return ret;
|
return ret;
|
||||||
@ -271,7 +276,12 @@ static int imx8m_soc_probe(struct platform_device *pdev)
|
|||||||
if (!soc_dev_attr->revision)
|
if (!soc_dev_attr->revision)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
soc_dev_attr->serial_number = devm_kasprintf(dev, GFP_KERNEL, "%016llX", soc_uid);
|
if (soc_uid[1])
|
||||||
|
soc_dev_attr->serial_number = devm_kasprintf(dev, GFP_KERNEL, "%016llX%016llX",
|
||||||
|
soc_uid[1], soc_uid[0]);
|
||||||
|
else
|
||||||
|
soc_dev_attr->serial_number = devm_kasprintf(dev, GFP_KERNEL, "%016llX",
|
||||||
|
soc_uid[0]);
|
||||||
if (!soc_dev_attr->serial_number)
|
if (!soc_dev_attr->serial_number)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user