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