spi: sun6i: Add dual read support for the H616

Message ID 20261110-spi-sun6i-h616-dual-read-v1-1-59bea5a897d4@gmail.com (mailing list archive)
State New
Headers
Series spi: sun6i: Add dual read support for the H616 |

Commit Message

Arun Iyengar via B4 Relay Nov. 10, 2026, 5:34 a.m. UTC
From: Arun Iyengar <aiyengar1990@gmail.com>

The H616 SPI controllers are bound through the "allwinner,sun8i-h3-spi"
fallback, whose configuration advertises no dual or quad modes. The
H616 user manual (v1.0, SPI_BCC register at 0x38) documents the same
dual read (DRM, bit 28) and quad (Quad_EN, bit 29) controls that the
driver already programs for the R329, while the controller keeps the
H3-style clock control register (SPI_CCR at 0x24).

Add an H616 configuration that combines the H3 clock control with dual
reads, matched on the existing "allwinner,sun50i-h616-spi" compatible,
so SPI NOR flashes can use 1-1-2 reads where the board wires both data
lines. Only dual reads are advertised: dual writes and quad mode use the
same register bits but have not been tested on the H616.

Tested on an Orange Pi Zero2 with its 2 MiB Macronix SPI NOR and
spi-rx-bus-width = <2> on the flash node: spi-nor reads with 1S-1S-2S
(opcode 0x3b), reading the whole flash takes 0.30 s instead of 0.52 s,
and repeated reads return identical data with a valid boot0 header.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
This patch was developed with Claude (Anthropic) as a coding assistant:
it investigated the problem, wrote the code and the commit message. I
reviewed it, and it was tested on an Orange Pi Zero2 (H616) as described
above.
---
 drivers/spi/spi-sun6i.c | 7 +++++++
 1 file changed, 7 insertions(+)


---
base-commit: 429c9a10b3811ca2581f88c05a58bb1fd23229a7
change-id: 20261110-spi-sun6i-h616-dual-read-562843bc20d7

Best regards,
--  
Arun Iyengar <aiyengar1990@gmail.com>
  

Comments

Mark Brown Nov. 13, 2026, 11:14 p.m. UTC | #1
> The H616 SPI controllers are bound through the "allwinner,sun8i-h3-spi"
> fallback, whose configuration advertises no dual or quad modes. The

> @@ -785,6 +791,7 @@ static const struct sun6i_spi_cfg sun50i_r329_spi_cfg = {
>  static const struct of_device_id sun6i_spi_match[] = {
>  	{ .compatible = "allwinner,sun6i-a31-spi", .data = &sun6i_a31_spi_cfg },
>  	{ .compatible = "allwinner,sun8i-h3-spi",  .data = &sun8i_h3_spi_cfg },
> +	{ .compatible = "allwinner,sun50i-h616-spi", .data = &sun50i_h616_spi_cfg },
>  	{ .compatible = "allwinner,sun50i-r329-spi", .data = &sun50i_r329_spi_cfg },
>  	/*
>  	 * A523's SPI controller has a combined RX buffer + FIFO counter

This new compatible needs a corresponding DT binding update.
  
Arun Iyengar Nov. 14, 2026, 1:13 a.m. UTC | #2
> This new compatible needs a corresponding DT binding update.

The binding already has it: allwinner,sun6i-a31-spi.yaml lists
"allwinner,sun50i-h616-spi" with the "allwinner,sun8i-h3-spi" fallback,
and sun50i-h616.dtsi uses that pair. The patch only makes the driver
match the specific compatible before the fallback.

I'll say so in the commit message if a v2 is needed.

Arun
  
Arun Iyengar Nov. 16, 2026, 5:58 a.m. UTC | #3
> This new compatible needs a corresponding DT binding update.

You were right and my earlier reply was wrong: the binding limits the
H616 to single-line bus widths, so a dual-read flash node fails the DT
check. v2 adds the binding change as patch 1.

Arun

On Fri, Nov 13, 2026 at 5:13 PM Arun Iyengar <aiyengar1990@gmail.com> wrote:
>
> > This new compatible needs a corresponding DT binding update.
>
> The binding already has it: allwinner,sun6i-a31-spi.yaml lists
> "allwinner,sun50i-h616-spi" with the "allwinner,sun8i-h3-spi" fallback,
> and sun50i-h616.dtsi uses that pair. The patch only makes the driver
> match the specific compatible before the fallback.
>
> I'll say so in the commit message if a v2 is needed.
>
> Arun
  

Patch

diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c
index e9fce8618299..2798b9c198c6 100644
--- a/drivers/spi/spi-sun6i.c
+++ b/drivers/spi/spi-sun6i.c
@@ -777,6 +777,12 @@  static const struct sun6i_spi_cfg sun8i_h3_spi_cfg = {
 	.has_clk_ctl	= true,
 };
 
+static const struct sun6i_spi_cfg sun50i_h616_spi_cfg = {
+	.fifo_depth	= SUN8I_FIFO_DEPTH,
+	.has_clk_ctl	= true,
+	.mode_bits	= SPI_RX_DUAL,
+};
+
 static const struct sun6i_spi_cfg sun50i_r329_spi_cfg = {
 	.fifo_depth	= SUN8I_FIFO_DEPTH,
 	.mode_bits	= SPI_RX_DUAL | SPI_TX_DUAL | SPI_RX_QUAD | SPI_TX_QUAD,
@@ -785,6 +791,7 @@  static const struct sun6i_spi_cfg sun50i_r329_spi_cfg = {
 static const struct of_device_id sun6i_spi_match[] = {
 	{ .compatible = "allwinner,sun6i-a31-spi", .data = &sun6i_a31_spi_cfg },
 	{ .compatible = "allwinner,sun8i-h3-spi",  .data = &sun8i_h3_spi_cfg },
+	{ .compatible = "allwinner,sun50i-h616-spi", .data = &sun50i_h616_spi_cfg },
 	{ .compatible = "allwinner,sun50i-r329-spi", .data = &sun50i_r329_spi_cfg },
 	/*
 	 * A523's SPI controller has a combined RX buffer + FIFO counter