blob: 2233e3d5e5f3ddbec48cd2e310dc7e9c5a63d059 [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
Stuart Yoder5e1e9ba2007-06-06 04:29:14 +100045 b) Gianfar-compatible ethernet nodes
Roy Zanga4ecaba2007-06-19 15:19:31 +080046 c) PHY nodes
Stuart Yoder5e1e9ba2007-06-06 04:29:14 +100047 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)
David Gibson20991722007-09-07 13:23:53 +100053 j) CFI or JEDEC memory-mapped NOR flash
Roy Zang3b824f82007-06-19 15:19:18 +080054 k) Global Utilities Block
Stuart Yoder5e1e9ba2007-06-06 04:29:14 +100055
56 VII - Specifying interrupt information for devices
57 1) interrupts property
58 2) interrupt-parent property
59 3) OpenPIC Interrupt Controllers
60 4) ISA Interrupt Controllers
61
62 Appendix A - Sample SOC node for MPC8540
63
64
65Revision Information
66====================
67
David Gibsonc125a182006-02-01 03:05:22 -080068 May 18, 2005: Rev 0.1 - Initial draft, no chapter III yet.
69
70 May 19, 2005: Rev 0.2 - Add chapter III and bits & pieces here or
71 clarifies the fact that a lot of things are
72 optional, the kernel only requires a very
73 small device tree, though it is encouraged
74 to provide an as complete one as possible.
75
76 May 24, 2005: Rev 0.3 - Precise that DT block has to be in RAM
77 - Misc fixes
78 - Define version 3 and new format version 16
79 for the DT block (version 16 needs kernel
80 patches, will be fwd separately).
81 String block now has a size, and full path
82 is replaced by unit name for more
83 compactness.
84 linux,phandle is made optional, only nodes
85 that are referenced by other nodes need it.
86 "name" property is now automatically
87 deduced from the unit name
88
89 June 1, 2005: Rev 0.4 - Correct confusion between OF_DT_END and
90 OF_DT_END_NODE in structure definition.
91 - Change version 16 format to always align
92 property data to 4 bytes. Since tokens are
93 already aligned, that means no specific
Matt LaPlante5d3f0832006-11-30 05:21:10 +010094 required alignment between property size
David Gibsonc125a182006-02-01 03:05:22 -080095 and property data. The old style variable
96 alignment would make it impossible to do
97 "simple" insertion of properties using
Domen Puncer5dd60162007-03-02 21:44:45 +110098 memmove (thanks Milton for
David Gibsonc125a182006-02-01 03:05:22 -080099 noticing). Updated kernel patch as well
Matt LaPlante5d3f0832006-11-30 05:21:10 +0100100 - Correct a few more alignment constraints
David Gibsonc125a182006-02-01 03:05:22 -0800101 - Add a chapter about the device-tree
102 compiler and the textural representation of
103 the tree that can be "compiled" by dtc.
104
David Gibsonc125a182006-02-01 03:05:22 -0800105 November 21, 2005: Rev 0.5
106 - Additions/generalizations for 32-bit
107 - Changed to reflect the new arch/powerpc
108 structure
109 - Added chapter VI
110
111
112 ToDo:
113 - Add some definitions of interrupt tree (simple/complex)
Domen Puncer5dd60162007-03-02 21:44:45 +1100114 - Add some definitions for PCI host bridges
David Gibsonc125a182006-02-01 03:05:22 -0800115 - Add some common address format examples
116 - Add definitions for standard properties and "compatible"
117 names for cells that are not already defined by the existing
118 OF spec.
119 - Compare FSL SOC use of PCI to standard and make sure no new
120 node definition required.
121 - Add more information about node definitions for SOC devices
122 that currently have no standard, like the FSL CPM.
123
124
125I - Introduction
126================
127
128During the recent development of the Linux/ppc64 kernel, and more
129specifically, the addition of new platform types outside of the old
130IBM pSeries/iSeries pair, it was decided to enforce some strict rules
131regarding the kernel entry and bootloader <-> kernel interfaces, in
132order to avoid the degeneration that had become the ppc32 kernel entry
133point and the way a new platform should be added to the kernel. The
134legacy iSeries platform breaks those rules as it predates this scheme,
135but no new board support will be accepted in the main tree that
136doesn't follows them properly. In addition, since the advent of the
137arch/powerpc merged architecture for ppc32 and ppc64, new 32-bit
138platforms and 32-bit platforms which move into arch/powerpc will be
139required to use these rules as well.
140
141The main requirement that will be defined in more detail below is
142the presence of a device-tree whose format is defined after Open
143Firmware specification. However, in order to make life easier
144to embedded board vendors, the kernel doesn't require the device-tree
145to represent every device in the system and only requires some nodes
146and properties to be present. This will be described in detail in
147section III, but, for example, the kernel does not require you to
148create a node for every PCI device in the system. It is a requirement
149to have a node for PCI host bridges in order to provide interrupt
150routing informations and memory/IO ranges, among others. It is also
151recommended to define nodes for on chip devices and other busses that
152don't specifically fit in an existing OF specification. This creates a
153great flexibility in the way the kernel can then probe those and match
154drivers to device, without having to hard code all sorts of tables. It
155also makes it more flexible for board vendors to do minor hardware
156upgrades without significantly impacting the kernel code or cluttering
157it with special cases.
158
159
1601) Entry point for arch/powerpc
161-------------------------------
162
163 There is one and one single entry point to the kernel, at the start
164 of the kernel image. That entry point supports two calling
165 conventions:
166
167 a) Boot from Open Firmware. If your firmware is compatible
168 with Open Firmware (IEEE 1275) or provides an OF compatible
169 client interface API (support for "interpret" callback of
170 forth words isn't required), you can enter the kernel with:
171
172 r5 : OF callback pointer as defined by IEEE 1275
Domen Puncer5dd60162007-03-02 21:44:45 +1100173 bindings to powerpc. Only the 32-bit client interface
David Gibsonc125a182006-02-01 03:05:22 -0800174 is currently supported
175
176 r3, r4 : address & length of an initrd if any or 0
177
178 The MMU is either on or off; the kernel will run the
179 trampoline located in arch/powerpc/kernel/prom_init.c to
180 extract the device-tree and other information from open
181 firmware and build a flattened device-tree as described
182 in b). prom_init() will then re-enter the kernel using
183 the second method. This trampoline code runs in the
184 context of the firmware, which is supposed to handle all
185 exceptions during that time.
186
187 b) Direct entry with a flattened device-tree block. This entry
188 point is called by a) after the OF trampoline and can also be
189 called directly by a bootloader that does not support the Open
190 Firmware client interface. It is also used by "kexec" to
191 implement "hot" booting of a new kernel from a previous
192 running one. This method is what I will describe in more
193 details in this document, as method a) is simply standard Open
194 Firmware, and thus should be implemented according to the
195 various standard documents defining it and its binding to the
196 PowerPC platform. The entry point definition then becomes:
197
198 r3 : physical pointer to the device-tree block
199 (defined in chapter II) in RAM
200
201 r4 : physical pointer to the kernel itself. This is
202 used by the assembly code to properly disable the MMU
203 in case you are entering the kernel with MMU enabled
204 and a non-1:1 mapping.
205
Matt LaPlante2fe0ae72006-10-03 22:50:39 +0200206 r5 : NULL (as to differentiate with method a)
David Gibsonc125a182006-02-01 03:05:22 -0800207
208 Note about SMP entry: Either your firmware puts your other
209 CPUs in some sleep loop or spin loop in ROM where you can get
210 them out via a soft reset or some other means, in which case
211 you don't need to care, or you'll have to enter the kernel
212 with all CPUs. The way to do that with method b) will be
213 described in a later revision of this document.
214
215
2162) Board support
217----------------
218
21964-bit kernels:
220
221 Board supports (platforms) are not exclusive config options. An
222 arbitrary set of board supports can be built in a single kernel
223 image. The kernel will "know" what set of functions to use for a
224 given platform based on the content of the device-tree. Thus, you
225 should:
226
227 a) add your platform support as a _boolean_ option in
228 arch/powerpc/Kconfig, following the example of PPC_PSERIES,
229 PPC_PMAC and PPC_MAPLE. The later is probably a good
230 example of a board support to start from.
231
232 b) create your main platform file as
233 "arch/powerpc/platforms/myplatform/myboard_setup.c" and add it
234 to the Makefile under the condition of your CONFIG_
235 option. This file will define a structure of type "ppc_md"
236 containing the various callbacks that the generic code will
237 use to get to your platform specific code
238
239 c) Add a reference to your "ppc_md" structure in the
240 "machines" table in arch/powerpc/kernel/setup_64.c if you are
241 a 64-bit platform.
242
243 d) request and get assigned a platform number (see PLATFORM_*
244 constants in include/asm-powerpc/processor.h
245
24632-bit embedded kernels:
247
248 Currently, board support is essentially an exclusive config option.
249 The kernel is configured for a single platform. Part of the reason
250 for this is to keep kernels on embedded systems small and efficient;
251 part of this is due to the fact the code is already that way. In the
252 future, a kernel may support multiple platforms, but only if the
Domen Puncer5dd60162007-03-02 21:44:45 +1100253 platforms feature the same core architecture. A single kernel build
David Gibsonc125a182006-02-01 03:05:22 -0800254 cannot support both configurations with Book E and configurations
255 with classic Powerpc architectures.
256
257 32-bit embedded platforms that are moved into arch/powerpc using a
258 flattened device tree should adopt the merged tree practice of
259 setting ppc_md up dynamically, even though the kernel is currently
260 built with support for only a single platform at a time. This allows
261 unification of the setup code, and will make it easier to go to a
262 multiple-platform-support model in the future.
263
264NOTE: I believe the above will be true once Ben's done with the merge
265of the boot sequences.... someone speak up if this is wrong!
266
267 To add a 32-bit embedded platform support, follow the instructions
268 for 64-bit platforms above, with the exception that the Kconfig
269 option should be set up such that the kernel builds exclusively for
270 the platform selected. The processor type for the platform should
271 enable another config option to select the specific board
272 supported.
273
Domen Puncer5dd60162007-03-02 21:44:45 +1100274NOTE: If Ben doesn't merge the setup files, may need to change this to
David Gibsonc125a182006-02-01 03:05:22 -0800275point to setup_32.c
276
277
278 I will describe later the boot process and various callbacks that
279 your platform should implement.
280
281
282II - The DT block format
283========================
284
285
286This chapter defines the actual format of the flattened device-tree
287passed to the kernel. The actual content of it and kernel requirements
288are described later. You can find example of code manipulating that
289format in various places, including arch/powerpc/kernel/prom_init.c
290which will generate a flattened device-tree from the Open Firmware
291representation, or the fs2dt utility which is part of the kexec tools
292which will generate one from a filesystem representation. It is
293expected that a bootloader like uboot provides a bit more support,
294that will be discussed later as well.
295
296Note: The block has to be in main memory. It has to be accessible in
297both real mode and virtual mode with no mapping other than main
298memory. If you are writing a simple flash bootloader, it should copy
299the block to RAM before passing it to the kernel.
300
301
3021) Header
303---------
304
305 The kernel is entered with r3 pointing to an area of memory that is
Matt LaPlanted6bc8ac2006-10-03 22:54:15 +0200306 roughly described in include/asm-powerpc/prom.h by the structure
David Gibsonc125a182006-02-01 03:05:22 -0800307 boot_param_header:
308
309struct boot_param_header {
310 u32 magic; /* magic word OF_DT_HEADER */
311 u32 totalsize; /* total size of DT block */
312 u32 off_dt_struct; /* offset to structure */
313 u32 off_dt_strings; /* offset to strings */
314 u32 off_mem_rsvmap; /* offset to memory reserve map
Domen Puncer5dd60162007-03-02 21:44:45 +1100315 */
David Gibsonc125a182006-02-01 03:05:22 -0800316 u32 version; /* format version */
317 u32 last_comp_version; /* last compatible version */
318
319 /* version 2 fields below */
320 u32 boot_cpuid_phys; /* Which physical CPU id we're
321 booting on */
322 /* version 3 fields below */
323 u32 size_dt_strings; /* size of the strings block */
David Gibson0e0293c2007-03-14 11:50:40 +1100324
325 /* version 17 fields below */
326 u32 size_dt_struct; /* size of the DT structure block */
David Gibsonc125a182006-02-01 03:05:22 -0800327};
328
329 Along with the constants:
330
331/* Definitions used by the flattened device tree */
332#define OF_DT_HEADER 0xd00dfeed /* 4: version,
333 4: total size */
334#define OF_DT_BEGIN_NODE 0x1 /* Start node: full name
Domen Puncer5dd60162007-03-02 21:44:45 +1100335 */
David Gibsonc125a182006-02-01 03:05:22 -0800336#define OF_DT_END_NODE 0x2 /* End node */
337#define OF_DT_PROP 0x3 /* Property: name off,
338 size, content */
339#define OF_DT_END 0x9
340
341 All values in this header are in big endian format, the various
342 fields in this header are defined more precisely below. All
343 "offset" values are in bytes from the start of the header; that is
344 from the value of r3.
345
346 - magic
347
348 This is a magic value that "marks" the beginning of the
349 device-tree block header. It contains the value 0xd00dfeed and is
350 defined by the constant OF_DT_HEADER
351
352 - totalsize
353
354 This is the total size of the DT block including the header. The
355 "DT" block should enclose all data structures defined in this
356 chapter (who are pointed to by offsets in this header). That is,
357 the device-tree structure, strings, and the memory reserve map.
358
359 - off_dt_struct
360
361 This is an offset from the beginning of the header to the start
362 of the "structure" part the device tree. (see 2) device tree)
363
364 - off_dt_strings
365
366 This is an offset from the beginning of the header to the start
367 of the "strings" part of the device-tree
368
369 - off_mem_rsvmap
370
371 This is an offset from the beginning of the header to the start
Domen Puncer5dd60162007-03-02 21:44:45 +1100372 of the reserved memory map. This map is a list of pairs of 64-
David Gibsonc125a182006-02-01 03:05:22 -0800373 bit integers. Each pair is a physical address and a size. The
David Gibsonc125a182006-02-01 03:05:22 -0800374 list is terminated by an entry of size 0. This map provides the
375 kernel with a list of physical memory areas that are "reserved"
376 and thus not to be used for memory allocations, especially during
377 early initialization. The kernel needs to allocate memory during
378 boot for things like un-flattening the device-tree, allocating an
379 MMU hash table, etc... Those allocations must be done in such a
380 way to avoid overriding critical things like, on Open Firmware
381 capable machines, the RTAS instance, or on some pSeries, the TCE
382 tables used for the iommu. Typically, the reserve map should
383 contain _at least_ this DT block itself (header,total_size). If
384 you are passing an initrd to the kernel, you should reserve it as
385 well. You do not need to reserve the kernel image itself. The map
Domen Puncer5dd60162007-03-02 21:44:45 +1100386 should be 64-bit aligned.
David Gibsonc125a182006-02-01 03:05:22 -0800387
388 - version
389
390 This is the version of this structure. Version 1 stops
391 here. Version 2 adds an additional field boot_cpuid_phys.
392 Version 3 adds the size of the strings block, allowing the kernel
393 to reallocate it easily at boot and free up the unused flattened
394 structure after expansion. Version 16 introduces a new more
395 "compact" format for the tree itself that is however not backward
David Gibson0e0293c2007-03-14 11:50:40 +1100396 compatible. Version 17 adds an additional field, size_dt_struct,
397 allowing it to be reallocated or moved more easily (this is
398 particularly useful for bootloaders which need to make
399 adjustments to a device tree based on probed information). You
400 should always generate a structure of the highest version defined
401 at the time of your implementation. Currently that is version 17,
402 unless you explicitly aim at being backward compatible.
David Gibsonc125a182006-02-01 03:05:22 -0800403
404 - last_comp_version
405
406 Last compatible version. This indicates down to what version of
407 the DT block you are backward compatible. For example, version 2
408 is backward compatible with version 1 (that is, a kernel build
409 for version 1 will be able to boot with a version 2 format). You
410 should put a 1 in this field if you generate a device tree of
David Gibson0e0293c2007-03-14 11:50:40 +1100411 version 1 to 3, or 16 if you generate a tree of version 16 or 17
David Gibsonc125a182006-02-01 03:05:22 -0800412 using the new unit name format.
413
414 - boot_cpuid_phys
415
416 This field only exist on version 2 headers. It indicate which
417 physical CPU ID is calling the kernel entry point. This is used,
418 among others, by kexec. If you are on an SMP system, this value
419 should match the content of the "reg" property of the CPU node in
420 the device-tree corresponding to the CPU calling the kernel entry
421 point (see further chapters for more informations on the required
422 device-tree contents)
423
David Gibson0e0293c2007-03-14 11:50:40 +1100424 - size_dt_strings
425
426 This field only exists on version 3 and later headers. It
427 gives the size of the "strings" section of the device tree (which
428 starts at the offset given by off_dt_strings).
429
430 - size_dt_struct
431
432 This field only exists on version 17 and later headers. It gives
433 the size of the "structure" section of the device tree (which
434 starts at the offset given by off_dt_struct).
David Gibsonc125a182006-02-01 03:05:22 -0800435
436 So the typical layout of a DT block (though the various parts don't
437 need to be in that order) looks like this (addresses go from top to
438 bottom):
439
440
441 ------------------------------
442 r3 -> | struct boot_param_header |
443 ------------------------------
444 | (alignment gap) (*) |
445 ------------------------------
446 | memory reserve map |
447 ------------------------------
448 | (alignment gap) |
449 ------------------------------
450 | |
451 | device-tree structure |
452 | |
453 ------------------------------
454 | (alignment gap) |
455 ------------------------------
456 | |
457 | device-tree strings |
458 | |
459 -----> ------------------------------
460 |
461 |
462 --- (r3 + totalsize)
463
464 (*) The alignment gaps are not necessarily present; their presence
465 and size are dependent on the various alignment requirements of
466 the individual data blocks.
467
468
4692) Device tree generalities
470---------------------------
471
472This device-tree itself is separated in two different blocks, a
473structure block and a strings block. Both need to be aligned to a 4
474byte boundary.
475
476First, let's quickly describe the device-tree concept before detailing
477the storage format. This chapter does _not_ describe the detail of the
478required types of nodes & properties for the kernel, this is done
479later in chapter III.
480
481The device-tree layout is strongly inherited from the definition of
482the Open Firmware IEEE 1275 device-tree. It's basically a tree of
483nodes, each node having two or more named properties. A property can
484have a value or not.
485
486It is a tree, so each node has one and only one parent except for the
487root node who has no parent.
488
489A node has 2 names. The actual node name is generally contained in a
490property of type "name" in the node property list whose value is a
491zero terminated string and is mandatory for version 1 to 3 of the
David Gibson0e0293c2007-03-14 11:50:40 +1100492format definition (as it is in Open Firmware). Version 16 makes it
David Gibsonc125a182006-02-01 03:05:22 -0800493optional as it can generate it from the unit name defined below.
494
Matt LaPlante2fe0ae72006-10-03 22:50:39 +0200495There is also a "unit name" that is used to differentiate nodes with
David Gibsonc125a182006-02-01 03:05:22 -0800496the same name at the same level, it is usually made of the node
Matt LaPlante2fe0ae72006-10-03 22:50:39 +0200497names, the "@" sign, and a "unit address", which definition is
David Gibsonc125a182006-02-01 03:05:22 -0800498specific to the bus type the node sits on.
499
500The unit name doesn't exist as a property per-se but is included in
501the device-tree structure. It is typically used to represent "path" in
502the device-tree. More details about the actual format of these will be
503below.
504
505The kernel powerpc generic code does not make any formal use of the
506unit address (though some board support code may do) so the only real
507requirement here for the unit address is to ensure uniqueness of
508the node unit name at a given level of the tree. Nodes with no notion
509of address and no possible sibling of the same name (like /memory or
510/cpus) may omit the unit address in the context of this specification,
511or use the "@0" default unit address. The unit name is used to define
512a node "full path", which is the concatenation of all parent node
513unit names separated with "/".
514
515The root node doesn't have a defined name, and isn't required to have
516a name property either if you are using version 3 or earlier of the
517format. It also has no unit address (no @ symbol followed by a unit
518address). The root node unit name is thus an empty string. The full
519path to the root node is "/".
520
521Every node which actually represents an actual device (that is, a node
522which isn't only a virtual "container" for more nodes, like "/cpus"
523is) is also required to have a "device_type" property indicating the
524type of node .
525
526Finally, every node that can be referenced from a property in another
527node is required to have a "linux,phandle" property. Real open
528firmware implementations provide a unique "phandle" value for every
529node that the "prom_init()" trampoline code turns into
530"linux,phandle" properties. However, this is made optional if the
531flattened device tree is used directly. An example of a node
532referencing another node via "phandle" is when laying out the
533interrupt tree which will be described in a further version of this
534document.
535
Domen Puncer5dd60162007-03-02 21:44:45 +1100536This "linux, phandle" property is a 32-bit value that uniquely
David Gibsonc125a182006-02-01 03:05:22 -0800537identifies a node. You are free to use whatever values or system of
538values, internal pointers, or whatever to generate these, the only
539requirement is that every node for which you provide that property has
540a unique value for it.
541
542Here is an example of a simple device-tree. In this example, an "o"
543designates a node followed by the node unit name. Properties are
544presented with their name followed by their content. "content"
545represents an ASCII string (zero terminated) value, while <content>
Domen Puncer5dd60162007-03-02 21:44:45 +1100546represents a 32-bit hexadecimal value. The various nodes in this
David Gibsonc125a182006-02-01 03:05:22 -0800547example will be discussed in a later chapter. At this point, it is
548only meant to give you a idea of what a device-tree looks like. I have
549purposefully kept the "name" and "linux,phandle" properties which
550aren't necessary in order to give you a better idea of what the tree
551looks like in practice.
552
553 / o device-tree
554 |- name = "device-tree"
555 |- model = "MyBoardName"
556 |- compatible = "MyBoardFamilyName"
557 |- #address-cells = <2>
558 |- #size-cells = <2>
559 |- linux,phandle = <0>
560 |
561 o cpus
562 | | - name = "cpus"
563 | | - linux,phandle = <1>
564 | | - #address-cells = <1>
565 | | - #size-cells = <0>
566 | |
567 | o PowerPC,970@0
568 | |- name = "PowerPC,970"
569 | |- device_type = "cpu"
570 | |- reg = <0>
571 | |- clock-frequency = <5f5e1000>
Timur Tabi32aed2a2007-02-14 15:29:07 -0600572 | |- 64-bit
David Gibsonc125a182006-02-01 03:05:22 -0800573 | |- linux,phandle = <2>
574 |
575 o memory@0
576 | |- name = "memory"
577 | |- device_type = "memory"
578 | |- reg = <00000000 00000000 00000000 20000000>
579 | |- linux,phandle = <3>
580 |
581 o chosen
582 |- name = "chosen"
583 |- bootargs = "root=/dev/sda2"
David Gibsonc125a182006-02-01 03:05:22 -0800584 |- linux,phandle = <4>
585
586This tree is almost a minimal tree. It pretty much contains the
587minimal set of required nodes and properties to boot a linux kernel;
588that is, some basic model informations at the root, the CPUs, and the
589physical memory layout. It also includes misc information passed
590through /chosen, like in this example, the platform type (mandatory)
591and the kernel command line arguments (optional).
592
Timur Tabi32aed2a2007-02-14 15:29:07 -0600593The /cpus/PowerPC,970@0/64-bit property is an example of a
David Gibsonc125a182006-02-01 03:05:22 -0800594property without a value. All other properties have a value. The
595significance of the #address-cells and #size-cells properties will be
596explained in chapter IV which defines precisely the required nodes and
597properties and their content.
598
599
6003) Device tree "structure" block
601
602The structure of the device tree is a linearized tree structure. The
603"OF_DT_BEGIN_NODE" token starts a new node, and the "OF_DT_END_NODE"
604ends that node definition. Child nodes are simply defined before
605"OF_DT_END_NODE" (that is nodes within the node). A 'token' is a 32
606bit value. The tree has to be "finished" with a OF_DT_END token
607
608Here's the basic structure of a single node:
609
610 * token OF_DT_BEGIN_NODE (that is 0x00000001)
611 * for version 1 to 3, this is the node full path as a zero
612 terminated string, starting with "/". For version 16 and later,
613 this is the node unit name only (or an empty string for the
614 root node)
615 * [align gap to next 4 bytes boundary]
616 * for each property:
617 * token OF_DT_PROP (that is 0x00000003)
Domen Puncer5dd60162007-03-02 21:44:45 +1100618 * 32-bit value of property value size in bytes (or 0 if no
619 value)
620 * 32-bit value of offset in string block of property name
David Gibsonc125a182006-02-01 03:05:22 -0800621 * property value data if any
622 * [align gap to next 4 bytes boundary]
623 * [child nodes if any]
624 * token OF_DT_END_NODE (that is 0x00000002)
625
Domen Puncer5dd60162007-03-02 21:44:45 +1100626So the node content can be summarized as a start token, a full path,
Matt LaPlante53cb4722006-10-03 22:55:17 +0200627a list of properties, a list of child nodes, and an end token. Every
David Gibsonc125a182006-02-01 03:05:22 -0800628child node is a full node structure itself as defined above.
629
David Gibsoneff2ebd2007-06-28 15:56:26 +1000630NOTE: The above definition requires that all property definitions for
631a particular node MUST precede any subnode definitions for that node.
632Although the structure would not be ambiguous if properties and
633subnodes were intermingled, the kernel parser requires that the
634properties come first (up until at least 2.6.22). Any tools
635manipulating a flattened tree must take care to preserve this
636constraint.
637
Matt LaPlante53cb4722006-10-03 22:55:17 +02006384) Device tree "strings" block
David Gibsonc125a182006-02-01 03:05:22 -0800639
640In order to save space, property names, which are generally redundant,
641are stored separately in the "strings" block. This block is simply the
642whole bunch of zero terminated strings for all property names
643concatenated together. The device-tree property definitions in the
644structure block will contain offset values from the beginning of the
645strings block.
646
647
648III - Required content of the device tree
649=========================================
650
651WARNING: All "linux,*" properties defined in this document apply only
652to a flattened device-tree. If your platform uses a real
653implementation of Open Firmware or an implementation compatible with
654the Open Firmware client interface, those properties will be created
655by the trampoline code in the kernel's prom_init() file. For example,
656that's where you'll have to add code to detect your board model and
Matt LaPlantea2ffd272006-10-03 22:49:15 +0200657set the platform number. However, when using the flattened device-tree
David Gibsonc125a182006-02-01 03:05:22 -0800658entry point, there is no prom_init() pass, and thus you have to
659provide those properties yourself.
660
661
6621) Note about cells and address representation
663----------------------------------------------
664
665The general rule is documented in the various Open Firmware
Domen Puncer5dd60162007-03-02 21:44:45 +1100666documentations. If you choose to describe a bus with the device-tree
David Gibsonc125a182006-02-01 03:05:22 -0800667and there exist an OF bus binding, then you should follow the
668specification. However, the kernel does not require every single
669device or bus to be described by the device tree.
670
671In general, the format of an address for a device is defined by the
672parent bus type, based on the #address-cells and #size-cells
673property. In the absence of such a property, the parent's parent
674values are used, etc... The kernel requires the root node to have
675those properties defining addresses format for devices directly mapped
676on the processor bus.
677
678Those 2 properties define 'cells' for representing an address and a
Domen Puncer5dd60162007-03-02 21:44:45 +1100679size. A "cell" is a 32-bit number. For example, if both contain 2
David Gibsonc125a182006-02-01 03:05:22 -0800680like the example tree given above, then an address and a size are both
Domen Puncer5dd60162007-03-02 21:44:45 +1100681composed of 2 cells, and each is a 64-bit number (cells are
David Gibsonc125a182006-02-01 03:05:22 -0800682concatenated and expected to be in big endian format). Another example
683is the way Apple firmware defines them, with 2 cells for an address
684and one cell for a size. Most 32-bit implementations should define
685#address-cells and #size-cells to 1, which represents a 32-bit value.
686Some 32-bit processors allow for physical addresses greater than 32
687bits; these processors should define #address-cells as 2.
688
689"reg" properties are always a tuple of the type "address size" where
690the number of cells of address and size is specified by the bus
691#address-cells and #size-cells. When a bus supports various address
692spaces and other flags relative to a given address allocation (like
693prefetchable, etc...) those flags are usually added to the top level
694bits of the physical address. For example, a PCI physical address is
695made of 3 cells, the bottom two containing the actual address itself
696while the top cell contains address space indication, flags, and pci
697bus & device numbers.
698
699For busses that support dynamic allocation, it's the accepted practice
700to then not provide the address in "reg" (keep it 0) though while
701providing a flag indicating the address is dynamically allocated, and
702then, to provide a separate "assigned-addresses" property that
703contains the fully allocated addresses. See the PCI OF bindings for
704details.
705
706In general, a simple bus with no address space bits and no dynamic
707allocation is preferred if it reflects your hardware, as the existing
708kernel address parsing functions will work out of the box. If you
709define a bus type with a more complex address format, including things
710like address space bits, you'll have to add a bus translator to the
711prom_parse.c file of the recent kernels for your bus type.
712
713The "reg" property only defines addresses and sizes (if #size-cells
Matt LaPlante992caac2006-10-03 22:52:05 +0200714is non-0) within a given bus. In order to translate addresses upward
Domen Puncer5dd60162007-03-02 21:44:45 +1100715(that is into parent bus addresses, and possibly into CPU physical
David Gibsonc125a182006-02-01 03:05:22 -0800716addresses), all busses must contain a "ranges" property. If the
717"ranges" property is missing at a given level, it's assumed that
Matt LaPlante992caac2006-10-03 22:52:05 +0200718translation isn't possible. The format of the "ranges" property for a
David Gibsonc125a182006-02-01 03:05:22 -0800719bus is a list of:
720
721 bus address, parent bus address, size
722
723"bus address" is in the format of the bus this bus node is defining,
724that is, for a PCI bridge, it would be a PCI address. Thus, (bus
725address, size) defines a range of addresses for child devices. "parent
726bus address" is in the format of the parent bus of this bus. For
727example, for a PCI host controller, that would be a CPU address. For a
728PCI<->ISA bridge, that would be a PCI address. It defines the base
729address in the parent bus where the beginning of that range is mapped.
730
Domen Puncer5dd60162007-03-02 21:44:45 +1100731For a new 64-bit powerpc board, I recommend either the 2/2 format or
David Gibsonc125a182006-02-01 03:05:22 -0800732Apple's 2/1 format which is slightly more compact since sizes usually
Domen Puncer5dd60162007-03-02 21:44:45 +1100733fit in a single 32-bit word. New 32-bit powerpc boards should use a
David Gibsonc125a182006-02-01 03:05:22 -08007341/1 format, unless the processor supports physical addresses greater
735than 32-bits, in which case a 2/1 format is recommended.
736
737
7382) Note about "compatible" properties
739-------------------------------------
740
741These properties are optional, but recommended in devices and the root
742node. The format of a "compatible" property is a list of concatenated
743zero terminated strings. They allow a device to express its
744compatibility with a family of similar devices, in some cases,
745allowing a single driver to match against several devices regardless
746of their actual names.
747
7483) Note about "name" properties
749-------------------------------
750
751While earlier users of Open Firmware like OldWorld macintoshes tended
752to use the actual device name for the "name" property, it's nowadays
753considered a good practice to use a name that is closer to the device
754class (often equal to device_type). For example, nowadays, ethernet
755controllers are named "ethernet", an additional "model" property
756defining precisely the chip type/model, and "compatible" property
757defining the family in case a single driver can driver more than one
758of these chips. However, the kernel doesn't generally put any
759restriction on the "name" property; it is simply considered good
760practice to follow the standard and its evolutions as closely as
761possible.
762
763Note also that the new format version 16 makes the "name" property
764optional. If it's absent for a node, then the node's unit name is then
765used to reconstruct the name. That is, the part of the unit name
766before the "@" sign is used (or the entire unit name if no "@" sign
767is present).
768
7694) Note about node and property names and character set
770-------------------------------------------------------
771
Matt LaPlantea2ffd272006-10-03 22:49:15 +0200772While open firmware provides more flexible usage of 8859-1, this
David Gibsonc125a182006-02-01 03:05:22 -0800773specification enforces more strict rules. Nodes and properties should
774be comprised only of ASCII characters 'a' to 'z', '0' to
775'9', ',', '.', '_', '+', '#', '?', and '-'. Node names additionally
776allow uppercase characters 'A' to 'Z' (property names should be
777lowercase. The fact that vendors like Apple don't respect this rule is
778irrelevant here). Additionally, node and property names should always
779begin with a character in the range 'a' to 'z' (or 'A' to 'Z' for node
780names).
781
782The maximum number of characters for both nodes and property names
783is 31. In the case of node names, this is only the leftmost part of
784a unit name (the pure "name" property), it doesn't include the unit
785address which can extend beyond that limit.
786
787
7885) Required nodes and properties
789--------------------------------
790 These are all that are currently required. However, it is strongly
791 recommended that you expose PCI host bridges as documented in the
792 PCI binding to open firmware, and your interrupt tree as documented
793 in OF interrupt tree specification.
794
795 a) The root node
796
797 The root node requires some properties to be present:
798
799 - model : this is your board name/model
800 - #address-cells : address representation for "root" devices
801 - #size-cells: the size representation for "root" devices
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100802 - device_type : This property shouldn't be necessary. However, if
803 you decide to create a device_type for your root node, make sure it
804 is _not_ "chrp" unless your platform is a pSeries or PAPR compliant
805 one for 64-bit, or a CHRP-type machine for 32-bit as this will
806 matched by the kernel this way.
David Gibsonc125a182006-02-01 03:05:22 -0800807
808 Additionally, some recommended properties are:
809
810 - compatible : the board "family" generally finds its way here,
811 for example, if you have 2 board models with a similar layout,
812 that typically get driven by the same platform code in the
813 kernel, you would use a different "model" property but put a
814 value in "compatible". The kernel doesn't directly use that
Stuart Yoder143a42d2007-02-16 11:30:29 -0600815 value but it is generally useful.
David Gibsonc125a182006-02-01 03:05:22 -0800816
817 The root node is also generally where you add additional properties
818 specific to your board like the serial number if any, that sort of
Matt LaPlante6c28f2c2006-10-03 22:46:31 +0200819 thing. It is recommended that if you add any "custom" property whose
David Gibsonc125a182006-02-01 03:05:22 -0800820 name may clash with standard defined ones, you prefix them with your
821 vendor name and a comma.
822
823 b) The /cpus node
824
825 This node is the parent of all individual CPU nodes. It doesn't
826 have any specific requirements, though it's generally good practice
827 to have at least:
828
829 #address-cells = <00000001>
830 #size-cells = <00000000>
831
832 This defines that the "address" for a CPU is a single cell, and has
833 no meaningful size. This is not necessary but the kernel will assume
834 that format when reading the "reg" properties of a CPU node, see
835 below
836
837 c) The /cpus/* nodes
838
839 So under /cpus, you are supposed to create a node for every CPU on
840 the machine. There is no specific restriction on the name of the
841 CPU, though It's common practice to call it PowerPC,<name>. For
842 example, Apple uses PowerPC,G5 while IBM uses PowerPC,970FX.
843
844 Required properties:
845
846 - device_type : has to be "cpu"
Domen Puncer5dd60162007-03-02 21:44:45 +1100847 - reg : This is the physical CPU number, it's a single 32-bit cell
David Gibsonc125a182006-02-01 03:05:22 -0800848 and is also used as-is as the unit number for constructing the
849 unit name in the full path. For example, with 2 CPUs, you would
850 have the full path:
851 /cpus/PowerPC,970FX@0
852 /cpus/PowerPC,970FX@1
853 (unit addresses do not require leading zeroes)
Benjamin Herrenschmidt20474ab2007-10-28 08:49:28 +1100854 - d-cache-block-size : one cell, L1 data cache block size in bytes (*)
855 - i-cache-block-size : one cell, L1 instruction cache block size in
David Gibsonc125a182006-02-01 03:05:22 -0800856 bytes
857 - d-cache-size : one cell, size of L1 data cache in bytes
858 - i-cache-size : one cell, size of L1 instruction cache in bytes
David Gibsonc125a182006-02-01 03:05:22 -0800859
Benjamin Herrenschmidt20474ab2007-10-28 08:49:28 +1100860(*) The cache "block" size is the size on which the cache management
861instructions operate. Historically, this document used the cache
862"line" size here which is incorrect. The kernel will prefer the cache
863block size and will fallback to cache line size for backward
864compatibility.
865
David Gibsonc125a182006-02-01 03:05:22 -0800866 Recommended properties:
867
868 - timebase-frequency : a cell indicating the frequency of the
869 timebase in Hz. This is not directly used by the generic code,
870 but you are welcome to copy/paste the pSeries code for setting
871 the kernel timebase/decrementer calibration based on this
872 value.
873 - clock-frequency : a cell indicating the CPU core clock frequency
Domen Puncer5dd60162007-03-02 21:44:45 +1100874 in Hz. A new property will be defined for 64-bit values, but if
David Gibsonc125a182006-02-01 03:05:22 -0800875 your frequency is < 4Ghz, one cell is enough. Here as well as
876 for the above, the common code doesn't use that property, but
877 you are welcome to re-use the pSeries or Maple one. A future
878 kernel version might provide a common function for this.
Benjamin Herrenschmidt20474ab2007-10-28 08:49:28 +1100879 - d-cache-line-size : one cell, L1 data cache line size in bytes
880 if different from the block size
881 - i-cache-line-size : one cell, L1 instruction cache line size in
882 bytes if different from the block size
David Gibsonc125a182006-02-01 03:05:22 -0800883
884 You are welcome to add any property you find relevant to your board,
885 like some information about the mechanism used to soft-reset the
886 CPUs. For example, Apple puts the GPIO number for CPU soft reset
887 lines in there as a "soft-reset" property since they start secondary
888 CPUs by soft-resetting them.
889
890
891 d) the /memory node(s)
892
893 To define the physical memory layout of your board, you should
894 create one or more memory node(s). You can either create a single
895 node with all memory ranges in its reg property, or you can create
896 several nodes, as you wish. The unit address (@ part) used for the
897 full path is the address of the first range of memory defined by a
898 given node. If you use a single memory node, this will typically be
899 @0.
900
901 Required properties:
902
903 - device_type : has to be "memory"
904 - reg : This property contains all the physical memory ranges of
905 your board. It's a list of addresses/sizes concatenated
906 together, with the number of cells of each defined by the
907 #address-cells and #size-cells of the root node. For example,
Matt LaPlante6c28f2c2006-10-03 22:46:31 +0200908 with both of these properties being 2 like in the example given
David Gibsonc125a182006-02-01 03:05:22 -0800909 earlier, a 970 based machine with 6Gb of RAM could typically
910 have a "reg" property here that looks like:
911
912 00000000 00000000 00000000 80000000
913 00000001 00000000 00000001 00000000
914
915 That is a range starting at 0 of 0x80000000 bytes and a range
916 starting at 0x100000000 and of 0x100000000 bytes. You can see
917 that there is no memory covering the IO hole between 2Gb and
918 4Gb. Some vendors prefer splitting those ranges into smaller
919 segments, but the kernel doesn't care.
920
921 e) The /chosen node
922
923 This node is a bit "special". Normally, that's where open firmware
924 puts some variable environment information, like the arguments, or
Stuart Yoderd1bff9e2007-02-19 11:25:05 -0600925 the default input/output devices.
David Gibsonc125a182006-02-01 03:05:22 -0800926
927 This specification makes a few of these mandatory, but also defines
928 some linux-specific properties that would be normally constructed by
929 the prom_init() trampoline when booting with an OF client interface,
930 but that you have to provide yourself when using the flattened format.
931
David Gibsonc125a182006-02-01 03:05:22 -0800932 Recommended properties:
933
934 - bootargs : This zero-terminated string is passed as the kernel
935 command line
936 - linux,stdout-path : This is the full path to your standard
937 console device if any. Typically, if you have serial devices on
938 your board, you may want to put the full path to the one set as
939 the default console in the firmware here, for the kernel to pick
Matt LaPlante5d3f0832006-11-30 05:21:10 +0100940 it up as its own default console. If you look at the function
David Gibsonc125a182006-02-01 03:05:22 -0800941 set_preferred_console() in arch/ppc64/kernel/setup.c, you'll see
942 that the kernel tries to find out the default console and has
943 knowledge of various types like 8250 serial ports. You may want
944 to extend this function to add your own.
David Gibsonc125a182006-02-01 03:05:22 -0800945
946 Note that u-boot creates and fills in the chosen node for platforms
947 that use it.
948
Stuart Yoderd1bff9e2007-02-19 11:25:05 -0600949 (Note: a practice that is now obsolete was to include a property
950 under /chosen called interrupt-controller which had a phandle value
951 that pointed to the main interrupt controller)
952
David Gibsonc125a182006-02-01 03:05:22 -0800953 f) the /soc<SOCname> node
954
955 This node is used to represent a system-on-a-chip (SOC) and must be
956 present if the processor is a SOC. The top-level soc node contains
957 information that is global to all devices on the SOC. The node name
958 should contain a unit address for the SOC, which is the base address
959 of the memory-mapped register set for the SOC. The name of an soc
960 node should start with "soc", and the remainder of the name should
961 represent the part number for the soc. For example, the MPC8540's
962 soc node would be called "soc8540".
963
964 Required properties:
965
966 - device_type : Should be "soc"
967 - ranges : Should be defined as specified in 1) to describe the
968 translation of SOC addresses for memory mapped SOC registers.
Becky Bruce7d4b95a2006-02-06 14:26:31 -0600969 - bus-frequency: Contains the bus frequency for the SOC node.
970 Typically, the value of this field is filled in by the boot
971 loader.
972
David Gibsonc125a182006-02-01 03:05:22 -0800973
974 Recommended properties:
975
976 - reg : This property defines the address and size of the
977 memory-mapped registers that are used for the SOC node itself.
978 It does not include the child device registers - these will be
979 defined inside each child node. The address specified in the
980 "reg" property should match the unit address of the SOC node.
981 - #address-cells : Address representation for "soc" devices. The
982 format of this field may vary depending on whether or not the
983 device registers are memory mapped. For memory mapped
984 registers, this field represents the number of cells needed to
985 represent the address of the registers. For SOCs that do not
986 use MMIO, a special address format should be defined that
987 contains enough cells to represent the required information.
988 See 1) above for more details on defining #address-cells.
989 - #size-cells : Size representation for "soc" devices
990 - #interrupt-cells : Defines the width of cells used to represent
991 interrupts. Typically this value is <2>, which includes a
992 32-bit number that represents the interrupt number, and a
993 32-bit number that represents the interrupt sense and level.
994 This field is only needed if the SOC contains an interrupt
995 controller.
996
997 The SOC node may contain child nodes for each SOC device that the
998 platform uses. Nodes should not be created for devices which exist
999 on the SOC but are not used by a particular platform. See chapter VI
Domen Puncer5dd60162007-03-02 21:44:45 +11001000 for more information on how to specify devices that are part of a SOC.
David Gibsonc125a182006-02-01 03:05:22 -08001001
1002 Example SOC node for the MPC8540:
1003
1004 soc8540@e0000000 {
1005 #address-cells = <1>;
1006 #size-cells = <1>;
1007 #interrupt-cells = <2>;
1008 device_type = "soc";
1009 ranges = <00000000 e0000000 00100000>
1010 reg = <e0000000 00003000>;
Becky Bruce7d4b95a2006-02-06 14:26:31 -06001011 bus-frequency = <0>;
David Gibsonc125a182006-02-01 03:05:22 -08001012 }
1013
1014
1015
1016IV - "dtc", the device tree compiler
1017====================================
1018
1019
1020dtc source code can be found at
1021<http://ozlabs.org/~dgibson/dtc/dtc.tar.gz>
1022
1023WARNING: This version is still in early development stage; the
1024resulting device-tree "blobs" have not yet been validated with the
1025kernel. The current generated bloc lacks a useful reserve map (it will
1026be fixed to generate an empty one, it's up to the bootloader to fill
1027it up) among others. The error handling needs work, bugs are lurking,
1028etc...
1029
1030dtc basically takes a device-tree in a given format and outputs a
1031device-tree in another format. The currently supported formats are:
1032
1033 Input formats:
1034 -------------
1035
1036 - "dtb": "blob" format, that is a flattened device-tree block
1037 with
1038 header all in a binary blob.
1039 - "dts": "source" format. This is a text file containing a
1040 "source" for a device-tree. The format is defined later in this
1041 chapter.
1042 - "fs" format. This is a representation equivalent to the
1043 output of /proc/device-tree, that is nodes are directories and
1044 properties are files
1045
1046 Output formats:
1047 ---------------
1048
1049 - "dtb": "blob" format
1050 - "dts": "source" format
1051 - "asm": assembly language file. This is a file that can be
1052 sourced by gas to generate a device-tree "blob". That file can
1053 then simply be added to your Makefile. Additionally, the
Matt LaPlante6c28f2c2006-10-03 22:46:31 +02001054 assembly file exports some symbols that can be used.
David Gibsonc125a182006-02-01 03:05:22 -08001055
1056
1057The syntax of the dtc tool is
1058
1059 dtc [-I <input-format>] [-O <output-format>]
1060 [-o output-filename] [-V output_version] input_filename
1061
1062
Domen Puncer5dd60162007-03-02 21:44:45 +11001063The "output_version" defines what version of the "blob" format will be
David Gibsonc125a182006-02-01 03:05:22 -08001064generated. Supported versions are 1,2,3 and 16. The default is
1065currently version 3 but that may change in the future to version 16.
1066
1067Additionally, dtc performs various sanity checks on the tree, like the
Matt LaPlante6c28f2c2006-10-03 22:46:31 +02001068uniqueness of linux, phandle properties, validity of strings, etc...
David Gibsonc125a182006-02-01 03:05:22 -08001069
1070The format of the .dts "source" file is "C" like, supports C and C++
Matt LaPlante6c28f2c2006-10-03 22:46:31 +02001071style comments.
David Gibsonc125a182006-02-01 03:05:22 -08001072
1073/ {
1074}
1075
1076The above is the "device-tree" definition. It's the only statement
1077supported currently at the toplevel.
1078
1079/ {
1080 property1 = "string_value"; /* define a property containing a 0
1081 * terminated string
1082 */
1083
1084 property2 = <1234abcd>; /* define a property containing a
Domen Puncer5dd60162007-03-02 21:44:45 +11001085 * numerical 32-bit value (hexadecimal)
David Gibsonc125a182006-02-01 03:05:22 -08001086 */
1087
1088 property3 = <12345678 12345678 deadbeef>;
1089 /* define a property containing 3
Domen Puncer5dd60162007-03-02 21:44:45 +11001090 * numerical 32-bit values (cells) in
David Gibsonc125a182006-02-01 03:05:22 -08001091 * hexadecimal
1092 */
1093 property4 = [0a 0b 0c 0d de ea ad be ef];
1094 /* define a property whose content is
1095 * an arbitrary array of bytes
1096 */
1097
1098 childnode@addresss { /* define a child node named "childnode"
1099 * whose unit name is "childnode at
1100 * address"
1101 */
1102
1103 childprop = "hello\n"; /* define a property "childprop" of
1104 * childnode (in this case, a string)
1105 */
1106 };
1107};
1108
1109Nodes can contain other nodes etc... thus defining the hierarchical
1110structure of the tree.
1111
1112Strings support common escape sequences from C: "\n", "\t", "\r",
1113"\(octal value)", "\x(hex value)".
1114
1115It is also suggested that you pipe your source file through cpp (gcc
1116preprocessor) so you can use #include's, #define for constants, etc...
1117
1118Finally, various options are planned but not yet implemented, like
1119automatic generation of phandles, labels (exported to the asm file so
1120you can point to a property content and change it easily from whatever
1121you link the device-tree with), label or path instead of numeric value
1122in some cells to "point" to a node (replaced by a phandle at compile
1123time), export of reserve map address to the asm file, ability to
1124specify reserve map content at compile time, etc...
1125
1126We may provide a .h include file with common definitions of that
1127proves useful for some properties (like building PCI properties or
1128interrupt maps) though it may be better to add a notion of struct
1129definitions to the compiler...
1130
1131
1132V - Recommendations for a bootloader
1133====================================
1134
1135
1136Here are some various ideas/recommendations that have been proposed
1137while all this has been defined and implemented.
1138
1139 - The bootloader may want to be able to use the device-tree itself
1140 and may want to manipulate it (to add/edit some properties,
1141 like physical memory size or kernel arguments). At this point, 2
1142 choices can be made. Either the bootloader works directly on the
1143 flattened format, or the bootloader has its own internal tree
1144 representation with pointers (similar to the kernel one) and
1145 re-flattens the tree when booting the kernel. The former is a bit
1146 more difficult to edit/modify, the later requires probably a bit
1147 more code to handle the tree structure. Note that the structure
1148 format has been designed so it's relatively easy to "insert"
1149 properties or nodes or delete them by just memmoving things
1150 around. It contains no internal offsets or pointers for this
1151 purpose.
1152
Matt LaPlanted6bc8ac2006-10-03 22:54:15 +02001153 - An example of code for iterating nodes & retrieving properties
David Gibsonc125a182006-02-01 03:05:22 -08001154 directly from the flattened tree format can be found in the kernel
1155 file arch/ppc64/kernel/prom.c, look at scan_flat_dt() function,
Matt LaPlanted6bc8ac2006-10-03 22:54:15 +02001156 its usage in early_init_devtree(), and the corresponding various
David Gibsonc125a182006-02-01 03:05:22 -08001157 early_init_dt_scan_*() callbacks. That code can be re-used in a
1158 GPL bootloader, and as the author of that code, I would be happy
Domen Puncer5dd60162007-03-02 21:44:45 +11001159 to discuss possible free licensing to any vendor who wishes to
David Gibsonc125a182006-02-01 03:05:22 -08001160 integrate all or part of this code into a non-GPL bootloader.
1161
1162
1163
1164VI - System-on-a-chip devices and nodes
1165=======================================
1166
1167Many companies are now starting to develop system-on-a-chip
Domen Puncer5dd60162007-03-02 21:44:45 +11001168processors, where the processor core (CPU) and many peripheral devices
David Gibsonc125a182006-02-01 03:05:22 -08001169exist on a single piece of silicon. For these SOCs, an SOC node
1170should be used that defines child nodes for the devices that make
1171up the SOC. While platforms are not required to use this model in
1172order to boot the kernel, it is highly encouraged that all SOC
1173implementations define as complete a flat-device-tree as possible to
1174describe the devices on the SOC. This will allow for the
1175genericization of much of the kernel code.
1176
1177
11781) Defining child nodes of an SOC
1179---------------------------------
1180
1181Each device that is part of an SOC may have its own node entry inside
1182the SOC node. For each device that is included in the SOC, the unit
1183address property represents the address offset for this device's
1184memory-mapped registers in the parent's address space. The parent's
1185address space is defined by the "ranges" property in the top-level soc
1186node. The "reg" property for each node that exists directly under the
1187SOC node should contain the address mapping from the child address space
1188to the parent SOC address space and the size of the device's
1189memory-mapped register file.
1190
1191For many devices that may exist inside an SOC, there are predefined
1192specifications for the format of the device tree node. All SOC child
1193nodes should follow these specifications, except where noted in this
1194document.
1195
1196See appendix A for an example partial SOC node definition for the
1197MPC8540.
1198
1199
Stuart Yoder27565902007-03-02 13:42:33 -060012002) Representing devices without a current OF specification
David Gibsonc125a182006-02-01 03:05:22 -08001201----------------------------------------------------------
1202
1203Currently, there are many devices on SOCs that do not have a standard
1204representation pre-defined as part of the open firmware
1205specifications, mainly because the boards that contain these SOCs are
1206not currently booted using open firmware. This section contains
1207descriptions for the SOC devices for which new nodes have been
1208defined; this list will expand as more and more SOC-containing
1209platforms are moved over to use the flattened-device-tree model.
1210
1211 a) MDIO IO device
1212
1213 The MDIO is a bus to which the PHY devices are connected. For each
1214 device that exists on this bus, a child node should be created. See
1215 the definition of the PHY node below for an example of how to define
1216 a PHY.
1217
1218 Required properties:
1219 - reg : Offset and length of the register set for the device
1220 - device_type : Should be "mdio"
1221 - compatible : Should define the compatible device type for the
1222 mdio. Currently, this is most likely to be "gianfar"
1223
1224 Example:
1225
1226 mdio@24520 {
1227 reg = <24520 20>;
Becky Bruce7d4b95a2006-02-06 14:26:31 -06001228 device_type = "mdio";
1229 compatible = "gianfar";
David Gibsonc125a182006-02-01 03:05:22 -08001230
1231 ethernet-phy@0 {
1232 ......
1233 };
1234 };
1235
1236
1237 b) Gianfar-compatible ethernet nodes
1238
1239 Required properties:
1240
1241 - device_type : Should be "network"
1242 - model : Model of the device. Can be "TSEC", "eTSEC", or "FEC"
1243 - compatible : Should be "gianfar"
1244 - reg : Offset and length of the register set for the device
Jon Loeligerf5831652006-08-17 08:42:35 -05001245 - mac-address : List of bytes representing the ethernet address of
David Gibsonc125a182006-02-01 03:05:22 -08001246 this controller
1247 - interrupts : <a b> where a is the interrupt number and b is a
1248 field that represents an encoding of the sense and level
1249 information for the interrupt. This should be encoded based on
1250 the information in section 2) depending on the type of interrupt
1251 controller you have.
1252 - interrupt-parent : the phandle for the interrupt controller that
1253 services interrupts for this device.
1254 - phy-handle : The phandle for the PHY connected to this ethernet
1255 controller.
1256
Scott Woode0a2f282007-03-16 12:28:46 -05001257 Recommended properties:
1258
1259 - linux,network-index : This is the intended "index" of this
1260 network device. This is used by the bootwrapper to interpret
1261 MAC addresses passed by the firmware when no information other
1262 than indices is available to associate an address with a device.
Andy Flemingcc651852007-07-10 17:28:49 -05001263 - phy-connection-type : a string naming the controller/PHY interface type,
1264 i.e., "mii" (default), "rmii", "gmii", "rgmii", "rgmii-id", "sgmii",
1265 "tbi", or "rtbi". This property is only really needed if the connection
1266 is of type "rgmii-id", as all other connection types are detected by
1267 hardware.
1268
Scott Woode0a2f282007-03-16 12:28:46 -05001269
David Gibsonc125a182006-02-01 03:05:22 -08001270 Example:
1271
1272 ethernet@24000 {
1273 #size-cells = <0>;
1274 device_type = "network";
1275 model = "TSEC";
1276 compatible = "gianfar";
1277 reg = <24000 1000>;
Jon Loeligerf5831652006-08-17 08:42:35 -05001278 mac-address = [ 00 E0 0C 00 73 00 ];
David Gibsonc125a182006-02-01 03:05:22 -08001279 interrupts = <d 3 e 3 12 3>;
1280 interrupt-parent = <40000>;
1281 phy-handle = <2452000>
1282 };
1283
1284
1285
1286 c) PHY nodes
1287
1288 Required properties:
1289
1290 - device_type : Should be "ethernet-phy"
1291 - interrupts : <a b> where a is the interrupt number and b is a
1292 field that represents an encoding of the sense and level
1293 information for the interrupt. This should be encoded based on
1294 the information in section 2) depending on the type of interrupt
1295 controller you have.
1296 - interrupt-parent : the phandle for the interrupt controller that
1297 services interrupts for this device.
1298 - reg : The ID number for the phy, usually a small integer
1299 - linux,phandle : phandle for this node; likely referenced by an
1300 ethernet controller node.
1301
1302
1303 Example:
1304
1305 ethernet-phy@0 {
1306 linux,phandle = <2452000>
1307 interrupt-parent = <40000>;
1308 interrupts = <35 1>;
1309 reg = <0>;
1310 device_type = "ethernet-phy";
1311 };
1312
1313
1314 d) Interrupt controllers
1315
1316 Some SOC devices contain interrupt controllers that are different
1317 from the standard Open PIC specification. The SOC device nodes for
1318 these types of controllers should be specified just like a standard
1319 OpenPIC controller. Sense and level information should be encoded
1320 as specified in section 2) of this chapter for each device that
1321 specifies an interrupt.
1322
1323 Example :
1324
1325 pic@40000 {
1326 linux,phandle = <40000>;
1327 clock-frequency = <0>;
1328 interrupt-controller;
1329 #address-cells = <0>;
1330 reg = <40000 40000>;
1331 built-in;
1332 compatible = "chrp,open-pic";
1333 device_type = "open-pic";
1334 big-endian;
1335 };
1336
1337
1338 e) I2C
1339
1340 Required properties :
1341
1342 - device_type : Should be "i2c"
1343 - reg : Offset and length of the register set for the device
1344
1345 Recommended properties :
1346
1347 - compatible : Should be "fsl-i2c" for parts compatible with
1348 Freescale I2C specifications.
1349 - interrupts : <a b> where a is the interrupt number and b is a
1350 field that represents an encoding of the sense and level
1351 information for the interrupt. This should be encoded based on
1352 the information in section 2) depending on the type of interrupt
1353 controller you have.
1354 - interrupt-parent : the phandle for the interrupt controller that
1355 services interrupts for this device.
1356 - dfsrr : boolean; if defined, indicates that this I2C device has
1357 a digital filter sampling rate register
1358 - fsl5200-clocking : boolean; if defined, indicated that this device
1359 uses the FSL 5200 clocking mechanism.
1360
1361 Example :
1362
1363 i2c@3000 {
1364 interrupt-parent = <40000>;
1365 interrupts = <1b 3>;
1366 reg = <3000 18>;
1367 device_type = "i2c";
1368 compatible = "fsl-i2c";
1369 dfsrr;
1370 };
1371
1372
Becky Brucead71f122006-02-07 13:44:08 -06001373 f) Freescale SOC USB controllers
1374
1375 The device node for a USB controller that is part of a Freescale
1376 SOC is as described in the document "Open Firmware Recommended
1377 Practice : Universal Serial Bus" with the following modifications
1378 and additions :
1379
1380 Required properties :
Domen Puncer5dd60162007-03-02 21:44:45 +11001381 - compatible : Should be "fsl-usb2-mph" for multi port host USB
1382 controllers, or "fsl-usb2-dr" for dual role USB controllers
1383 - phy_type : For multi port host USB controllers, should be one of
1384 "ulpi", or "serial". For dual role USB controllers, should be
Becky Brucead71f122006-02-07 13:44:08 -06001385 one of "ulpi", "utmi", "utmi_wide", or "serial".
1386 - reg : Offset and length of the register set for the device
1387 - port0 : boolean; if defined, indicates port0 is connected for
1388 fsl-usb2-mph compatible controllers. Either this property or
1389 "port1" (or both) must be defined for "fsl-usb2-mph" compatible
1390 controllers.
1391 - port1 : boolean; if defined, indicates port1 is connected for
1392 fsl-usb2-mph compatible controllers. Either this property or
1393 "port0" (or both) must be defined for "fsl-usb2-mph" compatible
1394 controllers.
Li Yangea5b7a62007-02-07 13:51:09 +08001395 - dr_mode : indicates the working mode for "fsl-usb2-dr" compatible
1396 controllers. Can be "host", "peripheral", or "otg". Default to
1397 "host" if not defined for backward compatibility.
Becky Brucead71f122006-02-07 13:44:08 -06001398
1399 Recommended properties :
1400 - interrupts : <a b> where a is the interrupt number and b is a
1401 field that represents an encoding of the sense and level
1402 information for the interrupt. This should be encoded based on
1403 the information in section 2) depending on the type of interrupt
1404 controller you have.
1405 - interrupt-parent : the phandle for the interrupt controller that
1406 services interrupts for this device.
1407
Domen Puncer5dd60162007-03-02 21:44:45 +11001408 Example multi port host USB controller device node :
Becky Brucead71f122006-02-07 13:44:08 -06001409 usb@22000 {
1410 device_type = "usb";
1411 compatible = "fsl-usb2-mph";
1412 reg = <22000 1000>;
1413 #address-cells = <1>;
1414 #size-cells = <0>;
1415 interrupt-parent = <700>;
1416 interrupts = <27 1>;
1417 phy_type = "ulpi";
1418 port0;
1419 port1;
1420 };
1421
Domen Puncer5dd60162007-03-02 21:44:45 +11001422 Example dual role USB controller device node :
Becky Brucead71f122006-02-07 13:44:08 -06001423 usb@23000 {
1424 device_type = "usb";
1425 compatible = "fsl-usb2-dr";
1426 reg = <23000 1000>;
1427 #address-cells = <1>;
1428 #size-cells = <0>;
1429 interrupt-parent = <700>;
1430 interrupts = <26 1>;
Li Yangea5b7a62007-02-07 13:51:09 +08001431 dr_mode = "otg";
Becky Brucead71f122006-02-07 13:44:08 -06001432 phy = "ulpi";
1433 };
1434
1435
Kim Phillipsb88a0b12006-03-22 14:39:03 -06001436 g) Freescale SOC SEC Security Engines
1437
1438 Required properties:
1439
1440 - device_type : Should be "crypto"
1441 - model : Model of the device. Should be "SEC1" or "SEC2"
1442 - compatible : Should be "talitos"
1443 - reg : Offset and length of the register set for the device
1444 - interrupts : <a b> where a is the interrupt number and b is a
1445 field that represents an encoding of the sense and level
1446 information for the interrupt. This should be encoded based on
1447 the information in section 2) depending on the type of interrupt
1448 controller you have.
1449 - interrupt-parent : the phandle for the interrupt controller that
1450 services interrupts for this device.
1451 - num-channels : An integer representing the number of channels
1452 available.
1453 - channel-fifo-len : An integer representing the number of
1454 descriptor pointers each channel fetch fifo can hold.
1455 - exec-units-mask : The bitmask representing what execution units
Domen Puncer5dd60162007-03-02 21:44:45 +11001456 (EUs) are available. It's a single 32-bit cell. EU information
Kim Phillipsb88a0b12006-03-22 14:39:03 -06001457 should be encoded following the SEC's Descriptor Header Dword
1458 EU_SEL0 field documentation, i.e. as follows:
1459
1460 bit 0 = reserved - should be 0
1461 bit 1 = set if SEC has the ARC4 EU (AFEU)
1462 bit 2 = set if SEC has the DES/3DES EU (DEU)
1463 bit 3 = set if SEC has the message digest EU (MDEU)
1464 bit 4 = set if SEC has the random number generator EU (RNG)
1465 bit 5 = set if SEC has the public key EU (PKEU)
1466 bit 6 = set if SEC has the AES EU (AESU)
1467 bit 7 = set if SEC has the Kasumi EU (KEU)
1468
1469 bits 8 through 31 are reserved for future SEC EUs.
1470
1471 - descriptor-types-mask : The bitmask representing what descriptors
Domen Puncer5dd60162007-03-02 21:44:45 +11001472 are available. It's a single 32-bit cell. Descriptor type
Kim Phillipsb88a0b12006-03-22 14:39:03 -06001473 information should be encoded following the SEC's Descriptor
1474 Header Dword DESC_TYPE field documentation, i.e. as follows:
1475
1476 bit 0 = set if SEC supports the aesu_ctr_nonsnoop desc. type
1477 bit 1 = set if SEC supports the ipsec_esp descriptor type
1478 bit 2 = set if SEC supports the common_nonsnoop desc. type
1479 bit 3 = set if SEC supports the 802.11i AES ccmp desc. type
1480 bit 4 = set if SEC supports the hmac_snoop_no_afeu desc. type
1481 bit 5 = set if SEC supports the srtp descriptor type
1482 bit 6 = set if SEC supports the non_hmac_snoop_no_afeu desc.type
1483 bit 7 = set if SEC supports the pkeu_assemble descriptor type
1484 bit 8 = set if SEC supports the aesu_key_expand_output desc.type
1485 bit 9 = set if SEC supports the pkeu_ptmul descriptor type
1486 bit 10 = set if SEC supports the common_nonsnoop_afeu desc. type
1487 bit 11 = set if SEC supports the pkeu_ptadd_dbl descriptor type
1488
1489 ..and so on and so forth.
1490
1491 Example:
1492
1493 /* MPC8548E */
1494 crypto@30000 {
1495 device_type = "crypto";
1496 model = "SEC2";
1497 compatible = "talitos";
1498 reg = <30000 10000>;
1499 interrupts = <1d 3>;
1500 interrupt-parent = <40000>;
1501 num-channels = <4>;
Kim Phillipscbdb54d2006-07-03 15:10:14 -05001502 channel-fifo-len = <18>;
Kim Phillipsb88a0b12006-03-22 14:39:03 -06001503 exec-units-mask = <000000fe>;
Kim Phillipscbdb54d2006-07-03 15:10:14 -05001504 descriptor-types-mask = <012b0ebf>;
Kim Phillipsb88a0b12006-03-22 14:39:03 -06001505 };
1506
Li Yang9a1ab882006-10-02 20:08:59 -05001507 h) Board Control and Status (BCSR)
1508
1509 Required properties:
1510
1511 - device_type : Should be "board-control"
1512 - reg : Offset and length of the register set for the device
1513
1514 Example:
1515
1516 bcsr@f8000000 {
1517 device_type = "board-control";
1518 reg = <f8000000 8000>;
1519 };
1520
1521 i) Freescale QUICC Engine module (QE)
1522 This represents qe module that is installed on PowerQUICC II Pro.
Scott Woode631ae32007-09-14 13:04:54 -05001523
1524 NOTE: This is an interim binding; it should be updated to fit
1525 in with the CPM binding later in this document.
1526
Li Yang9a1ab882006-10-02 20:08:59 -05001527 Basically, it is a bus of devices, that could act more or less
1528 as a complete entity (UCC, USB etc ). All of them should be siblings on
1529 the "root" qe node, using the common properties from there.
Michael Opdenacker59c51592007-05-09 08:57:56 +02001530 The description below applies to the qe of MPC8360 and
Li Yang9a1ab882006-10-02 20:08:59 -05001531 more nodes and properties would be extended in the future.
1532
1533 i) Root QE device
1534
1535 Required properties:
1536 - device_type : should be "qe";
1537 - model : precise model of the QE, Can be "QE", "CPM", or "CPM2"
1538 - reg : offset and length of the device registers.
1539 - bus-frequency : the clock frequency for QUICC Engine.
1540
1541 Recommended properties
1542 - brg-frequency : the internal clock source frequency for baud-rate
1543 generators in Hz.
1544
1545 Example:
1546 qe@e0100000 {
1547 #address-cells = <1>;
1548 #size-cells = <1>;
1549 #interrupt-cells = <2>;
1550 device_type = "qe";
1551 model = "QE";
1552 ranges = <0 e0100000 00100000>;
1553 reg = <e0100000 480>;
1554 brg-frequency = <0>;
1555 bus-frequency = <179A7B00>;
1556 }
1557
1558
1559 ii) SPI (Serial Peripheral Interface)
1560
1561 Required properties:
1562 - device_type : should be "spi".
1563 - compatible : should be "fsl_spi".
Peter Korsgaardf023dc72007-10-03 18:29:09 +02001564 - mode : the SPI operation mode, it can be "cpu" or "cpu-qe".
Li Yang9a1ab882006-10-02 20:08:59 -05001565 - reg : Offset and length of the register set for the device
1566 - interrupts : <a b> where a is the interrupt number and b is a
1567 field that represents an encoding of the sense and level
1568 information for the interrupt. This should be encoded based on
1569 the information in section 2) depending on the type of interrupt
1570 controller you have.
1571 - interrupt-parent : the phandle for the interrupt controller that
1572 services interrupts for this device.
1573
1574 Example:
1575 spi@4c0 {
1576 device_type = "spi";
1577 compatible = "fsl_spi";
1578 reg = <4c0 40>;
1579 interrupts = <82 0>;
1580 interrupt-parent = <700>;
1581 mode = "cpu";
1582 };
1583
1584
1585 iii) USB (Universal Serial Bus Controller)
1586
1587 Required properties:
1588 - device_type : should be "usb".
1589 - compatible : could be "qe_udc" or "fhci-hcd".
1590 - mode : the could be "host" or "slave".
1591 - reg : Offset and length of the register set for the device
1592 - interrupts : <a b> where a is the interrupt number and b is a
1593 field that represents an encoding of the sense and level
1594 information for the interrupt. This should be encoded based on
1595 the information in section 2) depending on the type of interrupt
1596 controller you have.
1597 - interrupt-parent : the phandle for the interrupt controller that
1598 services interrupts for this device.
1599
1600 Example(slave):
1601 usb@6c0 {
1602 device_type = "usb";
1603 compatible = "qe_udc";
1604 reg = <6c0 40>;
1605 interrupts = <8b 0>;
1606 interrupt-parent = <700>;
1607 mode = "slave";
1608 };
1609
1610
1611 iv) UCC (Unified Communications Controllers)
1612
1613 Required properties:
1614 - device_type : should be "network", "hldc", "uart", "transparent"
1615 "bisync" or "atm".
1616 - compatible : could be "ucc_geth" or "fsl_atm" and so on.
1617 - model : should be "UCC".
1618 - device-id : the ucc number(1-8), corresponding to UCCx in UM.
1619 - reg : Offset and length of the register set for the device
1620 - interrupts : <a b> where a is the interrupt number and b is a
1621 field that represents an encoding of the sense and level
1622 information for the interrupt. This should be encoded based on
1623 the information in section 2) depending on the type of interrupt
1624 controller you have.
1625 - interrupt-parent : the phandle for the interrupt controller that
1626 services interrupts for this device.
1627 - pio-handle : The phandle for the Parallel I/O port configuration.
1628 - rx-clock : represents the UCC receive clock source.
1629 0x00 : clock source is disabled;
1630 0x1~0x10 : clock source is BRG1~BRG16 respectively;
1631 0x11~0x28: clock source is QE_CLK1~QE_CLK24 respectively.
1632 - tx-clock: represents the UCC transmit clock source;
1633 0x00 : clock source is disabled;
1634 0x1~0x10 : clock source is BRG1~BRG16 respectively;
1635 0x11~0x28: clock source is QE_CLK1~QE_CLK24 respectively.
1636
1637 Required properties for network device_type:
1638 - mac-address : list of bytes representing the ethernet address.
1639 - phy-handle : The phandle for the PHY connected to this controller.
1640
Scott Woode0a2f282007-03-16 12:28:46 -05001641 Recommended properties:
1642 - linux,network-index : This is the intended "index" of this
1643 network device. This is used by the bootwrapper to interpret
1644 MAC addresses passed by the firmware when no information other
1645 than indices is available to associate an address with a device.
Kim Phillips60c19222007-04-24 07:26:10 +10001646 - phy-connection-type : a string naming the controller/PHY interface type,
1647 i.e., "mii" (default), "rmii", "gmii", "rgmii", "rgmii-id", "tbi",
1648 or "rtbi".
Scott Woode0a2f282007-03-16 12:28:46 -05001649
Li Yang9a1ab882006-10-02 20:08:59 -05001650 Example:
1651 ucc@2000 {
1652 device_type = "network";
1653 compatible = "ucc_geth";
1654 model = "UCC";
1655 device-id = <1>;
1656 reg = <2000 200>;
1657 interrupts = <a0 0>;
1658 interrupt-parent = <700>;
1659 mac-address = [ 00 04 9f 00 23 23 ];
1660 rx-clock = "none";
1661 tx-clock = "clk9";
1662 phy-handle = <212000>;
Kim Phillips60c19222007-04-24 07:26:10 +10001663 phy-connection-type = "gmii";
Li Yang9a1ab882006-10-02 20:08:59 -05001664 pio-handle = <140001>;
1665 };
1666
1667
1668 v) Parallel I/O Ports
1669
1670 This node configures Parallel I/O ports for CPUs with QE support.
1671 The node should reside in the "soc" node of the tree. For each
1672 device that using parallel I/O ports, a child node should be created.
1673 See the definition of the Pin configuration nodes below for more
1674 information.
1675
1676 Required properties:
1677 - device_type : should be "par_io".
1678 - reg : offset to the register set and its length.
1679 - num-ports : number of Parallel I/O ports
1680
1681 Example:
1682 par_io@1400 {
1683 reg = <1400 100>;
1684 #address-cells = <1>;
1685 #size-cells = <0>;
1686 device_type = "par_io";
1687 num-ports = <7>;
1688 ucc_pin@01 {
1689 ......
1690 };
1691
1692
1693 vi) Pin configuration nodes
1694
1695 Required properties:
1696 - linux,phandle : phandle of this node; likely referenced by a QE
1697 device.
1698 - pio-map : array of pin configurations. Each pin is defined by 6
1699 integers. The six numbers are respectively: port, pin, dir,
1700 open_drain, assignment, has_irq.
1701 - port : port number of the pin; 0-6 represent port A-G in UM.
1702 - pin : pin number in the port.
1703 - dir : direction of the pin, should encode as follows:
1704
1705 0 = The pin is disabled
1706 1 = The pin is an output
1707 2 = The pin is an input
1708 3 = The pin is I/O
1709
1710 - open_drain : indicates the pin is normal or wired-OR:
1711
1712 0 = The pin is actively driven as an output
1713 1 = The pin is an open-drain driver. As an output, the pin is
1714 driven active-low, otherwise it is three-stated.
1715
1716 - assignment : function number of the pin according to the Pin Assignment
1717 tables in User Manual. Each pin can have up to 4 possible functions in
1718 QE and two options for CPM.
Matt LaPlantea982ac02007-05-09 07:35:06 +02001719 - has_irq : indicates if the pin is used as source of external
Li Yang9a1ab882006-10-02 20:08:59 -05001720 interrupts.
1721
1722 Example:
1723 ucc_pin@01 {
1724 linux,phandle = <140001>;
1725 pio-map = <
1726 /* port pin dir open_drain assignment has_irq */
1727 0 3 1 0 1 0 /* TxD0 */
1728 0 4 1 0 1 0 /* TxD1 */
1729 0 5 1 0 1 0 /* TxD2 */
1730 0 6 1 0 1 0 /* TxD3 */
1731 1 6 1 0 3 0 /* TxD4 */
1732 1 7 1 0 1 0 /* TxD5 */
1733 1 9 1 0 2 0 /* TxD6 */
1734 1 a 1 0 2 0 /* TxD7 */
1735 0 9 2 0 1 0 /* RxD0 */
1736 0 a 2 0 1 0 /* RxD1 */
1737 0 b 2 0 1 0 /* RxD2 */
1738 0 c 2 0 1 0 /* RxD3 */
1739 0 d 2 0 1 0 /* RxD4 */
1740 1 1 2 0 2 0 /* RxD5 */
1741 1 0 2 0 2 0 /* RxD6 */
1742 1 4 2 0 2 0 /* RxD7 */
1743 0 7 1 0 1 0 /* TX_EN */
1744 0 8 1 0 1 0 /* TX_ER */
1745 0 f 2 0 1 0 /* RX_DV */
1746 0 10 2 0 1 0 /* RX_ER */
1747 0 0 2 0 1 0 /* RX_CLK */
1748 2 9 1 0 3 0 /* GTX_CLK - CLK10 */
1749 2 8 2 0 1 0>; /* GTX125 - CLK9 */
1750 };
1751
1752 vii) Multi-User RAM (MURAM)
1753
1754 Required properties:
1755 - device_type : should be "muram".
1756 - mode : the could be "host" or "slave".
1757 - ranges : Should be defined as specified in 1) to describe the
1758 translation of MURAM addresses.
1759 - data-only : sub-node which defines the address area under MURAM
1760 bus that can be allocated as data/parameter
1761
1762 Example:
1763
1764 muram@10000 {
1765 device_type = "muram";
1766 ranges = <0 00010000 0000c000>;
1767
1768 data-only@0{
1769 reg = <0 c000>;
1770 };
1771 };
Kim Phillipsb88a0b12006-03-22 14:39:03 -06001772
David Gibson20991722007-09-07 13:23:53 +10001773 j) CFI or JEDEC memory-mapped NOR flash
Vitaly Wool28f9ec32006-11-20 16:32:39 +03001774
1775 Flash chips (Memory Technology Devices) are often used for solid state
1776 file systems on embedded devices.
1777
David Gibson20991722007-09-07 13:23:53 +10001778 - compatible : should contain the specific model of flash chip(s)
1779 used, if known, followed by either "cfi-flash" or "jedec-flash"
1780 - reg : Address range of the flash chip
1781 - bank-width : Width (in bytes) of the flash bank. Equal to the
1782 device width times the number of interleaved chips.
1783 - device-width : (optional) Width of a single flash chip. If
1784 omitted, assumed to be equal to 'bank-width'.
1785 - #address-cells, #size-cells : Must be present if the flash has
1786 sub-nodes representing partitions (see below). In this case
1787 both #address-cells and #size-cells must be equal to 1.
Vitaly Wool28f9ec32006-11-20 16:32:39 +03001788
David Gibson20991722007-09-07 13:23:53 +10001789 For JEDEC compatible devices, the following additional properties
1790 are defined:
Vitaly Wool28f9ec32006-11-20 16:32:39 +03001791
David Gibson20991722007-09-07 13:23:53 +10001792 - vendor-id : Contains the flash chip's vendor id (1 byte).
1793 - device-id : Contains the flash chip's device id (1 byte).
Vitaly Wool28f9ec32006-11-20 16:32:39 +03001794
David Gibson20991722007-09-07 13:23:53 +10001795 In addition to the information on the flash bank itself, the
1796 device tree may optionally contain additional information
1797 describing partitions of the flash address space. This can be
1798 used on platforms which have strong conventions about which
1799 portions of the flash are used for what purposes, but which don't
1800 use an on-flash partition table such as RedBoot.
Vitaly Wool28f9ec32006-11-20 16:32:39 +03001801
David Gibson20991722007-09-07 13:23:53 +10001802 Each partition is represented as a sub-node of the flash device.
1803 Each node's name represents the name of the corresponding
1804 partition of the flash device.
Vitaly Wool28f9ec32006-11-20 16:32:39 +03001805
David Gibson20991722007-09-07 13:23:53 +10001806 Flash partitions
1807 - reg : The partition's offset and size within the flash bank.
1808 - label : (optional) The label / name for this flash partition.
1809 If omitted, the label is taken from the node name (excluding
1810 the unit address).
1811 - read-only : (optional) This parameter, if present, is a hint to
1812 Linux that this flash partition should only be mounted
1813 read-only. This is usually used for flash partitions
1814 containing early-boot firmware images or data which should not
1815 be clobbered.
1816
1817 Example:
1818
1819 flash@ff000000 {
1820 compatible = "amd,am29lv128ml", "cfi-flash";
1821 reg = <ff000000 01000000>;
1822 bank-width = <4>;
1823 device-width = <1>;
1824 #address-cells = <1>;
1825 #size-cells = <1>;
1826 fs@0 {
1827 label = "fs";
1828 reg = <0 f80000>;
1829 };
1830 firmware@f80000 {
1831 label ="firmware";
1832 reg = <f80000 80000>;
1833 read-only;
1834 };
1835 };
Vitaly Wool28f9ec32006-11-20 16:32:39 +03001836
Roy Zang3b824f82007-06-19 15:19:18 +08001837 k) Global Utilities Block
1838
1839 The global utilities block controls power management, I/O device
1840 enabling, power-on-reset configuration monitoring, general-purpose
1841 I/O signal configuration, alternate function selection for multiplexed
1842 signals, and clock control.
1843
1844 Required properties:
1845
1846 - compatible : Should define the compatible device type for
1847 global-utilities.
1848 - reg : Offset and length of the register set for the device.
1849
1850 Recommended properties:
1851
1852 - fsl,has-rstcr : Indicates that the global utilities register set
1853 contains a functioning "reset control register" (i.e. the board
1854 is wired to reset upon setting the HRESET_REQ bit in this register).
1855
1856 Example:
1857
1858 global-utilities@e0000 { /* global utilities block */
1859 compatible = "fsl,mpc8548-guts";
1860 reg = <e0000 1000>;
1861 fsl,has-rstcr;
1862 };
1863
Scott Woode631ae32007-09-14 13:04:54 -05001864 l) Freescale Communications Processor Module
David Gibson1d3bb992007-08-23 13:56:01 +10001865
Scott Woode631ae32007-09-14 13:04:54 -05001866 NOTE: This is an interim binding, and will likely change slightly,
1867 as more devices are supported. The QE bindings especially are
1868 incomplete.
1869
1870 i) Root CPM node
1871
1872 Properties:
1873 - compatible : "fsl,cpm1", "fsl,cpm2", or "fsl,qe".
Scott Wood15f8c602007-09-28 14:06:16 -05001874 - reg : A 48-byte region beginning with CPCR.
Scott Woode631ae32007-09-14 13:04:54 -05001875
1876 Example:
1877 cpm@119c0 {
1878 #address-cells = <1>;
1879 #size-cells = <1>;
1880 #interrupt-cells = <2>;
1881 compatible = "fsl,mpc8272-cpm", "fsl,cpm2";
Scott Wood15f8c602007-09-28 14:06:16 -05001882 reg = <119c0 30>;
Scott Woode631ae32007-09-14 13:04:54 -05001883 }
1884
1885 ii) Properties common to mulitple CPM/QE devices
1886
1887 - fsl,cpm-command : This value is ORed with the opcode and command flag
1888 to specify the device on which a CPM command operates.
1889
1890 - fsl,cpm-brg : Indicates which baud rate generator the device
1891 is associated with. If absent, an unused BRG
1892 should be dynamically allocated. If zero, the
1893 device uses an external clock rather than a BRG.
1894
1895 - reg : Unless otherwise specified, the first resource represents the
1896 scc/fcc/ucc registers, and the second represents the device's
1897 parameter RAM region (if it has one).
1898
1899 iii) Serial
1900
1901 Currently defined compatibles:
1902 - fsl,cpm1-smc-uart
1903 - fsl,cpm2-smc-uart
1904 - fsl,cpm1-scc-uart
1905 - fsl,cpm2-scc-uart
1906 - fsl,qe-uart
1907
1908 Example:
1909
1910 serial@11a00 {
1911 device_type = "serial";
1912 compatible = "fsl,mpc8272-scc-uart",
1913 "fsl,cpm2-scc-uart";
1914 reg = <11a00 20 8000 100>;
1915 interrupts = <28 8>;
1916 interrupt-parent = <&PIC>;
1917 fsl,cpm-brg = <1>;
1918 fsl,cpm-command = <00800000>;
1919 };
1920
1921 iii) Network
1922
1923 Currently defined compatibles:
1924 - fsl,cpm1-scc-enet
1925 - fsl,cpm2-scc-enet
1926 - fsl,cpm1-fec-enet
1927 - fsl,cpm2-fcc-enet (third resource is GFEMR)
1928 - fsl,qe-enet
1929
1930 Example:
1931
1932 ethernet@11300 {
1933 device_type = "network";
1934 compatible = "fsl,mpc8272-fcc-enet",
1935 "fsl,cpm2-fcc-enet";
1936 reg = <11300 20 8400 100 11390 1>;
1937 local-mac-address = [ 00 00 00 00 00 00 ];
1938 interrupts = <20 8>;
1939 interrupt-parent = <&PIC>;
1940 phy-handle = <&PHY0>;
1941 linux,network-index = <0>;
1942 fsl,cpm-command = <12000300>;
1943 };
1944
1945 iv) MDIO
1946
1947 Currently defined compatibles:
1948 fsl,pq1-fec-mdio (reg is same as first resource of FEC device)
1949 fsl,cpm2-mdio-bitbang (reg is port C registers)
1950
1951 Properties for fsl,cpm2-mdio-bitbang:
1952 fsl,mdio-pin : pin of port C controlling mdio data
1953 fsl,mdc-pin : pin of port C controlling mdio clock
1954
1955 Example:
1956
1957 mdio@10d40 {
1958 device_type = "mdio";
1959 compatible = "fsl,mpc8272ads-mdio-bitbang",
1960 "fsl,mpc8272-mdio-bitbang",
1961 "fsl,cpm2-mdio-bitbang";
1962 reg = <10d40 14>;
1963 #address-cells = <1>;
1964 #size-cells = <0>;
1965 fsl,mdio-pin = <12>;
1966 fsl,mdc-pin = <13>;
1967 };
1968
1969 v) Baud Rate Generators
1970
1971 Currently defined compatibles:
1972 fsl,cpm-brg
1973 fsl,cpm1-brg
1974 fsl,cpm2-brg
1975
1976 Properties:
1977 - reg : There may be an arbitrary number of reg resources; BRG
1978 numbers are assigned to these in order.
1979 - clock-frequency : Specifies the base frequency driving
1980 the BRG.
1981
1982 Example:
1983
1984 brg@119f0 {
1985 compatible = "fsl,mpc8272-brg",
1986 "fsl,cpm2-brg",
1987 "fsl,cpm-brg";
1988 reg = <119f0 10 115f0 10>;
1989 clock-frequency = <d#25000000>;
1990 };
1991
1992 vi) Interrupt Controllers
1993
1994 Currently defined compatibles:
1995 - fsl,cpm1-pic
1996 - only one interrupt cell
1997 - fsl,pq1-pic
1998 - fsl,cpm2-pic
1999 - second interrupt cell is level/sense:
2000 - 2 is falling edge
2001 - 8 is active low
2002
2003 Example:
2004
2005 interrupt-controller@10c00 {
2006 #interrupt-cells = <2>;
2007 interrupt-controller;
2008 reg = <10c00 80>;
2009 compatible = "mpc8272-pic", "fsl,cpm2-pic";
2010 };
2011
2012 vii) USB (Universal Serial Bus Controller)
2013
2014 Properties:
2015 - compatible : "fsl,cpm1-usb", "fsl,cpm2-usb", "fsl,qe-usb"
2016
2017 Example:
2018 usb@11bc0 {
2019 #address-cells = <1>;
2020 #size-cells = <0>;
2021 compatible = "fsl,cpm2-usb";
2022 reg = <11b60 18 8b00 100>;
2023 interrupts = <b 8>;
2024 interrupt-parent = <&PIC>;
2025 fsl,cpm-command = <2e600000>;
2026 };
2027
Scott Wood15f8c602007-09-28 14:06:16 -05002028 viii) Multi-User RAM (MURAM)
2029
2030 The multi-user/dual-ported RAM is expressed as a bus under the CPM node.
2031
2032 Ranges must be set up subject to the following restrictions:
2033
2034 - Children's reg nodes must be offsets from the start of all muram, even
2035 if the user-data area does not begin at zero.
2036 - If multiple range entries are used, the difference between the parent
2037 address and the child address must be the same in all, so that a single
2038 mapping can cover them all while maintaining the ability to determine
2039 CPM-side offsets with pointer subtraction. It is recommended that
2040 multiple range entries not be used.
2041 - A child address of zero must be translatable, even if no reg resources
2042 contain it.
2043
2044 A child "data" node must exist, compatible with "fsl,cpm-muram-data", to
2045 indicate the portion of muram that is usable by the OS for arbitrary
2046 purposes. The data node may have an arbitrary number of reg resources,
2047 all of which contribute to the allocatable muram pool.
2048
2049 Example, based on mpc8272:
2050
2051 muram@0 {
2052 #address-cells = <1>;
2053 #size-cells = <1>;
2054 ranges = <0 0 10000>;
2055
2056 data@0 {
2057 compatible = "fsl,cpm-muram-data";
2058 reg = <0 2000 9800 800>;
2059 };
2060 };
2061
Scott Wood96fca1de2007-09-14 13:24:02 -05002062 m) Chipselect/Local Bus
2063
2064 Properties:
2065 - name : Should be localbus
2066 - #address-cells : Should be either two or three. The first cell is the
2067 chipselect number, and the remaining cells are the
2068 offset into the chipselect.
2069 - #size-cells : Either one or two, depending on how large each chipselect
2070 can be.
2071 - ranges : Each range corresponds to a single chipselect, and cover
2072 the entire access window as configured.
2073
2074 Example:
2075 localbus@f0010100 {
2076 compatible = "fsl,mpc8272ads-localbus",
2077 "fsl,mpc8272-localbus",
2078 "fsl,pq2-localbus";
2079 #address-cells = <2>;
2080 #size-cells = <1>;
2081 reg = <f0010100 40>;
2082
2083 ranges = <0 0 fe000000 02000000
2084 1 0 f4500000 00008000>;
2085
2086 flash@0,0 {
2087 compatible = "jedec-flash";
2088 reg = <0 0 2000000>;
2089 bank-width = <4>;
2090 device-width = <1>;
2091 };
2092
2093 board-control@1,0 {
2094 reg = <1 0 20>;
2095 compatible = "fsl,mpc8272ads-bcsr";
2096 };
2097 };
2098
2099
Linus Torvaldse8690862007-10-11 21:55:47 -07002100 n) 4xx/Axon EMAC ethernet nodes
David Gibson1d3bb992007-08-23 13:56:01 +10002101
2102 The EMAC ethernet controller in IBM and AMCC 4xx chips, and also
2103 the Axon bridge. To operate this needs to interact with a ths
2104 special McMAL DMA controller, and sometimes an RGMII or ZMII
2105 interface. In addition to the nodes and properties described
2106 below, the node for the OPB bus on which the EMAC sits must have a
2107 correct clock-frequency property.
2108
2109 i) The EMAC node itself
2110
2111 Required properties:
2112 - device_type : "network"
2113
2114 - compatible : compatible list, contains 2 entries, first is
2115 "ibm,emac-CHIP" where CHIP is the host ASIC (440gx,
2116 405gp, Axon) and second is either "ibm,emac" or
2117 "ibm,emac4". For Axon, thus, we have: "ibm,emac-axon",
2118 "ibm,emac4"
2119 - interrupts : <interrupt mapping for EMAC IRQ and WOL IRQ>
2120 - interrupt-parent : optional, if needed for interrupt mapping
2121 - reg : <registers mapping>
2122 - local-mac-address : 6 bytes, MAC address
2123 - mal-device : phandle of the associated McMAL node
2124 - mal-tx-channel : 1 cell, index of the tx channel on McMAL associated
2125 with this EMAC
2126 - mal-rx-channel : 1 cell, index of the rx channel on McMAL associated
2127 with this EMAC
2128 - cell-index : 1 cell, hardware index of the EMAC cell on a given
2129 ASIC (typically 0x0 and 0x1 for EMAC0 and EMAC1 on
2130 each Axon chip)
2131 - max-frame-size : 1 cell, maximum frame size supported in bytes
2132 - rx-fifo-size : 1 cell, Rx fifo size in bytes for 10 and 100 Mb/sec
2133 operations.
2134 For Axon, 2048
2135 - tx-fifo-size : 1 cell, Tx fifo size in bytes for 10 and 100 Mb/sec
2136 operations.
2137 For Axon, 2048.
2138 - fifo-entry-size : 1 cell, size of a fifo entry (used to calculate
2139 thresholds).
2140 For Axon, 0x00000010
2141 - mal-burst-size : 1 cell, MAL burst size (used to calculate thresholds)
2142 in bytes.
2143 For Axon, 0x00000100 (I think ...)
2144 - phy-mode : string, mode of operations of the PHY interface.
2145 Supported values are: "mii", "rmii", "smii", "rgmii",
2146 "tbi", "gmii", rtbi", "sgmii".
2147 For Axon on CAB, it is "rgmii"
2148 - mdio-device : 1 cell, required iff using shared MDIO registers
2149 (440EP). phandle of the EMAC to use to drive the
2150 MDIO lines for the PHY used by this EMAC.
2151 - zmii-device : 1 cell, required iff connected to a ZMII. phandle of
2152 the ZMII device node
2153 - zmii-channel : 1 cell, required iff connected to a ZMII. Which ZMII
2154 channel or 0xffffffff if ZMII is only used for MDIO.
2155 - rgmii-device : 1 cell, required iff connected to an RGMII. phandle
2156 of the RGMII device node.
2157 For Axon: phandle of plb5/plb4/opb/rgmii
2158 - rgmii-channel : 1 cell, required iff connected to an RGMII. Which
2159 RGMII channel is used by this EMAC.
2160 Fox Axon: present, whatever value is appropriate for each
2161 EMAC, that is the content of the current (bogus) "phy-port"
2162 property.
2163
2164 Recommended properties:
2165 - linux,network-index : This is the intended "index" of this
2166 network device. This is used by the bootwrapper to interpret
2167 MAC addresses passed by the firmware when no information other
2168 than indices is available to associate an address with a device.
2169
2170 Optional properties:
2171 - phy-address : 1 cell, optional, MDIO address of the PHY. If absent,
2172 a search is performed.
2173 - phy-map : 1 cell, optional, bitmap of addresses to probe the PHY
2174 for, used if phy-address is absent. bit 0x00000001 is
2175 MDIO address 0.
2176 For Axon it can be absent, thouugh my current driver
2177 doesn't handle phy-address yet so for now, keep
2178 0x00ffffff in it.
2179 - rx-fifo-size-gige : 1 cell, Rx fifo size in bytes for 1000 Mb/sec
2180 operations (if absent the value is the same as
2181 rx-fifo-size). For Axon, either absent or 2048.
2182 - tx-fifo-size-gige : 1 cell, Tx fifo size in bytes for 1000 Mb/sec
2183 operations (if absent the value is the same as
2184 tx-fifo-size). For Axon, either absent or 2048.
2185 - tah-device : 1 cell, optional. If connected to a TAH engine for
2186 offload, phandle of the TAH device node.
2187 - tah-channel : 1 cell, optional. If appropriate, channel used on the
2188 TAH engine.
2189
2190 Example:
2191
2192 EMAC0: ethernet@40000800 {
2193 linux,network-index = <0>;
2194 device_type = "network";
2195 compatible = "ibm,emac-440gp", "ibm,emac";
2196 interrupt-parent = <&UIC1>;
2197 interrupts = <1c 4 1d 4>;
2198 reg = <40000800 70>;
2199 local-mac-address = [00 04 AC E3 1B 1E];
2200 mal-device = <&MAL0>;
2201 mal-tx-channel = <0 1>;
2202 mal-rx-channel = <0>;
2203 cell-index = <0>;
2204 max-frame-size = <5dc>;
2205 rx-fifo-size = <1000>;
2206 tx-fifo-size = <800>;
2207 phy-mode = "rmii";
2208 phy-map = <00000001>;
2209 zmii-device = <&ZMII0>;
2210 zmii-channel = <0>;
2211 };
2212
2213 ii) McMAL node
2214
2215 Required properties:
2216 - device_type : "dma-controller"
2217 - compatible : compatible list, containing 2 entries, first is
2218 "ibm,mcmal-CHIP" where CHIP is the host ASIC (like
2219 emac) and the second is either "ibm,mcmal" or
2220 "ibm,mcmal2".
2221 For Axon, "ibm,mcmal-axon","ibm,mcmal2"
2222 - interrupts : <interrupt mapping for the MAL interrupts sources:
2223 5 sources: tx_eob, rx_eob, serr, txde, rxde>.
2224 For Axon: This is _different_ from the current
2225 firmware. We use the "delayed" interrupts for txeob
2226 and rxeob. Thus we end up with mapping those 5 MPIC
2227 interrupts, all level positive sensitive: 10, 11, 32,
2228 33, 34 (in decimal)
2229 - dcr-reg : < DCR registers range >
2230 - dcr-parent : if needed for dcr-reg
2231 - num-tx-chans : 1 cell, number of Tx channels
2232 - num-rx-chans : 1 cell, number of Rx channels
2233
2234 iii) ZMII node
2235
2236 Required properties:
2237 - compatible : compatible list, containing 2 entries, first is
2238 "ibm,zmii-CHIP" where CHIP is the host ASIC (like
2239 EMAC) and the second is "ibm,zmii".
2240 For Axon, there is no ZMII node.
2241 - reg : <registers mapping>
2242
2243 iv) RGMII node
2244
2245 Required properties:
2246 - compatible : compatible list, containing 2 entries, first is
2247 "ibm,rgmii-CHIP" where CHIP is the host ASIC (like
2248 EMAC) and the second is "ibm,rgmii".
2249 For Axon, "ibm,rgmii-axon","ibm,rgmii"
2250 - reg : <registers mapping>
2251 - revision : as provided by the RGMII new version register if
2252 available.
2253 For Axon: 0x0000012a
2254
David Gibsonc125a182006-02-01 03:05:22 -08002255 More devices will be defined as this spec matures.
2256
Stuart Yoder27565902007-03-02 13:42:33 -06002257VII - Specifying interrupt information for devices
2258===================================================
2259
2260The device tree represents the busses and devices of a hardware
2261system in a form similar to the physical bus topology of the
2262hardware.
2263
2264In addition, a logical 'interrupt tree' exists which represents the
2265hierarchy and routing of interrupts in the hardware.
2266
2267The interrupt tree model is fully described in the
2268document "Open Firmware Recommended Practice: Interrupt
2269Mapping Version 0.9". The document is available at:
2270<http://playground.sun.com/1275/practice>.
2271
22721) interrupts property
2273----------------------
2274
2275Devices that generate interrupts to a single interrupt controller
2276should use the conventional OF representation described in the
2277OF interrupt mapping documentation.
2278
2279Each device which generates interrupts must have an 'interrupt'
2280property. The interrupt property value is an arbitrary number of
2281of 'interrupt specifier' values which describe the interrupt or
2282interrupts for the device.
2283
2284The encoding of an interrupt specifier is determined by the
2285interrupt domain in which the device is located in the
2286interrupt tree. The root of an interrupt domain specifies in
2287its #interrupt-cells property the number of 32-bit cells
2288required to encode an interrupt specifier. See the OF interrupt
2289mapping documentation for a detailed description of domains.
2290
2291For example, the binding for the OpenPIC interrupt controller
2292specifies an #interrupt-cells value of 2 to encode the interrupt
2293number and level/sense information. All interrupt children in an
2294OpenPIC interrupt domain use 2 cells per interrupt in their interrupts
2295property.
2296
2297The PCI bus binding specifies a #interrupt-cell value of 1 to encode
2298which interrupt pin (INTA,INTB,INTC,INTD) is used.
2299
23002) interrupt-parent property
2301----------------------------
2302
2303The interrupt-parent property is specified to define an explicit
2304link between a device node and its interrupt parent in
2305the interrupt tree. The value of interrupt-parent is the
2306phandle of the parent node.
2307
2308If the interrupt-parent property is not defined for a node, it's
2309interrupt parent is assumed to be an ancestor in the node's
2310_device tree_ hierarchy.
2311
23123) OpenPIC Interrupt Controllers
2313--------------------------------
2314
2315OpenPIC interrupt controllers require 2 cells to encode
2316interrupt information. The first cell defines the interrupt
2317number. The second cell defines the sense and level
2318information.
2319
2320Sense and level information should be encoded as follows:
2321
2322 0 = low to high edge sensitive type enabled
2323 1 = active low level sensitive type enabled
2324 2 = active high level sensitive type enabled
2325 3 = high to low edge sensitive type enabled
2326
23274) ISA Interrupt Controllers
2328----------------------------
2329
2330ISA PIC interrupt controllers require 2 cells to encode
2331interrupt information. The first cell defines the interrupt
2332number. The second cell defines the sense and level
2333information.
2334
2335ISA PIC interrupt controllers should adhere to the ISA PIC
2336encodings listed below:
2337
2338 0 = active low level sensitive type enabled
2339 1 = active high level sensitive type enabled
2340 2 = high to low edge sensitive type enabled
2341 3 = low to high edge sensitive type enabled
2342
David Gibsonc125a182006-02-01 03:05:22 -08002343
2344Appendix A - Sample SOC node for MPC8540
2345========================================
2346
2347Note that the #address-cells and #size-cells for the SoC node
2348in this example have been explicitly listed; these are likely
2349not necessary as they are usually the same as the root node.
2350
2351 soc8540@e0000000 {
2352 #address-cells = <1>;
2353 #size-cells = <1>;
2354 #interrupt-cells = <2>;
2355 device_type = "soc";
2356 ranges = <00000000 e0000000 00100000>
2357 reg = <e0000000 00003000>;
Becky Bruce7d4b95a2006-02-06 14:26:31 -06002358 bus-frequency = <0>;
David Gibsonc125a182006-02-01 03:05:22 -08002359
2360 mdio@24520 {
2361 reg = <24520 20>;
2362 device_type = "mdio";
2363 compatible = "gianfar";
2364
2365 ethernet-phy@0 {
2366 linux,phandle = <2452000>
2367 interrupt-parent = <40000>;
2368 interrupts = <35 1>;
2369 reg = <0>;
2370 device_type = "ethernet-phy";
2371 };
2372
2373 ethernet-phy@1 {
2374 linux,phandle = <2452001>
2375 interrupt-parent = <40000>;
2376 interrupts = <35 1>;
2377 reg = <1>;
2378 device_type = "ethernet-phy";
2379 };
2380
2381 ethernet-phy@3 {
2382 linux,phandle = <2452002>
2383 interrupt-parent = <40000>;
2384 interrupts = <35 1>;
2385 reg = <3>;
2386 device_type = "ethernet-phy";
2387 };
2388
2389 };
2390
2391 ethernet@24000 {
2392 #size-cells = <0>;
2393 device_type = "network";
2394 model = "TSEC";
2395 compatible = "gianfar";
2396 reg = <24000 1000>;
Jon Loeligerf5831652006-08-17 08:42:35 -05002397 mac-address = [ 00 E0 0C 00 73 00 ];
David Gibsonc125a182006-02-01 03:05:22 -08002398 interrupts = <d 3 e 3 12 3>;
2399 interrupt-parent = <40000>;
2400 phy-handle = <2452000>;
2401 };
2402
2403 ethernet@25000 {
2404 #address-cells = <1>;
2405 #size-cells = <0>;
2406 device_type = "network";
2407 model = "TSEC";
2408 compatible = "gianfar";
2409 reg = <25000 1000>;
Jon Loeligerf5831652006-08-17 08:42:35 -05002410 mac-address = [ 00 E0 0C 00 73 01 ];
David Gibsonc125a182006-02-01 03:05:22 -08002411 interrupts = <13 3 14 3 18 3>;
2412 interrupt-parent = <40000>;
2413 phy-handle = <2452001>;
2414 };
2415
2416 ethernet@26000 {
2417 #address-cells = <1>;
2418 #size-cells = <0>;
2419 device_type = "network";
2420 model = "FEC";
2421 compatible = "gianfar";
2422 reg = <26000 1000>;
Jon Loeligerf5831652006-08-17 08:42:35 -05002423 mac-address = [ 00 E0 0C 00 73 02 ];
David Gibsonc125a182006-02-01 03:05:22 -08002424 interrupts = <19 3>;
2425 interrupt-parent = <40000>;
2426 phy-handle = <2452002>;
2427 };
2428
2429 serial@4500 {
2430 device_type = "serial";
2431 compatible = "ns16550";
2432 reg = <4500 100>;
2433 clock-frequency = <0>;
2434 interrupts = <1a 3>;
2435 interrupt-parent = <40000>;
2436 };
2437
2438 pic@40000 {
2439 linux,phandle = <40000>;
2440 clock-frequency = <0>;
2441 interrupt-controller;
2442 #address-cells = <0>;
2443 reg = <40000 40000>;
2444 built-in;
2445 compatible = "chrp,open-pic";
2446 device_type = "open-pic";
2447 big-endian;
2448 };
2449
2450 i2c@3000 {
2451 interrupt-parent = <40000>;
2452 interrupts = <1b 3>;
2453 reg = <3000 18>;
2454 device_type = "i2c";
2455 compatible = "fsl-i2c";
2456 dfsrr;
2457 };
2458
2459 };