booting-without-of.txt 59 KB

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