Danny Baumann | bd62af8 | 2015-08-27 16:08:38 +0200 | [diff] [blame] | 1 | Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. |
David Ng | 3556e58 | 2012-07-27 23:52:11 +0000 | [diff] [blame] | 2 | |
| 3 | Redistribution and use in source form and compiled forms (SGML, HTML, |
| 4 | PDF, PostScript, RTF and so forth) with or without modification, are |
| 5 | permitted provided that the following conditions are met: |
| 6 | |
| 7 | Redistributions in source form must retain the above copyright |
| 8 | notice, this list of conditions and the following disclaimer as the |
| 9 | first lines of this file unmodified. |
| 10 | |
| 11 | Redistributions in compiled form (transformed to other DTDs, |
| 12 | converted to PDF, PostScript, RTF and other formats) must reproduce |
| 13 | the above copyright notice, this list of conditions and the following |
| 14 | disclaimer in the documentation and/or other materials provided with |
| 15 | the distribution. |
| 16 | |
| 17 | THIS DOCUMENTATION IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND |
| 20 | NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE FREEBSD |
| 21 | DOCUMENTATION PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 | OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 28 | DAMAGE. |
| 29 | |
| 30 | |
| 31 | Android - Table of Device Tree |
| 32 | ============================== |
| 33 | |
| 34 | 0) Document revision |
| 35 | v1.0 - Initial version (dng) |
Danny Baumann | bd62af8 | 2015-08-27 16:08:38 +0200 | [diff] [blame] | 36 | v1.1 - Add v2 format to allow subtype (dng) |
David Ng | 3556e58 | 2012-07-27 23:52:11 +0000 | [diff] [blame] | 37 | |
| 38 | 1) Android boot image: |
| 39 | ---------------------- |
| 40 | 1.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 | |
| 56 | 1.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 | |
| 62 | 2) QC table of device tree |
| 63 | -------------------------- |
| 64 | 2.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 | |
| 71 | 2.2) Format: |
| 72 | size |
| 73 | x +------------------+ |
| 74 | | | MAGIC ("QCDT") | 4B |
| 75 | | +------------------+ |
Danny Baumann | bd62af8 | 2015-08-27 16:08:38 +0200 | [diff] [blame] | 76 | header | VERSION | uint32 (version 3) |
David Ng | 3556e58 | 2012-07-27 23:52:11 +0000 | [diff] [blame] | 77 | | +------------------+ |
| 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 Baumann | bd62af8 | 2015-08-27 16:08:38 +0200 | [diff] [blame] | 83 | | +------------------+ |
| 84 | | | subtype id #1 | uint32 (e.g. ID for subtype) (QCDT v2) |
David Ng | 3556e58 | 2012-07-27 23:52:11 +0000 | [diff] [blame] | 85 | device +------------------+ |
| 86 | #1 | soc rev #1 | uint32 (e.g. MSM8974 v2) |
| 87 | entry +------------------+ |
Danny Baumann | bd62af8 | 2015-08-27 16:08:38 +0200 | [diff] [blame] | 88 | | | 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 Ng | 3556e58 | 2012-07-27 23:52:11 +0000 | [diff] [blame] | 96 | | | 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 Baumann | bd62af8 | 2015-08-27 16:08:38 +0200 | [diff] [blame] | 109 | entry | subtype id #Z | uint32 (e.g. ID for subtype) (QCDT v2) |
David Ng | 3556e58 | 2012-07-27 23:52:11 +0000 | [diff] [blame] | 110 | (last) +------------------+ |
Danny Baumann | bd62af8 | 2015-08-27 16:08:38 +0200 | [diff] [blame] | 111 | | | 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 Ng | 3556e58 | 2012-07-27 23:52:11 +0000 | [diff] [blame] | 121 | | | 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 | |
| 143 | 3) Operations |
| 144 | ------------- |
| 145 | 3.1) Build-time: |
Danny Baumann | bd62af8 | 2015-08-27 16:08:38 +0200 | [diff] [blame] | 146 | 1) Each DTS per device will add a "qcom,msm-id" entry |
David Ng | 3556e58 | 2012-07-27 23:52:11 +0000 | [diff] [blame] | 147 | e.g. for msm8974-sim.dts, add |
Danny Baumann | bd62af8 | 2015-08-27 16:08:38 +0200 | [diff] [blame] | 148 | 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 Ng | 3556e58 | 2012-07-27 23:52:11 +0000 | [diff] [blame] | 192 | 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 Baumann | bd62af8 | 2015-08-27 16:08:38 +0200 | [diff] [blame] | 195 | b) decompile the DTB for "qcom,msm-id"/"qcom,board-id"/"qcom,pmic-id" |
David Ng | 3556e58 | 2012-07-27 23:52:11 +0000 | [diff] [blame] | 196 | c) generate the QC table of device tree in sorted |
Danny Baumann | bd62af8 | 2015-08-27 16:08:38 +0200 | [diff] [blame] | 197 | order (platform, variant, subtype, soc rev, pmic0, pmic1, pmic2, pmic3) |
David Ng | 3556e58 | 2012-07-27 23:52:11 +0000 | [diff] [blame] | 198 | d) modified mkbootimg will merge new table of DT |
| 199 | |
| 200 | 3.2) Run-time: |
Danny Baumann | bd62af8 | 2015-08-27 16:08:38 +0200 | [diff] [blame] | 201 | 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 Ng | 3556e58 | 2012-07-27 23:52:11 +0000 | [diff] [blame] | 203 | 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 Baumann | bd62af8 | 2015-08-27 16:08:38 +0200 | [diff] [blame] | 212 | 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 Ng | 3556e58 | 2012-07-27 23:52:11 +0000 | [diff] [blame] | 223 | equal to or lower than the runtime detected soc rev |
Danny Baumann | bd62af8 | 2015-08-27 16:08:38 +0200 | [diff] [blame] | 224 | 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 Ng | 3556e58 | 2012-07-27 23:52:11 +0000 | [diff] [blame] | 234 | 6) Load the matching DTB blob to the tags addr |
| 235 | 7) LK pass the correct DTB to the kernel |