Linux Device Tree (two-node representation) in my eyes
Two-node Representation
First, the node representation method. Except for the root node, only the slash "/" is used for representation. The representation of other nodes is as follows: "node-name @ unit-address ". @ The front side is the node name, and the back side is the node address.
The node name length ranges from 1 to 31. The available characters are described in the ePAPR specification, including:
0-9 digits
Lowercase letters a-z
A-Z capital letters
, Comma
. Period (English)
_ Underline
+ Plus sign
-Discount (English)
The specification requires that the node name should start with a letter. Although non-letter characters are allowed at the back of the node, we do not need to use other characters in actual conditions. Generally, it is enough to express all the characters in letters. In particular, we recommend that you use a common name instead of a proprietary name when naming a NIC. For example, you can use ethernet to indicate the NIC. You can use addresses to distinguish different NICs, the network adapter can be distinguished by attributes under the node. There is also a widely accepted name for all the existing devices. We do not have to make any difference here, for example, the name of the node listed in the following specification (drivers can guess the device at a Glance ):
Atm
Cache-controller
Compact-flash
Can
Cpu
Crypto
Disk
Display
Dma-controller
Ethernet
Ethernet-phy
Fdc
Flash
Gpio
I2c
Ide
Interrupt-controller
Isa
Keyboard
Mdio
Memory
Memory-controller
Mouse
Nvram
Parallel
Pc-card
Pci
Pcie
Rtc
Sata
Scsi
Serial
Sound
Spi
Timer
Usb
Vme
Watchdog
A node address is used to distinguish a node with the same name. It is not an address in the software sense, but in some cases, the software address can be used as the address. For example, the names of the two I2C controllers can be i2c, and the first address of the controller register is used as the node address. For the cpu, because it does not have a register address, you can use the number of the core as the address. For an 8-core processor, the address can be from 0 to 7. The description of the node address in the ePAPR specification is not well understood. the original Article is "The unit-address component of the name is specific to the bus type on which the node sits ". In fact, I think this statement is not accurate, because not all nodes indicate that the hardware is on a bus, such as memory and cpu. The Device Tree is an approximate representation of hardware by software. For the cpu, the software requires the serial number, so the address uses the serial number. For the i2c controller, the software requires the first register address, so the address is used. In addition, the specification also requires that if a node has an address, there must be an attribute Named reg under the node, and the address must be the same as the first address of the reg attribute. If the node does not have the reg attribute, neither the node address nor the @ at the front edge must be available. We haven't introduced the attributes and values yet. Here, reg is the abbreviation of register. This attribute is mainly used to indicate the first address of the controller register. In my opinion, this rule is not very necessary because some devices only need an address, so it is enough to put it in the node address, and there is no need to add a reg attribute. In The last sentence of this section, the canonicalized phrase "the binding for a special bus may specify additional, more specific ments for The format of reg and the unit-address. ", I think the meaning of this sentence is similar to that of" The Device Tree is an approximate representation of the software on the hardware. How does the software need to be expressed? How does it mean, there is no Xuan.
The Node path is easy to understand. A path can be formed from the root node to each node, for example, the first section/cpus/cpu @ 0, this can uniquely represent the cpu @ 0 node. Because the cpu @ 0 is unique under cpus, but the entire Device Tree may not be unique, you can confirm which node it belongs to without any objection only when using full path. If the node address is omitted, the node address is not ambiguous. Like brackets in programming, I personally think this is unnecessary.