booting-without-of.txt 58 KB

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