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.
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.
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”.
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.
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.
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 label
s 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 :
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.
Why pci0
node in NOT under the soc8313
node?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With