Re: [PATCH V10 8/8] arm64: dts: sc7280: Add aliases for I2C and SPI

From: Arnd Bergmann
Date: Tue Oct 19 2021 - 17:27:30 EST


On Tue, Oct 19, 2021 at 11:11 PM Doug Anderson <dianders@xxxxxxxxxxxx> wrote:
> On Tue, Oct 19, 2021 at 1:57 PM Bjorn Andersson
>
> Hrm. I know this gets into slightly controversial topics, but I'm a
> little curious what the downside of having these in the dtsi is. In
> the case where these i2c/spi/mmc devices _don't_ have "well defined"
> numbers in the hardware manual of the SoC then I can agree that it
> doesn't make sense to list these in the dtsi file. However, in the
> case of sc7280 these numbers are well defined at the SoC level for i2c
> and SPI.
>
> Said another way: if you have a board that's got peripherals connected
> on the pins labelled "i2c2" and "i2c6" on the SoC then it's a really
> nice thing if these show up on /dev/i2c-2 and /dev/i2c-6.
>
> ...so I'm not sure what board exactly would be overriding and
> re-numbering? Unless a board really has a strong use case where they
> need the device connected to the pins for "i2c2" to show up on
> "/dev/i2c-0"?

There are multiple things going on here:

- The aliases are traditionally managed by the bootloader, same way
as the /chosen nodes including the kernel command line, so the
numbers are local policy, and the per-board defaults are just
for convenience.

- IMHO there should not be any aliases for status="disabled"
nodes, and the status is usually set in the board files.

- The labels on the board don't always match what the SoC calls
them, or there might not be any labels at all. This is more
important for things like serial ports that are often bare
connectors rather than already wired up. The aliases should
normally match how the board numbers the connectors, not
how they are attached internally.

- For i2c, it's not uncommon to have i2c devices attached behind
expanders on i2c/spi/gpio/usb/pci devices

Arnd