Merge tag 'fscache-fixes-20141013' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / Documentation / devicetree / booting-without-of.txt
1            Booting the Linux/ppc kernel without Open Firmware
2            --------------------------------------------------
3
4 (c) 2005 Benjamin Herrenschmidt <benh at kernel.crashing.org>,
5     IBM Corp.
6 (c) 2005 Becky Bruce <becky.bruce at freescale.com>,
7     Freescale Semiconductor, FSL SOC and 32-bit additions
8 (c) 2006 MontaVista Software, Inc.
9     Flash chip node definition
10
11 Table of Contents
12 =================
13
14   I - Introduction
15     1) Entry point for arch/arm
16     2) Entry point for arch/powerpc
17     3) Entry point for arch/x86
18
19   II - The DT block format
20     1) Header
21     2) Device tree generalities
22     3) Device tree "structure" block
23     4) Device tree "strings" block
24
25   III - Required content of the device tree
26     1) Note about cells and address representation
27     2) Note about "compatible" properties
28     3) Note about "name" properties
29     4) Note about node and property names and character set
30     5) Required nodes and properties
31       a) The root node
32       b) The /cpus node
33       c) The /cpus/* nodes
34       d) the /memory node(s)
35       e) The /chosen node
36       f) the /soc<SOCname> node
37
38   IV - "dtc", the device tree compiler
39
40   V - Recommendations for a bootloader
41
42   VI - System-on-a-chip devices and nodes
43     1) Defining child nodes of an SOC
44     2) Representing devices without a current OF specification
45
46   VII - Specifying interrupt information for devices
47     1) interrupts property
48     2) interrupt-parent property
49     3) OpenPIC Interrupt Controllers
50     4) ISA Interrupt Controllers
51
52   VIII - Specifying device power management information (sleep property)
53
54   IX - Specifying dma bus information
55
56   Appendix A - Sample SOC node for MPC8540
57
58
59 Revision Information
60 ====================
61
62    May 18, 2005: Rev 0.1 - Initial draft, no chapter III yet.
63
64    May 19, 2005: Rev 0.2 - Add chapter III and bits & pieces here or
65                            clarifies the fact that a lot of things are
66                            optional, the kernel only requires a very
67                            small device tree, though it is encouraged
68                            to provide an as complete one as possible.
69
70    May 24, 2005: Rev 0.3 - Precise that DT block has to be in RAM
71                          - Misc fixes
72                          - Define version 3 and new format version 16
73                            for the DT block (version 16 needs kernel
74                            patches, will be fwd separately).
75                            String block now has a size, and full path
76                            is replaced by unit name for more
77                            compactness.
78                            linux,phandle is made optional, only nodes
79                            that are referenced by other nodes need it.
80                            "name" property is now automatically
81                            deduced from the unit name
82
83    June 1, 2005: Rev 0.4 - Correct confusion between OF_DT_END and
84                            OF_DT_END_NODE in structure definition.
85                          - Change version 16 format to always align
86                            property data to 4 bytes. Since tokens are
87                            already aligned, that means no specific
88                            required alignment between property size
89                            and property data. The old style variable
90                            alignment would make it impossible to do
91                            "simple" insertion of properties using
92                            memmove (thanks Milton for
93                            noticing). Updated kernel patch as well
94                          - Correct a few more alignment constraints
95                          - Add a chapter about the device-tree
96                            compiler and the textural representation of
97                            the tree that can be "compiled" by dtc.
98
99    November 21, 2005: Rev 0.5
100                          - Additions/generalizations for 32-bit
101                          - Changed to reflect the new arch/powerpc
102                            structure
103                          - Added chapter VI
104
105
106  ToDo:
107         - Add some definitions of interrupt tree (simple/complex)
108         - Add some definitions for PCI host bridges
109         - Add some common address format examples
110         - Add definitions for standard properties and "compatible"
111           names for cells that are not already defined by the existing
112           OF spec.
113         - Compare FSL SOC use of PCI to standard and make sure no new
114           node definition required.
115         - Add more information about node definitions for SOC devices
116           that currently have no standard, like the FSL CPM.
117
118
119 I - Introduction
120 ================
121
122 During the development of the Linux/ppc64 kernel, and more
123 specifically, the addition of new platform types outside of the old
124 IBM pSeries/iSeries pair, it was decided to enforce some strict rules
125 regarding the kernel entry and bootloader <-> kernel interfaces, in
126 order to avoid the degeneration that had become the ppc32 kernel entry
127 point and the way a new platform should be added to the kernel. The
128 legacy iSeries platform breaks those rules as it predates this scheme,
129 but no new board support will be accepted in the main tree that
130 doesn't follow them properly.  In addition, since the advent of the
131 arch/powerpc merged architecture for ppc32 and ppc64, new 32-bit
132 platforms and 32-bit platforms which move into arch/powerpc will be
133 required to use these rules as well.
134
135 The main requirement that will be defined in more detail below is
136 the presence of a device-tree whose format is defined after Open
137 Firmware specification. However, in order to make life easier
138 to embedded board vendors, the kernel doesn't require the device-tree
139 to represent every device in the system and only requires some nodes
140 and properties to be present. This will be described in detail in
141 section III, but, for example, the kernel does not require you to
142 create a node for every PCI device in the system. It is a requirement
143 to have a node for PCI host bridges in order to provide interrupt
144 routing information and memory/IO ranges, among others. It is also
145 recommended to define nodes for on chip devices and other buses that
146 don't specifically fit in an existing OF specification. This creates a
147 great flexibility in the way the kernel can then probe those and match
148 drivers to device, without having to hard code all sorts of tables. It
149 also makes it more flexible for board vendors to do minor hardware
150 upgrades without significantly impacting the kernel code or cluttering
151 it with special cases.
152
153
154 1) Entry point for arch/arm
155 ---------------------------
156
157    There is one single entry point to the kernel, at the start
158    of the kernel image. That entry point supports two calling
159    conventions.  A summary of the interface is described here.  A full
160    description of the boot requirements is documented in
161    Documentation/arm/Booting
162
163         a) ATAGS interface.  Minimal information is passed from firmware
164         to the kernel with a tagged list of predefined parameters.
165
166                 r0 : 0
167
168                 r1 : Machine type number
169
170                 r2 : Physical address of tagged list in system RAM
171
172         b) Entry with a flattened device-tree block.  Firmware loads the
173         physical address of the flattened device tree block (dtb) into r2,
174         r1 is not used, but it is considered good practice to use a valid
175         machine number as described in Documentation/arm/Booting.
176
177                 r0 : 0
178
179                 r1 : Valid machine type number.  When using a device tree,
180                 a single machine type number will often be assigned to
181                 represent a class or family of SoCs.
182
183                 r2 : physical pointer to the device-tree block
184                 (defined in chapter II) in RAM.  Device tree can be located
185                 anywhere in system RAM, but it should be aligned on a 64 bit
186                 boundary.
187
188    The kernel will differentiate between ATAGS and device tree booting by
189    reading the memory pointed to by r2 and looking for either the flattened
190    device tree block magic value (0xd00dfeed) or the ATAG_CORE value at
191    offset 0x4 from r2 (0x54410001).
192
193 2) Entry point for arch/powerpc
194 -------------------------------
195
196    There is one single entry point to the kernel, at the start
197    of the kernel image. That entry point supports two calling
198    conventions:
199
200         a) Boot from Open Firmware. If your firmware is compatible
201         with Open Firmware (IEEE 1275) or provides an OF compatible
202         client interface API (support for "interpret" callback of
203         forth words isn't required), you can enter the kernel with:
204
205               r5 : OF callback pointer as defined by IEEE 1275
206               bindings to powerpc. Only the 32-bit client interface
207               is currently supported
208
209               r3, r4 : address & length of an initrd if any or 0
210
211               The MMU is either on or off; the kernel will run the
212               trampoline located in arch/powerpc/kernel/prom_init.c to
213               extract the device-tree and other information from open
214               firmware and build a flattened device-tree as described
215               in b). prom_init() will then re-enter the kernel using
216               the second method. This trampoline code runs in the
217               context of the firmware, which is supposed to handle all
218               exceptions during that time.
219
220         b) Direct entry with a flattened device-tree block. This entry
221         point is called by a) after the OF trampoline and can also be
222         called directly by a bootloader that does not support the Open
223         Firmware client interface. It is also used by "kexec" to
224         implement "hot" booting of a new kernel from a previous
225         running one. This method is what I will describe in more
226         details in this document, as method a) is simply standard Open
227         Firmware, and thus should be implemented according to the
228         various standard documents defining it and its binding to the
229         PowerPC platform. The entry point definition then becomes:
230
231                 r3 : physical pointer to the device-tree block
232                 (defined in chapter II) in RAM
233
234                 r4 : physical pointer to the kernel itself. This is
235                 used by the assembly code to properly disable the MMU
236                 in case you are entering the kernel with MMU enabled
237                 and a non-1:1 mapping.
238
239                 r5 : NULL (as to differentiate with method a)
240
241         Note about SMP entry: Either your firmware puts your other
242         CPUs in some sleep loop or spin loop in ROM where you can get
243         them out via a soft reset or some other means, in which case
244         you don't need to care, or you'll have to enter the kernel
245         with all CPUs. The way to do that with method b) will be
246         described in a later revision of this document.
247
248    Board supports (platforms) are not exclusive config options. An
249    arbitrary set of board supports can be built in a single kernel
250    image. The kernel will "know" what set of functions to use for a
251    given platform based on the content of the device-tree. Thus, you
252    should:
253
254         a) add your platform support as a _boolean_ option in
255         arch/powerpc/Kconfig, following the example of PPC_PSERIES,
256         PPC_PMAC and PPC_MAPLE. The later is probably a good
257         example of a board support to start from.
258
259         b) create your main platform file as
260         "arch/powerpc/platforms/myplatform/myboard_setup.c" and add it
261         to the Makefile under the condition of your CONFIG_
262         option. This file will define a structure of type "ppc_md"
263         containing the various callbacks that the generic code will
264         use to get to your platform specific code
265
266   A kernel image may support multiple platforms, but only if the
267   platforms feature the same core architecture.  A single kernel build
268   cannot support both configurations with Book E and configurations
269   with classic Powerpc architectures.
270
271 3) Entry point for arch/x86
272 -------------------------------
273
274   There is one single 32bit entry point to the kernel at code32_start,
275   the decompressor (the real mode entry point goes to the same  32bit
276   entry point once it switched into protected mode). That entry point
277   supports one calling convention which is documented in
278   Documentation/x86/boot.txt
279   The physical pointer to the device-tree block (defined in chapter II)
280   is passed via setup_data which requires at least boot protocol 2.09.
281   The type filed is defined as
282
283   #define SETUP_DTB                      2
284
285   This device-tree is used as an extension to the "boot page". As such it
286   does not parse / consider data which is already covered by the boot
287   page. This includes memory size, reserved ranges, command line arguments
288   or initrd address. It simply holds information which can not be retrieved
289   otherwise like interrupt routing or a list of devices behind an I2C bus.
290
291 II - The DT block format
292 ========================
293
294
295 This chapter defines the actual format of the flattened device-tree
296 passed to the kernel. The actual content of it and kernel requirements
297 are described later. You can find example of code manipulating that
298 format in various places, including arch/powerpc/kernel/prom_init.c
299 which will generate a flattened device-tree from the Open Firmware
300 representation, or the fs2dt utility which is part of the kexec tools
301 which will generate one from a filesystem representation. It is
302 expected that a bootloader like uboot provides a bit more support,
303 that will be discussed later as well.
304
305 Note: The block has to be in main memory. It has to be accessible in
306 both real mode and virtual mode with no mapping other than main
307 memory. If you are writing a simple flash bootloader, it should copy
308 the block to RAM before passing it to the kernel.
309
310
311 1) Header
312 ---------
313
314    The kernel is passed the physical address pointing to an area of memory
315    that is roughly described in include/linux/of_fdt.h by the structure
316    boot_param_header:
317
318 struct boot_param_header {
319         u32     magic;                  /* magic word OF_DT_HEADER */
320         u32     totalsize;              /* total size of DT block */
321         u32     off_dt_struct;          /* offset to structure */
322         u32     off_dt_strings;         /* offset to strings */
323         u32     off_mem_rsvmap;         /* offset to memory reserve map
324                                            */
325         u32     version;                /* format version */
326         u32     last_comp_version;      /* last compatible version */
327
328         /* version 2 fields below */
329         u32     boot_cpuid_phys;        /* Which physical CPU id we're
330                                            booting on */
331         /* version 3 fields below */
332         u32     size_dt_strings;        /* size of the strings block */
333
334         /* version 17 fields below */
335         u32     size_dt_struct;         /* size of the DT structure block */
336 };
337
338    Along with the constants:
339
340 /* Definitions used by the flattened device tree */
341 #define OF_DT_HEADER            0xd00dfeed      /* 4: version,
342                                                    4: total size */
343 #define OF_DT_BEGIN_NODE        0x1             /* Start node: full name
344                                                    */
345 #define OF_DT_END_NODE          0x2             /* End node */
346 #define OF_DT_PROP              0x3             /* Property: name off,
347                                                    size, content */
348 #define OF_DT_END               0x9
349
350    All values in this header are in big endian format, the various
351    fields in this header are defined more precisely below. All
352    "offset" values are in bytes from the start of the header; that is
353    from the physical base address of the device tree block.
354
355    - magic
356
357      This is a magic value that "marks" the beginning of the
358      device-tree block header. It contains the value 0xd00dfeed and is
359      defined by the constant OF_DT_HEADER
360
361    - totalsize
362
363      This is the total size of the DT block including the header. The
364      "DT" block should enclose all data structures defined in this
365      chapter (who are pointed to by offsets in this header). That is,
366      the device-tree structure, strings, and the memory reserve map.
367
368    - off_dt_struct
369
370      This is an offset from the beginning of the header to the start
371      of the "structure" part the device tree. (see 2) device tree)
372
373    - off_dt_strings
374
375      This is an offset from the beginning of the header to the start
376      of the "strings" part of the device-tree
377
378    - off_mem_rsvmap
379
380      This is an offset from the beginning of the header to the start
381      of the reserved memory map. This map is a list of pairs of 64-
382      bit integers. Each pair is a physical address and a size. The
383      list is terminated by an entry of size 0. This map provides the
384      kernel with a list of physical memory areas that are "reserved"
385      and thus not to be used for memory allocations, especially during
386      early initialization. The kernel needs to allocate memory during
387      boot for things like un-flattening the device-tree, allocating an
388      MMU hash table, etc... Those allocations must be done in such a
389      way to avoid overriding critical things like, on Open Firmware
390      capable machines, the RTAS instance, or on some pSeries, the TCE
391      tables used for the iommu. Typically, the reserve map should
392      contain _at least_ this DT block itself (header,total_size). If
393      you are passing an initrd to the kernel, you should reserve it as
394      well. You do not need to reserve the kernel image itself. The map
395      should be 64-bit aligned.
396
397    - version
398
399      This is the version of this structure. Version 1 stops
400      here. Version 2 adds an additional field boot_cpuid_phys.
401      Version 3 adds the size of the strings block, allowing the kernel
402      to reallocate it easily at boot and free up the unused flattened
403      structure after expansion. Version 16 introduces a new more
404      "compact" format for the tree itself that is however not backward
405      compatible. Version 17 adds an additional field, size_dt_struct,
406      allowing it to be reallocated or moved more easily (this is
407      particularly useful for bootloaders which need to make
408      adjustments to a device tree based on probed information). You
409      should always generate a structure of the highest version defined
410      at the time of your implementation. Currently that is version 17,
411      unless you explicitly aim at being backward compatible.
412
413    - last_comp_version
414
415      Last compatible version. This indicates down to what version of
416      the DT block you are backward compatible. For example, version 2
417      is backward compatible with version 1 (that is, a kernel build
418      for version 1 will be able to boot with a version 2 format). You
419      should put a 1 in this field if you generate a device tree of
420      version 1 to 3, or 16 if you generate a tree of version 16 or 17
421      using the new unit name format.
422
423    - boot_cpuid_phys
424
425      This field only exist on version 2 headers. It indicate which
426      physical CPU ID is calling the kernel entry point. This is used,
427      among others, by kexec. If you are on an SMP system, this value
428      should match the content of the "reg" property of the CPU node in
429      the device-tree corresponding to the CPU calling the kernel entry
430      point (see further chapters for more information on the required
431      device-tree contents)
432
433    - size_dt_strings
434
435      This field only exists on version 3 and later headers.  It
436      gives the size of the "strings" section of the device tree (which
437      starts at the offset given by off_dt_strings).
438
439    - size_dt_struct
440
441      This field only exists on version 17 and later headers.  It gives
442      the size of the "structure" section of the device tree (which
443      starts at the offset given by off_dt_struct).
444
445    So the typical layout of a DT block (though the various parts don't
446    need to be in that order) looks like this (addresses go from top to
447    bottom):
448
449
450              ------------------------------
451      base -> |  struct boot_param_header  |
452              ------------------------------
453              |      (alignment gap) (*)   |
454              ------------------------------
455              |      memory reserve map    |
456              ------------------------------
457              |      (alignment gap)       |
458              ------------------------------
459              |                            |
460              |    device-tree structure   |
461              |                            |
462              ------------------------------
463              |      (alignment gap)       |
464              ------------------------------
465              |                            |
466              |     device-tree strings    |
467              |                            |
468       -----> ------------------------------
469       |
470       |
471       --- (base + totalsize)
472
473   (*) The alignment gaps are not necessarily present; their presence
474       and size are dependent on the various alignment requirements of
475       the individual data blocks.
476
477
478 2) Device tree generalities
479 ---------------------------
480
481 This device-tree itself is separated in two different blocks, a
482 structure block and a strings block. Both need to be aligned to a 4
483 byte boundary.
484
485 First, let's quickly describe the device-tree concept before detailing
486 the storage format. This chapter does _not_ describe the detail of the
487 required types of nodes & properties for the kernel, this is done
488 later in chapter III.
489
490 The device-tree layout is strongly inherited from the definition of
491 the Open Firmware IEEE 1275 device-tree. It's basically a tree of
492 nodes, each node having two or more named properties. A property can
493 have a value or not.
494
495 It is a tree, so each node has one and only one parent except for the
496 root node who has no parent.
497
498 A node has 2 names. The actual node name is generally contained in a
499 property of type "name" in the node property list whose value is a
500 zero terminated string and is mandatory for version 1 to 3 of the
501 format definition (as it is in Open Firmware). Version 16 makes it
502 optional as it can generate it from the unit name defined below.
503
504 There is also a "unit name" that is used to differentiate nodes with
505 the same name at the same level, it is usually made of the node
506 names, the "@" sign, and a "unit address", which definition is
507 specific to the bus type the node sits on.
508
509 The unit name doesn't exist as a property per-se but is included in
510 the device-tree structure. It is typically used to represent "path" in
511 the device-tree. More details about the actual format of these will be
512 below.
513
514 The kernel generic code does not make any formal use of the
515 unit address (though some board support code may do) so the only real
516 requirement here for the unit address is to ensure uniqueness of
517 the node unit name at a given level of the tree. Nodes with no notion
518 of address and no possible sibling of the same name (like /memory or
519 /cpus) may omit the unit address in the context of this specification,
520 or use the "@0" default unit address. The unit name is used to define
521 a node "full path", which is the concatenation of all parent node
522 unit names separated with "/".
523
524 The root node doesn't have a defined name, and isn't required to have
525 a name property either if you are using version 3 or earlier of the
526 format. It also has no unit address (no @ symbol followed by a unit
527 address). The root node unit name is thus an empty string. The full
528 path to the root node is "/".
529
530 Every node which actually represents an actual device (that is, a node
531 which isn't only a virtual "container" for more nodes, like "/cpus"
532 is) is also required to have a "compatible" property indicating the
533 specific hardware and an optional list of devices it is fully
534 backwards compatible with.
535
536 Finally, every node that can be referenced from a property in another
537 node is required to have either a "phandle" or a "linux,phandle"
538 property. Real Open Firmware implementations provide a unique
539 "phandle" value for every node that the "prom_init()" trampoline code
540 turns into "linux,phandle" properties. However, this is made optional
541 if the flattened device tree is used directly. An example of a node
542 referencing another node via "phandle" is when laying out the
543 interrupt tree which will be described in a further version of this
544 document.
545
546 The "phandle" property is a 32-bit value that uniquely
547 identifies a node. You are free to use whatever values or system of
548 values, internal pointers, or whatever to generate these, the only
549 requirement is that every node for which you provide that property has
550 a unique value for it.
551
552 Here is an example of a simple device-tree. In this example, an "o"
553 designates a node followed by the node unit name. Properties are
554 presented with their name followed by their content. "content"
555 represents an ASCII string (zero terminated) value, while <content>
556 represents a 32-bit value, specified in decimal or hexadecimal (the
557 latter prefixed 0x). The various nodes in this example will be
558 discussed in a later chapter. At this point, it is only meant to give
559 you a idea of what a device-tree looks like. I have purposefully kept
560 the "name" and "linux,phandle" properties which aren't necessary in
561 order to give you a better idea of what the tree looks like in
562 practice.
563
564   / o device-tree
565       |- name = "device-tree"
566       |- model = "MyBoardName"
567       |- compatible = "MyBoardFamilyName"
568       |- #address-cells = <2>
569       |- #size-cells = <2>
570       |- linux,phandle = <0>
571       |
572       o cpus
573       | | - name = "cpus"
574       | | - linux,phandle = <1>
575       | | - #address-cells = <1>
576       | | - #size-cells = <0>
577       | |
578       | o PowerPC,970@0
579       |   |- name = "PowerPC,970"
580       |   |- device_type = "cpu"
581       |   |- reg = <0>
582       |   |- clock-frequency = <0x5f5e1000>
583       |   |- 64-bit
584       |   |- linux,phandle = <2>
585       |
586       o memory@0
587       | |- name = "memory"
588       | |- device_type = "memory"
589       | |- reg = <0x00000000 0x00000000 0x00000000 0x20000000>
590       | |- linux,phandle = <3>
591       |
592       o chosen
593         |- name = "chosen"
594         |- bootargs = "root=/dev/sda2"
595         |- linux,phandle = <4>
596
597 This tree is almost a minimal tree. It pretty much contains the
598 minimal set of required nodes and properties to boot a linux kernel;
599 that is, some basic model information at the root, the CPUs, and the
600 physical memory layout.  It also includes misc information passed
601 through /chosen, like in this example, the platform type (mandatory)
602 and the kernel command line arguments (optional).
603
604 The /cpus/PowerPC,970@0/64-bit property is an example of a
605 property without a value. All other properties have a value. The
606 significance of the #address-cells and #size-cells properties will be
607 explained in chapter IV which defines precisely the required nodes and
608 properties and their content.
609
610
611 3) Device tree "structure" block
612
613 The structure of the device tree is a linearized tree structure. The
614 "OF_DT_BEGIN_NODE" token starts a new node, and the "OF_DT_END_NODE"
615 ends that node definition. Child nodes are simply defined before
616 "OF_DT_END_NODE" (that is nodes within the node). A 'token' is a 32
617 bit value. The tree has to be "finished" with a OF_DT_END token
618
619 Here's the basic structure of a single node:
620
621      * token OF_DT_BEGIN_NODE (that is 0x00000001)
622      * for version 1 to 3, this is the node full path as a zero
623        terminated string, starting with "/". For version 16 and later,
624        this is the node unit name only (or an empty string for the
625        root node)
626      * [align gap to next 4 bytes boundary]
627      * for each property:
628         * token OF_DT_PROP (that is 0x00000003)
629         * 32-bit value of property value size in bytes (or 0 if no
630           value)
631         * 32-bit value of offset in string block of property name
632         * property value data if any
633         * [align gap to next 4 bytes boundary]
634      * [child nodes if any]
635      * token OF_DT_END_NODE (that is 0x00000002)
636
637 So the node content can be summarized as a start token, a full path,
638 a list of properties, a list of child nodes, and an end token. Every
639 child node is a full node structure itself as defined above.
640
641 NOTE: The above definition requires that all property definitions for
642 a particular node MUST precede any subnode definitions for that node.
643 Although the structure would not be ambiguous if properties and
644 subnodes were intermingled, the kernel parser requires that the
645 properties come first (up until at least 2.6.22).  Any tools
646 manipulating a flattened tree must take care to preserve this
647 constraint.
648
649 4) Device tree "strings" block
650
651 In order to save space, property names, which are generally redundant,
652 are stored separately in the "strings" block. This block is simply the
653 whole bunch of zero terminated strings for all property names
654 concatenated together. The device-tree property definitions in the
655 structure block will contain offset values from the beginning of the
656 strings block.
657
658
659 III - Required content of the device tree
660 =========================================
661
662 WARNING: All "linux,*" properties defined in this document apply only
663 to a flattened device-tree. If your platform uses a real
664 implementation of Open Firmware or an implementation compatible with
665 the Open Firmware client interface, those properties will be created
666 by the trampoline code in the kernel's prom_init() file. For example,
667 that's where you'll have to add code to detect your board model and
668 set the platform number. However, when using the flattened device-tree
669 entry point, there is no prom_init() pass, and thus you have to
670 provide those properties yourself.
671
672
673 1) Note about cells and address representation
674 ----------------------------------------------
675
676 The general rule is documented in the various Open Firmware
677 documentations. If you choose to describe a bus with the device-tree
678 and there exist an OF bus binding, then you should follow the
679 specification. However, the kernel does not require every single
680 device or bus to be described by the device tree.
681
682 In general, the format of an address for a device is defined by the
683 parent bus type, based on the #address-cells and #size-cells
684 properties.  Note that the parent's parent definitions of #address-cells
685 and #size-cells are not inherited so every node with children must specify
686 them.  The kernel requires the root node to have those properties defining
687 addresses format for devices directly mapped on the processor bus.
688
689 Those 2 properties define 'cells' for representing an address and a
690 size. A "cell" is a 32-bit number. For example, if both contain 2
691 like the example tree given above, then an address and a size are both
692 composed of 2 cells, and each is a 64-bit number (cells are
693 concatenated and expected to be in big endian format). Another example
694 is the way Apple firmware defines them, with 2 cells for an address
695 and one cell for a size.  Most 32-bit implementations should define
696 #address-cells and #size-cells to 1, which represents a 32-bit value.
697 Some 32-bit processors allow for physical addresses greater than 32
698 bits; these processors should define #address-cells as 2.
699
700 "reg" properties are always a tuple of the type "address size" where
701 the number of cells of address and size is specified by the bus
702 #address-cells and #size-cells. When a bus supports various address
703 spaces and other flags relative to a given address allocation (like
704 prefetchable, etc...) those flags are usually added to the top level
705 bits of the physical address. For example, a PCI physical address is
706 made of 3 cells, the bottom two containing the actual address itself
707 while the top cell contains address space indication, flags, and pci
708 bus & device numbers.
709
710 For buses that support dynamic allocation, it's the accepted practice
711 to then not provide the address in "reg" (keep it 0) though while
712 providing a flag indicating the address is dynamically allocated, and
713 then, to provide a separate "assigned-addresses" property that
714 contains the fully allocated addresses. See the PCI OF bindings for
715 details.
716
717 In general, a simple bus with no address space bits and no dynamic
718 allocation is preferred if it reflects your hardware, as the existing
719 kernel address parsing functions will work out of the box. If you
720 define a bus type with a more complex address format, including things
721 like address space bits, you'll have to add a bus translator to the
722 prom_parse.c file of the recent kernels for your bus type.
723
724 The "reg" property only defines addresses and sizes (if #size-cells is
725 non-0) within a given bus. In order to translate addresses upward
726 (that is into parent bus addresses, and possibly into CPU physical
727 addresses), all buses must contain a "ranges" property. If the
728 "ranges" property is missing at a given level, it's assumed that
729 translation isn't possible, i.e., the registers are not visible on the
730 parent bus.  The format of the "ranges" property for a bus is a list
731 of:
732
733         bus address, parent bus address, size
734
735 "bus address" is in the format of the bus this bus node is defining,
736 that is, for a PCI bridge, it would be a PCI address. Thus, (bus
737 address, size) defines a range of addresses for child devices. "parent
738 bus address" is in the format of the parent bus of this bus. For
739 example, for a PCI host controller, that would be a CPU address. For a
740 PCI<->ISA bridge, that would be a PCI address. It defines the base
741 address in the parent bus where the beginning of that range is mapped.
742
743 For new 64-bit board support, I recommend either the 2/2 format or
744 Apple's 2/1 format which is slightly more compact since sizes usually
745 fit in a single 32-bit word.   New 32-bit board support should use a
746 1/1 format, unless the processor supports physical addresses greater
747 than 32-bits, in which case a 2/1 format is recommended.
748
749 Alternatively, the "ranges" property may be empty, indicating that the
750 registers are visible on the parent bus using an identity mapping
751 translation.  In other words, the parent bus address space is the same
752 as the child bus address space.
753
754 2) Note about "compatible" properties
755 -------------------------------------
756
757 These properties are optional, but recommended in devices and the root
758 node. The format of a "compatible" property is a list of concatenated
759 zero terminated strings. They allow a device to express its
760 compatibility with a family of similar devices, in some cases,
761 allowing a single driver to match against several devices regardless
762 of their actual names.
763
764 3) Note about "name" properties
765 -------------------------------
766
767 While earlier users of Open Firmware like OldWorld macintoshes tended
768 to use the actual device name for the "name" property, it's nowadays
769 considered a good practice to use a name that is closer to the device
770 class (often equal to device_type). For example, nowadays, Ethernet
771 controllers are named "ethernet", an additional "model" property
772 defining precisely the chip type/model, and "compatible" property
773 defining the family in case a single driver can driver more than one
774 of these chips. However, the kernel doesn't generally put any
775 restriction on the "name" property; it is simply considered good
776 practice to follow the standard and its evolutions as closely as
777 possible.
778
779 Note also that the new format version 16 makes the "name" property
780 optional. If it's absent for a node, then the node's unit name is then
781 used to reconstruct the name. That is, the part of the unit name
782 before the "@" sign is used (or the entire unit name if no "@" sign
783 is present).
784
785 4) Note about node and property names and character set
786 -------------------------------------------------------
787
788 While Open Firmware provides more flexible usage of 8859-1, this
789 specification enforces more strict rules. Nodes and properties should
790 be comprised only of ASCII characters 'a' to 'z', '0' to
791 '9', ',', '.', '_', '+', '#', '?', and '-'. Node names additionally
792 allow uppercase characters 'A' to 'Z' (property names should be
793 lowercase. The fact that vendors like Apple don't respect this rule is
794 irrelevant here). Additionally, node and property names should always
795 begin with a character in the range 'a' to 'z' (or 'A' to 'Z' for node
796 names).
797
798 The maximum number of characters for both nodes and property names
799 is 31. In the case of node names, this is only the leftmost part of
800 a unit name (the pure "name" property), it doesn't include the unit
801 address which can extend beyond that limit.
802
803
804 5) Required nodes and properties
805 --------------------------------
806   These are all that are currently required. However, it is strongly
807   recommended that you expose PCI host bridges as documented in the
808   PCI binding to Open Firmware, and your interrupt tree as documented
809   in OF interrupt tree specification.
810
811   a) The root node
812
813   The root node requires some properties to be present:
814
815     - model : this is your board name/model
816     - #address-cells : address representation for "root" devices
817     - #size-cells: the size representation for "root" devices
818     - compatible : the board "family" generally finds its way here,
819       for example, if you have 2 board models with a similar layout,
820       that typically get driven by the same platform code in the
821       kernel, you would specify the exact board model in the
822       compatible property followed by an entry that represents the SoC
823       model.
824
825   The root node is also generally where you add additional properties
826   specific to your board like the serial number if any, that sort of
827   thing. It is recommended that if you add any "custom" property whose
828   name may clash with standard defined ones, you prefix them with your
829   vendor name and a comma.
830
831   b) The /cpus node
832
833   This node is the parent of all individual CPU nodes. It doesn't
834   have any specific requirements, though it's generally good practice
835   to have at least:
836
837                #address-cells = <00000001>
838                #size-cells    = <00000000>
839
840   This defines that the "address" for a CPU is a single cell, and has
841   no meaningful size. This is not necessary but the kernel will assume
842   that format when reading the "reg" properties of a CPU node, see
843   below
844
845   c) The /cpus/* nodes
846
847   So under /cpus, you are supposed to create a node for every CPU on
848   the machine. There is no specific restriction on the name of the
849   CPU, though it's common to call it <architecture>,<core>. For
850   example, Apple uses PowerPC,G5 while IBM uses PowerPC,970FX.
851   However, the Generic Names convention suggests that it would be
852   better to simply use 'cpu' for each cpu node and use the compatible
853   property to identify the specific cpu core.
854
855   Required properties:
856
857     - device_type : has to be "cpu"
858     - reg : This is the physical CPU number, it's a single 32-bit cell
859       and is also used as-is as the unit number for constructing the
860       unit name in the full path. For example, with 2 CPUs, you would
861       have the full path:
862         /cpus/PowerPC,970FX@0
863         /cpus/PowerPC,970FX@1
864       (unit addresses do not require leading zeroes)
865     - d-cache-block-size : one cell, L1 data cache block size in bytes (*)
866     - i-cache-block-size : one cell, L1 instruction cache block size in
867       bytes
868     - d-cache-size : one cell, size of L1 data cache in bytes
869     - i-cache-size : one cell, size of L1 instruction cache in bytes
870
871 (*) The cache "block" size is the size on which the cache management
872 instructions operate. Historically, this document used the cache
873 "line" size here which is incorrect. The kernel will prefer the cache
874 block size and will fallback to cache line size for backward
875 compatibility.
876
877   Recommended properties:
878
879     - timebase-frequency : a cell indicating the frequency of the
880       timebase in Hz. This is not directly used by the generic code,
881       but you are welcome to copy/paste the pSeries code for setting
882       the kernel timebase/decrementer calibration based on this
883       value.
884     - clock-frequency : a cell indicating the CPU core clock frequency
885       in Hz. A new property will be defined for 64-bit values, but if
886       your frequency is < 4Ghz, one cell is enough. Here as well as
887       for the above, the common code doesn't use that property, but
888       you are welcome to re-use the pSeries or Maple one. A future
889       kernel version might provide a common function for this.
890     - d-cache-line-size : one cell, L1 data cache line size in bytes
891       if different from the block size
892     - i-cache-line-size : one cell, L1 instruction cache line size in
893       bytes if different from the block size
894
895   You are welcome to add any property you find relevant to your board,
896   like some information about the mechanism used to soft-reset the
897   CPUs. For example, Apple puts the GPIO number for CPU soft reset
898   lines in there as a "soft-reset" property since they start secondary
899   CPUs by soft-resetting them.
900
901
902   d) the /memory node(s)
903
904   To define the physical memory layout of your board, you should
905   create one or more memory node(s). You can either create a single
906   node with all memory ranges in its reg property, or you can create
907   several nodes, as you wish. The unit address (@ part) used for the
908   full path is the address of the first range of memory defined by a
909   given node. If you use a single memory node, this will typically be
910   @0.
911
912   Required properties:
913
914     - device_type : has to be "memory"
915     - reg : This property contains all the physical memory ranges of
916       your board. It's a list of addresses/sizes concatenated
917       together, with the number of cells of each defined by the
918       #address-cells and #size-cells of the root node. For example,
919       with both of these properties being 2 like in the example given
920       earlier, a 970 based machine with 6Gb of RAM could typically
921       have a "reg" property here that looks like:
922
923       00000000 00000000 00000000 80000000
924       00000001 00000000 00000001 00000000
925
926       That is a range starting at 0 of 0x80000000 bytes and a range
927       starting at 0x100000000 and of 0x100000000 bytes. You can see
928       that there is no memory covering the IO hole between 2Gb and
929       4Gb. Some vendors prefer splitting those ranges into smaller
930       segments, but the kernel doesn't care.
931
932   e) The /chosen node
933
934   This node is a bit "special". Normally, that's where Open Firmware
935   puts some variable environment information, like the arguments, or
936   the default input/output devices.
937
938   This specification makes a few of these mandatory, but also defines
939   some linux-specific properties that would be normally constructed by
940   the prom_init() trampoline when booting with an OF client interface,
941   but that you have to provide yourself when using the flattened format.
942
943   Recommended properties:
944
945     - bootargs : This zero-terminated string is passed as the kernel
946       command line
947     - linux,stdout-path : This is the full path to your standard
948       console device if any. Typically, if you have serial devices on
949       your board, you may want to put the full path to the one set as
950       the default console in the firmware here, for the kernel to pick
951       it up as its own default console.
952
953   Note that u-boot creates and fills in the chosen node for platforms
954   that use it.
955
956   (Note: a practice that is now obsolete was to include a property
957   under /chosen called interrupt-controller which had a phandle value
958   that pointed to the main interrupt controller)
959
960   f) the /soc<SOCname> node
961
962   This node is used to represent a system-on-a-chip (SoC) and must be
963   present if the processor is a SoC. The top-level soc node contains
964   information that is global to all devices on the SoC. The node name
965   should contain a unit address for the SoC, which is the base address
966   of the memory-mapped register set for the SoC. The name of an SoC
967   node should start with "soc", and the remainder of the name should
968   represent the part number for the soc.  For example, the MPC8540's
969   soc node would be called "soc8540".
970
971   Required properties:
972
973     - ranges : Should be defined as specified in 1) to describe the
974       translation of SoC addresses for memory mapped SoC registers.
975     - bus-frequency: Contains the bus frequency for the SoC node.
976       Typically, the value of this field is filled in by the boot
977       loader.
978     - compatible : Exact model of the SoC
979
980
981   Recommended properties:
982
983     - reg : This property defines the address and size of the
984       memory-mapped registers that are used for the SOC node itself.
985       It does not include the child device registers - these will be
986       defined inside each child node.  The address specified in the
987       "reg" property should match the unit address of the SOC node.
988     - #address-cells : Address representation for "soc" devices.  The
989       format of this field may vary depending on whether or not the
990       device registers are memory mapped.  For memory mapped
991       registers, this field represents the number of cells needed to
992       represent the address of the registers.  For SOCs that do not
993       use MMIO, a special address format should be defined that
994       contains enough cells to represent the required information.
995       See 1) above for more details on defining #address-cells.
996     - #size-cells : Size representation for "soc" devices
997     - #interrupt-cells : Defines the width of cells used to represent
998        interrupts.  Typically this value is <2>, which includes a
999        32-bit number that represents the interrupt number, and a
1000        32-bit number that represents the interrupt sense and level.
1001        This field is only needed if the SOC contains an interrupt
1002        controller.
1003
1004   The SOC node may contain child nodes for each SOC device that the
1005   platform uses.  Nodes should not be created for devices which exist
1006   on the SOC but are not used by a particular platform. See chapter VI
1007   for more information on how to specify devices that are part of a SOC.
1008
1009   Example SOC node for the MPC8540:
1010
1011         soc8540@e0000000 {
1012                 #address-cells = <1>;
1013                 #size-cells = <1>;
1014                 #interrupt-cells = <2>;
1015                 device_type = "soc";
1016                 ranges = <0x00000000 0xe0000000 0x00100000>
1017                 reg = <0xe0000000 0x00003000>;
1018                 bus-frequency = <0>;
1019         }
1020
1021
1022
1023 IV - "dtc", the device tree compiler
1024 ====================================
1025
1026
1027 dtc source code can be found at
1028 <http://git.jdl.com/gitweb/?p=dtc.git>
1029
1030 WARNING: This version is still in early development stage; the
1031 resulting device-tree "blobs" have not yet been validated with the
1032 kernel. The current generated block lacks a useful reserve map (it will
1033 be fixed to generate an empty one, it's up to the bootloader to fill
1034 it up) among others. The error handling needs work, bugs are lurking,
1035 etc...
1036
1037 dtc basically takes a device-tree in a given format and outputs a
1038 device-tree in another format. The currently supported formats are:
1039
1040   Input formats:
1041   -------------
1042
1043      - "dtb": "blob" format, that is a flattened device-tree block
1044        with
1045         header all in a binary blob.
1046      - "dts": "source" format. This is a text file containing a
1047        "source" for a device-tree. The format is defined later in this
1048         chapter.
1049      - "fs" format. This is a representation equivalent to the
1050         output of /proc/device-tree, that is nodes are directories and
1051         properties are files
1052
1053  Output formats:
1054  ---------------
1055
1056      - "dtb": "blob" format
1057      - "dts": "source" format
1058      - "asm": assembly language file. This is a file that can be
1059        sourced by gas to generate a device-tree "blob". That file can
1060        then simply be added to your Makefile. Additionally, the
1061        assembly file exports some symbols that can be used.
1062
1063
1064 The syntax of the dtc tool is
1065
1066     dtc [-I <input-format>] [-O <output-format>]
1067         [-o output-filename] [-V output_version] input_filename
1068
1069
1070 The "output_version" defines what version of the "blob" format will be
1071 generated. Supported versions are 1,2,3 and 16. The default is
1072 currently version 3 but that may change in the future to version 16.
1073
1074 Additionally, dtc performs various sanity checks on the tree, like the
1075 uniqueness of linux, phandle properties, validity of strings, etc...
1076
1077 The format of the .dts "source" file is "C" like, supports C and C++
1078 style comments.
1079
1080 / {
1081 }
1082
1083 The above is the "device-tree" definition. It's the only statement
1084 supported currently at the toplevel.
1085
1086 / {
1087   property1 = "string_value";   /* define a property containing a 0
1088                                  * terminated string
1089                                  */
1090
1091   property2 = <0x1234abcd>;     /* define a property containing a
1092                                  * numerical 32-bit value (hexadecimal)
1093                                  */
1094
1095   property3 = <0x12345678 0x12345678 0xdeadbeef>;
1096                                 /* define a property containing 3
1097                                  * numerical 32-bit values (cells) in
1098                                  * hexadecimal
1099                                  */
1100   property4 = [0x0a 0x0b 0x0c 0x0d 0xde 0xea 0xad 0xbe 0xef];
1101                                 /* define a property whose content is
1102                                  * an arbitrary array of bytes
1103                                  */
1104
1105   childnode@address {   /* define a child node named "childnode"
1106                                  * whose unit name is "childnode at
1107                                  * address"
1108                                  */
1109
1110     childprop = "hello\n";      /* define a property "childprop" of
1111                                  * childnode (in this case, a string)
1112                                  */
1113   };
1114 };
1115
1116 Nodes can contain other nodes etc... thus defining the hierarchical
1117 structure of the tree.
1118
1119 Strings support common escape sequences from C: "\n", "\t", "\r",
1120 "\(octal value)", "\x(hex value)".
1121
1122 It is also suggested that you pipe your source file through cpp (gcc
1123 preprocessor) so you can use #include's, #define for constants, etc...
1124
1125 Finally, various options are planned but not yet implemented, like
1126 automatic generation of phandles, labels (exported to the asm file so
1127 you can point to a property content and change it easily from whatever
1128 you link the device-tree with), label or path instead of numeric value
1129 in some cells to "point" to a node (replaced by a phandle at compile
1130 time), export of reserve map address to the asm file, ability to
1131 specify reserve map content at compile time, etc...
1132
1133 We may provide a .h include file with common definitions of that
1134 proves useful for some properties (like building PCI properties or
1135 interrupt maps) though it may be better to add a notion of struct
1136 definitions to the compiler...
1137
1138
1139 V - Recommendations for a bootloader
1140 ====================================
1141
1142
1143 Here are some various ideas/recommendations that have been proposed
1144 while all this has been defined and implemented.
1145
1146   - The bootloader may want to be able to use the device-tree itself
1147     and may want to manipulate it (to add/edit some properties,
1148     like physical memory size or kernel arguments). At this point, 2
1149     choices can be made. Either the bootloader works directly on the
1150     flattened format, or the bootloader has its own internal tree
1151     representation with pointers (similar to the kernel one) and
1152     re-flattens the tree when booting the kernel. The former is a bit
1153     more difficult to edit/modify, the later requires probably a bit
1154     more code to handle the tree structure. Note that the structure
1155     format has been designed so it's relatively easy to "insert"
1156     properties or nodes or delete them by just memmoving things
1157     around. It contains no internal offsets or pointers for this
1158     purpose.
1159
1160   - An example of code for iterating nodes & retrieving properties
1161     directly from the flattened tree format can be found in the kernel
1162     file drivers/of/fdt.c.  Look at the of_scan_flat_dt() function,
1163     its usage in early_init_devtree(), and the corresponding various
1164     early_init_dt_scan_*() callbacks. That code can be re-used in a
1165     GPL bootloader, and as the author of that code, I would be happy
1166     to discuss possible free licensing to any vendor who wishes to
1167     integrate all or part of this code into a non-GPL bootloader.
1168     (reference needed; who is 'I' here? ---gcl Jan 31, 2011)
1169
1170
1171
1172 VI - System-on-a-chip devices and nodes
1173 =======================================
1174
1175 Many companies are now starting to develop system-on-a-chip
1176 processors, where the processor core (CPU) and many peripheral devices
1177 exist on a single piece of silicon.  For these SOCs, an SOC node
1178 should be used that defines child nodes for the devices that make
1179 up the SOC. While platforms are not required to use this model in
1180 order to boot the kernel, it is highly encouraged that all SOC
1181 implementations define as complete a flat-device-tree as possible to
1182 describe the devices on the SOC.  This will allow for the
1183 genericization of much of the kernel code.
1184
1185
1186 1) Defining child nodes of an SOC
1187 ---------------------------------
1188
1189 Each device that is part of an SOC may have its own node entry inside
1190 the SOC node.  For each device that is included in the SOC, the unit
1191 address property represents the address offset for this device's
1192 memory-mapped registers in the parent's address space.  The parent's
1193 address space is defined by the "ranges" property in the top-level soc
1194 node. The "reg" property for each node that exists directly under the
1195 SOC node should contain the address mapping from the child address space
1196 to the parent SOC address space and the size of the device's
1197 memory-mapped register file.
1198
1199 For many devices that may exist inside an SOC, there are predefined
1200 specifications for the format of the device tree node.  All SOC child
1201 nodes should follow these specifications, except where noted in this
1202 document.
1203
1204 See appendix A for an example partial SOC node definition for the
1205 MPC8540.
1206
1207
1208 2) Representing devices without a current OF specification
1209 ----------------------------------------------------------
1210
1211 Currently, there are many devices on SoCs that do not have a standard
1212 representation defined as part of the Open Firmware specifications,
1213 mainly because the boards that contain these SoCs are not currently
1214 booted using Open Firmware.  Binding documentation for new devices
1215 should be added to the Documentation/devicetree/bindings directory.
1216 That directory will expand as device tree support is added to more and
1217 more SoCs.
1218
1219
1220 VII - Specifying interrupt information for devices
1221 ===================================================
1222
1223 The device tree represents the buses and devices of a hardware
1224 system in a form similar to the physical bus topology of the
1225 hardware.
1226
1227 In addition, a logical 'interrupt tree' exists which represents the
1228 hierarchy and routing of interrupts in the hardware.
1229
1230 The interrupt tree model is fully described in the
1231 document "Open Firmware Recommended Practice: Interrupt
1232 Mapping Version 0.9".  The document is available at:
1233 <http://www.openfirmware.org/ofwg/practice/>
1234
1235 1) interrupts property
1236 ----------------------
1237
1238 Devices that generate interrupts to a single interrupt controller
1239 should use the conventional OF representation described in the
1240 OF interrupt mapping documentation.
1241
1242 Each device which generates interrupts must have an 'interrupt'
1243 property.  The interrupt property value is an arbitrary number of
1244 of 'interrupt specifier' values which describe the interrupt or
1245 interrupts for the device.
1246
1247 The encoding of an interrupt specifier is determined by the
1248 interrupt domain in which the device is located in the
1249 interrupt tree.  The root of an interrupt domain specifies in
1250 its #interrupt-cells property the number of 32-bit cells
1251 required to encode an interrupt specifier.  See the OF interrupt
1252 mapping documentation for a detailed description of domains.
1253
1254 For example, the binding for the OpenPIC interrupt controller
1255 specifies  an #interrupt-cells value of 2 to encode the interrupt
1256 number and level/sense information. All interrupt children in an
1257 OpenPIC interrupt domain use 2 cells per interrupt in their interrupts
1258 property.
1259
1260 The PCI bus binding specifies a #interrupt-cell value of 1 to encode
1261 which interrupt pin (INTA,INTB,INTC,INTD) is used.
1262
1263 2) interrupt-parent property
1264 ----------------------------
1265
1266 The interrupt-parent property is specified to define an explicit
1267 link between a device node and its interrupt parent in
1268 the interrupt tree.  The value of interrupt-parent is the
1269 phandle of the parent node.
1270
1271 If the interrupt-parent property is not defined for a node, its
1272 interrupt parent is assumed to be an ancestor in the node's
1273 _device tree_ hierarchy.
1274
1275 3) OpenPIC Interrupt Controllers
1276 --------------------------------
1277
1278 OpenPIC interrupt controllers require 2 cells to encode
1279 interrupt information.  The first cell defines the interrupt
1280 number.  The second cell defines the sense and level
1281 information.
1282
1283 Sense and level information should be encoded as follows:
1284
1285         0 = low to high edge sensitive type enabled
1286         1 = active low level sensitive type enabled
1287         2 = active high level sensitive type enabled
1288         3 = high to low edge sensitive type enabled
1289
1290 4) ISA Interrupt Controllers
1291 ----------------------------
1292
1293 ISA PIC interrupt controllers require 2 cells to encode
1294 interrupt information.  The first cell defines the interrupt
1295 number.  The second cell defines the sense and level
1296 information.
1297
1298 ISA PIC interrupt controllers should adhere to the ISA PIC
1299 encodings listed below:
1300
1301         0 =  active low level sensitive type enabled
1302         1 =  active high level sensitive type enabled
1303         2 =  high to low edge sensitive type enabled
1304         3 =  low to high edge sensitive type enabled
1305
1306 VIII - Specifying Device Power Management Information (sleep property)
1307 ===================================================================
1308
1309 Devices on SOCs often have mechanisms for placing devices into low-power
1310 states that are decoupled from the devices' own register blocks.  Sometimes,
1311 this information is more complicated than a cell-index property can
1312 reasonably describe.  Thus, each device controlled in such a manner
1313 may contain a "sleep" property which describes these connections.
1314
1315 The sleep property consists of one or more sleep resources, each of
1316 which consists of a phandle to a sleep controller, followed by a
1317 controller-specific sleep specifier of zero or more cells.
1318
1319 The semantics of what type of low power modes are possible are defined
1320 by the sleep controller.  Some examples of the types of low power modes
1321 that may be supported are:
1322
1323  - Dynamic: The device may be disabled or enabled at any time.
1324  - System Suspend: The device may request to be disabled or remain
1325    awake during system suspend, but will not be disabled until then.
1326  - Permanent: The device is disabled permanently (until the next hard
1327    reset).
1328
1329 Some devices may share a clock domain with each other, such that they should
1330 only be suspended when none of the devices are in use.  Where reasonable,
1331 such nodes should be placed on a virtual bus, where the bus has the sleep
1332 property.  If the clock domain is shared among devices that cannot be
1333 reasonably grouped in this manner, then create a virtual sleep controller
1334 (similar to an interrupt nexus, except that defining a standardized
1335 sleep-map should wait until its necessity is demonstrated).
1336
1337 IX - Specifying dma bus information
1338
1339 Some devices may have DMA memory range shifted relatively to the beginning of
1340 RAM, or even placed outside of kernel RAM. For example, the Keystone 2 SoC
1341 worked in LPAE mode with 4G memory has:
1342 - RAM range: [0x8 0000 0000, 0x8 FFFF FFFF]
1343 - DMA range: [  0x8000 0000,   0xFFFF FFFF]
1344 and DMA range is aliased into first 2G of RAM in HW.
1345
1346 In such cases, DMA addresses translation should be performed between CPU phys
1347 and DMA addresses. The "dma-ranges" property is intended to be used
1348 for describing the configuration of such system in DT.
1349
1350 In addition, each DMA master device on the DMA bus may or may not support
1351 coherent DMA operations. The "dma-coherent" property is intended to be used
1352 for identifying devices supported coherent DMA operations in DT.
1353
1354 * DMA Bus master
1355 Optional property:
1356 - dma-ranges: <prop-encoded-array> encoded as arbitrary number of triplets of
1357         (child-bus-address, parent-bus-address, length). Each triplet specified
1358         describes a contiguous DMA address range.
1359         The dma-ranges property is used to describe the direct memory access (DMA)
1360         structure of a memory-mapped bus whose device tree parent can be accessed
1361         from DMA operations originating from the bus. It provides a means of
1362         defining a mapping or translation between the physical address space of
1363         the bus and the physical address space of the parent of the bus.
1364         (for more information see ePAPR specification)
1365
1366 * DMA Bus child
1367 Optional property:
1368 - dma-ranges: <empty> value. if present - It means that DMA addresses
1369         translation has to be enabled for this device.
1370 - dma-coherent: Present if dma operations are coherent
1371
1372 Example:
1373 soc {
1374                 compatible = "ti,keystone","simple-bus";
1375                 ranges = <0x0 0x0 0x0 0xc0000000>;
1376                 dma-ranges = <0x80000000 0x8 0x00000000 0x80000000>;
1377
1378                 [...]
1379
1380                 usb: usb@2680000 {
1381                         compatible = "ti,keystone-dwc3";
1382
1383                         [...]
1384                         dma-coherent;
1385                 };
1386 };
1387
1388 Appendix A - Sample SOC node for MPC8540
1389 ========================================
1390
1391         soc@e0000000 {
1392                 #address-cells = <1>;
1393                 #size-cells = <1>;
1394                 compatible = "fsl,mpc8540-ccsr", "simple-bus";
1395                 device_type = "soc";
1396                 ranges = <0x00000000 0xe0000000 0x00100000>
1397                 bus-frequency = <0>;
1398                 interrupt-parent = <&pic>;
1399
1400                 ethernet@24000 {
1401                         #address-cells = <1>;
1402                         #size-cells = <1>;
1403                         device_type = "network";
1404                         model = "TSEC";
1405                         compatible = "gianfar", "simple-bus";
1406                         reg = <0x24000 0x1000>;
1407                         local-mac-address = [ 0x00 0xE0 0x0C 0x00 0x73 0x00 ];
1408                         interrupts = <0x29 2 0x30 2 0x34 2>;
1409                         phy-handle = <&phy0>;
1410                         sleep = <&pmc 0x00000080>;
1411                         ranges;
1412
1413                         mdio@24520 {
1414                                 reg = <0x24520 0x20>;
1415                                 compatible = "fsl,gianfar-mdio";
1416
1417                                 phy0: ethernet-phy@0 {
1418                                         interrupts = <5 1>;
1419                                         reg = <0>;
1420                                 };
1421
1422                                 phy1: ethernet-phy@1 {
1423                                         interrupts = <5 1>;
1424                                         reg = <1>;
1425                                 };
1426
1427                                 phy3: ethernet-phy@3 {
1428                                         interrupts = <7 1>;
1429                                         reg = <3>;
1430                                 };
1431                         };
1432                 };
1433
1434                 ethernet@25000 {
1435                         device_type = "network";
1436                         model = "TSEC";
1437                         compatible = "gianfar";
1438                         reg = <0x25000 0x1000>;
1439                         local-mac-address = [ 0x00 0xE0 0x0C 0x00 0x73 0x01 ];
1440                         interrupts = <0x13 2 0x14 2 0x18 2>;
1441                         phy-handle = <&phy1>;
1442                         sleep = <&pmc 0x00000040>;
1443                 };
1444
1445                 ethernet@26000 {
1446                         device_type = "network";
1447                         model = "FEC";
1448                         compatible = "gianfar";
1449                         reg = <0x26000 0x1000>;
1450                         local-mac-address = [ 0x00 0xE0 0x0C 0x00 0x73 0x02 ];
1451                         interrupts = <0x41 2>;
1452                         phy-handle = <&phy3>;
1453                         sleep = <&pmc 0x00000020>;
1454                 };
1455
1456                 serial@4500 {
1457                         #address-cells = <1>;
1458                         #size-cells = <1>;
1459                         compatible = "fsl,mpc8540-duart", "simple-bus";
1460                         sleep = <&pmc 0x00000002>;
1461                         ranges;
1462
1463                         serial@4500 {
1464                                 device_type = "serial";
1465                                 compatible = "ns16550";
1466                                 reg = <0x4500 0x100>;
1467                                 clock-frequency = <0>;
1468                                 interrupts = <0x42 2>;
1469                         };
1470
1471                         serial@4600 {
1472                                 device_type = "serial";
1473                                 compatible = "ns16550";
1474                                 reg = <0x4600 0x100>;
1475                                 clock-frequency = <0>;
1476                                 interrupts = <0x42 2>;
1477                         };
1478                 };
1479
1480                 pic: pic@40000 {
1481                         interrupt-controller;
1482                         #address-cells = <0>;
1483                         #interrupt-cells = <2>;
1484                         reg = <0x40000 0x40000>;
1485                         compatible = "chrp,open-pic";
1486                         device_type = "open-pic";
1487                 };
1488
1489                 i2c@3000 {
1490                         interrupts = <0x43 2>;
1491                         reg = <0x3000 0x100>;
1492                         compatible  = "fsl-i2c";
1493                         dfsrr;
1494                         sleep = <&pmc 0x00000004>;
1495                 };
1496
1497                 pmc: power@e0070 {
1498                         compatible = "fsl,mpc8540-pmc", "fsl,mpc8548-pmc";
1499                         reg = <0xe0070 0x20>;
1500                 };
1501         };