]> git.ipfire.org Git - thirdparty/linux.git/commit
spi: rzv2h-rspi: add support for RZ/T2H and RZ/N2H
authorCosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>
Wed, 19 Nov 2025 16:14:32 +0000 (18:14 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 24 Nov 2025 14:10:48 +0000 (14:10 +0000)
commit0cc8cd824b9fb7fb087a2ec6b0c80d812cc4fde7
tree126e29cbf3dcb91f5161235082e4fc94ae52db2b
parente93d7b2d8b349f659fa9456048ee86e10eb422f9
spi: rzv2h-rspi: add support for RZ/T2H and RZ/N2H

Compared to the previously supported RZ/V2H, the Renesas RZ/T2H
(R9A09G077) and RZ/N2H (R9A09G087) SoCs have a smaller FIFO, no resets,
and only two clocks: PCLKSPIn and PCLK. PCLKSPIn, being the clock from
which the SPI transfer clock is generated, is the equivalent of the TCLK
clock from RZ/V2H. They also support generating the SPI transfer clock
from PCLK.

PCLKSPIn supports multiple dividers, generating multiple possible
frequencies from its parent. To handle this, do the following changes.

Use the minimum frequency of SPI clock to calculate the SPI controller's
min_speed_hz, and the maximum frequency to calculate max_speed_hz.

Add a new function, rzv2h_rspi_find_rate_variable(), which is used for
the .find_tclk_rate() callback, and which supports handling clocks with
a variable rate, with the following overall logic.

Iterate through all possible BRDV values.

For each BRDV, calculate two different SPRs, one for the clock's minimum
frequency, and one for the maxmimum, and iterate through each SPR
between them.

If the minimum SPR is higher than the upper SPR limit, the minimum rate
is too high to achieve the requested SPI frequency, skip to the next
BRDV.

For each SPR, calculate a rate and let the clock framework round it to
the closest supported rate of the clock.

The rate and SPR that generate a transfer frequency closest to the
requested SPI transfer frequency will be picked.

Signed-off-by: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>
Link: https://patch.msgid.link/20251119161434.595677-12-cosmin-gabriel.tanislav.xa@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-rzv2h-rspi.c