Skip to contentSkip to conversation

Add add SPI-NAND Flash controller driver for EN7581

PATCH Superseded Lorenzo Bianconi 4 participants 9 messages Apr 29, 2024 – May 2, 2024

Subsystems (4)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Lorenzo Bianconi

author maintainer
#0 lore raw

v5 cover Add add SPI-NAND Flash controller driver for EN7581

Introduce support for SPI-NAND driver of the Airoha NAND Flash Interface found on Airoha ARM EN7581 SoCs.

Changes since v4:
- rely on devm_platform_ioremap_resource() routine
- rework airoha_snand_is_page_ops() routine
Changes since v3:
- rely on devm_kzalloc() to allocate airoha_snand_dev buffers
- rely on dev_err_probe()
- cosmetic rework
Changes since v2:
- Fix compilation warnings
- Remove interrupt entry in dts since it is not connected so far Changes since v1:
- Introduce spi clock dependency

Lorenzo Bianconi (3):
dt-bindings: spi: airoha: Add YAML schema for SNFI controller
arm64: dts: airoha: add EN7581 spi-nand node
spi: airoha: add SPI-NAND Flash controller driver

 .../bindings/spi/airoha,en7581-snand.yaml     |   65 +
 MAINTAINERS                                   |    9 +
 arch/arm64/boot/dts/airoha/en7581.dtsi        |   19 +
 drivers/spi/Kconfig                           |   10 +
 drivers/spi/Makefile                          |    1 +
 drivers/spi/spi-airoha-snfi.c                 | 1129 +++++++++++++++++
 6 files changed, 1233 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/airoha,en7581-snand.yaml
 create mode 100644 drivers/spi/spi-airoha-snfi.c
Signature · 1 line
2.44.0
author maintainer
#1 lore raw

PATCH v5 1/3 dt-bindings: spi: airoha: Add YAML schema for SNFI controller

Introduce Airoha EN7581 SPI NAND controller binding

---
 .../bindings/spi/airoha,en7581-snand.yaml     | 65 +++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/airoha,en7581-snand.yaml
Documentation/devicetree/bindings/spi/airoha,en7581-snand.yaml new file +65 -0
new file mode 100644
index 000000000000..b820c5613dcc
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/spi/airoha,en7581-snand.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SPI-NAND flash controller for Airoha ARM SoCs
+
+maintainers:
+  - Lorenzo Bianconi <[email protected]>
+
+allOf:
+  - $ref: spi-controller.yaml#
+
+properties:
+  compatible:
+    const: airoha,en7581-snand
+
+  reg:
+    items:
+      - description: spi base address
+      - description: nfi2spi base address
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    items:
+      - const: spi
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/en7523-clk.h>
+
+    soc {
+      #address-cells = <2>;
+      #size-cells = <2>;
+
+      spi@1fa10000 {
+        compatible = "airoha,en7581-snand";
+        reg = <0x0 0x1fa10000 0x0 0x140>,
+              <0x0 0x1fa11000 0x0 0x160>;
+
+        clocks = <&scuclk EN7523_CLK_SPI>;
+        clock-names = "spi";
+
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        flash@0 {
+          compatible = "spi-nand";
+          reg = <0>;
+          spi-tx-bus-width = <1>;
+          spi-rx-bus-width = <2>;
+        };
+      };
+    };
Signature · 1 line
2.44.0
maintainer
#2 lore raw

Re: [PATCH v5 1/3] dt-bindings: spi: airoha: Add YAML schema for SNFI controller

Quoted 1 line · Lorenzo Bianconi

Introduce Airoha EN7581 SPI NAND controller binding

Please submit patches using subject lines reflecting the style for the subsystem, this makes it easier for people to identify relevant patches. Look at what existing commits in the area you're changing are doing and make sure your subject lines visually resemble what they're doing. There's no need to resubmit to fix this alone.

author maintainer
#3 lore raw

PATCH v5 2/3 arm64: dts: airoha: add EN7581 spi-nand node

In reply to Lorenzo Bianconi

Introduce the Airoha EN7581 spi-nand node in Airoha EN7581 dtsi

---
 arch/arm64/boot/dts/airoha/en7581.dtsi | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
arch/arm64/boot/dts/airoha/en7581.dtsi +19 -0
index 5c4bfe3e1e5a..98c2a86086e1 100644
@@ -159,5 +159,24 @@ scuclk: clock-controller@1fa20000 {
 			      <0x0 0x1fbe3400 0x0 0xfc>;
 			#clock-cells = <1>;
 		};
+
+		snfi: spi@1fa10000 {
+			compatible = "airoha,en7581-snand";
+			reg = <0x0 0x1fa10000 0x0 0x140>,
+			      <0x0 0x1fa11000 0x0 0x160>;
+
+			clocks = <&scuclk EN7523_CLK_SPI>;
+			clock-names = "spi";
+
+			#address-cells = <1>;
+			#size-cells = <0>;
+			spi_nand: nand@0 {
+				compatible = "spi-nand";
+				reg = <0>;
+				spi-max-frequency = <50000000>;
+				spi-tx-bus-width = <1>;
+				spi-rx-bus-width = <2>;
+			};
+		};
 	};
 };
Signature · 1 line
2.44.0
author maintainer
#4 lore raw

PATCH v5 3/3 spi: airoha: add SPI-NAND Flash controller driver

In reply to Lorenzo Bianconi

Introduce support for SPI-NAND driver of the Airoha NAND Flash Interface found on Airoha ARM SoCs.

---
 MAINTAINERS                   |    9 +
 drivers/spi/Kconfig           |   10 +
 drivers/spi/Makefile          |    1 +
 drivers/spi/spi-airoha-snfi.c | 1129 +++++++++++++++++++++++++++++++++
 4 files changed, 1149 insertions(+)
 create mode 100644 drivers/spi/spi-airoha-snfi.c
MAINTAINERS +9 -0
index aa3b947fb080..ce9fac46f741 100644
@@ -653,6 +653,15 @@ S:	Supported
 F:	fs/aio.c
 F:	include/linux/*aio*.h
 
+AIROHA SPI SNFI DRIVER
+M:	Lorenzo Bianconi <[email protected]>
+M:	Ray Liu <[email protected]>
+L:	[email protected] (moderated for non-subscribers)
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/spi/airoha,en7581-snand.yaml
+F:	drivers/spi/spi-airoha.c
+
 AIRSPY MEDIA DRIVER
 L:	[email protected]
 S:	Orphan
drivers/spi/Kconfig +10 -0
index bc7021da2fe9..6fa91775f334 100644
@@ -57,6 +57,16 @@ config SPI_MEM
 
 comment "SPI Master Controller Drivers"
 
+config SPI_AIROHA_SNFI
+	tristate "Airoha SPI NAND Flash Interface"
+	depends on ARCH_AIROHA || COMPILE_TEST
+	depends on SPI_MASTER
+	select REGMAP_MMIO
+	help
+	  This enables support for SPI-NAND mode on the Airoha NAND
+	  Flash Interface found on Airoha ARM SoCs. This controller
+	  is implemented as a SPI-MEM controller.
+
 config SPI_ALTERA
 	tristate "Altera SPI Controller platform driver"
 	select SPI_ALTERA_CORE
drivers/spi/Makefile +1 -0
index 4ff8d725ba5e..e694254dec04 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_SPI_SPIDEV)		+= spidev.o
 obj-$(CONFIG_SPI_LOOPBACK_TEST)		+= spi-loopback-test.o
 
 # SPI master controller drivers (bus)
+obj-$(CONFIG_SPI_AIROHA_SNFI)		+= spi-airoha-snfi.o
 obj-$(CONFIG_SPI_ALTERA)		+= spi-altera-platform.o
 obj-$(CONFIG_SPI_ALTERA_CORE)		+= spi-altera-core.o
 obj-$(CONFIG_SPI_ALTERA_DFL)		+= spi-altera-dfl.o
drivers/spi/spi-airoha-snfi.c new file +1129 -0

1,129 lines not on this page · raw message

Signature · 1 line
2.44.0
Reviewed-by on v5 3/3
#5 lore raw

Re: [PATCH v5 3/3] spi: airoha: add SPI-NAND Flash controller driver

Quoted 3 lines · Lorenzo Bianconi

Introduce support for SPI-NAND driver of the Airoha NAND Flash Interface found on Airoha ARM SoCs.

FWIW,

...

drivers/spi/spi-airoha-snfi.c line 1000

Quoted 7 lines
drivers/spi/spi-airoha-snfi.c new file +6 -0
+static void airoha_snand_cleanup(struct spi_device *spi)
+{
+       struct airoha_snand_dev *as_dev = spi_get_ctldata(spi);
 
+       struct airoha_snand_ctrl *as_ctrl;
+
+       as_ctrl = spi_controller_get_devdata(spi->controller);

You may do it on one line above (the same way as for as_dev). Ditto for other similar cases around.

Quoted 4 lines
drivers/spi/spi-airoha-snfi.c new file +4 -0
+       dma_unmap_single(as_ctrl->dev, as_dev->dma_addr,
+                        as_dev->buf_len, DMA_BIDIRECTIONAL);
+       spi_set_ctldata(spi, NULL);
+}

...

drivers/spi/spi-airoha-snfi.c line 1056

Quoted 5 lines
drivers/spi/spi-airoha-snfi.c new file +5 -0
+static const struct of_device_id airoha_snand_ids[] = {
+       { .compatible   = "airoha,en7581-snand" },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, airoha_snand_ids);

No need to keep this block here, the first user is below the ->probe().

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#6 lore raw

Re: [PATCH v5 3/3] spi: airoha: add SPI-NAND Flash controller driver

Quoted 14 lines · Lorenzo Bianconi
Quoted 3 lines

Introduce support for SPI-NAND driver of the Airoha NAND Flash Interface found on Airoha ARM SoCs.

FWIW,

...

Quoted 3 lines
drivers/spi/spi-airoha-snfi.c new file +3 -0
+static void airoha_snand_cleanup(struct spi_device *spi)
+{
+       struct airoha_snand_dev *as_dev = spi_get_ctldata(spi);
Quoted 6 lines

drivers/spi/spi-airoha-snfi.c line 664

Quoted 3 lines
drivers/spi/spi-airoha-snfi.c new file +3 -0
+       struct airoha_snand_ctrl *as_ctrl;
+
+       as_ctrl = spi_controller_get_devdata(spi->controller);

You may do it on one line above (the same way as for as_dev). Ditto for other similar cases around.

It was to avoid going beyond 79 columns, I do not have a strong opinion about it.

Quoted 8 lines
Quoted 5 lines
drivers/spi/spi-airoha-snfi.c new file +4 -0
+       dma_unmap_single(as_ctrl->dev, as_dev->dma_addr,
+                        as_dev->buf_len, DMA_BIDIRECTIONAL);
+       spi_set_ctldata(spi, NULL);
+}

...

Quoted 7 lines

drivers/spi/spi-airoha-snfi.c line 1056

Quoted 5 lines
drivers/spi/spi-airoha-snfi.c new file +5 -0
+static const struct of_device_id airoha_snand_ids[] = {
+       { .compatible   = "airoha,en7581-snand" },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, airoha_snand_ids);

No need to keep this block here, the first user is below the ->probe().

ack, I will fix it.

Regards,
Lorenzo

Quoted 4 lines
Signature · 3 lines
-- 
With Best Regards,
Andy Shevchenko
maintainer Reviewed-by on v5 3/3
#7 lore raw

Re: [PATCH v5 3/3] spi: airoha: add SPI-NAND Flash controller driver

In reply to Lorenzo Bianconi

Il 29/04/24 10:13, Lorenzo Bianconi ha scritto:

Quoted 5 lines

Introduce support for SPI-NAND driver of the Airoha NAND Flash Interface found on Airoha ARM SoCs.

maintainer
#8 lore raw

Re: (subset) [PATCH v5 0/3] Add add SPI-NAND Flash controller driver for EN7581

In reply to Lorenzo Bianconi
Quoted 16 lines · Lorenzo Bianconi

Introduce support for SPI-NAND driver of the Airoha NAND Flash Interface found on Airoha ARM EN7581 SoCs.

Changes since v4:
- rely on devm_platform_ioremap_resource() routine
- rework airoha_snand_is_page_ops() routine
Changes since v3:
- rely on devm_kzalloc() to allocate airoha_snand_dev buffers
- rely on dev_err_probe()
- cosmetic rework
Changes since v2:
- Fix compilation warnings
- Remove interrupt entry in dts since it is not connected so far Changes since v1:
- Introduce spi clock dependency

Quoted 1 line

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/3] dt-bindings: spi: airoha: Add YAML schema for SNFI controller

      commit: 8bd0d557aa8394b75f6983b2334aaf1a633e1ce5
[3/3] spi: airoha: add SPI-NAND Flash controller driver
      commit: a403997c12019d0f82a9480207bf85985b8de5e7

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark