[PATCH v5 05/15] clk: renesas: r8a78000: Add SCMI remapping support
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Mon Nov 23 04:54:10 PST 2026
On Mon, Nov 23, 2026 at 01:34:06PM +0100, Geert Uytterhoeven wrote:
> On Mon, Nov 23, 2026, at 12:36, Laurent Pinchart wrote:
> > On Wed, Nov 18, 2026 at 08:44:53PM +0100, Geert Uytterhoeven wrote:
> >> Extend the Clock Pulse Generator driver for R-Car X5H with SCMI support,
> >> to remap DT clock IDs to abstractions (clocks) offered by the SCMI
> >> firmware when running on a system with SCMI, and SCMI support is
> >> enabled. Take into account some peculiarities of the current SCMI
> >> firmware implementations, and fall-back to fixed-rate clocks as
> >> replacements for SCMI clocks that are not available.
> >> Support for bus clocks used by serial, I2C, and SPI devices is included.
> >>
> >> This lets us avoid putting SCMI IDs in DT, and allows us to use the same
> >> hardware description in SoC DTS for systems with and without SCMI
> >> firmware.
> >>
> >> For now, it is assumed SCMI clock IDs are stable, and match SCP FW
> >> SDKv4.31.0 and later.
> >>
> >> Suggested-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
> >> Signed-off-by: Geert Uytterhoeven <geert+renesas at glider.be>
> >> Tested-by: Wolfram Sang <wsa+renesas at sang-engineering.com>
>
> >> --- a/drivers/clk/renesas/r8a78000-cpg.c
> >> +++ b/drivers/clk/renesas/r8a78000-cpg.c
>
> >> @@ -140,7 +182,35 @@ static struct clk_hw **get_hws(struct r8a78000_cpg_priv *priv)
> >>
> >> for (unsigned int i = 0; i < map->size; i++) {
> >> fw_id = map->entries[i].fw_id;
> >> - hws[i] = fixed_hws[fw_id];
> >> + if (fw_id >= FIXED_CLK_OFFSET) {
> >> + hws[i] = fixed_hws[fw_id - FIXED_CLK_OFFSET];
> >> + continue;
> >> + }
> >> +
> >> + scmi_spec.np = scmi_clk_np;
> >> + scmi_spec.args_count = 1;
> >> + scmi_spec.args[0] = fw_id;
> >> +
> >> + clk = of_clk_get_from_provider(&scmi_spec);
> >> + if (IS_ERR(clk))
> >> + return dev_err_cast_probe(dev, clk,
> >> + "Failed to get SCMI clock %u\n", fw_id);
> >> +
> >> + hw = __clk_get_hw(clk);
> >> + clk_put(clk);
> >
> > Doesn't that leave the hw pointer possibly dangling, shouldn't you keep
> > the reference to the clock ?
>
> Only struct clk is reference-counted; struct clk_hw is not, and exists as
> long as the clock provider hasn't unregistered it.
That's what I meant, what prevents clk_hw from being destroyed while you
still hold a pointer ?
--
Regards,
Laurent Pinchart
More information about the linux-arm-kernel
mailing list