blob: f920c2459e89ee2ae7903879ae330af53bfd95e3 [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
Grant Likely7ae0fa492007-10-23 14:27:41 +100055 l) Xilinx IP cores
Stuart Yoder5e1e9ba2007-06-06 04:29:14 +100056
57 VII - Specifying interrupt information for devices
58 1) interrupts property
59 2) interrupt-parent property
60 3) OpenPIC Interrupt Controllers
61 4) ISA Interrupt Controllers
62
63 Appendix A - Sample SOC node for MPC8540
64
65
66Revision Information
67====================
68
David Gibsonc125a182006-02-01 03:05:22 -080069 May 18, 2005: Rev 0.1 - Initial draft, no chapter III yet.
70
71 May 19, 2005: Rev 0.2 - Add chapter III and bits & pieces here or
72 clarifies the fact that a lot of things are
73 optional, the kernel only requires a very
74 small device tree, though it is encouraged
75 to provide an as complete one as possible.
76
77 May 24, 2005: Rev 0.3 - Precise that DT block has to be in RAM
78 - Misc fixes
79 - Define version 3 and new format version 16
80 for the DT block (version 16 needs kernel
81 patches, will be fwd separately).
82 String block now has a size, and full path
83 is replaced by unit name for more
84 compactness.
85 linux,phandle is made optional, only nodes
86 that are referenced by other nodes need it.
87 "name" property is now automatically
88 deduced from the unit name
89
90 June 1, 2005: Rev 0.4 - Correct confusion between OF_DT_END and
91 OF_DT_END_NODE in structure definition.
92 - Change version 16 format to always align
93 property data to 4 bytes. Since tokens are
94 already aligned, that means no specific
Matt LaPlante5d3f0832006-11-30 05:21:10 +010095 required alignment between property size
David Gibsonc125a182006-02-01 03:05:22 -080096 and property data. The old style variable
97 alignment would make it impossible to do
98 "simple" insertion of properties using
Domen Puncer5dd60162007-03-02 21:44:45 +110099 memmove (thanks Milton for
David Gibsonc125a182006-02-01 03:05:22 -0800100 noticing). Updated kernel patch as well
Matt LaPlante5d3f0832006-11-30 05:21:10 +0100101 - Correct a few more alignment constraints
David Gibsonc125a182006-02-01 03:05:22 -0800102 - Add a chapter about the device-tree
103 compiler and the textural representation of
104 the tree that can be "compiled" by dtc.
105
David Gibsonc125a182006-02-01 03:05:22 -0800106 November 21, 2005: Rev 0.5
107 - Additions/generalizations for 32-bit
108 - Changed to reflect the new arch/powerpc
109 structure
110 - Added chapter VI
111
112
113 ToDo:
114 - Add some definitions of interrupt tree (simple/complex)
Domen Puncer5dd60162007-03-02 21:44:45 +1100115 - Add some definitions for PCI host bridges
David Gibsonc125a182006-02-01 03:05:22 -0800116 - Add some common address format examples
117 - Add definitions for standard properties and "compatible"
118 names for cells that are not already defined by the existing
119 OF spec.
120 - Compare FSL SOC use of PCI to standard and make sure no new
121 node definition required.
122 - Add more information about node definitions for SOC devices
123 that currently have no standard, like the FSL CPM.
124
125
126I - Introduction
127================
128
129During the recent development of the Linux/ppc64 kernel, and more
130specifically, the addition of new platform types outside of the old
131IBM pSeries/iSeries pair, it was decided to enforce some strict rules
132regarding the kernel entry and bootloader <-> kernel interfaces, in
133order to avoid the degeneration that had become the ppc32 kernel entry
134point and the way a new platform should be added to the kernel. The
135legacy iSeries platform breaks those rules as it predates this scheme,
136but no new board support will be accepted in the main tree that
137doesn't follows them properly. In addition, since the advent of the
138arch/powerpc merged architecture for ppc32 and ppc64, new 32-bit
139platforms and 32-bit platforms which move into arch/powerpc will be
140required to use these rules as well.
141
142The main requirement that will be defined in more detail below is
143the presence of a device-tree whose format is defined after Open
144Firmware specification. However, in order to make life easier
145to embedded board vendors, the kernel doesn't require the device-tree
146to represent every device in the system and only requires some nodes
147and properties to be present. This will be described in detail in
148section III, but, for example, the kernel does not require you to
149create a node for every PCI device in the system. It is a requirement
150to have a node for PCI host bridges in order to provide interrupt
151routing informations and memory/IO ranges, among others. It is also
152recommended to define nodes for on chip devices and other busses that
153don't specifically fit in an existing OF specification. This creates a
154great flexibility in the way the kernel can then probe those and match
155drivers to device, without having to hard code all sorts of tables. It
156also makes it more flexible for board vendors to do minor hardware
157upgrades without significantly impacting the kernel code or cluttering
158it with special cases.
159
160
1611) Entry point for arch/powerpc
162-------------------------------
163
164 There is one and one single entry point to the kernel, at the start
165 of the kernel image. That entry point supports two calling
166 conventions:
167
168 a) Boot from Open Firmware. If your firmware is compatible
169 with Open Firmware (IEEE 1275) or provides an OF compatible
170 client interface API (support for "interpret" callback of
171 forth words isn't required), you can enter the kernel with:
172
173 r5 : OF callback pointer as defined by IEEE 1275
Domen Puncer5dd60162007-03-02 21:44:45 +1100174 bindings to powerpc. Only the 32-bit client interface
David Gibsonc125a182006-02-01 03:05:22 -0800175 is currently supported
176
177 r3, r4 : address & length of an initrd if any or 0
178
179 The MMU is either on or off; the kernel will run the
180 trampoline located in arch/powerpc/kernel/prom_init.c to
181 extract the device-tree and other information from open
182 firmware and build a flattened device-tree as described
183 in b). prom_init() will then re-enter the kernel using
184 the second method. This trampoline code runs in the
185 context of the firmware, which is supposed to handle all
186 exceptions during that time.
187
188 b) Direct entry with a flattened device-tree block. This entry
189 point is called by a) after the OF trampoline and can also be
190 called directly by a bootloader that does not support the Open
191 Firmware client interface. It is also used by "kexec" to
192 implement "hot" booting of a new kernel from a previous
193 running one. This method is what I will describe in more
194 details in this document, as method a) is simply standard Open
195 Firmware, and thus should be implemented according to the
196 various standard documents defining it and its binding to the
197 PowerPC platform. The entry point definition then becomes:
198
199 r3 : physical pointer to the device-tree block
200 (defined in chapter II) in RAM
201
202 r4 : physical pointer to the kernel itself. This is
203 used by the assembly code to properly disable the MMU
204 in case you are entering the kernel with MMU enabled
205 and a non-1:1 mapping.
206
Matt LaPlante2fe0ae72006-10-03 22:50:39 +0200207 r5 : NULL (as to differentiate with method a)
David Gibsonc125a182006-02-01 03:05:22 -0800208
209 Note about SMP entry: Either your firmware puts your other
210 CPUs in some sleep loop or spin loop in ROM where you can get
211 them out via a soft reset or some other means, in which case
212 you don't need to care, or you'll have to enter the kernel
213 with all CPUs. The way to do that with method b) will be
214 described in a later revision of this document.
215
216
2172) Board support
218----------------
219
22064-bit kernels:
221
222 Board supports (platforms) are not exclusive config options. An
223 arbitrary set of board supports can be built in a single kernel
224 image. The kernel will "know" what set of functions to use for a
225 given platform based on the content of the device-tree. Thus, you
226 should:
227
228 a) add your platform support as a _boolean_ option in
229 arch/powerpc/Kconfig, following the example of PPC_PSERIES,
230 PPC_PMAC and PPC_MAPLE. The later is probably a good
231 example of a board support to start from.
232
233 b) create your main platform file as
234 "arch/powerpc/platforms/myplatform/myboard_setup.c" and add it
235 to the Makefile under the condition of your CONFIG_
236 option. This file will define a structure of type "ppc_md"
237 containing the various callbacks that the generic code will
238 use to get to your platform specific code
239
240 c) Add a reference to your "ppc_md" structure in the
241 "machines" table in arch/powerpc/kernel/setup_64.c if you are
242 a 64-bit platform.
243
244 d) request and get assigned a platform number (see PLATFORM_*
245 constants in include/asm-powerpc/processor.h
246
24732-bit embedded kernels:
248
249 Currently, board support is essentially an exclusive config option.
250 The kernel is configured for a single platform. Part of the reason
251 for this is to keep kernels on embedded systems small and efficient;
252 part of this is due to the fact the code is already that way. In the
253 future, a kernel may support multiple platforms, but only if the
Domen Puncer5dd60162007-03-02 21:44:45 +1100254 platforms feature the same core architecture. A single kernel build
David Gibsonc125a182006-02-01 03:05:22 -0800255 cannot support both configurations with Book E and configurations
256 with classic Powerpc architectures.
257
258 32-bit embedded platforms that are moved into arch/powerpc using a
259 flattened device tree should adopt the merged tree practice of
260 setting ppc_md up dynamically, even though the kernel is currently
261 built with support for only a single platform at a time. This allows
262 unification of the setup code, and will make it easier to go to a
263 multiple-platform-support model in the future.
264
265NOTE: I believe the above will be true once Ben's done with the merge
266of the boot sequences.... someone speak up if this is wrong!
267
268 To add a 32-bit embedded platform support, follow the instructions
269 for 64-bit platforms above, with the exception that the Kconfig
270 option should be set up such that the kernel builds exclusively for
271 the platform selected. The processor type for the platform should
272 enable another config option to select the specific board
273 supported.
274
Domen Puncer5dd60162007-03-02 21:44:45 +1100275NOTE: If Ben doesn't merge the setup files, may need to change this to
David Gibsonc125a182006-02-01 03:05:22 -0800276point to setup_32.c
277
278
279 I will describe later the boot process and various callbacks that
280 your platform should implement.
281
282
283II - The DT block format
284========================
285
286
287This chapter defines the actual format of the flattened device-tree
288passed to the kernel. The actual content of it and kernel requirements
289are described later. You can find example of code manipulating that
290format in various places, including arch/powerpc/kernel/prom_init.c
291which will generate a flattened device-tree from the Open Firmware
292representation, or the fs2dt utility which is part of the kexec tools
293which will generate one from a filesystem representation. It is
294expected that a bootloader like uboot provides a bit more support,
295that will be discussed later as well.
296
297Note: The block has to be in main memory. It has to be accessible in
298both real mode and virtual mode with no mapping other than main
299memory. If you are writing a simple flash bootloader, it should copy
300the block to RAM before passing it to the kernel.
301
302
3031) Header
304---------
305
306 The kernel is entered with r3 pointing to an area of memory that is
Matt LaPlanted6bc8ac2006-10-03 22:54:15 +0200307 roughly described in include/asm-powerpc/prom.h by the structure
David Gibsonc125a182006-02-01 03:05:22 -0800308 boot_param_header:
309
310struct boot_param_header {
311 u32 magic; /* magic word OF_DT_HEADER */
312 u32 totalsize; /* total size of DT block */
313 u32 off_dt_struct; /* offset to structure */
314 u32 off_dt_strings; /* offset to strings */
315 u32 off_mem_rsvmap; /* offset to memory reserve map
Domen Puncer5dd60162007-03-02 21:44:45 +1100316 */
David Gibsonc125a182006-02-01 03:05:22 -0800317 u32 version; /* format version */
318 u32 last_comp_version; /* last compatible version */
319
320 /* version 2 fields below */
321 u32 boot_cpuid_phys; /* Which physical CPU id we're
322 booting on */
323 /* version 3 fields below */
324 u32 size_dt_strings; /* size of the strings block */
David Gibson0e0293c2007-03-14 11:50:40 +1100325
326 /* version 17 fields below */
327 u32 size_dt_struct; /* size of the DT structure block */
David Gibsonc125a182006-02-01 03:05:22 -0800328};
329
330 Along with the constants:
331
332/* Definitions used by the flattened device tree */
333#define OF_DT_HEADER 0xd00dfeed /* 4: version,
334 4: total size */
335#define OF_DT_BEGIN_NODE 0x1 /* Start node: full name
Domen Puncer5dd60162007-03-02 21:44:45 +1100336 */
David Gibsonc125a182006-02-01 03:05:22 -0800337#define OF_DT_END_NODE 0x2 /* End node */
338#define OF_DT_PROP 0x3 /* Property: name off,
339 size, content */
340#define OF_DT_END 0x9
341
342 All values in this header are in big endian format, the various
343 fields in this header are defined more precisely below. All
344 "offset" values are in bytes from the start of the header; that is
345 from the value of r3.
346
347 - magic
348
349 This is a magic value that "marks" the beginning of the
350 device-tree block header. It contains the value 0xd00dfeed and is
351 defined by the constant OF_DT_HEADER
352
353 - totalsize
354
355 This is the total size of the DT block including the header. The
356 "DT" block should enclose all data structures defined in this
357 chapter (who are pointed to by offsets in this header). That is,
358 the device-tree structure, strings, and the memory reserve map.
359
360 - off_dt_struct
361
362 This is an offset from the beginning of the header to the start
363 of the "structure" part the device tree. (see 2) device tree)
364
365 - off_dt_strings
366
367 This is an offset from the beginning of the header to the start
368 of the "strings" part of the device-tree
369
370 - off_mem_rsvmap
371
372 This is an offset from the beginning of the header to the start
Domen Puncer5dd60162007-03-02 21:44:45 +1100373 of the reserved memory map. This map is a list of pairs of 64-
David Gibsonc125a182006-02-01 03:05:22 -0800374 bit integers. Each pair is a physical address and a size. The
David Gibsonc125a182006-02-01 03:05:22 -0800375 list is terminated by an entry of size 0. This map provides the
376 kernel with a list of physical memory areas that are "reserved"
377 and thus not to be used for memory allocations, especially during
378 early initialization. The kernel needs to allocate memory during
379 boot for things like un-flattening the device-tree, allocating an
380 MMU hash table, etc... Those allocations must be done in such a
381 way to avoid overriding critical things like, on Open Firmware
382 capable machines, the RTAS instance, or on some pSeries, the TCE
383 tables used for the iommu. Typically, the reserve map should
384 contain _at least_ this DT block itself (header,total_size). If
385 you are passing an initrd to the kernel, you should reserve it as
386 well. You do not need to reserve the kernel image itself. The map
Domen Puncer5dd60162007-03-02 21:44:45 +1100387 should be 64-bit aligned.
David Gibsonc125a182006-02-01 03:05:22 -0800388
389 - version
390
391 This is the version of this structure. Version 1 stops
392 here. Version 2 adds an additional field boot_cpuid_phys.
393 Version 3 adds the size of the strings block, allowing the kernel
394 to reallocate it easily at boot and free up the unused flattened
395 structure after expansion. Version 16 introduces a new more
396 "compact" format for the tree itself that is however not backward
David Gibson0e0293c2007-03-14 11:50:40 +1100397 compatible. Version 17 adds an additional field, size_dt_struct,
398 allowing it to be reallocated or moved more easily (this is
399 particularly useful for bootloaders which need to make
400 adjustments to a device tree based on probed information). You
401 should always generate a structure of the highest version defined
402 at the time of your implementation. Currently that is version 17,
403 unless you explicitly aim at being backward compatible.
David Gibsonc125a182006-02-01 03:05:22 -0800404
405 - last_comp_version
406
407 Last compatible version. This indicates down to what version of
408 the DT block you are backward compatible. For example, version 2
409 is backward compatible with version 1 (that is, a kernel build
410 for version 1 will be able to boot with a version 2 format). You
411 should put a 1 in this field if you generate a device tree of
David Gibson0e0293c2007-03-14 11:50:40 +1100412 version 1 to 3, or 16 if you generate a tree of version 16 or 17
David Gibsonc125a182006-02-01 03:05:22 -0800413 using the new unit name format.
414
415 - boot_cpuid_phys
416
417 This field only exist on version 2 headers. It indicate which
418 physical CPU ID is calling the kernel entry point. This is used,
419 among others, by kexec. If you are on an SMP system, this value
420 should match the content of the "reg" property of the CPU node in
421 the device-tree corresponding to the CPU calling the kernel entry
422 point (see further chapters for more informations on the required
423 device-tree contents)
424
David Gibson0e0293c2007-03-14 11:50:40 +1100425 - size_dt_strings
426
427 This field only exists on version 3 and later headers. It
428 gives the size of the "strings" section of the device tree (which
429 starts at the offset given by off_dt_strings).
430
431 - size_dt_struct
432
433 This field only exists on version 17 and later headers. It gives
434 the size of the "structure" section of the device tree (which
435 starts at the offset given by off_dt_struct).
David Gibsonc125a182006-02-01 03:05:22 -0800436
437 So the typical layout of a DT block (though the various parts don't
438 need to be in that order) looks like this (addresses go from top to
439 bottom):
440
441
442 ------------------------------
443 r3 -> | struct boot_param_header |
444 ------------------------------
445 | (alignment gap) (*) |
446 ------------------------------
447 | memory reserve map |
448 ------------------------------
449 | (alignment gap) |
450 ------------------------------
451 | |
452 | device-tree structure |
453 | |
454 ------------------------------
455 | (alignment gap) |
456 ------------------------------
457 | |
458 | device-tree strings |
459 | |
460 -----> ------------------------------
461 |
462 |
463 --- (r3 + totalsize)
464
465 (*) The alignment gaps are not necessarily present; their presence
466 and size are dependent on the various alignment requirements of
467 the individual data blocks.
468
469
4702) Device tree generalities
471---------------------------
472
473This device-tree itself is separated in two different blocks, a
474structure block and a strings block. Both need to be aligned to a 4
475byte boundary.
476
477First, let's quickly describe the device-tree concept before detailing
478the storage format. This chapter does _not_ describe the detail of the
479required types of nodes & properties for the kernel, this is done
480later in chapter III.
481
482The device-tree layout is strongly inherited from the definition of
483the Open Firmware IEEE 1275 device-tree. It's basically a tree of
484nodes, each node having two or more named properties. A property can
485have a value or not.
486
487It is a tree, so each node has one and only one parent except for the
488root node who has no parent.
489
490A node has 2 names. The actual node name is generally contained in a
491property of type "name" in the node property list whose value is a
492zero terminated string and is mandatory for version 1 to 3 of the
David Gibson0e0293c2007-03-14 11:50:40 +1100493format definition (as it is in Open Firmware). Version 16 makes it
David Gibsonc125a182006-02-01 03:05:22 -0800494optional as it can generate it from the unit name defined below.
495
Matt LaPlante2fe0ae72006-10-03 22:50:39 +0200496There is also a "unit name" that is used to differentiate nodes with
David Gibsonc125a182006-02-01 03:05:22 -0800497the same name at the same level, it is usually made of the node
Matt LaPlante2fe0ae72006-10-03 22:50:39 +0200498names, the "@" sign, and a "unit address", which definition is
David Gibsonc125a182006-02-01 03:05:22 -0800499specific to the bus type the node sits on.
500
501The unit name doesn't exist as a property per-se but is included in
502the device-tree structure. It is typically used to represent "path" in
503the device-tree. More details about the actual format of these will be
504below.
505
506The kernel powerpc generic code does not make any formal use of the
507unit address (though some board support code may do) so the only real
508requirement here for the unit address is to ensure uniqueness of
509the node unit name at a given level of the tree. Nodes with no notion
510of address and no possible sibling of the same name (like /memory or
511/cpus) may omit the unit address in the context of this specification,
512or use the "@0" default unit address. The unit name is used to define
513a node "full path", which is the concatenation of all parent node
514unit names separated with "/".
515
516The root node doesn't have a defined name, and isn't required to have
517a name property either if you are using version 3 or earlier of the
518format. It also has no unit address (no @ symbol followed by a unit
519address). The root node unit name is thus an empty string. The full
520path to the root node is "/".
521
522Every node which actually represents an actual device (that is, a node
523which isn't only a virtual "container" for more nodes, like "/cpus"
524is) is also required to have a "device_type" property indicating the
525type of node .
526
527Finally, every node that can be referenced from a property in another
528node is required to have a "linux,phandle" property. Real open
529firmware implementations provide a unique "phandle" value for every
530node that the "prom_init()" trampoline code turns into
531"linux,phandle" properties. However, this is made optional if the
532flattened device tree is used directly. An example of a node
533referencing another node via "phandle" is when laying out the
534interrupt tree which will be described in a further version of this
535document.
536
Domen Puncer5dd60162007-03-02 21:44:45 +1100537This "linux, phandle" property is a 32-bit value that uniquely
David Gibsonc125a182006-02-01 03:05:22 -0800538identifies a node. You are free to use whatever values or system of
539values, internal pointers, or whatever to generate these, the only
540requirement is that every node for which you provide that property has
541a unique value for it.
542
543Here is an example of a simple device-tree. In this example, an "o"
544designates a node followed by the node unit name. Properties are
545presented with their name followed by their content. "content"
546represents an ASCII string (zero terminated) value, while <content>
Domen Puncer5dd60162007-03-02 21:44:45 +1100547represents a 32-bit hexadecimal value. The various nodes in this
David Gibsonc125a182006-02-01 03:05:22 -0800548example will be discussed in a later chapter. At this point, it is
549only meant to give you a idea of what a device-tree looks like. I have
550purposefully kept the "name" and "linux,phandle" properties which
551aren't necessary in order to give you a better idea of what the tree
552looks like in practice.
553
554 / o device-tree
555 |- name = "device-tree"
556 |- model = "MyBoardName"
557 |- compatible = "MyBoardFamilyName"
558 |- #address-cells = <2>
559 |- #size-cells = <2>
560 |- linux,phandle = <0>
561 |
562 o cpus
563 | | - name = "cpus"
564 | | - linux,phandle = <1>
565 | | - #address-cells = <1>
566 | | - #size-cells = <0>
567 | |
568 | o PowerPC,970@0
569 | |- name = "PowerPC,970"
570 | |- device_type = "cpu"
571 | |- reg = <0>
572 | |- clock-frequency = <5f5e1000>
Timur Tabi32aed2a2007-02-14 15:29:07 -0600573 | |- 64-bit
David Gibsonc125a182006-02-01 03:05:22 -0800574 | |- linux,phandle = <2>
575 |
576 o memory@0
577 | |- name = "memory"
578 | |- device_type = "memory"
579 | |- reg = <00000000 00000000 00000000 20000000>
580 | |- linux,phandle = <3>
581 |
582 o chosen
583 |- name = "chosen"
584 |- bootargs = "root=/dev/sda2"
David Gibsonc125a182006-02-01 03:05:22 -0800585 |- linux,phandle = <4>
586
587This tree is almost a minimal tree. It pretty much contains the
588minimal set of required nodes and properties to boot a linux kernel;
589that is, some basic model informations at the root, the CPUs, and the
590physical memory layout. It also includes misc information passed
591through /chosen, like in this example, the platform type (mandatory)
592and the kernel command line arguments (optional).
593
Timur Tabi32aed2a2007-02-14 15:29:07 -0600594The /cpus/PowerPC,970@0/64-bit property is an example of a
David Gibsonc125a182006-02-01 03:05:22 -0800595property without a value. All other properties have a value. The
596significance of the #address-cells and #size-cells properties will be
597explained in chapter IV which defines precisely the required nodes and
598properties and their content.
599
600
6013) Device tree "structure" block
602
603The structure of the device tree is a linearized tree structure. The
604"OF_DT_BEGIN_NODE" token starts a new node, and the "OF_DT_END_NODE"
605ends that node definition. Child nodes are simply defined before
606"OF_DT_END_NODE" (that is nodes within the node). A 'token' is a 32
607bit value. The tree has to be "finished" with a OF_DT_END token
608
609Here's the basic structure of a single node:
610
611 * token OF_DT_BEGIN_NODE (that is 0x00000001)
612 * for version 1 to 3, this is the node full path as a zero
613 terminated string, starting with "/". For version 16 and later,
614 this is the node unit name only (or an empty string for the
615 root node)
616 * [align gap to next 4 bytes boundary]
617 * for each property:
618 * token OF_DT_PROP (that is 0x00000003)
Domen Puncer5dd60162007-03-02 21:44:45 +1100619 * 32-bit value of property value size in bytes (or 0 if no
620 value)
621 * 32-bit value of offset in string block of property name
David Gibsonc125a182006-02-01 03:05:22 -0800622 * property value data if any
623 * [align gap to next 4 bytes boundary]
624 * [child nodes if any]
625 * token OF_DT_END_NODE (that is 0x00000002)
626
Domen Puncer5dd60162007-03-02 21:44:45 +1100627So the node content can be summarized as a start token, a full path,
Matt LaPlante53cb4722006-10-03 22:55:17 +0200628a list of properties, a list of child nodes, and an end token. Every
David Gibsonc125a182006-02-01 03:05:22 -0800629child node is a full node structure itself as defined above.
630
David Gibsoneff2ebd2007-06-28 15:56:26 +1000631NOTE: The above definition requires that all property definitions for
632a particular node MUST precede any subnode definitions for that node.
633Although the structure would not be ambiguous if properties and
634subnodes were intermingled, the kernel parser requires that the
635properties come first (up until at least 2.6.22). Any tools
636manipulating a flattened tree must take care to preserve this
637constraint.
638
Matt LaPlante53cb4722006-10-03 22:55:17 +02006394) Device tree "strings" block
David Gibsonc125a182006-02-01 03:05:22 -0800640
641In order to save space, property names, which are generally redundant,
642are stored separately in the "strings" block. This block is simply the
643whole bunch of zero terminated strings for all property names
644concatenated together. The device-tree property definitions in the
645structure block will contain offset values from the beginning of the
646strings block.
647
648
649III - Required content of the device tree
650=========================================
651
652WARNING: All "linux,*" properties defined in this document apply only
653to a flattened device-tree. If your platform uses a real
654implementation of Open Firmware or an implementation compatible with
655the Open Firmware client interface, those properties will be created
656by the trampoline code in the kernel's prom_init() file. For example,
657that's where you'll have to add code to detect your board model and
Matt LaPlantea2ffd272006-10-03 22:49:15 +0200658set the platform number. However, when using the flattened device-tree
David Gibsonc125a182006-02-01 03:05:22 -0800659entry point, there is no prom_init() pass, and thus you have to
660provide those properties yourself.
661
662
6631) Note about cells and address representation
664----------------------------------------------
665
666The general rule is documented in the various Open Firmware
Domen Puncer5dd60162007-03-02 21:44:45 +1100667documentations. If you choose to describe a bus with the device-tree
David Gibsonc125a182006-02-01 03:05:22 -0800668and there exist an OF bus binding, then you should follow the
669specification. However, the kernel does not require every single
670device or bus to be described by the device tree.
671
672In general, the format of an address for a device is defined by the
673parent bus type, based on the #address-cells and #size-cells
Mark A. Greer5b14e5f2008-01-04 02:40:47 +1100674properties. Note that the parent's parent definitions of #address-cells
675and #size-cells are not inhereted so every node with children must specify
676them. The kernel requires the root node to have those properties defining
677addresses format for devices directly mapped on the processor bus.
David Gibsonc125a182006-02-01 03:05:22 -0800678
679Those 2 properties define 'cells' for representing an address and a
Domen Puncer5dd60162007-03-02 21:44:45 +1100680size. A "cell" is a 32-bit number. For example, if both contain 2
David Gibsonc125a182006-02-01 03:05:22 -0800681like the example tree given above, then an address and a size are both
Domen Puncer5dd60162007-03-02 21:44:45 +1100682composed of 2 cells, and each is a 64-bit number (cells are
David Gibsonc125a182006-02-01 03:05:22 -0800683concatenated and expected to be in big endian format). Another example
684is the way Apple firmware defines them, with 2 cells for an address
685and one cell for a size. Most 32-bit implementations should define
686#address-cells and #size-cells to 1, which represents a 32-bit value.
687Some 32-bit processors allow for physical addresses greater than 32
688bits; these processors should define #address-cells as 2.
689
690"reg" properties are always a tuple of the type "address size" where
691the number of cells of address and size is specified by the bus
692#address-cells and #size-cells. When a bus supports various address
693spaces and other flags relative to a given address allocation (like
694prefetchable, etc...) those flags are usually added to the top level
695bits of the physical address. For example, a PCI physical address is
696made of 3 cells, the bottom two containing the actual address itself
697while the top cell contains address space indication, flags, and pci
698bus & device numbers.
699
700For busses that support dynamic allocation, it's the accepted practice
701to then not provide the address in "reg" (keep it 0) though while
702providing a flag indicating the address is dynamically allocated, and
703then, to provide a separate "assigned-addresses" property that
704contains the fully allocated addresses. See the PCI OF bindings for
705details.
706
707In general, a simple bus with no address space bits and no dynamic
708allocation is preferred if it reflects your hardware, as the existing
709kernel address parsing functions will work out of the box. If you
710define a bus type with a more complex address format, including things
711like address space bits, you'll have to add a bus translator to the
712prom_parse.c file of the recent kernels for your bus type.
713
Stephen Neuendorffere1fd1862007-12-04 12:08:57 +1100714The "reg" property only defines addresses and sizes (if #size-cells is
715non-0) within a given bus. In order to translate addresses upward
Domen Puncer5dd60162007-03-02 21:44:45 +1100716(that is into parent bus addresses, and possibly into CPU physical
David Gibsonc125a182006-02-01 03:05:22 -0800717addresses), all busses must contain a "ranges" property. If the
718"ranges" property is missing at a given level, it's assumed that
Stephen Neuendorffere1fd1862007-12-04 12:08:57 +1100719translation isn't possible, i.e., the registers are not visible on the
720parent bus. The format of the "ranges" property for a bus is a list
721of:
David Gibsonc125a182006-02-01 03:05:22 -0800722
723 bus address, parent bus address, size
724
725"bus address" is in the format of the bus this bus node is defining,
726that is, for a PCI bridge, it would be a PCI address. Thus, (bus
727address, size) defines a range of addresses for child devices. "parent
728bus address" is in the format of the parent bus of this bus. For
729example, for a PCI host controller, that would be a CPU address. For a
730PCI<->ISA bridge, that would be a PCI address. It defines the base
731address in the parent bus where the beginning of that range is mapped.
732
Domen Puncer5dd60162007-03-02 21:44:45 +1100733For a new 64-bit powerpc board, I recommend either the 2/2 format or
David Gibsonc125a182006-02-01 03:05:22 -0800734Apple's 2/1 format which is slightly more compact since sizes usually
Domen Puncer5dd60162007-03-02 21:44:45 +1100735fit in a single 32-bit word. New 32-bit powerpc boards should use a
David Gibsonc125a182006-02-01 03:05:22 -08007361/1 format, unless the processor supports physical addresses greater
737than 32-bits, in which case a 2/1 format is recommended.
738
Stephen Neuendorffere1fd1862007-12-04 12:08:57 +1100739Alternatively, the "ranges" property may be empty, indicating that the
740registers are visible on the parent bus using an identity mapping
741translation. In other words, the parent bus address space is the same
742as the child bus address space.
David Gibsonc125a182006-02-01 03:05:22 -0800743
7442) Note about "compatible" properties
745-------------------------------------
746
747These properties are optional, but recommended in devices and the root
748node. The format of a "compatible" property is a list of concatenated
749zero terminated strings. They allow a device to express its
750compatibility with a family of similar devices, in some cases,
751allowing a single driver to match against several devices regardless
752of their actual names.
753
7543) Note about "name" properties
755-------------------------------
756
757While earlier users of Open Firmware like OldWorld macintoshes tended
758to use the actual device name for the "name" property, it's nowadays
759considered a good practice to use a name that is closer to the device
760class (often equal to device_type). For example, nowadays, ethernet
761controllers are named "ethernet", an additional "model" property
762defining precisely the chip type/model, and "compatible" property
763defining the family in case a single driver can driver more than one
764of these chips. However, the kernel doesn't generally put any
765restriction on the "name" property; it is simply considered good
766practice to follow the standard and its evolutions as closely as
767possible.
768
769Note also that the new format version 16 makes the "name" property
770optional. If it's absent for a node, then the node's unit name is then
771used to reconstruct the name. That is, the part of the unit name
772before the "@" sign is used (or the entire unit name if no "@" sign
773is present).
774
7754) Note about node and property names and character set
776-------------------------------------------------------
777
Matt LaPlantea2ffd272006-10-03 22:49:15 +0200778While open firmware provides more flexible usage of 8859-1, this
David Gibsonc125a182006-02-01 03:05:22 -0800779specification enforces more strict rules. Nodes and properties should
780be comprised only of ASCII characters 'a' to 'z', '0' to
781'9', ',', '.', '_', '+', '#', '?', and '-'. Node names additionally
782allow uppercase characters 'A' to 'Z' (property names should be
783lowercase. The fact that vendors like Apple don't respect this rule is
784irrelevant here). Additionally, node and property names should always
785begin with a character in the range 'a' to 'z' (or 'A' to 'Z' for node
786names).
787
788The maximum number of characters for both nodes and property names
789is 31. In the case of node names, this is only the leftmost part of
790a unit name (the pure "name" property), it doesn't include the unit
791address which can extend beyond that limit.
792
793
7945) Required nodes and properties
795--------------------------------
796 These are all that are currently required. However, it is strongly
797 recommended that you expose PCI host bridges as documented in the
798 PCI binding to open firmware, and your interrupt tree as documented
799 in OF interrupt tree specification.
800
801 a) The root node
802
803 The root node requires some properties to be present:
804
805 - model : this is your board name/model
806 - #address-cells : address representation for "root" devices
807 - #size-cells: the size representation for "root" devices
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100808 - device_type : This property shouldn't be necessary. However, if
809 you decide to create a device_type for your root node, make sure it
810 is _not_ "chrp" unless your platform is a pSeries or PAPR compliant
811 one for 64-bit, or a CHRP-type machine for 32-bit as this will
812 matched by the kernel this way.
David Gibsonc125a182006-02-01 03:05:22 -0800813
814 Additionally, some recommended properties are:
815
816 - compatible : the board "family" generally finds its way here,
817 for example, if you have 2 board models with a similar layout,
818 that typically get driven by the same platform code in the
819 kernel, you would use a different "model" property but put a
820 value in "compatible". The kernel doesn't directly use that
Stuart Yoder143a42d2007-02-16 11:30:29 -0600821 value but it is generally useful.
David Gibsonc125a182006-02-01 03:05:22 -0800822
823 The root node is also generally where you add additional properties
824 specific to your board like the serial number if any, that sort of
Matt LaPlante6c28f2c2006-10-03 22:46:31 +0200825 thing. It is recommended that if you add any "custom" property whose
David Gibsonc125a182006-02-01 03:05:22 -0800826 name may clash with standard defined ones, you prefix them with your
827 vendor name and a comma.
828
829 b) The /cpus node
830
831 This node is the parent of all individual CPU nodes. It doesn't
832 have any specific requirements, though it's generally good practice
833 to have at least:
834
835 #address-cells = <00000001>
836 #size-cells = <00000000>
837
838 This defines that the "address" for a CPU is a single cell, and has
839 no meaningful size. This is not necessary but the kernel will assume
840 that format when reading the "reg" properties of a CPU node, see
841 below
842
843 c) The /cpus/* nodes
844
845 So under /cpus, you are supposed to create a node for every CPU on
846 the machine. There is no specific restriction on the name of the
847 CPU, though It's common practice to call it PowerPC,<name>. For
848 example, Apple uses PowerPC,G5 while IBM uses PowerPC,970FX.
849
850 Required properties:
851
852 - device_type : has to be "cpu"
Domen Puncer5dd60162007-03-02 21:44:45 +1100853 - reg : This is the physical CPU number, it's a single 32-bit cell
David Gibsonc125a182006-02-01 03:05:22 -0800854 and is also used as-is as the unit number for constructing the
855 unit name in the full path. For example, with 2 CPUs, you would
856 have the full path:
857 /cpus/PowerPC,970FX@0
858 /cpus/PowerPC,970FX@1
859 (unit addresses do not require leading zeroes)
Benjamin Herrenschmidt20474ab2007-10-28 08:49:28 +1100860 - d-cache-block-size : one cell, L1 data cache block size in bytes (*)
861 - i-cache-block-size : one cell, L1 instruction cache block size in
David Gibsonc125a182006-02-01 03:05:22 -0800862 bytes
863 - d-cache-size : one cell, size of L1 data cache in bytes
864 - i-cache-size : one cell, size of L1 instruction cache in bytes
David Gibsonc125a182006-02-01 03:05:22 -0800865
Benjamin Herrenschmidt20474ab2007-10-28 08:49:28 +1100866(*) The cache "block" size is the size on which the cache management
867instructions operate. Historically, this document used the cache
868"line" size here which is incorrect. The kernel will prefer the cache
869block size and will fallback to cache line size for backward
870compatibility.
871
David Gibsonc125a182006-02-01 03:05:22 -0800872 Recommended properties:
873
874 - timebase-frequency : a cell indicating the frequency of the
875 timebase in Hz. This is not directly used by the generic code,
876 but you are welcome to copy/paste the pSeries code for setting
877 the kernel timebase/decrementer calibration based on this
878 value.
879 - clock-frequency : a cell indicating the CPU core clock frequency
Domen Puncer5dd60162007-03-02 21:44:45 +1100880 in Hz. A new property will be defined for 64-bit values, but if
David Gibsonc125a182006-02-01 03:05:22 -0800881 your frequency is < 4Ghz, one cell is enough. Here as well as
882 for the above, the common code doesn't use that property, but
883 you are welcome to re-use the pSeries or Maple one. A future
884 kernel version might provide a common function for this.
Benjamin Herrenschmidt20474ab2007-10-28 08:49:28 +1100885 - d-cache-line-size : one cell, L1 data cache line size in bytes
886 if different from the block size
887 - i-cache-line-size : one cell, L1 instruction cache line size in
888 bytes if different from the block size
David Gibsonc125a182006-02-01 03:05:22 -0800889
890 You are welcome to add any property you find relevant to your board,
891 like some information about the mechanism used to soft-reset the
892 CPUs. For example, Apple puts the GPIO number for CPU soft reset
893 lines in there as a "soft-reset" property since they start secondary
894 CPUs by soft-resetting them.
895
896
897 d) the /memory node(s)
898
899 To define the physical memory layout of your board, you should
900 create one or more memory node(s). You can either create a single
901 node with all memory ranges in its reg property, or you can create
902 several nodes, as you wish. The unit address (@ part) used for the
903 full path is the address of the first range of memory defined by a
904 given node. If you use a single memory node, this will typically be
905 @0.
906
907 Required properties:
908
909 - device_type : has to be "memory"
910 - reg : This property contains all the physical memory ranges of
911 your board. It's a list of addresses/sizes concatenated
912 together, with the number of cells of each defined by the
913 #address-cells and #size-cells of the root node. For example,
Matt LaPlante6c28f2c2006-10-03 22:46:31 +0200914 with both of these properties being 2 like in the example given
David Gibsonc125a182006-02-01 03:05:22 -0800915 earlier, a 970 based machine with 6Gb of RAM could typically
916 have a "reg" property here that looks like:
917
918 00000000 00000000 00000000 80000000
919 00000001 00000000 00000001 00000000
920
921 That is a range starting at 0 of 0x80000000 bytes and a range
922 starting at 0x100000000 and of 0x100000000 bytes. You can see
923 that there is no memory covering the IO hole between 2Gb and
924 4Gb. Some vendors prefer splitting those ranges into smaller
925 segments, but the kernel doesn't care.
926
927 e) The /chosen node
928
929 This node is a bit "special". Normally, that's where open firmware
930 puts some variable environment information, like the arguments, or
Stuart Yoderd1bff9e2007-02-19 11:25:05 -0600931 the default input/output devices.
David Gibsonc125a182006-02-01 03:05:22 -0800932
933 This specification makes a few of these mandatory, but also defines
934 some linux-specific properties that would be normally constructed by
935 the prom_init() trampoline when booting with an OF client interface,
936 but that you have to provide yourself when using the flattened format.
937
David Gibsonc125a182006-02-01 03:05:22 -0800938 Recommended properties:
939
940 - bootargs : This zero-terminated string is passed as the kernel
941 command line
942 - linux,stdout-path : This is the full path to your standard
943 console device if any. Typically, if you have serial devices on
944 your board, you may want to put the full path to the one set as
945 the default console in the firmware here, for the kernel to pick
Matt LaPlante5d3f0832006-11-30 05:21:10 +0100946 it up as its own default console. If you look at the function
David Gibsonc125a182006-02-01 03:05:22 -0800947 set_preferred_console() in arch/ppc64/kernel/setup.c, you'll see
948 that the kernel tries to find out the default console and has
949 knowledge of various types like 8250 serial ports. You may want
950 to extend this function to add your own.
David Gibsonc125a182006-02-01 03:05:22 -0800951
952 Note that u-boot creates and fills in the chosen node for platforms
953 that use it.
954
Stuart Yoderd1bff9e2007-02-19 11:25:05 -0600955 (Note: a practice that is now obsolete was to include a property
956 under /chosen called interrupt-controller which had a phandle value
957 that pointed to the main interrupt controller)
958
David Gibsonc125a182006-02-01 03:05:22 -0800959 f) the /soc<SOCname> node
960
961 This node is used to represent a system-on-a-chip (SOC) and must be
962 present if the processor is a SOC. The top-level soc node contains
963 information that is global to all devices on the SOC. The node name
964 should contain a unit address for the SOC, which is the base address
965 of the memory-mapped register set for the SOC. The name of an soc
966 node should start with "soc", and the remainder of the name should
967 represent the part number for the soc. For example, the MPC8540's
968 soc node would be called "soc8540".
969
970 Required properties:
971
972 - device_type : Should be "soc"
973 - ranges : Should be defined as specified in 1) to describe the
974 translation of SOC addresses for memory mapped SOC registers.
Becky Bruce7d4b95a2006-02-06 14:26:31 -0600975 - bus-frequency: Contains the bus frequency for the SOC node.
976 Typically, the value of this field is filled in by the boot
977 loader.
978
David Gibsonc125a182006-02-01 03:05:22 -0800979
980 Recommended properties:
981
982 - reg : This property defines the address and size of the
983 memory-mapped registers that are used for the SOC node itself.
984 It does not include the child device registers - these will be
985 defined inside each child node. The address specified in the
986 "reg" property should match the unit address of the SOC node.
987 - #address-cells : Address representation for "soc" devices. The
988 format of this field may vary depending on whether or not the
989 device registers are memory mapped. For memory mapped
990 registers, this field represents the number of cells needed to
991 represent the address of the registers. For SOCs that do not
992 use MMIO, a special address format should be defined that
993 contains enough cells to represent the required information.
994 See 1) above for more details on defining #address-cells.
995 - #size-cells : Size representation for "soc" devices
996 - #interrupt-cells : Defines the width of cells used to represent
997 interrupts. Typically this value is <2>, which includes a
998 32-bit number that represents the interrupt number, and a
999 32-bit number that represents the interrupt sense and level.
1000 This field is only needed if the SOC contains an interrupt
1001 controller.
1002
1003 The SOC node may contain child nodes for each SOC device that the
1004 platform uses. Nodes should not be created for devices which exist
1005 on the SOC but are not used by a particular platform. See chapter VI
Domen Puncer5dd60162007-03-02 21:44:45 +11001006 for more information on how to specify devices that are part of a SOC.
David Gibsonc125a182006-02-01 03:05:22 -08001007
1008 Example SOC node for the MPC8540:
1009
1010 soc8540@e0000000 {
1011 #address-cells = <1>;
1012 #size-cells = <1>;
1013 #interrupt-cells = <2>;
1014 device_type = "soc";
1015 ranges = <00000000 e0000000 00100000>
1016 reg = <e0000000 00003000>;
Becky Bruce7d4b95a2006-02-06 14:26:31 -06001017 bus-frequency = <0>;
David Gibsonc125a182006-02-01 03:05:22 -08001018 }
1019
1020
1021
1022IV - "dtc", the device tree compiler
1023====================================
1024
1025
1026dtc source code can be found at
1027<http://ozlabs.org/~dgibson/dtc/dtc.tar.gz>
1028
1029WARNING: This version is still in early development stage; the
1030resulting device-tree "blobs" have not yet been validated with the
1031kernel. The current generated bloc lacks a useful reserve map (it will
1032be fixed to generate an empty one, it's up to the bootloader to fill
1033it up) among others. The error handling needs work, bugs are lurking,
1034etc...
1035
1036dtc basically takes a device-tree in a given format and outputs a
1037device-tree in another format. The currently supported formats are:
1038
1039 Input formats:
1040 -------------
1041
1042 - "dtb": "blob" format, that is a flattened device-tree block
1043 with
1044 header all in a binary blob.
1045 - "dts": "source" format. This is a text file containing a
1046 "source" for a device-tree. The format is defined later in this
1047 chapter.
1048 - "fs" format. This is a representation equivalent to the
1049 output of /proc/device-tree, that is nodes are directories and
1050 properties are files
1051
1052 Output formats:
1053 ---------------
1054
1055 - "dtb": "blob" format
1056 - "dts": "source" format
1057 - "asm": assembly language file. This is a file that can be
1058 sourced by gas to generate a device-tree "blob". That file can
1059 then simply be added to your Makefile. Additionally, the
Matt LaPlante6c28f2c2006-10-03 22:46:31 +02001060 assembly file exports some symbols that can be used.
David Gibsonc125a182006-02-01 03:05:22 -08001061
1062
1063The syntax of the dtc tool is
1064
1065 dtc [-I <input-format>] [-O <output-format>]
1066 [-o output-filename] [-V output_version] input_filename
1067
1068
Domen Puncer5dd60162007-03-02 21:44:45 +11001069The "output_version" defines what version of the "blob" format will be
David Gibsonc125a182006-02-01 03:05:22 -08001070generated. Supported versions are 1,2,3 and 16. The default is
1071currently version 3 but that may change in the future to version 16.
1072
1073Additionally, dtc performs various sanity checks on the tree, like the
Matt LaPlante6c28f2c2006-10-03 22:46:31 +02001074uniqueness of linux, phandle properties, validity of strings, etc...
David Gibsonc125a182006-02-01 03:05:22 -08001075
1076The format of the .dts "source" file is "C" like, supports C and C++
Matt LaPlante6c28f2c2006-10-03 22:46:31 +02001077style comments.
David Gibsonc125a182006-02-01 03:05:22 -08001078
1079/ {
1080}
1081
1082The above is the "device-tree" definition. It's the only statement
1083supported currently at the toplevel.
1084
1085/ {
1086 property1 = "string_value"; /* define a property containing a 0
1087 * terminated string
1088 */
1089
1090 property2 = <1234abcd>; /* define a property containing a
Domen Puncer5dd60162007-03-02 21:44:45 +11001091 * numerical 32-bit value (hexadecimal)
David Gibsonc125a182006-02-01 03:05:22 -08001092 */
1093
1094 property3 = <12345678 12345678 deadbeef>;
1095 /* define a property containing 3
Domen Puncer5dd60162007-03-02 21:44:45 +11001096 * numerical 32-bit values (cells) in
David Gibsonc125a182006-02-01 03:05:22 -08001097 * hexadecimal
1098 */
1099 property4 = [0a 0b 0c 0d de ea ad be ef];
1100 /* define a property whose content is
1101 * an arbitrary array of bytes
1102 */
1103
1104 childnode@addresss { /* define a child node named "childnode"
1105 * whose unit name is "childnode at
1106 * address"
1107 */
1108
1109 childprop = "hello\n"; /* define a property "childprop" of
1110 * childnode (in this case, a string)
1111 */
1112 };
1113};
1114
1115Nodes can contain other nodes etc... thus defining the hierarchical
1116structure of the tree.
1117
1118Strings support common escape sequences from C: "\n", "\t", "\r",
1119"\(octal value)", "\x(hex value)".
1120
1121It is also suggested that you pipe your source file through cpp (gcc
1122preprocessor) so you can use #include's, #define for constants, etc...
1123
1124Finally, various options are planned but not yet implemented, like
1125automatic generation of phandles, labels (exported to the asm file so
1126you can point to a property content and change it easily from whatever
1127you link the device-tree with), label or path instead of numeric value
1128in some cells to "point" to a node (replaced by a phandle at compile
1129time), export of reserve map address to the asm file, ability to
1130specify reserve map content at compile time, etc...
1131
1132We may provide a .h include file with common definitions of that
1133proves useful for some properties (like building PCI properties or
1134interrupt maps) though it may be better to add a notion of struct
1135definitions to the compiler...
1136
1137
1138V - Recommendations for a bootloader
1139====================================
1140
1141
1142Here are some various ideas/recommendations that have been proposed
1143while all this has been defined and implemented.
1144
1145 - The bootloader may want to be able to use the device-tree itself
1146 and may want to manipulate it (to add/edit some properties,
1147 like physical memory size or kernel arguments). At this point, 2
1148 choices can be made. Either the bootloader works directly on the
1149 flattened format, or the bootloader has its own internal tree
1150 representation with pointers (similar to the kernel one) and
1151 re-flattens the tree when booting the kernel. The former is a bit
1152 more difficult to edit/modify, the later requires probably a bit
1153 more code to handle the tree structure. Note that the structure
1154 format has been designed so it's relatively easy to "insert"
1155 properties or nodes or delete them by just memmoving things
1156 around. It contains no internal offsets or pointers for this
1157 purpose.
1158
Matt LaPlanted6bc8ac2006-10-03 22:54:15 +02001159 - An example of code for iterating nodes & retrieving properties
David Gibsonc125a182006-02-01 03:05:22 -08001160 directly from the flattened tree format can be found in the kernel
1161 file arch/ppc64/kernel/prom.c, look at scan_flat_dt() function,
Matt LaPlanted6bc8ac2006-10-03 22:54:15 +02001162 its usage in early_init_devtree(), and the corresponding various
David Gibsonc125a182006-02-01 03:05:22 -08001163 early_init_dt_scan_*() callbacks. That code can be re-used in a
1164 GPL bootloader, and as the author of that code, I would be happy
Domen Puncer5dd60162007-03-02 21:44:45 +11001165 to discuss possible free licensing to any vendor who wishes to
David Gibsonc125a182006-02-01 03:05:22 -08001166 integrate all or part of this code into a non-GPL bootloader.
1167
1168
1169
1170VI - System-on-a-chip devices and nodes
1171=======================================
1172
1173Many companies are now starting to develop system-on-a-chip
Domen Puncer5dd60162007-03-02 21:44:45 +11001174processors, where the processor core (CPU) and many peripheral devices
David Gibsonc125a182006-02-01 03:05:22 -08001175exist on a single piece of silicon. For these SOCs, an SOC node
1176should be used that defines child nodes for the devices that make
1177up the SOC. While platforms are not required to use this model in
1178order to boot the kernel, it is highly encouraged that all SOC
1179implementations define as complete a flat-device-tree as possible to
1180describe the devices on the SOC. This will allow for the
1181genericization of much of the kernel code.
1182
1183
11841) Defining child nodes of an SOC
1185---------------------------------
1186
1187Each device that is part of an SOC may have its own node entry inside
1188the SOC node. For each device that is included in the SOC, the unit
1189address property represents the address offset for this device's
1190memory-mapped registers in the parent's address space. The parent's
1191address space is defined by the "ranges" property in the top-level soc
1192node. The "reg" property for each node that exists directly under the
1193SOC node should contain the address mapping from the child address space
1194to the parent SOC address space and the size of the device's
1195memory-mapped register file.
1196
1197For many devices that may exist inside an SOC, there are predefined
1198specifications for the format of the device tree node. All SOC child
1199nodes should follow these specifications, except where noted in this
1200document.
1201
1202See appendix A for an example partial SOC node definition for the
1203MPC8540.
1204
1205
Stuart Yoder27565902007-03-02 13:42:33 -060012062) Representing devices without a current OF specification
David Gibsonc125a182006-02-01 03:05:22 -08001207----------------------------------------------------------
1208
1209Currently, there are many devices on SOCs that do not have a standard
1210representation pre-defined as part of the open firmware
1211specifications, mainly because the boards that contain these SOCs are
1212not currently booted using open firmware. This section contains
1213descriptions for the SOC devices for which new nodes have been
1214defined; this list will expand as more and more SOC-containing
1215platforms are moved over to use the flattened-device-tree model.
1216
1217 a) MDIO IO device
1218
1219 The MDIO is a bus to which the PHY devices are connected. For each
1220 device that exists on this bus, a child node should be created. See
1221 the definition of the PHY node below for an example of how to define
1222 a PHY.
1223
1224 Required properties:
1225 - reg : Offset and length of the register set for the device
David Gibsonc125a182006-02-01 03:05:22 -08001226 - compatible : Should define the compatible device type for the
Kumar Galae77b28e2007-12-12 00:28:35 -06001227 mdio. Currently, this is most likely to be "fsl,gianfar-mdio"
David Gibsonc125a182006-02-01 03:05:22 -08001228
1229 Example:
1230
1231 mdio@24520 {
1232 reg = <24520 20>;
Kumar Galae77b28e2007-12-12 00:28:35 -06001233 compatible = "fsl,gianfar-mdio";
David Gibsonc125a182006-02-01 03:05:22 -08001234
1235 ethernet-phy@0 {
1236 ......
1237 };
1238 };
1239
1240
1241 b) Gianfar-compatible ethernet nodes
1242
1243 Required properties:
1244
1245 - device_type : Should be "network"
1246 - model : Model of the device. Can be "TSEC", "eTSEC", or "FEC"
1247 - compatible : Should be "gianfar"
1248 - reg : Offset and length of the register set for the device
Jon Loeligerf5831652006-08-17 08:42:35 -05001249 - mac-address : List of bytes representing the ethernet address of
David Gibsonc125a182006-02-01 03:05:22 -08001250 this controller
1251 - interrupts : <a b> where a is the interrupt number and b is a
1252 field that represents an encoding of the sense and level
1253 information for the interrupt. This should be encoded based on
1254 the information in section 2) depending on the type of interrupt
1255 controller you have.
1256 - interrupt-parent : the phandle for the interrupt controller that
1257 services interrupts for this device.
1258 - phy-handle : The phandle for the PHY connected to this ethernet
1259 controller.
Vitaly Borduga21e2822007-12-07 01:51:31 +03001260 - fixed-link : <a b c d e> where a is emulated phy id - choose any,
1261 but unique to the all specified fixed-links, b is duplex - 0 half,
1262 1 full, c is link speed - d#10/d#100/d#1000, d is pause - 0 no
1263 pause, 1 pause, e is asym_pause - 0 no asym_pause, 1 asym_pause.
David Gibsonc125a182006-02-01 03:05:22 -08001264
Scott Woode0a2f282007-03-16 12:28:46 -05001265 Recommended properties:
1266
1267 - linux,network-index : This is the intended "index" of this
1268 network device. This is used by the bootwrapper to interpret
1269 MAC addresses passed by the firmware when no information other
1270 than indices is available to associate an address with a device.
Andy Flemingcc651852007-07-10 17:28:49 -05001271 - phy-connection-type : a string naming the controller/PHY interface type,
1272 i.e., "mii" (default), "rmii", "gmii", "rgmii", "rgmii-id", "sgmii",
1273 "tbi", or "rtbi". This property is only really needed if the connection
1274 is of type "rgmii-id", as all other connection types are detected by
1275 hardware.
1276
Scott Woode0a2f282007-03-16 12:28:46 -05001277
David Gibsonc125a182006-02-01 03:05:22 -08001278 Example:
1279
1280 ethernet@24000 {
1281 #size-cells = <0>;
1282 device_type = "network";
1283 model = "TSEC";
1284 compatible = "gianfar";
1285 reg = <24000 1000>;
Jon Loeligerf5831652006-08-17 08:42:35 -05001286 mac-address = [ 00 E0 0C 00 73 00 ];
David Gibsonc125a182006-02-01 03:05:22 -08001287 interrupts = <d 3 e 3 12 3>;
1288 interrupt-parent = <40000>;
1289 phy-handle = <2452000>
1290 };
1291
1292
1293
1294 c) PHY nodes
1295
1296 Required properties:
1297
1298 - device_type : Should be "ethernet-phy"
1299 - interrupts : <a b> where a is the interrupt number and b is a
1300 field that represents an encoding of the sense and level
1301 information for the interrupt. This should be encoded based on
1302 the information in section 2) depending on the type of interrupt
1303 controller you have.
1304 - interrupt-parent : the phandle for the interrupt controller that
1305 services interrupts for this device.
1306 - reg : The ID number for the phy, usually a small integer
1307 - linux,phandle : phandle for this node; likely referenced by an
1308 ethernet controller node.
1309
1310
1311 Example:
1312
1313 ethernet-phy@0 {
1314 linux,phandle = <2452000>
1315 interrupt-parent = <40000>;
1316 interrupts = <35 1>;
1317 reg = <0>;
1318 device_type = "ethernet-phy";
1319 };
1320
1321
1322 d) Interrupt controllers
1323
1324 Some SOC devices contain interrupt controllers that are different
1325 from the standard Open PIC specification. The SOC device nodes for
1326 these types of controllers should be specified just like a standard
1327 OpenPIC controller. Sense and level information should be encoded
1328 as specified in section 2) of this chapter for each device that
1329 specifies an interrupt.
1330
1331 Example :
1332
1333 pic@40000 {
1334 linux,phandle = <40000>;
1335 clock-frequency = <0>;
1336 interrupt-controller;
1337 #address-cells = <0>;
1338 reg = <40000 40000>;
1339 built-in;
1340 compatible = "chrp,open-pic";
1341 device_type = "open-pic";
1342 big-endian;
1343 };
1344
1345
1346 e) I2C
1347
1348 Required properties :
1349
1350 - device_type : Should be "i2c"
1351 - reg : Offset and length of the register set for the device
1352
1353 Recommended properties :
1354
1355 - compatible : Should be "fsl-i2c" for parts compatible with
1356 Freescale I2C specifications.
1357 - interrupts : <a b> where a is the interrupt number and b is a
1358 field that represents an encoding of the sense and level
1359 information for the interrupt. This should be encoded based on
1360 the information in section 2) depending on the type of interrupt
1361 controller you have.
1362 - interrupt-parent : the phandle for the interrupt controller that
1363 services interrupts for this device.
1364 - dfsrr : boolean; if defined, indicates that this I2C device has
1365 a digital filter sampling rate register
1366 - fsl5200-clocking : boolean; if defined, indicated that this device
1367 uses the FSL 5200 clocking mechanism.
1368
1369 Example :
1370
1371 i2c@3000 {
1372 interrupt-parent = <40000>;
1373 interrupts = <1b 3>;
1374 reg = <3000 18>;
1375 device_type = "i2c";
1376 compatible = "fsl-i2c";
1377 dfsrr;
1378 };
1379
1380
Becky Brucead71f122006-02-07 13:44:08 -06001381 f) Freescale SOC USB controllers
1382
1383 The device node for a USB controller that is part of a Freescale
1384 SOC is as described in the document "Open Firmware Recommended
1385 Practice : Universal Serial Bus" with the following modifications
1386 and additions :
1387
1388 Required properties :
Domen Puncer5dd60162007-03-02 21:44:45 +11001389 - compatible : Should be "fsl-usb2-mph" for multi port host USB
1390 controllers, or "fsl-usb2-dr" for dual role USB controllers
1391 - phy_type : For multi port host USB controllers, should be one of
1392 "ulpi", or "serial". For dual role USB controllers, should be
Becky Brucead71f122006-02-07 13:44:08 -06001393 one of "ulpi", "utmi", "utmi_wide", or "serial".
1394 - reg : Offset and length of the register set for the device
1395 - port0 : boolean; if defined, indicates port0 is connected for
1396 fsl-usb2-mph compatible controllers. Either this property or
1397 "port1" (or both) must be defined for "fsl-usb2-mph" compatible
1398 controllers.
1399 - port1 : boolean; if defined, indicates port1 is connected for
1400 fsl-usb2-mph compatible controllers. Either this property or
1401 "port0" (or both) must be defined for "fsl-usb2-mph" compatible
1402 controllers.
Li Yangea5b7a62007-02-07 13:51:09 +08001403 - dr_mode : indicates the working mode for "fsl-usb2-dr" compatible
1404 controllers. Can be "host", "peripheral", or "otg". Default to
1405 "host" if not defined for backward compatibility.
Becky Brucead71f122006-02-07 13:44:08 -06001406
1407 Recommended properties :
1408 - interrupts : <a b> where a is the interrupt number and b is a
1409 field that represents an encoding of the sense and level
1410 information for the interrupt. This should be encoded based on
1411 the information in section 2) depending on the type of interrupt
1412 controller you have.
1413 - interrupt-parent : the phandle for the interrupt controller that
1414 services interrupts for this device.
1415
Domen Puncer5dd60162007-03-02 21:44:45 +11001416 Example multi port host USB controller device node :
Becky Brucead71f122006-02-07 13:44:08 -06001417 usb@22000 {
Becky Brucead71f122006-02-07 13:44:08 -06001418 compatible = "fsl-usb2-mph";
1419 reg = <22000 1000>;
1420 #address-cells = <1>;
1421 #size-cells = <0>;
1422 interrupt-parent = <700>;
1423 interrupts = <27 1>;
1424 phy_type = "ulpi";
1425 port0;
1426 port1;
1427 };
1428
Domen Puncer5dd60162007-03-02 21:44:45 +11001429 Example dual role USB controller device node :
Becky Brucead71f122006-02-07 13:44:08 -06001430 usb@23000 {
Becky Brucead71f122006-02-07 13:44:08 -06001431 compatible = "fsl-usb2-dr";
1432 reg = <23000 1000>;
1433 #address-cells = <1>;
1434 #size-cells = <0>;
1435 interrupt-parent = <700>;
1436 interrupts = <26 1>;
Li Yangea5b7a62007-02-07 13:51:09 +08001437 dr_mode = "otg";
Becky Brucead71f122006-02-07 13:44:08 -06001438 phy = "ulpi";
1439 };
1440
1441
Kim Phillipsb88a0b12006-03-22 14:39:03 -06001442 g) Freescale SOC SEC Security Engines
1443
1444 Required properties:
1445
1446 - device_type : Should be "crypto"
1447 - model : Model of the device. Should be "SEC1" or "SEC2"
1448 - compatible : Should be "talitos"
1449 - reg : Offset and length of the register set for the device
1450 - interrupts : <a b> where a is the interrupt number and b is a
1451 field that represents an encoding of the sense and level
1452 information for the interrupt. This should be encoded based on
1453 the information in section 2) depending on the type of interrupt
1454 controller you have.
1455 - interrupt-parent : the phandle for the interrupt controller that
1456 services interrupts for this device.
1457 - num-channels : An integer representing the number of channels
1458 available.
1459 - channel-fifo-len : An integer representing the number of
1460 descriptor pointers each channel fetch fifo can hold.
1461 - exec-units-mask : The bitmask representing what execution units
Domen Puncer5dd60162007-03-02 21:44:45 +11001462 (EUs) are available. It's a single 32-bit cell. EU information
Kim Phillipsb88a0b12006-03-22 14:39:03 -06001463 should be encoded following the SEC's Descriptor Header Dword
1464 EU_SEL0 field documentation, i.e. as follows:
1465
1466 bit 0 = reserved - should be 0
1467 bit 1 = set if SEC has the ARC4 EU (AFEU)
1468 bit 2 = set if SEC has the DES/3DES EU (DEU)
1469 bit 3 = set if SEC has the message digest EU (MDEU)
1470 bit 4 = set if SEC has the random number generator EU (RNG)
1471 bit 5 = set if SEC has the public key EU (PKEU)
1472 bit 6 = set if SEC has the AES EU (AESU)
1473 bit 7 = set if SEC has the Kasumi EU (KEU)
1474
1475 bits 8 through 31 are reserved for future SEC EUs.
1476
1477 - descriptor-types-mask : The bitmask representing what descriptors
Domen Puncer5dd60162007-03-02 21:44:45 +11001478 are available. It's a single 32-bit cell. Descriptor type
Kim Phillipsb88a0b12006-03-22 14:39:03 -06001479 information should be encoded following the SEC's Descriptor
1480 Header Dword DESC_TYPE field documentation, i.e. as follows:
1481
1482 bit 0 = set if SEC supports the aesu_ctr_nonsnoop desc. type
1483 bit 1 = set if SEC supports the ipsec_esp descriptor type
1484 bit 2 = set if SEC supports the common_nonsnoop desc. type
1485 bit 3 = set if SEC supports the 802.11i AES ccmp desc. type
1486 bit 4 = set if SEC supports the hmac_snoop_no_afeu desc. type
1487 bit 5 = set if SEC supports the srtp descriptor type
1488 bit 6 = set if SEC supports the non_hmac_snoop_no_afeu desc.type
1489 bit 7 = set if SEC supports the pkeu_assemble descriptor type
1490 bit 8 = set if SEC supports the aesu_key_expand_output desc.type
1491 bit 9 = set if SEC supports the pkeu_ptmul descriptor type
1492 bit 10 = set if SEC supports the common_nonsnoop_afeu desc. type
1493 bit 11 = set if SEC supports the pkeu_ptadd_dbl descriptor type
1494
1495 ..and so on and so forth.
1496
1497 Example:
1498
1499 /* MPC8548E */
1500 crypto@30000 {
1501 device_type = "crypto";
1502 model = "SEC2";
1503 compatible = "talitos";
1504 reg = <30000 10000>;
1505 interrupts = <1d 3>;
1506 interrupt-parent = <40000>;
1507 num-channels = <4>;
Kim Phillipscbdb54d2006-07-03 15:10:14 -05001508 channel-fifo-len = <18>;
Kim Phillipsb88a0b12006-03-22 14:39:03 -06001509 exec-units-mask = <000000fe>;
Kim Phillipscbdb54d2006-07-03 15:10:14 -05001510 descriptor-types-mask = <012b0ebf>;
Kim Phillipsb88a0b12006-03-22 14:39:03 -06001511 };
1512
Li Yang9a1ab882006-10-02 20:08:59 -05001513 h) Board Control and Status (BCSR)
1514
1515 Required properties:
1516
1517 - device_type : Should be "board-control"
1518 - reg : Offset and length of the register set for the device
1519
1520 Example:
1521
1522 bcsr@f8000000 {
1523 device_type = "board-control";
1524 reg = <f8000000 8000>;
1525 };
1526
1527 i) Freescale QUICC Engine module (QE)
1528 This represents qe module that is installed on PowerQUICC II Pro.
Scott Woode631ae32007-09-14 13:04:54 -05001529
1530 NOTE: This is an interim binding; it should be updated to fit
1531 in with the CPM binding later in this document.
1532
Li Yang9a1ab882006-10-02 20:08:59 -05001533 Basically, it is a bus of devices, that could act more or less
1534 as a complete entity (UCC, USB etc ). All of them should be siblings on
1535 the "root" qe node, using the common properties from there.
Michael Opdenacker59c51592007-05-09 08:57:56 +02001536 The description below applies to the qe of MPC8360 and
Li Yang9a1ab882006-10-02 20:08:59 -05001537 more nodes and properties would be extended in the future.
1538
1539 i) Root QE device
1540
1541 Required properties:
1542 - device_type : should be "qe";
1543 - model : precise model of the QE, Can be "QE", "CPM", or "CPM2"
1544 - reg : offset and length of the device registers.
1545 - bus-frequency : the clock frequency for QUICC Engine.
1546
1547 Recommended properties
1548 - brg-frequency : the internal clock source frequency for baud-rate
1549 generators in Hz.
1550
1551 Example:
1552 qe@e0100000 {
1553 #address-cells = <1>;
1554 #size-cells = <1>;
1555 #interrupt-cells = <2>;
1556 device_type = "qe";
1557 model = "QE";
1558 ranges = <0 e0100000 00100000>;
1559 reg = <e0100000 480>;
1560 brg-frequency = <0>;
1561 bus-frequency = <179A7B00>;
1562 }
1563
1564
1565 ii) SPI (Serial Peripheral Interface)
1566
1567 Required properties:
1568 - device_type : should be "spi".
1569 - compatible : should be "fsl_spi".
Peter Korsgaardf023dc72007-10-03 18:29:09 +02001570 - mode : the SPI operation mode, it can be "cpu" or "cpu-qe".
Li Yang9a1ab882006-10-02 20:08:59 -05001571 - reg : Offset and length of the register set for the device
1572 - interrupts : <a b> where a is the interrupt number and b is a
1573 field that represents an encoding of the sense and level
1574 information for the interrupt. This should be encoded based on
1575 the information in section 2) depending on the type of interrupt
1576 controller you have.
1577 - interrupt-parent : the phandle for the interrupt controller that
1578 services interrupts for this device.
1579
1580 Example:
1581 spi@4c0 {
1582 device_type = "spi";
1583 compatible = "fsl_spi";
1584 reg = <4c0 40>;
1585 interrupts = <82 0>;
1586 interrupt-parent = <700>;
1587 mode = "cpu";
1588 };
1589
1590
1591 iii) USB (Universal Serial Bus Controller)
1592
1593 Required properties:
Li Yang9a1ab882006-10-02 20:08:59 -05001594 - compatible : could be "qe_udc" or "fhci-hcd".
1595 - mode : the could be "host" or "slave".
1596 - reg : Offset and length of the register set for the device
1597 - interrupts : <a b> where a is the interrupt number and b is a
1598 field that represents an encoding of the sense and level
1599 information for the interrupt. This should be encoded based on
1600 the information in section 2) depending on the type of interrupt
1601 controller you have.
1602 - interrupt-parent : the phandle for the interrupt controller that
1603 services interrupts for this device.
1604
1605 Example(slave):
1606 usb@6c0 {
Li Yang9a1ab882006-10-02 20:08:59 -05001607 compatible = "qe_udc";
1608 reg = <6c0 40>;
1609 interrupts = <8b 0>;
1610 interrupt-parent = <700>;
1611 mode = "slave";
1612 };
1613
1614
1615 iv) UCC (Unified Communications Controllers)
1616
1617 Required properties:
1618 - device_type : should be "network", "hldc", "uart", "transparent"
1619 "bisync" or "atm".
1620 - compatible : could be "ucc_geth" or "fsl_atm" and so on.
1621 - model : should be "UCC".
1622 - device-id : the ucc number(1-8), corresponding to UCCx in UM.
1623 - reg : Offset and length of the register set for the device
1624 - interrupts : <a b> where a is the interrupt number and b is a
1625 field that represents an encoding of the sense and level
1626 information for the interrupt. This should be encoded based on
1627 the information in section 2) depending on the type of interrupt
1628 controller you have.
1629 - interrupt-parent : the phandle for the interrupt controller that
1630 services interrupts for this device.
1631 - pio-handle : The phandle for the Parallel I/O port configuration.
Timur Tabi174b0da2007-12-03 15:17:58 -06001632 - rx-clock-name: the UCC receive clock source
1633 "none": clock source is disabled
1634 "brg1" through "brg16": clock source is BRG1-BRG16, respectively
1635 "clk1" through "clk24": clock source is CLK1-CLK24, respectively
1636 - tx-clock-name: the UCC transmit clock source
1637 "none": clock source is disabled
1638 "brg1" through "brg16": clock source is BRG1-BRG16, respectively
1639 "clk1" through "clk24": clock source is CLK1-CLK24, respectively
1640 The following two properties are deprecated. rx-clock has been replaced
1641 with rx-clock-name, and tx-clock has been replaced with tx-clock-name.
1642 Drivers that currently use the deprecated properties should continue to
1643 do so, in order to support older device trees, but they should be updated
1644 to check for the new properties first.
Li Yang9a1ab882006-10-02 20:08:59 -05001645 - rx-clock : represents the UCC receive clock source.
1646 0x00 : clock source is disabled;
1647 0x1~0x10 : clock source is BRG1~BRG16 respectively;
1648 0x11~0x28: clock source is QE_CLK1~QE_CLK24 respectively.
1649 - tx-clock: represents the UCC transmit clock source;
1650 0x00 : clock source is disabled;
1651 0x1~0x10 : clock source is BRG1~BRG16 respectively;
1652 0x11~0x28: clock source is QE_CLK1~QE_CLK24 respectively.
1653
1654 Required properties for network device_type:
1655 - mac-address : list of bytes representing the ethernet address.
1656 - phy-handle : The phandle for the PHY connected to this controller.
1657
Scott Woode0a2f282007-03-16 12:28:46 -05001658 Recommended properties:
1659 - linux,network-index : This is the intended "index" of this
1660 network device. This is used by the bootwrapper to interpret
1661 MAC addresses passed by the firmware when no information other
1662 than indices is available to associate an address with a device.
Kim Phillips60c19222007-04-24 07:26:10 +10001663 - phy-connection-type : a string naming the controller/PHY interface type,
Kim Phillips34be4562007-11-05 12:15:35 -06001664 i.e., "mii" (default), "rmii", "gmii", "rgmii", "rgmii-id" (Internal
1665 Delay), "rgmii-txid" (delay on TX only), "rgmii-rxid" (delay on RX only),
1666 "tbi", or "rtbi".
Scott Woode0a2f282007-03-16 12:28:46 -05001667
Li Yang9a1ab882006-10-02 20:08:59 -05001668 Example:
1669 ucc@2000 {
1670 device_type = "network";
1671 compatible = "ucc_geth";
1672 model = "UCC";
1673 device-id = <1>;
1674 reg = <2000 200>;
1675 interrupts = <a0 0>;
1676 interrupt-parent = <700>;
1677 mac-address = [ 00 04 9f 00 23 23 ];
1678 rx-clock = "none";
1679 tx-clock = "clk9";
1680 phy-handle = <212000>;
Kim Phillips60c19222007-04-24 07:26:10 +10001681 phy-connection-type = "gmii";
Li Yang9a1ab882006-10-02 20:08:59 -05001682 pio-handle = <140001>;
1683 };
1684
1685
1686 v) Parallel I/O Ports
1687
1688 This node configures Parallel I/O ports for CPUs with QE support.
1689 The node should reside in the "soc" node of the tree. For each
1690 device that using parallel I/O ports, a child node should be created.
1691 See the definition of the Pin configuration nodes below for more
1692 information.
1693
1694 Required properties:
1695 - device_type : should be "par_io".
1696 - reg : offset to the register set and its length.
1697 - num-ports : number of Parallel I/O ports
1698
1699 Example:
1700 par_io@1400 {
1701 reg = <1400 100>;
1702 #address-cells = <1>;
1703 #size-cells = <0>;
1704 device_type = "par_io";
1705 num-ports = <7>;
1706 ucc_pin@01 {
1707 ......
1708 };
1709
1710
1711 vi) Pin configuration nodes
1712
1713 Required properties:
1714 - linux,phandle : phandle of this node; likely referenced by a QE
1715 device.
1716 - pio-map : array of pin configurations. Each pin is defined by 6
1717 integers. The six numbers are respectively: port, pin, dir,
1718 open_drain, assignment, has_irq.
1719 - port : port number of the pin; 0-6 represent port A-G in UM.
1720 - pin : pin number in the port.
1721 - dir : direction of the pin, should encode as follows:
1722
1723 0 = The pin is disabled
1724 1 = The pin is an output
1725 2 = The pin is an input
1726 3 = The pin is I/O
1727
1728 - open_drain : indicates the pin is normal or wired-OR:
1729
1730 0 = The pin is actively driven as an output
1731 1 = The pin is an open-drain driver. As an output, the pin is
1732 driven active-low, otherwise it is three-stated.
1733
1734 - assignment : function number of the pin according to the Pin Assignment
1735 tables in User Manual. Each pin can have up to 4 possible functions in
1736 QE and two options for CPM.
Matt LaPlantea982ac02007-05-09 07:35:06 +02001737 - has_irq : indicates if the pin is used as source of external
Li Yang9a1ab882006-10-02 20:08:59 -05001738 interrupts.
1739
1740 Example:
1741 ucc_pin@01 {
1742 linux,phandle = <140001>;
1743 pio-map = <
1744 /* port pin dir open_drain assignment has_irq */
1745 0 3 1 0 1 0 /* TxD0 */
1746 0 4 1 0 1 0 /* TxD1 */
1747 0 5 1 0 1 0 /* TxD2 */
1748 0 6 1 0 1 0 /* TxD3 */
1749 1 6 1 0 3 0 /* TxD4 */
1750 1 7 1 0 1 0 /* TxD5 */
1751 1 9 1 0 2 0 /* TxD6 */
1752 1 a 1 0 2 0 /* TxD7 */
1753 0 9 2 0 1 0 /* RxD0 */
1754 0 a 2 0 1 0 /* RxD1 */
1755 0 b 2 0 1 0 /* RxD2 */
1756 0 c 2 0 1 0 /* RxD3 */
1757 0 d 2 0 1 0 /* RxD4 */
1758 1 1 2 0 2 0 /* RxD5 */
1759 1 0 2 0 2 0 /* RxD6 */
1760 1 4 2 0 2 0 /* RxD7 */
1761 0 7 1 0 1 0 /* TX_EN */
1762 0 8 1 0 1 0 /* TX_ER */
1763 0 f 2 0 1 0 /* RX_DV */
1764 0 10 2 0 1 0 /* RX_ER */
1765 0 0 2 0 1 0 /* RX_CLK */
1766 2 9 1 0 3 0 /* GTX_CLK - CLK10 */
1767 2 8 2 0 1 0>; /* GTX125 - CLK9 */
1768 };
1769
1770 vii) Multi-User RAM (MURAM)
1771
1772 Required properties:
1773 - device_type : should be "muram".
1774 - mode : the could be "host" or "slave".
1775 - ranges : Should be defined as specified in 1) to describe the
1776 translation of MURAM addresses.
1777 - data-only : sub-node which defines the address area under MURAM
1778 bus that can be allocated as data/parameter
1779
1780 Example:
1781
1782 muram@10000 {
1783 device_type = "muram";
1784 ranges = <0 00010000 0000c000>;
1785
1786 data-only@0{
1787 reg = <0 c000>;
1788 };
1789 };
Kim Phillipsb88a0b12006-03-22 14:39:03 -06001790
David Gibson20991722007-09-07 13:23:53 +10001791 j) CFI or JEDEC memory-mapped NOR flash
Vitaly Wool28f9ec32006-11-20 16:32:39 +03001792
1793 Flash chips (Memory Technology Devices) are often used for solid state
1794 file systems on embedded devices.
1795
David Gibson20991722007-09-07 13:23:53 +10001796 - compatible : should contain the specific model of flash chip(s)
1797 used, if known, followed by either "cfi-flash" or "jedec-flash"
1798 - reg : Address range of the flash chip
1799 - bank-width : Width (in bytes) of the flash bank. Equal to the
1800 device width times the number of interleaved chips.
1801 - device-width : (optional) Width of a single flash chip. If
1802 omitted, assumed to be equal to 'bank-width'.
1803 - #address-cells, #size-cells : Must be present if the flash has
1804 sub-nodes representing partitions (see below). In this case
1805 both #address-cells and #size-cells must be equal to 1.
Vitaly Wool28f9ec32006-11-20 16:32:39 +03001806
David Gibson20991722007-09-07 13:23:53 +10001807 For JEDEC compatible devices, the following additional properties
1808 are defined:
Vitaly Wool28f9ec32006-11-20 16:32:39 +03001809
David Gibson20991722007-09-07 13:23:53 +10001810 - vendor-id : Contains the flash chip's vendor id (1 byte).
1811 - device-id : Contains the flash chip's device id (1 byte).
Vitaly Wool28f9ec32006-11-20 16:32:39 +03001812
David Gibson20991722007-09-07 13:23:53 +10001813 In addition to the information on the flash bank itself, the
1814 device tree may optionally contain additional information
1815 describing partitions of the flash address space. This can be
1816 used on platforms which have strong conventions about which
1817 portions of the flash are used for what purposes, but which don't
1818 use an on-flash partition table such as RedBoot.
Vitaly Wool28f9ec32006-11-20 16:32:39 +03001819
David Gibson20991722007-09-07 13:23:53 +10001820 Each partition is represented as a sub-node of the flash device.
1821 Each node's name represents the name of the corresponding
1822 partition of the flash device.
Vitaly Wool28f9ec32006-11-20 16:32:39 +03001823
David Gibson20991722007-09-07 13:23:53 +10001824 Flash partitions
1825 - reg : The partition's offset and size within the flash bank.
1826 - label : (optional) The label / name for this flash partition.
1827 If omitted, the label is taken from the node name (excluding
1828 the unit address).
1829 - read-only : (optional) This parameter, if present, is a hint to
1830 Linux that this flash partition should only be mounted
1831 read-only. This is usually used for flash partitions
1832 containing early-boot firmware images or data which should not
1833 be clobbered.
1834
1835 Example:
1836
1837 flash@ff000000 {
1838 compatible = "amd,am29lv128ml", "cfi-flash";
1839 reg = <ff000000 01000000>;
1840 bank-width = <4>;
1841 device-width = <1>;
1842 #address-cells = <1>;
1843 #size-cells = <1>;
1844 fs@0 {
1845 label = "fs";
1846 reg = <0 f80000>;
1847 };
1848 firmware@f80000 {
1849 label ="firmware";
1850 reg = <f80000 80000>;
1851 read-only;
1852 };
1853 };
Vitaly Wool28f9ec32006-11-20 16:32:39 +03001854
Roy Zang3b824f82007-06-19 15:19:18 +08001855 k) Global Utilities Block
1856
1857 The global utilities block controls power management, I/O device
1858 enabling, power-on-reset configuration monitoring, general-purpose
1859 I/O signal configuration, alternate function selection for multiplexed
1860 signals, and clock control.
1861
1862 Required properties:
1863
1864 - compatible : Should define the compatible device type for
1865 global-utilities.
1866 - reg : Offset and length of the register set for the device.
1867
1868 Recommended properties:
1869
1870 - fsl,has-rstcr : Indicates that the global utilities register set
1871 contains a functioning "reset control register" (i.e. the board
1872 is wired to reset upon setting the HRESET_REQ bit in this register).
1873
1874 Example:
1875
1876 global-utilities@e0000 { /* global utilities block */
1877 compatible = "fsl,mpc8548-guts";
1878 reg = <e0000 1000>;
1879 fsl,has-rstcr;
1880 };
1881
Scott Woode631ae32007-09-14 13:04:54 -05001882 l) Freescale Communications Processor Module
David Gibson1d3bb992007-08-23 13:56:01 +10001883
Scott Woode631ae32007-09-14 13:04:54 -05001884 NOTE: This is an interim binding, and will likely change slightly,
1885 as more devices are supported. The QE bindings especially are
1886 incomplete.
1887
1888 i) Root CPM node
1889
1890 Properties:
1891 - compatible : "fsl,cpm1", "fsl,cpm2", or "fsl,qe".
Scott Wood15f8c602007-09-28 14:06:16 -05001892 - reg : A 48-byte region beginning with CPCR.
Scott Woode631ae32007-09-14 13:04:54 -05001893
1894 Example:
1895 cpm@119c0 {
1896 #address-cells = <1>;
1897 #size-cells = <1>;
1898 #interrupt-cells = <2>;
1899 compatible = "fsl,mpc8272-cpm", "fsl,cpm2";
Scott Wood15f8c602007-09-28 14:06:16 -05001900 reg = <119c0 30>;
Scott Woode631ae32007-09-14 13:04:54 -05001901 }
1902
1903 ii) Properties common to mulitple CPM/QE devices
1904
1905 - fsl,cpm-command : This value is ORed with the opcode and command flag
1906 to specify the device on which a CPM command operates.
1907
1908 - fsl,cpm-brg : Indicates which baud rate generator the device
1909 is associated with. If absent, an unused BRG
1910 should be dynamically allocated. If zero, the
1911 device uses an external clock rather than a BRG.
1912
1913 - reg : Unless otherwise specified, the first resource represents the
1914 scc/fcc/ucc registers, and the second represents the device's
1915 parameter RAM region (if it has one).
1916
1917 iii) Serial
1918
1919 Currently defined compatibles:
1920 - fsl,cpm1-smc-uart
1921 - fsl,cpm2-smc-uart
1922 - fsl,cpm1-scc-uart
1923 - fsl,cpm2-scc-uart
1924 - fsl,qe-uart
1925
1926 Example:
1927
1928 serial@11a00 {
1929 device_type = "serial";
1930 compatible = "fsl,mpc8272-scc-uart",
1931 "fsl,cpm2-scc-uart";
1932 reg = <11a00 20 8000 100>;
1933 interrupts = <28 8>;
1934 interrupt-parent = <&PIC>;
1935 fsl,cpm-brg = <1>;
1936 fsl,cpm-command = <00800000>;
1937 };
1938
1939 iii) Network
1940
1941 Currently defined compatibles:
1942 - fsl,cpm1-scc-enet
1943 - fsl,cpm2-scc-enet
1944 - fsl,cpm1-fec-enet
1945 - fsl,cpm2-fcc-enet (third resource is GFEMR)
1946 - fsl,qe-enet
1947
1948 Example:
1949
1950 ethernet@11300 {
1951 device_type = "network";
1952 compatible = "fsl,mpc8272-fcc-enet",
1953 "fsl,cpm2-fcc-enet";
1954 reg = <11300 20 8400 100 11390 1>;
1955 local-mac-address = [ 00 00 00 00 00 00 ];
1956 interrupts = <20 8>;
1957 interrupt-parent = <&PIC>;
1958 phy-handle = <&PHY0>;
1959 linux,network-index = <0>;
1960 fsl,cpm-command = <12000300>;
1961 };
1962
1963 iv) MDIO
1964
1965 Currently defined compatibles:
1966 fsl,pq1-fec-mdio (reg is same as first resource of FEC device)
1967 fsl,cpm2-mdio-bitbang (reg is port C registers)
1968
1969 Properties for fsl,cpm2-mdio-bitbang:
1970 fsl,mdio-pin : pin of port C controlling mdio data
1971 fsl,mdc-pin : pin of port C controlling mdio clock
1972
1973 Example:
1974
1975 mdio@10d40 {
1976 device_type = "mdio";
1977 compatible = "fsl,mpc8272ads-mdio-bitbang",
1978 "fsl,mpc8272-mdio-bitbang",
1979 "fsl,cpm2-mdio-bitbang";
1980 reg = <10d40 14>;
1981 #address-cells = <1>;
1982 #size-cells = <0>;
1983 fsl,mdio-pin = <12>;
1984 fsl,mdc-pin = <13>;
1985 };
1986
1987 v) Baud Rate Generators
1988
1989 Currently defined compatibles:
1990 fsl,cpm-brg
1991 fsl,cpm1-brg
1992 fsl,cpm2-brg
1993
1994 Properties:
1995 - reg : There may be an arbitrary number of reg resources; BRG
1996 numbers are assigned to these in order.
1997 - clock-frequency : Specifies the base frequency driving
1998 the BRG.
1999
2000 Example:
2001
2002 brg@119f0 {
2003 compatible = "fsl,mpc8272-brg",
2004 "fsl,cpm2-brg",
2005 "fsl,cpm-brg";
2006 reg = <119f0 10 115f0 10>;
2007 clock-frequency = <d#25000000>;
2008 };
2009
2010 vi) Interrupt Controllers
2011
2012 Currently defined compatibles:
2013 - fsl,cpm1-pic
2014 - only one interrupt cell
2015 - fsl,pq1-pic
2016 - fsl,cpm2-pic
2017 - second interrupt cell is level/sense:
2018 - 2 is falling edge
2019 - 8 is active low
2020
2021 Example:
2022
2023 interrupt-controller@10c00 {
2024 #interrupt-cells = <2>;
2025 interrupt-controller;
2026 reg = <10c00 80>;
2027 compatible = "mpc8272-pic", "fsl,cpm2-pic";
2028 };
2029
2030 vii) USB (Universal Serial Bus Controller)
2031
2032 Properties:
2033 - compatible : "fsl,cpm1-usb", "fsl,cpm2-usb", "fsl,qe-usb"
2034
2035 Example:
2036 usb@11bc0 {
2037 #address-cells = <1>;
2038 #size-cells = <0>;
2039 compatible = "fsl,cpm2-usb";
2040 reg = <11b60 18 8b00 100>;
2041 interrupts = <b 8>;
2042 interrupt-parent = <&PIC>;
2043 fsl,cpm-command = <2e600000>;
2044 };
2045
Scott Wood15f8c602007-09-28 14:06:16 -05002046 viii) Multi-User RAM (MURAM)
2047
2048 The multi-user/dual-ported RAM is expressed as a bus under the CPM node.
2049
2050 Ranges must be set up subject to the following restrictions:
2051
2052 - Children's reg nodes must be offsets from the start of all muram, even
2053 if the user-data area does not begin at zero.
2054 - If multiple range entries are used, the difference between the parent
2055 address and the child address must be the same in all, so that a single
2056 mapping can cover them all while maintaining the ability to determine
2057 CPM-side offsets with pointer subtraction. It is recommended that
2058 multiple range entries not be used.
2059 - A child address of zero must be translatable, even if no reg resources
2060 contain it.
2061
2062 A child "data" node must exist, compatible with "fsl,cpm-muram-data", to
2063 indicate the portion of muram that is usable by the OS for arbitrary
2064 purposes. The data node may have an arbitrary number of reg resources,
2065 all of which contribute to the allocatable muram pool.
2066
2067 Example, based on mpc8272:
2068
2069 muram@0 {
2070 #address-cells = <1>;
2071 #size-cells = <1>;
2072 ranges = <0 0 10000>;
2073
2074 data@0 {
2075 compatible = "fsl,cpm-muram-data";
2076 reg = <0 2000 9800 800>;
2077 };
2078 };
2079
Scott Wood96fca1de2007-09-14 13:24:02 -05002080 m) Chipselect/Local Bus
2081
2082 Properties:
2083 - name : Should be localbus
2084 - #address-cells : Should be either two or three. The first cell is the
2085 chipselect number, and the remaining cells are the
2086 offset into the chipselect.
2087 - #size-cells : Either one or two, depending on how large each chipselect
2088 can be.
2089 - ranges : Each range corresponds to a single chipselect, and cover
2090 the entire access window as configured.
2091
2092 Example:
2093 localbus@f0010100 {
Anton Vorontsov253772b2007-12-15 05:48:26 +11002094 compatible = "fsl,mpc8272-localbus",
Scott Wood96fca1de2007-09-14 13:24:02 -05002095 "fsl,pq2-localbus";
2096 #address-cells = <2>;
2097 #size-cells = <1>;
2098 reg = <f0010100 40>;
2099
2100 ranges = <0 0 fe000000 02000000
2101 1 0 f4500000 00008000>;
2102
2103 flash@0,0 {
2104 compatible = "jedec-flash";
2105 reg = <0 0 2000000>;
2106 bank-width = <4>;
2107 device-width = <1>;
2108 };
2109
2110 board-control@1,0 {
2111 reg = <1 0 20>;
2112 compatible = "fsl,mpc8272ads-bcsr";
2113 };
2114 };
2115
2116
Linus Torvaldse8690862007-10-11 21:55:47 -07002117 n) 4xx/Axon EMAC ethernet nodes
David Gibson1d3bb992007-08-23 13:56:01 +10002118
2119 The EMAC ethernet controller in IBM and AMCC 4xx chips, and also
2120 the Axon bridge. To operate this needs to interact with a ths
2121 special McMAL DMA controller, and sometimes an RGMII or ZMII
2122 interface. In addition to the nodes and properties described
2123 below, the node for the OPB bus on which the EMAC sits must have a
2124 correct clock-frequency property.
2125
2126 i) The EMAC node itself
2127
2128 Required properties:
2129 - device_type : "network"
2130
2131 - compatible : compatible list, contains 2 entries, first is
2132 "ibm,emac-CHIP" where CHIP is the host ASIC (440gx,
2133 405gp, Axon) and second is either "ibm,emac" or
2134 "ibm,emac4". For Axon, thus, we have: "ibm,emac-axon",
2135 "ibm,emac4"
2136 - interrupts : <interrupt mapping for EMAC IRQ and WOL IRQ>
2137 - interrupt-parent : optional, if needed for interrupt mapping
2138 - reg : <registers mapping>
2139 - local-mac-address : 6 bytes, MAC address
2140 - mal-device : phandle of the associated McMAL node
2141 - mal-tx-channel : 1 cell, index of the tx channel on McMAL associated
2142 with this EMAC
2143 - mal-rx-channel : 1 cell, index of the rx channel on McMAL associated
2144 with this EMAC
2145 - cell-index : 1 cell, hardware index of the EMAC cell on a given
2146 ASIC (typically 0x0 and 0x1 for EMAC0 and EMAC1 on
2147 each Axon chip)
2148 - max-frame-size : 1 cell, maximum frame size supported in bytes
2149 - rx-fifo-size : 1 cell, Rx fifo size in bytes for 10 and 100 Mb/sec
2150 operations.
2151 For Axon, 2048
2152 - tx-fifo-size : 1 cell, Tx fifo size in bytes for 10 and 100 Mb/sec
2153 operations.
2154 For Axon, 2048.
2155 - fifo-entry-size : 1 cell, size of a fifo entry (used to calculate
2156 thresholds).
2157 For Axon, 0x00000010
2158 - mal-burst-size : 1 cell, MAL burst size (used to calculate thresholds)
2159 in bytes.
2160 For Axon, 0x00000100 (I think ...)
2161 - phy-mode : string, mode of operations of the PHY interface.
2162 Supported values are: "mii", "rmii", "smii", "rgmii",
2163 "tbi", "gmii", rtbi", "sgmii".
2164 For Axon on CAB, it is "rgmii"
2165 - mdio-device : 1 cell, required iff using shared MDIO registers
2166 (440EP). phandle of the EMAC to use to drive the
2167 MDIO lines for the PHY used by this EMAC.
2168 - zmii-device : 1 cell, required iff connected to a ZMII. phandle of
2169 the ZMII device node
2170 - zmii-channel : 1 cell, required iff connected to a ZMII. Which ZMII
2171 channel or 0xffffffff if ZMII is only used for MDIO.
2172 - rgmii-device : 1 cell, required iff connected to an RGMII. phandle
2173 of the RGMII device node.
2174 For Axon: phandle of plb5/plb4/opb/rgmii
2175 - rgmii-channel : 1 cell, required iff connected to an RGMII. Which
2176 RGMII channel is used by this EMAC.
2177 Fox Axon: present, whatever value is appropriate for each
2178 EMAC, that is the content of the current (bogus) "phy-port"
2179 property.
2180
2181 Recommended properties:
2182 - linux,network-index : This is the intended "index" of this
2183 network device. This is used by the bootwrapper to interpret
2184 MAC addresses passed by the firmware when no information other
2185 than indices is available to associate an address with a device.
2186
2187 Optional properties:
2188 - phy-address : 1 cell, optional, MDIO address of the PHY. If absent,
2189 a search is performed.
2190 - phy-map : 1 cell, optional, bitmap of addresses to probe the PHY
2191 for, used if phy-address is absent. bit 0x00000001 is
2192 MDIO address 0.
2193 For Axon it can be absent, thouugh my current driver
2194 doesn't handle phy-address yet so for now, keep
2195 0x00ffffff in it.
2196 - rx-fifo-size-gige : 1 cell, Rx fifo size in bytes for 1000 Mb/sec
2197 operations (if absent the value is the same as
2198 rx-fifo-size). For Axon, either absent or 2048.
2199 - tx-fifo-size-gige : 1 cell, Tx fifo size in bytes for 1000 Mb/sec
2200 operations (if absent the value is the same as
2201 tx-fifo-size). For Axon, either absent or 2048.
2202 - tah-device : 1 cell, optional. If connected to a TAH engine for
2203 offload, phandle of the TAH device node.
2204 - tah-channel : 1 cell, optional. If appropriate, channel used on the
2205 TAH engine.
2206
2207 Example:
2208
2209 EMAC0: ethernet@40000800 {
2210 linux,network-index = <0>;
2211 device_type = "network";
2212 compatible = "ibm,emac-440gp", "ibm,emac";
2213 interrupt-parent = <&UIC1>;
2214 interrupts = <1c 4 1d 4>;
2215 reg = <40000800 70>;
2216 local-mac-address = [00 04 AC E3 1B 1E];
2217 mal-device = <&MAL0>;
2218 mal-tx-channel = <0 1>;
2219 mal-rx-channel = <0>;
2220 cell-index = <0>;
2221 max-frame-size = <5dc>;
2222 rx-fifo-size = <1000>;
2223 tx-fifo-size = <800>;
2224 phy-mode = "rmii";
2225 phy-map = <00000001>;
2226 zmii-device = <&ZMII0>;
2227 zmii-channel = <0>;
2228 };
2229
2230 ii) McMAL node
2231
2232 Required properties:
2233 - device_type : "dma-controller"
2234 - compatible : compatible list, containing 2 entries, first is
2235 "ibm,mcmal-CHIP" where CHIP is the host ASIC (like
2236 emac) and the second is either "ibm,mcmal" or
2237 "ibm,mcmal2".
2238 For Axon, "ibm,mcmal-axon","ibm,mcmal2"
2239 - interrupts : <interrupt mapping for the MAL interrupts sources:
2240 5 sources: tx_eob, rx_eob, serr, txde, rxde>.
2241 For Axon: This is _different_ from the current
2242 firmware. We use the "delayed" interrupts for txeob
2243 and rxeob. Thus we end up with mapping those 5 MPIC
2244 interrupts, all level positive sensitive: 10, 11, 32,
2245 33, 34 (in decimal)
2246 - dcr-reg : < DCR registers range >
2247 - dcr-parent : if needed for dcr-reg
2248 - num-tx-chans : 1 cell, number of Tx channels
2249 - num-rx-chans : 1 cell, number of Rx channels
2250
2251 iii) ZMII node
2252
2253 Required properties:
2254 - compatible : compatible list, containing 2 entries, first is
2255 "ibm,zmii-CHIP" where CHIP is the host ASIC (like
2256 EMAC) and the second is "ibm,zmii".
2257 For Axon, there is no ZMII node.
2258 - reg : <registers mapping>
2259
2260 iv) RGMII node
2261
2262 Required properties:
2263 - compatible : compatible list, containing 2 entries, first is
2264 "ibm,rgmii-CHIP" where CHIP is the host ASIC (like
2265 EMAC) and the second is "ibm,rgmii".
2266 For Axon, "ibm,rgmii-axon","ibm,rgmii"
2267 - reg : <registers mapping>
2268 - revision : as provided by the RGMII new version register if
2269 available.
2270 For Axon: 0x0000012a
2271
Grant Likely7ae0fa492007-10-23 14:27:41 +10002272 l) Xilinx IP cores
2273
2274 The Xilinx EDK toolchain ships with a set of IP cores (devices) for use
2275 in Xilinx Spartan and Virtex FPGAs. The devices cover the whole range
2276 of standard device types (network, serial, etc.) and miscellanious
2277 devices (gpio, LCD, spi, etc). Also, since these devices are
2278 implemented within the fpga fabric every instance of the device can be
2279 synthesised with different options that change the behaviour.
2280
2281 Each IP-core has a set of parameters which the FPGA designer can use to
2282 control how the core is synthesized. Historically, the EDK tool would
2283 extract the device parameters relevant to device drivers and copy them
2284 into an 'xparameters.h' in the form of #define symbols. This tells the
2285 device drivers how the IP cores are configured, but it requres the kernel
2286 to be recompiled every time the FPGA bitstream is resynthesized.
2287
2288 The new approach is to export the parameters into the device tree and
2289 generate a new device tree each time the FPGA bitstream changes. The
2290 parameters which used to be exported as #defines will now become
2291 properties of the device node. In general, device nodes for IP-cores
2292 will take the following form:
2293
Stephen Neuendorfferab99eee2008-01-09 06:35:07 +11002294 (name): (generic-name)@(base-address) {
Grant Likely7ae0fa492007-10-23 14:27:41 +10002295 compatible = "xlnx,(ip-core-name)-(HW_VER)"
2296 [, (list of compatible devices), ...];
2297 reg = <(baseaddr) (size)>;
2298 interrupt-parent = <&interrupt-controller-phandle>;
2299 interrupts = < ... >;
2300 xlnx,(parameter1) = "(string-value)";
2301 xlnx,(parameter2) = <(int-value)>;
2302 };
2303
Stephen Neuendorfferab99eee2008-01-09 06:35:07 +11002304 (generic-name): an open firmware-style name that describes the
2305 generic class of device. Preferably, this is one word, such
2306 as 'serial' or 'ethernet'.
Grant Likely7ae0fa492007-10-23 14:27:41 +10002307 (ip-core-name): the name of the ip block (given after the BEGIN
2308 directive in system.mhs). Should be in lowercase
2309 and all underscores '_' converted to dashes '-'.
2310 (name): is derived from the "PARAMETER INSTANCE" value.
2311 (parameter#): C_* parameters from system.mhs. The C_ prefix is
2312 dropped from the parameter name, the name is converted
2313 to lowercase and all underscore '_' characters are
2314 converted to dashes '-'.
Stephen Neuendorfferab99eee2008-01-09 06:35:07 +11002315 (baseaddr): the baseaddr parameter value (often named C_BASEADDR).
Grant Likely7ae0fa492007-10-23 14:27:41 +10002316 (HW_VER): from the HW_VER parameter.
Stephen Neuendorfferab99eee2008-01-09 06:35:07 +11002317 (size): the address range size (often C_HIGHADDR - C_BASEADDR + 1).
Grant Likely7ae0fa492007-10-23 14:27:41 +10002318
2319 Typically, the compatible list will include the exact IP core version
2320 followed by an older IP core version which implements the same
2321 interface or any other device with the same interface.
2322
2323 'reg', 'interrupt-parent' and 'interrupts' are all optional properties.
2324
2325 For example, the following block from system.mhs:
2326
2327 BEGIN opb_uartlite
2328 PARAMETER INSTANCE = opb_uartlite_0
2329 PARAMETER HW_VER = 1.00.b
2330 PARAMETER C_BAUDRATE = 115200
2331 PARAMETER C_DATA_BITS = 8
2332 PARAMETER C_ODD_PARITY = 0
2333 PARAMETER C_USE_PARITY = 0
2334 PARAMETER C_CLK_FREQ = 50000000
2335 PARAMETER C_BASEADDR = 0xEC100000
2336 PARAMETER C_HIGHADDR = 0xEC10FFFF
2337 BUS_INTERFACE SOPB = opb_7
2338 PORT OPB_Clk = CLK_50MHz
2339 PORT Interrupt = opb_uartlite_0_Interrupt
2340 PORT RX = opb_uartlite_0_RX
2341 PORT TX = opb_uartlite_0_TX
2342 PORT OPB_Rst = sys_bus_reset_0
2343 END
2344
2345 becomes the following device tree node:
2346
Stephen Neuendorfferab99eee2008-01-09 06:35:07 +11002347 opb_uartlite_0: serial@ec100000 {
Grant Likely7ae0fa492007-10-23 14:27:41 +10002348 device_type = "serial";
2349 compatible = "xlnx,opb-uartlite-1.00.b";
2350 reg = <ec100000 10000>;
Stephen Neuendorfferab99eee2008-01-09 06:35:07 +11002351 interrupt-parent = <&opb_intc_0>;
Grant Likely7ae0fa492007-10-23 14:27:41 +10002352 interrupts = <1 0>; // got this from the opb_intc parameters
2353 current-speed = <d#115200>; // standard serial device prop
2354 clock-frequency = <d#50000000>; // standard serial device prop
2355 xlnx,data-bits = <8>;
2356 xlnx,odd-parity = <0>;
2357 xlnx,use-parity = <0>;
2358 };
2359
Stephen Neuendorfferab99eee2008-01-09 06:35:07 +11002360 Some IP cores actually implement 2 or more logical devices. In
2361 this case, the device should still describe the whole IP core with
2362 a single node and add a child node for each logical device. The
2363 ranges property can be used to translate from parent IP-core to the
2364 registers of each device. In addition, the parent node should be
2365 compatible with the bus type 'xlnx,compound', and should contain
2366 #address-cells and #size-cells, as with any other bus. (Note: this
2367 makes the assumption that both logical devices have the same bus
2368 binding. If this is not true, then separate nodes should be used
2369 for each logical device). The 'cell-index' property can be used to
2370 enumerate logical devices within an IP core. For example, the
2371 following is the system.mhs entry for the dual ps2 controller found
2372 on the ml403 reference design.
Grant Likely7ae0fa492007-10-23 14:27:41 +10002373
2374 BEGIN opb_ps2_dual_ref
2375 PARAMETER INSTANCE = opb_ps2_dual_ref_0
2376 PARAMETER HW_VER = 1.00.a
2377 PARAMETER C_BASEADDR = 0xA9000000
2378 PARAMETER C_HIGHADDR = 0xA9001FFF
2379 BUS_INTERFACE SOPB = opb_v20_0
2380 PORT Sys_Intr1 = ps2_1_intr
2381 PORT Sys_Intr2 = ps2_2_intr
2382 PORT Clkin1 = ps2_clk_rx_1
2383 PORT Clkin2 = ps2_clk_rx_2
2384 PORT Clkpd1 = ps2_clk_tx_1
2385 PORT Clkpd2 = ps2_clk_tx_2
2386 PORT Rx1 = ps2_d_rx_1
2387 PORT Rx2 = ps2_d_rx_2
2388 PORT Txpd1 = ps2_d_tx_1
2389 PORT Txpd2 = ps2_d_tx_2
2390 END
2391
2392 It would result in the following device tree nodes:
2393
Stephen Neuendorfferab99eee2008-01-09 06:35:07 +11002394 opb_ps2_dual_ref_0: opb-ps2-dual-ref@a9000000 {
2395 #address-cells = <1>;
2396 #size-cells = <1>;
2397 compatible = "xlnx,compound";
Grant Likely7ae0fa492007-10-23 14:27:41 +10002398 ranges = <0 a9000000 2000>;
2399 // If this device had extra parameters, then they would
2400 // go here.
2401 ps2@0 {
2402 compatible = "xlnx,opb-ps2-dual-ref-1.00.a";
2403 reg = <0 40>;
Stephen Neuendorfferab99eee2008-01-09 06:35:07 +11002404 interrupt-parent = <&opb_intc_0>;
Grant Likely7ae0fa492007-10-23 14:27:41 +10002405 interrupts = <3 0>;
2406 cell-index = <0>;
2407 };
2408 ps2@1000 {
2409 compatible = "xlnx,opb-ps2-dual-ref-1.00.a";
2410 reg = <1000 40>;
Stephen Neuendorfferab99eee2008-01-09 06:35:07 +11002411 interrupt-parent = <&opb_intc_0>;
Grant Likely7ae0fa492007-10-23 14:27:41 +10002412 interrupts = <3 0>;
2413 cell-index = <0>;
2414 };
2415 };
2416
2417 Also, the system.mhs file defines bus attachments from the processor
2418 to the devices. The device tree structure should reflect the bus
2419 attachments. Again an example; this system.mhs fragment:
2420
2421 BEGIN ppc405_virtex4
2422 PARAMETER INSTANCE = ppc405_0
2423 PARAMETER HW_VER = 1.01.a
2424 BUS_INTERFACE DPLB = plb_v34_0
2425 BUS_INTERFACE IPLB = plb_v34_0
2426 END
2427
2428 BEGIN opb_intc
2429 PARAMETER INSTANCE = opb_intc_0
2430 PARAMETER HW_VER = 1.00.c
2431 PARAMETER C_BASEADDR = 0xD1000FC0
2432 PARAMETER C_HIGHADDR = 0xD1000FDF
2433 BUS_INTERFACE SOPB = opb_v20_0
2434 END
2435
2436 BEGIN opb_uart16550
2437 PARAMETER INSTANCE = opb_uart16550_0
2438 PARAMETER HW_VER = 1.00.d
2439 PARAMETER C_BASEADDR = 0xa0000000
2440 PARAMETER C_HIGHADDR = 0xa0001FFF
2441 BUS_INTERFACE SOPB = opb_v20_0
2442 END
2443
2444 BEGIN plb_v34
2445 PARAMETER INSTANCE = plb_v34_0
2446 PARAMETER HW_VER = 1.02.a
2447 END
2448
2449 BEGIN plb_bram_if_cntlr
2450 PARAMETER INSTANCE = plb_bram_if_cntlr_0
2451 PARAMETER HW_VER = 1.00.b
2452 PARAMETER C_BASEADDR = 0xFFFF0000
2453 PARAMETER C_HIGHADDR = 0xFFFFFFFF
2454 BUS_INTERFACE SPLB = plb_v34_0
2455 END
2456
2457 BEGIN plb2opb_bridge
2458 PARAMETER INSTANCE = plb2opb_bridge_0
2459 PARAMETER HW_VER = 1.01.a
2460 PARAMETER C_RNG0_BASEADDR = 0x20000000
2461 PARAMETER C_RNG0_HIGHADDR = 0x3FFFFFFF
2462 PARAMETER C_RNG1_BASEADDR = 0x60000000
2463 PARAMETER C_RNG1_HIGHADDR = 0x7FFFFFFF
2464 PARAMETER C_RNG2_BASEADDR = 0x80000000
2465 PARAMETER C_RNG2_HIGHADDR = 0xBFFFFFFF
2466 PARAMETER C_RNG3_BASEADDR = 0xC0000000
2467 PARAMETER C_RNG3_HIGHADDR = 0xDFFFFFFF
2468 BUS_INTERFACE SPLB = plb_v34_0
2469 BUS_INTERFACE MOPB = opb_v20_0
2470 END
2471
2472 Gives this device tree (some properties removed for clarity):
2473
Stephen Neuendorfferab99eee2008-01-09 06:35:07 +11002474 plb@0 {
Grant Likely7ae0fa492007-10-23 14:27:41 +10002475 #address-cells = <1>;
2476 #size-cells = <1>;
Stephen Neuendorfferab99eee2008-01-09 06:35:07 +11002477 compatible = "xlnx,plb-v34-1.02.a";
Grant Likely7ae0fa492007-10-23 14:27:41 +10002478 device_type = "ibm,plb";
2479 ranges; // 1:1 translation
2480
Stephen Neuendorfferab99eee2008-01-09 06:35:07 +11002481 plb_bram_if_cntrl_0: bram@ffff0000 {
Grant Likely7ae0fa492007-10-23 14:27:41 +10002482 reg = <ffff0000 10000>;
2483 }
2484
Stephen Neuendorfferab99eee2008-01-09 06:35:07 +11002485 opb@20000000 {
Grant Likely7ae0fa492007-10-23 14:27:41 +10002486 #address-cells = <1>;
2487 #size-cells = <1>;
2488 ranges = <20000000 20000000 20000000
2489 60000000 60000000 20000000
2490 80000000 80000000 40000000
2491 c0000000 c0000000 20000000>;
2492
Stephen Neuendorfferab99eee2008-01-09 06:35:07 +11002493 opb_uart16550_0: serial@a0000000 {
Grant Likely7ae0fa492007-10-23 14:27:41 +10002494 reg = <a00000000 2000>;
2495 };
2496
Stephen Neuendorfferab99eee2008-01-09 06:35:07 +11002497 opb_intc_0: interrupt-controller@d1000fc0 {
Grant Likely7ae0fa492007-10-23 14:27:41 +10002498 reg = <d1000fc0 20>;
2499 };
2500 };
2501 };
2502
2503 That covers the general approach to binding xilinx IP cores into the
2504 device tree. The following are bindings for specific devices:
2505
2506 i) Xilinx ML300 Framebuffer
2507
2508 Simple framebuffer device from the ML300 reference design (also on the
2509 ML403 reference design as well as others).
2510
2511 Optional properties:
2512 - resolution = <xres yres> : pixel resolution of framebuffer. Some
2513 implementations use a different resolution.
2514 Default is <d#640 d#480>
2515 - virt-resolution = <xvirt yvirt> : Size of framebuffer in memory.
2516 Default is <d#1024 d#480>.
2517 - rotate-display (empty) : rotate display 180 degrees.
2518
2519 ii) Xilinx SystemACE
2520
2521 The Xilinx SystemACE device is used to program FPGAs from an FPGA
2522 bitstream stored on a CF card. It can also be used as a generic CF
2523 interface device.
2524
2525 Optional properties:
2526 - 8-bit (empty) : Set this property for SystemACE in 8 bit mode
2527
2528 iii) Xilinx EMAC and Xilinx TEMAC
2529
2530 Xilinx Ethernet devices. In addition to general xilinx properties
2531 listed above, nodes for these devices should include a phy-handle
2532 property, and may include other common network device properties
2533 like local-mac-address.
2534
2535 iv) Xilinx Uartlite
2536
2537 Xilinx uartlite devices are simple fixed speed serial ports.
2538
2539 Requred properties:
2540 - current-speed : Baud rate of uartlite
2541
David Gibsonc125a182006-02-01 03:05:22 -08002542 More devices will be defined as this spec matures.
2543
Stuart Yoder27565902007-03-02 13:42:33 -06002544VII - Specifying interrupt information for devices
2545===================================================
2546
2547The device tree represents the busses and devices of a hardware
2548system in a form similar to the physical bus topology of the
2549hardware.
2550
2551In addition, a logical 'interrupt tree' exists which represents the
2552hierarchy and routing of interrupts in the hardware.
2553
2554The interrupt tree model is fully described in the
2555document "Open Firmware Recommended Practice: Interrupt
2556Mapping Version 0.9". The document is available at:
2557<http://playground.sun.com/1275/practice>.
2558
25591) interrupts property
2560----------------------
2561
2562Devices that generate interrupts to a single interrupt controller
2563should use the conventional OF representation described in the
2564OF interrupt mapping documentation.
2565
2566Each device which generates interrupts must have an 'interrupt'
2567property. The interrupt property value is an arbitrary number of
2568of 'interrupt specifier' values which describe the interrupt or
2569interrupts for the device.
2570
2571The encoding of an interrupt specifier is determined by the
2572interrupt domain in which the device is located in the
2573interrupt tree. The root of an interrupt domain specifies in
2574its #interrupt-cells property the number of 32-bit cells
2575required to encode an interrupt specifier. See the OF interrupt
2576mapping documentation for a detailed description of domains.
2577
2578For example, the binding for the OpenPIC interrupt controller
2579specifies an #interrupt-cells value of 2 to encode the interrupt
2580number and level/sense information. All interrupt children in an
2581OpenPIC interrupt domain use 2 cells per interrupt in their interrupts
2582property.
2583
2584The PCI bus binding specifies a #interrupt-cell value of 1 to encode
2585which interrupt pin (INTA,INTB,INTC,INTD) is used.
2586
25872) interrupt-parent property
2588----------------------------
2589
2590The interrupt-parent property is specified to define an explicit
2591link between a device node and its interrupt parent in
2592the interrupt tree. The value of interrupt-parent is the
2593phandle of the parent node.
2594
2595If the interrupt-parent property is not defined for a node, it's
2596interrupt parent is assumed to be an ancestor in the node's
2597_device tree_ hierarchy.
2598
25993) OpenPIC Interrupt Controllers
2600--------------------------------
2601
2602OpenPIC interrupt controllers require 2 cells to encode
2603interrupt information. The first cell defines the interrupt
2604number. The second cell defines the sense and level
2605information.
2606
2607Sense and level information should be encoded as follows:
2608
2609 0 = low to high edge sensitive type enabled
2610 1 = active low level sensitive type enabled
2611 2 = active high level sensitive type enabled
2612 3 = high to low edge sensitive type enabled
2613
26144) ISA Interrupt Controllers
2615----------------------------
2616
2617ISA PIC interrupt controllers require 2 cells to encode
2618interrupt information. The first cell defines the interrupt
2619number. The second cell defines the sense and level
2620information.
2621
2622ISA PIC interrupt controllers should adhere to the ISA PIC
2623encodings listed below:
2624
2625 0 = active low level sensitive type enabled
2626 1 = active high level sensitive type enabled
2627 2 = high to low edge sensitive type enabled
2628 3 = low to high edge sensitive type enabled
2629
David Gibsonc125a182006-02-01 03:05:22 -08002630
2631Appendix A - Sample SOC node for MPC8540
2632========================================
2633
2634Note that the #address-cells and #size-cells for the SoC node
2635in this example have been explicitly listed; these are likely
2636not necessary as they are usually the same as the root node.
2637
2638 soc8540@e0000000 {
2639 #address-cells = <1>;
2640 #size-cells = <1>;
2641 #interrupt-cells = <2>;
2642 device_type = "soc";
2643 ranges = <00000000 e0000000 00100000>
2644 reg = <e0000000 00003000>;
Becky Bruce7d4b95a2006-02-06 14:26:31 -06002645 bus-frequency = <0>;
David Gibsonc125a182006-02-01 03:05:22 -08002646
2647 mdio@24520 {
2648 reg = <24520 20>;
2649 device_type = "mdio";
2650 compatible = "gianfar";
2651
2652 ethernet-phy@0 {
2653 linux,phandle = <2452000>
2654 interrupt-parent = <40000>;
2655 interrupts = <35 1>;
2656 reg = <0>;
2657 device_type = "ethernet-phy";
2658 };
2659
2660 ethernet-phy@1 {
2661 linux,phandle = <2452001>
2662 interrupt-parent = <40000>;
2663 interrupts = <35 1>;
2664 reg = <1>;
2665 device_type = "ethernet-phy";
2666 };
2667
2668 ethernet-phy@3 {
2669 linux,phandle = <2452002>
2670 interrupt-parent = <40000>;
2671 interrupts = <35 1>;
2672 reg = <3>;
2673 device_type = "ethernet-phy";
2674 };
2675
2676 };
2677
2678 ethernet@24000 {
2679 #size-cells = <0>;
2680 device_type = "network";
2681 model = "TSEC";
2682 compatible = "gianfar";
2683 reg = <24000 1000>;
Jon Loeligerf5831652006-08-17 08:42:35 -05002684 mac-address = [ 00 E0 0C 00 73 00 ];
David Gibsonc125a182006-02-01 03:05:22 -08002685 interrupts = <d 3 e 3 12 3>;
2686 interrupt-parent = <40000>;
2687 phy-handle = <2452000>;
2688 };
2689
2690 ethernet@25000 {
2691 #address-cells = <1>;
2692 #size-cells = <0>;
2693 device_type = "network";
2694 model = "TSEC";
2695 compatible = "gianfar";
2696 reg = <25000 1000>;
Jon Loeligerf5831652006-08-17 08:42:35 -05002697 mac-address = [ 00 E0 0C 00 73 01 ];
David Gibsonc125a182006-02-01 03:05:22 -08002698 interrupts = <13 3 14 3 18 3>;
2699 interrupt-parent = <40000>;
2700 phy-handle = <2452001>;
2701 };
2702
2703 ethernet@26000 {
2704 #address-cells = <1>;
2705 #size-cells = <0>;
2706 device_type = "network";
2707 model = "FEC";
2708 compatible = "gianfar";
2709 reg = <26000 1000>;
Jon Loeligerf5831652006-08-17 08:42:35 -05002710 mac-address = [ 00 E0 0C 00 73 02 ];
David Gibsonc125a182006-02-01 03:05:22 -08002711 interrupts = <19 3>;
2712 interrupt-parent = <40000>;
2713 phy-handle = <2452002>;
2714 };
2715
2716 serial@4500 {
2717 device_type = "serial";
2718 compatible = "ns16550";
2719 reg = <4500 100>;
2720 clock-frequency = <0>;
2721 interrupts = <1a 3>;
2722 interrupt-parent = <40000>;
2723 };
2724
2725 pic@40000 {
2726 linux,phandle = <40000>;
2727 clock-frequency = <0>;
2728 interrupt-controller;
2729 #address-cells = <0>;
2730 reg = <40000 40000>;
2731 built-in;
2732 compatible = "chrp,open-pic";
2733 device_type = "open-pic";
2734 big-endian;
2735 };
2736
2737 i2c@3000 {
2738 interrupt-parent = <40000>;
2739 interrupts = <1b 3>;
2740 reg = <3000 18>;
2741 device_type = "i2c";
2742 compatible = "fsl-i2c";
2743 dfsrr;
2744 };
2745
2746 };