All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Kyle Bonnici <kylebonnici@hotmail.com>
Cc: Herve Codina <herve.codina@bootlin.com>,
	"devicetree-compiler@vger.kernel.org"
	<devicetree-compiler@vger.kernel.org>
Subject: Re: Phandles
Date: Mon, 13 Apr 2026 12:12:50 +1000	[thread overview]
Message-ID: <adxRIlenv2OTFXJC@zatzit> (raw)
In-Reply-To: <D22046DB-95B3-431E-8E80-0BA806811D01@hotmail.com>

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

On Sun, Apr 12, 2026 at 01:51:35PM +0000, Kyle Bonnici wrote:
> 
> 
> > On 12 Apr 2026, at 14:51, Herve Codina <herve.codina@bootlin.com> wrote:
> > 
> > Hi Kyle,
> > 
> > On Sat, 11 Apr 2026 18:33:33 +0000
> > Kyle Bonnici <kylebonnici@hotmail.com> wrote:
> > 
> >> Hi
> >> 
> >> I have been looking at the the code for the compiler and I am wondering which specifications marks the below properties MUST BE Nexus Properties hence the validation.
> >> 
> >> WARNING_PROPERTY_PHANDLE_CELLS(clocks, "clocks", "#clock-cells");
> >> WARNING_PROPERTY_PHANDLE_CELLS(cooling_device, "cooling-device", "#cooling-cells");
> >> WARNING_PROPERTY_PHANDLE_CELLS(dmas, "dmas", "#dma-cells");
> >> WARNING_PROPERTY_PHANDLE_CELLS(hwlocks, "hwlocks", "#hwlock-cells");
> >> WARNING_PROPERTY_PHANDLE_CELLS(interrupts_extended, "interrupts-extended", "#interrupt-cells");
> >> WARNING_PROPERTY_PHANDLE_CELLS(io_channels, "io-channels", "#io-channel-cells");
> >> WARNING_PROPERTY_PHANDLE_CELLS(iommus, "iommus", "#iommu-cells");
> >> WARNING_PROPERTY_PHANDLE_CELLS(mboxes, "mboxes", "#mbox-cells");
> >> WARNING_PROPERTY_PHANDLE_CELLS(msi_parent, "msi-parent", "#msi-cells", true);
> >> WARNING_PROPERTY_PHANDLE_CELLS(mux_controls, "mux-controls", "#mux-control-cells");
> >> WARNING_PROPERTY_PHANDLE_CELLS(phys, "phys", "#phy-cells");
> >> WARNING_PROPERTY_PHANDLE_CELLS(power_domains, "power-domains", "#power-domain-cells");
> >> WARNING_PROPERTY_PHANDLE_CELLS(pwms, "pwms", "#pwm-cells");
> >> WARNING_PROPERTY_PHANDLE_CELLS(resets, "resets", "#reset-cells");
> >> WARNING_PROPERTY_PHANDLE_CELLS(sound_dai, "sound-dai", "#sound-dai-cells");
> >> WARNING_PROPERTY_PHANDLE_CELLS(thermal_sensors, "thermal-sensors", "#thermal-sensor-cells");
> > 
> > All of those properties are defined as phandles.
> > 
> > For instance, the 'pwms' property available in a node means the the node is
> > a pwm consumer. It must follow the pwm consumer binding [1] and so a phandle
> > is involved.
> > 
> > This phandle can have arguments and the number of argument is defined by the
> > #pwm-cells property set in the pwm provider node [2], [3].
> > 
> > [1] https://elixir.bootlin.com/zephyr/v4.4.0-rc3/source/dts/bindings/pwm/pwm-controller.yaml
> > [2] https://github.com/zephyrproject-rtos/zephyr/blob/main/dts/bindings/pwm/pwm-controller.yaml
> > [3] https://elixir.bootlin.com/linux/v7.0-rc7/source/Documentation/devicetree/bindings/pwm/pwm.yaml
> > 
> >> 
> >> 
> >> These can be found here: https://github.com/dgibson/dtc/blob/main/checks.c#L1498 this is relevant for https://github.com/zephyrproject-rtos/zephyr/issues/107066
> > 
> > Examples provided in the zephyrproject issue link are, in my opinion, incorrect.
> > 
> >  Case 1:
> >  / {
> >      node1 {
> >           pwms = <1 &pwm0 1 20 PWM_POLARITY_NORMAL>;
> > 
> >           Here the first cell '1' is not a phandle.
> 
> Here the compiler is making an assumption here that all `pwms`
> properties must be specifier properties and all use `pwm` specifier.
> 
> This is not the case in zephyr. Any property that is a specifier
> property must implement a binding and follow these rules
> https://docs.zephyrproject.org/latest/build/dts/bindings-syntax.html#specifier-space
> and validation is the responsibility go Zephyr's build system.

I'm not quite sure what you're saying here.  Are you saying that
Zephyr is using the same property name as an existing binding, but in
a different way from that binding?

That's a terrible idea, whether or not it's technically against any
spec,

Also, Zephyr shouldn't be making choices about how the device tree is
encoded.  The device tree describes *hardware* (real or virtual) not
how the hardware is used by a particular OS.

> The same applies for all the other examples I have here
> https://github.com/zephyrproject-rtos/zephyr/issues/107066
> 
> Given that these nodes do not implement any binding then no type should be inferred.
> 
> In addition AFAIK the devicetree specification does not say anything
> about these specific property names (unlike `interrupts` and
> `interrupts-extended)`
> 
> Hence it is my option that the compiler should be agnostic of the
> binding system used and not make any assumptions about bindings
> used.
> 
> > 
> >      };
> > 
> >      node2 {
> >          pwms = <&pwm0 1 20>;
> > 
> >          Here 2 arguments. The node referenced by &pwm0 must indicated the
> >          number of argument to provide. I.e it must have a #pwm-cells$
> >          property set.
> > 
> >          According to your example, this property must be #pwm-cells= <2>;
> > 
> > 
> >      };
> > 
> >      node3 {
> >          pwms = <1 &pwm0 1 20 PWM_POLARITY_NORMAL>;
> > 
> >          Here also, '1', the first cell, is not a phandle.
> >      };
> >  };
> > 
> >  Case 2:
> > 
> >  / {
> >      foobar {
> >          pwms = <1 2 3 4 5>;
> > 
> >          Random values. Error detected by DTC.
> > 
> >      };
> >  };
> > 
> >  Case 3:
> > 
> >  / {
> >      zephyr,user {
> >          pwms = <1  20 1>;
> 
> This is yet another example see where zephyr want to allow any inference based on the value and not the property name.
> see https://github.com/zephyrproject-rtos/zephyr/pull/107127 (https://docs.zephyrproject.org/latest/build/dts/zephyr-user-node.html) 
> 
> i.e .          
> pwms = ‘foobar”; // should be a string
> pwms = <10>; // should be a number or U32
> And so on.
> 
> 
> > 
> >          Here also the phandle is missing.
> >      };
> >  };
> > 
> > 
> > If you want to use Nexus node on top of that, you can have a look at the
> > following example:
> >  https://elixir.bootlin.com/linux/v7.0-rc7/source/Documentation/devicetree/bindings/pwm/pwm-nexus-node.yaml
> > 
> > In the example, you will find the consumer, the nexus node and the pwm
> > providers.
> > 
> > Not sure to have fully understood your issue but I hope my comments help.
> > 
> > Best regards,
> > Hervé
> 
> 

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

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

  parent reply	other threads:[~2026-04-13  2:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-11 18:33 Phandles Kyle Bonnici
2026-04-12 12:51 ` Phandles Herve Codina
2026-04-12 13:51   ` Phandles Kyle Bonnici
2026-04-12 15:40     ` Phandles Herve Codina
2026-04-12 16:37       ` Phandles Kyle Bonnici
2026-04-13  6:37         ` Phandles Krzysztof Kozlowski
2026-04-13  7:10           ` Phandles Kyle Bonnici
2026-04-13  7:55             ` Phandles Krzysztof Kozlowski
2026-04-13  8:40               ` Phandles Kyle Bonnici
2026-04-13  9:16                 ` Phandles Krzysztof Kozlowski
2026-04-13  9:50                   ` Phandles Kyle Bonnici
2026-04-13  9:57                     ` Phandles Krzysztof Kozlowski
2026-04-13 20:25                       ` Phandles Kyle Bonnici
2026-04-14 15:24                     ` Phandles Rob Herring
2026-04-14 19:31                       ` Phandles Kyle Bonnici
2026-04-13  6:33       ` Phandles Krzysztof Kozlowski
2026-04-13 10:30         ` Phandles Herve Codina
2026-04-13  2:12     ` David Gibson [this message]
2026-04-13  6:29       ` Phandles Kyle Bonnici

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=adxRIlenv2OTFXJC@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=devicetree-compiler@vger.kernel.org \
    --cc=herve.codina@bootlin.com \
    --cc=kylebonnici@hotmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.