LKML Archive on
help / color / mirror / Atom feed
From: Stephen Boyd <>
To: Bjorn Andersson <>
Cc: Doug Anderson <>,
	Andy Gross <>,
	Evan Green <>,
	Kishon Vijay Abraham I <>,
	Rob Herring <>,,,
	linux-arm-msm <>,
	LKML <>,
	Rob Herring <>,
	David Brown <>,
	Mark Rutland <>,
	"open list:ARM/QUALCOMM SUPPORT" <>
Subject: Re: [PATCH v5 4/5] arm64: dts: qcom: sdm845: Add UFS nodes for sdm845-mtp
Date: Tue, 27 Nov 2018 18:31:19 -0800	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <20181122070412.GJ2225@minitux>

Quoting Bjorn Andersson (2018-11-21 23:04:12)
> On Mon 19 Nov 11:42 PST 2018, Stephen Boyd wrote:
> > 
> > A workaround for this somewhat rare case would be to specify
> > /delete-property/ on those nodes that aren't used. Unless that can't
> > even work because the phandle is parsed before properties are deleted? I
> > haven't tried. Or we could try to have dtc ignore broken phandles in
> > status = "disabled" nodes or omit them entirely from the dtb so this
> > isn't a problem.
> > 
> > Either way, I would push for making it easier for the users of the SoC
> > to not need to know the SoC internal details too much and rely on the
> > SoC dtsi file to get it right. From the user perspective it's just a
> > bunch of pins connected to something. We could also have a 0 volt
> > "ground" regulator for any grounded/unconnected pins if that helps. It
> > could be marked as status = "disabled" so that no runtime code is used
> > while dtc is still happy to have the disabled node with a label.
> > 
> I dislike the use of the labels "vdda_ufs1_core" as that doesn't tell me
> which regulator this is actually wired to, without having to jump around
> in the board dts file. It's annoying, but it's pretty much write-once so
> it's not a big issue.
> But I really don't like the idea of having sdm845.dtsi depend on labels
> specified in the board dtsi. This just means that in order to add a new
> board I need to figure out the information and the way to specify it is
> to change a label in the board file.
> The static configuration here is that vdda-phy-supply is connected to
> the vdda_ufs1_core pin on the SoC, which is connected to some board
> specific regulator.  If anything I think we should model that
> intermediate entity, in which case we could move the link between the
> phy and the pin to the platform dtsi.

Hmm alright. This is a similar problem that the DT connectors have with
phandle remapping through the connector to the actual phandle that is
desired. I can think of two solutions. One would be to make a
phandle-map binding to remap phandles within the soc node to actually be
another phandle. The downside is that we need to make nodes for
everything just to remap them. For example:

	soc {
		phandle-map {
			vdda_ufs1_core: vdda-ufs1-core {

In the SoC dtsi file and then

	&vdda_ufs1_core {
		phandle-alias = <&pm8998_ldo19>

Would be in the board specific dtsi file.

The regulator code to fix that up is rather simple, but not generic. It
just walks the chain of alias nodes until it doesn't find anything else.

diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 210fc20f7de7..9c1346374351 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -432,6 +432,15 @@ static int of_node_match(struct device *dev, const void *data)
 struct regulator_dev *of_find_regulator_by_node(struct device_node *np)
 	struct device *dev;
+	struct device_node *aliased_np;
+	do {
+		aliased_np = of_parse_phandle(np, "phandle-alias", 0);
+		if (aliased_np)
+			np = aliased_np;
+	} while (aliased_np);
 	dev = class_find_device(&regulator_class, NULL, np, of_node_match);
Another idea would be to have a phandle nexus node that converts
phandles into some #cells property. This way, we can make the regulator
supply binding parse the cells of the nexus node and figure out that the
next specifier after it corresponds to something that needs to be set in
the nexus node by the board.

	soc {
		soc_regulator: regulator-nexus {
			#regulator-cells = <1>;
			#define VDDA_UFS1_CORE 0

		ufs {
			vdda-supply = <&soc_regulator VDDA_UFS1_CORE>;


In the SoC dtsi file and then

	&soc_regulator {
		regulator-map = <VDDA_UFS1_CORE &pm8998_ldo19>

And then some parsing code in regulator core to remap the cells on the
left side to the phandle on the right of the cells. I suppose that makes
things sort of awkward and makes the binding look different depending on
if the node has the #regulator-cells property or not for the supply

Another idea would be to have dts phandle fixups applied somehow when
the DT is loaded by the kernel or possibly bootloader or extra
efficiently with a compiler change. So then we can alias labels to
different labels in the board file.

So in the board dtsi file we would have something like

	soc {
		phandle-map {
			vdda-ufs1-core = <&pm8998_ldo19>;

and the SoC dtsi file would have:

	soc {
		phandle-map {
			vdda_ufs1_core: vdda-ufs1-core = <0>;

except I can't get this to compile right now because syntax errors.

  reply	other threads:[~2018-11-28  2:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-26 17:35 [PATCH v5 0/5] arm64: dts: qcom: sdm845: Add UFS DT nodes Evan Green
2018-10-26 17:35 ` [PATCH v5 1/5] dt-bindings: phy-qcom-qmp: Fix register underspecification Evan Green
2018-11-04  2:40   ` Stephen Boyd
2018-11-05 16:52     ` Doug Anderson
2018-11-10  0:53       ` Stephen Boyd
2018-10-26 17:35 ` [PATCH v5 2/5] phy: qcom-qmp: Utilize fully-specified DT registers Evan Green
2018-10-26 17:35 ` [PATCH v5 3/5] arm64: dts: qcom: sdm845: add UFS controller Evan Green
2018-11-22  7:18   ` Bjorn Andersson
2018-11-28 23:43     ` Evan Green
2018-10-26 17:35 ` [PATCH v5 4/5] arm64: dts: qcom: sdm845: Add UFS nodes for sdm845-mtp Evan Green
2018-11-19 19:19   ` Stephen Boyd
2018-11-19 19:25     ` Doug Anderson
2018-11-19 19:42       ` Stephen Boyd
2018-11-22  7:04         ` Bjorn Andersson
2018-11-28  2:31           ` Stephen Boyd [this message]
2018-10-26 17:35 ` [PATCH v5 5/5] arm64: dts: qcom: sdm845: Add USB PHY lane two Evan Green
2018-11-22  7:07   ` Bjorn Andersson

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH v5 4/5] arm64: dts: qcom: sdm845: Add UFS nodes for sdm845-mtp' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).