David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1 | Booting the Linux/ppc kernel without Open Firmware |
| 2 | -------------------------------------------------- |
| 3 | |
| 4 | |
| 5 | (c) 2005 Benjamin Herrenschmidt <benh at kernel.crashing.org>, |
| 6 | IBM Corp. |
| 7 | (c) 2005 Becky Bruce <becky.bruce at freescale.com>, |
| 8 | Freescale Semiconductor, FSL SOC and 32-bit additions |
Vitaly Wool | 28f9ec3 | 2006-11-20 16:32:39 +0300 | [diff] [blame] | 9 | (c) 2006 MontaVista Software, Inc. |
| 10 | Flash chip node definition |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 11 | |
| 12 | May 18, 2005: Rev 0.1 - Initial draft, no chapter III yet. |
| 13 | |
| 14 | May 19, 2005: Rev 0.2 - Add chapter III and bits & pieces here or |
| 15 | clarifies the fact that a lot of things are |
| 16 | optional, the kernel only requires a very |
| 17 | small device tree, though it is encouraged |
| 18 | to provide an as complete one as possible. |
| 19 | |
| 20 | May 24, 2005: Rev 0.3 - Precise that DT block has to be in RAM |
| 21 | - Misc fixes |
| 22 | - Define version 3 and new format version 16 |
| 23 | for the DT block (version 16 needs kernel |
| 24 | patches, will be fwd separately). |
| 25 | String block now has a size, and full path |
| 26 | is replaced by unit name for more |
| 27 | compactness. |
| 28 | linux,phandle is made optional, only nodes |
| 29 | that are referenced by other nodes need it. |
| 30 | "name" property is now automatically |
| 31 | deduced from the unit name |
| 32 | |
| 33 | June 1, 2005: Rev 0.4 - Correct confusion between OF_DT_END and |
| 34 | OF_DT_END_NODE in structure definition. |
| 35 | - Change version 16 format to always align |
| 36 | property data to 4 bytes. Since tokens are |
| 37 | already aligned, that means no specific |
Matt LaPlante | 5d3f083 | 2006-11-30 05:21:10 +0100 | [diff] [blame] | 38 | required alignment between property size |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 39 | and property data. The old style variable |
| 40 | alignment would make it impossible to do |
| 41 | "simple" insertion of properties using |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 42 | memmove (thanks Milton for |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 43 | noticing). Updated kernel patch as well |
Matt LaPlante | 5d3f083 | 2006-11-30 05:21:10 +0100 | [diff] [blame] | 44 | - Correct a few more alignment constraints |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 45 | - Add a chapter about the device-tree |
| 46 | compiler and the textural representation of |
| 47 | the tree that can be "compiled" by dtc. |
| 48 | |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 49 | November 21, 2005: Rev 0.5 |
| 50 | - Additions/generalizations for 32-bit |
| 51 | - Changed to reflect the new arch/powerpc |
| 52 | structure |
| 53 | - Added chapter VI |
| 54 | |
| 55 | |
| 56 | ToDo: |
| 57 | - Add some definitions of interrupt tree (simple/complex) |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 58 | - Add some definitions for PCI host bridges |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 59 | - Add some common address format examples |
| 60 | - Add definitions for standard properties and "compatible" |
| 61 | names for cells that are not already defined by the existing |
| 62 | OF spec. |
| 63 | - Compare FSL SOC use of PCI to standard and make sure no new |
| 64 | node definition required. |
| 65 | - Add more information about node definitions for SOC devices |
| 66 | that currently have no standard, like the FSL CPM. |
| 67 | |
| 68 | |
| 69 | I - Introduction |
| 70 | ================ |
| 71 | |
| 72 | During the recent development of the Linux/ppc64 kernel, and more |
| 73 | specifically, the addition of new platform types outside of the old |
| 74 | IBM pSeries/iSeries pair, it was decided to enforce some strict rules |
| 75 | regarding the kernel entry and bootloader <-> kernel interfaces, in |
| 76 | order to avoid the degeneration that had become the ppc32 kernel entry |
| 77 | point and the way a new platform should be added to the kernel. The |
| 78 | legacy iSeries platform breaks those rules as it predates this scheme, |
| 79 | but no new board support will be accepted in the main tree that |
| 80 | doesn't follows them properly. In addition, since the advent of the |
| 81 | arch/powerpc merged architecture for ppc32 and ppc64, new 32-bit |
| 82 | platforms and 32-bit platforms which move into arch/powerpc will be |
| 83 | required to use these rules as well. |
| 84 | |
| 85 | The main requirement that will be defined in more detail below is |
| 86 | the presence of a device-tree whose format is defined after Open |
| 87 | Firmware specification. However, in order to make life easier |
| 88 | to embedded board vendors, the kernel doesn't require the device-tree |
| 89 | to represent every device in the system and only requires some nodes |
| 90 | and properties to be present. This will be described in detail in |
| 91 | section III, but, for example, the kernel does not require you to |
| 92 | create a node for every PCI device in the system. It is a requirement |
| 93 | to have a node for PCI host bridges in order to provide interrupt |
| 94 | routing informations and memory/IO ranges, among others. It is also |
| 95 | recommended to define nodes for on chip devices and other busses that |
| 96 | don't specifically fit in an existing OF specification. This creates a |
| 97 | great flexibility in the way the kernel can then probe those and match |
| 98 | drivers to device, without having to hard code all sorts of tables. It |
| 99 | also makes it more flexible for board vendors to do minor hardware |
| 100 | upgrades without significantly impacting the kernel code or cluttering |
| 101 | it with special cases. |
| 102 | |
| 103 | |
| 104 | 1) Entry point for arch/powerpc |
| 105 | ------------------------------- |
| 106 | |
| 107 | There is one and one single entry point to the kernel, at the start |
| 108 | of the kernel image. That entry point supports two calling |
| 109 | conventions: |
| 110 | |
| 111 | a) Boot from Open Firmware. If your firmware is compatible |
| 112 | with Open Firmware (IEEE 1275) or provides an OF compatible |
| 113 | client interface API (support for "interpret" callback of |
| 114 | forth words isn't required), you can enter the kernel with: |
| 115 | |
| 116 | r5 : OF callback pointer as defined by IEEE 1275 |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 117 | bindings to powerpc. Only the 32-bit client interface |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 118 | is currently supported |
| 119 | |
| 120 | r3, r4 : address & length of an initrd if any or 0 |
| 121 | |
| 122 | The MMU is either on or off; the kernel will run the |
| 123 | trampoline located in arch/powerpc/kernel/prom_init.c to |
| 124 | extract the device-tree and other information from open |
| 125 | firmware and build a flattened device-tree as described |
| 126 | in b). prom_init() will then re-enter the kernel using |
| 127 | the second method. This trampoline code runs in the |
| 128 | context of the firmware, which is supposed to handle all |
| 129 | exceptions during that time. |
| 130 | |
| 131 | b) Direct entry with a flattened device-tree block. This entry |
| 132 | point is called by a) after the OF trampoline and can also be |
| 133 | called directly by a bootloader that does not support the Open |
| 134 | Firmware client interface. It is also used by "kexec" to |
| 135 | implement "hot" booting of a new kernel from a previous |
| 136 | running one. This method is what I will describe in more |
| 137 | details in this document, as method a) is simply standard Open |
| 138 | Firmware, and thus should be implemented according to the |
| 139 | various standard documents defining it and its binding to the |
| 140 | PowerPC platform. The entry point definition then becomes: |
| 141 | |
| 142 | r3 : physical pointer to the device-tree block |
| 143 | (defined in chapter II) in RAM |
| 144 | |
| 145 | r4 : physical pointer to the kernel itself. This is |
| 146 | used by the assembly code to properly disable the MMU |
| 147 | in case you are entering the kernel with MMU enabled |
| 148 | and a non-1:1 mapping. |
| 149 | |
Matt LaPlante | 2fe0ae7 | 2006-10-03 22:50:39 +0200 | [diff] [blame] | 150 | r5 : NULL (as to differentiate with method a) |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 151 | |
| 152 | Note about SMP entry: Either your firmware puts your other |
| 153 | CPUs in some sleep loop or spin loop in ROM where you can get |
| 154 | them out via a soft reset or some other means, in which case |
| 155 | you don't need to care, or you'll have to enter the kernel |
| 156 | with all CPUs. The way to do that with method b) will be |
| 157 | described in a later revision of this document. |
| 158 | |
| 159 | |
| 160 | 2) Board support |
| 161 | ---------------- |
| 162 | |
| 163 | 64-bit kernels: |
| 164 | |
| 165 | Board supports (platforms) are not exclusive config options. An |
| 166 | arbitrary set of board supports can be built in a single kernel |
| 167 | image. The kernel will "know" what set of functions to use for a |
| 168 | given platform based on the content of the device-tree. Thus, you |
| 169 | should: |
| 170 | |
| 171 | a) add your platform support as a _boolean_ option in |
| 172 | arch/powerpc/Kconfig, following the example of PPC_PSERIES, |
| 173 | PPC_PMAC and PPC_MAPLE. The later is probably a good |
| 174 | example of a board support to start from. |
| 175 | |
| 176 | b) create your main platform file as |
| 177 | "arch/powerpc/platforms/myplatform/myboard_setup.c" and add it |
| 178 | to the Makefile under the condition of your CONFIG_ |
| 179 | option. This file will define a structure of type "ppc_md" |
| 180 | containing the various callbacks that the generic code will |
| 181 | use to get to your platform specific code |
| 182 | |
| 183 | c) Add a reference to your "ppc_md" structure in the |
| 184 | "machines" table in arch/powerpc/kernel/setup_64.c if you are |
| 185 | a 64-bit platform. |
| 186 | |
| 187 | d) request and get assigned a platform number (see PLATFORM_* |
| 188 | constants in include/asm-powerpc/processor.h |
| 189 | |
| 190 | 32-bit embedded kernels: |
| 191 | |
| 192 | Currently, board support is essentially an exclusive config option. |
| 193 | The kernel is configured for a single platform. Part of the reason |
| 194 | for this is to keep kernels on embedded systems small and efficient; |
| 195 | part of this is due to the fact the code is already that way. In the |
| 196 | future, a kernel may support multiple platforms, but only if the |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 197 | platforms feature the same core architecture. A single kernel build |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 198 | cannot support both configurations with Book E and configurations |
| 199 | with classic Powerpc architectures. |
| 200 | |
| 201 | 32-bit embedded platforms that are moved into arch/powerpc using a |
| 202 | flattened device tree should adopt the merged tree practice of |
| 203 | setting ppc_md up dynamically, even though the kernel is currently |
| 204 | built with support for only a single platform at a time. This allows |
| 205 | unification of the setup code, and will make it easier to go to a |
| 206 | multiple-platform-support model in the future. |
| 207 | |
| 208 | NOTE: I believe the above will be true once Ben's done with the merge |
| 209 | of the boot sequences.... someone speak up if this is wrong! |
| 210 | |
| 211 | To add a 32-bit embedded platform support, follow the instructions |
| 212 | for 64-bit platforms above, with the exception that the Kconfig |
| 213 | option should be set up such that the kernel builds exclusively for |
| 214 | the platform selected. The processor type for the platform should |
| 215 | enable another config option to select the specific board |
| 216 | supported. |
| 217 | |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 218 | 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] | 219 | point to setup_32.c |
| 220 | |
| 221 | |
| 222 | I will describe later the boot process and various callbacks that |
| 223 | your platform should implement. |
| 224 | |
| 225 | |
| 226 | II - The DT block format |
| 227 | ======================== |
| 228 | |
| 229 | |
| 230 | This chapter defines the actual format of the flattened device-tree |
| 231 | passed to the kernel. The actual content of it and kernel requirements |
| 232 | are described later. You can find example of code manipulating that |
| 233 | format in various places, including arch/powerpc/kernel/prom_init.c |
| 234 | which will generate a flattened device-tree from the Open Firmware |
| 235 | representation, or the fs2dt utility which is part of the kexec tools |
| 236 | which will generate one from a filesystem representation. It is |
| 237 | expected that a bootloader like uboot provides a bit more support, |
| 238 | that will be discussed later as well. |
| 239 | |
| 240 | Note: The block has to be in main memory. It has to be accessible in |
| 241 | both real mode and virtual mode with no mapping other than main |
| 242 | memory. If you are writing a simple flash bootloader, it should copy |
| 243 | the block to RAM before passing it to the kernel. |
| 244 | |
| 245 | |
| 246 | 1) Header |
| 247 | --------- |
| 248 | |
| 249 | The kernel is entered with r3 pointing to an area of memory that is |
Matt LaPlante | d6bc8ac | 2006-10-03 22:54:15 +0200 | [diff] [blame] | 250 | roughly described in include/asm-powerpc/prom.h by the structure |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 251 | boot_param_header: |
| 252 | |
| 253 | struct boot_param_header { |
| 254 | u32 magic; /* magic word OF_DT_HEADER */ |
| 255 | u32 totalsize; /* total size of DT block */ |
| 256 | u32 off_dt_struct; /* offset to structure */ |
| 257 | u32 off_dt_strings; /* offset to strings */ |
| 258 | u32 off_mem_rsvmap; /* offset to memory reserve map |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 259 | */ |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 260 | u32 version; /* format version */ |
| 261 | u32 last_comp_version; /* last compatible version */ |
| 262 | |
| 263 | /* version 2 fields below */ |
| 264 | u32 boot_cpuid_phys; /* Which physical CPU id we're |
| 265 | booting on */ |
| 266 | /* version 3 fields below */ |
| 267 | u32 size_dt_strings; /* size of the strings block */ |
David Gibson | 0e0293c | 2007-03-14 11:50:40 +1100 | [diff] [blame] | 268 | |
| 269 | /* version 17 fields below */ |
| 270 | u32 size_dt_struct; /* size of the DT structure block */ |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 271 | }; |
| 272 | |
| 273 | Along with the constants: |
| 274 | |
| 275 | /* Definitions used by the flattened device tree */ |
| 276 | #define OF_DT_HEADER 0xd00dfeed /* 4: version, |
| 277 | 4: total size */ |
| 278 | #define OF_DT_BEGIN_NODE 0x1 /* Start node: full name |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 279 | */ |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 280 | #define OF_DT_END_NODE 0x2 /* End node */ |
| 281 | #define OF_DT_PROP 0x3 /* Property: name off, |
| 282 | size, content */ |
| 283 | #define OF_DT_END 0x9 |
| 284 | |
| 285 | All values in this header are in big endian format, the various |
| 286 | fields in this header are defined more precisely below. All |
| 287 | "offset" values are in bytes from the start of the header; that is |
| 288 | from the value of r3. |
| 289 | |
| 290 | - magic |
| 291 | |
| 292 | This is a magic value that "marks" the beginning of the |
| 293 | device-tree block header. It contains the value 0xd00dfeed and is |
| 294 | defined by the constant OF_DT_HEADER |
| 295 | |
| 296 | - totalsize |
| 297 | |
| 298 | This is the total size of the DT block including the header. The |
| 299 | "DT" block should enclose all data structures defined in this |
| 300 | chapter (who are pointed to by offsets in this header). That is, |
| 301 | the device-tree structure, strings, and the memory reserve map. |
| 302 | |
| 303 | - off_dt_struct |
| 304 | |
| 305 | This is an offset from the beginning of the header to the start |
| 306 | of the "structure" part the device tree. (see 2) device tree) |
| 307 | |
| 308 | - off_dt_strings |
| 309 | |
| 310 | This is an offset from the beginning of the header to the start |
| 311 | of the "strings" part of the device-tree |
| 312 | |
| 313 | - off_mem_rsvmap |
| 314 | |
| 315 | 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] | 316 | 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] | 317 | bit integers. Each pair is a physical address and a size. The |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 318 | list is terminated by an entry of size 0. This map provides the |
| 319 | kernel with a list of physical memory areas that are "reserved" |
| 320 | and thus not to be used for memory allocations, especially during |
| 321 | early initialization. The kernel needs to allocate memory during |
| 322 | boot for things like un-flattening the device-tree, allocating an |
| 323 | MMU hash table, etc... Those allocations must be done in such a |
| 324 | way to avoid overriding critical things like, on Open Firmware |
| 325 | capable machines, the RTAS instance, or on some pSeries, the TCE |
| 326 | tables used for the iommu. Typically, the reserve map should |
| 327 | contain _at least_ this DT block itself (header,total_size). If |
| 328 | you are passing an initrd to the kernel, you should reserve it as |
| 329 | 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] | 330 | should be 64-bit aligned. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 331 | |
| 332 | - version |
| 333 | |
| 334 | This is the version of this structure. Version 1 stops |
| 335 | here. Version 2 adds an additional field boot_cpuid_phys. |
| 336 | Version 3 adds the size of the strings block, allowing the kernel |
| 337 | to reallocate it easily at boot and free up the unused flattened |
| 338 | structure after expansion. Version 16 introduces a new more |
| 339 | "compact" format for the tree itself that is however not backward |
David Gibson | 0e0293c | 2007-03-14 11:50:40 +1100 | [diff] [blame] | 340 | compatible. Version 17 adds an additional field, size_dt_struct, |
| 341 | allowing it to be reallocated or moved more easily (this is |
| 342 | particularly useful for bootloaders which need to make |
| 343 | adjustments to a device tree based on probed information). You |
| 344 | should always generate a structure of the highest version defined |
| 345 | at the time of your implementation. Currently that is version 17, |
| 346 | unless you explicitly aim at being backward compatible. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 347 | |
| 348 | - last_comp_version |
| 349 | |
| 350 | Last compatible version. This indicates down to what version of |
| 351 | the DT block you are backward compatible. For example, version 2 |
| 352 | is backward compatible with version 1 (that is, a kernel build |
| 353 | for version 1 will be able to boot with a version 2 format). You |
| 354 | 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] | 355 | 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] | 356 | using the new unit name format. |
| 357 | |
| 358 | - boot_cpuid_phys |
| 359 | |
| 360 | This field only exist on version 2 headers. It indicate which |
| 361 | physical CPU ID is calling the kernel entry point. This is used, |
| 362 | among others, by kexec. If you are on an SMP system, this value |
| 363 | should match the content of the "reg" property of the CPU node in |
| 364 | the device-tree corresponding to the CPU calling the kernel entry |
| 365 | point (see further chapters for more informations on the required |
| 366 | device-tree contents) |
| 367 | |
David Gibson | 0e0293c | 2007-03-14 11:50:40 +1100 | [diff] [blame] | 368 | - size_dt_strings |
| 369 | |
| 370 | This field only exists on version 3 and later headers. It |
| 371 | gives the size of the "strings" section of the device tree (which |
| 372 | starts at the offset given by off_dt_strings). |
| 373 | |
| 374 | - size_dt_struct |
| 375 | |
| 376 | This field only exists on version 17 and later headers. It gives |
| 377 | the size of the "structure" section of the device tree (which |
| 378 | starts at the offset given by off_dt_struct). |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 379 | |
| 380 | So the typical layout of a DT block (though the various parts don't |
| 381 | need to be in that order) looks like this (addresses go from top to |
| 382 | bottom): |
| 383 | |
| 384 | |
| 385 | ------------------------------ |
| 386 | r3 -> | struct boot_param_header | |
| 387 | ------------------------------ |
| 388 | | (alignment gap) (*) | |
| 389 | ------------------------------ |
| 390 | | memory reserve map | |
| 391 | ------------------------------ |
| 392 | | (alignment gap) | |
| 393 | ------------------------------ |
| 394 | | | |
| 395 | | device-tree structure | |
| 396 | | | |
| 397 | ------------------------------ |
| 398 | | (alignment gap) | |
| 399 | ------------------------------ |
| 400 | | | |
| 401 | | device-tree strings | |
| 402 | | | |
| 403 | -----> ------------------------------ |
| 404 | | |
| 405 | | |
| 406 | --- (r3 + totalsize) |
| 407 | |
| 408 | (*) The alignment gaps are not necessarily present; their presence |
| 409 | and size are dependent on the various alignment requirements of |
| 410 | the individual data blocks. |
| 411 | |
| 412 | |
| 413 | 2) Device tree generalities |
| 414 | --------------------------- |
| 415 | |
| 416 | This device-tree itself is separated in two different blocks, a |
| 417 | structure block and a strings block. Both need to be aligned to a 4 |
| 418 | byte boundary. |
| 419 | |
| 420 | First, let's quickly describe the device-tree concept before detailing |
| 421 | the storage format. This chapter does _not_ describe the detail of the |
| 422 | required types of nodes & properties for the kernel, this is done |
| 423 | later in chapter III. |
| 424 | |
| 425 | The device-tree layout is strongly inherited from the definition of |
| 426 | the Open Firmware IEEE 1275 device-tree. It's basically a tree of |
| 427 | nodes, each node having two or more named properties. A property can |
| 428 | have a value or not. |
| 429 | |
| 430 | It is a tree, so each node has one and only one parent except for the |
| 431 | root node who has no parent. |
| 432 | |
| 433 | A node has 2 names. The actual node name is generally contained in a |
| 434 | property of type "name" in the node property list whose value is a |
| 435 | 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] | 436 | format definition (as it is in Open Firmware). Version 16 makes it |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 437 | optional as it can generate it from the unit name defined below. |
| 438 | |
Matt LaPlante | 2fe0ae7 | 2006-10-03 22:50:39 +0200 | [diff] [blame] | 439 | 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] | 440 | 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] | 441 | names, the "@" sign, and a "unit address", which definition is |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 442 | specific to the bus type the node sits on. |
| 443 | |
| 444 | The unit name doesn't exist as a property per-se but is included in |
| 445 | the device-tree structure. It is typically used to represent "path" in |
| 446 | the device-tree. More details about the actual format of these will be |
| 447 | below. |
| 448 | |
| 449 | The kernel powerpc generic code does not make any formal use of the |
| 450 | unit address (though some board support code may do) so the only real |
| 451 | requirement here for the unit address is to ensure uniqueness of |
| 452 | the node unit name at a given level of the tree. Nodes with no notion |
| 453 | of address and no possible sibling of the same name (like /memory or |
| 454 | /cpus) may omit the unit address in the context of this specification, |
| 455 | or use the "@0" default unit address. The unit name is used to define |
| 456 | a node "full path", which is the concatenation of all parent node |
| 457 | unit names separated with "/". |
| 458 | |
| 459 | The root node doesn't have a defined name, and isn't required to have |
| 460 | a name property either if you are using version 3 or earlier of the |
| 461 | format. It also has no unit address (no @ symbol followed by a unit |
| 462 | address). The root node unit name is thus an empty string. The full |
| 463 | path to the root node is "/". |
| 464 | |
| 465 | Every node which actually represents an actual device (that is, a node |
| 466 | which isn't only a virtual "container" for more nodes, like "/cpus" |
| 467 | is) is also required to have a "device_type" property indicating the |
| 468 | type of node . |
| 469 | |
| 470 | Finally, every node that can be referenced from a property in another |
| 471 | node is required to have a "linux,phandle" property. Real open |
| 472 | firmware implementations provide a unique "phandle" value for every |
| 473 | node that the "prom_init()" trampoline code turns into |
| 474 | "linux,phandle" properties. However, this is made optional if the |
| 475 | flattened device tree is used directly. An example of a node |
| 476 | referencing another node via "phandle" is when laying out the |
| 477 | interrupt tree which will be described in a further version of this |
| 478 | document. |
| 479 | |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 480 | This "linux, phandle" property is a 32-bit value that uniquely |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 481 | identifies a node. You are free to use whatever values or system of |
| 482 | values, internal pointers, or whatever to generate these, the only |
| 483 | requirement is that every node for which you provide that property has |
| 484 | a unique value for it. |
| 485 | |
| 486 | Here is an example of a simple device-tree. In this example, an "o" |
| 487 | designates a node followed by the node unit name. Properties are |
| 488 | presented with their name followed by their content. "content" |
| 489 | represents an ASCII string (zero terminated) value, while <content> |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 490 | represents a 32-bit hexadecimal value. The various nodes in this |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 491 | example will be discussed in a later chapter. At this point, it is |
| 492 | only meant to give you a idea of what a device-tree looks like. I have |
| 493 | purposefully kept the "name" and "linux,phandle" properties which |
| 494 | aren't necessary in order to give you a better idea of what the tree |
| 495 | looks like in practice. |
| 496 | |
| 497 | / o device-tree |
| 498 | |- name = "device-tree" |
| 499 | |- model = "MyBoardName" |
| 500 | |- compatible = "MyBoardFamilyName" |
| 501 | |- #address-cells = <2> |
| 502 | |- #size-cells = <2> |
| 503 | |- linux,phandle = <0> |
| 504 | | |
| 505 | o cpus |
| 506 | | | - name = "cpus" |
| 507 | | | - linux,phandle = <1> |
| 508 | | | - #address-cells = <1> |
| 509 | | | - #size-cells = <0> |
| 510 | | | |
| 511 | | o PowerPC,970@0 |
| 512 | | |- name = "PowerPC,970" |
| 513 | | |- device_type = "cpu" |
| 514 | | |- reg = <0> |
| 515 | | |- clock-frequency = <5f5e1000> |
Timur Tabi | 32aed2a | 2007-02-14 15:29:07 -0600 | [diff] [blame] | 516 | | |- 64-bit |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 517 | | |- linux,phandle = <2> |
| 518 | | |
| 519 | o memory@0 |
| 520 | | |- name = "memory" |
| 521 | | |- device_type = "memory" |
| 522 | | |- reg = <00000000 00000000 00000000 20000000> |
| 523 | | |- linux,phandle = <3> |
| 524 | | |
| 525 | o chosen |
| 526 | |- name = "chosen" |
| 527 | |- bootargs = "root=/dev/sda2" |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 528 | |- linux,phandle = <4> |
| 529 | |
| 530 | This tree is almost a minimal tree. It pretty much contains the |
| 531 | minimal set of required nodes and properties to boot a linux kernel; |
| 532 | that is, some basic model informations at the root, the CPUs, and the |
| 533 | physical memory layout. It also includes misc information passed |
| 534 | through /chosen, like in this example, the platform type (mandatory) |
| 535 | and the kernel command line arguments (optional). |
| 536 | |
Timur Tabi | 32aed2a | 2007-02-14 15:29:07 -0600 | [diff] [blame] | 537 | 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] | 538 | property without a value. All other properties have a value. The |
| 539 | significance of the #address-cells and #size-cells properties will be |
| 540 | explained in chapter IV which defines precisely the required nodes and |
| 541 | properties and their content. |
| 542 | |
| 543 | |
| 544 | 3) Device tree "structure" block |
| 545 | |
| 546 | The structure of the device tree is a linearized tree structure. The |
| 547 | "OF_DT_BEGIN_NODE" token starts a new node, and the "OF_DT_END_NODE" |
| 548 | ends that node definition. Child nodes are simply defined before |
| 549 | "OF_DT_END_NODE" (that is nodes within the node). A 'token' is a 32 |
| 550 | bit value. The tree has to be "finished" with a OF_DT_END token |
| 551 | |
| 552 | Here's the basic structure of a single node: |
| 553 | |
| 554 | * token OF_DT_BEGIN_NODE (that is 0x00000001) |
| 555 | * for version 1 to 3, this is the node full path as a zero |
| 556 | terminated string, starting with "/". For version 16 and later, |
| 557 | this is the node unit name only (or an empty string for the |
| 558 | root node) |
| 559 | * [align gap to next 4 bytes boundary] |
| 560 | * for each property: |
| 561 | * token OF_DT_PROP (that is 0x00000003) |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 562 | * 32-bit value of property value size in bytes (or 0 if no |
| 563 | value) |
| 564 | * 32-bit value of offset in string block of property name |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 565 | * property value data if any |
| 566 | * [align gap to next 4 bytes boundary] |
| 567 | * [child nodes if any] |
| 568 | * token OF_DT_END_NODE (that is 0x00000002) |
| 569 | |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 570 | 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] | 571 | 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] | 572 | child node is a full node structure itself as defined above. |
| 573 | |
Matt LaPlante | 53cb472 | 2006-10-03 22:55:17 +0200 | [diff] [blame] | 574 | 4) Device tree "strings" block |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 575 | |
| 576 | In order to save space, property names, which are generally redundant, |
| 577 | are stored separately in the "strings" block. This block is simply the |
| 578 | whole bunch of zero terminated strings for all property names |
| 579 | concatenated together. The device-tree property definitions in the |
| 580 | structure block will contain offset values from the beginning of the |
| 581 | strings block. |
| 582 | |
| 583 | |
| 584 | III - Required content of the device tree |
| 585 | ========================================= |
| 586 | |
| 587 | WARNING: All "linux,*" properties defined in this document apply only |
| 588 | to a flattened device-tree. If your platform uses a real |
| 589 | implementation of Open Firmware or an implementation compatible with |
| 590 | the Open Firmware client interface, those properties will be created |
| 591 | by the trampoline code in the kernel's prom_init() file. For example, |
| 592 | 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] | 593 | set the platform number. However, when using the flattened device-tree |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 594 | entry point, there is no prom_init() pass, and thus you have to |
| 595 | provide those properties yourself. |
| 596 | |
| 597 | |
| 598 | 1) Note about cells and address representation |
| 599 | ---------------------------------------------- |
| 600 | |
| 601 | The general rule is documented in the various Open Firmware |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 602 | documentations. If you choose to describe a bus with the device-tree |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 603 | and there exist an OF bus binding, then you should follow the |
| 604 | specification. However, the kernel does not require every single |
| 605 | device or bus to be described by the device tree. |
| 606 | |
| 607 | In general, the format of an address for a device is defined by the |
| 608 | parent bus type, based on the #address-cells and #size-cells |
| 609 | property. In the absence of such a property, the parent's parent |
| 610 | values are used, etc... The kernel requires the root node to have |
| 611 | those properties defining addresses format for devices directly mapped |
| 612 | on the processor bus. |
| 613 | |
| 614 | Those 2 properties define 'cells' for representing an address and a |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 615 | 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] | 616 | 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] | 617 | 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] | 618 | concatenated and expected to be in big endian format). Another example |
| 619 | is the way Apple firmware defines them, with 2 cells for an address |
| 620 | and one cell for a size. Most 32-bit implementations should define |
| 621 | #address-cells and #size-cells to 1, which represents a 32-bit value. |
| 622 | Some 32-bit processors allow for physical addresses greater than 32 |
| 623 | bits; these processors should define #address-cells as 2. |
| 624 | |
| 625 | "reg" properties are always a tuple of the type "address size" where |
| 626 | the number of cells of address and size is specified by the bus |
| 627 | #address-cells and #size-cells. When a bus supports various address |
| 628 | spaces and other flags relative to a given address allocation (like |
| 629 | prefetchable, etc...) those flags are usually added to the top level |
| 630 | bits of the physical address. For example, a PCI physical address is |
| 631 | made of 3 cells, the bottom two containing the actual address itself |
| 632 | while the top cell contains address space indication, flags, and pci |
| 633 | bus & device numbers. |
| 634 | |
| 635 | For busses that support dynamic allocation, it's the accepted practice |
| 636 | to then not provide the address in "reg" (keep it 0) though while |
| 637 | providing a flag indicating the address is dynamically allocated, and |
| 638 | then, to provide a separate "assigned-addresses" property that |
| 639 | contains the fully allocated addresses. See the PCI OF bindings for |
| 640 | details. |
| 641 | |
| 642 | In general, a simple bus with no address space bits and no dynamic |
| 643 | allocation is preferred if it reflects your hardware, as the existing |
| 644 | kernel address parsing functions will work out of the box. If you |
| 645 | define a bus type with a more complex address format, including things |
| 646 | like address space bits, you'll have to add a bus translator to the |
| 647 | prom_parse.c file of the recent kernels for your bus type. |
| 648 | |
| 649 | The "reg" property only defines addresses and sizes (if #size-cells |
Matt LaPlante | 992caac | 2006-10-03 22:52:05 +0200 | [diff] [blame] | 650 | is non-0) within a given bus. In order to translate addresses upward |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 651 | (that is into parent bus addresses, and possibly into CPU physical |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 652 | addresses), all busses must contain a "ranges" property. If the |
| 653 | "ranges" property is missing at a given level, it's assumed that |
Matt LaPlante | 992caac | 2006-10-03 22:52:05 +0200 | [diff] [blame] | 654 | translation isn't possible. The format of the "ranges" property for a |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 655 | bus is a list of: |
| 656 | |
| 657 | bus address, parent bus address, size |
| 658 | |
| 659 | "bus address" is in the format of the bus this bus node is defining, |
| 660 | that is, for a PCI bridge, it would be a PCI address. Thus, (bus |
| 661 | address, size) defines a range of addresses for child devices. "parent |
| 662 | bus address" is in the format of the parent bus of this bus. For |
| 663 | example, for a PCI host controller, that would be a CPU address. For a |
| 664 | PCI<->ISA bridge, that would be a PCI address. It defines the base |
| 665 | address in the parent bus where the beginning of that range is mapped. |
| 666 | |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 667 | 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] | 668 | 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] | 669 | 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] | 670 | 1/1 format, unless the processor supports physical addresses greater |
| 671 | than 32-bits, in which case a 2/1 format is recommended. |
| 672 | |
| 673 | |
| 674 | 2) Note about "compatible" properties |
| 675 | ------------------------------------- |
| 676 | |
| 677 | These properties are optional, but recommended in devices and the root |
| 678 | node. The format of a "compatible" property is a list of concatenated |
| 679 | zero terminated strings. They allow a device to express its |
| 680 | compatibility with a family of similar devices, in some cases, |
| 681 | allowing a single driver to match against several devices regardless |
| 682 | of their actual names. |
| 683 | |
| 684 | 3) Note about "name" properties |
| 685 | ------------------------------- |
| 686 | |
| 687 | While earlier users of Open Firmware like OldWorld macintoshes tended |
| 688 | to use the actual device name for the "name" property, it's nowadays |
| 689 | considered a good practice to use a name that is closer to the device |
| 690 | class (often equal to device_type). For example, nowadays, ethernet |
| 691 | controllers are named "ethernet", an additional "model" property |
| 692 | defining precisely the chip type/model, and "compatible" property |
| 693 | defining the family in case a single driver can driver more than one |
| 694 | of these chips. However, the kernel doesn't generally put any |
| 695 | restriction on the "name" property; it is simply considered good |
| 696 | practice to follow the standard and its evolutions as closely as |
| 697 | possible. |
| 698 | |
| 699 | Note also that the new format version 16 makes the "name" property |
| 700 | optional. If it's absent for a node, then the node's unit name is then |
| 701 | used to reconstruct the name. That is, the part of the unit name |
| 702 | before the "@" sign is used (or the entire unit name if no "@" sign |
| 703 | is present). |
| 704 | |
| 705 | 4) Note about node and property names and character set |
| 706 | ------------------------------------------------------- |
| 707 | |
Matt LaPlante | a2ffd27 | 2006-10-03 22:49:15 +0200 | [diff] [blame] | 708 | While open firmware provides more flexible usage of 8859-1, this |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 709 | specification enforces more strict rules. Nodes and properties should |
| 710 | be comprised only of ASCII characters 'a' to 'z', '0' to |
| 711 | '9', ',', '.', '_', '+', '#', '?', and '-'. Node names additionally |
| 712 | allow uppercase characters 'A' to 'Z' (property names should be |
| 713 | lowercase. The fact that vendors like Apple don't respect this rule is |
| 714 | irrelevant here). Additionally, node and property names should always |
| 715 | begin with a character in the range 'a' to 'z' (or 'A' to 'Z' for node |
| 716 | names). |
| 717 | |
| 718 | The maximum number of characters for both nodes and property names |
| 719 | is 31. In the case of node names, this is only the leftmost part of |
| 720 | a unit name (the pure "name" property), it doesn't include the unit |
| 721 | address which can extend beyond that limit. |
| 722 | |
| 723 | |
| 724 | 5) Required nodes and properties |
| 725 | -------------------------------- |
| 726 | These are all that are currently required. However, it is strongly |
| 727 | recommended that you expose PCI host bridges as documented in the |
| 728 | PCI binding to open firmware, and your interrupt tree as documented |
| 729 | in OF interrupt tree specification. |
| 730 | |
| 731 | a) The root node |
| 732 | |
| 733 | The root node requires some properties to be present: |
| 734 | |
| 735 | - model : this is your board name/model |
| 736 | - #address-cells : address representation for "root" devices |
| 737 | - #size-cells: the size representation for "root" devices |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 738 | - device_type : This property shouldn't be necessary. However, if |
| 739 | you decide to create a device_type for your root node, make sure it |
| 740 | is _not_ "chrp" unless your platform is a pSeries or PAPR compliant |
| 741 | one for 64-bit, or a CHRP-type machine for 32-bit as this will |
| 742 | matched by the kernel this way. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 743 | |
| 744 | Additionally, some recommended properties are: |
| 745 | |
| 746 | - compatible : the board "family" generally finds its way here, |
| 747 | for example, if you have 2 board models with a similar layout, |
| 748 | that typically get driven by the same platform code in the |
| 749 | kernel, you would use a different "model" property but put a |
| 750 | value in "compatible". The kernel doesn't directly use that |
Stuart Yoder | 143a42d | 2007-02-16 11:30:29 -0600 | [diff] [blame] | 751 | value but it is generally useful. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 752 | |
| 753 | The root node is also generally where you add additional properties |
| 754 | 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] | 755 | thing. It is recommended that if you add any "custom" property whose |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 756 | name may clash with standard defined ones, you prefix them with your |
| 757 | vendor name and a comma. |
| 758 | |
| 759 | b) The /cpus node |
| 760 | |
| 761 | This node is the parent of all individual CPU nodes. It doesn't |
| 762 | have any specific requirements, though it's generally good practice |
| 763 | to have at least: |
| 764 | |
| 765 | #address-cells = <00000001> |
| 766 | #size-cells = <00000000> |
| 767 | |
| 768 | This defines that the "address" for a CPU is a single cell, and has |
| 769 | no meaningful size. This is not necessary but the kernel will assume |
| 770 | that format when reading the "reg" properties of a CPU node, see |
| 771 | below |
| 772 | |
| 773 | c) The /cpus/* nodes |
| 774 | |
| 775 | So under /cpus, you are supposed to create a node for every CPU on |
| 776 | the machine. There is no specific restriction on the name of the |
| 777 | CPU, though It's common practice to call it PowerPC,<name>. For |
| 778 | example, Apple uses PowerPC,G5 while IBM uses PowerPC,970FX. |
| 779 | |
| 780 | Required properties: |
| 781 | |
| 782 | - device_type : has to be "cpu" |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 783 | - 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] | 784 | and is also used as-is as the unit number for constructing the |
| 785 | unit name in the full path. For example, with 2 CPUs, you would |
| 786 | have the full path: |
| 787 | /cpus/PowerPC,970FX@0 |
| 788 | /cpus/PowerPC,970FX@1 |
| 789 | (unit addresses do not require leading zeroes) |
| 790 | - d-cache-line-size : one cell, L1 data cache line size in bytes |
| 791 | - i-cache-line-size : one cell, L1 instruction cache line size in |
| 792 | bytes |
| 793 | - d-cache-size : one cell, size of L1 data cache in bytes |
| 794 | - i-cache-size : one cell, size of L1 instruction cache in bytes |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 795 | |
| 796 | Recommended properties: |
| 797 | |
| 798 | - timebase-frequency : a cell indicating the frequency of the |
| 799 | timebase in Hz. This is not directly used by the generic code, |
| 800 | but you are welcome to copy/paste the pSeries code for setting |
| 801 | the kernel timebase/decrementer calibration based on this |
| 802 | value. |
| 803 | - clock-frequency : a cell indicating the CPU core clock frequency |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 804 | 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] | 805 | your frequency is < 4Ghz, one cell is enough. Here as well as |
| 806 | for the above, the common code doesn't use that property, but |
| 807 | you are welcome to re-use the pSeries or Maple one. A future |
| 808 | kernel version might provide a common function for this. |
| 809 | |
| 810 | You are welcome to add any property you find relevant to your board, |
| 811 | like some information about the mechanism used to soft-reset the |
| 812 | CPUs. For example, Apple puts the GPIO number for CPU soft reset |
| 813 | lines in there as a "soft-reset" property since they start secondary |
| 814 | CPUs by soft-resetting them. |
| 815 | |
| 816 | |
| 817 | d) the /memory node(s) |
| 818 | |
| 819 | To define the physical memory layout of your board, you should |
| 820 | create one or more memory node(s). You can either create a single |
| 821 | node with all memory ranges in its reg property, or you can create |
| 822 | several nodes, as you wish. The unit address (@ part) used for the |
| 823 | full path is the address of the first range of memory defined by a |
| 824 | given node. If you use a single memory node, this will typically be |
| 825 | @0. |
| 826 | |
| 827 | Required properties: |
| 828 | |
| 829 | - device_type : has to be "memory" |
| 830 | - reg : This property contains all the physical memory ranges of |
| 831 | your board. It's a list of addresses/sizes concatenated |
| 832 | together, with the number of cells of each defined by the |
| 833 | #address-cells and #size-cells of the root node. For example, |
Matt LaPlante | 6c28f2c | 2006-10-03 22:46:31 +0200 | [diff] [blame] | 834 | with both of these properties being 2 like in the example given |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 835 | earlier, a 970 based machine with 6Gb of RAM could typically |
| 836 | have a "reg" property here that looks like: |
| 837 | |
| 838 | 00000000 00000000 00000000 80000000 |
| 839 | 00000001 00000000 00000001 00000000 |
| 840 | |
| 841 | That is a range starting at 0 of 0x80000000 bytes and a range |
| 842 | starting at 0x100000000 and of 0x100000000 bytes. You can see |
| 843 | that there is no memory covering the IO hole between 2Gb and |
| 844 | 4Gb. Some vendors prefer splitting those ranges into smaller |
| 845 | segments, but the kernel doesn't care. |
| 846 | |
| 847 | e) The /chosen node |
| 848 | |
| 849 | This node is a bit "special". Normally, that's where open firmware |
| 850 | puts some variable environment information, like the arguments, or |
Stuart Yoder | d1bff9e | 2007-02-19 11:25:05 -0600 | [diff] [blame] | 851 | the default input/output devices. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 852 | |
| 853 | This specification makes a few of these mandatory, but also defines |
| 854 | some linux-specific properties that would be normally constructed by |
| 855 | the prom_init() trampoline when booting with an OF client interface, |
| 856 | but that you have to provide yourself when using the flattened format. |
| 857 | |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 858 | Recommended properties: |
| 859 | |
| 860 | - bootargs : This zero-terminated string is passed as the kernel |
| 861 | command line |
| 862 | - linux,stdout-path : This is the full path to your standard |
| 863 | console device if any. Typically, if you have serial devices on |
| 864 | your board, you may want to put the full path to the one set as |
| 865 | the default console in the firmware here, for the kernel to pick |
Matt LaPlante | 5d3f083 | 2006-11-30 05:21:10 +0100 | [diff] [blame] | 866 | 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] | 867 | set_preferred_console() in arch/ppc64/kernel/setup.c, you'll see |
| 868 | that the kernel tries to find out the default console and has |
| 869 | knowledge of various types like 8250 serial ports. You may want |
| 870 | to extend this function to add your own. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 871 | |
| 872 | Note that u-boot creates and fills in the chosen node for platforms |
| 873 | that use it. |
| 874 | |
Stuart Yoder | d1bff9e | 2007-02-19 11:25:05 -0600 | [diff] [blame] | 875 | (Note: a practice that is now obsolete was to include a property |
| 876 | under /chosen called interrupt-controller which had a phandle value |
| 877 | that pointed to the main interrupt controller) |
| 878 | |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 879 | f) the /soc<SOCname> node |
| 880 | |
| 881 | This node is used to represent a system-on-a-chip (SOC) and must be |
| 882 | present if the processor is a SOC. The top-level soc node contains |
| 883 | information that is global to all devices on the SOC. The node name |
| 884 | should contain a unit address for the SOC, which is the base address |
| 885 | of the memory-mapped register set for the SOC. The name of an soc |
| 886 | node should start with "soc", and the remainder of the name should |
| 887 | represent the part number for the soc. For example, the MPC8540's |
| 888 | soc node would be called "soc8540". |
| 889 | |
| 890 | Required properties: |
| 891 | |
| 892 | - device_type : Should be "soc" |
| 893 | - ranges : Should be defined as specified in 1) to describe the |
| 894 | translation of SOC addresses for memory mapped SOC registers. |
Becky Bruce | 7d4b95a | 2006-02-06 14:26:31 -0600 | [diff] [blame] | 895 | - bus-frequency: Contains the bus frequency for the SOC node. |
| 896 | Typically, the value of this field is filled in by the boot |
| 897 | loader. |
| 898 | |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 899 | |
| 900 | Recommended properties: |
| 901 | |
| 902 | - reg : This property defines the address and size of the |
| 903 | memory-mapped registers that are used for the SOC node itself. |
| 904 | It does not include the child device registers - these will be |
| 905 | defined inside each child node. The address specified in the |
| 906 | "reg" property should match the unit address of the SOC node. |
| 907 | - #address-cells : Address representation for "soc" devices. The |
| 908 | format of this field may vary depending on whether or not the |
| 909 | device registers are memory mapped. For memory mapped |
| 910 | registers, this field represents the number of cells needed to |
| 911 | represent the address of the registers. For SOCs that do not |
| 912 | use MMIO, a special address format should be defined that |
| 913 | contains enough cells to represent the required information. |
| 914 | See 1) above for more details on defining #address-cells. |
| 915 | - #size-cells : Size representation for "soc" devices |
| 916 | - #interrupt-cells : Defines the width of cells used to represent |
| 917 | interrupts. Typically this value is <2>, which includes a |
| 918 | 32-bit number that represents the interrupt number, and a |
| 919 | 32-bit number that represents the interrupt sense and level. |
| 920 | This field is only needed if the SOC contains an interrupt |
| 921 | controller. |
| 922 | |
| 923 | The SOC node may contain child nodes for each SOC device that the |
| 924 | platform uses. Nodes should not be created for devices which exist |
| 925 | 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] | 926 | 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] | 927 | |
| 928 | Example SOC node for the MPC8540: |
| 929 | |
| 930 | soc8540@e0000000 { |
| 931 | #address-cells = <1>; |
| 932 | #size-cells = <1>; |
| 933 | #interrupt-cells = <2>; |
| 934 | device_type = "soc"; |
| 935 | ranges = <00000000 e0000000 00100000> |
| 936 | reg = <e0000000 00003000>; |
Becky Bruce | 7d4b95a | 2006-02-06 14:26:31 -0600 | [diff] [blame] | 937 | bus-frequency = <0>; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 938 | } |
| 939 | |
| 940 | |
| 941 | |
| 942 | IV - "dtc", the device tree compiler |
| 943 | ==================================== |
| 944 | |
| 945 | |
| 946 | dtc source code can be found at |
| 947 | <http://ozlabs.org/~dgibson/dtc/dtc.tar.gz> |
| 948 | |
| 949 | WARNING: This version is still in early development stage; the |
| 950 | resulting device-tree "blobs" have not yet been validated with the |
| 951 | kernel. The current generated bloc lacks a useful reserve map (it will |
| 952 | be fixed to generate an empty one, it's up to the bootloader to fill |
| 953 | it up) among others. The error handling needs work, bugs are lurking, |
| 954 | etc... |
| 955 | |
| 956 | dtc basically takes a device-tree in a given format and outputs a |
| 957 | device-tree in another format. The currently supported formats are: |
| 958 | |
| 959 | Input formats: |
| 960 | ------------- |
| 961 | |
| 962 | - "dtb": "blob" format, that is a flattened device-tree block |
| 963 | with |
| 964 | header all in a binary blob. |
| 965 | - "dts": "source" format. This is a text file containing a |
| 966 | "source" for a device-tree. The format is defined later in this |
| 967 | chapter. |
| 968 | - "fs" format. This is a representation equivalent to the |
| 969 | output of /proc/device-tree, that is nodes are directories and |
| 970 | properties are files |
| 971 | |
| 972 | Output formats: |
| 973 | --------------- |
| 974 | |
| 975 | - "dtb": "blob" format |
| 976 | - "dts": "source" format |
| 977 | - "asm": assembly language file. This is a file that can be |
| 978 | sourced by gas to generate a device-tree "blob". That file can |
| 979 | then simply be added to your Makefile. Additionally, the |
Matt LaPlante | 6c28f2c | 2006-10-03 22:46:31 +0200 | [diff] [blame] | 980 | assembly file exports some symbols that can be used. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 981 | |
| 982 | |
| 983 | The syntax of the dtc tool is |
| 984 | |
| 985 | dtc [-I <input-format>] [-O <output-format>] |
| 986 | [-o output-filename] [-V output_version] input_filename |
| 987 | |
| 988 | |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 989 | The "output_version" defines what version of the "blob" format will be |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 990 | generated. Supported versions are 1,2,3 and 16. The default is |
| 991 | currently version 3 but that may change in the future to version 16. |
| 992 | |
| 993 | Additionally, dtc performs various sanity checks on the tree, like the |
Matt LaPlante | 6c28f2c | 2006-10-03 22:46:31 +0200 | [diff] [blame] | 994 | uniqueness of linux, phandle properties, validity of strings, etc... |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 995 | |
| 996 | 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] | 997 | style comments. |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 998 | |
| 999 | / { |
| 1000 | } |
| 1001 | |
| 1002 | The above is the "device-tree" definition. It's the only statement |
| 1003 | supported currently at the toplevel. |
| 1004 | |
| 1005 | / { |
| 1006 | property1 = "string_value"; /* define a property containing a 0 |
| 1007 | * terminated string |
| 1008 | */ |
| 1009 | |
| 1010 | property2 = <1234abcd>; /* define a property containing a |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 1011 | * numerical 32-bit value (hexadecimal) |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1012 | */ |
| 1013 | |
| 1014 | property3 = <12345678 12345678 deadbeef>; |
| 1015 | /* define a property containing 3 |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 1016 | * numerical 32-bit values (cells) in |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1017 | * hexadecimal |
| 1018 | */ |
| 1019 | property4 = [0a 0b 0c 0d de ea ad be ef]; |
| 1020 | /* define a property whose content is |
| 1021 | * an arbitrary array of bytes |
| 1022 | */ |
| 1023 | |
| 1024 | childnode@addresss { /* define a child node named "childnode" |
| 1025 | * whose unit name is "childnode at |
| 1026 | * address" |
| 1027 | */ |
| 1028 | |
| 1029 | childprop = "hello\n"; /* define a property "childprop" of |
| 1030 | * childnode (in this case, a string) |
| 1031 | */ |
| 1032 | }; |
| 1033 | }; |
| 1034 | |
| 1035 | Nodes can contain other nodes etc... thus defining the hierarchical |
| 1036 | structure of the tree. |
| 1037 | |
| 1038 | Strings support common escape sequences from C: "\n", "\t", "\r", |
| 1039 | "\(octal value)", "\x(hex value)". |
| 1040 | |
| 1041 | It is also suggested that you pipe your source file through cpp (gcc |
| 1042 | preprocessor) so you can use #include's, #define for constants, etc... |
| 1043 | |
| 1044 | Finally, various options are planned but not yet implemented, like |
| 1045 | automatic generation of phandles, labels (exported to the asm file so |
| 1046 | you can point to a property content and change it easily from whatever |
| 1047 | you link the device-tree with), label or path instead of numeric value |
| 1048 | in some cells to "point" to a node (replaced by a phandle at compile |
| 1049 | time), export of reserve map address to the asm file, ability to |
| 1050 | specify reserve map content at compile time, etc... |
| 1051 | |
| 1052 | We may provide a .h include file with common definitions of that |
| 1053 | proves useful for some properties (like building PCI properties or |
| 1054 | interrupt maps) though it may be better to add a notion of struct |
| 1055 | definitions to the compiler... |
| 1056 | |
| 1057 | |
| 1058 | V - Recommendations for a bootloader |
| 1059 | ==================================== |
| 1060 | |
| 1061 | |
| 1062 | Here are some various ideas/recommendations that have been proposed |
| 1063 | while all this has been defined and implemented. |
| 1064 | |
| 1065 | - The bootloader may want to be able to use the device-tree itself |
| 1066 | and may want to manipulate it (to add/edit some properties, |
| 1067 | like physical memory size or kernel arguments). At this point, 2 |
| 1068 | choices can be made. Either the bootloader works directly on the |
| 1069 | flattened format, or the bootloader has its own internal tree |
| 1070 | representation with pointers (similar to the kernel one) and |
| 1071 | re-flattens the tree when booting the kernel. The former is a bit |
| 1072 | more difficult to edit/modify, the later requires probably a bit |
| 1073 | more code to handle the tree structure. Note that the structure |
| 1074 | format has been designed so it's relatively easy to "insert" |
| 1075 | properties or nodes or delete them by just memmoving things |
| 1076 | around. It contains no internal offsets or pointers for this |
| 1077 | purpose. |
| 1078 | |
Matt LaPlante | d6bc8ac | 2006-10-03 22:54:15 +0200 | [diff] [blame] | 1079 | - An example of code for iterating nodes & retrieving properties |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1080 | directly from the flattened tree format can be found in the kernel |
| 1081 | file arch/ppc64/kernel/prom.c, look at scan_flat_dt() function, |
Matt LaPlante | d6bc8ac | 2006-10-03 22:54:15 +0200 | [diff] [blame] | 1082 | its usage in early_init_devtree(), and the corresponding various |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1083 | early_init_dt_scan_*() callbacks. That code can be re-used in a |
| 1084 | 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] | 1085 | to discuss possible free licensing to any vendor who wishes to |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1086 | integrate all or part of this code into a non-GPL bootloader. |
| 1087 | |
| 1088 | |
| 1089 | |
| 1090 | VI - System-on-a-chip devices and nodes |
| 1091 | ======================================= |
| 1092 | |
| 1093 | Many companies are now starting to develop system-on-a-chip |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 1094 | processors, where the processor core (CPU) and many peripheral devices |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1095 | exist on a single piece of silicon. For these SOCs, an SOC node |
| 1096 | should be used that defines child nodes for the devices that make |
| 1097 | up the SOC. While platforms are not required to use this model in |
| 1098 | order to boot the kernel, it is highly encouraged that all SOC |
| 1099 | implementations define as complete a flat-device-tree as possible to |
| 1100 | describe the devices on the SOC. This will allow for the |
| 1101 | genericization of much of the kernel code. |
| 1102 | |
| 1103 | |
| 1104 | 1) Defining child nodes of an SOC |
| 1105 | --------------------------------- |
| 1106 | |
| 1107 | Each device that is part of an SOC may have its own node entry inside |
| 1108 | the SOC node. For each device that is included in the SOC, the unit |
| 1109 | address property represents the address offset for this device's |
| 1110 | memory-mapped registers in the parent's address space. The parent's |
| 1111 | address space is defined by the "ranges" property in the top-level soc |
| 1112 | node. The "reg" property for each node that exists directly under the |
| 1113 | SOC node should contain the address mapping from the child address space |
| 1114 | to the parent SOC address space and the size of the device's |
| 1115 | memory-mapped register file. |
| 1116 | |
| 1117 | For many devices that may exist inside an SOC, there are predefined |
| 1118 | specifications for the format of the device tree node. All SOC child |
| 1119 | nodes should follow these specifications, except where noted in this |
| 1120 | document. |
| 1121 | |
| 1122 | See appendix A for an example partial SOC node definition for the |
| 1123 | MPC8540. |
| 1124 | |
| 1125 | |
Stuart Yoder | 2756590 | 2007-03-02 13:42:33 -0600 | [diff] [blame] | 1126 | 2) Representing devices without a current OF specification |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1127 | ---------------------------------------------------------- |
| 1128 | |
| 1129 | Currently, there are many devices on SOCs that do not have a standard |
| 1130 | representation pre-defined as part of the open firmware |
| 1131 | specifications, mainly because the boards that contain these SOCs are |
| 1132 | not currently booted using open firmware. This section contains |
| 1133 | descriptions for the SOC devices for which new nodes have been |
| 1134 | defined; this list will expand as more and more SOC-containing |
| 1135 | platforms are moved over to use the flattened-device-tree model. |
| 1136 | |
| 1137 | a) MDIO IO device |
| 1138 | |
| 1139 | The MDIO is a bus to which the PHY devices are connected. For each |
| 1140 | device that exists on this bus, a child node should be created. See |
| 1141 | the definition of the PHY node below for an example of how to define |
| 1142 | a PHY. |
| 1143 | |
| 1144 | Required properties: |
| 1145 | - reg : Offset and length of the register set for the device |
| 1146 | - device_type : Should be "mdio" |
| 1147 | - compatible : Should define the compatible device type for the |
| 1148 | mdio. Currently, this is most likely to be "gianfar" |
| 1149 | |
| 1150 | Example: |
| 1151 | |
| 1152 | mdio@24520 { |
| 1153 | reg = <24520 20>; |
Becky Bruce | 7d4b95a | 2006-02-06 14:26:31 -0600 | [diff] [blame] | 1154 | device_type = "mdio"; |
| 1155 | compatible = "gianfar"; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1156 | |
| 1157 | ethernet-phy@0 { |
| 1158 | ...... |
| 1159 | }; |
| 1160 | }; |
| 1161 | |
| 1162 | |
| 1163 | b) Gianfar-compatible ethernet nodes |
| 1164 | |
| 1165 | Required properties: |
| 1166 | |
| 1167 | - device_type : Should be "network" |
| 1168 | - model : Model of the device. Can be "TSEC", "eTSEC", or "FEC" |
| 1169 | - compatible : Should be "gianfar" |
| 1170 | - reg : Offset and length of the register set for the device |
Jon Loeliger | f583165 | 2006-08-17 08:42:35 -0500 | [diff] [blame] | 1171 | - mac-address : List of bytes representing the ethernet address of |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1172 | this controller |
| 1173 | - interrupts : <a b> where a is the interrupt number and b is a |
| 1174 | field that represents an encoding of the sense and level |
| 1175 | information for the interrupt. This should be encoded based on |
| 1176 | the information in section 2) depending on the type of interrupt |
| 1177 | controller you have. |
| 1178 | - interrupt-parent : the phandle for the interrupt controller that |
| 1179 | services interrupts for this device. |
| 1180 | - phy-handle : The phandle for the PHY connected to this ethernet |
| 1181 | controller. |
| 1182 | |
Scott Wood | e0a2f28 | 2007-03-16 12:28:46 -0500 | [diff] [blame] | 1183 | Recommended properties: |
| 1184 | |
| 1185 | - linux,network-index : This is the intended "index" of this |
| 1186 | network device. This is used by the bootwrapper to interpret |
| 1187 | MAC addresses passed by the firmware when no information other |
| 1188 | than indices is available to associate an address with a device. |
| 1189 | |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1190 | Example: |
| 1191 | |
| 1192 | ethernet@24000 { |
| 1193 | #size-cells = <0>; |
| 1194 | device_type = "network"; |
| 1195 | model = "TSEC"; |
| 1196 | compatible = "gianfar"; |
| 1197 | reg = <24000 1000>; |
Jon Loeliger | f583165 | 2006-08-17 08:42:35 -0500 | [diff] [blame] | 1198 | mac-address = [ 00 E0 0C 00 73 00 ]; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1199 | interrupts = <d 3 e 3 12 3>; |
| 1200 | interrupt-parent = <40000>; |
| 1201 | phy-handle = <2452000> |
| 1202 | }; |
| 1203 | |
| 1204 | |
| 1205 | |
| 1206 | c) PHY nodes |
| 1207 | |
| 1208 | Required properties: |
| 1209 | |
| 1210 | - device_type : Should be "ethernet-phy" |
| 1211 | - interrupts : <a b> where a is the interrupt number and b is a |
| 1212 | field that represents an encoding of the sense and level |
| 1213 | information for the interrupt. This should be encoded based on |
| 1214 | the information in section 2) depending on the type of interrupt |
| 1215 | controller you have. |
| 1216 | - interrupt-parent : the phandle for the interrupt controller that |
| 1217 | services interrupts for this device. |
| 1218 | - reg : The ID number for the phy, usually a small integer |
| 1219 | - linux,phandle : phandle for this node; likely referenced by an |
| 1220 | ethernet controller node. |
| 1221 | |
| 1222 | |
| 1223 | Example: |
| 1224 | |
| 1225 | ethernet-phy@0 { |
| 1226 | linux,phandle = <2452000> |
| 1227 | interrupt-parent = <40000>; |
| 1228 | interrupts = <35 1>; |
| 1229 | reg = <0>; |
| 1230 | device_type = "ethernet-phy"; |
| 1231 | }; |
| 1232 | |
| 1233 | |
| 1234 | d) Interrupt controllers |
| 1235 | |
| 1236 | Some SOC devices contain interrupt controllers that are different |
| 1237 | from the standard Open PIC specification. The SOC device nodes for |
| 1238 | these types of controllers should be specified just like a standard |
| 1239 | OpenPIC controller. Sense and level information should be encoded |
| 1240 | as specified in section 2) of this chapter for each device that |
| 1241 | specifies an interrupt. |
| 1242 | |
| 1243 | Example : |
| 1244 | |
| 1245 | pic@40000 { |
| 1246 | linux,phandle = <40000>; |
| 1247 | clock-frequency = <0>; |
| 1248 | interrupt-controller; |
| 1249 | #address-cells = <0>; |
| 1250 | reg = <40000 40000>; |
| 1251 | built-in; |
| 1252 | compatible = "chrp,open-pic"; |
| 1253 | device_type = "open-pic"; |
| 1254 | big-endian; |
| 1255 | }; |
| 1256 | |
| 1257 | |
| 1258 | e) I2C |
| 1259 | |
| 1260 | Required properties : |
| 1261 | |
| 1262 | - device_type : Should be "i2c" |
| 1263 | - reg : Offset and length of the register set for the device |
| 1264 | |
| 1265 | Recommended properties : |
| 1266 | |
| 1267 | - compatible : Should be "fsl-i2c" for parts compatible with |
| 1268 | Freescale I2C specifications. |
| 1269 | - interrupts : <a b> where a is the interrupt number and b is a |
| 1270 | field that represents an encoding of the sense and level |
| 1271 | information for the interrupt. This should be encoded based on |
| 1272 | the information in section 2) depending on the type of interrupt |
| 1273 | controller you have. |
| 1274 | - interrupt-parent : the phandle for the interrupt controller that |
| 1275 | services interrupts for this device. |
| 1276 | - dfsrr : boolean; if defined, indicates that this I2C device has |
| 1277 | a digital filter sampling rate register |
| 1278 | - fsl5200-clocking : boolean; if defined, indicated that this device |
| 1279 | uses the FSL 5200 clocking mechanism. |
| 1280 | |
| 1281 | Example : |
| 1282 | |
| 1283 | i2c@3000 { |
| 1284 | interrupt-parent = <40000>; |
| 1285 | interrupts = <1b 3>; |
| 1286 | reg = <3000 18>; |
| 1287 | device_type = "i2c"; |
| 1288 | compatible = "fsl-i2c"; |
| 1289 | dfsrr; |
| 1290 | }; |
| 1291 | |
| 1292 | |
Becky Bruce | ad71f12 | 2006-02-07 13:44:08 -0600 | [diff] [blame] | 1293 | f) Freescale SOC USB controllers |
| 1294 | |
| 1295 | The device node for a USB controller that is part of a Freescale |
| 1296 | SOC is as described in the document "Open Firmware Recommended |
| 1297 | Practice : Universal Serial Bus" with the following modifications |
| 1298 | and additions : |
| 1299 | |
| 1300 | Required properties : |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 1301 | - compatible : Should be "fsl-usb2-mph" for multi port host USB |
| 1302 | controllers, or "fsl-usb2-dr" for dual role USB controllers |
| 1303 | - phy_type : For multi port host USB controllers, should be one of |
| 1304 | "ulpi", or "serial". For dual role USB controllers, should be |
Becky Bruce | ad71f12 | 2006-02-07 13:44:08 -0600 | [diff] [blame] | 1305 | one of "ulpi", "utmi", "utmi_wide", or "serial". |
| 1306 | - reg : Offset and length of the register set for the device |
| 1307 | - port0 : boolean; if defined, indicates port0 is connected for |
| 1308 | fsl-usb2-mph compatible controllers. Either this property or |
| 1309 | "port1" (or both) must be defined for "fsl-usb2-mph" compatible |
| 1310 | controllers. |
| 1311 | - port1 : boolean; if defined, indicates port1 is connected for |
| 1312 | fsl-usb2-mph compatible controllers. Either this property or |
| 1313 | "port0" (or both) must be defined for "fsl-usb2-mph" compatible |
| 1314 | controllers. |
Li Yang | ea5b7a6 | 2007-02-07 13:51:09 +0800 | [diff] [blame] | 1315 | - dr_mode : indicates the working mode for "fsl-usb2-dr" compatible |
| 1316 | controllers. Can be "host", "peripheral", or "otg". Default to |
| 1317 | "host" if not defined for backward compatibility. |
Becky Bruce | ad71f12 | 2006-02-07 13:44:08 -0600 | [diff] [blame] | 1318 | |
| 1319 | Recommended properties : |
| 1320 | - interrupts : <a b> where a is the interrupt number and b is a |
| 1321 | field that represents an encoding of the sense and level |
| 1322 | information for the interrupt. This should be encoded based on |
| 1323 | the information in section 2) depending on the type of interrupt |
| 1324 | controller you have. |
| 1325 | - interrupt-parent : the phandle for the interrupt controller that |
| 1326 | services interrupts for this device. |
| 1327 | |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 1328 | Example multi port host USB controller device node : |
Becky Bruce | ad71f12 | 2006-02-07 13:44:08 -0600 | [diff] [blame] | 1329 | usb@22000 { |
| 1330 | device_type = "usb"; |
| 1331 | compatible = "fsl-usb2-mph"; |
| 1332 | reg = <22000 1000>; |
| 1333 | #address-cells = <1>; |
| 1334 | #size-cells = <0>; |
| 1335 | interrupt-parent = <700>; |
| 1336 | interrupts = <27 1>; |
| 1337 | phy_type = "ulpi"; |
| 1338 | port0; |
| 1339 | port1; |
| 1340 | }; |
| 1341 | |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 1342 | Example dual role USB controller device node : |
Becky Bruce | ad71f12 | 2006-02-07 13:44:08 -0600 | [diff] [blame] | 1343 | usb@23000 { |
| 1344 | device_type = "usb"; |
| 1345 | compatible = "fsl-usb2-dr"; |
| 1346 | reg = <23000 1000>; |
| 1347 | #address-cells = <1>; |
| 1348 | #size-cells = <0>; |
| 1349 | interrupt-parent = <700>; |
| 1350 | interrupts = <26 1>; |
Li Yang | ea5b7a6 | 2007-02-07 13:51:09 +0800 | [diff] [blame] | 1351 | dr_mode = "otg"; |
Becky Bruce | ad71f12 | 2006-02-07 13:44:08 -0600 | [diff] [blame] | 1352 | phy = "ulpi"; |
| 1353 | }; |
| 1354 | |
| 1355 | |
Kim Phillips | b88a0b1 | 2006-03-22 14:39:03 -0600 | [diff] [blame] | 1356 | g) Freescale SOC SEC Security Engines |
| 1357 | |
| 1358 | Required properties: |
| 1359 | |
| 1360 | - device_type : Should be "crypto" |
| 1361 | - model : Model of the device. Should be "SEC1" or "SEC2" |
| 1362 | - compatible : Should be "talitos" |
| 1363 | - reg : Offset and length of the register set for the device |
| 1364 | - interrupts : <a b> where a is the interrupt number and b is a |
| 1365 | field that represents an encoding of the sense and level |
| 1366 | information for the interrupt. This should be encoded based on |
| 1367 | the information in section 2) depending on the type of interrupt |
| 1368 | controller you have. |
| 1369 | - interrupt-parent : the phandle for the interrupt controller that |
| 1370 | services interrupts for this device. |
| 1371 | - num-channels : An integer representing the number of channels |
| 1372 | available. |
| 1373 | - channel-fifo-len : An integer representing the number of |
| 1374 | descriptor pointers each channel fetch fifo can hold. |
| 1375 | - exec-units-mask : The bitmask representing what execution units |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 1376 | (EUs) are available. It's a single 32-bit cell. EU information |
Kim Phillips | b88a0b1 | 2006-03-22 14:39:03 -0600 | [diff] [blame] | 1377 | should be encoded following the SEC's Descriptor Header Dword |
| 1378 | EU_SEL0 field documentation, i.e. as follows: |
| 1379 | |
| 1380 | bit 0 = reserved - should be 0 |
| 1381 | bit 1 = set if SEC has the ARC4 EU (AFEU) |
| 1382 | bit 2 = set if SEC has the DES/3DES EU (DEU) |
| 1383 | bit 3 = set if SEC has the message digest EU (MDEU) |
| 1384 | bit 4 = set if SEC has the random number generator EU (RNG) |
| 1385 | bit 5 = set if SEC has the public key EU (PKEU) |
| 1386 | bit 6 = set if SEC has the AES EU (AESU) |
| 1387 | bit 7 = set if SEC has the Kasumi EU (KEU) |
| 1388 | |
| 1389 | bits 8 through 31 are reserved for future SEC EUs. |
| 1390 | |
| 1391 | - descriptor-types-mask : The bitmask representing what descriptors |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 1392 | are available. It's a single 32-bit cell. Descriptor type |
Kim Phillips | b88a0b1 | 2006-03-22 14:39:03 -0600 | [diff] [blame] | 1393 | information should be encoded following the SEC's Descriptor |
| 1394 | Header Dword DESC_TYPE field documentation, i.e. as follows: |
| 1395 | |
| 1396 | bit 0 = set if SEC supports the aesu_ctr_nonsnoop desc. type |
| 1397 | bit 1 = set if SEC supports the ipsec_esp descriptor type |
| 1398 | bit 2 = set if SEC supports the common_nonsnoop desc. type |
| 1399 | bit 3 = set if SEC supports the 802.11i AES ccmp desc. type |
| 1400 | bit 4 = set if SEC supports the hmac_snoop_no_afeu desc. type |
| 1401 | bit 5 = set if SEC supports the srtp descriptor type |
| 1402 | bit 6 = set if SEC supports the non_hmac_snoop_no_afeu desc.type |
| 1403 | bit 7 = set if SEC supports the pkeu_assemble descriptor type |
| 1404 | bit 8 = set if SEC supports the aesu_key_expand_output desc.type |
| 1405 | bit 9 = set if SEC supports the pkeu_ptmul descriptor type |
| 1406 | bit 10 = set if SEC supports the common_nonsnoop_afeu desc. type |
| 1407 | bit 11 = set if SEC supports the pkeu_ptadd_dbl descriptor type |
| 1408 | |
| 1409 | ..and so on and so forth. |
| 1410 | |
| 1411 | Example: |
| 1412 | |
| 1413 | /* MPC8548E */ |
| 1414 | crypto@30000 { |
| 1415 | device_type = "crypto"; |
| 1416 | model = "SEC2"; |
| 1417 | compatible = "talitos"; |
| 1418 | reg = <30000 10000>; |
| 1419 | interrupts = <1d 3>; |
| 1420 | interrupt-parent = <40000>; |
| 1421 | num-channels = <4>; |
Kim Phillips | cbdb54d | 2006-07-03 15:10:14 -0500 | [diff] [blame] | 1422 | channel-fifo-len = <18>; |
Kim Phillips | b88a0b1 | 2006-03-22 14:39:03 -0600 | [diff] [blame] | 1423 | exec-units-mask = <000000fe>; |
Kim Phillips | cbdb54d | 2006-07-03 15:10:14 -0500 | [diff] [blame] | 1424 | descriptor-types-mask = <012b0ebf>; |
Kim Phillips | b88a0b1 | 2006-03-22 14:39:03 -0600 | [diff] [blame] | 1425 | }; |
| 1426 | |
Li Yang | 9a1ab88 | 2006-10-02 20:08:59 -0500 | [diff] [blame] | 1427 | h) Board Control and Status (BCSR) |
| 1428 | |
| 1429 | Required properties: |
| 1430 | |
| 1431 | - device_type : Should be "board-control" |
| 1432 | - reg : Offset and length of the register set for the device |
| 1433 | |
| 1434 | Example: |
| 1435 | |
| 1436 | bcsr@f8000000 { |
| 1437 | device_type = "board-control"; |
| 1438 | reg = <f8000000 8000>; |
| 1439 | }; |
| 1440 | |
| 1441 | i) Freescale QUICC Engine module (QE) |
| 1442 | This represents qe module that is installed on PowerQUICC II Pro. |
| 1443 | Hopefully it will merge backward compatibility with CPM/CPM2. |
| 1444 | Basically, it is a bus of devices, that could act more or less |
| 1445 | as a complete entity (UCC, USB etc ). All of them should be siblings on |
| 1446 | the "root" qe node, using the common properties from there. |
Michael Opdenacker | 59c5159 | 2007-05-09 08:57:56 +0200 | [diff] [blame] | 1447 | The description below applies to the qe of MPC8360 and |
Li Yang | 9a1ab88 | 2006-10-02 20:08:59 -0500 | [diff] [blame] | 1448 | more nodes and properties would be extended in the future. |
| 1449 | |
| 1450 | i) Root QE device |
| 1451 | |
| 1452 | Required properties: |
| 1453 | - device_type : should be "qe"; |
| 1454 | - model : precise model of the QE, Can be "QE", "CPM", or "CPM2" |
| 1455 | - reg : offset and length of the device registers. |
| 1456 | - bus-frequency : the clock frequency for QUICC Engine. |
| 1457 | |
| 1458 | Recommended properties |
| 1459 | - brg-frequency : the internal clock source frequency for baud-rate |
| 1460 | generators in Hz. |
| 1461 | |
| 1462 | Example: |
| 1463 | qe@e0100000 { |
| 1464 | #address-cells = <1>; |
| 1465 | #size-cells = <1>; |
| 1466 | #interrupt-cells = <2>; |
| 1467 | device_type = "qe"; |
| 1468 | model = "QE"; |
| 1469 | ranges = <0 e0100000 00100000>; |
| 1470 | reg = <e0100000 480>; |
| 1471 | brg-frequency = <0>; |
| 1472 | bus-frequency = <179A7B00>; |
| 1473 | } |
| 1474 | |
| 1475 | |
| 1476 | ii) SPI (Serial Peripheral Interface) |
| 1477 | |
| 1478 | Required properties: |
| 1479 | - device_type : should be "spi". |
| 1480 | - compatible : should be "fsl_spi". |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 1481 | - mode : the SPI operation mode, it can be "cpu" or "qe". |
Li Yang | 9a1ab88 | 2006-10-02 20:08:59 -0500 | [diff] [blame] | 1482 | - reg : Offset and length of the register set for the device |
| 1483 | - interrupts : <a b> where a is the interrupt number and b is a |
| 1484 | field that represents an encoding of the sense and level |
| 1485 | information for the interrupt. This should be encoded based on |
| 1486 | the information in section 2) depending on the type of interrupt |
| 1487 | controller you have. |
| 1488 | - interrupt-parent : the phandle for the interrupt controller that |
| 1489 | services interrupts for this device. |
| 1490 | |
| 1491 | Example: |
| 1492 | spi@4c0 { |
| 1493 | device_type = "spi"; |
| 1494 | compatible = "fsl_spi"; |
| 1495 | reg = <4c0 40>; |
| 1496 | interrupts = <82 0>; |
| 1497 | interrupt-parent = <700>; |
| 1498 | mode = "cpu"; |
| 1499 | }; |
| 1500 | |
| 1501 | |
| 1502 | iii) USB (Universal Serial Bus Controller) |
| 1503 | |
| 1504 | Required properties: |
| 1505 | - device_type : should be "usb". |
| 1506 | - compatible : could be "qe_udc" or "fhci-hcd". |
| 1507 | - mode : the could be "host" or "slave". |
| 1508 | - reg : Offset and length of the register set for the device |
| 1509 | - interrupts : <a b> where a is the interrupt number and b is a |
| 1510 | field that represents an encoding of the sense and level |
| 1511 | information for the interrupt. This should be encoded based on |
| 1512 | the information in section 2) depending on the type of interrupt |
| 1513 | controller you have. |
| 1514 | - interrupt-parent : the phandle for the interrupt controller that |
| 1515 | services interrupts for this device. |
| 1516 | |
| 1517 | Example(slave): |
| 1518 | usb@6c0 { |
| 1519 | device_type = "usb"; |
| 1520 | compatible = "qe_udc"; |
| 1521 | reg = <6c0 40>; |
| 1522 | interrupts = <8b 0>; |
| 1523 | interrupt-parent = <700>; |
| 1524 | mode = "slave"; |
| 1525 | }; |
| 1526 | |
| 1527 | |
| 1528 | iv) UCC (Unified Communications Controllers) |
| 1529 | |
| 1530 | Required properties: |
| 1531 | - device_type : should be "network", "hldc", "uart", "transparent" |
| 1532 | "bisync" or "atm". |
| 1533 | - compatible : could be "ucc_geth" or "fsl_atm" and so on. |
| 1534 | - model : should be "UCC". |
| 1535 | - device-id : the ucc number(1-8), corresponding to UCCx in UM. |
| 1536 | - reg : Offset and length of the register set for the device |
| 1537 | - interrupts : <a b> where a is the interrupt number and b is a |
| 1538 | field that represents an encoding of the sense and level |
| 1539 | information for the interrupt. This should be encoded based on |
| 1540 | the information in section 2) depending on the type of interrupt |
| 1541 | controller you have. |
| 1542 | - interrupt-parent : the phandle for the interrupt controller that |
| 1543 | services interrupts for this device. |
| 1544 | - pio-handle : The phandle for the Parallel I/O port configuration. |
| 1545 | - rx-clock : represents the UCC receive clock source. |
| 1546 | 0x00 : clock source is disabled; |
| 1547 | 0x1~0x10 : clock source is BRG1~BRG16 respectively; |
| 1548 | 0x11~0x28: clock source is QE_CLK1~QE_CLK24 respectively. |
| 1549 | - tx-clock: represents the UCC transmit clock source; |
| 1550 | 0x00 : clock source is disabled; |
| 1551 | 0x1~0x10 : clock source is BRG1~BRG16 respectively; |
| 1552 | 0x11~0x28: clock source is QE_CLK1~QE_CLK24 respectively. |
| 1553 | |
| 1554 | Required properties for network device_type: |
| 1555 | - mac-address : list of bytes representing the ethernet address. |
| 1556 | - phy-handle : The phandle for the PHY connected to this controller. |
| 1557 | |
Scott Wood | e0a2f28 | 2007-03-16 12:28:46 -0500 | [diff] [blame] | 1558 | Recommended properties: |
| 1559 | - linux,network-index : This is the intended "index" of this |
| 1560 | network device. This is used by the bootwrapper to interpret |
| 1561 | MAC addresses passed by the firmware when no information other |
| 1562 | than indices is available to associate an address with a device. |
Kim Phillips | 60c1922 | 2007-04-24 07:26:10 +1000 | [diff] [blame] | 1563 | - phy-connection-type : a string naming the controller/PHY interface type, |
| 1564 | i.e., "mii" (default), "rmii", "gmii", "rgmii", "rgmii-id", "tbi", |
| 1565 | or "rtbi". |
Scott Wood | e0a2f28 | 2007-03-16 12:28:46 -0500 | [diff] [blame] | 1566 | |
Li Yang | 9a1ab88 | 2006-10-02 20:08:59 -0500 | [diff] [blame] | 1567 | Example: |
| 1568 | ucc@2000 { |
| 1569 | device_type = "network"; |
| 1570 | compatible = "ucc_geth"; |
| 1571 | model = "UCC"; |
| 1572 | device-id = <1>; |
| 1573 | reg = <2000 200>; |
| 1574 | interrupts = <a0 0>; |
| 1575 | interrupt-parent = <700>; |
| 1576 | mac-address = [ 00 04 9f 00 23 23 ]; |
| 1577 | rx-clock = "none"; |
| 1578 | tx-clock = "clk9"; |
| 1579 | phy-handle = <212000>; |
Kim Phillips | 60c1922 | 2007-04-24 07:26:10 +1000 | [diff] [blame] | 1580 | phy-connection-type = "gmii"; |
Li Yang | 9a1ab88 | 2006-10-02 20:08:59 -0500 | [diff] [blame] | 1581 | pio-handle = <140001>; |
| 1582 | }; |
| 1583 | |
| 1584 | |
| 1585 | v) Parallel I/O Ports |
| 1586 | |
| 1587 | This node configures Parallel I/O ports for CPUs with QE support. |
| 1588 | The node should reside in the "soc" node of the tree. For each |
| 1589 | device that using parallel I/O ports, a child node should be created. |
| 1590 | See the definition of the Pin configuration nodes below for more |
| 1591 | information. |
| 1592 | |
| 1593 | Required properties: |
| 1594 | - device_type : should be "par_io". |
| 1595 | - reg : offset to the register set and its length. |
| 1596 | - num-ports : number of Parallel I/O ports |
| 1597 | |
| 1598 | Example: |
| 1599 | par_io@1400 { |
| 1600 | reg = <1400 100>; |
| 1601 | #address-cells = <1>; |
| 1602 | #size-cells = <0>; |
| 1603 | device_type = "par_io"; |
| 1604 | num-ports = <7>; |
| 1605 | ucc_pin@01 { |
| 1606 | ...... |
| 1607 | }; |
| 1608 | |
| 1609 | |
| 1610 | vi) Pin configuration nodes |
| 1611 | |
| 1612 | Required properties: |
| 1613 | - linux,phandle : phandle of this node; likely referenced by a QE |
| 1614 | device. |
| 1615 | - pio-map : array of pin configurations. Each pin is defined by 6 |
| 1616 | integers. The six numbers are respectively: port, pin, dir, |
| 1617 | open_drain, assignment, has_irq. |
| 1618 | - port : port number of the pin; 0-6 represent port A-G in UM. |
| 1619 | - pin : pin number in the port. |
| 1620 | - dir : direction of the pin, should encode as follows: |
| 1621 | |
| 1622 | 0 = The pin is disabled |
| 1623 | 1 = The pin is an output |
| 1624 | 2 = The pin is an input |
| 1625 | 3 = The pin is I/O |
| 1626 | |
| 1627 | - open_drain : indicates the pin is normal or wired-OR: |
| 1628 | |
| 1629 | 0 = The pin is actively driven as an output |
| 1630 | 1 = The pin is an open-drain driver. As an output, the pin is |
| 1631 | driven active-low, otherwise it is three-stated. |
| 1632 | |
| 1633 | - assignment : function number of the pin according to the Pin Assignment |
| 1634 | tables in User Manual. Each pin can have up to 4 possible functions in |
| 1635 | QE and two options for CPM. |
Matt LaPlante | a982ac0 | 2007-05-09 07:35:06 +0200 | [diff] [blame] | 1636 | - has_irq : indicates if the pin is used as source of external |
Li Yang | 9a1ab88 | 2006-10-02 20:08:59 -0500 | [diff] [blame] | 1637 | interrupts. |
| 1638 | |
| 1639 | Example: |
| 1640 | ucc_pin@01 { |
| 1641 | linux,phandle = <140001>; |
| 1642 | pio-map = < |
| 1643 | /* port pin dir open_drain assignment has_irq */ |
| 1644 | 0 3 1 0 1 0 /* TxD0 */ |
| 1645 | 0 4 1 0 1 0 /* TxD1 */ |
| 1646 | 0 5 1 0 1 0 /* TxD2 */ |
| 1647 | 0 6 1 0 1 0 /* TxD3 */ |
| 1648 | 1 6 1 0 3 0 /* TxD4 */ |
| 1649 | 1 7 1 0 1 0 /* TxD5 */ |
| 1650 | 1 9 1 0 2 0 /* TxD6 */ |
| 1651 | 1 a 1 0 2 0 /* TxD7 */ |
| 1652 | 0 9 2 0 1 0 /* RxD0 */ |
| 1653 | 0 a 2 0 1 0 /* RxD1 */ |
| 1654 | 0 b 2 0 1 0 /* RxD2 */ |
| 1655 | 0 c 2 0 1 0 /* RxD3 */ |
| 1656 | 0 d 2 0 1 0 /* RxD4 */ |
| 1657 | 1 1 2 0 2 0 /* RxD5 */ |
| 1658 | 1 0 2 0 2 0 /* RxD6 */ |
| 1659 | 1 4 2 0 2 0 /* RxD7 */ |
| 1660 | 0 7 1 0 1 0 /* TX_EN */ |
| 1661 | 0 8 1 0 1 0 /* TX_ER */ |
| 1662 | 0 f 2 0 1 0 /* RX_DV */ |
| 1663 | 0 10 2 0 1 0 /* RX_ER */ |
| 1664 | 0 0 2 0 1 0 /* RX_CLK */ |
| 1665 | 2 9 1 0 3 0 /* GTX_CLK - CLK10 */ |
| 1666 | 2 8 2 0 1 0>; /* GTX125 - CLK9 */ |
| 1667 | }; |
| 1668 | |
| 1669 | vii) Multi-User RAM (MURAM) |
| 1670 | |
| 1671 | Required properties: |
| 1672 | - device_type : should be "muram". |
| 1673 | - mode : the could be "host" or "slave". |
| 1674 | - ranges : Should be defined as specified in 1) to describe the |
| 1675 | translation of MURAM addresses. |
| 1676 | - data-only : sub-node which defines the address area under MURAM |
| 1677 | bus that can be allocated as data/parameter |
| 1678 | |
| 1679 | Example: |
| 1680 | |
| 1681 | muram@10000 { |
| 1682 | device_type = "muram"; |
| 1683 | ranges = <0 00010000 0000c000>; |
| 1684 | |
| 1685 | data-only@0{ |
| 1686 | reg = <0 c000>; |
| 1687 | }; |
| 1688 | }; |
Kim Phillips | b88a0b1 | 2006-03-22 14:39:03 -0600 | [diff] [blame] | 1689 | |
Stuart Yoder | d30ac12 | 2007-06-05 07:16:15 +1000 | [diff] [blame^] | 1690 | j) Flash chip nodes |
Vitaly Wool | 28f9ec3 | 2006-11-20 16:32:39 +0300 | [diff] [blame] | 1691 | |
| 1692 | Flash chips (Memory Technology Devices) are often used for solid state |
| 1693 | file systems on embedded devices. |
| 1694 | |
| 1695 | Required properties: |
| 1696 | |
| 1697 | - device_type : has to be "rom" |
Vitaly Wool | 173935f | 2006-12-19 18:44:25 +0300 | [diff] [blame] | 1698 | - compatible : Should specify what this flash device is compatible with. |
| 1699 | Currently, this is most likely to be "direct-mapped" (which |
| 1700 | corresponds to the MTD physmap mapping driver). |
| 1701 | - reg : Offset and length of the register set (or memory mapping) for |
Vitaly Wool | 28f9ec3 | 2006-11-20 16:32:39 +0300 | [diff] [blame] | 1702 | the device. |
Vitaly Wool | 173935f | 2006-12-19 18:44:25 +0300 | [diff] [blame] | 1703 | - bank-width : Width of the flash data bus in bytes. Required |
| 1704 | for the NOR flashes (compatible == "direct-mapped" and others) ONLY. |
Vitaly Wool | 28f9ec3 | 2006-11-20 16:32:39 +0300 | [diff] [blame] | 1705 | |
| 1706 | Recommended properties : |
| 1707 | |
Vitaly Wool | 28f9ec3 | 2006-11-20 16:32:39 +0300 | [diff] [blame] | 1708 | - partitions : Several pairs of 32-bit values where the first value is |
| 1709 | partition's offset from the start of the device and the second one is |
| 1710 | partition size in bytes with LSB used to signify a read only |
Domen Puncer | 5dd6016 | 2007-03-02 21:44:45 +1100 | [diff] [blame] | 1711 | partition (so, the partition size should always be an even number). |
Vitaly Wool | 28f9ec3 | 2006-11-20 16:32:39 +0300 | [diff] [blame] | 1712 | - partition-names : The list of concatenated zero terminated strings |
| 1713 | representing the partition names. |
Vitaly Wool | 173935f | 2006-12-19 18:44:25 +0300 | [diff] [blame] | 1714 | - probe-type : The type of probe which should be done for the chip |
| 1715 | (JEDEC vs CFI actually). Valid ONLY for NOR flashes. |
Vitaly Wool | 28f9ec3 | 2006-11-20 16:32:39 +0300 | [diff] [blame] | 1716 | |
| 1717 | Example: |
| 1718 | |
| 1719 | flash@ff000000 { |
| 1720 | device_type = "rom"; |
| 1721 | compatible = "direct-mapped"; |
Vitaly Wool | 173935f | 2006-12-19 18:44:25 +0300 | [diff] [blame] | 1722 | probe-type = "CFI"; |
| 1723 | reg = <ff000000 01000000>; |
Vitaly Wool | 28f9ec3 | 2006-11-20 16:32:39 +0300 | [diff] [blame] | 1724 | bank-width = <4>; |
| 1725 | partitions = <00000000 00f80000 |
| 1726 | 00f80000 00080001>; |
| 1727 | partition-names = "fs\0firmware"; |
| 1728 | }; |
| 1729 | |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1730 | More devices will be defined as this spec matures. |
| 1731 | |
Stuart Yoder | 2756590 | 2007-03-02 13:42:33 -0600 | [diff] [blame] | 1732 | VII - Specifying interrupt information for devices |
| 1733 | =================================================== |
| 1734 | |
| 1735 | The device tree represents the busses and devices of a hardware |
| 1736 | system in a form similar to the physical bus topology of the |
| 1737 | hardware. |
| 1738 | |
| 1739 | In addition, a logical 'interrupt tree' exists which represents the |
| 1740 | hierarchy and routing of interrupts in the hardware. |
| 1741 | |
| 1742 | The interrupt tree model is fully described in the |
| 1743 | document "Open Firmware Recommended Practice: Interrupt |
| 1744 | Mapping Version 0.9". The document is available at: |
| 1745 | <http://playground.sun.com/1275/practice>. |
| 1746 | |
| 1747 | 1) interrupts property |
| 1748 | ---------------------- |
| 1749 | |
| 1750 | Devices that generate interrupts to a single interrupt controller |
| 1751 | should use the conventional OF representation described in the |
| 1752 | OF interrupt mapping documentation. |
| 1753 | |
| 1754 | Each device which generates interrupts must have an 'interrupt' |
| 1755 | property. The interrupt property value is an arbitrary number of |
| 1756 | of 'interrupt specifier' values which describe the interrupt or |
| 1757 | interrupts for the device. |
| 1758 | |
| 1759 | The encoding of an interrupt specifier is determined by the |
| 1760 | interrupt domain in which the device is located in the |
| 1761 | interrupt tree. The root of an interrupt domain specifies in |
| 1762 | its #interrupt-cells property the number of 32-bit cells |
| 1763 | required to encode an interrupt specifier. See the OF interrupt |
| 1764 | mapping documentation for a detailed description of domains. |
| 1765 | |
| 1766 | For example, the binding for the OpenPIC interrupt controller |
| 1767 | specifies an #interrupt-cells value of 2 to encode the interrupt |
| 1768 | number and level/sense information. All interrupt children in an |
| 1769 | OpenPIC interrupt domain use 2 cells per interrupt in their interrupts |
| 1770 | property. |
| 1771 | |
| 1772 | The PCI bus binding specifies a #interrupt-cell value of 1 to encode |
| 1773 | which interrupt pin (INTA,INTB,INTC,INTD) is used. |
| 1774 | |
| 1775 | 2) interrupt-parent property |
| 1776 | ---------------------------- |
| 1777 | |
| 1778 | The interrupt-parent property is specified to define an explicit |
| 1779 | link between a device node and its interrupt parent in |
| 1780 | the interrupt tree. The value of interrupt-parent is the |
| 1781 | phandle of the parent node. |
| 1782 | |
| 1783 | If the interrupt-parent property is not defined for a node, it's |
| 1784 | interrupt parent is assumed to be an ancestor in the node's |
| 1785 | _device tree_ hierarchy. |
| 1786 | |
| 1787 | 3) OpenPIC Interrupt Controllers |
| 1788 | -------------------------------- |
| 1789 | |
| 1790 | OpenPIC interrupt controllers require 2 cells to encode |
| 1791 | interrupt information. The first cell defines the interrupt |
| 1792 | number. The second cell defines the sense and level |
| 1793 | information. |
| 1794 | |
| 1795 | Sense and level information should be encoded as follows: |
| 1796 | |
| 1797 | 0 = low to high edge sensitive type enabled |
| 1798 | 1 = active low level sensitive type enabled |
| 1799 | 2 = active high level sensitive type enabled |
| 1800 | 3 = high to low edge sensitive type enabled |
| 1801 | |
| 1802 | 4) ISA Interrupt Controllers |
| 1803 | ---------------------------- |
| 1804 | |
| 1805 | ISA PIC interrupt controllers require 2 cells to encode |
| 1806 | interrupt information. The first cell defines the interrupt |
| 1807 | number. The second cell defines the sense and level |
| 1808 | information. |
| 1809 | |
| 1810 | ISA PIC interrupt controllers should adhere to the ISA PIC |
| 1811 | encodings listed below: |
| 1812 | |
| 1813 | 0 = active low level sensitive type enabled |
| 1814 | 1 = active high level sensitive type enabled |
| 1815 | 2 = high to low edge sensitive type enabled |
| 1816 | 3 = low to high edge sensitive type enabled |
| 1817 | |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1818 | |
| 1819 | Appendix A - Sample SOC node for MPC8540 |
| 1820 | ======================================== |
| 1821 | |
| 1822 | Note that the #address-cells and #size-cells for the SoC node |
| 1823 | in this example have been explicitly listed; these are likely |
| 1824 | not necessary as they are usually the same as the root node. |
| 1825 | |
| 1826 | soc8540@e0000000 { |
| 1827 | #address-cells = <1>; |
| 1828 | #size-cells = <1>; |
| 1829 | #interrupt-cells = <2>; |
| 1830 | device_type = "soc"; |
| 1831 | ranges = <00000000 e0000000 00100000> |
| 1832 | reg = <e0000000 00003000>; |
Becky Bruce | 7d4b95a | 2006-02-06 14:26:31 -0600 | [diff] [blame] | 1833 | bus-frequency = <0>; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1834 | |
| 1835 | mdio@24520 { |
| 1836 | reg = <24520 20>; |
| 1837 | device_type = "mdio"; |
| 1838 | compatible = "gianfar"; |
| 1839 | |
| 1840 | ethernet-phy@0 { |
| 1841 | linux,phandle = <2452000> |
| 1842 | interrupt-parent = <40000>; |
| 1843 | interrupts = <35 1>; |
| 1844 | reg = <0>; |
| 1845 | device_type = "ethernet-phy"; |
| 1846 | }; |
| 1847 | |
| 1848 | ethernet-phy@1 { |
| 1849 | linux,phandle = <2452001> |
| 1850 | interrupt-parent = <40000>; |
| 1851 | interrupts = <35 1>; |
| 1852 | reg = <1>; |
| 1853 | device_type = "ethernet-phy"; |
| 1854 | }; |
| 1855 | |
| 1856 | ethernet-phy@3 { |
| 1857 | linux,phandle = <2452002> |
| 1858 | interrupt-parent = <40000>; |
| 1859 | interrupts = <35 1>; |
| 1860 | reg = <3>; |
| 1861 | device_type = "ethernet-phy"; |
| 1862 | }; |
| 1863 | |
| 1864 | }; |
| 1865 | |
| 1866 | ethernet@24000 { |
| 1867 | #size-cells = <0>; |
| 1868 | device_type = "network"; |
| 1869 | model = "TSEC"; |
| 1870 | compatible = "gianfar"; |
| 1871 | reg = <24000 1000>; |
Jon Loeliger | f583165 | 2006-08-17 08:42:35 -0500 | [diff] [blame] | 1872 | mac-address = [ 00 E0 0C 00 73 00 ]; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1873 | interrupts = <d 3 e 3 12 3>; |
| 1874 | interrupt-parent = <40000>; |
| 1875 | phy-handle = <2452000>; |
| 1876 | }; |
| 1877 | |
| 1878 | ethernet@25000 { |
| 1879 | #address-cells = <1>; |
| 1880 | #size-cells = <0>; |
| 1881 | device_type = "network"; |
| 1882 | model = "TSEC"; |
| 1883 | compatible = "gianfar"; |
| 1884 | reg = <25000 1000>; |
Jon Loeliger | f583165 | 2006-08-17 08:42:35 -0500 | [diff] [blame] | 1885 | mac-address = [ 00 E0 0C 00 73 01 ]; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1886 | interrupts = <13 3 14 3 18 3>; |
| 1887 | interrupt-parent = <40000>; |
| 1888 | phy-handle = <2452001>; |
| 1889 | }; |
| 1890 | |
| 1891 | ethernet@26000 { |
| 1892 | #address-cells = <1>; |
| 1893 | #size-cells = <0>; |
| 1894 | device_type = "network"; |
| 1895 | model = "FEC"; |
| 1896 | compatible = "gianfar"; |
| 1897 | reg = <26000 1000>; |
Jon Loeliger | f583165 | 2006-08-17 08:42:35 -0500 | [diff] [blame] | 1898 | mac-address = [ 00 E0 0C 00 73 02 ]; |
David Gibson | c125a18 | 2006-02-01 03:05:22 -0800 | [diff] [blame] | 1899 | interrupts = <19 3>; |
| 1900 | interrupt-parent = <40000>; |
| 1901 | phy-handle = <2452002>; |
| 1902 | }; |
| 1903 | |
| 1904 | serial@4500 { |
| 1905 | device_type = "serial"; |
| 1906 | compatible = "ns16550"; |
| 1907 | reg = <4500 100>; |
| 1908 | clock-frequency = <0>; |
| 1909 | interrupts = <1a 3>; |
| 1910 | interrupt-parent = <40000>; |
| 1911 | }; |
| 1912 | |
| 1913 | pic@40000 { |
| 1914 | linux,phandle = <40000>; |
| 1915 | clock-frequency = <0>; |
| 1916 | interrupt-controller; |
| 1917 | #address-cells = <0>; |
| 1918 | reg = <40000 40000>; |
| 1919 | built-in; |
| 1920 | compatible = "chrp,open-pic"; |
| 1921 | device_type = "open-pic"; |
| 1922 | big-endian; |
| 1923 | }; |
| 1924 | |
| 1925 | i2c@3000 { |
| 1926 | interrupt-parent = <40000>; |
| 1927 | interrupts = <1b 3>; |
| 1928 | reg = <3000 18>; |
| 1929 | device_type = "i2c"; |
| 1930 | compatible = "fsl-i2c"; |
| 1931 | dfsrr; |
| 1932 | }; |
| 1933 | |
| 1934 | }; |