public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Stephen Boyd <sboyd@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Michael Turquette <mturquette@baylibre.com>,
	Rob Herring <robh+dt@kernel.org>,
	linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	quic_tdas@quicinc.com
Subject: Re: [PATCH v2 1/2] dt-bindings: clock: Add Qualcomm SC8280XP GCC bindings
Date: Thu, 28 Apr 2022 09:01:20 -0700	[thread overview]
Message-ID: <Ymq6UOjrYgFlzl/W@ripper> (raw)
In-Reply-To: <3fb043e6-2748-24f8-0115-b5372c747a12@linaro.org>

On Thu 28 Apr 08:44 PDT 2022, Dmitry Baryshkov wrote:

> On 26/04/2022 01:34, Stephen Boyd wrote:
> > Quoting Bjorn Andersson (2022-04-22 20:43:18)
> > > On Fri 22 Apr 20:13 PDT 2022, Stephen Boyd wrote:
> > > > 
> > > > I'd really rather not have clock-names at all because we spend a bunch
> > > > of time comparing strings with them when we could just as easily use
> > > > a number.
> > > 
> > > I know that you would like to get rid of the clock-names for the clock
> > > controllers. I've looked at it since and while it will be faster to
> > > execute I still feel that it's going to be harder to write and maintain.
> > > 
> > > E.g. look at gcc_pcie_4_pipe_clk_src, its parents today are
> > > pcie_4_pipe_clk and bi_tcxo. Something I can reason about being correct
> > > or not.
> > > 
> > > If we ditch the clock-names I will have:
> > > 
> > > static const struct clk_parent_data gcc_parent_data_14[] = {
> > >          { .index = 30 },
> > >          { .index = 0 },
> > 
> > Those numbers could have some #define.
> > 
> > 	{ .index = PCIE_4_PIPE_CLK_DT }
> > 	{ .index = BI_TCXO_DT }
> > 
> > > };
> > > 
> > > Generally we would perhaps use some compile time constant, but that
> > > won't work here because we're talking about the index in the clocks
> > > array in the yaml.
> > > 
> > > 
> > > But perhaps I'm missing something that would make this manageable?
> > 
> > I dunno. Maybe a macro in the dt-binding header could be used to specify
> > the 'clocks' property of the DT node that is providing the other side?
> > The idea is to make a bunch of macros that insert the arguments of the
> > macro in the right place for the clocks property and then define the
> > order of arguments otherwise. It would be similar to how
> > CREATE_TRACE_POINTS is used in include/trace/define_trace.h
> > 
> > In the dt-bindings/qcom,gcc-soc.h file:
> > 
> > 	#ifdef IN_DTSI
> > 
> > 	#undef GCC_DT_NODE_CLOCKS
> > 	#define GCC_DT_NODE_CLOCKS
> > 		clocks = <BI_TCXO_DT>,
> > 			 <SLEEP_CLK_DT>;
> > 
> > 	#endif /* IN_DTSI */
> > 
> > 	#define BI_TCXO_DT 0
> > 	#define SLEEP_CLK_DT 1

BI_TCXO_DT is not the value, its the index of the entry in the clocks
array. And the actual values of the clock controller's clocks
property is not a property of the clock controller, but the system
definition.

I.e. that should be clear and explicitly expressed in the dts.

> 
> Isn't this being an overkill, to define exact properties in the bindings
> header? Also this would mean that we'd have to add dt-binding headers for
> all _consumers_ of clocks. And to make things more complex, e.g. for PCIe
> devices different instances of the device would use different amount of
> clocks. This would mean that we'd have to define SM8250_PCI0_CLOCKS,
> SM8250_PCIE1_CLOCKS and SM8250_PCIE2_CLOCKS.
> 
> 
> If we were to switch to this fragile path of using indices (yes I consider
> it to be very fragile), I'd consider something like the following to work in
> the platform dtsi file:
> 
> clocks =
> BEGIN_CLOCK
> CLOCK(BI_TCXO_DT, &bi_tcxo)
> CLOCK(SLEEP_CLK_DT, &sleep_clk)
> END_CLOCK;
> 
> While the following should give an error:
> clocks =
> BEGIN_CLOCK
> CLOCK(SLEEP_CLK_DT, &sleep_clk)
> CLOCK(BI_TCXO_DT, &bi_tcxo)
> END_CLOCK;
> 
> I think we can make this error out by using some additional tool (or
> additional preprocessor pass over the sources)
> 

Let's not invent some magical syntax for describing the clocks in the
DT.

These macros can't expand to sparse arrays anyways, so iiuc this would
give a sense that the ordering might not be significant, when it really
is.

> > And then in the SoC.dtsi file have
> > 
> > 	#define IN_DTSI
> > 	#include <dt-bindings/qcom,gcc-soc.h>
> > 
> > 	#define BI_TCXO_DT	&xo_board
> > 	#define SLEEP_CLK_DT	&sleep_clk
> > 
> > 	...
> > 
> > 	clock-controller@a000000 {
> > 		compatible = "qcom,gcc-soc";
> > 		reg = <0xa000000 0x10000>;
> > 		GCC_DT_NODE_CLOCKS
> > 	};
> > 
> > 
> > and then in drivers/clk/qcom/gcc-soc.c file:
> > 
> > 	#include <dt-bindings/qcom,gcc-soc.h>
> > 
> > 	static const struct clk_parent_data gcc_parent_data_14[] = {
> > 		{ .index = PCIE_4_PIPE_CLK_DT },
> > 		{ .index = BI_TCXO_DT },
> > 	};
> > 
> > The benefit I see to this is that the index for each clock is in the
> > header file (BI_TCXO_DT is 0) and it's next to the clocks property.
> > Someone could still mess up the index based on where the macro is used
> > in the clocks property though.
> 
> And actually might I suggest an alternative approach to manually using
> indices everywhere? What about spending the time once during the boot to
> convert .fw_name and clock_names to parent indices during clock registration
> and then using them for all the further operations?
> 

I'm pretty sure that's what clk_core_fill_parent_index() already does.

Regards,
Bjorn

  reply	other threads:[~2022-04-28 15:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-22 23:00 [PATCH v2 1/2] dt-bindings: clock: Add Qualcomm SC8280XP GCC bindings Bjorn Andersson
2022-04-22 23:00 ` [PATCH v2 2/2] clk: qcom: add sc8280xp GCC driver Bjorn Andersson
2022-04-23  1:53   ` Stephen Boyd
2022-04-23  1:48 ` [PATCH v2 1/2] dt-bindings: clock: Add Qualcomm SC8280XP GCC bindings Stephen Boyd
2022-04-23  3:02   ` Bjorn Andersson
2022-04-23  3:13     ` Stephen Boyd
2022-04-23  3:43       ` Bjorn Andersson
2022-04-25 22:34         ` Stephen Boyd
2022-04-28 15:44           ` Dmitry Baryshkov
2022-04-28 16:01             ` Bjorn Andersson [this message]
2022-04-28 16:24               ` Dmitry Baryshkov
2022-04-28 19:12                 ` Bjorn Andersson
2022-05-03 19:19                   ` Stephen Boyd

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=Ymq6UOjrYgFlzl/W@ripper \
    --to=bjorn.andersson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=quic_tdas@quicinc.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@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