Skip to contentSkip to conversation

spi-nor: add optional vcc-supply and enable it for i.MX93

PATCH Superseded Peng Fan (OSS) 7 participants 12 messages Sep 30, 2024 – Oct 29, 2024

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover spi-nor: add optional vcc-supply and enable it for i.MX93

spi-nor flash needs power supply to work properly, the power supply could be software controlled. So need enable the power before using the flash.

Patch 1,2 is to add vcc-supply for spi-nor
Patch 3 is to add overlays for i.MX93-11x11-EVK

---
Changes in v2:
- Add A-b for patch 1, typo in patch 1
- Use devm_regulator_get_enable in patch 2
I still keep it in spi_nor_scan because it is in probe stage.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Peng Fan (3):
dt-bindings: mtd: jedec,spi-nor: add optional vcc-supply
mtd: spi-nor: support vcc-supply regulator
arm64: dts: imx93-11x11-evk: add overlays for flexspi flash

 .../devicetree/bindings/mtd/jedec,spi-nor.yaml     |  4 ++
 arch/arm64/boot/dts/freescale/Makefile             |  3 ++
 .../dts/freescale/imx93-11x11-evk-flexspi-m2.dtso  | 59 ++++++++++++++++++++++
 arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts  | 10 ++++
 drivers/mtd/spi-nor/core.c                         |  5 ++
 5 files changed, 81 insertions(+)

---
base-commit: 1dfc4eba4ed353d2c6b26acc0f3518d3eecf28c3
change-id: 20240920-spi-34231ea74761

Best regards,

Signature · 1 line
Peng Fan <[email protected]>
#1 lore raw

PATCH v2 1/3 dt-bindings: mtd: jedec,spi-nor: add optional vcc-supply

From: Peng Fan <[email protected]>

Introduce optional vcc-supply property, SPI NOR flashes needs power supply to work properly. The power supply maybe software controlable per board design.

---
 Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml +4 -0
index 6e3afb42926e..bab0617a51d5 100644
@@ -96,6 +96,10 @@ properties:
       If "broken-flash-reset" is present then having this property does not
       make any difference.
 
+  vcc-supply:
+    description:
+      Supply for the spi nor power.
+
   spi-cpol: true
   spi-cpha: true
 
Signature · 1 line
2.37.1
maintainer
#2 lore raw

Re: [PATCH v2 1/3] dt-bindings: mtd: jedec,spi-nor: add optional vcc-supply

Hi,

[email protected] wrote on Mon, 30 Sep 2024 17:22:24 +0800:

Quoted 17 lines

From: Peng Fan <[email protected]>

Introduce optional vcc-supply property, SPI NOR flashes needs power supply to work properly. The power supply maybe software controlable per board design.

---
 Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml +0 -0
index 6e3afb42926e..bab0617a51d5 100644

Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml properties: · line 101

Quoted 6 lines
Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml +3 -0
@@ -96,6 +96,10 @@ properties:
       If "broken-flash-reset" is present then having this property does not
       make any difference.
 
+  vcc-supply:
+    description:
+      Supply for the spi nor power.

SPI NOR?

Thanks,
Miquèl

#3 lore raw

RE: [PATCH v2 1/3] dt-bindings: mtd: jedec,spi-nor: add optional vcc-supply

Hi Tudor, Miquel

Quoted 30 lines

Subject: Re: [PATCH v2 1/3] dt-bindings: mtd: jedec,spi-nor: add optional vcc-supply

Hi,

[email protected] wrote on Mon, 30 Sep 2024 17:22:24 +0800:

Quoted 4 lines

From: Peng Fan <[email protected]>

Introduce optional vcc-supply property, SPI NOR flashes needs power supply to work properly. The power supply maybe software

controlable

Quoted 6 lines

per board design.

---
 Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml | 4

++++

Review

Quoted 3 lines
 1 file changed, 4 insertions(+)
(quoted diff) +0 -0

nor.yaml

Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml properties: · line 96

Quoted 6 lines

b/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml index 6e3afb42926e..bab0617a51d5 100644

Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml +0 -0
@@ -96,6 +96,10 @@ properties:
       If "broken-flash-reset" is present then having this property does

not

Quoted 7 lines

Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml properties: · line 101

Quoted 5 lines
Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml +3 -0
       make any difference.
 
+  vcc-supply:
+    description:
+      Supply for the spi nor power.

SPI NOR?

Since this is a minor typo, do you expect me to send v3 or you could help update when applying the patch?

Thanks,
Peng.

Quoted 3 lines

Thanks,
Miquèl

#4 lore raw

PATCH v2 2/3 mtd: spi-nor: support vcc-supply regulator

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

SPI NOR flashes needs power supply to work properly. The power supply maybe software controllable per board design. So add the support for an vcc-supply regulator.

---
 drivers/mtd/spi-nor/core.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/mtd/spi-nor/core.c +5 -0
index 9d6e85bf227b..5249c8b13916 100644
@@ -17,6 +17,7 @@
 #include <linux/mtd/spi-nor.h>
 #include <linux/mutex.h>
 #include <linux/of_platform.h>
+#include <linux/regulator/consumer.h>
 #include <linux/sched/task_stack.h>
 #include <linux/sizes.h>
 #include <linux/slab.h>
@@ -3462,6 +3463,10 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
 	if (!nor->bouncebuf)
 		return -ENOMEM;
 
+	ret = devm_regulator_get_enable(dev, "vcc");
+	if (ret)
+		return ret;
+
 	ret = spi_nor_hw_reset(nor);
 	if (ret)
 		return ret;
Signature · 1 line
2.37.1
maintainer
#5 lore raw

Re: [PATCH v2 2/3] mtd: spi-nor: support vcc-supply regulator

Hi,

[email protected] wrote on Mon, 30 Sep 2024 17:22:25 +0800:

Quoted 24 lines

From: Peng Fan <[email protected]>

SPI NOR flashes needs power supply to work properly. The power supply maybe software controllable per board design. So add the support for an vcc-supply regulator.

---
 drivers/mtd/spi-nor/core.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/mtd/spi-nor/core.c +1 -0
index 9d6e85bf227b..5249c8b13916 100644
@@ -17,6 +17,7 @@
 #include <linux/mtd/spi-nor.h>
 #include <linux/mutex.h>
 #include <linux/of_platform.h>
+#include <linux/regulator/consumer.h>
 #include <linux/sched/task_stack.h>
 #include <linux/sizes.h>
 #include <linux/slab.h>

drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const char *name, · line 3466

Quoted 4 lines
drivers/mtd/spi-nor/core.c +1 -0
@@ -3462,6 +3463,10 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
 	if (!nor->bouncebuf)
 		return -ENOMEM;
 
+	ret = devm_regulator_get_enable(dev, "vcc");

_optional ?

drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const char *name, · line 3472

Quoted 7 lines
drivers/mtd/spi-nor/core.c +3 -0
+	if (ret)
+		return ret;
+
 	ret = spi_nor_hw_reset(nor);
 	if (ret)
 		return ret;

Thanks,
Miquèl

#6 lore raw

Re: [PATCH v2 2/3] mtd: spi-nor: support vcc-supply regulator

Hi Miquel,

Quoted 31 lines · Miquel Raynal

Hi,

[email protected] wrote on Mon, 30 Sep 2024 17:22:25 +0800:

Quoted 27 lines

From: Peng Fan <[email protected]>

SPI NOR flashes needs power supply to work properly. The power supply maybe software controllable per board design. So add the support for an vcc-supply regulator.

---
 drivers/mtd/spi-nor/core.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/mtd/spi-nor/core.c +1 -0
index 9d6e85bf227b..5249c8b13916 100644
@@ -17,6 +17,7 @@
 #include <linux/mtd/spi-nor.h>
 #include <linux/mutex.h>
 #include <linux/of_platform.h>
+#include <linux/regulator/consumer.h>
 #include <linux/sched/task_stack.h>
 #include <linux/sizes.h>
 #include <linux/slab.h>
@@ -3462,6 +3463,10 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
 	if (!nor->bouncebuf)
 		return -ENOMEM;
 
Quoted 3 lines

drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const char *name, · line 3466

Quoted 1 line
drivers/mtd/spi-nor/core.c +1 -0
+	ret = devm_regulator_get_enable(dev, "vcc");

_optional ?

The regulator optional API is different compared to other optional APIs. If we would use optional here, we would need to check the returned error code. On the other hand if the non optional API is used and the regualtor is missing, a dummy regualtor is returned (as pointed out by Marc).

Please see the _optional API doc to see more information about the _optional usage.

Regards,
Marco

Quoted 12 lines

drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const char *name, · line 3472

Quoted 7 lines
drivers/mtd/spi-nor/core.c +3 -0
+	if (ret)
+		return ret;
+
 	ret = spi_nor_hw_reset(nor);
 	if (ret)
 		return ret;

Thanks,
Miquèl

#7 lore raw

Re: [PATCH v2 2/3] mtd: spi-nor: support vcc-supply regulator

In reply to Peng Fan (OSS)
Quoted 24 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

SPI NOR flashes needs power supply to work properly. The power supply maybe software controllable per board design. So add the support for an vcc-supply regulator.

---
 drivers/mtd/spi-nor/core.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/mtd/spi-nor/core.c +1 -0
index 9d6e85bf227b..5249c8b13916 100644
@@ -17,6 +17,7 @@
 #include <linux/mtd/spi-nor.h>
 #include <linux/mutex.h>
 #include <linux/of_platform.h>
+#include <linux/regulator/consumer.h>
 #include <linux/sched/task_stack.h>
 #include <linux/sizes.h>
 #include <linux/slab.h>

drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const char *name, · line 3469

Quoted 7 lines
drivers/mtd/spi-nor/core.c +4 -0
@@ -3462,6 +3463,10 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
 	if (!nor->bouncebuf)
 		return -ENOMEM;
 
+	ret = devm_regulator_get_enable(dev, "vcc");
+	if (ret)
+		return ret;
+

What happens if the SPI-NOR doesn't have a "vcc" regulator?

Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |
#8 lore raw

Re: [PATCH v2 2/3] mtd: spi-nor: support vcc-supply regulator

Quoted 28 lines · Marc Kleine-Budde
Quoted 27 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

SPI NOR flashes needs power supply to work properly. The power supply maybe software controllable per board design. So add the support for an vcc-supply regulator.

---
 drivers/mtd/spi-nor/core.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/mtd/spi-nor/core.c +1 -0
index 9d6e85bf227b..5249c8b13916 100644
@@ -17,6 +17,7 @@
 #include <linux/mtd/spi-nor.h>
 #include <linux/mutex.h>
 #include <linux/of_platform.h>
+#include <linux/regulator/consumer.h>
 #include <linux/sched/task_stack.h>
 #include <linux/sizes.h>
 #include <linux/slab.h>
@@ -3462,6 +3463,10 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
 	if (!nor->bouncebuf)
 		return -ENOMEM;
 
Quoted 6 lines

drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const char *name, · line 3469

Quoted 4 lines
drivers/mtd/spi-nor/core.c +4 -0
+	ret = devm_regulator_get_enable(dev, "vcc");
+	if (ret)
+		return ret;
+

What happens if the SPI-NOR doesn't have a "vcc" regulator?

...the SPI-NOR will use the dummy regulator.

regards,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |
maintainer
#9 lore raw

Re: [PATCH v2 2/3] mtd: spi-nor: support vcc-supply regulator

Hi,

Quoted 8 lines
Quoted 6 lines

drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const char *name, · line 3469

Quoted 4 lines
drivers/mtd/spi-nor/core.c +4 -0
+	ret = devm_regulator_get_enable(dev, "vcc");
+	if (ret)
+		return ret;
+

What happens if the SPI-NOR doesn't have a "vcc" regulator?

...the SPI-NOR will use the dummy regulator.

Which then prints a warning "using dummy regulator". Is that the usual way to go?
I mean the regulator is actually mandatory because it is the main voltage rail for the flash. To get rid of the warning one can add a fixed-regulator (which is correct anyway). But OTOH, the device tree lists it as optional (marking it as required isn't an option either because virtually all device trees won't have that property).

-michael

#10 lore raw

Re: [PATCH v2 2/3] mtd: spi-nor: support vcc-supply regulator

Quoted 9 lines · Michael Walle

Hi,

Quoted 7 lines
Quoted 6 lines

drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const char *name, · line 3469

Quoted 4 lines
drivers/mtd/spi-nor/core.c +4 -0
+	ret = devm_regulator_get_enable(dev, "vcc");
+	if (ret)
+		return ret;
+

What happens if the SPI-NOR doesn't have a "vcc" regulator?

Quoted 7 lines
Quoted 1 line

...the SPI-NOR will use the dummy regulator.

Which then prints a warning "using dummy regulator". Is that the usual way to go?
I mean the regulator is actually mandatory because it is the main voltage rail for the flash. To get rid of the warning one can add a fixed-regulator (which is correct anyway). But OTOH, the device tree

I think it's fine to have the warning. It will help people write a better device tree.

Quoted 4 lines

lists it as optional (marking it as required isn't an option either because virtually all device trees won't have that property).

-michael

#11 lore raw

PATCH v2 3/3 arm64: dts: imx93-11x11-evk: add overlays for flexspi flash

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Add overlays for the flexspi flash connected using M.2 interface. The M.2 interface could be connected with M.2 flash card. The M.2 interface needs PCIE power to work properly, the flash card needs 1.8V voltage to work properly.

---
 arch/arm64/boot/dts/freescale/Makefile             |  3 ++
 .../dts/freescale/imx93-11x11-evk-flexspi-m2.dtso  | 59 ++++++++++++++++++++++
 arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts  | 10 ++++
 3 files changed, 72 insertions(+)
arch/arm64/boot/dts/freescale/Makefile +3 -0
index 9d3df8b218a2..8f82aae85fe0 100644
@@ -241,6 +241,7 @@ dtb-$(CONFIG_ARCH_MXC) += imx8qxp-tqma8xqp-mba8xx.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8ulp-evk.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx93-9x9-qsb.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx93-11x11-evk.dtb
+dtb-$(CONFIG_ARCH_MXC) += imx93-11x11-evk-flexspi-m2.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx93-14x14-evk.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx93-kontron-bl-osm-s.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx93-phyboard-segin.dtb
@@ -249,6 +250,8 @@ dtb-$(CONFIG_ARCH_MXC) += imx93-tqma9352-mba93xxla.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx93-var-som-symphony.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx95-19x19-evk.dtb
 
+imx93-11x11-evk-flexspi-m2-dtbs	:= imx93-11x11-evk.dtb imx93-11x11-evk-flexspi-m2.dtbo
+
 imx8mm-venice-gw72xx-0x-imx219-dtbs	:= imx8mm-venice-gw72xx-0x.dtb imx8mm-venice-gw72xx-0x-imx219.dtbo
 imx8mm-venice-gw72xx-0x-rpidsi-dtbs	:= imx8mm-venice-gw72xx-0x.dtb imx8mm-venice-gw72xx-0x-rpidsi.dtbo
 imx8mm-venice-gw72xx-0x-rs232-rts-dtbs	:= imx8mm-venice-gw72xx-0x.dtb imx8mm-venice-gw72xx-0x-rs232-rts.dtbo
arch/arm64/boot/dts/freescale/imx93-11x11-evk-flexspi-m2.dtso new file +59 -0

59 lines not on this page · raw message

arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts +10 -0
index 8d036b3962e9..2eefa65fbfa8 100644
@@ -78,6 +78,16 @@ reg_vref_1v8: regulator-adc-vref {
 		regulator-max-microvolt = <1800000>;
 	};
 
+	reg_m2_pwr: regulator-m2-pwr {
+		compatible = "regulator-fixed";
+		regulator-name = "M.2-power";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		gpio = <&pcal6524 13 GPIO_ACTIVE_HIGH>;
+		startup-delay-us = <2000>;
+		enable-active-high;
+	};
+
 	reg_usdhc2_vmmc: regulator-usdhc2 {
 		compatible = "regulator-fixed";
 		pinctrl-names = "default";
Signature · 1 line
2.37.1