xref: /aosp_15_r20/external/dtc/Documentation/dts-format.txt (revision cd60bc56d4bea3af4ec04523e4d71c2b272c8aff)
1*cd60bc56SAndroid Build Coastguard WorkerDevice Tree Source Format (version 1)
2*cd60bc56SAndroid Build Coastguard Worker=====================================
3*cd60bc56SAndroid Build Coastguard Worker
4*cd60bc56SAndroid Build Coastguard WorkerThe Device Tree Source (DTS) format is a textual representation of a
5*cd60bc56SAndroid Build Coastguard Workerdevice tree in a form that can be processed by dtc into a binary
6*cd60bc56SAndroid Build Coastguard Workerdevice tree in the form expected by the kernel.  The description below
7*cd60bc56SAndroid Build Coastguard Workeris not a formal syntax definition of DTS, but describes the basic
8*cd60bc56SAndroid Build Coastguard Workerconstructs used to represent device trees.
9*cd60bc56SAndroid Build Coastguard Worker
10*cd60bc56SAndroid Build Coastguard WorkerNode and property definitions
11*cd60bc56SAndroid Build Coastguard Worker-----------------------------
12*cd60bc56SAndroid Build Coastguard Worker
13*cd60bc56SAndroid Build Coastguard WorkerDevice tree nodes are defined with a node name and unit address with
14*cd60bc56SAndroid Build Coastguard Workerbraces marking the start and end of the node definition.  They may be
15*cd60bc56SAndroid Build Coastguard Workerpreceded by a label.
16*cd60bc56SAndroid Build Coastguard Worker
17*cd60bc56SAndroid Build Coastguard Worker	[label:] node-name[@unit-address] {
18*cd60bc56SAndroid Build Coastguard Worker		[properties definitions]
19*cd60bc56SAndroid Build Coastguard Worker		[child nodes]
20*cd60bc56SAndroid Build Coastguard Worker	}
21*cd60bc56SAndroid Build Coastguard Worker
22*cd60bc56SAndroid Build Coastguard WorkerNodes may contain property definitions and/or child node
23*cd60bc56SAndroid Build Coastguard Workerdefinitions. If both are present, properties must come before child
24*cd60bc56SAndroid Build Coastguard Workernodes.
25*cd60bc56SAndroid Build Coastguard Worker
26*cd60bc56SAndroid Build Coastguard WorkerProperty definitions are name value pairs in the form:
27*cd60bc56SAndroid Build Coastguard Worker	[label:] property-name = value;
28*cd60bc56SAndroid Build Coastguard Workerexcept for properties with empty (zero length) value which have the
29*cd60bc56SAndroid Build Coastguard Workerform:
30*cd60bc56SAndroid Build Coastguard Worker	[label:] property-name;
31*cd60bc56SAndroid Build Coastguard Worker
32*cd60bc56SAndroid Build Coastguard WorkerProperty values may be defined as an array of 8, 16, 32, or 64-bit integer
33*cd60bc56SAndroid Build Coastguard Workerelements, as NUL-terminated strings, as bytestrings or a combination of these.
34*cd60bc56SAndroid Build Coastguard Worker
35*cd60bc56SAndroid Build Coastguard Worker* Arrays are represented by angle brackets surrounding a space separated list
36*cd60bc56SAndroid Build Coastguard Worker  of C-style integers or character literals.  Array elements default to 32-bits
37*cd60bc56SAndroid Build Coastguard Worker  in size.  An array of 32-bit elements is also known as a cell list or a list
38*cd60bc56SAndroid Build Coastguard Worker  of cells.  A cell being an unsigned 32-bit integer.
39*cd60bc56SAndroid Build Coastguard Worker
40*cd60bc56SAndroid Build Coastguard Worker	e.g. interrupts = <17 0xc>;
41*cd60bc56SAndroid Build Coastguard Worker
42*cd60bc56SAndroid Build Coastguard Worker* A 64-bit value can be represented with two 32-bit elements.
43*cd60bc56SAndroid Build Coastguard Worker
44*cd60bc56SAndroid Build Coastguard Worker	e.g. clock-frequency = <0x00000001 0x00000000>;
45*cd60bc56SAndroid Build Coastguard Worker
46*cd60bc56SAndroid Build Coastguard Worker* The storage size of an element can be changed using the /bits/ prefix.  The
47*cd60bc56SAndroid Build Coastguard Worker  /bits/ prefix allows for the creation of 8, 16, 32, and 64-bit elements.
48*cd60bc56SAndroid Build Coastguard Worker  The resulting array will not be padded to a multiple of the default 32-bit
49*cd60bc56SAndroid Build Coastguard Worker  element size.
50*cd60bc56SAndroid Build Coastguard Worker
51*cd60bc56SAndroid Build Coastguard Worker	e.g. interrupts = /bits/ 8 <17 0xc>;
52*cd60bc56SAndroid Build Coastguard Worker	e.g. clock-frequency = /bits/ 64 <0x0000000100000000>;
53*cd60bc56SAndroid Build Coastguard Worker
54*cd60bc56SAndroid Build Coastguard Worker* A NUL-terminated string value is represented using double quotes
55*cd60bc56SAndroid Build Coastguard Worker  (the property value is considered to include the terminating NUL
56*cd60bc56SAndroid Build Coastguard Worker  character).
57*cd60bc56SAndroid Build Coastguard Worker
58*cd60bc56SAndroid Build Coastguard Worker	e.g. compatible = "simple-bus";
59*cd60bc56SAndroid Build Coastguard Worker
60*cd60bc56SAndroid Build Coastguard Worker* A bytestring is enclosed in square brackets [] with each byte
61*cd60bc56SAndroid Build Coastguard Worker  represented by two hexadecimal digits.  Spaces between each byte are
62*cd60bc56SAndroid Build Coastguard Worker  optional.
63*cd60bc56SAndroid Build Coastguard Worker
64*cd60bc56SAndroid Build Coastguard Worker	e.g. local-mac-address = [00 00 12 34 56 78]; or equivalently
65*cd60bc56SAndroid Build Coastguard Worker	     local-mac-address = [000012345678];
66*cd60bc56SAndroid Build Coastguard Worker
67*cd60bc56SAndroid Build Coastguard Worker* Values may have several comma-separated components, which are
68*cd60bc56SAndroid Build Coastguard Worker  concatenated together.
69*cd60bc56SAndroid Build Coastguard Worker	e.g. compatible = "ns16550", "ns8250";
70*cd60bc56SAndroid Build Coastguard Worker	     example = <0xf00f0000 19>, "a strange property format";
71*cd60bc56SAndroid Build Coastguard Worker
72*cd60bc56SAndroid Build Coastguard Worker* In an array a reference to another node will be expanded to that node's
73*cd60bc56SAndroid Build Coastguard Worker  phandle.  References may by '&' followed by a node's label:
74*cd60bc56SAndroid Build Coastguard Worker	e.g. interrupt-parent = < &mpic >;
75*cd60bc56SAndroid Build Coastguard Worker  or they may be '&' followed by a node's full path in braces:
76*cd60bc56SAndroid Build Coastguard Worker	e.g. interrupt-parent = < &{/soc/interrupt-controller@40000} >;
77*cd60bc56SAndroid Build Coastguard Worker  References are only permitted in arrays that have an element size of
78*cd60bc56SAndroid Build Coastguard Worker  32-bits.
79*cd60bc56SAndroid Build Coastguard Worker
80*cd60bc56SAndroid Build Coastguard Worker* Outside an array, a reference to another node will be expanded to that
81*cd60bc56SAndroid Build Coastguard Worker  node's full path.
82*cd60bc56SAndroid Build Coastguard Worker	e.g. ethernet0 = &EMAC0;
83*cd60bc56SAndroid Build Coastguard Worker
84*cd60bc56SAndroid Build Coastguard Worker* Labels may also appear before or after any component of a property
85*cd60bc56SAndroid Build Coastguard Worker  value, or between elements of an array, or between bytes of a bytestring.
86*cd60bc56SAndroid Build Coastguard Worker	e.g. reg = reglabel: <0 sizelabel: 0x1000000>;
87*cd60bc56SAndroid Build Coastguard Worker	e.g. prop = [ab cd ef byte4: 00 ff fe];
88*cd60bc56SAndroid Build Coastguard Worker	e.g. str = start: "string value" end: ;
89*cd60bc56SAndroid Build Coastguard Worker
90*cd60bc56SAndroid Build Coastguard Worker
91*cd60bc56SAndroid Build Coastguard WorkerFile layout
92*cd60bc56SAndroid Build Coastguard Worker-----------
93*cd60bc56SAndroid Build Coastguard Worker
94*cd60bc56SAndroid Build Coastguard WorkerVersion 1 DTS files have the overall layout:
95*cd60bc56SAndroid Build Coastguard Worker	/dts-v1/;
96*cd60bc56SAndroid Build Coastguard Worker
97*cd60bc56SAndroid Build Coastguard Worker	[memory reservations]
98*cd60bc56SAndroid Build Coastguard Worker
99*cd60bc56SAndroid Build Coastguard Worker	/ {
100*cd60bc56SAndroid Build Coastguard Worker		[property definitions]
101*cd60bc56SAndroid Build Coastguard Worker		[child nodes]
102*cd60bc56SAndroid Build Coastguard Worker	};
103*cd60bc56SAndroid Build Coastguard Worker
104*cd60bc56SAndroid Build Coastguard Worker* The "/dts-v1/;" must be present to identify the file as a version 1
105*cd60bc56SAndroid Build Coastguard Worker  DTS (dts files without this tag will be treated by dtc as being in
106*cd60bc56SAndroid Build Coastguard Worker  the obsolete "version 0", which uses a different format for integers
107*cd60bc56SAndroid Build Coastguard Worker  amongst other small but incompatible changes).
108*cd60bc56SAndroid Build Coastguard Worker
109*cd60bc56SAndroid Build Coastguard Worker* Memory reservations define an entry for the device tree blob's
110*cd60bc56SAndroid Build Coastguard Worker  memory reservation table.  They have the form:
111*cd60bc56SAndroid Build Coastguard Worker	e.g. /memreserve/ <address> <length>;
112*cd60bc56SAndroid Build Coastguard Worker  Where <address> and <length> are 64-bit C-style integers.
113*cd60bc56SAndroid Build Coastguard Worker
114*cd60bc56SAndroid Build Coastguard Worker* The / { ... }; section defines the root node of the device tree.
115*cd60bc56SAndroid Build Coastguard Worker
116*cd60bc56SAndroid Build Coastguard Worker* C style (/* ... */) and C++ style (// ...) comments are supported.
117*cd60bc56SAndroid Build Coastguard Worker
118*cd60bc56SAndroid Build Coastguard Worker
119*cd60bc56SAndroid Build Coastguard Worker
120*cd60bc56SAndroid Build Coastguard Worker	-- David Gibson <[email protected]>
121*cd60bc56SAndroid Build Coastguard Worker	-- Yoder Stuart <[email protected]>
122*cd60bc56SAndroid Build Coastguard Worker	-- Anton Staaf <[email protected]>
123