Skip to contentSkip to conversation

soc: imx: Add generic i.MX8 SoC driver

PATCH Superseded Abel Vesa 4 participants 7 messages Feb 26, 2019 – Feb 27, 2019 Arm i.MX and Layerscape

lore
Share & tools
lore

Abel Vesa

author
#0 lore raw

PATCH v2 1/1 soc: imx: Add generic i.MX8 SoC driver

Add generic i.MX8 SoC driver along with the i.MX8MQ SoC specific code. For now, only i.MX8MQ revision B1 is supported. For any other, i.MX8MQ revision it will print 'unknown'.

---

Changes since v1:
* added the of_node_put on free_soc failure as suggested by Stefan Agner.
* made imx8mq_soc_data const as suggested by Stefan Agner.
* also made the imx8mq_soc_data static
* marked imx8mq_soc_revision as __init
* changed the revision read-out from anatop to ocotp since the rev B1 is specified in there. For now, for i.MX8MQ only revision B1 is supported. For any other revision, it will print the revision as unknown.

 drivers/soc/imx/Makefile   |   1 +
 drivers/soc/imx/soc-imx8.c | 115 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 116 insertions(+)
 create mode 100644 drivers/soc/imx/soc-imx8.c
drivers/soc/imx/Makefile +1 -0
index 506a6f3..d6b529e0 100644
@@ -1,2 +1,3 @@
 obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o
 obj-$(CONFIG_IMX_GPCV2_PM_DOMAINS) += gpcv2.o
+obj-$(CONFIG_ARCH_MXC) += soc-imx8.o
drivers/soc/imx/soc-imx8.c new file +115 -0

115 lines not on this page · raw message

Signature · 1 line
2.7.4
Tested-by on v2 1/1
#1 lore raw
Quoted 5 lines · Abel Vesa

Add generic i.MX8 SoC driver along with the i.MX8MQ SoC specific code. For now, only i.MX8MQ revision B1 is supported. For any other, i.MX8MQ revision it will print 'unknown'.

Tested on i.MX8MQ-EVK. No idea what i.MX8MQ revision I've got on my board, but it shows 'unknown' for me.

Thanks,
Chris

#2 lore raw
In reply to Abel Vesa
Quoted 4 lines · Abel Vesa

Add generic i.MX8 SoC driver along with the i.MX8MQ SoC specific code. For now, only i.MX8MQ revision B1 is supported. For any other, i.MX8MQ revision it will print 'unknown'.

drivers/soc/imx/soc-imx8.c line 40

Quoted 10 lines
drivers/soc/imx/soc-imx8.c new file +10 -0
+	np = of_find_compatible_node(NULL, NULL, "fsl,imx8mq-ocotp");
+	if (!np)
+		goto out;
+
+	ocotp_base = of_iomap(np, 0);
+	WARN_ON(!ocotp_base);
+
+	magic = readl_relaxed(ocotp_base + IMX8MQ_SW_INFO_B1);
+	if (magic == IMX8MQ_SW_MAGIC_B1)
+		rev = REV_B1;

Turns out that imx8mq version determination is uniquely messy. I think we should try to print the revision number even for older chips so that we know how old they are, but this code can be enhanced in later patches.

In the vendor tree we handle this with a SIP call to ATF, it's not clear why we shouldn't just upstream that (in both ATF and Linux).

Also, there are some imx soc revision declarations in include/soc/imx/revision.h. Those are implemented in arch/arm/mach-imx for older chips, would it make sense for soc-imx8 to define imx_get_soc_revision?

--
Regards,
Leonard
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#3 lore raw
Quoted 5 lines · Leonard Crestez
Quoted 4 lines · Abel Vesa

Add generic i.MX8 SoC driver along with the i.MX8MQ SoC specific code. For now, only i.MX8MQ revision B1 is supported. For any other, i.MX8MQ revision it will print 'unknown'.

Quoted 16 lines

drivers/soc/imx/soc-imx8.c line 40

Quoted 10 lines
drivers/soc/imx/soc-imx8.c new file +10 -0
+	np = of_find_compatible_node(NULL, NULL, "fsl,imx8mq-ocotp");
+	if (!np)
+		goto out;
+
+	ocotp_base = of_iomap(np, 0);
+	WARN_ON(!ocotp_base);
+
+	magic = readl_relaxed(ocotp_base + IMX8MQ_SW_INFO_B1);
+	if (magic == IMX8MQ_SW_MAGIC_B1)
+		rev = REV_B1;

Turns out that imx8mq version determination is uniquely messy. I think we should try to print the revision number even for older chips so that we know how old they are, but this code can be enhanced in later patches.

Fair enough. I believe we should stick to B1 only for now though.

Quoted 3 lines

In the vendor tree we handle this with a SIP call to ATF, it's not clear why we shouldn't just upstream that (in both ATF and Linux).

Question here is: do we need to go through psci for things like revision ? I believe the cost is not worth it.

Quoted 5 lines

Also, there are some imx soc revision declarations in include/soc/imx/revision.h. Those are implemented in arch/arm/mach-imx for older chips, would it make sense for soc-imx8 to define imx_get_soc_revision?

I'm totally against the use of imx_get_soc_revision everywhere. Plus, according to our internal tree there doens't seem to indicate a need for such a thing for imx8. Anyway, that can be added later on if necessary.

Quoted 3 lines

--
Regards,
Leonard

#4 lore raw
Quoted 22 lines · Abel Vesa
Quoted 5 lines · Leonard Crestez
Quoted 4 lines · Abel Vesa

Add generic i.MX8 SoC driver along with the i.MX8MQ SoC specific code. For now, only i.MX8MQ revision B1 is supported. For any other, i.MX8MQ revision it will print 'unknown'.

Quoted 15 lines

drivers/soc/imx/soc-imx8.c line 40

Quoted 10 lines
drivers/soc/imx/soc-imx8.c new file +10 -0
+	np = of_find_compatible_node(NULL, NULL, "fsl,imx8mq-ocotp");
+	if (!np)
+		goto out;
+
+	ocotp_base = of_iomap(np, 0);
+	WARN_ON(!ocotp_base);
+
+	magic = readl_relaxed(ocotp_base + IMX8MQ_SW_INFO_B1);
+	if (magic == IMX8MQ_SW_MAGIC_B1)
+		rev = REV_B1;

Turns out that imx8mq version determination is uniquely messy. I think we should try to print the revision number even for older chips so that we know how old they are, but this code can be enhanced in later patches.

Quoted 1 line

Fair enough. I believe we should stick to B1 only for now though.

Yes, people who want their old SOC revisions to be be detected can submit later patches.

reviewer
#5 lore raw
In reply to Abel Vesa

drivers/soc/imx/soc-imx8.c line 40

Quoted 3 lines · Abel Vesa
drivers/soc/imx/soc-imx8.c new file +3 -0
+       magic = readl_relaxed(ocotp_base + IMX8MQ_SW_INFO_B1);
+       if (magic == IMX8MQ_SW_MAGIC_B1)
+               rev = REV_B1;

Don't you mean rev == REV_B1; ?

reviewer
#6 lore raw
Quoted 8 lines · Fabio Estevam

drivers/soc/imx/soc-imx8.c line 40

Quoted 3 lines · Abel Vesa
drivers/soc/imx/soc-imx8.c new file +3 -0
+       magic = readl_relaxed(ocotp_base + IMX8MQ_SW_INFO_B1);
+       if (magic == IMX8MQ_SW_MAGIC_B1)
+               rev = REV_B1;

Don't you mean rev == REV_B1; ?

Ops, was looking at the wrong line, sorry :-)