Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DTS file explanation - aliases

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.

like image 285
New to Rails Avatar asked Jul 19 '13 05:07

New to Rails


People also ask

What is aliases in device tree?

The "/aliases" node contains properties that are aliases. The name of each property is the name of the alias, and the value of the property is the full path to a node in the device tree. The aliases are not used directly in the device tree source, but are instead dereferenced by the Linux kernel.

What is DTS and Dtsi file?

dtsi files are included files, containing definitions of SoC-level information, while . dts files are final device trees containing board-level information. The . dtsi extension denotes “device tree source include”.

What is DTS file in Linux kernel?

Device tree file types The device tree is a set of text files in the Linux kernel source tree that describe the hardware of a certain platform. They are located at arch/arm/boot/dts/ and can have two extensions: *. dtsi files are device tree source include files.

What is a Phandle?

You can understand phandle as some kind of pointer for the node which points to the definition of that node which is either kept in the same file or the other file.


1 Answers

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)

  • enet0
  • enet1
  • serial0
  • serial1
  • pci0

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.
like image 108
TheCodeArtist Avatar answered Oct 30 '22 20:10

TheCodeArtist