All of lore.kernel.org
 help / color / mirror / Atom feed
* question on format of unit addresses
@ 2025-03-21 10:24 Rasmus Villemoes
  0 siblings, 0 replies; only message in thread
From: Rasmus Villemoes @ 2025-03-21 10:24 UTC (permalink / raw)
  To: devicetree

Hi

I have a 11-port ethernet switch, with ports numbered 0-10, and the
cpu-facing port being port 10. I was under the impression that unit
addresses were supposed to be in hex (but with no 0x prefix), so I wrote

	port@a {
		reg = <10>;
		label = "cpu";
                ...

But the schema check fails, because dsa.yaml specifies

        patternProperties:
          "^(ethernet-)?port@[0-9]+$":
            description: Ethernet switch ports

So I can fix that by naming the node port@10, but then I thought I'd get
another complaint that 16 != 10. I don't; the only check I can see in
dtc about node address v reg is a check that if there's a node address
there should also be a reg (or ranges) and vice versa, but there doesn't
seem to be anything that compares the numerical values in either dtc or
dt-validate.

I haven't been able to find documentation on how exactly the node
address is interpreted (if at all, other than as a suffix to distinguish
it from other nodes at the same level). The closest is
https://devicetree-specification.readthedocs.io/en/stable/devicetree-basics.html#node-names
which says

   The unit-address component of the name is specific to the bus type on
   which the node sits. It consists of one or more ASCII characters from
   the set of characters in Table 2.1. The unit-address must match the
   first address specified in the reg property of the node.

but "match" is not really defined.

Can someone clarify what the rules actually are? Something like

- stick to all node addresses being either hex or decimal

- when the binding only allows decimal digits, use that

- in cases where the reg property is most naturally specified in decimal
  (such as smallish-but-maybe-larger-than-9 indexes such as for ethernet
  ports or SPI chip selects), use decimal in both the reg and node
  address

?

Rasmus

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-03-21 10:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-21 10:24 question on format of unit addresses Rasmus Villemoes

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.