Skip to contentSkip to conversation

soc: imx: support i.MX93 soc device

PATCH Superseded Peng Fan (OSS) 3 participants 3 messages May 9, 2023 – May 15, 2023 Arm i.MX and Layerscape

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 soc: imx: support i.MX93 soc device

From: Peng Fan <[email protected]>

Similar to i.MX8M, add i.MX93 soc device support

---

V2:
The ocotp yaml has got R-b from DT maintainer:
https://lore.kernel.org/all/[email protected]/

Remove uid_length from V1 which is unused.

 drivers/soc/imx/Makefile    |  2 +-
 drivers/soc/imx/soc-imx8m.c | 64 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 64 insertions(+), 2 deletions(-)
drivers/soc/imx/Makefile +1 -1
index a28c44a1f16a..83aff181ae51 100644
@@ -7,5 +7,5 @@ obj-$(CONFIG_IMX_GPCV2_PM_DOMAINS) += gpcv2.o
 obj-$(CONFIG_SOC_IMX8M) += soc-imx8m.o
 obj-$(CONFIG_IMX8M_BLK_CTRL) += imx8m-blk-ctrl.o
 obj-$(CONFIG_IMX8M_BLK_CTRL) += imx8mp-blk-ctrl.o
-obj-$(CONFIG_SOC_IMX9) += imx93-src.o imx93-pd.o
+obj-$(CONFIG_SOC_IMX9) += soc-imx8m.o imx93-src.o imx93-pd.o
 obj-$(CONFIG_IMX9_BLK_CTRL) += imx93-blk-ctrl.o
drivers/soc/imx/soc-imx8m.c +63 -1

101 lines not on this page · raw message

Signature · 1 line
2.37.1
#1 lore raw
Quoted 3 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Similar to i.MX8M, add i.MX93 soc device support

This commit log doesn't provide too much helpful information. You may want to briefly introduce i.MX93 UID, which looks something new?

Quoted 122 lines

---

V2:
The ocotp yaml has got R-b from DT maintainer:
https://lore.kernel.org/all/[email protected]/

Remove uid_length from V1 which is unused.

 drivers/soc/imx/Makefile    |  2 +-
 drivers/soc/imx/soc-imx8m.c | 64 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 64 insertions(+), 2 deletions(-)
drivers/soc/imx/Makefile +1 -1
index a28c44a1f16a..83aff181ae51 100644
@@ -7,5 +7,5 @@ obj-$(CONFIG_IMX_GPCV2_PM_DOMAINS) += gpcv2.o
 obj-$(CONFIG_SOC_IMX8M) += soc-imx8m.o
 obj-$(CONFIG_IMX8M_BLK_CTRL) += imx8m-blk-ctrl.o
 obj-$(CONFIG_IMX8M_BLK_CTRL) += imx8mp-blk-ctrl.o
-obj-$(CONFIG_SOC_IMX9) += imx93-src.o imx93-pd.o
+obj-$(CONFIG_SOC_IMX9) += soc-imx8m.o imx93-src.o imx93-pd.o
 obj-$(CONFIG_IMX9_BLK_CTRL) += imx93-blk-ctrl.o
drivers/soc/imx/soc-imx8m.c +57 -0
index 1dcd243df567..0e69b8b48183 100644
@@ -25,8 +25,11 @@
 
 #define IMX8MP_OCOTP_UID_OFFSET		0x10
 
+#define IMX93_OCOTP_UID_OFFSET		0x80c0
+
 /* Same as ANADIG_DIGPROG_IMX7D */
 #define ANADIG_DIGPROG_IMX8MM	0x800
+#define ANADIG_DIGPROG_IMX93	0x800
 
 struct imx8_soc_data {
 	char *name;
@@ -34,6 +37,7 @@ struct imx8_soc_data {
 };
 
 static u64 soc_uid;
+static u64 soc_uid_h;
 
 #ifdef CONFIG_HAVE_ARM_SMCCC
 static u32 imx8mq_soc_revision_from_atf(void)
@@ -141,6 +145,53 @@ static u32 __init imx8mm_soc_revision(void)
 	return rev;
 }
 
+static void __init imx93_soc_uid(void)
+{
+	void __iomem *ocotp_base;
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "fsl,imx93-ocotp");
+	if (!np)
+		return;
+
+	ocotp_base = of_iomap(np, 0);
+	WARN_ON(!ocotp_base);
+
+	soc_uid = readl_relaxed(ocotp_base + IMX93_OCOTP_UID_OFFSET + 0x8);
+	soc_uid <<= 32;
+	soc_uid |= readl_relaxed(ocotp_base + IMX93_OCOTP_UID_OFFSET + 0xC);
+
+	soc_uid_h = readl_relaxed(ocotp_base + IMX93_OCOTP_UID_OFFSET + 0x0);
+	soc_uid_h <<= 32;
+	soc_uid_h |= readl_relaxed(ocotp_base + IMX93_OCOTP_UID_OFFSET + 0x4);
+
+	iounmap(ocotp_base);
+	of_node_put(np);
+}
+
+static u32 __init imx93_soc_revision(void)
+{
+	struct device_node *np;
+	void __iomem *anatop_base;
+	u32 rev;
+
+	np = of_find_compatible_node(NULL, NULL, "fsl,imx93-anatop");
+	if (!np)
+		return 0;
+
+	anatop_base = of_iomap(np, 0);
+	WARN_ON(!anatop_base);
+
+	rev = readl_relaxed(anatop_base + ANADIG_DIGPROG_IMX93);
+
+	iounmap(anatop_base);
+	of_node_put(np);
+
+	imx93_soc_uid();
+
+	return rev;
+}
+
 static const struct imx8_soc_data imx8mq_soc_data = {
 	.name = "i.MX8MQ",
 	.soc_revision = imx8mq_soc_revision,
@@ -161,11 +212,17 @@ static const struct imx8_soc_data imx8mp_soc_data = {
 	.soc_revision = imx8mm_soc_revision,
 };
 
+static const struct imx8_soc_data imx93_soc_data = {
+	.name = "i.MX93",
+	.soc_revision = imx93_soc_revision,
+};
+
 static __maybe_unused const struct of_device_id imx8_soc_match[] = {
 	{ .compatible = "fsl,imx8mq", .data = &imx8mq_soc_data, },
 	{ .compatible = "fsl,imx8mm", .data = &imx8mm_soc_data, },
 	{ .compatible = "fsl,imx8mn", .data = &imx8mn_soc_data, },
 	{ .compatible = "fsl,imx8mp", .data = &imx8mp_soc_data, },
+	{ .compatible = "fsl,imx93", .data = &imx93_soc_data, },
 	{ }
 };
 

drivers/soc/imx/soc-imx8m.c static int __init imx8_soc_init(void) · line 272

Quoted 5 lines
drivers/soc/imx/soc-imx8m.c +1 -1
@@ -212,7 +269,12 @@ static int __init imx8_soc_init(void)
 		goto free_soc;
 	}
 
-	soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", soc_uid);
+	if (soc_uid_h) {

Unnecessary parentheses.

Shawn

Quoted 11 lines
drivers/soc/imx/soc-imx8m.c +5 -0
+		soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX%016llX",
+							soc_uid_h, soc_uid);
+	} else {
+		soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", soc_uid);
+	}
 	if (!soc_dev_attr->serial_number) {
 		ret = -ENOMEM;
 		goto free_rev;
Signature · 1 line
2.37.1
#2 lore raw

Shawn,

Just posted V3 to address your comments.

Thanks,
Peng.

Quoted 176 lines

Subject: Re: [PATCH V2] soc: imx: support i.MX93 soc device

Quoted 3 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Similar to i.MX8M, add i.MX93 soc device support

This commit log doesn't provide too much helpful information. You may want to briefly introduce i.MX93 UID, which looks something new?

Quoted 8 lines

---

V2:
The ocotp yaml has got R-b from DT maintainer:

https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore

Quoted 1 line

.kernel.org%2Fall%2F01be24b3-aaf2-e27b-d00e-

f8649a497463%40linaro.org%

Quoted 1 line

2F&data=05%7C01%7Cpeng.fan%40nxp.com%7Ced8cd9c0eac146837e8c08d b54f1950

Quoted 1 line

5%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C638197168793784 144%7CUn

Quoted 1 line

known%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI 6Ik1haW

Quoted 1 line

wiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=2QBo%2ByyZflXjzQ%2FW 8jQBlald6Gt

Quoted 49 lines

w9kyUIu0pP2iIqhg%3D&reserved=0

Remove uid_length from V1 which is unused.

 drivers/soc/imx/Makefile    |  2 +-
 drivers/soc/imx/soc-imx8m.c | 64
++++++++++++++++++++++++++++++++++++-
 2 files changed, 64 insertions(+), 2 deletions(-)
drivers/soc/imx/Makefile index renamed from drivers/soc/imx/Makefile +0 -0

a28c44a1f16a..83aff181ae51 100644

drivers/soc/imx/Makefile +1 -1
@@ -7,5 +7,5 @@ obj-$(CONFIG_IMX_GPCV2_PM_DOMAINS) += gpcv2.o
 obj-$(CONFIG_SOC_IMX8M) += soc-imx8m.o
 obj-$(CONFIG_IMX8M_BLK_CTRL) += imx8m-blk-ctrl.o
 obj-$(CONFIG_IMX8M_BLK_CTRL) += imx8mp-blk-ctrl.o
-obj-$(CONFIG_SOC_IMX9) += imx93-src.o imx93-pd.o
+obj-$(CONFIG_SOC_IMX9) += soc-imx8m.o imx93-src.o imx93-pd.o
 obj-$(CONFIG_IMX9_BLK_CTRL) += imx93-blk-ctrl.o diff --git

a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c index 1dcd243df567..0e69b8b48183 100644

drivers/soc/imx/soc-imx8m.c +6 -0
@@ -25,8 +25,11 @@
 
 #define IMX8MP_OCOTP_UID_OFFSET		0x10
 
+#define IMX93_OCOTP_UID_OFFSET		0x80c0
+
 /* Same as ANADIG_DIGPROG_IMX7D */
 #define ANADIG_DIGPROG_IMX8MM	0x800
+#define ANADIG_DIGPROG_IMX93	0x800
 
 struct imx8_soc_data {
 	char *name;
@@ -34,6 +37,7 @@ struct imx8_soc_data {  };
 
 static u64 soc_uid;
+static u64 soc_uid_h;
 
 #ifdef CONFIG_HAVE_ARM_SMCCC
 static u32 imx8mq_soc_revision_from_atf(void)
@@ -141,6 +145,53 @@ static u32 __init imx8mm_soc_revision(void)
 	return rev;
 }
 
+static void __init imx93_soc_uid(void) {
+	void __iomem *ocotp_base;

drivers/soc/imx/soc-imx8m.c static u32 __init imx8mm_soc_revision(void) · line 159

Quoted 10 lines
drivers/soc/imx/soc-imx8m.c +10 -0
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "fsl,imx93-ocotp");
+	if (!np)
+		return;
+
+	ocotp_base = of_iomap(np, 0);
+	WARN_ON(!ocotp_base);
+
+	soc_uid = readl_relaxed(ocotp_base + IMX93_OCOTP_UID_OFFSET +

0x8);

drivers/soc/imx/soc-imx8m.c static u32 __init imx8mm_soc_revision(void) · line 161

Quoted 2 lines
drivers/soc/imx/soc-imx8m.c +2 -0
+	soc_uid <<= 32;
+	soc_uid |= readl_relaxed(ocotp_base + IMX93_OCOTP_UID_OFFSET

+ 0xC);

drivers/soc/imx/soc-imx8m.c static u32 __init imx8mm_soc_revision(void) · line 163

Quoted 2 lines
drivers/soc/imx/soc-imx8m.c +2 -0
+
+	soc_uid_h = readl_relaxed(ocotp_base +

IMX93_OCOTP_UID_OFFSET + 0x0);

drivers/soc/imx/soc-imx8m.c static u32 __init imx8mm_soc_revision(void) · line 165

Quoted 2 lines
drivers/soc/imx/soc-imx8m.c +2 -0
+	soc_uid_h <<= 32;
+	soc_uid_h |= readl_relaxed(ocotp_base +

IMX93_OCOTP_UID_OFFSET +

Quoted 21 lines
drivers/soc/imx/soc-imx8m.c +21 -0
+0x4);
+
+	iounmap(ocotp_base);
+	of_node_put(np);
+}
+
+static u32 __init imx93_soc_revision(void) {
+	struct device_node *np;
+	void __iomem *anatop_base;
+	u32 rev;
+
+	np = of_find_compatible_node(NULL, NULL, "fsl,imx93-anatop");
+	if (!np)
+		return 0;
+
+	anatop_base = of_iomap(np, 0);
+	WARN_ON(!anatop_base);
+
+	rev = readl_relaxed(anatop_base + ANADIG_DIGPROG_IMX93);
+
+	iounmap(anatop_base);

drivers/soc/imx/soc-imx8m.c static u32 __init imx8mm_soc_revision(void)

Quoted 10 lines
drivers/soc/imx/soc-imx8m.c +7 -0
+	of_node_put(np);
+
+	imx93_soc_uid();
+
+	return rev;
+}
+
 static const struct imx8_soc_data imx8mq_soc_data = {
 	.name = "i.MX8MQ",
 	.soc_revision = imx8mq_soc_revision, @@ -161,11 +212,17 @@

static

Quoted 18 lines

const struct imx8_soc_data imx8mp_soc_data = {

drivers/soc/imx/soc-imx8m.c +6 -0
 	.soc_revision = imx8mm_soc_revision,  };
 
+static const struct imx8_soc_data imx93_soc_data = {
+	.name = "i.MX93",
+	.soc_revision = imx93_soc_revision,
+};
+
 static __maybe_unused const struct of_device_id imx8_soc_match[] = {
 	{ .compatible = "fsl,imx8mq", .data = &imx8mq_soc_data, },
 	{ .compatible = "fsl,imx8mm", .data = &imx8mm_soc_data, },
 	{ .compatible = "fsl,imx8mn", .data = &imx8mn_soc_data, },
 	{ .compatible = "fsl,imx8mp", .data = &imx8mp_soc_data, },
+	{ .compatible = "fsl,imx93", .data = &imx93_soc_data, },
 	{ }
 };

drivers/soc/imx/soc-imx8m.c static int __init imx8_soc_init(void) · line 215

Quoted 4 lines
drivers/soc/imx/soc-imx8m.c +0 -1
@@ -212,7 +269,12 @@ static int __init imx8_soc_init(void)
 		goto free_soc;
 	}
 
-	soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX",

soc_uid);

drivers/soc/imx/soc-imx8m.c static int __init imx8_soc_init(void) · line 272

Quoted 1 line
drivers/soc/imx/soc-imx8m.c +1 -0
+	if (soc_uid_h) {

Unnecessary parentheses.

Shawn

drivers/soc/imx/soc-imx8m.c static int __init imx8_soc_init(void) · line 273

Quoted 1 line
drivers/soc/imx/soc-imx8m.c +1 -0
+		soc_dev_attr->serial_number = kasprintf(GFP_KERNEL,

"%016llX%016llX",

drivers/soc/imx/soc-imx8m.c static int __init imx8_soc_init(void)

Quoted 3 lines
drivers/soc/imx/soc-imx8m.c +3 -0
+							soc_uid_h, soc_uid);
+	} else {
+		soc_dev_attr->serial_number = kasprintf(GFP_KERNEL,

"%016llX", soc_uid);

Quoted 7 lines
drivers/soc/imx/soc-imx8m.c +1 -1
+	}
 	if (!soc_dev_attr->serial_number) {
 		ret = -ENOMEM;
 		goto free_rev;
--

2.37.1