devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@kernel.org>
To: "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	Mike Looijmans <mike.looijmans@topic.nl>
Cc: "mturquette@baylibre.com" <mturquette@baylibre.com>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"mark.rutland@arm.com" <mark.rutland@arm.com>,
	"linux-clk@vger.kernel.org" <linux-clk@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] dt-bindings: Add silabs,si5341
Date: Wed, 26 Jun 2019 14:24:08 -0700	[thread overview]
Message-ID: <20190626212409.9C0E6208E3@mail.kernel.org> (raw)
In-Reply-To: <c7f5184f-f484-e8ad-33ae-36b0da061113@topic.nl>

Sorry, I'm getting through my inbox pile and saw this one.

Quoting Mike Looijmans (2019-04-30 22:46:55)
> On 30-04-19 02:17, Stephen Boyd wrote:
> > 
> > Why can't that driver call clk_prepare_enable()? Is there some sort of
> > assumption that this clk will always be enabled and not have a driver
> > that configures the rate and gates/ungates it?
> 
> Not only clk_prepare_enable(), but the driver could also call clk_set_rate() 
> and clk_set_parent() and the likes, but it doesn't, so that's why there is 
> "assigned-clocks" right?
> 
> There are multiple scenario's, similar to why regulators also have properties 
> like these.
> 
> - The clock is related to hardware that the kernel is not aware of.
> - The clock is for a driver that isn't aware of its clock requirements. It 
> might be an extra clock for an FPGA implemented controller that mimics 
> existing hardware.

Are these hypothetical scenarios or actual scenarios you need to
support?

> 
> I'd also consider patching "assigned-clocks" to call "clk_prepare_enable()", 
> would that make sense, or is it intentional that assigned-clocks doesn't do that?
> 

It's intentional that assigned-clocks doesn't really do anything besides
setup the list of clks to operate on with the rate or parent settings
specified in other properties. We would need to add another property
indicating which clks we want to mark as 'critical' or 'always-on'.

There have been prior discussions where we had developers want to mark
clks with the CLK_IS_CRITICAL flag from DT, but we felt like that was
putting SoC level details into the DT. While that was correct for SoC
specific clk drivers, I can see board designs where it's configurable
and we want to express that a board has some clks that must be enabled
early on and left enabled forever because the hardware engineer has
design the board that way. In this case, marking the clk with the
CLK_IS_CRITICAL flag needs to be done from DT.

In fact, we pretty much already have support for this with
of_clk_detect_critical(). Maybe we should re-use that binding with
'clock-critical' to let clk providers indicate that they have some clks
that should be marked critical once they're registered. We could
probably add another property too that indicates certain clks are
enabled out of the bootloader, similar to the regulator-boot-on
property, but where it takes a clock-cells wide list for the provider
the property is inside of.

We need to be careful though and make sure that clk drivers don't start
putting everything in DT. In your example, it sounds like you have a
consumer driver that wants to make sure the clk is prepared or enabled
when the consumer probes. In this case the prepare/enable calls should
be put directly into the consumer driver so it can manage the clk state.
For the case of rates and parents, it's essentially a oneshot
configuration of the rate or the parents of a clk. We don't need to
"undo" the configuration when the device driver is removed. For prepare
and enable though, we typically want to disable clks when the hardware
is not in use to save power. Adding a property to DT should only be done
to indicate a clk must always be on in this board configuration, not to
avoid calling clk_prepare_enable() in the driver probe.

To put it another way, I'm looking to describe how the board is designed
and to indicate that certain clks are always enabled at power on or are
enabled by the bootloader. Configuration has it's place too, just that
configuration is a oneshot sort of thing that never needs to change at
runtime.

  reply	other threads:[~2019-06-26 21:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-24  9:02 [PATCH] dt-bindings: Add silabs,si5341 Mike Looijmans
2019-04-25 23:04 ` Stephen Boyd
2019-04-26  6:51   ` Mike Looijmans
2019-04-27  0:44     ` Stephen Boyd
2019-04-27  9:42       ` Mike Looijmans
2019-04-30  0:17         ` Stephen Boyd
2019-05-01  5:46           ` Mike Looijmans
2019-06-26 21:24             ` Stephen Boyd [this message]
2019-06-27 11:38               ` Mike Looijmans
2019-06-27 20:54                 ` Stephen Boyd
2019-05-07 14:04         ` [PATCH v2] dt-bindings: clock: " Mike Looijmans
2019-05-13 20:31           ` Rob Herring
2019-05-17 13:20             ` [PATCH v3] " Mike Looijmans
2019-06-13 22:41               ` Rob Herring
2019-06-27 20:57               ` Stephen Boyd
2019-05-02  0:17 ` [PATCH] dt-bindings: " Rob Herring

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=20190626212409.9C0E6208E3@mail.kernel.org \
    --to=sboyd@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mike.looijmans@topic.nl \
    --cc=mturquette@baylibre.com \
    --cc=robh+dt@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).