Skip to contentSkip to conversation

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

PATCH In review Peng Fan (OSS) 3 participants 5 messages Oct 27, 2024 – Oct 29, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v3 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 v3:
- Rebased to linux-next next-20241025
- Drop patch 3 which is to add i.MX93 flexspi overlay device tree.
- Typo "spi nor" -> "SPI NOR" in patch 1
- Link to v2: https://lore.kernel.org/r/[email protected]

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 (2):
dt-bindings: mtd: jedec,spi-nor: add optional vcc-supply
mtd: spi-nor: support vcc-supply regulator

 Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml | 4 ++++
 drivers/mtd/spi-nor/core.c                               | 5 +++++
 2 files changed, 9 insertions(+)

---
base-commit: 7c98818f1183b7e4b6757901b41b0e37293aa28c
change-id: 20240920-spi-34231ea74761

Best regards,

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

PATCH v3 1/2 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 6e3afb42926ea6d22f0dd2ebf39752e115502615..335f8204aa1ebce3d2b4686b2a06d0ea3791667c 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
#2 lore raw

PATCH v3 2/2 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 b6f374ded390a0c0429a61dd0579204e0e98bfa1..d95427c4f4d0839c5df348eeddea59582ef99d9d 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>
@@ -3465,6 +3466,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
#4 lore raw

Re: [PATCH v3 2/2] 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 b6f374ded390a0c0429a61dd0579204e0e98bfa1..d95427c4f4d0839c5df348eeddea59582ef99d9d 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 3471

Quoted 6 lines
drivers/mtd/spi-nor/core.c +3 -0
@@ -3465,6 +3466,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;

This is all looking good, but please move it to spi_nor_probe().

All the SPI NOR controllers need to move to spi/. We stopped adding support for the SPI NOR controllers few years ago.

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