blob: 1aa0be4382bc980d617ff0f888041754282060a2 [file] [log] [blame]
Danny Baumannbd62af82015-08-27 16:08:38 +02001Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
David Ng3556e582012-07-27 23:52:11 +00002
3Redistribution and use in source form and compiled forms (SGML, HTML,
4PDF, PostScript, RTF and so forth) with or without modification, are
5permitted provided that the following conditions are met:
6
7Redistributions in source form must retain the above copyright
8notice, this list of conditions and the following disclaimer as the
9first lines of this file unmodified.
10
11Redistributions in compiled form (transformed to other DTDs,
12converted to PDF, PostScript, RTF and other formats) must reproduce
13the above copyright notice, this list of conditions and the following
14disclaimer in the documentation and/or other materials provided with
15the distribution.
16
17THIS DOCUMENTATION IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND
20NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE FREEBSD
21DOCUMENTATION PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
28DAMAGE.
29
30
31Android - Table of Device Tree
32==============================
33
340) Document revision
35 v1.0 - Initial version (dng)
Danny Baumannbd62af82015-08-27 16:08:38 +020036 v1.1 - Add v2 format to allow subtype (dng)
David Ng3556e582012-07-27 23:52:11 +000037
381) Android boot image:
39----------------------
401.1) Header:
41 1) Magic (8B)
42 2) kernel size (4B)
43 3) kernel addr (4B)
44 4) ramdisk size (4B)
45 5) ramdisk addr (4B)
46 6) 2ndary size (4B)
47 7) 2ndary addr (4B)
48 8) tags addr (4B)
49 9) page size (4B)
50 10) unused #1 (4B) (zero in standard Android)
51 11) unused #2 (4B) (zero in standard Android)
52 12) product name (16B)
53 13) kernel cmdline (512B)
54 14) id (8B)
55
561.2) Layout:
57 A) header (as above - 1 page)
58 B) kernel (n pages)
59 C) ramdisk (m pages)
60 D) second stage (o pages)
61
622) QC table of device tree
63--------------------------
642.1) Changes:
65 i) use "unused #1, #2" members in existing boot image
66 header to point to new table of device tree
67 (#1 - size of QC table of DT)
68 ii) append table of device tree (described later)
69 after "D) second stage"
70
712.2) Format:
72 size
73 x +------------------+
74 | | MAGIC ("QCDT") | 4B
75 | +------------------+
Danny Baumannbd62af82015-08-27 16:08:38 +020076 header | VERSION | uint32 (version 3)
David Ng3556e582012-07-27 23:52:11 +000077 | +------------------+
78 | | num of DTBs | uint32 (number of DTB entries)
79 x +------------------+
80 | | platform id #1 | uint32 (e.g. ID for MSM8974)
81 | +------------------+
82 | | variant id #1 | uint32 (e.g. ID for CDP, MTP)
Danny Baumannbd62af82015-08-27 16:08:38 +020083 | +------------------+
84 | | subtype id #1 | uint32 (e.g. ID for subtype) (QCDT v2)
David Ng3556e582012-07-27 23:52:11 +000085 device +------------------+
86 #1 | soc rev #1 | uint32 (e.g. MSM8974 v2)
87 entry +------------------+
Danny Baumannbd62af82015-08-27 16:08:38 +020088 | | pmic0 #1 | uint32 (pmic0-> first smallest SID of existing pmic)
89 | +------------------+
90 | | pmic1 #1 | uint32 (pmic1-> secondary smallest SID of existing pmic)
91 | +------------------+
92 | | pmic2 #1 | uint32 (pmic2-> third smallest SID of existing pmic)
93 | +------------------+
94 | | pmic3 #1 | uint32 (pmic3-> fourth smallest SID of existing pmic)
95 | +------------------+
David Ng3556e582012-07-27 23:52:11 +000096 | | offset #1 | uint32 (byte offset from start/before MAGIC
97 | +------------------+ to DTB entry)
98 | | size #1 | uint32 (size in bytes of DTB blob)
99 x +------------------+
100 . .
101 . . (repeat)
102 . .
103
104 x +------------------+
105 | | platform id #Z | uint32 (e.g. ID for MSM8974)
106 | +------------------+
107 device | variant id #Z | uint32 (e.g. ID for CDP, MTP)
108 #Z +------------------+
Danny Baumannbd62af82015-08-27 16:08:38 +0200109 entry | subtype id #Z | uint32 (e.g. ID for subtype) (QCDT v2)
David Ng3556e582012-07-27 23:52:11 +0000110 (last) +------------------+
Danny Baumannbd62af82015-08-27 16:08:38 +0200111 | | soc rev #Z | uint32 (e.g. MSM8974 v2)
112 | +------------------+
113 | | pmic0 #1 | uint32 (pmic0-> first smallest SID of existing pmic)
114 | +------------------+
115 | | pmic1 #1 | uint32 (pmic1-> secondary smallest SID of existing pmic)
116 | +------------------+
117 | | pmic2 #1 | uint32 (pmic2-> third smallest SID of existing pmic)
118 | +------------------+
119 | | pmic3 #1 | uint32 (pmic3-> fourth smallest SID of existing pmic)
120 | +------------------+
David Ng3556e582012-07-27 23:52:11 +0000121 | | offset #Z | uint32 (byte offset from start/before MAGIC
122 x +------------------+ to DTB entry)
123 | 0 ("zero") | uint32 (end of list delimiter)
124 +------------------+ to DTB entry)
125 | padding | variable length for next DTB to start on
126 +------------------+ page boundary
127 | DTB #1 | variable (start is page aligned)
128 | |
129 | |
130 +------------------+
131 | padding | variable length for next DTB to start on
132 +------------------+ page boundary
133 .
134 .
135 .
136
137 +------------------+
138 | DTB #Z (last) | variable (start is page aligned)
139 | |
140 | |
141 +------------------+
142
1433) Operations
144-------------
1453.1) Build-time:
Danny Baumannbd62af82015-08-27 16:08:38 +0200146 1) Each DTS per device will add a "qcom,msm-id" entry
David Ng3556e582012-07-27 23:52:11 +0000147 e.g. for msm8974-sim.dts, add
Danny Baumannbd62af82015-08-27 16:08:38 +0200148 qcom,msm-id = <x y z>;
149 or
150 qcom,msm-id = <x z>;
151 qcom,board-id = <y y'>;
152 or
153 qcom,msm-id = <x z>;
154 qcom,board-id = <y y'>;
155 qcom,pmic-id = <a b c d>;
156 x = ID for msm8974
157 y = ID for CDP, MTP, etc.
158 y' = ID for subtype (assumed zero if absent)
159 z = ID for soc revision
160 a = pmic0
161 b = pmic1
162 c = pmic2
163 d = pmic3
164 SBL populates the pmic entries always in ascending order of SID, so
165 pmic0-> SID0, pmic1-> SID1, pmic2-> SID2, pmic3-> SID3.
166 e.g. for qcom,pmic-id = <pmic0 pmic1 pmic2 pmic3>
167 Board X = MSM8994 + PM8994 + PMI8994 (Existing boards [ROW])
168 Board Y = MSM8994 + PM8994 + PMI8994 + PM8004 (Internal SS board variant)
169 Board Z = MSM8994 + PM8994 + PM8004 (Boards that SS will be making)
170
171 For all boards X, Y, and Z, PMICs have the following SIDs and REVID SUBTYPEs
172 (i.e. PMIC Model):
173 PM8994 - SID 0 and 1; subtype = 9
174 PMI8994 - SID 2 and 3; subtype = 10
175 PM8004 - SID 4 and 5; subtype = 12
176
177 LK using SMEM PMIC info(1 as major and 0 as minor version for example):
178 Board X: qcom,pmic-id = <0x0109 0x010A 0x0 0x0>;
179 Board Y: qcom,pmic-id = <0x0109 0x010A 0x010C 0x0>;
180 Board Z: qcom,pmic-id = <0x0109 0x010C 0x0 0x0>;
181
182 The entry can optionally be an array:
183 qcom,msm-id = <x1 y1 z1>, <x2 y2 z2>, ...;
184 or
185 qcom,msm-id = <x1 z1>, <x2 z2>, ...;
186 qcom,board-id = <y1 y1'>, ...;
187 or
188 qcom,msm-id = <x1 z1>, <x2 z2>, ...;
189 qcom,board-id = <y1 y1'>, ...;
190 qcom,pmic-id = <a1 b1 c1 d1>, ...;
191 Note that qcom,msm-id, qcom,board-id and qcom,pmic-id are not matched pairs.
David Ng3556e582012-07-27 23:52:11 +0000192 2) Kernel compile will generate the DTB
193 3) Android build will run a new tool (dtbTool)
194 a) scan the DTB output directory for all compiled DTB
Danny Baumannbd62af82015-08-27 16:08:38 +0200195 b) decompile the DTB for "qcom,msm-id"/"qcom,board-id"/"qcom,pmic-id"
David Ng3556e582012-07-27 23:52:11 +0000196 c) generate the QC table of device tree in sorted
Danny Baumannbd62af82015-08-27 16:08:38 +0200197 order (platform, variant, subtype, soc rev, pmic0, pmic1, pmic2, pmic3)
David Ng3556e582012-07-27 23:52:11 +0000198 d) modified mkbootimg will merge new table of DT
199
2003.2) Run-time:
Danny Baumannbd62af82015-08-27 16:08:38 +0200201 1) LK bootloader will obtain platform id/variant/subtype/soc rev/major ver/minor ver
202 /pmic0/pmic1/pmic2/pmic3 info either from early bootloaders or via other means
David Ng3556e582012-07-27 23:52:11 +0000203 2) LK bootloader will check entries #10 for non-zero
204 value (set to zero for standard boot.img). If the
205 value is non-zero, refer to page section after
206 the "second stage" in the boot.img layout
207 3) Check QCDT magic
208 4) Check QCDT version (optional LK to handle multiple
209 QCDT version)
210 5) LK scans through the QCDT table to look for matching
211 entry. Search order is:
Danny Baumannbd62af82015-08-27 16:08:38 +0200212 1) msm ID exact match
213 2) Platform type exact match
214 3) subtype ID exact match
215 4) HLOS subtype exact match
216 5) Pmic0 model ID exact match
217 6) Pmic1 model ID exact match
218 7) Pmic2 model ID exact match
219 8) Pmic3 model ID exact match
220 9) foundry ID, look for exact match, if not found choose
221 device tree with foundry-id(0x0)
222 10) select the highest soc rev in QCDT that is
David Ng3556e582012-07-27 23:52:11 +0000223 equal to or lower than the runtime detected soc rev
Danny Baumannbd62af82015-08-27 16:08:38 +0200224 11) select the highest major&minor ver in QCDT that is
225 equal to or lower than the runtime detected major ver
226 12) select the highest pmic0 major&minor in QCDT that is
227 equal to or lower than the runtime detected pmic0
228 13) select the highest pmic1 major&minor in QCDT that is
229 equal to or lower than the runtime detected pmic1
230 14) select the highest pmic2 major&minor in QCDT that is
231 equal to or lower than the runtime detected pmic2
232 15) select the highest pmic3 major&minor in QCDT that is
233 equal to or lower than the runtime detected pmic3
David Ng3556e582012-07-27 23:52:11 +0000234 6) Load the matching DTB blob to the tags addr
235 7) LK pass the correct DTB to the kernel