Re: [PATCH v4 2/7] clk: qcom: Add generic clkref_en support
From: Dmitry Baryshkov
Date: Thu May 28 2026 - 11:09:12 EST
On Thu, May 28, 2026 at 09:46:51PM +0800, Jie Gan wrote:
>
>
> On 5/28/2026 9:06 PM, Qiang Yu wrote:
> > On Thu, May 28, 2026 at 11:03:45AM +0800, Jie Gan wrote:
> > >
> > >
> > > On 5/28/2026 10:29 AM, Qiang Yu wrote:
> > > > Before XO refclk is distributed to PCIe/USB/eDP PHYs, it passes through
> > > > a QREF block. QREF is powered by dedicated LDO rails, and the clkref_en
> > > > register controls whether refclk is gated through to the PHY side.
> > > >
> > > > These clkref controls are different from typical GCC branch clocks:
> > > > - only a single enable bit is present, without branch-style config bits
> > > > - regulators must be voted before enable and unvoted after disable
> > > >
> > > > Model this as a dedicated clk_ref clock type with custom clk_ops instead
> > > > of reusing struct clk_branch semantics.
> > > >
> > > > Also provide a common registration/probe API so the same clkref model
> > > > can be reused regardless of where clkref_en registers are placed, e.g.
> > > > TCSR on glymur and TLMM on SM8750.
> > > >
>
> [...]
>
> > > > +
> > > > +static int qcom_clk_ref_is_enabled(struct clk_hw *hw)
> > > > +{
> > > > + struct qcom_clk_ref *rclk = to_qcom_clk_ref(hw);
> > > > + u32 val;
> > > > + int ret;
> > > > +
> > > > + ret = regmap_read(rclk->regmap, rclk->desc.offset, &val);
> > > > + if (ret)
> > > > + return ret;
> > >
> > > regmap_read returns a negative error code on failure, but the
> > > clk_ops.is_enabled() treats the non-zero value as enabled.
> > >
> >
> > A regmap_read failure doesn't mean the clock is disabled.
>
> Do we have special reason to treat the error number as "true"? Its worthy to
> add a comment to explain why.
to be 'false', the error number must be 0.
--
With best wishes
Dmitry