Re: [PATCH v2 2/2] spi: spi-mem: Add Realtek SPI flash controller driver

From: Mark Brown

Date: Mon Sep 07 2026 - 09:58:44 EST


On Sun, Sep 06, 2026 at 10:57:55PM +0800, Yu-Chun Lin wrote:

> Add a spi-mem driver for the SPI Flash Controller (SFC) found on Realtek
> DHC SoC. SFC supports Dual I/O.

> drivers/spi/Makefile | 1 +
> drivers/spi/spi-rtk-nor.c | 637 ++++++++++++++++++++++++++++++++++++++

Are we sule Realtek won't have more flash controllers?

> @@ -0,0 +1,637 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Realtek SPI Nor Flash Controller Driver (SFC)
> + *
> + * Copyright (c) 2024-2026 Realtek Technologies Co., Ltd.
> + */

Please make the entire comment block a C++ one so things look more
intentional.

> +static int rtk_spi_do_write_and_cmds(struct rtk_spi_host *host, const struct spi_mem_op *op)
> +{

> + } else {
> + readb(host->iobase);
> +
> + /*
> + * For pure commands that require internal state synchronization
> + * (such as Chip Erase), poll the flash status.
> + */
> + ret = rtk_spi_read_status(host);
> + }

Shouldn't this be done by the spi-nor core if it's needed? There's also
some timeout logic there which this will override.

> +static int rtk_spi_dma_transfer(struct rtk_spi_host *host, loff_t offset,
> + size_t len, bool is_read)
> +{

> + writel(DMA_W_EN | DMA_START, host->mdbase + MD_FDMA_CTRL1);
> + udelay(1);

> + ret = readl_poll_timeout(host->mdbase + MD_FDMA_CTRL1, val,
> + !(val & DMA_START), 100, timeout_us);
> + if (ret) {
> + dev_err(host->dev, "DMA transfer timed out\n");
> + return ret;
> + }

Don't we need to turn off the hardware here?

> +static int rtk_spi_runtime_resume(struct device *dev)
> +{
> + struct spi_controller *ctlr = dev_get_drvdata(dev);
> + struct rtk_spi_host *host = spi_controller_get_devdata(ctlr);
> + int ret;
> +
> + ret = clk_prepare_enable(host->clk);
> + if (ret < 0) {
> + dev_err(dev, "clk_prepare_enable failed: %d\n", ret);
> + return ret;
> + }
> +
> + reset_control_assert(host->rstc);
> + usleep_range(10, 20);
> + reset_control_deassert(host->rstc);
> +
> + rtk_spi_init(host);
> +
> + return 0;
> +}

rtk_spi_init() doesn't handle 4 byte mode does it?

Attachment: signature.asc
Description: PGP signature