Question

I am trying to understand the following snippet from a DTS file.

/dts-v1/;

/ {
    model = "MPC8313ERDB";
    compatible = "MPC8313ERDB", "MPC831xRDB", "MPC83xxRDB";
    #address-cells = <1>;
    #size-cells = <1>;

    aliases {
        ethernet0 = &enet0;
        serial0 = &serial0;
        serial1 = &serial1;
        pci0 = &pci0;
    };

What does the aliases part does?
My understanding is as follows.
For ethernet0, we can use enet0.
But why serial0=&serial0?
and serial1 = &serial1
Can anyone brief please?

Thanks.

Was it helpful?

Solution

In the aliases section of a DTS, we see entries of the format

property = &label;

Each of the entries consists of :
a. property -- A new property defined here.
b. &label -- Complete DTS path to the node referenced by the label.

It basically assigns the value of b to a. Henceforth, the long-name to the node identified by the label can be accessed using the shorthand property.

Note that the RHS of this assignment is using labels and NOT the short-names of the individual nodes. Just like a label in C code refers to an instruction on the line where it is defined, a label in DTS refers to the individual node (using its complete long path) that is defined on that line.

For example, considering the following DTS,
lxr.free-electrons.com/source/arch/powerpc/boot/dts/mpc8313erdb.dts

whose aliases section consists of the following :

 20         aliases {
 21                 ethernet0 = &enet0;
 22                 ethernet1 = &enet1;
 23                 serial0 = &serial0;
 24                 serial1 = &serial1;
 25                 pci0 = &pci0;
 26         };

The newly defined properties (LHS)

  • ethernet0
  • ethernet1
  • serial0
  • serial1
  • pci0

refer to the corresponding labels (RHS)

For example, the property ethernet0 is now set to "/soc8313@e0000000/ethernet@24000" i.e. the node defined on the line where the label enet0 is defined.


UPDATE :

  1. Why are aliases defined ONLY for ethernet0, serial0 ... ?

    • Further down the line, the developer intends to access these nodes in the kernel source code. Once an alias is defined in the DTS, a handle to the node it is referring to is obtained by simply searching for it in the aliases section rather than searching for it in the entire DTS.

      Source: The function find_node_by_alias() in the Linux kernel source.

  2. Why pci0 node in NOT under the soc8313 node?

    • On MPC8313, the PCI and DMA blocks are interfaced via the IO-Sequencer(IOS). Hence the special treatment as compared to the other blocks (ethernet, I2C, UART) that are connected directly to the system bus.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top