From: Pavel Machek <pavel@nabladev.com>
To: tommaso.merciai.xr@bp.renesas.com
Cc: cip-dev@lists.cip-project.org,
Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>,
Pavel Machek <pavel@nabladev.com>,
Biju Das <biju.das.jz@bp.renesas.com>,
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>,
tomm.merciai@gmail.com
Subject: Re: [cip-dev] [PATCH 6.1.y-cip 17/32] spi: rzv2h-rspi: add support for RZ/T2H and RZ/N2H
Date: Sat, 27 Jun 2026 13:11:34 +0200 [thread overview]
Message-ID: <aj-v5pqrtAsWVkmP@duo.ucw.cz> (raw)
In-Reply-To: <20260617083003.1071543-18-tommaso.merciai.xr@bp.renesas.com>
[-- Attachment #1: Type: text/plain, Size: 3059 bytes --]
HI!
> 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>
> Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> ---
> drivers/spi/spi-rzv2h-rspi.c | 108 +++++++++++++++++++++++++++++++++++
> 1 file changed, 108 insertions(+)
>
> diff --git a/drivers/spi/spi-rzv2h-rspi.c b/drivers/spi/spi-rzv2h-rspi.c
> index 3c1cb76bc7b4..2f4feaedaf97 100644
> --- a/drivers/spi/spi-rzv2h-rspi.c
> +++ b/drivers/spi/spi-rzv2h-rspi.c
> @@ -258,6 +258,105 @@ static inline u32 rzv2h_rspi_calc_bitrate(unsigned long tclk_rate, u8 spr,
> return DIV_ROUND_UP(tclk_rate, (2 * (spr + 1) * (1 << brdv)));
> }
>
> +static void rzv2h_rspi_find_rate_variable(struct clk *clk, u32 hz,
> + u8 spr_min, u8 spr_max,
> + struct rzv2h_rspi_best_clock *best)
> +{
> + long clk_rate, clk_min_rate, clk_max_rate;
> + int min_rate_spr, max_rate_spr;
> + unsigned long error;
> + u32 actual_hz;
> + u8 brdv;
> + int spr;
> +
> + /*
> + * On T2H / N2H, the source for the SPI clock is PCLKSPIn, which is a
> + * 1/32, 1/30, 1/25 or 1/24 divider of PLL4, which is 2400MHz,
> + * resulting in either 75MHz, 80MHz, 96MHz or 100MHz.
> + */
> + clk_min_rate = clk_round_rate(clk, 0);
> + if (clk_min_rate < 0)
> + return;
These are clearly failures, yet we are returning void. That is not
usual coding style.
Best regards,
Pavel
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2026-06-27 11:11 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-17 8:29 [PATCH 6.1.y-cip 00/32] Add RSPI support for RZ/G3E SoC Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 01/32] dmaengine: Add devm_dma_request_chan() Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 02/32] spi: Introduce internal spi_xfer_is_dma_mapped() helper Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 03/32] clk: renesas: r9a09g047: Add entries for the RSPIs Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 04/32] spi: dt-bindings: renesas,rzv2h-rspi: document optional support for DMA Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 05/32] spi: dt-bindings: renesas,rzv2h-rspi: allow multiple DMAs Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 06/32] spi: dt-bindings: renesas,rzv2h-rspi: Document dmas property Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 07/32] spi: dt-bindings: renesas,rzv2h-rspi: Document RZ/G3E SoC support Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 08/32] spi: rzv2h-rspi: make resets optional Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 09/32] spi: rzv2h-rspi: make FIFO size chip-specific Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 10/32] spi: rzv2h-rspi: make clocks chip-specific Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 11/32] spi: rzv2h-rspi: move register writes out of rzv2h_rspi_setup_clock() Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 12/32] spi: rzv2h-rspi: avoid recomputing transfer frequency Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 13/32] spi: rzv2h-rspi: make transfer clock rate finding chip-specific Tommaso Merciai
2026-06-27 11:09 ` Pavel Machek
2026-06-17 8:29 ` [PATCH 6.1.y-cip 14/32] spi: rzv2h-rspi: add support for using PCLK for transfer clock Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 15/32] spi: rzv2h-rspi: add support for variable " Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 16/32] spi: rzv2h-rspi: add support for loopback mode Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 17/32] spi: rzv2h-rspi: add support for RZ/T2H and RZ/N2H Tommaso Merciai
2026-06-27 11:11 ` Pavel Machek [this message]
2026-06-17 8:29 ` [PATCH 6.1.y-cip 18/32] spi: rzv2h-rspi: fix rzv2h_rspi_transfer_one() indentation Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 19/32] spi: rzv2h-rspi: remove call to spi_finalize_current_transfer() Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 20/32] spi: rzv2h-rspi: use device-managed APIs Tommaso Merciai
2026-06-27 11:27 ` Pavel Machek
2026-06-17 8:29 ` [PATCH 6.1.y-cip 21/32] spi: rzv2h-rspi: store RX interrupt in state Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 22/32] spi: rzv2h-rspi: set MUST_RX/MUST_TX Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 23/32] spi: rzv2h-rspi: set TX FIFO threshold to 0 Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 24/32] spi: rzv2h-rspi: enable TX buffer empty interrupt Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 25/32] spi: rzv2h-rspi: split out PIO transfer Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 26/32] spi: rzv2h-rspi: add support for DMA mode Tommaso Merciai
2026-06-27 11:20 ` Pavel Machek
2026-06-17 8:29 ` [PATCH 6.1.y-cip 27/32] spi: rzv2h-rspi: Fix max_speed_hz advertising prohibited bit rate Tommaso Merciai
2026-06-17 8:29 ` [PATCH 6.1.y-cip 28/32] spi: rzv2h-rspi: Fix invalid SPR=0/BRDV=0 clock configuration Tommaso Merciai
2026-06-17 8:30 ` [PATCH 6.1.y-cip 29/32] spi: rzv2h-rspi: Simplify clock rate search function signatures Tommaso Merciai
2026-06-17 8:30 ` [PATCH 6.1.y-cip 30/32] spi: rzv2h-rspi: Fix silent failure in clock setup error path Tommaso Merciai
2026-06-17 8:30 ` [PATCH 6.1.y-cip 31/32] arm64: dts: renesas: r9a09g047: Add RSPI nodes Tommaso Merciai
2026-06-17 8:30 ` [PATCH 6.1.y-cip 32/32] arm64: dts: renesas: r9a09g047e57-smarc: Enable RSPI0 Tommaso Merciai
2026-06-22 9:15 ` [PATCH 6.1.y-cip 00/32] Add RSPI support for RZ/G3E SoC Pavel Machek
2026-06-27 21:35 ` Pavel Machek
2026-07-09 9:23 ` Tommaso Merciai
2026-07-14 7:44 ` Tommaso Merciai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aj-v5pqrtAsWVkmP@duo.ucw.cz \
--to=pavel@nabladev.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=cip-dev@lists.cip-project.org \
--cc=nobuhiro1.iwamatsu@toshiba.co.jp \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=tomm.merciai@gmail.com \
--cc=tommaso.merciai.xr@bp.renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox