Skip to content

Commit 8878249

Browse files
Demon000broonie
authored andcommitted
spi: rzv2h-rspi: avoid recomputing transfer frequency
Renesas RZ/T2H (R9A09G077) and RZ/N2H (R9A09G087) SoCs have a more complicated algorithm for calculating the optimal SPI transfer frequency compared to RZ/V2H, as the clock from which the SPI frequency is generated supports multiple dividers. Cache the requested transfer frequency and skip calling rzv2h_rspi_setup_clock() if it matches the last used one to prepare for adding support for variable clock frequency handling. Signed-off-by: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com> Link: https://patch.msgid.link/20251119161434.595677-6-cosmin-gabriel.tanislav.xa@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 1b7ce96 commit 8878249

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

drivers/spi/spi-rzv2h-rspi.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ struct rzv2h_rspi_priv {
8181
struct clk *tclk;
8282
wait_queue_head_t wait;
8383
unsigned int bytes_per_word;
84+
u32 last_speed_hz;
8485
u32 freq;
8586
u16 status;
8687
u8 spr;
@@ -298,9 +299,13 @@ static int rzv2h_rspi_prepare_message(struct spi_controller *ctlr,
298299

299300
rspi->bytes_per_word = roundup_pow_of_two(BITS_TO_BYTES(bits_per_word));
300301

301-
rspi->freq = rzv2h_rspi_setup_clock(rspi, speed_hz);
302-
if (!rspi->freq)
303-
return -EINVAL;
302+
if (speed_hz != rspi->last_speed_hz) {
303+
rspi->freq = rzv2h_rspi_setup_clock(rspi, speed_hz);
304+
if (!rspi->freq)
305+
return -EINVAL;
306+
307+
rspi->last_speed_hz = speed_hz;
308+
}
304309

305310
writeb(rspi->spr, rspi->base + RSPI_SPBR);
306311

0 commit comments

Comments
 (0)