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