[PATCH v2 6/6] spi: rockchip: Add an atomic transfer function
Sebastian Reichel
sebastian.reichel at collabora.com
Fri Nov 13 11:04:27 PST 2026
Hi,
On Fri, Nov 13, 2026 at 02:50:17PM +0100, Heiko Stuebner wrote:
> From: Heiko Stuebner <heiko.stuebner at cherry.de>
>
> Rockchip SPI controllers are often used to handle SPI connected PMICs that
> also handle system power-off events, like the RK806.
>
> When the kernel signals the power-off, all the interrupts are already
> disabled, so regular SPI with its mutexes and DMA transfers does not
> work anymore.
>
> Implement an atomic transfer function that does SPI transfers polling the
> controller in a loop without any DMA or IRQ.
>
> This can successfully handle the power-off command to RK806, but also
> read back the 2 chip-id registers just fine before that, as a test.
>
> Signed-off-by: Heiko Stuebner <heiko.stuebner at cherry.de>
> ---
> [...]
> +static int rockchip_spi_transfer_atomic(struct spi_device *spi, struct spi_message *msg)
> +{
> + struct spi_controller *ctlr = spi->controller;
> + struct rockchip_spi *rs = spi_controller_get_devdata(ctlr);
> + struct spi_transfer *xfer;
> + int ret = 0;
> +
> + spi_set_cs(spi, true, false);
I think it's sensible to avoid SErrors in case something went wrong
with the preparation:
if (!pm_runtime_active(rs->dev)) {
dev_err(rs->dev, "Failed to do atomic SPI transfer due to runtime suspend\n");
ret = -EIO;
goto out;
}
> +
> + /* make sure all interrupts are masked and status cleared */
> + writel_relaxed(0, rs->regs + ROCKCHIP_SPI_IMR);
> + writel_relaxed(0xffffffff, rs->regs + ROCKCHIP_SPI_ICR);
>
> [...]
Greetings,
-- Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-rockchip/attachments/20261113/8c9d01e5/attachment-0001.sig>
More information about the Linux-rockchip
mailing list