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