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