public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
* Devicetree spec: Specifying /cpus/cpu@* unit address format?
@ 2026-04-03 10:06 Vivian Wang
  2026-04-05  4:43 ` David Gibson
  0 siblings, 1 reply; 5+ messages in thread
From: Vivian Wang @ 2026-04-03 10:06 UTC (permalink / raw)
  To: devicetree-spec
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Paul Walmsley,
	Palmer Dabbelt, Alexandre Ghiti, Chen Wang, Inochi Amaoto,
	devicetree, linux-riscv, sophgo

(Also posted at: https://github.com/devicetree-org/devicetree-specification/issues/86 )

Hi all,

Presently, there seems to be some confusion in the community about the
format of unit addresses for "/cpus/cpu@*" nodes for a CPU with ID > 9, e.g.

    cpu@??? {
        reg = <10>;
        /* reg = <0xa>; */ /* This should be equivalent */
    }


Should this be a decimal "cpu@10", or hexadecimal "cpu@a"? I can't find
any explicit specification.

  * Most other nodes specify a hex unit address
  * I could not find anything specifying this generically
      o AFAICT, there's no /cpus in IEEE 1275
      o ePAPR doesn't say anything about this
      o Presently, DTSpec doesn't say anything about this.
  * dt-schema says it's ^cpu@[0-9a-f]+$, seemingly intending to use
    hexadecimal, but not forbidding decimal. [1]
  * Of the `/cpus` schemas in Linux
    (Documentation/devicetree/bindings/{arm,mips,riscv,loongarch}/cpus.yaml),
    none mention the node unit address

As of current usage:

  * Of all the DTS files in (mainline) Linux, most either use hex, or
    have reg < 9 for all CPUs.
      o AFAICT from grepping, arm and arm64 consistently uses hex.
      o Most riscv SoCs have <= 9 CPUs. The two that don't use decimal:
        arch/riscv/boot/dts/sophgo/{sg2042,sg2044}-cpus.dtsi
      o No other arch has in-tree DTS with CPU reg > 9
  * Of all the dt-bindings examples in Linux, only one uses decimal, but
    it seems to be unintentional:
    Documentation/devicetree/bindings/opp/opp-v2.yaml
  * QEMU generates decimal for multiple archs in e.g.
    `hw/{arm,riscv}/virt.c` and other places (grep -R "cpu@")
  * Spike (RISC-V emulator) generates decimal [3]

It could be a good idea to have this standardized, like all other unit
addresses.

DTSpec says:

  The binding for a particular bus may specify additional, more specific
requirements for the format of reg and the unit-address.

Since /cpus and /cpus/cpu@* are generically defined in DTSpec and
specialized for various architectures, I believe this is the right place
to start standardizing this. Even if arch-specific definitions are
required, at least DTSpec can give a recommendation on whether to use
decimal or hexadecimal.

Thanks,
Vivian "dramforever" Wang

[1]: https://github.com/devicetree-org/dt-schema/blob/v2025.12/dtschema/schemas/cpus.yaml#L52-L54
[2]: https://github.com/riscv-software-src/riscv-isa-sim/blob/5eeeb91efa966936ef7b980f5e8dd00ffbe70786/riscv/dts.cc#L61


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-04-06 16:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-03 10:06 Devicetree spec: Specifying /cpus/cpu@* unit address format? Vivian Wang
2026-04-05  4:43 ` David Gibson
2026-04-06 12:48   ` Rob Herring
2026-04-06 14:46     ` Vivian Wang
2026-04-06 16:08     ` Kyle Bonnici

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox