Linux clock framework development
 help / color / mirror / Atom feed
From: Conor Dooley <conor@kernel.org>
To: Vyacheslav Yurkov <uvv.mail@gmail.com>
Cc: Rob Herring <robh@kernel.org>,
	Vyacheslav Yurkov <V.Yurkov.EXT@bruker.com>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Brian Masney <bmasney@redhat.com>,
	linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v4 1/2] dt-bindings: Add GPIO-locked fixed clock
Date: Fri, 28 Aug 2026 18:12:13 +0100	[thread overview]
Message-ID: <20260828-sneeze-audacity-02b95504a3b1@spud> (raw)
In-Reply-To: <cfac0540-4f08-45b6-8d01-71080e0fcb47@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4558 bytes --]

On Fri, Aug 28, 2026 at 07:31:10AM +0200, Vyacheslav Yurkov wrote:
> On 27.08.2026 18:55, Conor Dooley wrote:
> 
> > > It is n input clocks and 1 output clock. It is kind of a mux, but the CPU
> > > doesn't control the clocks or GPIO signals. The whole idea is that
> > > peripherals check the output clock, when it's locked that means _all_ the
> > > clocks are locked and GPIOs are in expected state. That's why the selection
> > > operation is not really implemented.
> > > 
> > > Actually the number of input clocks don't have to correspond to the number
> > > of the GPIOs, because the GPIO signals indicate the locked state of the
> > > clocks that are not accessible to the CPU.
> > 
> > I'm not entirely sure what you mean by this, but it is starting to sound
> > like you're only having one output because that's the minimum you need to do
> > to ensure that this driver has probed before the peripheral(s) using the
> > N input clocks.
> 
> That's exactly the idea. How else I would ensure in peripheral's probe
> driver that clocks are locked?

Every peripheral should already contain a reference to all of the clocks
that are connected to it, and the peripheral drivers should request
those clocks. If you do that for all clocks a peripheral uses, you don't
need to have an artificial check for the gpios representing clocks
b,c,d,e,f,g... in the enable function for clock a, because their own
{devm,}clk_get_enabled() will interrogate the relevant bit.

At present, I'm expecting that you have a dt like

clk_gpio_locked: gpio-locked-fixed-clock {
    compatible = "gpio-locked-fixed-clock";
    #clock-cells = <0>;

    clocks = <&clk0 0>, <&pll 0>;

    locked-gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>,
            <&gpio0 5 GPIO_ACTIVE_HIGH>,
            <&gpio1 2 GPIO_ACTIVE_LOW>;

    clock-output-names = "clkout0";
};

peripheral {
	clocks = <&clk_gpio_locked>, <&clk0 0>, <&pll 0>;
	//or this, depending on whether clkout0 actually produces a
	//rate, which I guess it does given it's a passthrough for the
	//first clocks entry?
	clocks = <&clk_gpio_locked>, <&pll 0>;
};

when really you should have something like

clk_gpio_locked: gpio-locked-fixed-clock {
    compatible = "gpio-locked-fixed-clock";
    #clock-cells = <1>;

    clocks = <&clk0 0>, <&pll 0>, <more clocks here>;

    locked-gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>,
            <&gpio0 5 GPIO_ACTIVE_HIGH>,
            <&gpio1 2 GPIO_ACTIVE_LOW>;

    clock-output-names = "clkout0", "clkout1", "more clocks here";
};

peripheral {
	clocks = <&clk_gpio_locked 0>, <&clk_gpio_locked 1>;
};

> > Requiring other input clocks to be stable before
> > declaring the input that's actually connected to the output stable
> > appears to be a shortcut/hack rather than an accurate description of the
> > hardware. If that's the case, I'd be much happier with this if this was
> > implemented as either a) N inputs with N gpios and N outputs, or b) 1 input,
> > M gpios (if multiple represent the stability of that input) and 1 output,
> > with N instances, one for each clock.
> 
> How having N outputs would help? It looks like it would just move the job I
> do here into each peripheral driver instead.

Two reasons. Firstly because what you've got here suits you just fine,
but since you're adding it to a generic binding it should be written in
the most generic manner possible. Some other similar use case might not
want to wait for clocks used by other peripherals to lock before
allowing the driver for what they do care about to probe.
Secondly because it's a bit of a hack currently, you've got one clock
representing the status for a bunch of other clocks. Each clock should
represent it's own status. If this was done in the hardware it'd be one
thing, but you've got a pure software construct blocking one clock from
being locked because other clocks that may be unrelated to it entirely
are not yet locked.
The argument for including this depends on it not being a pure software
construct, and having what appears to be a hack so that you can rely on
the status of one clock rather than correctly determining the locked
state of individual clocks undermines your own argument for inclusion.

Cheers,
Conor.

> > On the other hand, if this is genuinely a mux, then the binding should
> > reflect that, rather than only describe a subset of what you can do and
> > the driver should only check the actual parent out the output, rather
> > than the N-1 other inputs.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2026-08-28 17:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-26 17:40 [PATCH v4 0/2] A proposal to add a gpio-locked fixed clock driver Vyacheslav Yurkov via B4 Relay
2026-07-26 17:40 ` [PATCH v4 1/2] dt-bindings: Add GPIO-locked fixed clock Vyacheslav Yurkov via B4 Relay
2026-08-10 16:40   ` Rob Herring
2026-08-10 16:54     ` Rob Herring
2026-08-10 16:58       ` Conor Dooley
2026-08-27  8:23         ` Vyacheslav Yurkov
2026-08-27 16:55           ` Conor Dooley
2026-08-28  5:31             ` Vyacheslav Yurkov
2026-08-28 17:12               ` Conor Dooley [this message]
2026-07-26 17:40 ` [PATCH v4 2/2] clk: Add gpio-locked fixed clock driver Vyacheslav Yurkov via B4 Relay

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=20260828-sneeze-audacity-02b95504a3b1@spud \
    --to=conor@kernel.org \
    --cc=V.Yurkov.EXT@bruker.com \
    --cc=bmasney@redhat.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=uvv.mail@gmail.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