David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1 | Booting the Linux/ppc kernel without Open Firmware |
| 2 | -------------------------------------------------- |
| 3 | |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 4 | (c) 2005 Benjamin Herrenschmidt <benh at kernel.crashing.org>, |
| 5 | IBM Corp. |
| 6 | (c) 2005 Becky Bruce <becky.bruce at freescale.com>, |
| 7 | Freescale Semiconductor, FSL SOC and 32-bit additions |
Vitaly Wool | 28f9ec3 | 2006-11-20 16:32:39 +0300 | [diff] [blame] | 8 | (c) 2006 MontaVista Software, Inc. |
| 9 | Flash chip node definition |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 10 | |
Stuart Yoder | 5e1e9ba | 2007-06-06 04:29:14 +1000 | [diff] [blame] | 11 | Table of Contents |
| 12 | ================= |
| 13 | |
| 14 | I - Introduction |
| 15 | 1) Entry point for arch/powerpc |
| 16 | 2) Board support |
| 17 | |
| 18 | II - The DT block format |
| 19 | 1) Header |
| 20 | 2) Device tree generalities |
| 21 | 3) Device tree "structure" block |
| 22 | 4) Device tree "strings" block |
| 23 | |
| 24 | III - Required content of the device tree |
| 25 | 1) Note about cells and address representation |
| 26 | 2) Note about "compatible" properties |
| 27 | 3) Note about "name" properties |
| 28 | 4) Note about node and property names and character set |
| 29 | 5) Required nodes and properties |
| 30 | a) The root node |
| 31 | b) The /cpus node |
| 32 | c) The /cpus/* nodes |
| 33 | d) the /memory node(s) |
| 34 | e) The /chosen node |
| 35 | f) the /soc<SOCname> node |
| 36 | |
| 37 | IV - "dtc", the device tree compiler |
| 38 | |
| 39 | V - Recommendations for a bootloader |
| 40 | |
| 41 | VI - System-on-a-chip devices and nodes |
| 42 | 1) Defining child nodes of an SOC |
| 43 | 2) Representing devices without a current OF specification |
| 44 | a) MDIO IO device |
Stuart Yoder | 5e1e9ba | 2007-06-06 04:29:14 +1000 | [diff] [blame] | 45 | b) Gianfar-compatible ethernet nodes |
Roy Zang | a4ecaba | 2007-06-19 15:19:31 +0800 | [diff] [blame] | 46 | c) PHY nodes |
Stuart Yoder | 5e1e9ba | 2007-06-06 04:29:14 +1000 | [diff] [blame] | 47 | d) Interrupt controllers |
| 48 | e) I2C |
| 49 | f) Freescale SOC USB controllers |
| 50 | g) Freescale SOC SEC Security Engines |
| 51 | h) Board Control and Status (BCSR) |
| 52 | i) Freescale QUICC Engine module (QE) |
David Gibson | 2099172 | 2007-09-07 13:23:53 +1000 | [diff] [blame] | 53 | j) CFI or JEDEC memory-mapped NOR flash |
Roy Zang | 3b824f8 | 2007-06-19 15:19:18 +0800 | [diff] [blame] | 54 | k) Global Utilities Block |
Timur Tabi | bc556ba | 2008-01-08 10:30:58 -0600 | [diff] [blame] | 55 | l) Freescale Communications Processor Module |
| 56 | m) Chipselect/Local Bus |
| 57 | n) 4xx/Axon EMAC ethernet nodes |
| 58 | o) Xilinx IP cores |
Timur Tabi | c7d24a2 | 2008-01-18 09:24:53 -0600 | [diff] [blame] | 59 | p) Freescale Synchronous Serial Interface |
Valentine Barshak | 41abd68 | 2007-09-25 05:27:56 +1000 | [diff] [blame] | 60 | q) USB EHCI controllers |
Laurent Pinchart | a5edecc | 2008-05-26 11:53:21 +0200 | [diff] [blame] | 61 | r) MDIO on GPIOs |
Grant Likely | 79c28ac | 2008-07-11 16:17:57 -0600 | [diff] [blame] | 62 | s) SPI busses |
Stuart Yoder | 5e1e9ba | 2007-06-06 04:29:14 +1000 | [diff] [blame] | 63 | |
Dale Farnsworth | f5412c4 | 2008-04-08 08:12:07 +1000 | [diff] [blame] | 64 | VII - Marvell Discovery mv64[345]6x System Controller chips |
| 65 | 1) The /system-controller node |
| 66 | 2) Child nodes of /system-controller |
| 67 | a) Marvell Discovery MDIO bus |
| 68 | b) Marvell Discovery ethernet controller |
| 69 | c) Marvell Discovery PHY nodes |
| 70 | d) Marvell Discovery SDMA nodes |
| 71 | e) Marvell Discovery BRG nodes |
| 72 | f) Marvell Discovery CUNIT nodes |
| 73 | g) Marvell Discovery MPSCROUTING nodes |
| 74 | h) Marvell Discovery MPSCINTR nodes |
| 75 | i) Marvell Discovery MPSC nodes |
| 76 | j) Marvell Discovery Watch Dog Timer nodes |
| 77 | k) Marvell Discovery I2C nodes |
| 78 | l) Marvell Discovery PIC (Programmable Interrupt Controller) nodes |
| 79 | m) Marvell Discovery MPP (Multipurpose Pins) multiplexing nodes |
| 80 | n) Marvell Discovery GPP (General Purpose Pins) nodes |
| 81 | o) Marvell Discovery PCI host bridge node |
| 82 | p) Marvell Discovery CPU Error nodes |
| 83 | q) Marvell Discovery SRAM Controller nodes |
| 84 | r) Marvell Discovery PCI Error Handler nodes |
| 85 | s) Marvell Discovery Memory Controller nodes |
| 86 | |
| 87 | VIII - Specifying interrupt information for devices |
Stuart Yoder | 5e1e9ba | 2007-06-06 04:29:14 +1000 | [diff] [blame] | 88 | 1) interrupts property |
| 89 | 2) interrupt-parent property |
| 90 | 3) OpenPIC Interrupt Controllers |
| 91 | 4) ISA Interrupt Controllers |
| 92 | |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 93 | IX - Specifying GPIO information for devices |
Anton Vorontsov | b7ce341 | 2008-04-11 23:06:36 +1000 | [diff] [blame] | 94 | 1) gpios property |
| 95 | 2) gpio-controller nodes |
| 96 | |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 97 | X - Specifying device power management information (sleep property) |
| 98 | |
Stuart Yoder | 5e1e9ba | 2007-06-06 04:29:14 +1000 | [diff] [blame] | 99 | Appendix A - Sample SOC node for MPC8540 |
| 100 | |
| 101 | |
| 102 | Revision Information |
| 103 | ==================== |
| 104 | |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 105 | May 18, 2005: Rev 0.1 - Initial draft, no chapter III yet. |
| 106 | |
| 107 | May 19, 2005: Rev 0.2 - Add chapter III and bits & pieces here or |
| 108 | clarifies the fact that a lot of things are |
| 109 | optional, the kernel only requires a very |
| 110 | small device tree, though it is encouraged |
| 111 | to provide an as complete one as possible. |
| 112 | |
| 113 | May 24, 2005: Rev 0.3 - Precise that DT block has to be in RAM |
| 114 | - Misc fixes |
| 115 | - Define version 3 and new format version 16 |
| 116 | for the DT block (version 16 needs kernel |
| 117 | patches, will be fwd separately). |
| 118 | String block now has a size, and full path |
| 119 | is replaced by unit name for more |
| 120 | compactness. |
| 121 | linux,phandle is made optional, only nodes |
| 122 | that are referenced by other nodes need it. |
| 123 | "name" property is now automatically |
| 124 | deduced from the unit name |
| 125 | |
| 126 | June 1, 2005: Rev 0.4 - Correct confusion between OF_DT_END and |
| 127 | OF_DT_END_NODE in structure definition. |
| 128 | - Change version 16 format to always align |
| 129 | property data to 4 bytes. Since tokens are |
| 130 | already aligned, that means no specific |
Matt LaPlante | 5d3f083 | 2006-11-30 05:21:10 +0100 | [diff] [blame] | 131 | required alignment between property size |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 132 | and property data. The old style variable |
| 133 | alignment would make it impossible to do |
| 134 | "simple" insertion of properties using |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 135 | memmove (thanks Milton for |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 136 | noticing). Updated kernel patch as well |
Matt LaPlante | 5d3f083 | 2006-11-30 05:21:10 +0100 | [diff] [blame] | 137 | - Correct a few more alignment constraints |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 138 | - Add a chapter about the device-tree |
| 139 | compiler and the textural representation of |
| 140 | the tree that can be "compiled" by dtc. |
| 141 | |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 142 | November 21, 2005: Rev 0.5 |
| 143 | - Additions/generalizations for 32-bit |
| 144 | - Changed to reflect the new arch/powerpc |
| 145 | structure |
| 146 | - Added chapter VI |
| 147 | |
| 148 | |
| 149 | ToDo: |
| 150 | - Add some definitions of interrupt tree (simple/complex) |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 151 | - Add some definitions for PCI host bridges |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 152 | - Add some common address format examples |
| 153 | - Add definitions for standard properties and "compatible" |
| 154 | names for cells that are not already defined by the existing |
| 155 | OF spec. |
| 156 | - Compare FSL SOC use of PCI to standard and make sure no new |
| 157 | node definition required. |
| 158 | - Add more information about node definitions for SOC devices |
| 159 | that currently have no standard, like the FSL CPM. |
| 160 | |
| 161 | |
| 162 | I - Introduction |
| 163 | ================ |
| 164 | |
| 165 | During the recent development of the Linux/ppc64 kernel, and more |
| 166 | specifically, the addition of new platform types outside of the old |
| 167 | IBM pSeries/iSeries pair, it was decided to enforce some strict rules |
| 168 | regarding the kernel entry and bootloader <-> kernel interfaces, in |
| 169 | order to avoid the degeneration that had become the ppc32 kernel entry |
| 170 | point and the way a new platform should be added to the kernel. The |
| 171 | legacy iSeries platform breaks those rules as it predates this scheme, |
| 172 | but no new board support will be accepted in the main tree that |
| 173 | doesn't follows them properly. In addition, since the advent of the |
| 174 | arch/powerpc merged architecture for ppc32 and ppc64, new 32-bit |
| 175 | platforms and 32-bit platforms which move into arch/powerpc will be |
| 176 | required to use these rules as well. |
| 177 | |
| 178 | The main requirement that will be defined in more detail below is |
| 179 | the presence of a device-tree whose format is defined after Open |
| 180 | Firmware specification. However, in order to make life easier |
| 181 | to embedded board vendors, the kernel doesn't require the device-tree |
| 182 | to represent every device in the system and only requires some nodes |
| 183 | and properties to be present. This will be described in detail in |
| 184 | section III, but, for example, the kernel does not require you to |
| 185 | create a node for every PCI device in the system. It is a requirement |
| 186 | to have a node for PCI host bridges in order to provide interrupt |
| 187 | routing informations and memory/IO ranges, among others. It is also |
| 188 | recommended to define nodes for on chip devices and other busses that |
| 189 | don't specifically fit in an existing OF specification. This creates a |
| 190 | great flexibility in the way the kernel can then probe those and match |
| 191 | drivers to device, without having to hard code all sorts of tables. It |
| 192 | also makes it more flexible for board vendors to do minor hardware |
| 193 | upgrades without significantly impacting the kernel code or cluttering |
| 194 | it with special cases. |
| 195 | |
| 196 | |
| 197 | 1) Entry point for arch/powerpc |
| 198 | ------------------------------- |
| 199 | |
| 200 | There is one and one single entry point to the kernel, at the start |
| 201 | of the kernel image. That entry point supports two calling |
| 202 | conventions: |
| 203 | |
| 204 | a) Boot from Open Firmware. If your firmware is compatible |
| 205 | with Open Firmware (IEEE 1275) or provides an OF compatible |
| 206 | client interface API (support for "interpret" callback of |
| 207 | forth words isn't required), you can enter the kernel with: |
| 208 | |
| 209 | r5 : OF callback pointer as defined by IEEE 1275 |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 210 | bindings to powerpc. Only the 32-bit client interface |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 211 | is currently supported |
| 212 | |
| 213 | r3, r4 : address & length of an initrd if any or 0 |
| 214 | |
| 215 | The MMU is either on or off; the kernel will run the |
| 216 | trampoline located in arch/powerpc/kernel/prom_init.c to |
| 217 | extract the device-tree and other information from open |
| 218 | firmware and build a flattened device-tree as described |
| 219 | in b). prom_init() will then re-enter the kernel using |
| 220 | the second method. This trampoline code runs in the |
| 221 | context of the firmware, which is supposed to handle all |
| 222 | exceptions during that time. |
| 223 | |
| 224 | b) Direct entry with a flattened device-tree block. This entry |
| 225 | point is called by a) after the OF trampoline and can also be |
| 226 | called directly by a bootloader that does not support the Open |
| 227 | Firmware client interface. It is also used by "kexec" to |
| 228 | implement "hot" booting of a new kernel from a previous |
| 229 | running one. This method is what I will describe in more |
| 230 | details in this document, as method a) is simply standard Open |
| 231 | Firmware, and thus should be implemented according to the |
| 232 | various standard documents defining it and its binding to the |
| 233 | PowerPC platform. The entry point definition then becomes: |
| 234 | |
| 235 | r3 : physical pointer to the device-tree block |
| 236 | (defined in chapter II) in RAM |
| 237 | |
| 238 | r4 : physical pointer to the kernel itself. This is |
| 239 | used by the assembly code to properly disable the MMU |
| 240 | in case you are entering the kernel with MMU enabled |
| 241 | and a non-1:1 mapping. |
| 242 | |
Matt LaPlante | 2fe0ae7 | 2006-10-03 22:50:39 +0200 | [diff] [blame] | 243 | r5 : NULL (as to differentiate with method a) |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 244 | |
| 245 | Note about SMP entry: Either your firmware puts your other |
| 246 | CPUs in some sleep loop or spin loop in ROM where you can get |
| 247 | them out via a soft reset or some other means, in which case |
| 248 | you don't need to care, or you'll have to enter the kernel |
| 249 | with all CPUs. The way to do that with method b) will be |
| 250 | described in a later revision of this document. |
| 251 | |
| 252 | |
| 253 | 2) Board support |
| 254 | ---------------- |
| 255 | |
| 256 | 64-bit kernels: |
| 257 | |
| 258 | Board supports (platforms) are not exclusive config options. An |
| 259 | arbitrary set of board supports can be built in a single kernel |
| 260 | image. The kernel will "know" what set of functions to use for a |
| 261 | given platform based on the content of the device-tree. Thus, you |
| 262 | should: |
| 263 | |
| 264 | a) add your platform support as a _boolean_ option in |
| 265 | arch/powerpc/Kconfig, following the example of PPC_PSERIES, |
| 266 | PPC_PMAC and PPC_MAPLE. The later is probably a good |
| 267 | example of a board support to start from. |
| 268 | |
| 269 | b) create your main platform file as |
| 270 | "arch/powerpc/platforms/myplatform/myboard_setup.c" and add it |
| 271 | to the Makefile under the condition of your CONFIG_ |
| 272 | option. This file will define a structure of type "ppc_md" |
| 273 | containing the various callbacks that the generic code will |
| 274 | use to get to your platform specific code |
| 275 | |
| 276 | c) Add a reference to your "ppc_md" structure in the |
| 277 | "machines" table in arch/powerpc/kernel/setup_64.c if you are |
| 278 | a 64-bit platform. |
| 279 | |
| 280 | d) request and get assigned a platform number (see PLATFORM_* |
Stephen Rothwell | b8b572e | 2008-08-01 15:20:30 +1000 | [diff] [blame] | 281 | constants in arch/powerpc/include/asm/processor.h |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 282 | |
| 283 | 32-bit embedded kernels: |
| 284 | |
| 285 | Currently, board support is essentially an exclusive config option. |
| 286 | The kernel is configured for a single platform. Part of the reason |
| 287 | for this is to keep kernels on embedded systems small and efficient; |
| 288 | part of this is due to the fact the code is already that way. In the |
| 289 | future, a kernel may support multiple platforms, but only if the |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 290 | platforms feature the same core architecture. A single kernel build |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 291 | cannot support both configurations with Book E and configurations |
| 292 | with classic Powerpc architectures. |
| 293 | |
| 294 | 32-bit embedded platforms that are moved into arch/powerpc using a |
| 295 | flattened device tree should adopt the merged tree practice of |
| 296 | setting ppc_md up dynamically, even though the kernel is currently |
| 297 | built with support for only a single platform at a time. This allows |
| 298 | unification of the setup code, and will make it easier to go to a |
| 299 | multiple-platform-support model in the future. |
| 300 | |
| 301 | NOTE: I believe the above will be true once Ben's done with the merge |
| 302 | of the boot sequences.... someone speak up if this is wrong! |
| 303 | |
| 304 | To add a 32-bit embedded platform support, follow the instructions |
| 305 | for 64-bit platforms above, with the exception that the Kconfig |
| 306 | option should be set up such that the kernel builds exclusively for |
| 307 | the platform selected. The processor type for the platform should |
| 308 | enable another config option to select the specific board |
| 309 | supported. |
| 310 | |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 311 | NOTE: If Ben doesn't merge the setup files, may need to change this to |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 312 | point to setup_32.c |
| 313 | |
| 314 | |
| 315 | I will describe later the boot process and various callbacks that |
| 316 | your platform should implement. |
| 317 | |
| 318 | |
| 319 | II - The DT block format |
| 320 | ======================== |
| 321 | |
| 322 | |
| 323 | This chapter defines the actual format of the flattened device-tree |
| 324 | passed to the kernel. The actual content of it and kernel requirements |
| 325 | are described later. You can find example of code manipulating that |
| 326 | format in various places, including arch/powerpc/kernel/prom_init.c |
| 327 | which will generate a flattened device-tree from the Open Firmware |
| 328 | representation, or the fs2dt utility which is part of the kexec tools |
| 329 | which will generate one from a filesystem representation. It is |
| 330 | expected that a bootloader like uboot provides a bit more support, |
| 331 | that will be discussed later as well. |
| 332 | |
| 333 | Note: The block has to be in main memory. It has to be accessible in |
| 334 | both real mode and virtual mode with no mapping other than main |
| 335 | memory. If you are writing a simple flash bootloader, it should copy |
| 336 | the block to RAM before passing it to the kernel. |
| 337 | |
| 338 | |
| 339 | 1) Header |
| 340 | --------- |
| 341 | |
| 342 | The kernel is entered with r3 pointing to an area of memory that is |
Stephen Rothwell | b8b572e | 2008-08-01 15:20:30 +1000 | [diff] [blame] | 343 | roughly described in arch/powerpc/include/asm/prom.h by the structure |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 344 | boot_param_header: |
| 345 | |
| 346 | struct boot_param_header { |
| 347 | u32 magic; /* magic word OF_DT_HEADER */ |
| 348 | u32 totalsize; /* total size of DT block */ |
| 349 | u32 off_dt_struct; /* offset to structure */ |
| 350 | u32 off_dt_strings; /* offset to strings */ |
| 351 | u32 off_mem_rsvmap; /* offset to memory reserve map |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 352 | */ |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 353 | u32 version; /* format version */ |
| 354 | u32 last_comp_version; /* last compatible version */ |
| 355 | |
| 356 | /* version 2 fields below */ |
| 357 | u32 boot_cpuid_phys; /* Which physical CPU id we're |
| 358 | booting on */ |
| 359 | /* version 3 fields below */ |
| 360 | u32 size_dt_strings; /* size of the strings block */ |
David Gibson | 0e0293c | 2007-03-14 11:50:40 +1100 | [diff] [blame] | 361 | |
| 362 | /* version 17 fields below */ |
| 363 | u32 size_dt_struct; /* size of the DT structure block */ |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 364 | }; |
| 365 | |
| 366 | Along with the constants: |
| 367 | |
| 368 | /* Definitions used by the flattened device tree */ |
| 369 | #define OF_DT_HEADER 0xd00dfeed /* 4: version, |
| 370 | 4: total size */ |
| 371 | #define OF_DT_BEGIN_NODE 0x1 /* Start node: full name |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 372 | */ |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 373 | #define OF_DT_END_NODE 0x2 /* End node */ |
| 374 | #define OF_DT_PROP 0x3 /* Property: name off, |
| 375 | size, content */ |
| 376 | #define OF_DT_END 0x9 |
| 377 | |
| 378 | All values in this header are in big endian format, the various |
| 379 | fields in this header are defined more precisely below. All |
| 380 | "offset" values are in bytes from the start of the header; that is |
| 381 | from the value of r3. |
| 382 | |
| 383 | - magic |
| 384 | |
| 385 | This is a magic value that "marks" the beginning of the |
| 386 | device-tree block header. It contains the value 0xd00dfeed and is |
| 387 | defined by the constant OF_DT_HEADER |
| 388 | |
| 389 | - totalsize |
| 390 | |
| 391 | This is the total size of the DT block including the header. The |
| 392 | "DT" block should enclose all data structures defined in this |
| 393 | chapter (who are pointed to by offsets in this header). That is, |
| 394 | the device-tree structure, strings, and the memory reserve map. |
| 395 | |
| 396 | - off_dt_struct |
| 397 | |
| 398 | This is an offset from the beginning of the header to the start |
| 399 | of the "structure" part the device tree. (see 2) device tree) |
| 400 | |
| 401 | - off_dt_strings |
| 402 | |
| 403 | This is an offset from the beginning of the header to the start |
| 404 | of the "strings" part of the device-tree |
| 405 | |
| 406 | - off_mem_rsvmap |
| 407 | |
| 408 | This is an offset from the beginning of the header to the start |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 409 | of the reserved memory map. This map is a list of pairs of 64- |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 410 | bit integers. Each pair is a physical address and a size. The |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 411 | list is terminated by an entry of size 0. This map provides the |
| 412 | kernel with a list of physical memory areas that are "reserved" |
| 413 | and thus not to be used for memory allocations, especially during |
| 414 | early initialization. The kernel needs to allocate memory during |
| 415 | boot for things like un-flattening the device-tree, allocating an |
| 416 | MMU hash table, etc... Those allocations must be done in such a |
| 417 | way to avoid overriding critical things like, on Open Firmware |
| 418 | capable machines, the RTAS instance, or on some pSeries, the TCE |
| 419 | tables used for the iommu. Typically, the reserve map should |
| 420 | contain _at least_ this DT block itself (header,total_size). If |
| 421 | you are passing an initrd to the kernel, you should reserve it as |
| 422 | well. You do not need to reserve the kernel image itself. The map |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 423 | should be 64-bit aligned. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 424 | |
| 425 | - version |
| 426 | |
| 427 | This is the version of this structure. Version 1 stops |
| 428 | here. Version 2 adds an additional field boot_cpuid_phys. |
| 429 | Version 3 adds the size of the strings block, allowing the kernel |
| 430 | to reallocate it easily at boot and free up the unused flattened |
| 431 | structure after expansion. Version 16 introduces a new more |
| 432 | "compact" format for the tree itself that is however not backward |
David Gibson | 0e0293c | 2007-03-14 11:50:40 +1100 | [diff] [blame] | 433 | compatible. Version 17 adds an additional field, size_dt_struct, |
| 434 | allowing it to be reallocated or moved more easily (this is |
| 435 | particularly useful for bootloaders which need to make |
| 436 | adjustments to a device tree based on probed information). You |
| 437 | should always generate a structure of the highest version defined |
| 438 | at the time of your implementation. Currently that is version 17, |
| 439 | unless you explicitly aim at being backward compatible. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 440 | |
| 441 | - last_comp_version |
| 442 | |
| 443 | Last compatible version. This indicates down to what version of |
| 444 | the DT block you are backward compatible. For example, version 2 |
| 445 | is backward compatible with version 1 (that is, a kernel build |
| 446 | for version 1 will be able to boot with a version 2 format). You |
| 447 | should put a 1 in this field if you generate a device tree of |
David Gibson | 0e0293c | 2007-03-14 11:50:40 +1100 | [diff] [blame] | 448 | version 1 to 3, or 16 if you generate a tree of version 16 or 17 |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 449 | using the new unit name format. |
| 450 | |
| 451 | - boot_cpuid_phys |
| 452 | |
| 453 | This field only exist on version 2 headers. It indicate which |
| 454 | physical CPU ID is calling the kernel entry point. This is used, |
| 455 | among others, by kexec. If you are on an SMP system, this value |
| 456 | should match the content of the "reg" property of the CPU node in |
| 457 | the device-tree corresponding to the CPU calling the kernel entry |
| 458 | point (see further chapters for more informations on the required |
| 459 | device-tree contents) |
| 460 | |
David Gibson | 0e0293c | 2007-03-14 11:50:40 +1100 | [diff] [blame] | 461 | - size_dt_strings |
| 462 | |
| 463 | This field only exists on version 3 and later headers. It |
| 464 | gives the size of the "strings" section of the device tree (which |
| 465 | starts at the offset given by off_dt_strings). |
| 466 | |
| 467 | - size_dt_struct |
| 468 | |
| 469 | This field only exists on version 17 and later headers. It gives |
| 470 | the size of the "structure" section of the device tree (which |
| 471 | starts at the offset given by off_dt_struct). |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 472 | |
| 473 | So the typical layout of a DT block (though the various parts don't |
| 474 | need to be in that order) looks like this (addresses go from top to |
| 475 | bottom): |
| 476 | |
| 477 | |
| 478 | ------------------------------ |
| 479 | r3 -> | struct boot_param_header | |
| 480 | ------------------------------ |
| 481 | | (alignment gap) (*) | |
| 482 | ------------------------------ |
| 483 | | memory reserve map | |
| 484 | ------------------------------ |
| 485 | | (alignment gap) | |
| 486 | ------------------------------ |
| 487 | | | |
| 488 | | device-tree structure | |
| 489 | | | |
| 490 | ------------------------------ |
| 491 | | (alignment gap) | |
| 492 | ------------------------------ |
| 493 | | | |
| 494 | | device-tree strings | |
| 495 | | | |
| 496 | -----> ------------------------------ |
| 497 | | |
| 498 | | |
| 499 | --- (r3 + totalsize) |
| 500 | |
| 501 | (*) The alignment gaps are not necessarily present; their presence |
| 502 | and size are dependent on the various alignment requirements of |
| 503 | the individual data blocks. |
| 504 | |
| 505 | |
| 506 | 2) Device tree generalities |
| 507 | --------------------------- |
| 508 | |
| 509 | This device-tree itself is separated in two different blocks, a |
| 510 | structure block and a strings block. Both need to be aligned to a 4 |
| 511 | byte boundary. |
| 512 | |
| 513 | First, let's quickly describe the device-tree concept before detailing |
| 514 | the storage format. This chapter does _not_ describe the detail of the |
| 515 | required types of nodes & properties for the kernel, this is done |
| 516 | later in chapter III. |
| 517 | |
| 518 | The device-tree layout is strongly inherited from the definition of |
| 519 | the Open Firmware IEEE 1275 device-tree. It's basically a tree of |
| 520 | nodes, each node having two or more named properties. A property can |
| 521 | have a value or not. |
| 522 | |
| 523 | It is a tree, so each node has one and only one parent except for the |
| 524 | root node who has no parent. |
| 525 | |
| 526 | A node has 2 names. The actual node name is generally contained in a |
| 527 | property of type "name" in the node property list whose value is a |
| 528 | zero terminated string and is mandatory for version 1 to 3 of the |
David Gibson | 0e0293c | 2007-03-14 11:50:40 +1100 | [diff] [blame] | 529 | format definition (as it is in Open Firmware). Version 16 makes it |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 530 | optional as it can generate it from the unit name defined below. |
| 531 | |
Matt LaPlante | 2fe0ae7 | 2006-10-03 22:50:39 +0200 | [diff] [blame] | 532 | There is also a "unit name" that is used to differentiate nodes with |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 533 | the same name at the same level, it is usually made of the node |
Matt LaPlante | 2fe0ae7 | 2006-10-03 22:50:39 +0200 | [diff] [blame] | 534 | names, the "@" sign, and a "unit address", which definition is |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 535 | specific to the bus type the node sits on. |
| 536 | |
| 537 | The unit name doesn't exist as a property per-se but is included in |
| 538 | the device-tree structure. It is typically used to represent "path" in |
| 539 | the device-tree. More details about the actual format of these will be |
| 540 | below. |
| 541 | |
| 542 | The kernel powerpc generic code does not make any formal use of the |
| 543 | unit address (though some board support code may do) so the only real |
| 544 | requirement here for the unit address is to ensure uniqueness of |
| 545 | the node unit name at a given level of the tree. Nodes with no notion |
| 546 | of address and no possible sibling of the same name (like /memory or |
| 547 | /cpus) may omit the unit address in the context of this specification, |
| 548 | or use the "@0" default unit address. The unit name is used to define |
| 549 | a node "full path", which is the concatenation of all parent node |
| 550 | unit names separated with "/". |
| 551 | |
| 552 | The root node doesn't have a defined name, and isn't required to have |
| 553 | a name property either if you are using version 3 or earlier of the |
| 554 | format. It also has no unit address (no @ symbol followed by a unit |
| 555 | address). The root node unit name is thus an empty string. The full |
| 556 | path to the root node is "/". |
| 557 | |
| 558 | Every node which actually represents an actual device (that is, a node |
| 559 | which isn't only a virtual "container" for more nodes, like "/cpus" |
| 560 | is) is also required to have a "device_type" property indicating the |
| 561 | type of node . |
| 562 | |
| 563 | Finally, every node that can be referenced from a property in another |
| 564 | node is required to have a "linux,phandle" property. Real open |
| 565 | firmware implementations provide a unique "phandle" value for every |
| 566 | node that the "prom_init()" trampoline code turns into |
| 567 | "linux,phandle" properties. However, this is made optional if the |
| 568 | flattened device tree is used directly. An example of a node |
| 569 | referencing another node via "phandle" is when laying out the |
| 570 | interrupt tree which will be described in a further version of this |
| 571 | document. |
| 572 | |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 573 | This "linux, phandle" property is a 32-bit value that uniquely |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 574 | identifies a node. You are free to use whatever values or system of |
| 575 | values, internal pointers, or whatever to generate these, the only |
| 576 | requirement is that every node for which you provide that property has |
| 577 | a unique value for it. |
| 578 | |
| 579 | Here is an example of a simple device-tree. In this example, an "o" |
| 580 | designates a node followed by the node unit name. Properties are |
| 581 | presented with their name followed by their content. "content" |
| 582 | represents an ASCII string (zero terminated) value, while <content> |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 583 | represents a 32-bit hexadecimal value. The various nodes in this |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 584 | example will be discussed in a later chapter. At this point, it is |
| 585 | only meant to give you a idea of what a device-tree looks like. I have |
| 586 | purposefully kept the "name" and "linux,phandle" properties which |
| 587 | aren't necessary in order to give you a better idea of what the tree |
| 588 | looks like in practice. |
| 589 | |
| 590 | / o device-tree |
| 591 | |- name = "device-tree" |
| 592 | |- model = "MyBoardName" |
| 593 | |- compatible = "MyBoardFamilyName" |
| 594 | |- #address-cells = <2> |
| 595 | |- #size-cells = <2> |
| 596 | |- linux,phandle = <0> |
| 597 | | |
| 598 | o cpus |
| 599 | | | - name = "cpus" |
| 600 | | | - linux,phandle = <1> |
| 601 | | | - #address-cells = <1> |
| 602 | | | - #size-cells = <0> |
| 603 | | | |
| 604 | | o PowerPC,970@0 |
| 605 | | |- name = "PowerPC,970" |
| 606 | | |- device_type = "cpu" |
| 607 | | |- reg = <0> |
| 608 | | |- clock-frequency = <5f5e1000> |
Timur Tabi | 32aed2a | 2007-02-14 15:29:07 -0600 | [diff] [blame] | 609 | | |- 64-bit |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 610 | | |- linux,phandle = <2> |
| 611 | | |
| 612 | o memory@0 |
| 613 | | |- name = "memory" |
| 614 | | |- device_type = "memory" |
| 615 | | |- reg = <00000000 00000000 00000000 20000000> |
| 616 | | |- linux,phandle = <3> |
| 617 | | |
| 618 | o chosen |
| 619 | |- name = "chosen" |
| 620 | |- bootargs = "root=/dev/sda2" |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 621 | |- linux,phandle = <4> |
| 622 | |
| 623 | This tree is almost a minimal tree. It pretty much contains the |
| 624 | minimal set of required nodes and properties to boot a linux kernel; |
| 625 | that is, some basic model informations at the root, the CPUs, and the |
| 626 | physical memory layout. It also includes misc information passed |
| 627 | through /chosen, like in this example, the platform type (mandatory) |
| 628 | and the kernel command line arguments (optional). |
| 629 | |
Timur Tabi | 32aed2a | 2007-02-14 15:29:07 -0600 | [diff] [blame] | 630 | The /cpus/PowerPC,970@0/64-bit property is an example of a |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 631 | property without a value. All other properties have a value. The |
| 632 | significance of the #address-cells and #size-cells properties will be |
| 633 | explained in chapter IV which defines precisely the required nodes and |
| 634 | properties and their content. |
| 635 | |
| 636 | |
| 637 | 3) Device tree "structure" block |
| 638 | |
| 639 | The structure of the device tree is a linearized tree structure. The |
| 640 | "OF_DT_BEGIN_NODE" token starts a new node, and the "OF_DT_END_NODE" |
| 641 | ends that node definition. Child nodes are simply defined before |
| 642 | "OF_DT_END_NODE" (that is nodes within the node). A 'token' is a 32 |
| 643 | bit value. The tree has to be "finished" with a OF_DT_END token |
| 644 | |
| 645 | Here's the basic structure of a single node: |
| 646 | |
| 647 | * token OF_DT_BEGIN_NODE (that is 0x00000001) |
| 648 | * for version 1 to 3, this is the node full path as a zero |
| 649 | terminated string, starting with "/". For version 16 and later, |
| 650 | this is the node unit name only (or an empty string for the |
| 651 | root node) |
| 652 | * [align gap to next 4 bytes boundary] |
| 653 | * for each property: |
| 654 | * token OF_DT_PROP (that is 0x00000003) |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 655 | * 32-bit value of property value size in bytes (or 0 if no |
| 656 | value) |
| 657 | * 32-bit value of offset in string block of property name |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 658 | * property value data if any |
| 659 | * [align gap to next 4 bytes boundary] |
| 660 | * [child nodes if any] |
| 661 | * token OF_DT_END_NODE (that is 0x00000002) |
| 662 | |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 663 | So the node content can be summarized as a start token, a full path, |
Matt LaPlante | 53cb472 | 2006-10-03 22:55:17 +0200 | [diff] [blame] | 664 | a list of properties, a list of child nodes, and an end token. Every |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 665 | child node is a full node structure itself as defined above. |
| 666 | |
David Gibson | eff2ebd | 2007-06-28 15:56:26 +1000 | [diff] [blame] | 667 | NOTE: The above definition requires that all property definitions for |
| 668 | a particular node MUST precede any subnode definitions for that node. |
| 669 | Although the structure would not be ambiguous if properties and |
| 670 | subnodes were intermingled, the kernel parser requires that the |
| 671 | properties come first (up until at least 2.6.22). Any tools |
| 672 | manipulating a flattened tree must take care to preserve this |
| 673 | constraint. |
| 674 | |
Matt LaPlante | 53cb472 | 2006-10-03 22:55:17 +0200 | [diff] [blame] | 675 | 4) Device tree "strings" block |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 676 | |
| 677 | In order to save space, property names, which are generally redundant, |
| 678 | are stored separately in the "strings" block. This block is simply the |
| 679 | whole bunch of zero terminated strings for all property names |
| 680 | concatenated together. The device-tree property definitions in the |
| 681 | structure block will contain offset values from the beginning of the |
| 682 | strings block. |
| 683 | |
| 684 | |
| 685 | III - Required content of the device tree |
| 686 | ========================================= |
| 687 | |
| 688 | WARNING: All "linux,*" properties defined in this document apply only |
| 689 | to a flattened device-tree. If your platform uses a real |
| 690 | implementation of Open Firmware or an implementation compatible with |
| 691 | the Open Firmware client interface, those properties will be created |
| 692 | by the trampoline code in the kernel's prom_init() file. For example, |
| 693 | that's where you'll have to add code to detect your board model and |
Matt LaPlante | a2ffd27 | 2006-10-03 22:49:15 +0200 | [diff] [blame] | 694 | set the platform number. However, when using the flattened device-tree |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 695 | entry point, there is no prom_init() pass, and thus you have to |
| 696 | provide those properties yourself. |
| 697 | |
| 698 | |
| 699 | 1) Note about cells and address representation |
| 700 | ---------------------------------------------- |
| 701 | |
| 702 | The general rule is documented in the various Open Firmware |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 703 | documentations. If you choose to describe a bus with the device-tree |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 704 | and there exist an OF bus binding, then you should follow the |
| 705 | specification. However, the kernel does not require every single |
| 706 | device or bus to be described by the device tree. |
| 707 | |
| 708 | In general, the format of an address for a device is defined by the |
| 709 | parent bus type, based on the #address-cells and #size-cells |
Mark A. Greer | 5b14e5f | 2008-01-04 02:40:47 +1100 | [diff] [blame] | 710 | properties. Note that the parent's parent definitions of #address-cells |
Matt LaPlante | d919588 | 2008-07-25 19:45:33 -0700 | [diff] [blame] | 711 | and #size-cells are not inherited so every node with children must specify |
Mark A. Greer | 5b14e5f | 2008-01-04 02:40:47 +1100 | [diff] [blame] | 712 | them. The kernel requires the root node to have those properties defining |
| 713 | addresses format for devices directly mapped on the processor bus. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 714 | |
| 715 | Those 2 properties define 'cells' for representing an address and a |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 716 | size. A "cell" is a 32-bit number. For example, if both contain 2 |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 717 | like the example tree given above, then an address and a size are both |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 718 | composed of 2 cells, and each is a 64-bit number (cells are |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 719 | concatenated and expected to be in big endian format). Another example |
| 720 | is the way Apple firmware defines them, with 2 cells for an address |
| 721 | and one cell for a size. Most 32-bit implementations should define |
| 722 | #address-cells and #size-cells to 1, which represents a 32-bit value. |
| 723 | Some 32-bit processors allow for physical addresses greater than 32 |
| 724 | bits; these processors should define #address-cells as 2. |
| 725 | |
| 726 | "reg" properties are always a tuple of the type "address size" where |
| 727 | the number of cells of address and size is specified by the bus |
| 728 | #address-cells and #size-cells. When a bus supports various address |
| 729 | spaces and other flags relative to a given address allocation (like |
| 730 | prefetchable, etc...) those flags are usually added to the top level |
| 731 | bits of the physical address. For example, a PCI physical address is |
| 732 | made of 3 cells, the bottom two containing the actual address itself |
| 733 | while the top cell contains address space indication, flags, and pci |
| 734 | bus & device numbers. |
| 735 | |
| 736 | For busses that support dynamic allocation, it's the accepted practice |
| 737 | to then not provide the address in "reg" (keep it 0) though while |
| 738 | providing a flag indicating the address is dynamically allocated, and |
| 739 | then, to provide a separate "assigned-addresses" property that |
| 740 | contains the fully allocated addresses. See the PCI OF bindings for |
| 741 | details. |
| 742 | |
| 743 | In general, a simple bus with no address space bits and no dynamic |
| 744 | allocation is preferred if it reflects your hardware, as the existing |
| 745 | kernel address parsing functions will work out of the box. If you |
| 746 | define a bus type with a more complex address format, including things |
| 747 | like address space bits, you'll have to add a bus translator to the |
| 748 | prom_parse.c file of the recent kernels for your bus type. |
| 749 | |
Stephen Neuendorffer | e1fd186 | 2007-12-04 12:08:57 +1100 | [diff] [blame] | 750 | The "reg" property only defines addresses and sizes (if #size-cells is |
| 751 | non-0) within a given bus. In order to translate addresses upward |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 752 | (that is into parent bus addresses, and possibly into CPU physical |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 753 | addresses), all busses must contain a "ranges" property. If the |
| 754 | "ranges" property is missing at a given level, it's assumed that |
Stephen Neuendorffer | e1fd186 | 2007-12-04 12:08:57 +1100 | [diff] [blame] | 755 | translation isn't possible, i.e., the registers are not visible on the |
| 756 | parent bus. The format of the "ranges" property for a bus is a list |
| 757 | of: |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 758 | |
| 759 | bus address, parent bus address, size |
| 760 | |
| 761 | "bus address" is in the format of the bus this bus node is defining, |
| 762 | that is, for a PCI bridge, it would be a PCI address. Thus, (bus |
| 763 | address, size) defines a range of addresses for child devices. "parent |
| 764 | bus address" is in the format of the parent bus of this bus. For |
| 765 | example, for a PCI host controller, that would be a CPU address. For a |
| 766 | PCI<->ISA bridge, that would be a PCI address. It defines the base |
| 767 | address in the parent bus where the beginning of that range is mapped. |
| 768 | |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 769 | For a new 64-bit powerpc board, I recommend either the 2/2 format or |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 770 | Apple's 2/1 format which is slightly more compact since sizes usually |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 771 | fit in a single 32-bit word. New 32-bit powerpc boards should use a |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 772 | 1/1 format, unless the processor supports physical addresses greater |
| 773 | than 32-bits, in which case a 2/1 format is recommended. |
| 774 | |
Stephen Neuendorffer | e1fd186 | 2007-12-04 12:08:57 +1100 | [diff] [blame] | 775 | Alternatively, the "ranges" property may be empty, indicating that the |
| 776 | registers are visible on the parent bus using an identity mapping |
| 777 | translation. In other words, the parent bus address space is the same |
| 778 | as the child bus address space. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 779 | |
| 780 | 2) Note about "compatible" properties |
| 781 | ------------------------------------- |
| 782 | |
| 783 | These properties are optional, but recommended in devices and the root |
| 784 | node. The format of a "compatible" property is a list of concatenated |
| 785 | zero terminated strings. They allow a device to express its |
| 786 | compatibility with a family of similar devices, in some cases, |
| 787 | allowing a single driver to match against several devices regardless |
| 788 | of their actual names. |
| 789 | |
| 790 | 3) Note about "name" properties |
| 791 | ------------------------------- |
| 792 | |
| 793 | While earlier users of Open Firmware like OldWorld macintoshes tended |
| 794 | to use the actual device name for the "name" property, it's nowadays |
| 795 | considered a good practice to use a name that is closer to the device |
| 796 | class (often equal to device_type). For example, nowadays, ethernet |
| 797 | controllers are named "ethernet", an additional "model" property |
| 798 | defining precisely the chip type/model, and "compatible" property |
| 799 | defining the family in case a single driver can driver more than one |
| 800 | of these chips. However, the kernel doesn't generally put any |
| 801 | restriction on the "name" property; it is simply considered good |
| 802 | practice to follow the standard and its evolutions as closely as |
| 803 | possible. |
| 804 | |
| 805 | Note also that the new format version 16 makes the "name" property |
| 806 | optional. If it's absent for a node, then the node's unit name is then |
| 807 | used to reconstruct the name. That is, the part of the unit name |
| 808 | before the "@" sign is used (or the entire unit name if no "@" sign |
| 809 | is present). |
| 810 | |
| 811 | 4) Note about node and property names and character set |
| 812 | ------------------------------------------------------- |
| 813 | |
Matt LaPlante | a2ffd27 | 2006-10-03 22:49:15 +0200 | [diff] [blame] | 814 | While open firmware provides more flexible usage of 8859-1, this |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 815 | specification enforces more strict rules. Nodes and properties should |
| 816 | be comprised only of ASCII characters 'a' to 'z', '0' to |
| 817 | '9', ',', '.', '_', '+', '#', '?', and '-'. Node names additionally |
| 818 | allow uppercase characters 'A' to 'Z' (property names should be |
| 819 | lowercase. The fact that vendors like Apple don't respect this rule is |
| 820 | irrelevant here). Additionally, node and property names should always |
| 821 | begin with a character in the range 'a' to 'z' (or 'A' to 'Z' for node |
| 822 | names). |
| 823 | |
| 824 | The maximum number of characters for both nodes and property names |
| 825 | is 31. In the case of node names, this is only the leftmost part of |
| 826 | a unit name (the pure "name" property), it doesn't include the unit |
| 827 | address which can extend beyond that limit. |
| 828 | |
| 829 | |
| 830 | 5) Required nodes and properties |
| 831 | -------------------------------- |
| 832 | These are all that are currently required. However, it is strongly |
| 833 | recommended that you expose PCI host bridges as documented in the |
| 834 | PCI binding to open firmware, and your interrupt tree as documented |
| 835 | in OF interrupt tree specification. |
| 836 | |
| 837 | a) The root node |
| 838 | |
| 839 | The root node requires some properties to be present: |
| 840 | |
| 841 | - model : this is your board name/model |
| 842 | - #address-cells : address representation for "root" devices |
| 843 | - #size-cells: the size representation for "root" devices |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 844 | - device_type : This property shouldn't be necessary. However, if |
| 845 | you decide to create a device_type for your root node, make sure it |
| 846 | is _not_ "chrp" unless your platform is a pSeries or PAPR compliant |
| 847 | one for 64-bit, or a CHRP-type machine for 32-bit as this will |
| 848 | matched by the kernel this way. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 849 | |
| 850 | Additionally, some recommended properties are: |
| 851 | |
| 852 | - compatible : the board "family" generally finds its way here, |
| 853 | for example, if you have 2 board models with a similar layout, |
| 854 | that typically get driven by the same platform code in the |
| 855 | kernel, you would use a different "model" property but put a |
| 856 | value in "compatible". The kernel doesn't directly use that |
Stuart Yoder | 143a42d | 2007-02-16 11:30:29 -0600 | [diff] [blame] | 857 | value but it is generally useful. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 858 | |
| 859 | The root node is also generally where you add additional properties |
| 860 | specific to your board like the serial number if any, that sort of |
Matt LaPlante | 6c28f2c | 2006-10-03 22:46:31 +0200 | [diff] [blame] | 861 | thing. It is recommended that if you add any "custom" property whose |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 862 | name may clash with standard defined ones, you prefix them with your |
| 863 | vendor name and a comma. |
| 864 | |
| 865 | b) The /cpus node |
| 866 | |
| 867 | This node is the parent of all individual CPU nodes. It doesn't |
| 868 | have any specific requirements, though it's generally good practice |
| 869 | to have at least: |
| 870 | |
| 871 | #address-cells = <00000001> |
| 872 | #size-cells = <00000000> |
| 873 | |
| 874 | This defines that the "address" for a CPU is a single cell, and has |
| 875 | no meaningful size. This is not necessary but the kernel will assume |
| 876 | that format when reading the "reg" properties of a CPU node, see |
| 877 | below |
| 878 | |
| 879 | c) The /cpus/* nodes |
| 880 | |
| 881 | So under /cpus, you are supposed to create a node for every CPU on |
| 882 | the machine. There is no specific restriction on the name of the |
| 883 | CPU, though It's common practice to call it PowerPC,<name>. For |
| 884 | example, Apple uses PowerPC,G5 while IBM uses PowerPC,970FX. |
| 885 | |
| 886 | Required properties: |
| 887 | |
| 888 | - device_type : has to be "cpu" |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 889 | - reg : This is the physical CPU number, it's a single 32-bit cell |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 890 | and is also used as-is as the unit number for constructing the |
| 891 | unit name in the full path. For example, with 2 CPUs, you would |
| 892 | have the full path: |
| 893 | /cpus/PowerPC,970FX@0 |
| 894 | /cpus/PowerPC,970FX@1 |
| 895 | (unit addresses do not require leading zeroes) |
Benjamin Herrenschmidt | 20474ab | 2007-10-28 08:49:28 +1100 | [diff] [blame] | 896 | - d-cache-block-size : one cell, L1 data cache block size in bytes (*) |
| 897 | - i-cache-block-size : one cell, L1 instruction cache block size in |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 898 | bytes |
| 899 | - d-cache-size : one cell, size of L1 data cache in bytes |
| 900 | - i-cache-size : one cell, size of L1 instruction cache in bytes |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 901 | |
Benjamin Herrenschmidt | 20474ab | 2007-10-28 08:49:28 +1100 | [diff] [blame] | 902 | (*) The cache "block" size is the size on which the cache management |
| 903 | instructions operate. Historically, this document used the cache |
| 904 | "line" size here which is incorrect. The kernel will prefer the cache |
| 905 | block size and will fallback to cache line size for backward |
| 906 | compatibility. |
| 907 | |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 908 | Recommended properties: |
| 909 | |
| 910 | - timebase-frequency : a cell indicating the frequency of the |
| 911 | timebase in Hz. This is not directly used by the generic code, |
| 912 | but you are welcome to copy/paste the pSeries code for setting |
| 913 | the kernel timebase/decrementer calibration based on this |
| 914 | value. |
| 915 | - clock-frequency : a cell indicating the CPU core clock frequency |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 916 | in Hz. A new property will be defined for 64-bit values, but if |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 917 | your frequency is < 4Ghz, one cell is enough. Here as well as |
| 918 | for the above, the common code doesn't use that property, but |
| 919 | you are welcome to re-use the pSeries or Maple one. A future |
| 920 | kernel version might provide a common function for this. |
Benjamin Herrenschmidt | 20474ab | 2007-10-28 08:49:28 +1100 | [diff] [blame] | 921 | - d-cache-line-size : one cell, L1 data cache line size in bytes |
| 922 | if different from the block size |
| 923 | - i-cache-line-size : one cell, L1 instruction cache line size in |
| 924 | bytes if different from the block size |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 925 | |
| 926 | You are welcome to add any property you find relevant to your board, |
| 927 | like some information about the mechanism used to soft-reset the |
| 928 | CPUs. For example, Apple puts the GPIO number for CPU soft reset |
| 929 | lines in there as a "soft-reset" property since they start secondary |
| 930 | CPUs by soft-resetting them. |
| 931 | |
| 932 | |
| 933 | d) the /memory node(s) |
| 934 | |
| 935 | To define the physical memory layout of your board, you should |
| 936 | create one or more memory node(s). You can either create a single |
| 937 | node with all memory ranges in its reg property, or you can create |
| 938 | several nodes, as you wish. The unit address (@ part) used for the |
| 939 | full path is the address of the first range of memory defined by a |
| 940 | given node. If you use a single memory node, this will typically be |
| 941 | @0. |
| 942 | |
| 943 | Required properties: |
| 944 | |
| 945 | - device_type : has to be "memory" |
| 946 | - reg : This property contains all the physical memory ranges of |
| 947 | your board. It's a list of addresses/sizes concatenated |
| 948 | together, with the number of cells of each defined by the |
| 949 | #address-cells and #size-cells of the root node. For example, |
Matt LaPlante | 6c28f2c | 2006-10-03 22:46:31 +0200 | [diff] [blame] | 950 | with both of these properties being 2 like in the example given |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 951 | earlier, a 970 based machine with 6Gb of RAM could typically |
| 952 | have a "reg" property here that looks like: |
| 953 | |
| 954 | 00000000 00000000 00000000 80000000 |
| 955 | 00000001 00000000 00000001 00000000 |
| 956 | |
| 957 | That is a range starting at 0 of 0x80000000 bytes and a range |
| 958 | starting at 0x100000000 and of 0x100000000 bytes. You can see |
| 959 | that there is no memory covering the IO hole between 2Gb and |
| 960 | 4Gb. Some vendors prefer splitting those ranges into smaller |
| 961 | segments, but the kernel doesn't care. |
| 962 | |
| 963 | e) The /chosen node |
| 964 | |
| 965 | This node is a bit "special". Normally, that's where open firmware |
| 966 | puts some variable environment information, like the arguments, or |
Stuart Yoder | d1bff9e | 2007-02-19 11:25:05 -0600 | [diff] [blame] | 967 | the default input/output devices. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 968 | |
| 969 | This specification makes a few of these mandatory, but also defines |
| 970 | some linux-specific properties that would be normally constructed by |
| 971 | the prom_init() trampoline when booting with an OF client interface, |
| 972 | but that you have to provide yourself when using the flattened format. |
| 973 | |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 974 | Recommended properties: |
| 975 | |
| 976 | - bootargs : This zero-terminated string is passed as the kernel |
| 977 | command line |
| 978 | - linux,stdout-path : This is the full path to your standard |
| 979 | console device if any. Typically, if you have serial devices on |
| 980 | your board, you may want to put the full path to the one set as |
| 981 | the default console in the firmware here, for the kernel to pick |
Matt LaPlante | 5d3f083 | 2006-11-30 05:21:10 +0100 | [diff] [blame] | 982 | it up as its own default console. If you look at the function |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 983 | set_preferred_console() in arch/ppc64/kernel/setup.c, you'll see |
| 984 | that the kernel tries to find out the default console and has |
| 985 | knowledge of various types like 8250 serial ports. You may want |
| 986 | to extend this function to add your own. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 987 | |
| 988 | Note that u-boot creates and fills in the chosen node for platforms |
| 989 | that use it. |
| 990 | |
Stuart Yoder | d1bff9e | 2007-02-19 11:25:05 -0600 | [diff] [blame] | 991 | (Note: a practice that is now obsolete was to include a property |
| 992 | under /chosen called interrupt-controller which had a phandle value |
| 993 | that pointed to the main interrupt controller) |
| 994 | |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 995 | f) the /soc<SOCname> node |
| 996 | |
| 997 | This node is used to represent a system-on-a-chip (SOC) and must be |
| 998 | present if the processor is a SOC. The top-level soc node contains |
| 999 | information that is global to all devices on the SOC. The node name |
| 1000 | should contain a unit address for the SOC, which is the base address |
| 1001 | of the memory-mapped register set for the SOC. The name of an soc |
| 1002 | node should start with "soc", and the remainder of the name should |
| 1003 | represent the part number for the soc. For example, the MPC8540's |
| 1004 | soc node would be called "soc8540". |
| 1005 | |
| 1006 | Required properties: |
| 1007 | |
| 1008 | - device_type : Should be "soc" |
| 1009 | - ranges : Should be defined as specified in 1) to describe the |
| 1010 | translation of SOC addresses for memory mapped SOC registers. |
Becky Bruce | 7d4b95a | 2006-02-06 14:26:31 -0600 | [diff] [blame] | 1011 | - bus-frequency: Contains the bus frequency for the SOC node. |
| 1012 | Typically, the value of this field is filled in by the boot |
| 1013 | loader. |
| 1014 | |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1015 | |
| 1016 | Recommended properties: |
| 1017 | |
| 1018 | - reg : This property defines the address and size of the |
| 1019 | memory-mapped registers that are used for the SOC node itself. |
| 1020 | It does not include the child device registers - these will be |
| 1021 | defined inside each child node. The address specified in the |
| 1022 | "reg" property should match the unit address of the SOC node. |
| 1023 | - #address-cells : Address representation for "soc" devices. The |
| 1024 | format of this field may vary depending on whether or not the |
| 1025 | device registers are memory mapped. For memory mapped |
| 1026 | registers, this field represents the number of cells needed to |
| 1027 | represent the address of the registers. For SOCs that do not |
| 1028 | use MMIO, a special address format should be defined that |
| 1029 | contains enough cells to represent the required information. |
| 1030 | See 1) above for more details on defining #address-cells. |
| 1031 | - #size-cells : Size representation for "soc" devices |
| 1032 | - #interrupt-cells : Defines the width of cells used to represent |
| 1033 | interrupts. Typically this value is <2>, which includes a |
| 1034 | 32-bit number that represents the interrupt number, and a |
| 1035 | 32-bit number that represents the interrupt sense and level. |
| 1036 | This field is only needed if the SOC contains an interrupt |
| 1037 | controller. |
| 1038 | |
| 1039 | The SOC node may contain child nodes for each SOC device that the |
| 1040 | platform uses. Nodes should not be created for devices which exist |
| 1041 | on the SOC but are not used by a particular platform. See chapter VI |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 1042 | for more information on how to specify devices that are part of a SOC. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1043 | |
| 1044 | Example SOC node for the MPC8540: |
| 1045 | |
| 1046 | soc8540@e0000000 { |
| 1047 | #address-cells = <1>; |
| 1048 | #size-cells = <1>; |
| 1049 | #interrupt-cells = <2>; |
| 1050 | device_type = "soc"; |
| 1051 | ranges = <00000000 e0000000 00100000> |
| 1052 | reg = <e0000000 00003000>; |
Becky Bruce | 7d4b95a | 2006-02-06 14:26:31 -0600 | [diff] [blame] | 1053 | bus-frequency = <0>; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1054 | } |
| 1055 | |
| 1056 | |
| 1057 | |
| 1058 | IV - "dtc", the device tree compiler |
| 1059 | ==================================== |
| 1060 | |
| 1061 | |
| 1062 | dtc source code can be found at |
| 1063 | <http://ozlabs.org/~dgibson/dtc/dtc.tar.gz> |
| 1064 | |
| 1065 | WARNING: This version is still in early development stage; the |
| 1066 | resulting device-tree "blobs" have not yet been validated with the |
| 1067 | kernel. The current generated bloc lacks a useful reserve map (it will |
| 1068 | be fixed to generate an empty one, it's up to the bootloader to fill |
| 1069 | it up) among others. The error handling needs work, bugs are lurking, |
| 1070 | etc... |
| 1071 | |
| 1072 | dtc basically takes a device-tree in a given format and outputs a |
| 1073 | device-tree in another format. The currently supported formats are: |
| 1074 | |
| 1075 | Input formats: |
| 1076 | ------------- |
| 1077 | |
| 1078 | - "dtb": "blob" format, that is a flattened device-tree block |
| 1079 | with |
| 1080 | header all in a binary blob. |
| 1081 | - "dts": "source" format. This is a text file containing a |
| 1082 | "source" for a device-tree. The format is defined later in this |
| 1083 | chapter. |
| 1084 | - "fs" format. This is a representation equivalent to the |
| 1085 | output of /proc/device-tree, that is nodes are directories and |
| 1086 | properties are files |
| 1087 | |
| 1088 | Output formats: |
| 1089 | --------------- |
| 1090 | |
| 1091 | - "dtb": "blob" format |
| 1092 | - "dts": "source" format |
| 1093 | - "asm": assembly language file. This is a file that can be |
| 1094 | sourced by gas to generate a device-tree "blob". That file can |
| 1095 | then simply be added to your Makefile. Additionally, the |
Matt LaPlante | 6c28f2c | 2006-10-03 22:46:31 +0200 | [diff] [blame] | 1096 | assembly file exports some symbols that can be used. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1097 | |
| 1098 | |
| 1099 | The syntax of the dtc tool is |
| 1100 | |
| 1101 | dtc [-I <input-format>] [-O <output-format>] |
| 1102 | [-o output-filename] [-V output_version] input_filename |
| 1103 | |
| 1104 | |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 1105 | The "output_version" defines what version of the "blob" format will be |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1106 | generated. Supported versions are 1,2,3 and 16. The default is |
| 1107 | currently version 3 but that may change in the future to version 16. |
| 1108 | |
| 1109 | Additionally, dtc performs various sanity checks on the tree, like the |
Matt LaPlante | 6c28f2c | 2006-10-03 22:46:31 +0200 | [diff] [blame] | 1110 | uniqueness of linux, phandle properties, validity of strings, etc... |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1111 | |
| 1112 | The format of the .dts "source" file is "C" like, supports C and C++ |
Matt LaPlante | 6c28f2c | 2006-10-03 22:46:31 +0200 | [diff] [blame] | 1113 | style comments. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1114 | |
| 1115 | / { |
| 1116 | } |
| 1117 | |
| 1118 | The above is the "device-tree" definition. It's the only statement |
| 1119 | supported currently at the toplevel. |
| 1120 | |
| 1121 | / { |
| 1122 | property1 = "string_value"; /* define a property containing a 0 |
| 1123 | * terminated string |
| 1124 | */ |
| 1125 | |
| 1126 | property2 = <1234abcd>; /* define a property containing a |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 1127 | * numerical 32-bit value (hexadecimal) |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1128 | */ |
| 1129 | |
| 1130 | property3 = <12345678 12345678 deadbeef>; |
| 1131 | /* define a property containing 3 |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 1132 | * numerical 32-bit values (cells) in |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1133 | * hexadecimal |
| 1134 | */ |
| 1135 | property4 = [0a 0b 0c 0d de ea ad be ef]; |
| 1136 | /* define a property whose content is |
| 1137 | * an arbitrary array of bytes |
| 1138 | */ |
| 1139 | |
| 1140 | childnode@addresss { /* define a child node named "childnode" |
| 1141 | * whose unit name is "childnode at |
| 1142 | * address" |
| 1143 | */ |
| 1144 | |
| 1145 | childprop = "hello\n"; /* define a property "childprop" of |
| 1146 | * childnode (in this case, a string) |
| 1147 | */ |
| 1148 | }; |
| 1149 | }; |
| 1150 | |
| 1151 | Nodes can contain other nodes etc... thus defining the hierarchical |
| 1152 | structure of the tree. |
| 1153 | |
| 1154 | Strings support common escape sequences from C: "\n", "\t", "\r", |
| 1155 | "\(octal value)", "\x(hex value)". |
| 1156 | |
| 1157 | It is also suggested that you pipe your source file through cpp (gcc |
| 1158 | preprocessor) so you can use #include's, #define for constants, etc... |
| 1159 | |
| 1160 | Finally, various options are planned but not yet implemented, like |
| 1161 | automatic generation of phandles, labels (exported to the asm file so |
| 1162 | you can point to a property content and change it easily from whatever |
| 1163 | you link the device-tree with), label or path instead of numeric value |
| 1164 | in some cells to "point" to a node (replaced by a phandle at compile |
| 1165 | time), export of reserve map address to the asm file, ability to |
| 1166 | specify reserve map content at compile time, etc... |
| 1167 | |
| 1168 | We may provide a .h include file with common definitions of that |
| 1169 | proves useful for some properties (like building PCI properties or |
| 1170 | interrupt maps) though it may be better to add a notion of struct |
| 1171 | definitions to the compiler... |
| 1172 | |
| 1173 | |
| 1174 | V - Recommendations for a bootloader |
| 1175 | ==================================== |
| 1176 | |
| 1177 | |
| 1178 | Here are some various ideas/recommendations that have been proposed |
| 1179 | while all this has been defined and implemented. |
| 1180 | |
| 1181 | - The bootloader may want to be able to use the device-tree itself |
| 1182 | and may want to manipulate it (to add/edit some properties, |
| 1183 | like physical memory size or kernel arguments). At this point, 2 |
| 1184 | choices can be made. Either the bootloader works directly on the |
| 1185 | flattened format, or the bootloader has its own internal tree |
| 1186 | representation with pointers (similar to the kernel one) and |
| 1187 | re-flattens the tree when booting the kernel. The former is a bit |
| 1188 | more difficult to edit/modify, the later requires probably a bit |
| 1189 | more code to handle the tree structure. Note that the structure |
| 1190 | format has been designed so it's relatively easy to "insert" |
| 1191 | properties or nodes or delete them by just memmoving things |
| 1192 | around. It contains no internal offsets or pointers for this |
| 1193 | purpose. |
| 1194 | |
Matt LaPlante | d6bc8ac | 2006-10-03 22:54:15 +0200 | [diff] [blame] | 1195 | - An example of code for iterating nodes & retrieving properties |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1196 | directly from the flattened tree format can be found in the kernel |
| 1197 | file arch/ppc64/kernel/prom.c, look at scan_flat_dt() function, |
Matt LaPlante | d6bc8ac | 2006-10-03 22:54:15 +0200 | [diff] [blame] | 1198 | its usage in early_init_devtree(), and the corresponding various |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1199 | early_init_dt_scan_*() callbacks. That code can be re-used in a |
| 1200 | GPL bootloader, and as the author of that code, I would be happy |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 1201 | to discuss possible free licensing to any vendor who wishes to |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1202 | integrate all or part of this code into a non-GPL bootloader. |
| 1203 | |
| 1204 | |
| 1205 | |
| 1206 | VI - System-on-a-chip devices and nodes |
| 1207 | ======================================= |
| 1208 | |
| 1209 | Many companies are now starting to develop system-on-a-chip |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 1210 | processors, where the processor core (CPU) and many peripheral devices |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1211 | exist on a single piece of silicon. For these SOCs, an SOC node |
| 1212 | should be used that defines child nodes for the devices that make |
| 1213 | up the SOC. While platforms are not required to use this model in |
| 1214 | order to boot the kernel, it is highly encouraged that all SOC |
| 1215 | implementations define as complete a flat-device-tree as possible to |
| 1216 | describe the devices on the SOC. This will allow for the |
| 1217 | genericization of much of the kernel code. |
| 1218 | |
| 1219 | |
| 1220 | 1) Defining child nodes of an SOC |
| 1221 | --------------------------------- |
| 1222 | |
| 1223 | Each device that is part of an SOC may have its own node entry inside |
| 1224 | the SOC node. For each device that is included in the SOC, the unit |
| 1225 | address property represents the address offset for this device's |
| 1226 | memory-mapped registers in the parent's address space. The parent's |
| 1227 | address space is defined by the "ranges" property in the top-level soc |
| 1228 | node. The "reg" property for each node that exists directly under the |
| 1229 | SOC node should contain the address mapping from the child address space |
| 1230 | to the parent SOC address space and the size of the device's |
| 1231 | memory-mapped register file. |
| 1232 | |
| 1233 | For many devices that may exist inside an SOC, there are predefined |
| 1234 | specifications for the format of the device tree node. All SOC child |
| 1235 | nodes should follow these specifications, except where noted in this |
| 1236 | document. |
| 1237 | |
| 1238 | See appendix A for an example partial SOC node definition for the |
| 1239 | MPC8540. |
| 1240 | |
| 1241 | |
Stuart Yoder | 2756590 | 2007-03-02 13:42:33 -0600 | [diff] [blame] | 1242 | 2) Representing devices without a current OF specification |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1243 | ---------------------------------------------------------- |
| 1244 | |
| 1245 | Currently, there are many devices on SOCs that do not have a standard |
| 1246 | representation pre-defined as part of the open firmware |
| 1247 | specifications, mainly because the boards that contain these SOCs are |
| 1248 | not currently booted using open firmware. This section contains |
| 1249 | descriptions for the SOC devices for which new nodes have been |
| 1250 | defined; this list will expand as more and more SOC-containing |
| 1251 | platforms are moved over to use the flattened-device-tree model. |
| 1252 | |
Kumar Gala | d0fc2ea | 2008-07-07 11:28:33 -0500 | [diff] [blame] | 1253 | a) PHY nodes |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1254 | |
| 1255 | Required properties: |
| 1256 | |
| 1257 | - device_type : Should be "ethernet-phy" |
| 1258 | - interrupts : <a b> where a is the interrupt number and b is a |
| 1259 | field that represents an encoding of the sense and level |
| 1260 | information for the interrupt. This should be encoded based on |
| 1261 | the information in section 2) depending on the type of interrupt |
| 1262 | controller you have. |
| 1263 | - interrupt-parent : the phandle for the interrupt controller that |
| 1264 | services interrupts for this device. |
| 1265 | - reg : The ID number for the phy, usually a small integer |
| 1266 | - linux,phandle : phandle for this node; likely referenced by an |
| 1267 | ethernet controller node. |
| 1268 | |
| 1269 | |
| 1270 | Example: |
| 1271 | |
| 1272 | ethernet-phy@0 { |
| 1273 | linux,phandle = <2452000> |
| 1274 | interrupt-parent = <40000>; |
| 1275 | interrupts = <35 1>; |
| 1276 | reg = <0>; |
| 1277 | device_type = "ethernet-phy"; |
| 1278 | }; |
| 1279 | |
| 1280 | |
Kumar Gala | d0fc2ea | 2008-07-07 11:28:33 -0500 | [diff] [blame] | 1281 | b) Interrupt controllers |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1282 | |
| 1283 | Some SOC devices contain interrupt controllers that are different |
| 1284 | from the standard Open PIC specification. The SOC device nodes for |
| 1285 | these types of controllers should be specified just like a standard |
| 1286 | OpenPIC controller. Sense and level information should be encoded |
| 1287 | as specified in section 2) of this chapter for each device that |
| 1288 | specifies an interrupt. |
| 1289 | |
| 1290 | Example : |
| 1291 | |
| 1292 | pic@40000 { |
| 1293 | linux,phandle = <40000>; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1294 | interrupt-controller; |
| 1295 | #address-cells = <0>; |
| 1296 | reg = <40000 40000>; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1297 | compatible = "chrp,open-pic"; |
| 1298 | device_type = "open-pic"; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1299 | }; |
| 1300 | |
Kumar Gala | d0fc2ea | 2008-07-07 11:28:33 -0500 | [diff] [blame] | 1301 | c) CFI or JEDEC memory-mapped NOR flash |
Vitaly Wool | 28f9ec3 | 2006-11-20 16:32:39 +0300 | [diff] [blame] | 1302 | |
| 1303 | Flash chips (Memory Technology Devices) are often used for solid state |
| 1304 | file systems on embedded devices. |
| 1305 | |
David Gibson | 2099172 | 2007-09-07 13:23:53 +1000 | [diff] [blame] | 1306 | - compatible : should contain the specific model of flash chip(s) |
| 1307 | used, if known, followed by either "cfi-flash" or "jedec-flash" |
| 1308 | - reg : Address range of the flash chip |
| 1309 | - bank-width : Width (in bytes) of the flash bank. Equal to the |
| 1310 | device width times the number of interleaved chips. |
| 1311 | - device-width : (optional) Width of a single flash chip. If |
| 1312 | omitted, assumed to be equal to 'bank-width'. |
| 1313 | - #address-cells, #size-cells : Must be present if the flash has |
| 1314 | sub-nodes representing partitions (see below). In this case |
| 1315 | both #address-cells and #size-cells must be equal to 1. |
Vitaly Wool | 28f9ec3 | 2006-11-20 16:32:39 +0300 | [diff] [blame] | 1316 | |
David Gibson | 2099172 | 2007-09-07 13:23:53 +1000 | [diff] [blame] | 1317 | For JEDEC compatible devices, the following additional properties |
| 1318 | are defined: |
Vitaly Wool | 28f9ec3 | 2006-11-20 16:32:39 +0300 | [diff] [blame] | 1319 | |
David Gibson | 2099172 | 2007-09-07 13:23:53 +1000 | [diff] [blame] | 1320 | - vendor-id : Contains the flash chip's vendor id (1 byte). |
| 1321 | - device-id : Contains the flash chip's device id (1 byte). |
Vitaly Wool | 28f9ec3 | 2006-11-20 16:32:39 +0300 | [diff] [blame] | 1322 | |
David Gibson | 2099172 | 2007-09-07 13:23:53 +1000 | [diff] [blame] | 1323 | In addition to the information on the flash bank itself, the |
| 1324 | device tree may optionally contain additional information |
| 1325 | describing partitions of the flash address space. This can be |
| 1326 | used on platforms which have strong conventions about which |
| 1327 | portions of the flash are used for what purposes, but which don't |
| 1328 | use an on-flash partition table such as RedBoot. |
Vitaly Wool | 28f9ec3 | 2006-11-20 16:32:39 +0300 | [diff] [blame] | 1329 | |
David Gibson | 2099172 | 2007-09-07 13:23:53 +1000 | [diff] [blame] | 1330 | Each partition is represented as a sub-node of the flash device. |
| 1331 | Each node's name represents the name of the corresponding |
| 1332 | partition of the flash device. |
Vitaly Wool | 28f9ec3 | 2006-11-20 16:32:39 +0300 | [diff] [blame] | 1333 | |
David Gibson | 2099172 | 2007-09-07 13:23:53 +1000 | [diff] [blame] | 1334 | Flash partitions |
| 1335 | - reg : The partition's offset and size within the flash bank. |
| 1336 | - label : (optional) The label / name for this flash partition. |
| 1337 | If omitted, the label is taken from the node name (excluding |
| 1338 | the unit address). |
| 1339 | - read-only : (optional) This parameter, if present, is a hint to |
| 1340 | Linux that this flash partition should only be mounted |
| 1341 | read-only. This is usually used for flash partitions |
| 1342 | containing early-boot firmware images or data which should not |
| 1343 | be clobbered. |
| 1344 | |
| 1345 | Example: |
| 1346 | |
| 1347 | flash@ff000000 { |
| 1348 | compatible = "amd,am29lv128ml", "cfi-flash"; |
| 1349 | reg = <ff000000 01000000>; |
| 1350 | bank-width = <4>; |
| 1351 | device-width = <1>; |
| 1352 | #address-cells = <1>; |
| 1353 | #size-cells = <1>; |
| 1354 | fs@0 { |
| 1355 | label = "fs"; |
| 1356 | reg = <0 f80000>; |
| 1357 | }; |
| 1358 | firmware@f80000 { |
| 1359 | label ="firmware"; |
| 1360 | reg = <f80000 80000>; |
| 1361 | read-only; |
| 1362 | }; |
| 1363 | }; |
Vitaly Wool | 28f9ec3 | 2006-11-20 16:32:39 +0300 | [diff] [blame] | 1364 | |
Kumar Gala | d0fc2ea | 2008-07-07 11:28:33 -0500 | [diff] [blame] | 1365 | d) 4xx/Axon EMAC ethernet nodes |
David Gibson | 1d3bb99 | 2007-08-23 13:56:01 +1000 | [diff] [blame] | 1366 | |
| 1367 | The EMAC ethernet controller in IBM and AMCC 4xx chips, and also |
| 1368 | the Axon bridge. To operate this needs to interact with a ths |
| 1369 | special McMAL DMA controller, and sometimes an RGMII or ZMII |
| 1370 | interface. In addition to the nodes and properties described |
| 1371 | below, the node for the OPB bus on which the EMAC sits must have a |
| 1372 | correct clock-frequency property. |
| 1373 | |
| 1374 | i) The EMAC node itself |
| 1375 | |
| 1376 | Required properties: |
| 1377 | - device_type : "network" |
| 1378 | |
| 1379 | - compatible : compatible list, contains 2 entries, first is |
| 1380 | "ibm,emac-CHIP" where CHIP is the host ASIC (440gx, |
| 1381 | 405gp, Axon) and second is either "ibm,emac" or |
| 1382 | "ibm,emac4". For Axon, thus, we have: "ibm,emac-axon", |
| 1383 | "ibm,emac4" |
| 1384 | - interrupts : <interrupt mapping for EMAC IRQ and WOL IRQ> |
| 1385 | - interrupt-parent : optional, if needed for interrupt mapping |
| 1386 | - reg : <registers mapping> |
| 1387 | - local-mac-address : 6 bytes, MAC address |
| 1388 | - mal-device : phandle of the associated McMAL node |
| 1389 | - mal-tx-channel : 1 cell, index of the tx channel on McMAL associated |
| 1390 | with this EMAC |
| 1391 | - mal-rx-channel : 1 cell, index of the rx channel on McMAL associated |
| 1392 | with this EMAC |
| 1393 | - cell-index : 1 cell, hardware index of the EMAC cell on a given |
| 1394 | ASIC (typically 0x0 and 0x1 for EMAC0 and EMAC1 on |
| 1395 | each Axon chip) |
| 1396 | - max-frame-size : 1 cell, maximum frame size supported in bytes |
| 1397 | - rx-fifo-size : 1 cell, Rx fifo size in bytes for 10 and 100 Mb/sec |
| 1398 | operations. |
| 1399 | For Axon, 2048 |
| 1400 | - tx-fifo-size : 1 cell, Tx fifo size in bytes for 10 and 100 Mb/sec |
| 1401 | operations. |
| 1402 | For Axon, 2048. |
| 1403 | - fifo-entry-size : 1 cell, size of a fifo entry (used to calculate |
| 1404 | thresholds). |
| 1405 | For Axon, 0x00000010 |
| 1406 | - mal-burst-size : 1 cell, MAL burst size (used to calculate thresholds) |
| 1407 | in bytes. |
| 1408 | For Axon, 0x00000100 (I think ...) |
| 1409 | - phy-mode : string, mode of operations of the PHY interface. |
| 1410 | Supported values are: "mii", "rmii", "smii", "rgmii", |
| 1411 | "tbi", "gmii", rtbi", "sgmii". |
| 1412 | For Axon on CAB, it is "rgmii" |
| 1413 | - mdio-device : 1 cell, required iff using shared MDIO registers |
| 1414 | (440EP). phandle of the EMAC to use to drive the |
| 1415 | MDIO lines for the PHY used by this EMAC. |
| 1416 | - zmii-device : 1 cell, required iff connected to a ZMII. phandle of |
| 1417 | the ZMII device node |
| 1418 | - zmii-channel : 1 cell, required iff connected to a ZMII. Which ZMII |
| 1419 | channel or 0xffffffff if ZMII is only used for MDIO. |
| 1420 | - rgmii-device : 1 cell, required iff connected to an RGMII. phandle |
| 1421 | of the RGMII device node. |
| 1422 | For Axon: phandle of plb5/plb4/opb/rgmii |
| 1423 | - rgmii-channel : 1 cell, required iff connected to an RGMII. Which |
| 1424 | RGMII channel is used by this EMAC. |
| 1425 | Fox Axon: present, whatever value is appropriate for each |
| 1426 | EMAC, that is the content of the current (bogus) "phy-port" |
| 1427 | property. |
| 1428 | |
David Gibson | 1d3bb99 | 2007-08-23 13:56:01 +1000 | [diff] [blame] | 1429 | Optional properties: |
| 1430 | - phy-address : 1 cell, optional, MDIO address of the PHY. If absent, |
| 1431 | a search is performed. |
| 1432 | - phy-map : 1 cell, optional, bitmap of addresses to probe the PHY |
| 1433 | for, used if phy-address is absent. bit 0x00000001 is |
| 1434 | MDIO address 0. |
| 1435 | For Axon it can be absent, thouugh my current driver |
| 1436 | doesn't handle phy-address yet so for now, keep |
| 1437 | 0x00ffffff in it. |
| 1438 | - rx-fifo-size-gige : 1 cell, Rx fifo size in bytes for 1000 Mb/sec |
| 1439 | operations (if absent the value is the same as |
| 1440 | rx-fifo-size). For Axon, either absent or 2048. |
| 1441 | - tx-fifo-size-gige : 1 cell, Tx fifo size in bytes for 1000 Mb/sec |
| 1442 | operations (if absent the value is the same as |
| 1443 | tx-fifo-size). For Axon, either absent or 2048. |
| 1444 | - tah-device : 1 cell, optional. If connected to a TAH engine for |
| 1445 | offload, phandle of the TAH device node. |
| 1446 | - tah-channel : 1 cell, optional. If appropriate, channel used on the |
| 1447 | TAH engine. |
| 1448 | |
| 1449 | Example: |
| 1450 | |
| 1451 | EMAC0: ethernet@40000800 { |
David Gibson | 1d3bb99 | 2007-08-23 13:56:01 +1000 | [diff] [blame] | 1452 | device_type = "network"; |
| 1453 | compatible = "ibm,emac-440gp", "ibm,emac"; |
| 1454 | interrupt-parent = <&UIC1>; |
| 1455 | interrupts = <1c 4 1d 4>; |
| 1456 | reg = <40000800 70>; |
| 1457 | local-mac-address = [00 04 AC E3 1B 1E]; |
| 1458 | mal-device = <&MAL0>; |
| 1459 | mal-tx-channel = <0 1>; |
| 1460 | mal-rx-channel = <0>; |
| 1461 | cell-index = <0>; |
| 1462 | max-frame-size = <5dc>; |
| 1463 | rx-fifo-size = <1000>; |
| 1464 | tx-fifo-size = <800>; |
| 1465 | phy-mode = "rmii"; |
| 1466 | phy-map = <00000001>; |
| 1467 | zmii-device = <&ZMII0>; |
| 1468 | zmii-channel = <0>; |
| 1469 | }; |
| 1470 | |
| 1471 | ii) McMAL node |
| 1472 | |
| 1473 | Required properties: |
| 1474 | - device_type : "dma-controller" |
| 1475 | - compatible : compatible list, containing 2 entries, first is |
| 1476 | "ibm,mcmal-CHIP" where CHIP is the host ASIC (like |
| 1477 | emac) and the second is either "ibm,mcmal" or |
| 1478 | "ibm,mcmal2". |
| 1479 | For Axon, "ibm,mcmal-axon","ibm,mcmal2" |
| 1480 | - interrupts : <interrupt mapping for the MAL interrupts sources: |
| 1481 | 5 sources: tx_eob, rx_eob, serr, txde, rxde>. |
| 1482 | For Axon: This is _different_ from the current |
| 1483 | firmware. We use the "delayed" interrupts for txeob |
| 1484 | and rxeob. Thus we end up with mapping those 5 MPIC |
| 1485 | interrupts, all level positive sensitive: 10, 11, 32, |
| 1486 | 33, 34 (in decimal) |
| 1487 | - dcr-reg : < DCR registers range > |
| 1488 | - dcr-parent : if needed for dcr-reg |
| 1489 | - num-tx-chans : 1 cell, number of Tx channels |
| 1490 | - num-rx-chans : 1 cell, number of Rx channels |
| 1491 | |
| 1492 | iii) ZMII node |
| 1493 | |
| 1494 | Required properties: |
| 1495 | - compatible : compatible list, containing 2 entries, first is |
| 1496 | "ibm,zmii-CHIP" where CHIP is the host ASIC (like |
| 1497 | EMAC) and the second is "ibm,zmii". |
| 1498 | For Axon, there is no ZMII node. |
| 1499 | - reg : <registers mapping> |
| 1500 | |
| 1501 | iv) RGMII node |
| 1502 | |
| 1503 | Required properties: |
| 1504 | - compatible : compatible list, containing 2 entries, first is |
| 1505 | "ibm,rgmii-CHIP" where CHIP is the host ASIC (like |
| 1506 | EMAC) and the second is "ibm,rgmii". |
| 1507 | For Axon, "ibm,rgmii-axon","ibm,rgmii" |
| 1508 | - reg : <registers mapping> |
| 1509 | - revision : as provided by the RGMII new version register if |
| 1510 | available. |
| 1511 | For Axon: 0x0000012a |
| 1512 | |
Kumar Gala | d0fc2ea | 2008-07-07 11:28:33 -0500 | [diff] [blame] | 1513 | e) Xilinx IP cores |
Grant Likely | 7ae0fa49 | 2007-10-23 14:27:41 +1000 | [diff] [blame] | 1514 | |
| 1515 | The Xilinx EDK toolchain ships with a set of IP cores (devices) for use |
| 1516 | in Xilinx Spartan and Virtex FPGAs. The devices cover the whole range |
| 1517 | of standard device types (network, serial, etc.) and miscellanious |
| 1518 | devices (gpio, LCD, spi, etc). Also, since these devices are |
| 1519 | implemented within the fpga fabric every instance of the device can be |
| 1520 | synthesised with different options that change the behaviour. |
| 1521 | |
| 1522 | Each IP-core has a set of parameters which the FPGA designer can use to |
| 1523 | control how the core is synthesized. Historically, the EDK tool would |
| 1524 | extract the device parameters relevant to device drivers and copy them |
| 1525 | into an 'xparameters.h' in the form of #define symbols. This tells the |
| 1526 | device drivers how the IP cores are configured, but it requres the kernel |
| 1527 | to be recompiled every time the FPGA bitstream is resynthesized. |
| 1528 | |
| 1529 | The new approach is to export the parameters into the device tree and |
| 1530 | generate a new device tree each time the FPGA bitstream changes. The |
| 1531 | parameters which used to be exported as #defines will now become |
| 1532 | properties of the device node. In general, device nodes for IP-cores |
| 1533 | will take the following form: |
| 1534 | |
Stephen Neuendorffer | ab99eee | 2008-01-09 06:35:07 +1100 | [diff] [blame] | 1535 | (name): (generic-name)@(base-address) { |
Grant Likely | 7ae0fa49 | 2007-10-23 14:27:41 +1000 | [diff] [blame] | 1536 | compatible = "xlnx,(ip-core-name)-(HW_VER)" |
| 1537 | [, (list of compatible devices), ...]; |
| 1538 | reg = <(baseaddr) (size)>; |
| 1539 | interrupt-parent = <&interrupt-controller-phandle>; |
| 1540 | interrupts = < ... >; |
| 1541 | xlnx,(parameter1) = "(string-value)"; |
| 1542 | xlnx,(parameter2) = <(int-value)>; |
| 1543 | }; |
| 1544 | |
Stephen Neuendorffer | ab99eee | 2008-01-09 06:35:07 +1100 | [diff] [blame] | 1545 | (generic-name): an open firmware-style name that describes the |
| 1546 | generic class of device. Preferably, this is one word, such |
| 1547 | as 'serial' or 'ethernet'. |
Grant Likely | 7ae0fa49 | 2007-10-23 14:27:41 +1000 | [diff] [blame] | 1548 | (ip-core-name): the name of the ip block (given after the BEGIN |
| 1549 | directive in system.mhs). Should be in lowercase |
| 1550 | and all underscores '_' converted to dashes '-'. |
| 1551 | (name): is derived from the "PARAMETER INSTANCE" value. |
| 1552 | (parameter#): C_* parameters from system.mhs. The C_ prefix is |
| 1553 | dropped from the parameter name, the name is converted |
| 1554 | to lowercase and all underscore '_' characters are |
| 1555 | converted to dashes '-'. |
Stephen Neuendorffer | ab99eee | 2008-01-09 06:35:07 +1100 | [diff] [blame] | 1556 | (baseaddr): the baseaddr parameter value (often named C_BASEADDR). |
Grant Likely | 7ae0fa49 | 2007-10-23 14:27:41 +1000 | [diff] [blame] | 1557 | (HW_VER): from the HW_VER parameter. |
Stephen Neuendorffer | ab99eee | 2008-01-09 06:35:07 +1100 | [diff] [blame] | 1558 | (size): the address range size (often C_HIGHADDR - C_BASEADDR + 1). |
Grant Likely | 7ae0fa49 | 2007-10-23 14:27:41 +1000 | [diff] [blame] | 1559 | |
| 1560 | Typically, the compatible list will include the exact IP core version |
| 1561 | followed by an older IP core version which implements the same |
| 1562 | interface or any other device with the same interface. |
| 1563 | |
| 1564 | 'reg', 'interrupt-parent' and 'interrupts' are all optional properties. |
| 1565 | |
| 1566 | For example, the following block from system.mhs: |
| 1567 | |
| 1568 | BEGIN opb_uartlite |
| 1569 | PARAMETER INSTANCE = opb_uartlite_0 |
| 1570 | PARAMETER HW_VER = 1.00.b |
| 1571 | PARAMETER C_BAUDRATE = 115200 |
| 1572 | PARAMETER C_DATA_BITS = 8 |
| 1573 | PARAMETER C_ODD_PARITY = 0 |
| 1574 | PARAMETER C_USE_PARITY = 0 |
| 1575 | PARAMETER C_CLK_FREQ = 50000000 |
| 1576 | PARAMETER C_BASEADDR = 0xEC100000 |
| 1577 | PARAMETER C_HIGHADDR = 0xEC10FFFF |
| 1578 | BUS_INTERFACE SOPB = opb_7 |
| 1579 | PORT OPB_Clk = CLK_50MHz |
| 1580 | PORT Interrupt = opb_uartlite_0_Interrupt |
| 1581 | PORT RX = opb_uartlite_0_RX |
| 1582 | PORT TX = opb_uartlite_0_TX |
| 1583 | PORT OPB_Rst = sys_bus_reset_0 |
| 1584 | END |
| 1585 | |
| 1586 | becomes the following device tree node: |
| 1587 | |
Stephen Neuendorffer | ab99eee | 2008-01-09 06:35:07 +1100 | [diff] [blame] | 1588 | opb_uartlite_0: serial@ec100000 { |
Grant Likely | 7ae0fa49 | 2007-10-23 14:27:41 +1000 | [diff] [blame] | 1589 | device_type = "serial"; |
| 1590 | compatible = "xlnx,opb-uartlite-1.00.b"; |
| 1591 | reg = <ec100000 10000>; |
Stephen Neuendorffer | ab99eee | 2008-01-09 06:35:07 +1100 | [diff] [blame] | 1592 | interrupt-parent = <&opb_intc_0>; |
Grant Likely | 7ae0fa49 | 2007-10-23 14:27:41 +1000 | [diff] [blame] | 1593 | interrupts = <1 0>; // got this from the opb_intc parameters |
| 1594 | current-speed = <d#115200>; // standard serial device prop |
| 1595 | clock-frequency = <d#50000000>; // standard serial device prop |
| 1596 | xlnx,data-bits = <8>; |
| 1597 | xlnx,odd-parity = <0>; |
| 1598 | xlnx,use-parity = <0>; |
| 1599 | }; |
| 1600 | |
Stephen Neuendorffer | ab99eee | 2008-01-09 06:35:07 +1100 | [diff] [blame] | 1601 | Some IP cores actually implement 2 or more logical devices. In |
| 1602 | this case, the device should still describe the whole IP core with |
| 1603 | a single node and add a child node for each logical device. The |
| 1604 | ranges property can be used to translate from parent IP-core to the |
| 1605 | registers of each device. In addition, the parent node should be |
| 1606 | compatible with the bus type 'xlnx,compound', and should contain |
| 1607 | #address-cells and #size-cells, as with any other bus. (Note: this |
| 1608 | makes the assumption that both logical devices have the same bus |
| 1609 | binding. If this is not true, then separate nodes should be used |
| 1610 | for each logical device). The 'cell-index' property can be used to |
| 1611 | enumerate logical devices within an IP core. For example, the |
| 1612 | following is the system.mhs entry for the dual ps2 controller found |
| 1613 | on the ml403 reference design. |
Grant Likely | 7ae0fa49 | 2007-10-23 14:27:41 +1000 | [diff] [blame] | 1614 | |
| 1615 | BEGIN opb_ps2_dual_ref |
| 1616 | PARAMETER INSTANCE = opb_ps2_dual_ref_0 |
| 1617 | PARAMETER HW_VER = 1.00.a |
| 1618 | PARAMETER C_BASEADDR = 0xA9000000 |
| 1619 | PARAMETER C_HIGHADDR = 0xA9001FFF |
| 1620 | BUS_INTERFACE SOPB = opb_v20_0 |
| 1621 | PORT Sys_Intr1 = ps2_1_intr |
| 1622 | PORT Sys_Intr2 = ps2_2_intr |
| 1623 | PORT Clkin1 = ps2_clk_rx_1 |
| 1624 | PORT Clkin2 = ps2_clk_rx_2 |
| 1625 | PORT Clkpd1 = ps2_clk_tx_1 |
| 1626 | PORT Clkpd2 = ps2_clk_tx_2 |
| 1627 | PORT Rx1 = ps2_d_rx_1 |
| 1628 | PORT Rx2 = ps2_d_rx_2 |
| 1629 | PORT Txpd1 = ps2_d_tx_1 |
| 1630 | PORT Txpd2 = ps2_d_tx_2 |
| 1631 | END |
| 1632 | |
| 1633 | It would result in the following device tree nodes: |
| 1634 | |
Stephen Neuendorffer | ab99eee | 2008-01-09 06:35:07 +1100 | [diff] [blame] | 1635 | opb_ps2_dual_ref_0: opb-ps2-dual-ref@a9000000 { |
| 1636 | #address-cells = <1>; |
| 1637 | #size-cells = <1>; |
| 1638 | compatible = "xlnx,compound"; |
Grant Likely | 7ae0fa49 | 2007-10-23 14:27:41 +1000 | [diff] [blame] | 1639 | ranges = <0 a9000000 2000>; |
| 1640 | // If this device had extra parameters, then they would |
| 1641 | // go here. |
| 1642 | ps2@0 { |
| 1643 | compatible = "xlnx,opb-ps2-dual-ref-1.00.a"; |
| 1644 | reg = <0 40>; |
Stephen Neuendorffer | ab99eee | 2008-01-09 06:35:07 +1100 | [diff] [blame] | 1645 | interrupt-parent = <&opb_intc_0>; |
Grant Likely | 7ae0fa49 | 2007-10-23 14:27:41 +1000 | [diff] [blame] | 1646 | interrupts = <3 0>; |
| 1647 | cell-index = <0>; |
| 1648 | }; |
| 1649 | ps2@1000 { |
| 1650 | compatible = "xlnx,opb-ps2-dual-ref-1.00.a"; |
| 1651 | reg = <1000 40>; |
Stephen Neuendorffer | ab99eee | 2008-01-09 06:35:07 +1100 | [diff] [blame] | 1652 | interrupt-parent = <&opb_intc_0>; |
Grant Likely | 7ae0fa49 | 2007-10-23 14:27:41 +1000 | [diff] [blame] | 1653 | interrupts = <3 0>; |
| 1654 | cell-index = <0>; |
| 1655 | }; |
| 1656 | }; |
| 1657 | |
| 1658 | Also, the system.mhs file defines bus attachments from the processor |
| 1659 | to the devices. The device tree structure should reflect the bus |
| 1660 | attachments. Again an example; this system.mhs fragment: |
| 1661 | |
| 1662 | BEGIN ppc405_virtex4 |
| 1663 | PARAMETER INSTANCE = ppc405_0 |
| 1664 | PARAMETER HW_VER = 1.01.a |
| 1665 | BUS_INTERFACE DPLB = plb_v34_0 |
| 1666 | BUS_INTERFACE IPLB = plb_v34_0 |
| 1667 | END |
| 1668 | |
| 1669 | BEGIN opb_intc |
| 1670 | PARAMETER INSTANCE = opb_intc_0 |
| 1671 | PARAMETER HW_VER = 1.00.c |
| 1672 | PARAMETER C_BASEADDR = 0xD1000FC0 |
| 1673 | PARAMETER C_HIGHADDR = 0xD1000FDF |
| 1674 | BUS_INTERFACE SOPB = opb_v20_0 |
| 1675 | END |
| 1676 | |
| 1677 | BEGIN opb_uart16550 |
| 1678 | PARAMETER INSTANCE = opb_uart16550_0 |
| 1679 | PARAMETER HW_VER = 1.00.d |
| 1680 | PARAMETER C_BASEADDR = 0xa0000000 |
| 1681 | PARAMETER C_HIGHADDR = 0xa0001FFF |
| 1682 | BUS_INTERFACE SOPB = opb_v20_0 |
| 1683 | END |
| 1684 | |
| 1685 | BEGIN plb_v34 |
| 1686 | PARAMETER INSTANCE = plb_v34_0 |
| 1687 | PARAMETER HW_VER = 1.02.a |
| 1688 | END |
| 1689 | |
| 1690 | BEGIN plb_bram_if_cntlr |
| 1691 | PARAMETER INSTANCE = plb_bram_if_cntlr_0 |
| 1692 | PARAMETER HW_VER = 1.00.b |
| 1693 | PARAMETER C_BASEADDR = 0xFFFF0000 |
| 1694 | PARAMETER C_HIGHADDR = 0xFFFFFFFF |
| 1695 | BUS_INTERFACE SPLB = plb_v34_0 |
| 1696 | END |
| 1697 | |
| 1698 | BEGIN plb2opb_bridge |
| 1699 | PARAMETER INSTANCE = plb2opb_bridge_0 |
| 1700 | PARAMETER HW_VER = 1.01.a |
| 1701 | PARAMETER C_RNG0_BASEADDR = 0x20000000 |
| 1702 | PARAMETER C_RNG0_HIGHADDR = 0x3FFFFFFF |
| 1703 | PARAMETER C_RNG1_BASEADDR = 0x60000000 |
| 1704 | PARAMETER C_RNG1_HIGHADDR = 0x7FFFFFFF |
| 1705 | PARAMETER C_RNG2_BASEADDR = 0x80000000 |
| 1706 | PARAMETER C_RNG2_HIGHADDR = 0xBFFFFFFF |
| 1707 | PARAMETER C_RNG3_BASEADDR = 0xC0000000 |
| 1708 | PARAMETER C_RNG3_HIGHADDR = 0xDFFFFFFF |
| 1709 | BUS_INTERFACE SPLB = plb_v34_0 |
| 1710 | BUS_INTERFACE MOPB = opb_v20_0 |
| 1711 | END |
| 1712 | |
| 1713 | Gives this device tree (some properties removed for clarity): |
| 1714 | |
Stephen Neuendorffer | ab99eee | 2008-01-09 06:35:07 +1100 | [diff] [blame] | 1715 | plb@0 { |
Grant Likely | 7ae0fa49 | 2007-10-23 14:27:41 +1000 | [diff] [blame] | 1716 | #address-cells = <1>; |
| 1717 | #size-cells = <1>; |
Stephen Neuendorffer | ab99eee | 2008-01-09 06:35:07 +1100 | [diff] [blame] | 1718 | compatible = "xlnx,plb-v34-1.02.a"; |
Grant Likely | 7ae0fa49 | 2007-10-23 14:27:41 +1000 | [diff] [blame] | 1719 | device_type = "ibm,plb"; |
| 1720 | ranges; // 1:1 translation |
| 1721 | |
Stephen Neuendorffer | ab99eee | 2008-01-09 06:35:07 +1100 | [diff] [blame] | 1722 | plb_bram_if_cntrl_0: bram@ffff0000 { |
Grant Likely | 7ae0fa49 | 2007-10-23 14:27:41 +1000 | [diff] [blame] | 1723 | reg = <ffff0000 10000>; |
| 1724 | } |
| 1725 | |
Stephen Neuendorffer | ab99eee | 2008-01-09 06:35:07 +1100 | [diff] [blame] | 1726 | opb@20000000 { |
Grant Likely | 7ae0fa49 | 2007-10-23 14:27:41 +1000 | [diff] [blame] | 1727 | #address-cells = <1>; |
| 1728 | #size-cells = <1>; |
| 1729 | ranges = <20000000 20000000 20000000 |
| 1730 | 60000000 60000000 20000000 |
| 1731 | 80000000 80000000 40000000 |
| 1732 | c0000000 c0000000 20000000>; |
| 1733 | |
Stephen Neuendorffer | ab99eee | 2008-01-09 06:35:07 +1100 | [diff] [blame] | 1734 | opb_uart16550_0: serial@a0000000 { |
Grant Likely | 7ae0fa49 | 2007-10-23 14:27:41 +1000 | [diff] [blame] | 1735 | reg = <a00000000 2000>; |
| 1736 | }; |
| 1737 | |
Stephen Neuendorffer | ab99eee | 2008-01-09 06:35:07 +1100 | [diff] [blame] | 1738 | opb_intc_0: interrupt-controller@d1000fc0 { |
Grant Likely | 7ae0fa49 | 2007-10-23 14:27:41 +1000 | [diff] [blame] | 1739 | reg = <d1000fc0 20>; |
| 1740 | }; |
| 1741 | }; |
| 1742 | }; |
| 1743 | |
| 1744 | That covers the general approach to binding xilinx IP cores into the |
| 1745 | device tree. The following are bindings for specific devices: |
| 1746 | |
| 1747 | i) Xilinx ML300 Framebuffer |
| 1748 | |
| 1749 | Simple framebuffer device from the ML300 reference design (also on the |
| 1750 | ML403 reference design as well as others). |
| 1751 | |
| 1752 | Optional properties: |
| 1753 | - resolution = <xres yres> : pixel resolution of framebuffer. Some |
| 1754 | implementations use a different resolution. |
| 1755 | Default is <d#640 d#480> |
| 1756 | - virt-resolution = <xvirt yvirt> : Size of framebuffer in memory. |
| 1757 | Default is <d#1024 d#480>. |
| 1758 | - rotate-display (empty) : rotate display 180 degrees. |
| 1759 | |
| 1760 | ii) Xilinx SystemACE |
| 1761 | |
| 1762 | The Xilinx SystemACE device is used to program FPGAs from an FPGA |
| 1763 | bitstream stored on a CF card. It can also be used as a generic CF |
| 1764 | interface device. |
| 1765 | |
| 1766 | Optional properties: |
| 1767 | - 8-bit (empty) : Set this property for SystemACE in 8 bit mode |
| 1768 | |
| 1769 | iii) Xilinx EMAC and Xilinx TEMAC |
| 1770 | |
| 1771 | Xilinx Ethernet devices. In addition to general xilinx properties |
| 1772 | listed above, nodes for these devices should include a phy-handle |
| 1773 | property, and may include other common network device properties |
| 1774 | like local-mac-address. |
| 1775 | |
| 1776 | iv) Xilinx Uartlite |
| 1777 | |
| 1778 | Xilinx uartlite devices are simple fixed speed serial ports. |
| 1779 | |
Matt LaPlante | d919588 | 2008-07-25 19:45:33 -0700 | [diff] [blame] | 1780 | Required properties: |
Grant Likely | 7ae0fa49 | 2007-10-23 14:27:41 +1000 | [diff] [blame] | 1781 | - current-speed : Baud rate of uartlite |
| 1782 | |
Stephen Neuendorffer | ef66a9d | 2008-02-06 04:24:10 +1100 | [diff] [blame] | 1783 | v) Xilinx hwicap |
| 1784 | |
| 1785 | Xilinx hwicap devices provide access to the configuration logic |
| 1786 | of the FPGA through the Internal Configuration Access Port |
| 1787 | (ICAP). The ICAP enables partial reconfiguration of the FPGA, |
| 1788 | readback of the configuration information, and some control over |
| 1789 | 'warm boots' of the FPGA fabric. |
| 1790 | |
| 1791 | Required properties: |
| 1792 | - xlnx,family : The family of the FPGA, necessary since the |
| 1793 | capabilities of the underlying ICAP hardware |
| 1794 | differ between different families. May be |
| 1795 | 'virtex2p', 'virtex4', or 'virtex5'. |
| 1796 | |
John Linn | b912b5e | 2008-04-03 10:22:19 +1100 | [diff] [blame] | 1797 | vi) Xilinx Uart 16550 |
| 1798 | |
| 1799 | Xilinx UART 16550 devices are very similar to the NS16550 but with |
| 1800 | different register spacing and an offset from the base address. |
| 1801 | |
Matt LaPlante | d919588 | 2008-07-25 19:45:33 -0700 | [diff] [blame] | 1802 | Required properties: |
John Linn | b912b5e | 2008-04-03 10:22:19 +1100 | [diff] [blame] | 1803 | - clock-frequency : Frequency of the clock input |
| 1804 | - reg-offset : A value of 3 is required |
| 1805 | - reg-shift : A value of 2 is required |
| 1806 | |
Kumar Gala | d0fc2ea | 2008-07-07 11:28:33 -0500 | [diff] [blame] | 1807 | f) USB EHCI controllers |
Valentine Barshak | 41abd68 | 2007-09-25 05:27:56 +1000 | [diff] [blame] | 1808 | |
| 1809 | Required properties: |
| 1810 | - compatible : should be "usb-ehci". |
| 1811 | - reg : should contain at least address and length of the standard EHCI |
| 1812 | register set for the device. Optional platform-dependent registers |
| 1813 | (debug-port or other) can be also specified here, but only after |
| 1814 | definition of standard EHCI registers. |
| 1815 | - interrupts : one EHCI interrupt should be described here. |
| 1816 | If device registers are implemented in big endian mode, the device |
| 1817 | node should have "big-endian-regs" property. |
| 1818 | If controller implementation operates with big endian descriptors, |
| 1819 | "big-endian-desc" property should be specified. |
| 1820 | If both big endian registers and descriptors are used by the controller |
| 1821 | implementation, "big-endian" property can be specified instead of having |
| 1822 | both "big-endian-regs" and "big-endian-desc". |
| 1823 | |
| 1824 | Example (Sequoia 440EPx): |
| 1825 | ehci@e0000300 { |
| 1826 | compatible = "ibm,usb-ehci-440epx", "usb-ehci"; |
| 1827 | interrupt-parent = <&UIC0>; |
| 1828 | interrupts = <1a 4>; |
| 1829 | reg = <0 e0000300 90 0 e0000390 70>; |
| 1830 | big-endian; |
| 1831 | }; |
| 1832 | |
York Sun | 9b53a9e | 2008-04-28 02:15:34 -0700 | [diff] [blame] | 1833 | r) Freescale Display Interface Unit |
| 1834 | |
| 1835 | The Freescale DIU is a LCD controller, with proper hardware, it can also |
| 1836 | drive DVI monitors. |
| 1837 | |
| 1838 | Required properties: |
| 1839 | - compatible : should be "fsl-diu". |
| 1840 | - reg : should contain at least address and length of the DIU register |
| 1841 | set. |
| 1842 | - Interrupts : one DIU interrupt should be describe here. |
| 1843 | |
| 1844 | Example (MPC8610HPCD) |
| 1845 | display@2c000 { |
| 1846 | compatible = "fsl,diu"; |
| 1847 | reg = <0x2c000 100>; |
| 1848 | interrupts = <72 2>; |
| 1849 | interrupt-parent = <&mpic>; |
| 1850 | }; |
| 1851 | |
| 1852 | s) Freescale on board FPGA |
| 1853 | |
| 1854 | This is the memory-mapped registers for on board FPGA. |
| 1855 | |
| 1856 | Required properities: |
| 1857 | - compatible : should be "fsl,fpga-pixis". |
| 1858 | - reg : should contain the address and the lenght of the FPPGA register |
| 1859 | set. |
| 1860 | |
| 1861 | Example (MPC8610HPCD) |
| 1862 | board-control@e8000000 { |
| 1863 | compatible = "fsl,fpga-pixis"; |
| 1864 | reg = <0xe8000000 32>; |
| 1865 | }; |
Valentine Barshak | 41abd68 | 2007-09-25 05:27:56 +1000 | [diff] [blame] | 1866 | |
Laurent Pinchart | a5edecc | 2008-05-26 11:53:21 +0200 | [diff] [blame] | 1867 | r) MDIO on GPIOs |
| 1868 | |
| 1869 | Currently defined compatibles: |
| 1870 | - virtual,gpio-mdio |
| 1871 | |
| 1872 | MDC and MDIO lines connected to GPIO controllers are listed in the |
| 1873 | gpios property as described in section VIII.1 in the following order: |
| 1874 | |
| 1875 | MDC, MDIO. |
| 1876 | |
| 1877 | Example: |
| 1878 | |
| 1879 | mdio { |
| 1880 | compatible = "virtual,mdio-gpio"; |
| 1881 | #address-cells = <1>; |
| 1882 | #size-cells = <0>; |
| 1883 | gpios = <&qe_pio_a 11 |
| 1884 | &qe_pio_c 6>; |
| 1885 | }; |
| 1886 | |
Grant Likely | 79c28ac | 2008-07-11 16:17:57 -0600 | [diff] [blame] | 1887 | s) SPI (Serial Peripheral Interface) busses |
| 1888 | |
| 1889 | SPI busses can be described with a node for the SPI master device |
| 1890 | and a set of child nodes for each SPI slave on the bus. For this |
| 1891 | discussion, it is assumed that the system's SPI controller is in |
| 1892 | SPI master mode. This binding does not describe SPI controllers |
| 1893 | in slave mode. |
| 1894 | |
| 1895 | The SPI master node requires the following properties: |
| 1896 | - #address-cells - number of cells required to define a chip select |
| 1897 | address on the SPI bus. |
| 1898 | - #size-cells - should be zero. |
| 1899 | - compatible - name of SPI bus controller following generic names |
| 1900 | recommended practice. |
| 1901 | No other properties are required in the SPI bus node. It is assumed |
| 1902 | that a driver for an SPI bus device will understand that it is an SPI bus. |
| 1903 | However, the binding does not attempt to define the specific method for |
| 1904 | assigning chip select numbers. Since SPI chip select configuration is |
| 1905 | flexible and non-standardized, it is left out of this binding with the |
| 1906 | assumption that board specific platform code will be used to manage |
| 1907 | chip selects. Individual drivers can define additional properties to |
| 1908 | support describing the chip select layout. |
| 1909 | |
| 1910 | SPI slave nodes must be children of the SPI master node and can |
| 1911 | contain the following properties. |
| 1912 | - reg - (required) chip select address of device. |
| 1913 | - compatible - (required) name of SPI device following generic names |
| 1914 | recommended practice |
| 1915 | - spi-max-frequency - (required) Maximum SPI clocking speed of device in Hz |
| 1916 | - spi-cpol - (optional) Empty property indicating device requires |
| 1917 | inverse clock polarity (CPOL) mode |
| 1918 | - spi-cpha - (optional) Empty property indicating device requires |
| 1919 | shifted clock phase (CPHA) mode |
Wolfgang Ocker | f618ebf | 2008-10-15 15:00:47 +0200 | [diff] [blame^] | 1920 | - spi-cs-high - (optional) Empty property indicating device requires |
| 1921 | chip select active high |
Grant Likely | 79c28ac | 2008-07-11 16:17:57 -0600 | [diff] [blame] | 1922 | |
| 1923 | SPI example for an MPC5200 SPI bus: |
| 1924 | spi@f00 { |
| 1925 | #address-cells = <1>; |
| 1926 | #size-cells = <0>; |
| 1927 | compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi"; |
| 1928 | reg = <0xf00 0x20>; |
| 1929 | interrupts = <2 13 0 2 14 0>; |
| 1930 | interrupt-parent = <&mpc5200_pic>; |
| 1931 | |
| 1932 | ethernet-switch@0 { |
| 1933 | compatible = "micrel,ks8995m"; |
| 1934 | spi-max-frequency = <1000000>; |
| 1935 | reg = <0>; |
| 1936 | }; |
| 1937 | |
| 1938 | codec@1 { |
| 1939 | compatible = "ti,tlv320aic26"; |
| 1940 | spi-max-frequency = <100000>; |
| 1941 | reg = <1>; |
| 1942 | }; |
| 1943 | }; |
| 1944 | |
Dale Farnsworth | f5412c4 | 2008-04-08 08:12:07 +1000 | [diff] [blame] | 1945 | VII - Marvell Discovery mv64[345]6x System Controller chips |
| 1946 | =========================================================== |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1947 | |
Dale Farnsworth | f5412c4 | 2008-04-08 08:12:07 +1000 | [diff] [blame] | 1948 | The Marvell mv64[345]60 series of system controller chips contain |
| 1949 | many of the peripherals needed to implement a complete computer |
| 1950 | system. In this section, we define device tree nodes to describe |
| 1951 | the system controller chip itself and each of the peripherals |
| 1952 | which it contains. Compatible string values for each node are |
| 1953 | prefixed with the string "marvell,", for Marvell Technology Group Ltd. |
| 1954 | |
| 1955 | 1) The /system-controller node |
| 1956 | |
| 1957 | This node is used to represent the system-controller and must be |
Matt LaPlante | d919588 | 2008-07-25 19:45:33 -0700 | [diff] [blame] | 1958 | present when the system uses a system controller chip. The top-level |
Dale Farnsworth | f5412c4 | 2008-04-08 08:12:07 +1000 | [diff] [blame] | 1959 | system-controller node contains information that is global to all |
| 1960 | devices within the system controller chip. The node name begins |
| 1961 | with "system-controller" followed by the unit address, which is |
| 1962 | the base address of the memory-mapped register set for the system |
| 1963 | controller chip. |
| 1964 | |
| 1965 | Required properties: |
| 1966 | |
| 1967 | - ranges : Describes the translation of system controller addresses |
| 1968 | for memory mapped registers. |
| 1969 | - clock-frequency: Contains the main clock frequency for the system |
| 1970 | controller chip. |
| 1971 | - reg : This property defines the address and size of the |
| 1972 | memory-mapped registers contained within the system controller |
| 1973 | chip. The address specified in the "reg" property should match |
| 1974 | the unit address of the system-controller node. |
| 1975 | - #address-cells : Address representation for system controller |
| 1976 | devices. This field represents the number of cells needed to |
| 1977 | represent the address of the memory-mapped registers of devices |
| 1978 | within the system controller chip. |
| 1979 | - #size-cells : Size representation for for the memory-mapped |
| 1980 | registers within the system controller chip. |
| 1981 | - #interrupt-cells : Defines the width of cells used to represent |
| 1982 | interrupts. |
| 1983 | |
| 1984 | Optional properties: |
| 1985 | |
| 1986 | - model : The specific model of the system controller chip. Such |
| 1987 | as, "mv64360", "mv64460", or "mv64560". |
| 1988 | - compatible : A string identifying the compatibility identifiers |
| 1989 | of the system controller chip. |
| 1990 | |
| 1991 | The system-controller node contains child nodes for each system |
| 1992 | controller device that the platform uses. Nodes should not be created |
| 1993 | for devices which exist on the system controller chip but are not used |
| 1994 | |
| 1995 | Example Marvell Discovery mv64360 system-controller node: |
| 1996 | |
| 1997 | system-controller@f1000000 { /* Marvell Discovery mv64360 */ |
| 1998 | #address-cells = <1>; |
| 1999 | #size-cells = <1>; |
| 2000 | model = "mv64360"; /* Default */ |
| 2001 | compatible = "marvell,mv64360"; |
| 2002 | clock-frequency = <133333333>; |
| 2003 | reg = <0xf1000000 0x10000>; |
| 2004 | virtual-reg = <0xf1000000>; |
| 2005 | ranges = <0x88000000 0x88000000 0x1000000 /* PCI 0 I/O Space */ |
| 2006 | 0x80000000 0x80000000 0x8000000 /* PCI 0 MEM Space */ |
| 2007 | 0xa0000000 0xa0000000 0x4000000 /* User FLASH */ |
| 2008 | 0x00000000 0xf1000000 0x0010000 /* Bridge's regs */ |
| 2009 | 0xf2000000 0xf2000000 0x0040000>;/* Integrated SRAM */ |
| 2010 | |
| 2011 | [ child node definitions... ] |
| 2012 | } |
| 2013 | |
| 2014 | 2) Child nodes of /system-controller |
| 2015 | |
| 2016 | a) Marvell Discovery MDIO bus |
| 2017 | |
| 2018 | The MDIO is a bus to which the PHY devices are connected. For each |
| 2019 | device that exists on this bus, a child node should be created. See |
| 2020 | the definition of the PHY node below for an example of how to define |
| 2021 | a PHY. |
| 2022 | |
| 2023 | Required properties: |
| 2024 | - #address-cells : Should be <1> |
| 2025 | - #size-cells : Should be <0> |
| 2026 | - device_type : Should be "mdio" |
| 2027 | - compatible : Should be "marvell,mv64360-mdio" |
| 2028 | |
| 2029 | Example: |
| 2030 | |
| 2031 | mdio { |
| 2032 | #address-cells = <1>; |
| 2033 | #size-cells = <0>; |
| 2034 | device_type = "mdio"; |
| 2035 | compatible = "marvell,mv64360-mdio"; |
| 2036 | |
| 2037 | ethernet-phy@0 { |
| 2038 | ...... |
| 2039 | }; |
| 2040 | }; |
| 2041 | |
| 2042 | |
| 2043 | b) Marvell Discovery ethernet controller |
| 2044 | |
| 2045 | The Discover ethernet controller is described with two levels |
| 2046 | of nodes. The first level describes an ethernet silicon block |
| 2047 | and the second level describes up to 3 ethernet nodes within |
| 2048 | that block. The reason for the multiple levels is that the |
| 2049 | registers for the node are interleaved within a single set |
| 2050 | of registers. The "ethernet-block" level describes the |
| 2051 | shared register set, and the "ethernet" nodes describe ethernet |
| 2052 | port-specific properties. |
| 2053 | |
| 2054 | Ethernet block node |
| 2055 | |
| 2056 | Required properties: |
| 2057 | - #address-cells : <1> |
| 2058 | - #size-cells : <0> |
| 2059 | - compatible : "marvell,mv64360-eth-block" |
| 2060 | - reg : Offset and length of the register set for this block |
| 2061 | |
| 2062 | Example Discovery Ethernet block node: |
| 2063 | ethernet-block@2000 { |
| 2064 | #address-cells = <1>; |
| 2065 | #size-cells = <0>; |
| 2066 | compatible = "marvell,mv64360-eth-block"; |
| 2067 | reg = <0x2000 0x2000>; |
| 2068 | ethernet@0 { |
| 2069 | ....... |
| 2070 | }; |
| 2071 | }; |
| 2072 | |
| 2073 | Ethernet port node |
| 2074 | |
| 2075 | Required properties: |
| 2076 | - device_type : Should be "network". |
| 2077 | - compatible : Should be "marvell,mv64360-eth". |
| 2078 | - reg : Should be <0>, <1>, or <2>, according to which registers |
| 2079 | within the silicon block the device uses. |
| 2080 | - interrupts : <a> where a is the interrupt number for the port. |
| 2081 | - interrupt-parent : the phandle for the interrupt controller |
| 2082 | that services interrupts for this device. |
| 2083 | - phy : the phandle for the PHY connected to this ethernet |
| 2084 | controller. |
| 2085 | - local-mac-address : 6 bytes, MAC address |
| 2086 | |
| 2087 | Example Discovery Ethernet port node: |
| 2088 | ethernet@0 { |
| 2089 | device_type = "network"; |
| 2090 | compatible = "marvell,mv64360-eth"; |
| 2091 | reg = <0>; |
| 2092 | interrupts = <32>; |
| 2093 | interrupt-parent = <&PIC>; |
| 2094 | phy = <&PHY0>; |
| 2095 | local-mac-address = [ 00 00 00 00 00 00 ]; |
| 2096 | }; |
| 2097 | |
| 2098 | |
| 2099 | |
| 2100 | c) Marvell Discovery PHY nodes |
| 2101 | |
| 2102 | Required properties: |
| 2103 | - device_type : Should be "ethernet-phy" |
| 2104 | - interrupts : <a> where a is the interrupt number for this phy. |
| 2105 | - interrupt-parent : the phandle for the interrupt controller that |
| 2106 | services interrupts for this device. |
| 2107 | - reg : The ID number for the phy, usually a small integer |
| 2108 | |
| 2109 | Example Discovery PHY node: |
| 2110 | ethernet-phy@1 { |
| 2111 | device_type = "ethernet-phy"; |
| 2112 | compatible = "broadcom,bcm5421"; |
| 2113 | interrupts = <76>; /* GPP 12 */ |
| 2114 | interrupt-parent = <&PIC>; |
| 2115 | reg = <1>; |
| 2116 | }; |
| 2117 | |
| 2118 | |
| 2119 | d) Marvell Discovery SDMA nodes |
| 2120 | |
| 2121 | Represent DMA hardware associated with the MPSC (multiprotocol |
| 2122 | serial controllers). |
| 2123 | |
| 2124 | Required properties: |
| 2125 | - compatible : "marvell,mv64360-sdma" |
| 2126 | - reg : Offset and length of the register set for this device |
| 2127 | - interrupts : <a> where a is the interrupt number for the DMA |
| 2128 | device. |
| 2129 | - interrupt-parent : the phandle for the interrupt controller |
| 2130 | that services interrupts for this device. |
| 2131 | |
| 2132 | Example Discovery SDMA node: |
| 2133 | sdma@4000 { |
| 2134 | compatible = "marvell,mv64360-sdma"; |
| 2135 | reg = <0x4000 0xc18>; |
| 2136 | virtual-reg = <0xf1004000>; |
| 2137 | interrupts = <36>; |
| 2138 | interrupt-parent = <&PIC>; |
| 2139 | }; |
| 2140 | |
| 2141 | |
| 2142 | e) Marvell Discovery BRG nodes |
| 2143 | |
| 2144 | Represent baud rate generator hardware associated with the MPSC |
| 2145 | (multiprotocol serial controllers). |
| 2146 | |
| 2147 | Required properties: |
| 2148 | - compatible : "marvell,mv64360-brg" |
| 2149 | - reg : Offset and length of the register set for this device |
| 2150 | - clock-src : A value from 0 to 15 which selects the clock |
| 2151 | source for the baud rate generator. This value corresponds |
| 2152 | to the CLKS value in the BRGx configuration register. See |
| 2153 | the mv64x60 User's Manual. |
| 2154 | - clock-frequence : The frequency (in Hz) of the baud rate |
| 2155 | generator's input clock. |
| 2156 | - current-speed : The current speed setting (presumably by |
| 2157 | firmware) of the baud rate generator. |
| 2158 | |
| 2159 | Example Discovery BRG node: |
| 2160 | brg@b200 { |
| 2161 | compatible = "marvell,mv64360-brg"; |
| 2162 | reg = <0xb200 0x8>; |
| 2163 | clock-src = <8>; |
| 2164 | clock-frequency = <133333333>; |
| 2165 | current-speed = <9600>; |
| 2166 | }; |
| 2167 | |
| 2168 | |
| 2169 | f) Marvell Discovery CUNIT nodes |
| 2170 | |
| 2171 | Represent the Serial Communications Unit device hardware. |
| 2172 | |
| 2173 | Required properties: |
| 2174 | - reg : Offset and length of the register set for this device |
| 2175 | |
| 2176 | Example Discovery CUNIT node: |
| 2177 | cunit@f200 { |
| 2178 | reg = <0xf200 0x200>; |
| 2179 | }; |
| 2180 | |
| 2181 | |
| 2182 | g) Marvell Discovery MPSCROUTING nodes |
| 2183 | |
| 2184 | Represent the Discovery's MPSC routing hardware |
| 2185 | |
| 2186 | Required properties: |
| 2187 | - reg : Offset and length of the register set for this device |
| 2188 | |
| 2189 | Example Discovery CUNIT node: |
| 2190 | mpscrouting@b500 { |
| 2191 | reg = <0xb400 0xc>; |
| 2192 | }; |
| 2193 | |
| 2194 | |
| 2195 | h) Marvell Discovery MPSCINTR nodes |
| 2196 | |
| 2197 | Represent the Discovery's MPSC DMA interrupt hardware registers |
| 2198 | (SDMA cause and mask registers). |
| 2199 | |
| 2200 | Required properties: |
| 2201 | - reg : Offset and length of the register set for this device |
| 2202 | |
| 2203 | Example Discovery MPSCINTR node: |
| 2204 | mpsintr@b800 { |
| 2205 | reg = <0xb800 0x100>; |
| 2206 | }; |
| 2207 | |
| 2208 | |
| 2209 | i) Marvell Discovery MPSC nodes |
| 2210 | |
| 2211 | Represent the Discovery's MPSC (Multiprotocol Serial Controller) |
| 2212 | serial port. |
| 2213 | |
| 2214 | Required properties: |
| 2215 | - device_type : "serial" |
| 2216 | - compatible : "marvell,mv64360-mpsc" |
| 2217 | - reg : Offset and length of the register set for this device |
| 2218 | - sdma : the phandle for the SDMA node used by this port |
| 2219 | - brg : the phandle for the BRG node used by this port |
| 2220 | - cunit : the phandle for the CUNIT node used by this port |
| 2221 | - mpscrouting : the phandle for the MPSCROUTING node used by this port |
| 2222 | - mpscintr : the phandle for the MPSCINTR node used by this port |
| 2223 | - cell-index : the hardware index of this cell in the MPSC core |
| 2224 | - max_idle : value needed for MPSC CHR3 (Maximum Frame Length) |
| 2225 | register |
| 2226 | - interrupts : <a> where a is the interrupt number for the MPSC. |
| 2227 | - interrupt-parent : the phandle for the interrupt controller |
| 2228 | that services interrupts for this device. |
| 2229 | |
| 2230 | Example Discovery MPSCINTR node: |
| 2231 | mpsc@8000 { |
| 2232 | device_type = "serial"; |
| 2233 | compatible = "marvell,mv64360-mpsc"; |
| 2234 | reg = <0x8000 0x38>; |
| 2235 | virtual-reg = <0xf1008000>; |
| 2236 | sdma = <&SDMA0>; |
| 2237 | brg = <&BRG0>; |
| 2238 | cunit = <&CUNIT>; |
| 2239 | mpscrouting = <&MPSCROUTING>; |
| 2240 | mpscintr = <&MPSCINTR>; |
| 2241 | cell-index = <0>; |
| 2242 | max_idle = <40>; |
| 2243 | interrupts = <40>; |
| 2244 | interrupt-parent = <&PIC>; |
| 2245 | }; |
| 2246 | |
| 2247 | |
| 2248 | j) Marvell Discovery Watch Dog Timer nodes |
| 2249 | |
| 2250 | Represent the Discovery's watchdog timer hardware |
| 2251 | |
| 2252 | Required properties: |
| 2253 | - compatible : "marvell,mv64360-wdt" |
| 2254 | - reg : Offset and length of the register set for this device |
| 2255 | |
| 2256 | Example Discovery Watch Dog Timer node: |
| 2257 | wdt@b410 { |
| 2258 | compatible = "marvell,mv64360-wdt"; |
| 2259 | reg = <0xb410 0x8>; |
| 2260 | }; |
| 2261 | |
| 2262 | |
| 2263 | k) Marvell Discovery I2C nodes |
| 2264 | |
| 2265 | Represent the Discovery's I2C hardware |
| 2266 | |
| 2267 | Required properties: |
| 2268 | - device_type : "i2c" |
| 2269 | - compatible : "marvell,mv64360-i2c" |
| 2270 | - reg : Offset and length of the register set for this device |
| 2271 | - interrupts : <a> where a is the interrupt number for the I2C. |
| 2272 | - interrupt-parent : the phandle for the interrupt controller |
| 2273 | that services interrupts for this device. |
| 2274 | |
| 2275 | Example Discovery I2C node: |
| 2276 | compatible = "marvell,mv64360-i2c"; |
| 2277 | reg = <0xc000 0x20>; |
| 2278 | virtual-reg = <0xf100c000>; |
| 2279 | interrupts = <37>; |
| 2280 | interrupt-parent = <&PIC>; |
| 2281 | }; |
| 2282 | |
| 2283 | |
| 2284 | l) Marvell Discovery PIC (Programmable Interrupt Controller) nodes |
| 2285 | |
| 2286 | Represent the Discovery's PIC hardware |
| 2287 | |
| 2288 | Required properties: |
| 2289 | - #interrupt-cells : <1> |
| 2290 | - #address-cells : <0> |
| 2291 | - compatible : "marvell,mv64360-pic" |
| 2292 | - reg : Offset and length of the register set for this device |
| 2293 | - interrupt-controller |
| 2294 | |
| 2295 | Example Discovery PIC node: |
| 2296 | pic { |
| 2297 | #interrupt-cells = <1>; |
| 2298 | #address-cells = <0>; |
| 2299 | compatible = "marvell,mv64360-pic"; |
| 2300 | reg = <0x0 0x88>; |
| 2301 | interrupt-controller; |
| 2302 | }; |
| 2303 | |
| 2304 | |
| 2305 | m) Marvell Discovery MPP (Multipurpose Pins) multiplexing nodes |
| 2306 | |
| 2307 | Represent the Discovery's MPP hardware |
| 2308 | |
| 2309 | Required properties: |
| 2310 | - compatible : "marvell,mv64360-mpp" |
| 2311 | - reg : Offset and length of the register set for this device |
| 2312 | |
| 2313 | Example Discovery MPP node: |
| 2314 | mpp@f000 { |
| 2315 | compatible = "marvell,mv64360-mpp"; |
| 2316 | reg = <0xf000 0x10>; |
| 2317 | }; |
| 2318 | |
| 2319 | |
| 2320 | n) Marvell Discovery GPP (General Purpose Pins) nodes |
| 2321 | |
| 2322 | Represent the Discovery's GPP hardware |
| 2323 | |
| 2324 | Required properties: |
| 2325 | - compatible : "marvell,mv64360-gpp" |
| 2326 | - reg : Offset and length of the register set for this device |
| 2327 | |
| 2328 | Example Discovery GPP node: |
| 2329 | gpp@f000 { |
| 2330 | compatible = "marvell,mv64360-gpp"; |
| 2331 | reg = <0xf100 0x20>; |
| 2332 | }; |
| 2333 | |
| 2334 | |
| 2335 | o) Marvell Discovery PCI host bridge node |
| 2336 | |
| 2337 | Represents the Discovery's PCI host bridge device. The properties |
| 2338 | for this node conform to Rev 2.1 of the PCI Bus Binding to IEEE |
| 2339 | 1275-1994. A typical value for the compatible property is |
| 2340 | "marvell,mv64360-pci". |
| 2341 | |
| 2342 | Example Discovery PCI host bridge node |
| 2343 | pci@80000000 { |
| 2344 | #address-cells = <3>; |
| 2345 | #size-cells = <2>; |
| 2346 | #interrupt-cells = <1>; |
| 2347 | device_type = "pci"; |
| 2348 | compatible = "marvell,mv64360-pci"; |
| 2349 | reg = <0xcf8 0x8>; |
| 2350 | ranges = <0x01000000 0x0 0x0 |
| 2351 | 0x88000000 0x0 0x01000000 |
| 2352 | 0x02000000 0x0 0x80000000 |
| 2353 | 0x80000000 0x0 0x08000000>; |
| 2354 | bus-range = <0 255>; |
| 2355 | clock-frequency = <66000000>; |
| 2356 | interrupt-parent = <&PIC>; |
| 2357 | interrupt-map-mask = <0xf800 0x0 0x0 0x7>; |
| 2358 | interrupt-map = < |
| 2359 | /* IDSEL 0x0a */ |
| 2360 | 0x5000 0 0 1 &PIC 80 |
| 2361 | 0x5000 0 0 2 &PIC 81 |
| 2362 | 0x5000 0 0 3 &PIC 91 |
| 2363 | 0x5000 0 0 4 &PIC 93 |
| 2364 | |
| 2365 | /* IDSEL 0x0b */ |
| 2366 | 0x5800 0 0 1 &PIC 91 |
| 2367 | 0x5800 0 0 2 &PIC 93 |
| 2368 | 0x5800 0 0 3 &PIC 80 |
| 2369 | 0x5800 0 0 4 &PIC 81 |
| 2370 | |
| 2371 | /* IDSEL 0x0c */ |
| 2372 | 0x6000 0 0 1 &PIC 91 |
| 2373 | 0x6000 0 0 2 &PIC 93 |
| 2374 | 0x6000 0 0 3 &PIC 80 |
| 2375 | 0x6000 0 0 4 &PIC 81 |
| 2376 | |
| 2377 | /* IDSEL 0x0d */ |
| 2378 | 0x6800 0 0 1 &PIC 93 |
| 2379 | 0x6800 0 0 2 &PIC 80 |
| 2380 | 0x6800 0 0 3 &PIC 81 |
| 2381 | 0x6800 0 0 4 &PIC 91 |
| 2382 | >; |
| 2383 | }; |
| 2384 | |
| 2385 | |
| 2386 | p) Marvell Discovery CPU Error nodes |
| 2387 | |
| 2388 | Represent the Discovery's CPU error handler device. |
| 2389 | |
| 2390 | Required properties: |
| 2391 | - compatible : "marvell,mv64360-cpu-error" |
| 2392 | - reg : Offset and length of the register set for this device |
| 2393 | - interrupts : the interrupt number for this device |
| 2394 | - interrupt-parent : the phandle for the interrupt controller |
| 2395 | that services interrupts for this device. |
| 2396 | |
| 2397 | Example Discovery CPU Error node: |
| 2398 | cpu-error@0070 { |
| 2399 | compatible = "marvell,mv64360-cpu-error"; |
| 2400 | reg = <0x70 0x10 0x128 0x28>; |
| 2401 | interrupts = <3>; |
| 2402 | interrupt-parent = <&PIC>; |
| 2403 | }; |
| 2404 | |
| 2405 | |
| 2406 | q) Marvell Discovery SRAM Controller nodes |
| 2407 | |
| 2408 | Represent the Discovery's SRAM controller device. |
| 2409 | |
| 2410 | Required properties: |
| 2411 | - compatible : "marvell,mv64360-sram-ctrl" |
| 2412 | - reg : Offset and length of the register set for this device |
| 2413 | - interrupts : the interrupt number for this device |
| 2414 | - interrupt-parent : the phandle for the interrupt controller |
| 2415 | that services interrupts for this device. |
| 2416 | |
| 2417 | Example Discovery SRAM Controller node: |
| 2418 | sram-ctrl@0380 { |
| 2419 | compatible = "marvell,mv64360-sram-ctrl"; |
| 2420 | reg = <0x380 0x80>; |
| 2421 | interrupts = <13>; |
| 2422 | interrupt-parent = <&PIC>; |
| 2423 | }; |
| 2424 | |
| 2425 | |
| 2426 | r) Marvell Discovery PCI Error Handler nodes |
| 2427 | |
| 2428 | Represent the Discovery's PCI error handler device. |
| 2429 | |
| 2430 | Required properties: |
| 2431 | - compatible : "marvell,mv64360-pci-error" |
| 2432 | - reg : Offset and length of the register set for this device |
| 2433 | - interrupts : the interrupt number for this device |
| 2434 | - interrupt-parent : the phandle for the interrupt controller |
| 2435 | that services interrupts for this device. |
| 2436 | |
| 2437 | Example Discovery PCI Error Handler node: |
| 2438 | pci-error@1d40 { |
| 2439 | compatible = "marvell,mv64360-pci-error"; |
| 2440 | reg = <0x1d40 0x40 0xc28 0x4>; |
| 2441 | interrupts = <12>; |
| 2442 | interrupt-parent = <&PIC>; |
| 2443 | }; |
| 2444 | |
| 2445 | |
| 2446 | s) Marvell Discovery Memory Controller nodes |
| 2447 | |
| 2448 | Represent the Discovery's memory controller device. |
| 2449 | |
| 2450 | Required properties: |
| 2451 | - compatible : "marvell,mv64360-mem-ctrl" |
| 2452 | - reg : Offset and length of the register set for this device |
| 2453 | - interrupts : the interrupt number for this device |
| 2454 | - interrupt-parent : the phandle for the interrupt controller |
| 2455 | that services interrupts for this device. |
| 2456 | |
| 2457 | Example Discovery Memory Controller node: |
| 2458 | mem-ctrl@1400 { |
| 2459 | compatible = "marvell,mv64360-mem-ctrl"; |
| 2460 | reg = <0x1400 0x60>; |
| 2461 | interrupts = <17>; |
| 2462 | interrupt-parent = <&PIC>; |
| 2463 | }; |
| 2464 | |
| 2465 | |
| 2466 | VIII - Specifying interrupt information for devices |
Stuart Yoder | 2756590 | 2007-03-02 13:42:33 -0600 | [diff] [blame] | 2467 | =================================================== |
| 2468 | |
| 2469 | The device tree represents the busses and devices of a hardware |
| 2470 | system in a form similar to the physical bus topology of the |
| 2471 | hardware. |
| 2472 | |
| 2473 | In addition, a logical 'interrupt tree' exists which represents the |
| 2474 | hierarchy and routing of interrupts in the hardware. |
| 2475 | |
| 2476 | The interrupt tree model is fully described in the |
| 2477 | document "Open Firmware Recommended Practice: Interrupt |
| 2478 | Mapping Version 0.9". The document is available at: |
| 2479 | <http://playground.sun.com/1275/practice>. |
| 2480 | |
| 2481 | 1) interrupts property |
| 2482 | ---------------------- |
| 2483 | |
| 2484 | Devices that generate interrupts to a single interrupt controller |
| 2485 | should use the conventional OF representation described in the |
| 2486 | OF interrupt mapping documentation. |
| 2487 | |
| 2488 | Each device which generates interrupts must have an 'interrupt' |
| 2489 | property. The interrupt property value is an arbitrary number of |
| 2490 | of 'interrupt specifier' values which describe the interrupt or |
| 2491 | interrupts for the device. |
| 2492 | |
| 2493 | The encoding of an interrupt specifier is determined by the |
| 2494 | interrupt domain in which the device is located in the |
| 2495 | interrupt tree. The root of an interrupt domain specifies in |
| 2496 | its #interrupt-cells property the number of 32-bit cells |
| 2497 | required to encode an interrupt specifier. See the OF interrupt |
| 2498 | mapping documentation for a detailed description of domains. |
| 2499 | |
| 2500 | For example, the binding for the OpenPIC interrupt controller |
| 2501 | specifies an #interrupt-cells value of 2 to encode the interrupt |
| 2502 | number and level/sense information. All interrupt children in an |
| 2503 | OpenPIC interrupt domain use 2 cells per interrupt in their interrupts |
| 2504 | property. |
| 2505 | |
| 2506 | The PCI bus binding specifies a #interrupt-cell value of 1 to encode |
| 2507 | which interrupt pin (INTA,INTB,INTC,INTD) is used. |
| 2508 | |
| 2509 | 2) interrupt-parent property |
| 2510 | ---------------------------- |
| 2511 | |
| 2512 | The interrupt-parent property is specified to define an explicit |
| 2513 | link between a device node and its interrupt parent in |
| 2514 | the interrupt tree. The value of interrupt-parent is the |
| 2515 | phandle of the parent node. |
| 2516 | |
| 2517 | If the interrupt-parent property is not defined for a node, it's |
| 2518 | interrupt parent is assumed to be an ancestor in the node's |
| 2519 | _device tree_ hierarchy. |
| 2520 | |
| 2521 | 3) OpenPIC Interrupt Controllers |
| 2522 | -------------------------------- |
| 2523 | |
| 2524 | OpenPIC interrupt controllers require 2 cells to encode |
| 2525 | interrupt information. The first cell defines the interrupt |
| 2526 | number. The second cell defines the sense and level |
| 2527 | information. |
| 2528 | |
| 2529 | Sense and level information should be encoded as follows: |
| 2530 | |
| 2531 | 0 = low to high edge sensitive type enabled |
| 2532 | 1 = active low level sensitive type enabled |
| 2533 | 2 = active high level sensitive type enabled |
| 2534 | 3 = high to low edge sensitive type enabled |
| 2535 | |
| 2536 | 4) ISA Interrupt Controllers |
| 2537 | ---------------------------- |
| 2538 | |
| 2539 | ISA PIC interrupt controllers require 2 cells to encode |
| 2540 | interrupt information. The first cell defines the interrupt |
| 2541 | number. The second cell defines the sense and level |
| 2542 | information. |
| 2543 | |
| 2544 | ISA PIC interrupt controllers should adhere to the ISA PIC |
| 2545 | encodings listed below: |
| 2546 | |
| 2547 | 0 = active low level sensitive type enabled |
| 2548 | 1 = active high level sensitive type enabled |
| 2549 | 2 = high to low edge sensitive type enabled |
| 2550 | 3 = low to high edge sensitive type enabled |
| 2551 | |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2552 | IX - Specifying GPIO information for devices |
| 2553 | ============================================ |
Anton Vorontsov | b7ce341 | 2008-04-11 23:06:36 +1000 | [diff] [blame] | 2554 | |
| 2555 | 1) gpios property |
| 2556 | ----------------- |
| 2557 | |
| 2558 | Nodes that makes use of GPIOs should define them using `gpios' property, |
| 2559 | format of which is: <&gpio-controller1-phandle gpio1-specifier |
| 2560 | &gpio-controller2-phandle gpio2-specifier |
| 2561 | 0 /* holes are permitted, means no GPIO 3 */ |
| 2562 | &gpio-controller4-phandle gpio4-specifier |
| 2563 | ...>; |
| 2564 | |
| 2565 | Note that gpio-specifier length is controller dependent. |
| 2566 | |
| 2567 | gpio-specifier may encode: bank, pin position inside the bank, |
| 2568 | whether pin is open-drain and whether pin is logically inverted. |
| 2569 | |
| 2570 | Example of the node using GPIOs: |
| 2571 | |
| 2572 | node { |
| 2573 | gpios = <&qe_pio_e 18 0>; |
| 2574 | }; |
| 2575 | |
| 2576 | In this example gpio-specifier is "18 0" and encodes GPIO pin number, |
| 2577 | and empty GPIO flags as accepted by the "qe_pio_e" gpio-controller. |
| 2578 | |
| 2579 | 2) gpio-controller nodes |
| 2580 | ------------------------ |
| 2581 | |
| 2582 | Every GPIO controller node must have #gpio-cells property defined, |
| 2583 | this information will be used to translate gpio-specifiers. |
| 2584 | |
| 2585 | Example of two SOC GPIO banks defined as gpio-controller nodes: |
| 2586 | |
| 2587 | qe_pio_a: gpio-controller@1400 { |
| 2588 | #gpio-cells = <2>; |
| 2589 | compatible = "fsl,qe-pario-bank-a", "fsl,qe-pario-bank"; |
| 2590 | reg = <0x1400 0x18>; |
| 2591 | gpio-controller; |
| 2592 | }; |
| 2593 | |
| 2594 | qe_pio_e: gpio-controller@1460 { |
| 2595 | #gpio-cells = <2>; |
| 2596 | compatible = "fsl,qe-pario-bank-e", "fsl,qe-pario-bank"; |
| 2597 | reg = <0x1460 0x18>; |
| 2598 | gpio-controller; |
| 2599 | }; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2600 | |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2601 | X - Specifying Device Power Management Information (sleep property) |
| 2602 | =================================================================== |
| 2603 | |
| 2604 | Devices on SOCs often have mechanisms for placing devices into low-power |
| 2605 | states that are decoupled from the devices' own register blocks. Sometimes, |
| 2606 | this information is more complicated than a cell-index property can |
| 2607 | reasonably describe. Thus, each device controlled in such a manner |
| 2608 | may contain a "sleep" property which describes these connections. |
| 2609 | |
| 2610 | The sleep property consists of one or more sleep resources, each of |
| 2611 | which consists of a phandle to a sleep controller, followed by a |
| 2612 | controller-specific sleep specifier of zero or more cells. |
| 2613 | |
| 2614 | The semantics of what type of low power modes are possible are defined |
| 2615 | by the sleep controller. Some examples of the types of low power modes |
| 2616 | that may be supported are: |
| 2617 | |
| 2618 | - Dynamic: The device may be disabled or enabled at any time. |
| 2619 | - System Suspend: The device may request to be disabled or remain |
| 2620 | awake during system suspend, but will not be disabled until then. |
| 2621 | - Permanent: The device is disabled permanently (until the next hard |
| 2622 | reset). |
| 2623 | |
| 2624 | Some devices may share a clock domain with each other, such that they should |
| 2625 | only be suspended when none of the devices are in use. Where reasonable, |
| 2626 | such nodes should be placed on a virtual bus, where the bus has the sleep |
| 2627 | property. If the clock domain is shared among devices that cannot be |
| 2628 | reasonably grouped in this manner, then create a virtual sleep controller |
| 2629 | (similar to an interrupt nexus, except that defining a standardized |
| 2630 | sleep-map should wait until its necessity is demonstrated). |
| 2631 | |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2632 | Appendix A - Sample SOC node for MPC8540 |
| 2633 | ======================================== |
| 2634 | |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2635 | soc@e0000000 { |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2636 | #address-cells = <1>; |
| 2637 | #size-cells = <1>; |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2638 | compatible = "fsl,mpc8540-ccsr", "simple-bus"; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2639 | device_type = "soc"; |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2640 | ranges = <0x00000000 0xe0000000 0x00100000> |
Becky Bruce | 7d4b95a | 2006-02-06 14:26:31 -0600 | [diff] [blame] | 2641 | bus-frequency = <0>; |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2642 | interrupt-parent = <&pic>; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2643 | |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2644 | ethernet@24000 { |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2645 | #address-cells = <1>; |
| 2646 | #size-cells = <1>; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2647 | device_type = "network"; |
| 2648 | model = "TSEC"; |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2649 | compatible = "gianfar", "simple-bus"; |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2650 | reg = <0x24000 0x1000>; |
| 2651 | local-mac-address = [ 00 E0 0C 00 73 00 ]; |
| 2652 | interrupts = <29 2 30 2 34 2>; |
| 2653 | phy-handle = <&phy0>; |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2654 | sleep = <&pmc 00000080>; |
| 2655 | ranges; |
| 2656 | |
| 2657 | mdio@24520 { |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2658 | reg = <0x24520 0x20>; |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2659 | compatible = "fsl,gianfar-mdio"; |
| 2660 | |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2661 | phy0: ethernet-phy@0 { |
| 2662 | interrupts = <5 1>; |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2663 | reg = <0>; |
| 2664 | device_type = "ethernet-phy"; |
| 2665 | }; |
| 2666 | |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2667 | phy1: ethernet-phy@1 { |
| 2668 | interrupts = <5 1>; |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2669 | reg = <1>; |
| 2670 | device_type = "ethernet-phy"; |
| 2671 | }; |
| 2672 | |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2673 | phy3: ethernet-phy@3 { |
| 2674 | interrupts = <7 1>; |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2675 | reg = <3>; |
| 2676 | device_type = "ethernet-phy"; |
| 2677 | }; |
| 2678 | }; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2679 | }; |
| 2680 | |
| 2681 | ethernet@25000 { |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2682 | device_type = "network"; |
| 2683 | model = "TSEC"; |
| 2684 | compatible = "gianfar"; |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2685 | reg = <0x25000 0x1000>; |
| 2686 | local-mac-address = [ 00 E0 0C 00 73 01 ]; |
| 2687 | interrupts = <13 2 14 2 18 2>; |
| 2688 | phy-handle = <&phy1>; |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2689 | sleep = <&pmc 00000040>; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2690 | }; |
| 2691 | |
| 2692 | ethernet@26000 { |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2693 | device_type = "network"; |
| 2694 | model = "FEC"; |
| 2695 | compatible = "gianfar"; |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2696 | reg = <0x26000 0x1000>; |
| 2697 | local-mac-address = [ 00 E0 0C 00 73 02 ]; |
| 2698 | interrupts = <41 2>; |
| 2699 | phy-handle = <&phy3>; |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2700 | sleep = <&pmc 00000020>; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2701 | }; |
| 2702 | |
| 2703 | serial@4500 { |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2704 | #address-cells = <1>; |
| 2705 | #size-cells = <1>; |
| 2706 | compatible = "fsl,mpc8540-duart", "simple-bus"; |
| 2707 | sleep = <&pmc 00000002>; |
| 2708 | ranges; |
| 2709 | |
| 2710 | serial@4500 { |
| 2711 | device_type = "serial"; |
| 2712 | compatible = "ns16550"; |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2713 | reg = <0x4500 0x100>; |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2714 | clock-frequency = <0>; |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2715 | interrupts = <42 2>; |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2716 | }; |
| 2717 | |
| 2718 | serial@4600 { |
| 2719 | device_type = "serial"; |
| 2720 | compatible = "ns16550"; |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2721 | reg = <0x4600 0x100>; |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2722 | clock-frequency = <0>; |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2723 | interrupts = <42 2>; |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2724 | }; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2725 | }; |
| 2726 | |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2727 | pic: pic@40000 { |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2728 | interrupt-controller; |
| 2729 | #address-cells = <0>; |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2730 | #interrupt-cells = <2>; |
| 2731 | reg = <0x40000 0x40000>; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2732 | compatible = "chrp,open-pic"; |
| 2733 | device_type = "open-pic"; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2734 | }; |
| 2735 | |
| 2736 | i2c@3000 { |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2737 | interrupts = <43 2>; |
| 2738 | reg = <0x3000 0x100>; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2739 | compatible = "fsl-i2c"; |
| 2740 | dfsrr; |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2741 | sleep = <&pmc 00000004>; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2742 | }; |
| 2743 | |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2744 | pmc: power@e0070 { |
| 2745 | compatible = "fsl,mpc8540-pmc", "fsl,mpc8548-pmc"; |
Scott Wood | 7e72063 | 2008-06-25 12:07:39 -0500 | [diff] [blame] | 2746 | reg = <0xe0070 0x20>; |
Scott Wood | 2dff417 | 2008-07-11 17:31:15 -0500 | [diff] [blame] | 2747 | }; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 2748 | }; |