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