Re: [PATCH v2 0/2] clk: sophgo: sg2042: Keep gates used by firmware enabled
From: Rob Herring
Date: Wed Dec 02 2026 - 09:50:40 EST
On Fri, Nov 27, 2026 at 04:01:32PM +0100, Jerome Brunet wrote:
> > On Milk-V Pioneer, firmware uses I2C0 for the EFI RTC and the serial
> > flash for its own image and EFI variables. Both sit behind clock gates
> > shared with devices Linux drives, so runtime PM on the Linux side can
> > turn them off under the firmware, and GetTime() returns EFI_NOT_READY.
> >
> > Let firmware list such gates in protected-clocks on the clkgen node,
> > and keep them enabled.
> >
> > qcom, the only current user of protected-clocks, does not register such
> > clocks at all. That would break the I2C controllers Linux uses, as the
> > DesignWare driver needs the clock rate, so here they stay registered and
> > are only kept on. I'm not sure this fits the intended use; suggestions
> > welcome.
> >
> > Tested on Milk-V Pioneer.
> >
> > Signed-off-by: Han Gao <gaohan@xxxxxxxxxxx>
> > ---
> > Changes in v2:
> > - Drop the EFI MMIO patch, Ard is taking it through the EFI tree
> > - Use protected-clocks instead of scanning reserved nodes under /soc
> > (Krzysztof)
>
> Hey Krzysztof,
>
> Using protected-clocks in the way proposed in this series would give it a different
> behavior/meaning compared to what introduced it in Qcom:
>
> - Qualcomm skips registering listed clocks. A consumer requesting a listed ID gets NULL.
> - SG2042 still registers listed gates and marks them CLK_IS_CRITICAL.
> A consumer gets a valid clock handle, can read its rate, but releasing its enable
> reference won’t turn off the hardware gate.
>
> Having different meaning for the same property is not ideal, is it ?
> Eventually that might be something we could fold into the framework, but that can only
> happen if the meaning is consistent.
>
> IMO what they are trying to do here might be more appropriate, but Qcom was there first.
> OTOH, actually registering the clock in Qcom would not be a breaking change DT wise, the driver
> would start returning a handle where it would previously have returned NULL.
>
> What is your view on this ?
>From a DT perspective, I don't think it matters too much if the OS
behavior varies in the way you describe. It would be nice if the
framework handled it rather than individual drivers though and providing
read-only clocks seems more useful than hiding the clocks.
Rob