]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
spi: rzv2h-rspi: Fix max_speed_hz advertising prohibited bit rate
authorLad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Fri, 10 Apr 2026 08:05:15 +0000 (09:05 +0100)
committerMark Brown <broonie@kernel.org>
Fri, 10 Apr 2026 12:19:58 +0000 (13:19 +0100)
On RZ/V2H(P), RZ/G3E and RZ/G3L, RSPI_n_TCLK is fixed at 200MHz.
The max_speed_hz was computed using clk_round_rate(tclk, ULONG_MAX)
with SPR=0 and BRDV=0, resulting in 100Mbps - the exact combination
prohibited on these SoCs. This could cause the SPI framework to request
a speed that rzv2h_rspi_find_rate_fixed() would skip, potentially
leading to a clock selection failure.

On RZ/T2H and RZ/N2H the max_speed_hz was correctly calculated as
50Mbps for both the variable PCLKSPIn and fixed PCLK clock sources.

Since the maximum supported bit rate is 50Mbps across all supported SoC
variants, replace the clk_round_rate() based calculation with a define
RSPI_MAX_SPEED_HZ set to 50MHz and use it directly for max_speed_hz.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://patch.msgid.link/20260410080517.2405700-2-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-rzv2h-rspi.c

index 23f0e92ae208e286deb6e7bbbb516c9e7fb47c62..15270f19c69c17dcfbedd71006a0b430d658968f 100644 (file)
@@ -77,6 +77,8 @@
 
 #define RSPI_RESET_NUM         2
 
+#define RSPI_MAX_SPEED_HZ      50000000
+
 struct rzv2h_rspi_best_clock {
        struct clk *clk;
        unsigned long clk_rate;
@@ -771,13 +773,7 @@ static int rzv2h_rspi_probe(struct platform_device *pdev)
                                                           RSPI_SPBR_SPR_MAX,
                                                           RSPI_SPCMD_BRDV_MAX);
 
-       tclk_rate = clk_round_rate(rspi->tclk, ULONG_MAX);
-       if (tclk_rate < 0)
-               return tclk_rate;
-
-       controller->max_speed_hz = rzv2h_rspi_calc_bitrate(tclk_rate,
-                                                          RSPI_SPBR_SPR_MIN,
-                                                          RSPI_SPCMD_BRDV_MIN);
+       controller->max_speed_hz = RSPI_MAX_SPEED_HZ;
 
        controller->dma_tx = devm_dma_request_chan(dev, "tx");
        if (IS_ERR(controller->dma_tx)) {