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