This article talks about the properties of Linux device tree nodes.
For related subjects, please refer to the SOC Table of Contents.
In order to define a node for device trees, it will need to follow the following format:
[label:]node-name[@unit-address]{ [properties definitions] [child nodes] };
Note that the portions in square brackets [] can be left blank. Including the label makes it easier for it to be referenced by other nodes in the .dts file.
node-name is the name of the node and can be any combination of ASCII characters forming a string; it is recommended for its name to describe its function, for example naming a UART1 peripheral node uart1.
unit-address represents the device’s address or base address, this can be left blank of the node doesn’t have it, such as cpu@0 or the interrupt nodes.
As stated before, nodes can have parent/child relations. An example is shown below:
cpus{ #address-cells = <1>; #size-cells = <0>; cpu0:cpu@0{ compatible = “arm,cortex-a9”; device_type = “cpu”; reg = <0>; clocks = <&clkc 3>; clock-latency = <1000>; cpu0-supply = <®ulator_vccpint>; operating-points = < /* kHz uV */ 666667 1000000 333334 1000000 >; }; cpu1:cpu@1{ compatible = “arm,cortex-a9”; device_type = “cpu”; reg = <1>; clocks = <&clkc 3>; }; };
Note that the cpus node at the start of the code block only has the node name. The cpus node has two properties: #address-cells and #size-cells, with values of <1> and <0> respectively.
We will proceed to go over each other node property.
Node properties can be any of the following six types:
String
compatible = “arm,cortex-a9”;
The string is enveloped in double quotation marks “”. As we can see from the example above, the property value of compatible is “arm,cortex-a9”.
32-bit unsigned integer
clock-latency = <1000>;
reg = <0x00000000 0x00500000>;
The unsigned integer is enveloped in open angle brackets <>. As we can see from the example above, clock-latency has a 32-bit unsigned int value of 1000, whereas reg has two pieces of data separated by a space, which we can identify as an array.
Binary
local-mac-address = [00 0a 35 00 le 53];
The binary value is enveloped in square brackets []. As we can see from the example above, it’s an array consisting of binary values.
String array
compatible = “n25q512a”,“micron,m25p80”;
Note that properties can also be lists of strings, as shown above. The strings are separated by commas.
Mixed values
mixed-property = “string”,[0x01 0x23 0x45 0x67],<0x12345678>;
Note that properties can also be a combination of different types, where they are separated by commas.
Node referencing
clocks = <&clkc 3>;
Note that &clkc references the node clkc, and the entire operation is also enveloped by open angle brackets.