Skip to contentSkip to conversation

Realtek SPI-NAND controller

PATCH Applied Chris Packham 4 participants 10 messages Oct 15, 2024 – Nov 23, 2024

Subsystems (4)
lore
Share & tools
lore

Chris Packham

author maintainer
#0 lore raw

v5 cover Realtek SPI-NAND controller

This series adds support for the SPI-NAND flash controller on the RTL9300 family of SoCs.

There are 2 physical chip selects which are called SPI_MST_CS0 and SPI_MST_CS1 in the datasheet. Via some pin-strapping these can be assigned to either the SPI-NOR controller or the SPI-NAND controller. Which means you can end up with the following permutations

SPI-Flash
Boot Model SPI_MST_CS0 SPI_MST_CS1
---------- ----------- -----------

  NOR x1     NOR-CS0     X
  NOR x2     NOR-CS0     NOR-CS1
  NAND x1    NAND-CS0    X
  NAND x2    NAND-CS0    NAND-CS1
  NOR+NAND   NOR-CS0     NAND-CS0

Chris Packham (3):
dt-bindings: spi: Add realtek,rtl9301-snand
mips: dts: realtek: Add SPI NAND controller
spi: spi-mem: Add Realtek SPI-NAND controller

 .../bindings/spi/realtek,rtl9301-snand.yaml   |  62 +++
 MAINTAINERS                                   |   6 +
 arch/mips/boot/dts/realtek/rtl930x.dtsi       |  13 +
 drivers/spi/Kconfig                           |  11 +
 drivers/spi/Makefile                          |   1 +
 drivers/spi/spi-realtek-rtl-snand.c           | 405 ++++++++++++++++++
 6 files changed, 498 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/realtek,rtl9301-snand.yaml
 create mode 100644 drivers/spi/spi-realtek-rtl-snand.c
Signature · 1 line
2.47.0
author maintainer
#1 lore raw

PATCH v5 1/3 dt-bindings: spi: Add realtek,rtl9301-snand

Add a dtschema for the SPI-NAND controller on the RTL9300 SoCs. The controller supports
* Serial/Dual/Quad data with
* PIO and DMA data read/write operation
* Configurable flash access timing

---

Notes:
Changes in v5:
- Use realtek,rtl9301-snand as a fallback to the other compatibles Changes in v4:
- Adjust commit message subject to refer to one of the used compatibles Changes in v3:
- drop wildcard rtl9300-snand
- drop redundant descriptions
- drop clock-names
Changes in v2:
- Add clocks
- For now I've kept realtek,rtl9300-snand to identify the IP block used in the various rtl930x chips. If the consensus is to drop this I can send a v3 with an updated driver to add the chip specific complatibles.

 .../bindings/spi/realtek,rtl9301-snand.yaml   | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/realtek,rtl9301-snand.yaml
Documentation/devicetree/bindings/spi/realtek,rtl9301-snand.yaml new file +62 -0
new file mode 100644
index 000000000000..36d79a90552b
@@ -0,0 +1,62 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/spi/realtek,rtl9301-snand.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SPI-NAND Flash Controller for Realtek RTL9300 SoCs
+
+maintainers:
+  - Chris Packham <[email protected]>
+
+description:
+  The Realtek RTL9300 SoCs have a built in SPI-NAND controller. It supports
+  typical SPI-NAND page cache operations in single, dual or quad IO mode.
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          - enum:
+              - realtek,rtl9302b-snand
+              - realtek,rtl9302c-snand
+              - realtek,rtl9303-snand
+          - const: realtek,rtl9301-snand
+      - const: realtek,rtl9301-snand
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+
+allOf:
+  - $ref: /schemas/spi/spi-controller.yaml#
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    spi@1a400 {
+      compatible = "realtek,rtl9302c-snand", "realtek,rtl9301-snand";
+      reg = <0x1a400 0x44>;
+      interrupt-parent = <&intc>;
+      interrupts = <19>;
+      clocks = <&lx_clk>;
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      flash@0 {
+        compatible = "spi-nand";
+        reg = <0>;
+      };
+    };
Signature · 1 line
2.47.0
author maintainer
#3 lore raw

PATCH v5 2/3 mips: dts: realtek: Add SPI NAND controller

In reply to Chris Packham

Add the SPI-NAND controller on the RTL9300 family of devices. This supports serial/dual/quad data width and DMA for read/program operations.

---

Notes:
Changes in v4 & v5:
- none
Changes in v3:
- drop wildcard rtl9300-snand compatible
- drop clock-names
Changes in v2:
- Add clocks

 arch/mips/boot/dts/realtek/rtl930x.dtsi | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/mips/boot/dts/realtek/rtl930x.dtsi +13 -0
index f271940f82be..b01a40ec3064 100644
@@ -32,6 +32,8 @@ lx_clk: clock-175mhz {
 };
 
 &soc {
+	ranges = <0x0 0x18000000 0x20000>;
+
 	intc: interrupt-controller@3000 {
 		compatible = "realtek,rtl9300-intc", "realtek,rtl-intc";
 		reg = <0x3000 0x18>, <0x3018 0x18>;
@@ -59,6 +61,17 @@ timer0: timer@3200 {
 		interrupts = <7>, <8>, <9>, <10>, <11>;
 		clocks = <&lx_clk>;
 	};
+
+	snand: spi@1a400 {
+		compatible = "realtek,rtl9301-snand";
+		reg = <0x1a400 0x44>;
+		interrupt-parent = <&intc>;
+		interrupts = <19>;
+		clocks = <&lx_clk>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "disabled";
+	};
 };
 
 &uart0 {
Signature · 1 line
2.47.0
author maintainer
#4 lore raw

Re: [PATCH v5 2/3] mips: dts: realtek: Add SPI NAND controller

Hi Thomas,

Quoted 5 lines · Chris Packham

Add the SPI-NAND controller on the RTL9300 family of devices. This supports serial/dual/quad data width and DMA for read/program operations.

Has this one fallen through the cracks?

I see you picked up a couple of my other changes for 6.13 but this seems to be missing from mips/linux.

Quoted 45 lines

---

Notes:
Changes in v4 & v5:
- none
Changes in v3:
- drop wildcard rtl9300-snand compatible
- drop clock-names
Changes in v2:
- Add clocks

  arch/mips/boot/dts/realtek/rtl930x.dtsi | 13 +++++++++++++
  1 file changed, 13 insertions(+)
arch/mips/boot/dts/realtek/rtl930x.dtsi +13 -0
index f271940f82be..b01a40ec3064 100644
@@ -32,6 +32,8 @@ lx_clk: clock-175mhz {
  };
 
  &soc {
+	ranges = <0x0 0x18000000 0x20000>;
+
  	intc: interrupt-controller@3000 {
  		compatible = "realtek,rtl9300-intc", "realtek,rtl-intc";
  		reg = <0x3000 0x18>, <0x3018 0x18>;
@@ -59,6 +61,17 @@ timer0: timer@3200 {
  		interrupts = <7>, <8>, <9>, <10>, <11>;
  		clocks = <&lx_clk>;
  	};
+
+	snand: spi@1a400 {
+		compatible = "realtek,rtl9301-snand";
+		reg = <0x1a400 0x44>;
+		interrupt-parent = <&intc>;
+		interrupts = <19>;
+		clocks = <&lx_clk>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "disabled";
+	};
  };
 
  &uart0 {
#5 lore raw

Re: [PATCH v5 2/3] mips: dts: realtek: Add SPI NAND controller

Quoted 7 lines · Chris Packham

Hi Thomas,

Quoted 4 lines · Chris Packham

Add the SPI-NAND controller on the RTL9300 family of devices. This supports serial/dual/quad data width and DMA for read/program operations.

Quoted 6 lines
Quoted 1 line

Has this one fallen through the cracks?

I see you picked up a couple of my other changes for 6.13 but this seems to be missing from mips/linux.

hmm, I thought I saw some unresolved problems with the other patches... But if this is all good, I'll add it to my second pull request.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
author maintainer
#6 lore raw

Re: [PATCH v5 2/3] mips: dts: realtek: Add SPI NAND controller

Quoted 8 lines · Thomas Bogendoerfer
Quoted 7 lines · Chris Packham

Hi Thomas,

Quoted 4 lines · Chris Packham

Add the SPI-NAND controller on the RTL9300 family of devices. This supports serial/dual/quad data width and DMA for read/program operations.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Has this one fallen through the cracks?

I see you picked up a couple of my other changes for 6.13 but this seems to be missing from mips/linux.

hmm, I thought I saw some unresolved problems with the other patches... But if this is all good, I'll add it to my second pull request.

The binding patch got an r-by from Krzysztof. The driver itself was applied by by Mark, it did have a problem but that was fixed with another patch. So from my point of view this is good to go (please speak up if I've missed something).

I do intend to add a few more compatibles for other RTL chips that use this spi-nand controller but I'll do that as new patches.

maintainer Applied
#7 lore raw

Re: [PATCH v5 2/3] mips: dts: realtek: Add SPI NAND controller

In reply to Chris Packham
Quoted 52 lines · Chris Packham

Add the SPI-NAND controller on the RTL9300 family of devices. This supports serial/dual/quad data width and DMA for read/program operations.

---

Notes:
Changes in v4 & v5:
- none
Changes in v3:
- drop wildcard rtl9300-snand compatible
- drop clock-names
Changes in v2:
- Add clocks

 arch/mips/boot/dts/realtek/rtl930x.dtsi | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/mips/boot/dts/realtek/rtl930x.dtsi +13 -0
index f271940f82be..b01a40ec3064 100644
@@ -32,6 +32,8 @@ lx_clk: clock-175mhz {
 };
 
 &soc {
+	ranges = <0x0 0x18000000 0x20000>;
+
 	intc: interrupt-controller@3000 {
 		compatible = "realtek,rtl9300-intc", "realtek,rtl-intc";
 		reg = <0x3000 0x18>, <0x3018 0x18>;
@@ -59,6 +61,17 @@ timer0: timer@3200 {
 		interrupts = <7>, <8>, <9>, <10>, <11>;
 		clocks = <&lx_clk>;
 	};
+
+	snand: spi@1a400 {
+		compatible = "realtek,rtl9301-snand";
+		reg = <0x1a400 0x44>;
+		interrupt-parent = <&intc>;
+		interrupts = <19>;
+		clocks = <&lx_clk>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "disabled";
+	};
 };
 
 &uart0 {
Signature · 1 line
2.47.0

applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
author maintainer
#8 lore raw

PATCH v5 3/3 spi: spi-mem: Add Realtek SPI-NAND controller

In reply to Chris Packham

Add a driver for the SPI-NAND controller on the RTL9300 family of devices.

The controller supports
* Serial/Dual/Quad data with
* PIO and DMA data read/write operation
* Configurable flash access timing

There is a separate ECC controller on the RTL9300 which isn't currently supported (instead we rely on the on-die ECC supported by most SPI-NAND chips).

---

Notes:
Changes in v5:
- None
Changes in v4:
- Fix up MAINTAINERS entry for renamed file Changes in v3:
- drop wildcard rtl9300-snand compatible
- Add SoC specific compatibles for the 4 known variants Changes in v2:
- Spell my own name correctly
- Remove unecessary rtl_snand_adjust_op_size()

 MAINTAINERS                         |   6 +
 drivers/spi/Kconfig                 |  11 +
 drivers/spi/Makefile                |   1 +
 drivers/spi/spi-realtek-rtl-snand.c | 405 ++++++++++++++++++++++++++++
 4 files changed, 423 insertions(+)
 create mode 100644 drivers/spi/spi-realtek-rtl-snand.c
MAINTAINERS +6 -0
index f328373463b0..cf020c566f4a 100644
@@ -19272,6 +19272,12 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/net/dsa/realtek.yaml
 F:	drivers/net/dsa/realtek/*
 
+REALTEK SPI-NAND
+M:	Chris Packham <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/spi/realtek,rtl9301-snand.yaml
+F:	drivers/spi/spi-realtek-rtl-snand.c
+
 REALTEK WIRELESS DRIVER (rtlwifi family)
 M:	Ping-Ke Shih <[email protected]>
 L:	[email protected]
drivers/spi/Kconfig +11 -0
index ec1550c698d5..33228a607c4b 100644
@@ -843,6 +843,17 @@ config SPI_PXA2XX
 config SPI_PXA2XX_PCI
 	def_tristate SPI_PXA2XX && PCI && COMMON_CLK
 
+config SPI_REALTEK_SNAND
+	tristate "Realtek SPI-NAND Flash Controller"
+	depends on MACH_REALTEK_RTL || COMPILE_TEST
+	select REGMAP
+	help
+	  This enables support for the SPI-NAND Flash controller on
+	  Realtek SoCs.
+
+	  This driver does not support generic SPI. The implementation
+	  only supports the spi-mem interface.
+
 config SPI_ROCKCHIP
 	tristate "Rockchip SPI controller driver"
 	depends on ARCH_ROCKCHIP || COMPILE_TEST
drivers/spi/Makefile +1 -0
index a9b1bc259b68..9a3338236645 100644
@@ -119,6 +119,7 @@ obj-$(CONFIG_SPI_ROCKCHIP)		+= spi-rockchip.o
 obj-$(CONFIG_SPI_ROCKCHIP_SFC)		+= spi-rockchip-sfc.o
 obj-$(CONFIG_SPI_RB4XX)			+= spi-rb4xx.o
 obj-$(CONFIG_MACH_REALTEK_RTL)		+= spi-realtek-rtl.o
+obj-$(CONFIG_SPI_REALTEK_SNAND)		+= spi-realtek-rtl-snand.o
 obj-$(CONFIG_SPI_RPCIF)			+= spi-rpc-if.o
 obj-$(CONFIG_SPI_RSPI)			+= spi-rspi.o
 obj-$(CONFIG_SPI_RZV2M_CSI)		+= spi-rzv2m-csi.o
drivers/spi/spi-realtek-rtl-snand.c new file +405 -0

405 lines not on this page · raw message

Signature · 1 line
2.47.0
maintainer
#9 lore raw

Re: (subset) [PATCH v5 0/3] Realtek SPI-NAND controller

In reply to Chris Packham
Quoted 9 lines · Chris Packham

This series adds support for the SPI-NAND flash controller on the RTL9300 family of SoCs.

There are 2 physical chip selects which are called SPI_MST_CS0 and SPI_MST_CS1 in the datasheet. Via some pin-strapping these can be assigned to either the SPI-NOR controller or the SPI-NAND controller. Which means you can end up with the following permutations

[...]

Applied to

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

Thanks!

[1/3] dt-bindings: spi: Add realtek,rtl9301-snand

      commit: eef26f1c6179eee5b622362b324a0a72dafb5c16
[3/3] spi: spi-mem: Add Realtek SPI-NAND controller
      commit: 42d20a6a61b8fccbb57d80df1ccde7dd82d5bbd6

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