booting-without-of.txt 62 KB

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