spi: ma35d1-qspi: Add Nuvoton MA35D1 QSPI controller
Subsystems (3)
v4 cover spi: ma35d1-qspi: Add Nuvoton MA35D1 QSPI controller
From: Chi-Wen Weng <[email protected]>
Add devicetree binding and SPI controller driver support for the Quad SPI controller found in Nuvoton MA35D1 SoCs.
The controller provides two native chip selects and supports standard SPI and spi-mem operations using single, dual and quad bus widths.
This initial implementation uses 8-bit PIO transfers and supports per-operation clock configuration, clock and reset handling, and direct execution of SPI memory operations. DMA and active-high chip select support are intentionally left out of the initial driver.
Changes in v4:
* Added minimum 1 and default 2 constraints for num-cs in the devicetree binding.
* Made the driver read num-cs and fall back to two chip selects when the property is absent.
* Dropped SPI_CS_HIGH support from the initial driver.
* Kept separate chip-select helpers for the SPI core and direct spi-mem paths because their boolean arguments have different semantics.
* Protected SSCTL register read-modify-write operations with a spinlock.
* Limited spi-mem operations and individual SPI transfers to 4 KiB.
* Limited complete SPI messages to 8 KiB.
* Restricted the initial driver to 8-bit words.
* Added defensive transfer-size validation to keep the PIO polling path bounded.
* Kept bidirectional data pins in input mode during dual and quad dummy transfers in the generic spi-mem fallback path.
* Treated zero tx_nbits and rx_nbits values as single-lane transfers in the generic SPI path.
Changes in v3:
* Fixed the DCO mismatch by using a consistent author and Signed-off-by address.
* Added spi_controller_mem_caps and enabled per-operation frequency handling for spi-mem operations.
* Added a short delay after requesting FIFO reset before polling reset completion.
* Documented that the controller generates one RX FIFO entry for each TX word in single, dual-output and quad-output modes.
* Added the missing linux/delay.h include.
* Removed unused register bit definitions.
Changes in v2:
* Updated patch subject lines to follow SPI subsystem style.
* Added a commit message to the devicetree binding patch.
* Added ARCH_MA35 || COMPILE_TEST dependency to Kconfig.
* Expanded the Kconfig help text.
* Converted the driver file header to C++-style comments.
* Added reset control handling.
* Added the resets property to the binding.
* Added a num-cs constraint to the binding.
* Removed the flash child node from the binding example.
* Used op->max_freq for spi-mem operations.
* Split low-level chip-select register handling from the SPI core callback.
* Limited spi-mem command opcode length to one byte.
* Forced spi-mem operations to use 8-bit words.
* Avoided driving bidirectional data pins during dummy cycles.
* Drained RX FIFO entries during transmit-only transfers.
* Rejected invalid chip-select numbers.
* Rejected unsupported dual and quad full-duplex generic SPI transfers.
* Fixed checkpatch style issues.
Chi-Wen Weng (2):
dt-bindings: spi: nuvoton,ma35d1-qspi: Add Nuvoton MA35D1 QSPI
spi: ma35d1-qspi: Add Nuvoton MA35D1 QSPI controller support
.../bindings/spi/nuvoton,ma35d1-qspi.yaml | 63 ++ drivers/spi/Kconfig | 10 + drivers/spi/Makefile | 1 + drivers/spi/spi-ma35d1-qspi.c | 658 ++++++++++++++++++ 4 files changed, 732 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/nuvoton,ma35d1-qspi.yaml create mode 100644 drivers/spi/spi-ma35d1-qspi.c
Signature · 1 line
2.25.1
PATCH v4 1/2 dt-bindings: spi: nuvoton,ma35d1-qspi: Add Nuvoton MA35D1 QSPI
From: Chi-Wen Weng <[email protected]>
Add a devicetree binding for the Quad SPI controller found in Nuvoton MA35D1 SoCs.
The controller supports SPI memory devices such as SPI NOR and SPI NAND flashes. It has one register range, one clock input and one reset line, and supports up to two chip selects.
--- .../bindings/spi/nuvoton,ma35d1-qspi.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/nuvoton,ma35d1-qspi.yaml
Documentation/devicetree/bindings/spi/nuvoton,ma35d1-qspi.yaml new file +63 -0
@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/spi/nuvoton,ma35d1-qspi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton MA35D1 Quad SPI Controller + +maintainers: + - Chi-Wen Weng <[email protected]> + +allOf: + - $ref: /schemas/spi/spi-controller.yaml# + +properties: + compatible: + const: nuvoton,ma35d1-qspi + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + maxItems: 1 + + num-cs: + minimum: 1 + maximum: 2 + default: 2 + +required: + - compatible + - reg + - clocks + - resets + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/clock/nuvoton,ma35d1-clk.h> + #include <dt-bindings/reset/nuvoton,ma35d1-reset.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + spi@40680000 { + compatible = "nuvoton,ma35d1-qspi"; + reg = <0 0x40680000 0 0x100>; + interrupts = <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk QSPI0_GATE>; + resets = <&sys MA35D1_RESET_QSPI0>; + #address-cells = <1>; + #size-cells = <0>; + }; + };
Signature · 1 line
2.25.1
Re: [PATCH v4 1/2] dt-bindings: spi: nuvoton,ma35d1-qspi: Add Nuvoton MA35D1 QSPI
Quoted 9 lines · Chi-Wen Weng
From: Chi-Wen Weng <[email protected]>
Add a devicetree binding for the Quad SPI controller found in Nuvoton MA35D1 SoCs.
The controller supports SPI memory devices such as SPI NOR and SPI NAND flashes. It has one register range, one clock input and one reset line, and supports up to two chip selects.
Quoted 5 lines
Signed-off-by Chi-Wen Weng <[email protected]>--- .../bindings/spi/nuvoton,ma35d1-qspi.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/nuvoton,ma35d1-qspi.yaml
Best regards,
Krzysztof
PATCH v4 2/2 spi: ma35d1-qspi: Add Nuvoton MA35D1 QSPI controller support
In reply to Chi-Wen WengFrom: Chi-Wen Weng <[email protected]>
Add SPI controller driver support for the Quad SPI controller found in Nuvoton MA35D1 SoCs.
The controller provides two native chip selects and supports standard SPI and spi-mem operations, including single-bit full-duplex transfers and dual or quad half-duplex transfers. Implement 8-bit PIO transfers, per-operation clock configuration, clock and reset handling, and direct execution of SPI memory operations.
Limit individual transfers to 4 KiB and SPI messages to 8 KiB to keep the PIO polling path bounded. Read the optional num-cs property and fall back to the hardware default of two chip selects when it is not present.
Active-high chip select and DMA transfers are not supported by this initial implementation.
--- drivers/spi/Kconfig | 10 + drivers/spi/Makefile | 1 + drivers/spi/spi-ma35d1-qspi.c | 658 ++++++++++++++++++++++++++++++++++ 3 files changed, 669 insertions(+) create mode 100644 drivers/spi/spi-ma35d1-qspi.c
drivers/spi/Kconfig +10 -0
@@ -694,6 +694,16 @@ config SPI_LJCA This driver can also be built as a module. If so, the module will be called spi-ljca. +config SPI_MA35D1_QSPI + tristate "Nuvoton MA35D1 QSPI controller" + depends on ARCH_MA35 || COMPILE_TEST + help + This enables support for the Quad SPI controller found in + Nuvoton MA35D1 SoCs. + + The controller supports SPI memory devices such as SPI NOR and + SPI NAND flashes in single, dual and quad I/O modes. + config SPI_MESON_SPICC tristate "Amlogic Meson SPICC controller" depends on COMMON_CLK
drivers/spi/Makefile +1 -0
@@ -85,6 +85,7 @@ obj-$(CONFIG_SPI_LOONGSON_CORE) += spi-loongson-core.o obj-$(CONFIG_SPI_LOONGSON_PCI) += spi-loongson-pci.o obj-$(CONFIG_SPI_LOONGSON_PLATFORM) += spi-loongson-plat.o obj-$(CONFIG_SPI_LP8841_RTC) += spi-lp8841-rtc.o +obj-$(CONFIG_SPI_MA35D1_QSPI) += spi-ma35d1-qspi.o obj-$(CONFIG_SPI_MESON_SPICC) += spi-meson-spicc.o obj-$(CONFIG_SPI_MESON_SPIFC) += spi-meson-spifc.o obj-$(CONFIG_SPI_MICROCHIP_CORE_QSPI) += spi-microchip-core-qspi.o
drivers/spi/spi-ma35d1-qspi.c new file +658 -0
658 lines not on this page · raw message
Signature · 1 line
2.25.1
Mark Brown
maintainerRe: [PATCH v4 2/2] spi: ma35d1-qspi: Add Nuvoton MA35D1 QSPI controller support
Quoted 4 lines · Chi-Wen Weng
Add SPI controller driver support for the Quad SPI controller found in Nuvoton MA35D1 SoCs.
drivers/spi/spi-ma35d1-qspi.c new file +1
-0+static int nuvoton_qspi_mem_exec_op(struct spi_mem *mem,
drivers/spi/spi-ma35d1-qspi.c line 491
Quoted 10 lines
drivers/spi/spi-ma35d1-qspi.c new file +9
-0+ const struct spi_mem_op *op) +{ +if (op->dummy.nbytes) { +nuvoton_qspi_set_bus_width (qspi, op->dummy.buswidth, +SPI_MEM_DATA_IN ); + ret =nuvoton_qspi_txrx (qspi,NULL ,NULL , op->dummy.nbytes); +if (ret) + goto out_deassert_cs; + }
I would expect dummy data to be an output rather than an input, we don't want the lines left floating? There's a similar thing below when setting up the dummy xfer.
Re: [PATCH v4 2/2] spi: ma35d1-qspi: Add Nuvoton MA35D1 QSPI controller support
Mark Brown 於 2026/7/30 下午 11:11 寫道:
Quoted 17 lines · Chi-Wen Weng
drivers/spi/spi-ma35d1-qspi.c line 491
Quoted 13 lines
Add SPI controller driver support for the Quad SPI controller found in Nuvoton MA35D1 SoCs.
drivers/spi/spi-ma35d1-qspi.c new file +10
-0+static int nuvoton_qspi_mem_exec_op (struct spi_mem *mem, +const struct spi_mem_op *op) +{ +if (op->dummy.nbytes) { +nuvoton_qspi_set_bus_width (qspi, op->dummy.buswidth, +SPI_MEM_DATA_IN ); + ret =nuvoton_qspi_txrx (qspi,NULL ,NULL , op->dummy.nbytes); +if (ret) + goto out_deassert_cs; + }I would expect dummy data to be an output rather than an input, we don't want the lines left floating? There's a similar thing below when setting up the dummy xfer.
Hi Mark,
Thanks for pointing this out.
You are right. The dummy phase should be driven as an output rather than leaving the data lines in input mode.
I will update the direct spi-mem path to use SPI_MEM_DATA_OUT for the dummy phase. I will also fix the generic transfer path so that spi-mem dummy transfers remain output transfers instead of switching the lines to input.
Best regards,
Chi-Wen