Re: SoC-specific device tree aliases?

Ahmad Fatoum <[email protected]> Fri, 14 Nov 2025 10:13:23 +0100
Newsgroups org.kernel.vger.devicetree-spec,org.kernel.vger.linux-devicetree
Message-ID <[email protected]>
Hi Rob,

On 11/13/25 7:04 PM, Rob Herring wrote:
> On Thu, Nov 13, 2025 at 2:29 AM Ahmad Fatoum <[email protected]> wrote:
>>
>> Hello,
>>
>> With /chosen/bootsource now part of dt-schema, I would like to raise a
>> related point: The need for SoC-specific device tree aliases.
>>
>> For many SoCs, there is a canonical numbering for peripherals; it's used
>> in the datasheet and BootROMs often makes use of it at runtime to report
>> the bootsource as a pair:
>>
>>   - One value to enumerate type of boot medium (e.g. mmc, spi-nor..)
>>   - Another value that describes which instance (e.g. SDHC1, SPI3, ...)
>>
>> Some examples, where this is the case, are AT91, STM32MP or i.MX.
>>
>> barebox has traditionally used /aliases to translate BootROM information
>> to a device tree node to fixup /chosen/bootsource.
> 
> So bootsource will be populated "mmc0" or "spinor1" for example?

It will be populated by the full device tree node path:

barebox$ of_diff /mnt/nfs/boot/imx8mp-tqma8mpql-mba8mpxl.dtb +  # to show fixups
chosen {
+         bootsource = "/soc@0/bus@30800000/mmc@30b50000";
+         reset-source = "POR";
+         reset-source-device = "/soc@0/bus@30800000/i2c@30a20000/pmic@25";
};
[...]

>> This doesn't work out for many newer SoC support, because of different
>> expectations: For upstream, aliases are relevant to a board, while
>> barebox traditionally expected them to be SoC-specific (because they
>> used to be on i.MX, probably).
> 
> But usually the numbering follows the SoC numbering. Sometimes it
> follows the PCB numbering, but I think that's mainly serial ports.
> I've certainly steered people away from vendor specific instance
> numbering properties towards aliases (if the need can't be eliminated
> entirely).
> 
> The board specific part I think is more that the board defines what
> devices are present and not present. It would be weird to have a
> serial3 alias when that's not wired up. And board .dts files are going
> to forget to remove it. Though I guess it is somewhat harmless.

I think differing from the established numbering in SoC datasheet and as
Heiko correctly notes most schematics is weirder.

> I think the real change here is it would make aliases required when
> currently they aren't really. Though I guess populating bootsource is
> entirely optional?

Yes, of course. If the bootloader doesn't have enough information to
resolve the bootsource, then it will just be missing.

I looked at the first 10 matches for of_alias_get_id in drivers/ and
6 from them used the alias as more than just ID, so renumbering would
actually break them.

Such driver could also benefit if we had a mechanism to unambiguously
represent SoC numbering in the device tree.

Cheers,
Ahmad

> 
> Rob
> 

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |