booting-without-of.txt 100 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721
  1. Booting the Linux/ppc kernel without Open Firmware
  2. --------------------------------------------------
  3. (c) 2005 Benjamin Herrenschmidt <benh at kernel.crashing.org>,
  4. IBM Corp.
  5. (c) 2005 Becky Bruce <becky.bruce at freescale.com>,
  6. Freescale Semiconductor, FSL SOC and 32-bit additions
  7. (c) 2006 MontaVista Software, Inc.
  8. Flash chip node definition
  9. Table of Contents
  10. =================
  11. I - Introduction
  12. 1) Entry point for arch/powerpc
  13. 2) Board support
  14. II - The DT block format
  15. 1) Header
  16. 2) Device tree generalities
  17. 3) Device tree "structure" block
  18. 4) Device tree "strings" block
  19. III - Required content of the device tree
  20. 1) Note about cells and address representation
  21. 2) Note about "compatible" properties
  22. 3) Note about "name" properties
  23. 4) Note about node and property names and character set
  24. 5) Required nodes and properties
  25. a) The root node
  26. b) The /cpus node
  27. c) The /cpus/* nodes
  28. d) the /memory node(s)
  29. e) The /chosen node
  30. f) the /soc<SOCname> node
  31. IV - "dtc", the device tree compiler
  32. V - Recommendations for a bootloader
  33. VI - System-on-a-chip devices and nodes
  34. 1) Defining child nodes of an SOC
  35. 2) Representing devices without a current OF specification
  36. a) MDIO IO device
  37. b) Gianfar-compatible ethernet nodes
  38. c) PHY nodes
  39. d) Interrupt controllers
  40. e) I2C
  41. f) Freescale SOC USB controllers
  42. g) Freescale SOC SEC Security Engines
  43. h) Board Control and Status (BCSR)
  44. i) Freescale QUICC Engine module (QE)
  45. j) CFI or JEDEC memory-mapped NOR flash
  46. k) Global Utilities Block
  47. l) Xilinx IP cores
  48. VII - Specifying interrupt information for devices
  49. 1) interrupts property
  50. 2) interrupt-parent property
  51. 3) OpenPIC Interrupt Controllers
  52. 4) ISA Interrupt Controllers
  53. Appendix A - Sample SOC node for MPC8540
  54. Revision Information
  55. ====================
  56. May 18, 2005: Rev 0.1 - Initial draft, no chapter III yet.
  57. May 19, 2005: Rev 0.2 - Add chapter III and bits & pieces here or
  58. clarifies the fact that a lot of things are
  59. optional, the kernel only requires a very
  60. small device tree, though it is encouraged
  61. to provide an as complete one as possible.
  62. May 24, 2005: Rev 0.3 - Precise that DT block has to be in RAM
  63. - Misc fixes
  64. - Define version 3 and new format version 16
  65. for the DT block (version 16 needs kernel
  66. patches, will be fwd separately).
  67. String block now has a size, and full path
  68. is replaced by unit name for more
  69. compactness.
  70. linux,phandle is made optional, only nodes
  71. that are referenced by other nodes need it.
  72. "name" property is now automatically
  73. deduced from the unit name
  74. June 1, 2005: Rev 0.4 - Correct confusion between OF_DT_END and
  75. OF_DT_END_NODE in structure definition.
  76. - Change version 16 format to always align
  77. property data to 4 bytes. Since tokens are
  78. already aligned, that means no specific
  79. required alignment between property size
  80. and property data. The old style variable
  81. alignment would make it impossible to do
  82. "simple" insertion of properties using
  83. memmove (thanks Milton for
  84. noticing). Updated kernel patch as well
  85. - Correct a few more alignment constraints
  86. - Add a chapter about the device-tree
  87. compiler and the textural representation of
  88. the tree that can be "compiled" by dtc.
  89. November 21, 2005: Rev 0.5
  90. - Additions/generalizations for 32-bit
  91. - Changed to reflect the new arch/powerpc
  92. structure
  93. - Added chapter VI
  94. ToDo:
  95. - Add some definitions of interrupt tree (simple/complex)
  96. - Add some definitions for PCI host bridges
  97. - Add some common address format examples
  98. - Add definitions for standard properties and "compatible"
  99. names for cells that are not already defined by the existing
  100. OF spec.
  101. - Compare FSL SOC use of PCI to standard and make sure no new
  102. node definition required.
  103. - Add more information about node definitions for SOC devices
  104. that currently have no standard, like the FSL CPM.
  105. I - Introduction
  106. ================
  107. During the recent development of the Linux/ppc64 kernel, and more
  108. specifically, the addition of new platform types outside of the old
  109. IBM pSeries/iSeries pair, it was decided to enforce some strict rules
  110. regarding the kernel entry and bootloader <-> kernel interfaces, in
  111. order to avoid the degeneration that had become the ppc32 kernel entry
  112. point and the way a new platform should be added to the kernel. The
  113. legacy iSeries platform breaks those rules as it predates this scheme,
  114. but no new board support will be accepted in the main tree that
  115. doesn't follows them properly. In addition, since the advent of the
  116. arch/powerpc merged architecture for ppc32 and ppc64, new 32-bit
  117. platforms and 32-bit platforms which move into arch/powerpc will be
  118. required to use these rules as well.
  119. The main requirement that will be defined in more detail below is
  120. the presence of a device-tree whose format is defined after Open
  121. Firmware specification. However, in order to make life easier
  122. to embedded board vendors, the kernel doesn't require the device-tree
  123. to represent every device in the system and only requires some nodes
  124. and properties to be present. This will be described in detail in
  125. section III, but, for example, the kernel does not require you to
  126. create a node for every PCI device in the system. It is a requirement
  127. to have a node for PCI host bridges in order to provide interrupt
  128. routing informations and memory/IO ranges, among others. It is also
  129. recommended to define nodes for on chip devices and other busses that
  130. don't specifically fit in an existing OF specification. This creates a
  131. great flexibility in the way the kernel can then probe those and match
  132. drivers to device, without having to hard code all sorts of tables. It
  133. also makes it more flexible for board vendors to do minor hardware
  134. upgrades without significantly impacting the kernel code or cluttering
  135. it with special cases.
  136. 1) Entry point for arch/powerpc
  137. -------------------------------
  138. There is one and one single entry point to the kernel, at the start
  139. of the kernel image. That entry point supports two calling
  140. conventions:
  141. a) Boot from Open Firmware. If your firmware is compatible
  142. with Open Firmware (IEEE 1275) or provides an OF compatible
  143. client interface API (support for "interpret" callback of
  144. forth words isn't required), you can enter the kernel with:
  145. r5 : OF callback pointer as defined by IEEE 1275
  146. bindings to powerpc. Only the 32-bit client interface
  147. is currently supported
  148. r3, r4 : address & length of an initrd if any or 0
  149. The MMU is either on or off; the kernel will run the
  150. trampoline located in arch/powerpc/kernel/prom_init.c to
  151. extract the device-tree and other information from open
  152. firmware and build a flattened device-tree as described
  153. in b). prom_init() will then re-enter the kernel using
  154. the second method. This trampoline code runs in the
  155. context of the firmware, which is supposed to handle all
  156. exceptions during that time.
  157. b) Direct entry with a flattened device-tree block. This entry
  158. point is called by a) after the OF trampoline and can also be
  159. called directly by a bootloader that does not support the Open
  160. Firmware client interface. It is also used by "kexec" to
  161. implement "hot" booting of a new kernel from a previous
  162. running one. This method is what I will describe in more
  163. details in this document, as method a) is simply standard Open
  164. Firmware, and thus should be implemented according to the
  165. various standard documents defining it and its binding to the
  166. PowerPC platform. The entry point definition then becomes:
  167. r3 : physical pointer to the device-tree block
  168. (defined in chapter II) in RAM
  169. r4 : physical pointer to the kernel itself. This is
  170. used by the assembly code to properly disable the MMU
  171. in case you are entering the kernel with MMU enabled
  172. and a non-1:1 mapping.
  173. r5 : NULL (as to differentiate with method a)
  174. Note about SMP entry: Either your firmware puts your other
  175. CPUs in some sleep loop or spin loop in ROM where you can get
  176. them out via a soft reset or some other means, in which case
  177. you don't need to care, or you'll have to enter the kernel
  178. with all CPUs. The way to do that with method b) will be
  179. described in a later revision of this document.
  180. 2) Board support
  181. ----------------
  182. 64-bit kernels:
  183. Board supports (platforms) are not exclusive config options. An
  184. arbitrary set of board supports can be built in a single kernel
  185. image. The kernel will "know" what set of functions to use for a
  186. given platform based on the content of the device-tree. Thus, you
  187. should:
  188. a) add your platform support as a _boolean_ option in
  189. arch/powerpc/Kconfig, following the example of PPC_PSERIES,
  190. PPC_PMAC and PPC_MAPLE. The later is probably a good
  191. example of a board support to start from.
  192. b) create your main platform file as
  193. "arch/powerpc/platforms/myplatform/myboard_setup.c" and add it
  194. to the Makefile under the condition of your CONFIG_
  195. option. This file will define a structure of type "ppc_md"
  196. containing the various callbacks that the generic code will
  197. use to get to your platform specific code
  198. c) Add a reference to your "ppc_md" structure in the
  199. "machines" table in arch/powerpc/kernel/setup_64.c if you are
  200. a 64-bit platform.
  201. d) request and get assigned a platform number (see PLATFORM_*
  202. constants in include/asm-powerpc/processor.h
  203. 32-bit embedded kernels:
  204. Currently, board support is essentially an exclusive config option.
  205. The kernel is configured for a single platform. Part of the reason
  206. for this is to keep kernels on embedded systems small and efficient;
  207. part of this is due to the fact the code is already that way. In the
  208. future, a kernel may support multiple platforms, but only if the
  209. platforms feature the same core architecture. A single kernel build
  210. cannot support both configurations with Book E and configurations
  211. with classic Powerpc architectures.
  212. 32-bit embedded platforms that are moved into arch/powerpc using a
  213. flattened device tree should adopt the merged tree practice of
  214. setting ppc_md up dynamically, even though the kernel is currently
  215. built with support for only a single platform at a time. This allows
  216. unification of the setup code, and will make it easier to go to a
  217. multiple-platform-support model in the future.
  218. NOTE: I believe the above will be true once Ben's done with the merge
  219. of the boot sequences.... someone speak up if this is wrong!
  220. To add a 32-bit embedded platform support, follow the instructions
  221. for 64-bit platforms above, with the exception that the Kconfig
  222. option should be set up such that the kernel builds exclusively for
  223. the platform selected. The processor type for the platform should
  224. enable another config option to select the specific board
  225. supported.
  226. NOTE: If Ben doesn't merge the setup files, may need to change this to
  227. point to setup_32.c
  228. I will describe later the boot process and various callbacks that
  229. your platform should implement.
  230. II - The DT block format
  231. ========================
  232. This chapter defines the actual format of the flattened device-tree
  233. passed to the kernel. The actual content of it and kernel requirements
  234. are described later. You can find example of code manipulating that
  235. format in various places, including arch/powerpc/kernel/prom_init.c
  236. which will generate a flattened device-tree from the Open Firmware
  237. representation, or the fs2dt utility which is part of the kexec tools
  238. which will generate one from a filesystem representation. It is
  239. expected that a bootloader like uboot provides a bit more support,
  240. that will be discussed later as well.
  241. Note: The block has to be in main memory. It has to be accessible in
  242. both real mode and virtual mode with no mapping other than main
  243. memory. If you are writing a simple flash bootloader, it should copy
  244. the block to RAM before passing it to the kernel.
  245. 1) Header
  246. ---------
  247. The kernel is entered with r3 pointing to an area of memory that is
  248. roughly described in include/asm-powerpc/prom.h by the structure
  249. boot_param_header:
  250. struct boot_param_header {
  251. u32 magic; /* magic word OF_DT_HEADER */
  252. u32 totalsize; /* total size of DT block */
  253. u32 off_dt_struct; /* offset to structure */
  254. u32 off_dt_strings; /* offset to strings */
  255. u32 off_mem_rsvmap; /* offset to memory reserve map
  256. */
  257. u32 version; /* format version */
  258. u32 last_comp_version; /* last compatible version */
  259. /* version 2 fields below */
  260. u32 boot_cpuid_phys; /* Which physical CPU id we're
  261. booting on */
  262. /* version 3 fields below */
  263. u32 size_dt_strings; /* size of the strings block */
  264. /* version 17 fields below */
  265. u32 size_dt_struct; /* size of the DT structure block */
  266. };
  267. Along with the constants:
  268. /* Definitions used by the flattened device tree */
  269. #define OF_DT_HEADER 0xd00dfeed /* 4: version,
  270. 4: total size */
  271. #define OF_DT_BEGIN_NODE 0x1 /* Start node: full name
  272. */
  273. #define OF_DT_END_NODE 0x2 /* End node */
  274. #define OF_DT_PROP 0x3 /* Property: name off,
  275. size, content */
  276. #define OF_DT_END 0x9
  277. All values in this header are in big endian format, the various
  278. fields in this header are defined more precisely below. All
  279. "offset" values are in bytes from the start of the header; that is
  280. from the value of r3.
  281. - magic
  282. This is a magic value that "marks" the beginning of the
  283. device-tree block header. It contains the value 0xd00dfeed and is
  284. defined by the constant OF_DT_HEADER
  285. - totalsize
  286. This is the total size of the DT block including the header. The
  287. "DT" block should enclose all data structures defined in this
  288. chapter (who are pointed to by offsets in this header). That is,
  289. the device-tree structure, strings, and the memory reserve map.
  290. - off_dt_struct
  291. This is an offset from the beginning of the header to the start
  292. of the "structure" part the device tree. (see 2) device tree)
  293. - off_dt_strings
  294. This is an offset from the beginning of the header to the start
  295. of the "strings" part of the device-tree
  296. - off_mem_rsvmap
  297. This is an offset from the beginning of the header to the start
  298. of the reserved memory map. This map is a list of pairs of 64-
  299. bit integers. Each pair is a physical address and a size. The
  300. list is terminated by an entry of size 0. This map provides the
  301. kernel with a list of physical memory areas that are "reserved"
  302. and thus not to be used for memory allocations, especially during
  303. early initialization. The kernel needs to allocate memory during
  304. boot for things like un-flattening the device-tree, allocating an
  305. MMU hash table, etc... Those allocations must be done in such a
  306. way to avoid overriding critical things like, on Open Firmware
  307. capable machines, the RTAS instance, or on some pSeries, the TCE
  308. tables used for the iommu. Typically, the reserve map should
  309. contain _at least_ this DT block itself (header,total_size). If
  310. you are passing an initrd to the kernel, you should reserve it as
  311. well. You do not need to reserve the kernel image itself. The map
  312. should be 64-bit aligned.
  313. - version
  314. This is the version of this structure. Version 1 stops
  315. here. Version 2 adds an additional field boot_cpuid_phys.
  316. Version 3 adds the size of the strings block, allowing the kernel
  317. to reallocate it easily at boot and free up the unused flattened
  318. structure after expansion. Version 16 introduces a new more
  319. "compact" format for the tree itself that is however not backward
  320. compatible. Version 17 adds an additional field, size_dt_struct,
  321. allowing it to be reallocated or moved more easily (this is
  322. particularly useful for bootloaders which need to make
  323. adjustments to a device tree based on probed information). You
  324. should always generate a structure of the highest version defined
  325. at the time of your implementation. Currently that is version 17,
  326. unless you explicitly aim at being backward compatible.
  327. - last_comp_version
  328. Last compatible version. This indicates down to what version of
  329. the DT block you are backward compatible. For example, version 2
  330. is backward compatible with version 1 (that is, a kernel build
  331. for version 1 will be able to boot with a version 2 format). You
  332. should put a 1 in this field if you generate a device tree of
  333. version 1 to 3, or 16 if you generate a tree of version 16 or 17
  334. using the new unit name format.
  335. - boot_cpuid_phys
  336. This field only exist on version 2 headers. It indicate which
  337. physical CPU ID is calling the kernel entry point. This is used,
  338. among others, by kexec. If you are on an SMP system, this value
  339. should match the content of the "reg" property of the CPU node in
  340. the device-tree corresponding to the CPU calling the kernel entry
  341. point (see further chapters for more informations on the required
  342. device-tree contents)
  343. - size_dt_strings
  344. This field only exists on version 3 and later headers. It
  345. gives the size of the "strings" section of the device tree (which
  346. starts at the offset given by off_dt_strings).
  347. - size_dt_struct
  348. This field only exists on version 17 and later headers. It gives
  349. the size of the "structure" section of the device tree (which
  350. starts at the offset given by off_dt_struct).
  351. So the typical layout of a DT block (though the various parts don't
  352. need to be in that order) looks like this (addresses go from top to
  353. bottom):
  354. ------------------------------
  355. r3 -> | struct boot_param_header |
  356. ------------------------------
  357. | (alignment gap) (*) |
  358. ------------------------------
  359. | memory reserve map |
  360. ------------------------------
  361. | (alignment gap) |
  362. ------------------------------
  363. | |
  364. | device-tree structure |
  365. | |
  366. ------------------------------
  367. | (alignment gap) |
  368. ------------------------------
  369. | |
  370. | device-tree strings |
  371. | |
  372. -----> ------------------------------
  373. |
  374. |
  375. --- (r3 + totalsize)
  376. (*) The alignment gaps are not necessarily present; their presence
  377. and size are dependent on the various alignment requirements of
  378. the individual data blocks.
  379. 2) Device tree generalities
  380. ---------------------------
  381. This device-tree itself is separated in two different blocks, a
  382. structure block and a strings block. Both need to be aligned to a 4
  383. byte boundary.
  384. First, let's quickly describe the device-tree concept before detailing
  385. the storage format. This chapter does _not_ describe the detail of the
  386. required types of nodes & properties for the kernel, this is done
  387. later in chapter III.
  388. The device-tree layout is strongly inherited from the definition of
  389. the Open Firmware IEEE 1275 device-tree. It's basically a tree of
  390. nodes, each node having two or more named properties. A property can
  391. have a value or not.
  392. It is a tree, so each node has one and only one parent except for the
  393. root node who has no parent.
  394. A node has 2 names. The actual node name is generally contained in a
  395. property of type "name" in the node property list whose value is a
  396. zero terminated string and is mandatory for version 1 to 3 of the
  397. format definition (as it is in Open Firmware). Version 16 makes it
  398. optional as it can generate it from the unit name defined below.
  399. There is also a "unit name" that is used to differentiate nodes with
  400. the same name at the same level, it is usually made of the node
  401. names, the "@" sign, and a "unit address", which definition is
  402. specific to the bus type the node sits on.
  403. The unit name doesn't exist as a property per-se but is included in
  404. the device-tree structure. It is typically used to represent "path" in
  405. the device-tree. More details about the actual format of these will be
  406. below.
  407. The kernel powerpc generic code does not make any formal use of the
  408. unit address (though some board support code may do) so the only real
  409. requirement here for the unit address is to ensure uniqueness of
  410. the node unit name at a given level of the tree. Nodes with no notion
  411. of address and no possible sibling of the same name (like /memory or
  412. /cpus) may omit the unit address in the context of this specification,
  413. or use the "@0" default unit address. The unit name is used to define
  414. a node "full path", which is the concatenation of all parent node
  415. unit names separated with "/".
  416. The root node doesn't have a defined name, and isn't required to have
  417. a name property either if you are using version 3 or earlier of the
  418. format. It also has no unit address (no @ symbol followed by a unit
  419. address). The root node unit name is thus an empty string. The full
  420. path to the root node is "/".
  421. Every node which actually represents an actual device (that is, a node
  422. which isn't only a virtual "container" for more nodes, like "/cpus"
  423. is) is also required to have a "device_type" property indicating the
  424. type of node .
  425. Finally, every node that can be referenced from a property in another
  426. node is required to have a "linux,phandle" property. Real open
  427. firmware implementations provide a unique "phandle" value for every
  428. node that the "prom_init()" trampoline code turns into
  429. "linux,phandle" properties. However, this is made optional if the
  430. flattened device tree is used directly. An example of a node
  431. referencing another node via "phandle" is when laying out the
  432. interrupt tree which will be described in a further version of this
  433. document.
  434. This "linux, phandle" property is a 32-bit value that uniquely
  435. identifies a node. You are free to use whatever values or system of
  436. values, internal pointers, or whatever to generate these, the only
  437. requirement is that every node for which you provide that property has
  438. a unique value for it.
  439. Here is an example of a simple device-tree. In this example, an "o"
  440. designates a node followed by the node unit name. Properties are
  441. presented with their name followed by their content. "content"
  442. represents an ASCII string (zero terminated) value, while <content>
  443. represents a 32-bit hexadecimal value. The various nodes in this
  444. example will be discussed in a later chapter. At this point, it is
  445. only meant to give you a idea of what a device-tree looks like. I have
  446. purposefully kept the "name" and "linux,phandle" properties which
  447. aren't necessary in order to give you a better idea of what the tree
  448. looks like in practice.
  449. / o device-tree
  450. |- name = "device-tree"
  451. |- model = "MyBoardName"
  452. |- compatible = "MyBoardFamilyName"
  453. |- #address-cells = <2>
  454. |- #size-cells = <2>
  455. |- linux,phandle = <0>
  456. |
  457. o cpus
  458. | | - name = "cpus"
  459. | | - linux,phandle = <1>
  460. | | - #address-cells = <1>
  461. | | - #size-cells = <0>
  462. | |
  463. | o PowerPC,970@0
  464. | |- name = "PowerPC,970"
  465. | |- device_type = "cpu"
  466. | |- reg = <0>
  467. | |- clock-frequency = <5f5e1000>
  468. | |- 64-bit
  469. | |- linux,phandle = <2>
  470. |
  471. o memory@0
  472. | |- name = "memory"
  473. | |- device_type = "memory"
  474. | |- reg = <00000000 00000000 00000000 20000000>
  475. | |- linux,phandle = <3>
  476. |
  477. o chosen
  478. |- name = "chosen"
  479. |- bootargs = "root=/dev/sda2"
  480. |- linux,phandle = <4>
  481. This tree is almost a minimal tree. It pretty much contains the
  482. minimal set of required nodes and properties to boot a linux kernel;
  483. that is, some basic model informations at the root, the CPUs, and the
  484. physical memory layout. It also includes misc information passed
  485. through /chosen, like in this example, the platform type (mandatory)
  486. and the kernel command line arguments (optional).
  487. The /cpus/PowerPC,970@0/64-bit property is an example of a
  488. property without a value. All other properties have a value. The
  489. significance of the #address-cells and #size-cells properties will be
  490. explained in chapter IV which defines precisely the required nodes and
  491. properties and their content.
  492. 3) Device tree "structure" block
  493. The structure of the device tree is a linearized tree structure. The
  494. "OF_DT_BEGIN_NODE" token starts a new node, and the "OF_DT_END_NODE"
  495. ends that node definition. Child nodes are simply defined before
  496. "OF_DT_END_NODE" (that is nodes within the node). A 'token' is a 32
  497. bit value. The tree has to be "finished" with a OF_DT_END token
  498. Here's the basic structure of a single node:
  499. * token OF_DT_BEGIN_NODE (that is 0x00000001)
  500. * for version 1 to 3, this is the node full path as a zero
  501. terminated string, starting with "/". For version 16 and later,
  502. this is the node unit name only (or an empty string for the
  503. root node)
  504. * [align gap to next 4 bytes boundary]
  505. * for each property:
  506. * token OF_DT_PROP (that is 0x00000003)
  507. * 32-bit value of property value size in bytes (or 0 if no
  508. value)
  509. * 32-bit value of offset in string block of property name
  510. * property value data if any
  511. * [align gap to next 4 bytes boundary]
  512. * [child nodes if any]
  513. * token OF_DT_END_NODE (that is 0x00000002)
  514. So the node content can be summarized as a start token, a full path,
  515. a list of properties, a list of child nodes, and an end token. Every
  516. child node is a full node structure itself as defined above.
  517. NOTE: The above definition requires that all property definitions for
  518. a particular node MUST precede any subnode definitions for that node.
  519. Although the structure would not be ambiguous if properties and
  520. subnodes were intermingled, the kernel parser requires that the
  521. properties come first (up until at least 2.6.22). Any tools
  522. manipulating a flattened tree must take care to preserve this
  523. constraint.
  524. 4) Device tree "strings" block
  525. In order to save space, property names, which are generally redundant,
  526. are stored separately in the "strings" block. This block is simply the
  527. whole bunch of zero terminated strings for all property names
  528. concatenated together. The device-tree property definitions in the
  529. structure block will contain offset values from the beginning of the
  530. strings block.
  531. III - Required content of the device tree
  532. =========================================
  533. WARNING: All "linux,*" properties defined in this document apply only
  534. to a flattened device-tree. If your platform uses a real
  535. implementation of Open Firmware or an implementation compatible with
  536. the Open Firmware client interface, those properties will be created
  537. by the trampoline code in the kernel's prom_init() file. For example,
  538. that's where you'll have to add code to detect your board model and
  539. set the platform number. However, when using the flattened device-tree
  540. entry point, there is no prom_init() pass, and thus you have to
  541. provide those properties yourself.
  542. 1) Note about cells and address representation
  543. ----------------------------------------------
  544. The general rule is documented in the various Open Firmware
  545. documentations. If you choose to describe a bus with the device-tree
  546. and there exist an OF bus binding, then you should follow the
  547. specification. However, the kernel does not require every single
  548. device or bus to be described by the device tree.
  549. In general, the format of an address for a device is defined by the
  550. parent bus type, based on the #address-cells and #size-cells
  551. property. In the absence of such a property, the parent's parent
  552. values are used, etc... The kernel requires the root node to have
  553. those properties defining addresses format for devices directly mapped
  554. on the processor bus.
  555. Those 2 properties define 'cells' for representing an address and a
  556. size. A "cell" is a 32-bit number. For example, if both contain 2
  557. like the example tree given above, then an address and a size are both
  558. composed of 2 cells, and each is a 64-bit number (cells are
  559. concatenated and expected to be in big endian format). Another example
  560. is the way Apple firmware defines them, with 2 cells for an address
  561. and one cell for a size. Most 32-bit implementations should define
  562. #address-cells and #size-cells to 1, which represents a 32-bit value.
  563. Some 32-bit processors allow for physical addresses greater than 32
  564. bits; these processors should define #address-cells as 2.
  565. "reg" properties are always a tuple of the type "address size" where
  566. the number of cells of address and size is specified by the bus
  567. #address-cells and #size-cells. When a bus supports various address
  568. spaces and other flags relative to a given address allocation (like
  569. prefetchable, etc...) those flags are usually added to the top level
  570. bits of the physical address. For example, a PCI physical address is
  571. made of 3 cells, the bottom two containing the actual address itself
  572. while the top cell contains address space indication, flags, and pci
  573. bus & device numbers.
  574. For busses that support dynamic allocation, it's the accepted practice
  575. to then not provide the address in "reg" (keep it 0) though while
  576. providing a flag indicating the address is dynamically allocated, and
  577. then, to provide a separate "assigned-addresses" property that
  578. contains the fully allocated addresses. See the PCI OF bindings for
  579. details.
  580. In general, a simple bus with no address space bits and no dynamic
  581. allocation is preferred if it reflects your hardware, as the existing
  582. kernel address parsing functions will work out of the box. If you
  583. define a bus type with a more complex address format, including things
  584. like address space bits, you'll have to add a bus translator to the
  585. prom_parse.c file of the recent kernels for your bus type.
  586. The "reg" property only defines addresses and sizes (if #size-cells
  587. is non-0) within a given bus. In order to translate addresses upward
  588. (that is into parent bus addresses, and possibly into CPU physical
  589. addresses), all busses must contain a "ranges" property. If the
  590. "ranges" property is missing at a given level, it's assumed that
  591. translation isn't possible. The format of the "ranges" property for a
  592. bus is a list of:
  593. bus address, parent bus address, size
  594. "bus address" is in the format of the bus this bus node is defining,
  595. that is, for a PCI bridge, it would be a PCI address. Thus, (bus
  596. address, size) defines a range of addresses for child devices. "parent
  597. bus address" is in the format of the parent bus of this bus. For
  598. example, for a PCI host controller, that would be a CPU address. For a
  599. PCI<->ISA bridge, that would be a PCI address. It defines the base
  600. address in the parent bus where the beginning of that range is mapped.
  601. For a new 64-bit powerpc board, I recommend either the 2/2 format or
  602. Apple's 2/1 format which is slightly more compact since sizes usually
  603. fit in a single 32-bit word. New 32-bit powerpc boards should use a
  604. 1/1 format, unless the processor supports physical addresses greater
  605. than 32-bits, in which case a 2/1 format is recommended.
  606. 2) Note about "compatible" properties
  607. -------------------------------------
  608. These properties are optional, but recommended in devices and the root
  609. node. The format of a "compatible" property is a list of concatenated
  610. zero terminated strings. They allow a device to express its
  611. compatibility with a family of similar devices, in some cases,
  612. allowing a single driver to match against several devices regardless
  613. of their actual names.
  614. 3) Note about "name" properties
  615. -------------------------------
  616. While earlier users of Open Firmware like OldWorld macintoshes tended
  617. to use the actual device name for the "name" property, it's nowadays
  618. considered a good practice to use a name that is closer to the device
  619. class (often equal to device_type). For example, nowadays, ethernet
  620. controllers are named "ethernet", an additional "model" property
  621. defining precisely the chip type/model, and "compatible" property
  622. defining the family in case a single driver can driver more than one
  623. of these chips. However, the kernel doesn't generally put any
  624. restriction on the "name" property; it is simply considered good
  625. practice to follow the standard and its evolutions as closely as
  626. possible.
  627. Note also that the new format version 16 makes the "name" property
  628. optional. If it's absent for a node, then the node's unit name is then
  629. used to reconstruct the name. That is, the part of the unit name
  630. before the "@" sign is used (or the entire unit name if no "@" sign
  631. is present).
  632. 4) Note about node and property names and character set
  633. -------------------------------------------------------
  634. While open firmware provides more flexible usage of 8859-1, this
  635. specification enforces more strict rules. Nodes and properties should
  636. be comprised only of ASCII characters 'a' to 'z', '0' to
  637. '9', ',', '.', '_', '+', '#', '?', and '-'. Node names additionally
  638. allow uppercase characters 'A' to 'Z' (property names should be
  639. lowercase. The fact that vendors like Apple don't respect this rule is
  640. irrelevant here). Additionally, node and property names should always
  641. begin with a character in the range 'a' to 'z' (or 'A' to 'Z' for node
  642. names).
  643. The maximum number of characters for both nodes and property names
  644. is 31. In the case of node names, this is only the leftmost part of
  645. a unit name (the pure "name" property), it doesn't include the unit
  646. address which can extend beyond that limit.
  647. 5) Required nodes and properties
  648. --------------------------------
  649. These are all that are currently required. However, it is strongly
  650. recommended that you expose PCI host bridges as documented in the
  651. PCI binding to open firmware, and your interrupt tree as documented
  652. in OF interrupt tree specification.
  653. a) The root node
  654. The root node requires some properties to be present:
  655. - model : this is your board name/model
  656. - #address-cells : address representation for "root" devices
  657. - #size-cells: the size representation for "root" devices
  658. - device_type : This property shouldn't be necessary. However, if
  659. you decide to create a device_type for your root node, make sure it
  660. is _not_ "chrp" unless your platform is a pSeries or PAPR compliant
  661. one for 64-bit, or a CHRP-type machine for 32-bit as this will
  662. matched by the kernel this way.
  663. Additionally, some recommended properties are:
  664. - compatible : the board "family" generally finds its way here,
  665. for example, if you have 2 board models with a similar layout,
  666. that typically get driven by the same platform code in the
  667. kernel, you would use a different "model" property but put a
  668. value in "compatible". The kernel doesn't directly use that
  669. value but it is generally useful.
  670. The root node is also generally where you add additional properties
  671. specific to your board like the serial number if any, that sort of
  672. thing. It is recommended that if you add any "custom" property whose
  673. name may clash with standard defined ones, you prefix them with your
  674. vendor name and a comma.
  675. b) The /cpus node
  676. This node is the parent of all individual CPU nodes. It doesn't
  677. have any specific requirements, though it's generally good practice
  678. to have at least:
  679. #address-cells = <00000001>
  680. #size-cells = <00000000>
  681. This defines that the "address" for a CPU is a single cell, and has
  682. no meaningful size. This is not necessary but the kernel will assume
  683. that format when reading the "reg" properties of a CPU node, see
  684. below
  685. c) The /cpus/* nodes
  686. So under /cpus, you are supposed to create a node for every CPU on
  687. the machine. There is no specific restriction on the name of the
  688. CPU, though It's common practice to call it PowerPC,<name>. For
  689. example, Apple uses PowerPC,G5 while IBM uses PowerPC,970FX.
  690. Required properties:
  691. - device_type : has to be "cpu"
  692. - reg : This is the physical CPU number, it's a single 32-bit cell
  693. and is also used as-is as the unit number for constructing the
  694. unit name in the full path. For example, with 2 CPUs, you would
  695. have the full path:
  696. /cpus/PowerPC,970FX@0
  697. /cpus/PowerPC,970FX@1
  698. (unit addresses do not require leading zeroes)
  699. - d-cache-block-size : one cell, L1 data cache block size in bytes (*)
  700. - i-cache-block-size : one cell, L1 instruction cache block size in
  701. bytes
  702. - d-cache-size : one cell, size of L1 data cache in bytes
  703. - i-cache-size : one cell, size of L1 instruction cache in bytes
  704. (*) The cache "block" size is the size on which the cache management
  705. instructions operate. Historically, this document used the cache
  706. "line" size here which is incorrect. The kernel will prefer the cache
  707. block size and will fallback to cache line size for backward
  708. compatibility.
  709. Recommended properties:
  710. - timebase-frequency : a cell indicating the frequency of the
  711. timebase in Hz. This is not directly used by the generic code,
  712. but you are welcome to copy/paste the pSeries code for setting
  713. the kernel timebase/decrementer calibration based on this
  714. value.
  715. - clock-frequency : a cell indicating the CPU core clock frequency
  716. in Hz. A new property will be defined for 64-bit values, but if
  717. your frequency is < 4Ghz, one cell is enough. Here as well as
  718. for the above, the common code doesn't use that property, but
  719. you are welcome to re-use the pSeries or Maple one. A future
  720. kernel version might provide a common function for this.
  721. - d-cache-line-size : one cell, L1 data cache line size in bytes
  722. if different from the block size
  723. - i-cache-line-size : one cell, L1 instruction cache line size in
  724. bytes if different from the block size
  725. You are welcome to add any property you find relevant to your board,
  726. like some information about the mechanism used to soft-reset the
  727. CPUs. For example, Apple puts the GPIO number for CPU soft reset
  728. lines in there as a "soft-reset" property since they start secondary
  729. CPUs by soft-resetting them.
  730. d) the /memory node(s)
  731. To define the physical memory layout of your board, you should
  732. create one or more memory node(s). You can either create a single
  733. node with all memory ranges in its reg property, or you can create
  734. several nodes, as you wish. The unit address (@ part) used for the
  735. full path is the address of the first range of memory defined by a
  736. given node. If you use a single memory node, this will typically be
  737. @0.
  738. Required properties:
  739. - device_type : has to be "memory"
  740. - reg : This property contains all the physical memory ranges of
  741. your board. It's a list of addresses/sizes concatenated
  742. together, with the number of cells of each defined by the
  743. #address-cells and #size-cells of the root node. For example,
  744. with both of these properties being 2 like in the example given
  745. earlier, a 970 based machine with 6Gb of RAM could typically
  746. have a "reg" property here that looks like:
  747. 00000000 00000000 00000000 80000000
  748. 00000001 00000000 00000001 00000000
  749. That is a range starting at 0 of 0x80000000 bytes and a range
  750. starting at 0x100000000 and of 0x100000000 bytes. You can see
  751. that there is no memory covering the IO hole between 2Gb and
  752. 4Gb. Some vendors prefer splitting those ranges into smaller
  753. segments, but the kernel doesn't care.
  754. e) The /chosen node
  755. This node is a bit "special". Normally, that's where open firmware
  756. puts some variable environment information, like the arguments, or
  757. the default input/output devices.
  758. This specification makes a few of these mandatory, but also defines
  759. some linux-specific properties that would be normally constructed by
  760. the prom_init() trampoline when booting with an OF client interface,
  761. but that you have to provide yourself when using the flattened format.
  762. Recommended properties:
  763. - bootargs : This zero-terminated string is passed as the kernel
  764. command line
  765. - linux,stdout-path : This is the full path to your standard
  766. console device if any. Typically, if you have serial devices on
  767. your board, you may want to put the full path to the one set as
  768. the default console in the firmware here, for the kernel to pick
  769. it up as its own default console. If you look at the function
  770. set_preferred_console() in arch/ppc64/kernel/setup.c, you'll see
  771. that the kernel tries to find out the default console and has
  772. knowledge of various types like 8250 serial ports. You may want
  773. to extend this function to add your own.
  774. Note that u-boot creates and fills in the chosen node for platforms
  775. that use it.
  776. (Note: a practice that is now obsolete was to include a property
  777. under /chosen called interrupt-controller which had a phandle value
  778. that pointed to the main interrupt controller)
  779. f) the /soc<SOCname> node
  780. This node is used to represent a system-on-a-chip (SOC) and must be
  781. present if the processor is a SOC. The top-level soc node contains
  782. information that is global to all devices on the SOC. The node name
  783. should contain a unit address for the SOC, which is the base address
  784. of the memory-mapped register set for the SOC. The name of an soc
  785. node should start with "soc", and the remainder of the name should
  786. represent the part number for the soc. For example, the MPC8540's
  787. soc node would be called "soc8540".
  788. Required properties:
  789. - device_type : Should be "soc"
  790. - ranges : Should be defined as specified in 1) to describe the
  791. translation of SOC addresses for memory mapped SOC registers.
  792. - bus-frequency: Contains the bus frequency for the SOC node.
  793. Typically, the value of this field is filled in by the boot
  794. loader.
  795. Recommended properties:
  796. - reg : This property defines the address and size of the
  797. memory-mapped registers that are used for the SOC node itself.
  798. It does not include the child device registers - these will be
  799. defined inside each child node. The address specified in the
  800. "reg" property should match the unit address of the SOC node.
  801. - #address-cells : Address representation for "soc" devices. The
  802. format of this field may vary depending on whether or not the
  803. device registers are memory mapped. For memory mapped
  804. registers, this field represents the number of cells needed to
  805. represent the address of the registers. For SOCs that do not
  806. use MMIO, a special address format should be defined that
  807. contains enough cells to represent the required information.
  808. See 1) above for more details on defining #address-cells.
  809. - #size-cells : Size representation for "soc" devices
  810. - #interrupt-cells : Defines the width of cells used to represent
  811. interrupts. Typically this value is <2>, which includes a
  812. 32-bit number that represents the interrupt number, and a
  813. 32-bit number that represents the interrupt sense and level.
  814. This field is only needed if the SOC contains an interrupt
  815. controller.
  816. The SOC node may contain child nodes for each SOC device that the
  817. platform uses. Nodes should not be created for devices which exist
  818. on the SOC but are not used by a particular platform. See chapter VI
  819. for more information on how to specify devices that are part of a SOC.
  820. Example SOC node for the MPC8540:
  821. soc8540@e0000000 {
  822. #address-cells = <1>;
  823. #size-cells = <1>;
  824. #interrupt-cells = <2>;
  825. device_type = "soc";
  826. ranges = <00000000 e0000000 00100000>
  827. reg = <e0000000 00003000>;
  828. bus-frequency = <0>;
  829. }
  830. IV - "dtc", the device tree compiler
  831. ====================================
  832. dtc source code can be found at
  833. <http://ozlabs.org/~dgibson/dtc/dtc.tar.gz>
  834. WARNING: This version is still in early development stage; the
  835. resulting device-tree "blobs" have not yet been validated with the
  836. kernel. The current generated bloc lacks a useful reserve map (it will
  837. be fixed to generate an empty one, it's up to the bootloader to fill
  838. it up) among others. The error handling needs work, bugs are lurking,
  839. etc...
  840. dtc basically takes a device-tree in a given format and outputs a
  841. device-tree in another format. The currently supported formats are:
  842. Input formats:
  843. -------------
  844. - "dtb": "blob" format, that is a flattened device-tree block
  845. with
  846. header all in a binary blob.
  847. - "dts": "source" format. This is a text file containing a
  848. "source" for a device-tree. The format is defined later in this
  849. chapter.
  850. - "fs" format. This is a representation equivalent to the
  851. output of /proc/device-tree, that is nodes are directories and
  852. properties are files
  853. Output formats:
  854. ---------------
  855. - "dtb": "blob" format
  856. - "dts": "source" format
  857. - "asm": assembly language file. This is a file that can be
  858. sourced by gas to generate a device-tree "blob". That file can
  859. then simply be added to your Makefile. Additionally, the
  860. assembly file exports some symbols that can be used.
  861. The syntax of the dtc tool is
  862. dtc [-I <input-format>] [-O <output-format>]
  863. [-o output-filename] [-V output_version] input_filename
  864. The "output_version" defines what version of the "blob" format will be
  865. generated. Supported versions are 1,2,3 and 16. The default is
  866. currently version 3 but that may change in the future to version 16.
  867. Additionally, dtc performs various sanity checks on the tree, like the
  868. uniqueness of linux, phandle properties, validity of strings, etc...
  869. The format of the .dts "source" file is "C" like, supports C and C++
  870. style comments.
  871. / {
  872. }
  873. The above is the "device-tree" definition. It's the only statement
  874. supported currently at the toplevel.
  875. / {
  876. property1 = "string_value"; /* define a property containing a 0
  877. * terminated string
  878. */
  879. property2 = <1234abcd>; /* define a property containing a
  880. * numerical 32-bit value (hexadecimal)
  881. */
  882. property3 = <12345678 12345678 deadbeef>;
  883. /* define a property containing 3
  884. * numerical 32-bit values (cells) in
  885. * hexadecimal
  886. */
  887. property4 = [0a 0b 0c 0d de ea ad be ef];
  888. /* define a property whose content is
  889. * an arbitrary array of bytes
  890. */
  891. childnode@addresss { /* define a child node named "childnode"
  892. * whose unit name is "childnode at
  893. * address"
  894. */
  895. childprop = "hello\n"; /* define a property "childprop" of
  896. * childnode (in this case, a string)
  897. */
  898. };
  899. };
  900. Nodes can contain other nodes etc... thus defining the hierarchical
  901. structure of the tree.
  902. Strings support common escape sequences from C: "\n", "\t", "\r",
  903. "\(octal value)", "\x(hex value)".
  904. It is also suggested that you pipe your source file through cpp (gcc
  905. preprocessor) so you can use #include's, #define for constants, etc...
  906. Finally, various options are planned but not yet implemented, like
  907. automatic generation of phandles, labels (exported to the asm file so
  908. you can point to a property content and change it easily from whatever
  909. you link the device-tree with), label or path instead of numeric value
  910. in some cells to "point" to a node (replaced by a phandle at compile
  911. time), export of reserve map address to the asm file, ability to
  912. specify reserve map content at compile time, etc...
  913. We may provide a .h include file with common definitions of that
  914. proves useful for some properties (like building PCI properties or
  915. interrupt maps) though it may be better to add a notion of struct
  916. definitions to the compiler...
  917. V - Recommendations for a bootloader
  918. ====================================
  919. Here are some various ideas/recommendations that have been proposed
  920. while all this has been defined and implemented.
  921. - The bootloader may want to be able to use the device-tree itself
  922. and may want to manipulate it (to add/edit some properties,
  923. like physical memory size or kernel arguments). At this point, 2
  924. choices can be made. Either the bootloader works directly on the
  925. flattened format, or the bootloader has its own internal tree
  926. representation with pointers (similar to the kernel one) and
  927. re-flattens the tree when booting the kernel. The former is a bit
  928. more difficult to edit/modify, the later requires probably a bit
  929. more code to handle the tree structure. Note that the structure
  930. format has been designed so it's relatively easy to "insert"
  931. properties or nodes or delete them by just memmoving things
  932. around. It contains no internal offsets or pointers for this
  933. purpose.
  934. - An example of code for iterating nodes & retrieving properties
  935. directly from the flattened tree format can be found in the kernel
  936. file arch/ppc64/kernel/prom.c, look at scan_flat_dt() function,
  937. its usage in early_init_devtree(), and the corresponding various
  938. early_init_dt_scan_*() callbacks. That code can be re-used in a
  939. GPL bootloader, and as the author of that code, I would be happy
  940. to discuss possible free licensing to any vendor who wishes to
  941. integrate all or part of this code into a non-GPL bootloader.
  942. VI - System-on-a-chip devices and nodes
  943. =======================================
  944. Many companies are now starting to develop system-on-a-chip
  945. processors, where the processor core (CPU) and many peripheral devices
  946. exist on a single piece of silicon. For these SOCs, an SOC node
  947. should be used that defines child nodes for the devices that make
  948. up the SOC. While platforms are not required to use this model in
  949. order to boot the kernel, it is highly encouraged that all SOC
  950. implementations define as complete a flat-device-tree as possible to
  951. describe the devices on the SOC. This will allow for the
  952. genericization of much of the kernel code.
  953. 1) Defining child nodes of an SOC
  954. ---------------------------------
  955. Each device that is part of an SOC may have its own node entry inside
  956. the SOC node. For each device that is included in the SOC, the unit
  957. address property represents the address offset for this device's
  958. memory-mapped registers in the parent's address space. The parent's
  959. address space is defined by the "ranges" property in the top-level soc
  960. node. The "reg" property for each node that exists directly under the
  961. SOC node should contain the address mapping from the child address space
  962. to the parent SOC address space and the size of the device's
  963. memory-mapped register file.
  964. For many devices that may exist inside an SOC, there are predefined
  965. specifications for the format of the device tree node. All SOC child
  966. nodes should follow these specifications, except where noted in this
  967. document.
  968. See appendix A for an example partial SOC node definition for the
  969. MPC8540.
  970. 2) Representing devices without a current OF specification
  971. ----------------------------------------------------------
  972. Currently, there are many devices on SOCs that do not have a standard
  973. representation pre-defined as part of the open firmware
  974. specifications, mainly because the boards that contain these SOCs are
  975. not currently booted using open firmware. This section contains
  976. descriptions for the SOC devices for which new nodes have been
  977. defined; this list will expand as more and more SOC-containing
  978. platforms are moved over to use the flattened-device-tree model.
  979. a) MDIO IO device
  980. The MDIO is a bus to which the PHY devices are connected. For each
  981. device that exists on this bus, a child node should be created. See
  982. the definition of the PHY node below for an example of how to define
  983. a PHY.
  984. Required properties:
  985. - reg : Offset and length of the register set for the device
  986. - device_type : Should be "mdio"
  987. - compatible : Should define the compatible device type for the
  988. mdio. Currently, this is most likely to be "gianfar"
  989. Example:
  990. mdio@24520 {
  991. reg = <24520 20>;
  992. device_type = "mdio";
  993. compatible = "gianfar";
  994. ethernet-phy@0 {
  995. ......
  996. };
  997. };
  998. b) Gianfar-compatible ethernet nodes
  999. Required properties:
  1000. - device_type : Should be "network"
  1001. - model : Model of the device. Can be "TSEC", "eTSEC", or "FEC"
  1002. - compatible : Should be "gianfar"
  1003. - reg : Offset and length of the register set for the device
  1004. - mac-address : List of bytes representing the ethernet address of
  1005. this controller
  1006. - interrupts : <a b> where a is the interrupt number and b is a
  1007. field that represents an encoding of the sense and level
  1008. information for the interrupt. This should be encoded based on
  1009. the information in section 2) depending on the type of interrupt
  1010. controller you have.
  1011. - interrupt-parent : the phandle for the interrupt controller that
  1012. services interrupts for this device.
  1013. - phy-handle : The phandle for the PHY connected to this ethernet
  1014. controller.
  1015. Recommended properties:
  1016. - linux,network-index : This is the intended "index" of this
  1017. network device. This is used by the bootwrapper to interpret
  1018. MAC addresses passed by the firmware when no information other
  1019. than indices is available to associate an address with a device.
  1020. - phy-connection-type : a string naming the controller/PHY interface type,
  1021. i.e., "mii" (default), "rmii", "gmii", "rgmii", "rgmii-id", "sgmii",
  1022. "tbi", or "rtbi". This property is only really needed if the connection
  1023. is of type "rgmii-id", as all other connection types are detected by
  1024. hardware.
  1025. Example:
  1026. ethernet@24000 {
  1027. #size-cells = <0>;
  1028. device_type = "network";
  1029. model = "TSEC";
  1030. compatible = "gianfar";
  1031. reg = <24000 1000>;
  1032. mac-address = [ 00 E0 0C 00 73 00 ];
  1033. interrupts = <d 3 e 3 12 3>;
  1034. interrupt-parent = <40000>;
  1035. phy-handle = <2452000>
  1036. };
  1037. c) PHY nodes
  1038. Required properties:
  1039. - device_type : Should be "ethernet-phy"
  1040. - interrupts : <a b> where a is the interrupt number and b is a
  1041. field that represents an encoding of the sense and level
  1042. information for the interrupt. This should be encoded based on
  1043. the information in section 2) depending on the type of interrupt
  1044. controller you have.
  1045. - interrupt-parent : the phandle for the interrupt controller that
  1046. services interrupts for this device.
  1047. - reg : The ID number for the phy, usually a small integer
  1048. - linux,phandle : phandle for this node; likely referenced by an
  1049. ethernet controller node.
  1050. Example:
  1051. ethernet-phy@0 {
  1052. linux,phandle = <2452000>
  1053. interrupt-parent = <40000>;
  1054. interrupts = <35 1>;
  1055. reg = <0>;
  1056. device_type = "ethernet-phy";
  1057. };
  1058. d) Interrupt controllers
  1059. Some SOC devices contain interrupt controllers that are different
  1060. from the standard Open PIC specification. The SOC device nodes for
  1061. these types of controllers should be specified just like a standard
  1062. OpenPIC controller. Sense and level information should be encoded
  1063. as specified in section 2) of this chapter for each device that
  1064. specifies an interrupt.
  1065. Example :
  1066. pic@40000 {
  1067. linux,phandle = <40000>;
  1068. clock-frequency = <0>;
  1069. interrupt-controller;
  1070. #address-cells = <0>;
  1071. reg = <40000 40000>;
  1072. built-in;
  1073. compatible = "chrp,open-pic";
  1074. device_type = "open-pic";
  1075. big-endian;
  1076. };
  1077. e) I2C
  1078. Required properties :
  1079. - device_type : Should be "i2c"
  1080. - reg : Offset and length of the register set for the device
  1081. Recommended properties :
  1082. - compatible : Should be "fsl-i2c" for parts compatible with
  1083. Freescale I2C specifications.
  1084. - interrupts : <a b> where a is the interrupt number and b is a
  1085. field that represents an encoding of the sense and level
  1086. information for the interrupt. This should be encoded based on
  1087. the information in section 2) depending on the type of interrupt
  1088. controller you have.
  1089. - interrupt-parent : the phandle for the interrupt controller that
  1090. services interrupts for this device.
  1091. - dfsrr : boolean; if defined, indicates that this I2C device has
  1092. a digital filter sampling rate register
  1093. - fsl5200-clocking : boolean; if defined, indicated that this device
  1094. uses the FSL 5200 clocking mechanism.
  1095. Example :
  1096. i2c@3000 {
  1097. interrupt-parent = <40000>;
  1098. interrupts = <1b 3>;
  1099. reg = <3000 18>;
  1100. device_type = "i2c";
  1101. compatible = "fsl-i2c";
  1102. dfsrr;
  1103. };
  1104. f) Freescale SOC USB controllers
  1105. The device node for a USB controller that is part of a Freescale
  1106. SOC is as described in the document "Open Firmware Recommended
  1107. Practice : Universal Serial Bus" with the following modifications
  1108. and additions :
  1109. Required properties :
  1110. - compatible : Should be "fsl-usb2-mph" for multi port host USB
  1111. controllers, or "fsl-usb2-dr" for dual role USB controllers
  1112. - phy_type : For multi port host USB controllers, should be one of
  1113. "ulpi", or "serial". For dual role USB controllers, should be
  1114. one of "ulpi", "utmi", "utmi_wide", or "serial".
  1115. - reg : Offset and length of the register set for the device
  1116. - port0 : boolean; if defined, indicates port0 is connected for
  1117. fsl-usb2-mph compatible controllers. Either this property or
  1118. "port1" (or both) must be defined for "fsl-usb2-mph" compatible
  1119. controllers.
  1120. - port1 : boolean; if defined, indicates port1 is connected for
  1121. fsl-usb2-mph compatible controllers. Either this property or
  1122. "port0" (or both) must be defined for "fsl-usb2-mph" compatible
  1123. controllers.
  1124. - dr_mode : indicates the working mode for "fsl-usb2-dr" compatible
  1125. controllers. Can be "host", "peripheral", or "otg". Default to
  1126. "host" if not defined for backward compatibility.
  1127. Recommended properties :
  1128. - interrupts : <a b> where a is the interrupt number and b is a
  1129. field that represents an encoding of the sense and level
  1130. information for the interrupt. This should be encoded based on
  1131. the information in section 2) depending on the type of interrupt
  1132. controller you have.
  1133. - interrupt-parent : the phandle for the interrupt controller that
  1134. services interrupts for this device.
  1135. Example multi port host USB controller device node :
  1136. usb@22000 {
  1137. device_type = "usb";
  1138. compatible = "fsl-usb2-mph";
  1139. reg = <22000 1000>;
  1140. #address-cells = <1>;
  1141. #size-cells = <0>;
  1142. interrupt-parent = <700>;
  1143. interrupts = <27 1>;
  1144. phy_type = "ulpi";
  1145. port0;
  1146. port1;
  1147. };
  1148. Example dual role USB controller device node :
  1149. usb@23000 {
  1150. device_type = "usb";
  1151. compatible = "fsl-usb2-dr";
  1152. reg = <23000 1000>;
  1153. #address-cells = <1>;
  1154. #size-cells = <0>;
  1155. interrupt-parent = <700>;
  1156. interrupts = <26 1>;
  1157. dr_mode = "otg";
  1158. phy = "ulpi";
  1159. };
  1160. g) Freescale SOC SEC Security Engines
  1161. Required properties:
  1162. - device_type : Should be "crypto"
  1163. - model : Model of the device. Should be "SEC1" or "SEC2"
  1164. - compatible : Should be "talitos"
  1165. - reg : Offset and length of the register set for the device
  1166. - interrupts : <a b> where a is the interrupt number and b is a
  1167. field that represents an encoding of the sense and level
  1168. information for the interrupt. This should be encoded based on
  1169. the information in section 2) depending on the type of interrupt
  1170. controller you have.
  1171. - interrupt-parent : the phandle for the interrupt controller that
  1172. services interrupts for this device.
  1173. - num-channels : An integer representing the number of channels
  1174. available.
  1175. - channel-fifo-len : An integer representing the number of
  1176. descriptor pointers each channel fetch fifo can hold.
  1177. - exec-units-mask : The bitmask representing what execution units
  1178. (EUs) are available. It's a single 32-bit cell. EU information
  1179. should be encoded following the SEC's Descriptor Header Dword
  1180. EU_SEL0 field documentation, i.e. as follows:
  1181. bit 0 = reserved - should be 0
  1182. bit 1 = set if SEC has the ARC4 EU (AFEU)
  1183. bit 2 = set if SEC has the DES/3DES EU (DEU)
  1184. bit 3 = set if SEC has the message digest EU (MDEU)
  1185. bit 4 = set if SEC has the random number generator EU (RNG)
  1186. bit 5 = set if SEC has the public key EU (PKEU)
  1187. bit 6 = set if SEC has the AES EU (AESU)
  1188. bit 7 = set if SEC has the Kasumi EU (KEU)
  1189. bits 8 through 31 are reserved for future SEC EUs.
  1190. - descriptor-types-mask : The bitmask representing what descriptors
  1191. are available. It's a single 32-bit cell. Descriptor type
  1192. information should be encoded following the SEC's Descriptor
  1193. Header Dword DESC_TYPE field documentation, i.e. as follows:
  1194. bit 0 = set if SEC supports the aesu_ctr_nonsnoop desc. type
  1195. bit 1 = set if SEC supports the ipsec_esp descriptor type
  1196. bit 2 = set if SEC supports the common_nonsnoop desc. type
  1197. bit 3 = set if SEC supports the 802.11i AES ccmp desc. type
  1198. bit 4 = set if SEC supports the hmac_snoop_no_afeu desc. type
  1199. bit 5 = set if SEC supports the srtp descriptor type
  1200. bit 6 = set if SEC supports the non_hmac_snoop_no_afeu desc.type
  1201. bit 7 = set if SEC supports the pkeu_assemble descriptor type
  1202. bit 8 = set if SEC supports the aesu_key_expand_output desc.type
  1203. bit 9 = set if SEC supports the pkeu_ptmul descriptor type
  1204. bit 10 = set if SEC supports the common_nonsnoop_afeu desc. type
  1205. bit 11 = set if SEC supports the pkeu_ptadd_dbl descriptor type
  1206. ..and so on and so forth.
  1207. Example:
  1208. /* MPC8548E */
  1209. crypto@30000 {
  1210. device_type = "crypto";
  1211. model = "SEC2";
  1212. compatible = "talitos";
  1213. reg = <30000 10000>;
  1214. interrupts = <1d 3>;
  1215. interrupt-parent = <40000>;
  1216. num-channels = <4>;
  1217. channel-fifo-len = <18>;
  1218. exec-units-mask = <000000fe>;
  1219. descriptor-types-mask = <012b0ebf>;
  1220. };
  1221. h) Board Control and Status (BCSR)
  1222. Required properties:
  1223. - device_type : Should be "board-control"
  1224. - reg : Offset and length of the register set for the device
  1225. Example:
  1226. bcsr@f8000000 {
  1227. device_type = "board-control";
  1228. reg = <f8000000 8000>;
  1229. };
  1230. i) Freescale QUICC Engine module (QE)
  1231. This represents qe module that is installed on PowerQUICC II Pro.
  1232. NOTE: This is an interim binding; it should be updated to fit
  1233. in with the CPM binding later in this document.
  1234. Basically, it is a bus of devices, that could act more or less
  1235. as a complete entity (UCC, USB etc ). All of them should be siblings on
  1236. the "root" qe node, using the common properties from there.
  1237. The description below applies to the qe of MPC8360 and
  1238. more nodes and properties would be extended in the future.
  1239. i) Root QE device
  1240. Required properties:
  1241. - device_type : should be "qe";
  1242. - model : precise model of the QE, Can be "QE", "CPM", or "CPM2"
  1243. - reg : offset and length of the device registers.
  1244. - bus-frequency : the clock frequency for QUICC Engine.
  1245. Recommended properties
  1246. - brg-frequency : the internal clock source frequency for baud-rate
  1247. generators in Hz.
  1248. Example:
  1249. qe@e0100000 {
  1250. #address-cells = <1>;
  1251. #size-cells = <1>;
  1252. #interrupt-cells = <2>;
  1253. device_type = "qe";
  1254. model = "QE";
  1255. ranges = <0 e0100000 00100000>;
  1256. reg = <e0100000 480>;
  1257. brg-frequency = <0>;
  1258. bus-frequency = <179A7B00>;
  1259. }
  1260. ii) SPI (Serial Peripheral Interface)
  1261. Required properties:
  1262. - device_type : should be "spi".
  1263. - compatible : should be "fsl_spi".
  1264. - mode : the SPI operation mode, it can be "cpu" or "cpu-qe".
  1265. - reg : Offset and length of the register set for the device
  1266. - interrupts : <a b> where a is the interrupt number and b is a
  1267. field that represents an encoding of the sense and level
  1268. information for the interrupt. This should be encoded based on
  1269. the information in section 2) depending on the type of interrupt
  1270. controller you have.
  1271. - interrupt-parent : the phandle for the interrupt controller that
  1272. services interrupts for this device.
  1273. Example:
  1274. spi@4c0 {
  1275. device_type = "spi";
  1276. compatible = "fsl_spi";
  1277. reg = <4c0 40>;
  1278. interrupts = <82 0>;
  1279. interrupt-parent = <700>;
  1280. mode = "cpu";
  1281. };
  1282. iii) USB (Universal Serial Bus Controller)
  1283. Required properties:
  1284. - device_type : should be "usb".
  1285. - compatible : could be "qe_udc" or "fhci-hcd".
  1286. - mode : the could be "host" or "slave".
  1287. - reg : Offset and length of the register set for the device
  1288. - interrupts : <a b> where a is the interrupt number and b is a
  1289. field that represents an encoding of the sense and level
  1290. information for the interrupt. This should be encoded based on
  1291. the information in section 2) depending on the type of interrupt
  1292. controller you have.
  1293. - interrupt-parent : the phandle for the interrupt controller that
  1294. services interrupts for this device.
  1295. Example(slave):
  1296. usb@6c0 {
  1297. device_type = "usb";
  1298. compatible = "qe_udc";
  1299. reg = <6c0 40>;
  1300. interrupts = <8b 0>;
  1301. interrupt-parent = <700>;
  1302. mode = "slave";
  1303. };
  1304. iv) UCC (Unified Communications Controllers)
  1305. Required properties:
  1306. - device_type : should be "network", "hldc", "uart", "transparent"
  1307. "bisync" or "atm".
  1308. - compatible : could be "ucc_geth" or "fsl_atm" and so on.
  1309. - model : should be "UCC".
  1310. - device-id : the ucc number(1-8), corresponding to UCCx in UM.
  1311. - reg : Offset and length of the register set for the device
  1312. - interrupts : <a b> where a is the interrupt number and b is a
  1313. field that represents an encoding of the sense and level
  1314. information for the interrupt. This should be encoded based on
  1315. the information in section 2) depending on the type of interrupt
  1316. controller you have.
  1317. - interrupt-parent : the phandle for the interrupt controller that
  1318. services interrupts for this device.
  1319. - pio-handle : The phandle for the Parallel I/O port configuration.
  1320. - rx-clock : represents the UCC receive clock source.
  1321. 0x00 : clock source is disabled;
  1322. 0x1~0x10 : clock source is BRG1~BRG16 respectively;
  1323. 0x11~0x28: clock source is QE_CLK1~QE_CLK24 respectively.
  1324. - tx-clock: represents the UCC transmit clock source;
  1325. 0x00 : clock source is disabled;
  1326. 0x1~0x10 : clock source is BRG1~BRG16 respectively;
  1327. 0x11~0x28: clock source is QE_CLK1~QE_CLK24 respectively.
  1328. Required properties for network device_type:
  1329. - mac-address : list of bytes representing the ethernet address.
  1330. - phy-handle : The phandle for the PHY connected to this controller.
  1331. Recommended properties:
  1332. - linux,network-index : This is the intended "index" of this
  1333. network device. This is used by the bootwrapper to interpret
  1334. MAC addresses passed by the firmware when no information other
  1335. than indices is available to associate an address with a device.
  1336. - phy-connection-type : a string naming the controller/PHY interface type,
  1337. i.e., "mii" (default), "rmii", "gmii", "rgmii", "rgmii-id" (Internal
  1338. Delay), "rgmii-txid" (delay on TX only), "rgmii-rxid" (delay on RX only),
  1339. "tbi", or "rtbi".
  1340. Example:
  1341. ucc@2000 {
  1342. device_type = "network";
  1343. compatible = "ucc_geth";
  1344. model = "UCC";
  1345. device-id = <1>;
  1346. reg = <2000 200>;
  1347. interrupts = <a0 0>;
  1348. interrupt-parent = <700>;
  1349. mac-address = [ 00 04 9f 00 23 23 ];
  1350. rx-clock = "none";
  1351. tx-clock = "clk9";
  1352. phy-handle = <212000>;
  1353. phy-connection-type = "gmii";
  1354. pio-handle = <140001>;
  1355. };
  1356. v) Parallel I/O Ports
  1357. This node configures Parallel I/O ports for CPUs with QE support.
  1358. The node should reside in the "soc" node of the tree. For each
  1359. device that using parallel I/O ports, a child node should be created.
  1360. See the definition of the Pin configuration nodes below for more
  1361. information.
  1362. Required properties:
  1363. - device_type : should be "par_io".
  1364. - reg : offset to the register set and its length.
  1365. - num-ports : number of Parallel I/O ports
  1366. Example:
  1367. par_io@1400 {
  1368. reg = <1400 100>;
  1369. #address-cells = <1>;
  1370. #size-cells = <0>;
  1371. device_type = "par_io";
  1372. num-ports = <7>;
  1373. ucc_pin@01 {
  1374. ......
  1375. };
  1376. vi) Pin configuration nodes
  1377. Required properties:
  1378. - linux,phandle : phandle of this node; likely referenced by a QE
  1379. device.
  1380. - pio-map : array of pin configurations. Each pin is defined by 6
  1381. integers. The six numbers are respectively: port, pin, dir,
  1382. open_drain, assignment, has_irq.
  1383. - port : port number of the pin; 0-6 represent port A-G in UM.
  1384. - pin : pin number in the port.
  1385. - dir : direction of the pin, should encode as follows:
  1386. 0 = The pin is disabled
  1387. 1 = The pin is an output
  1388. 2 = The pin is an input
  1389. 3 = The pin is I/O
  1390. - open_drain : indicates the pin is normal or wired-OR:
  1391. 0 = The pin is actively driven as an output
  1392. 1 = The pin is an open-drain driver. As an output, the pin is
  1393. driven active-low, otherwise it is three-stated.
  1394. - assignment : function number of the pin according to the Pin Assignment
  1395. tables in User Manual. Each pin can have up to 4 possible functions in
  1396. QE and two options for CPM.
  1397. - has_irq : indicates if the pin is used as source of external
  1398. interrupts.
  1399. Example:
  1400. ucc_pin@01 {
  1401. linux,phandle = <140001>;
  1402. pio-map = <
  1403. /* port pin dir open_drain assignment has_irq */
  1404. 0 3 1 0 1 0 /* TxD0 */
  1405. 0 4 1 0 1 0 /* TxD1 */
  1406. 0 5 1 0 1 0 /* TxD2 */
  1407. 0 6 1 0 1 0 /* TxD3 */
  1408. 1 6 1 0 3 0 /* TxD4 */
  1409. 1 7 1 0 1 0 /* TxD5 */
  1410. 1 9 1 0 2 0 /* TxD6 */
  1411. 1 a 1 0 2 0 /* TxD7 */
  1412. 0 9 2 0 1 0 /* RxD0 */
  1413. 0 a 2 0 1 0 /* RxD1 */
  1414. 0 b 2 0 1 0 /* RxD2 */
  1415. 0 c 2 0 1 0 /* RxD3 */
  1416. 0 d 2 0 1 0 /* RxD4 */
  1417. 1 1 2 0 2 0 /* RxD5 */
  1418. 1 0 2 0 2 0 /* RxD6 */
  1419. 1 4 2 0 2 0 /* RxD7 */
  1420. 0 7 1 0 1 0 /* TX_EN */
  1421. 0 8 1 0 1 0 /* TX_ER */
  1422. 0 f 2 0 1 0 /* RX_DV */
  1423. 0 10 2 0 1 0 /* RX_ER */
  1424. 0 0 2 0 1 0 /* RX_CLK */
  1425. 2 9 1 0 3 0 /* GTX_CLK - CLK10 */
  1426. 2 8 2 0 1 0>; /* GTX125 - CLK9 */
  1427. };
  1428. vii) Multi-User RAM (MURAM)
  1429. Required properties:
  1430. - device_type : should be "muram".
  1431. - mode : the could be "host" or "slave".
  1432. - ranges : Should be defined as specified in 1) to describe the
  1433. translation of MURAM addresses.
  1434. - data-only : sub-node which defines the address area under MURAM
  1435. bus that can be allocated as data/parameter
  1436. Example:
  1437. muram@10000 {
  1438. device_type = "muram";
  1439. ranges = <0 00010000 0000c000>;
  1440. data-only@0{
  1441. reg = <0 c000>;
  1442. };
  1443. };
  1444. j) CFI or JEDEC memory-mapped NOR flash
  1445. Flash chips (Memory Technology Devices) are often used for solid state
  1446. file systems on embedded devices.
  1447. - compatible : should contain the specific model of flash chip(s)
  1448. used, if known, followed by either "cfi-flash" or "jedec-flash"
  1449. - reg : Address range of the flash chip
  1450. - bank-width : Width (in bytes) of the flash bank. Equal to the
  1451. device width times the number of interleaved chips.
  1452. - device-width : (optional) Width of a single flash chip. If
  1453. omitted, assumed to be equal to 'bank-width'.
  1454. - #address-cells, #size-cells : Must be present if the flash has
  1455. sub-nodes representing partitions (see below). In this case
  1456. both #address-cells and #size-cells must be equal to 1.
  1457. For JEDEC compatible devices, the following additional properties
  1458. are defined:
  1459. - vendor-id : Contains the flash chip's vendor id (1 byte).
  1460. - device-id : Contains the flash chip's device id (1 byte).
  1461. In addition to the information on the flash bank itself, the
  1462. device tree may optionally contain additional information
  1463. describing partitions of the flash address space. This can be
  1464. used on platforms which have strong conventions about which
  1465. portions of the flash are used for what purposes, but which don't
  1466. use an on-flash partition table such as RedBoot.
  1467. Each partition is represented as a sub-node of the flash device.
  1468. Each node's name represents the name of the corresponding
  1469. partition of the flash device.
  1470. Flash partitions
  1471. - reg : The partition's offset and size within the flash bank.
  1472. - label : (optional) The label / name for this flash partition.
  1473. If omitted, the label is taken from the node name (excluding
  1474. the unit address).
  1475. - read-only : (optional) This parameter, if present, is a hint to
  1476. Linux that this flash partition should only be mounted
  1477. read-only. This is usually used for flash partitions
  1478. containing early-boot firmware images or data which should not
  1479. be clobbered.
  1480. Example:
  1481. flash@ff000000 {
  1482. compatible = "amd,am29lv128ml", "cfi-flash";
  1483. reg = <ff000000 01000000>;
  1484. bank-width = <4>;
  1485. device-width = <1>;
  1486. #address-cells = <1>;
  1487. #size-cells = <1>;
  1488. fs@0 {
  1489. label = "fs";
  1490. reg = <0 f80000>;
  1491. };
  1492. firmware@f80000 {
  1493. label ="firmware";
  1494. reg = <f80000 80000>;
  1495. read-only;
  1496. };
  1497. };
  1498. k) Global Utilities Block
  1499. The global utilities block controls power management, I/O device
  1500. enabling, power-on-reset configuration monitoring, general-purpose
  1501. I/O signal configuration, alternate function selection for multiplexed
  1502. signals, and clock control.
  1503. Required properties:
  1504. - compatible : Should define the compatible device type for
  1505. global-utilities.
  1506. - reg : Offset and length of the register set for the device.
  1507. Recommended properties:
  1508. - fsl,has-rstcr : Indicates that the global utilities register set
  1509. contains a functioning "reset control register" (i.e. the board
  1510. is wired to reset upon setting the HRESET_REQ bit in this register).
  1511. Example:
  1512. global-utilities@e0000 { /* global utilities block */
  1513. compatible = "fsl,mpc8548-guts";
  1514. reg = <e0000 1000>;
  1515. fsl,has-rstcr;
  1516. };
  1517. l) Freescale Communications Processor Module
  1518. NOTE: This is an interim binding, and will likely change slightly,
  1519. as more devices are supported. The QE bindings especially are
  1520. incomplete.
  1521. i) Root CPM node
  1522. Properties:
  1523. - compatible : "fsl,cpm1", "fsl,cpm2", or "fsl,qe".
  1524. - reg : A 48-byte region beginning with CPCR.
  1525. Example:
  1526. cpm@119c0 {
  1527. #address-cells = <1>;
  1528. #size-cells = <1>;
  1529. #interrupt-cells = <2>;
  1530. compatible = "fsl,mpc8272-cpm", "fsl,cpm2";
  1531. reg = <119c0 30>;
  1532. }
  1533. ii) Properties common to mulitple CPM/QE devices
  1534. - fsl,cpm-command : This value is ORed with the opcode and command flag
  1535. to specify the device on which a CPM command operates.
  1536. - fsl,cpm-brg : Indicates which baud rate generator the device
  1537. is associated with. If absent, an unused BRG
  1538. should be dynamically allocated. If zero, the
  1539. device uses an external clock rather than a BRG.
  1540. - reg : Unless otherwise specified, the first resource represents the
  1541. scc/fcc/ucc registers, and the second represents the device's
  1542. parameter RAM region (if it has one).
  1543. iii) Serial
  1544. Currently defined compatibles:
  1545. - fsl,cpm1-smc-uart
  1546. - fsl,cpm2-smc-uart
  1547. - fsl,cpm1-scc-uart
  1548. - fsl,cpm2-scc-uart
  1549. - fsl,qe-uart
  1550. Example:
  1551. serial@11a00 {
  1552. device_type = "serial";
  1553. compatible = "fsl,mpc8272-scc-uart",
  1554. "fsl,cpm2-scc-uart";
  1555. reg = <11a00 20 8000 100>;
  1556. interrupts = <28 8>;
  1557. interrupt-parent = <&PIC>;
  1558. fsl,cpm-brg = <1>;
  1559. fsl,cpm-command = <00800000>;
  1560. };
  1561. iii) Network
  1562. Currently defined compatibles:
  1563. - fsl,cpm1-scc-enet
  1564. - fsl,cpm2-scc-enet
  1565. - fsl,cpm1-fec-enet
  1566. - fsl,cpm2-fcc-enet (third resource is GFEMR)
  1567. - fsl,qe-enet
  1568. Example:
  1569. ethernet@11300 {
  1570. device_type = "network";
  1571. compatible = "fsl,mpc8272-fcc-enet",
  1572. "fsl,cpm2-fcc-enet";
  1573. reg = <11300 20 8400 100 11390 1>;
  1574. local-mac-address = [ 00 00 00 00 00 00 ];
  1575. interrupts = <20 8>;
  1576. interrupt-parent = <&PIC>;
  1577. phy-handle = <&PHY0>;
  1578. linux,network-index = <0>;
  1579. fsl,cpm-command = <12000300>;
  1580. };
  1581. iv) MDIO
  1582. Currently defined compatibles:
  1583. fsl,pq1-fec-mdio (reg is same as first resource of FEC device)
  1584. fsl,cpm2-mdio-bitbang (reg is port C registers)
  1585. Properties for fsl,cpm2-mdio-bitbang:
  1586. fsl,mdio-pin : pin of port C controlling mdio data
  1587. fsl,mdc-pin : pin of port C controlling mdio clock
  1588. Example:
  1589. mdio@10d40 {
  1590. device_type = "mdio";
  1591. compatible = "fsl,mpc8272ads-mdio-bitbang",
  1592. "fsl,mpc8272-mdio-bitbang",
  1593. "fsl,cpm2-mdio-bitbang";
  1594. reg = <10d40 14>;
  1595. #address-cells = <1>;
  1596. #size-cells = <0>;
  1597. fsl,mdio-pin = <12>;
  1598. fsl,mdc-pin = <13>;
  1599. };
  1600. v) Baud Rate Generators
  1601. Currently defined compatibles:
  1602. fsl,cpm-brg
  1603. fsl,cpm1-brg
  1604. fsl,cpm2-brg
  1605. Properties:
  1606. - reg : There may be an arbitrary number of reg resources; BRG
  1607. numbers are assigned to these in order.
  1608. - clock-frequency : Specifies the base frequency driving
  1609. the BRG.
  1610. Example:
  1611. brg@119f0 {
  1612. compatible = "fsl,mpc8272-brg",
  1613. "fsl,cpm2-brg",
  1614. "fsl,cpm-brg";
  1615. reg = <119f0 10 115f0 10>;
  1616. clock-frequency = <d#25000000>;
  1617. };
  1618. vi) Interrupt Controllers
  1619. Currently defined compatibles:
  1620. - fsl,cpm1-pic
  1621. - only one interrupt cell
  1622. - fsl,pq1-pic
  1623. - fsl,cpm2-pic
  1624. - second interrupt cell is level/sense:
  1625. - 2 is falling edge
  1626. - 8 is active low
  1627. Example:
  1628. interrupt-controller@10c00 {
  1629. #interrupt-cells = <2>;
  1630. interrupt-controller;
  1631. reg = <10c00 80>;
  1632. compatible = "mpc8272-pic", "fsl,cpm2-pic";
  1633. };
  1634. vii) USB (Universal Serial Bus Controller)
  1635. Properties:
  1636. - compatible : "fsl,cpm1-usb", "fsl,cpm2-usb", "fsl,qe-usb"
  1637. Example:
  1638. usb@11bc0 {
  1639. #address-cells = <1>;
  1640. #size-cells = <0>;
  1641. compatible = "fsl,cpm2-usb";
  1642. reg = <11b60 18 8b00 100>;
  1643. interrupts = <b 8>;
  1644. interrupt-parent = <&PIC>;
  1645. fsl,cpm-command = <2e600000>;
  1646. };
  1647. viii) Multi-User RAM (MURAM)
  1648. The multi-user/dual-ported RAM is expressed as a bus under the CPM node.
  1649. Ranges must be set up subject to the following restrictions:
  1650. - Children's reg nodes must be offsets from the start of all muram, even
  1651. if the user-data area does not begin at zero.
  1652. - If multiple range entries are used, the difference between the parent
  1653. address and the child address must be the same in all, so that a single
  1654. mapping can cover them all while maintaining the ability to determine
  1655. CPM-side offsets with pointer subtraction. It is recommended that
  1656. multiple range entries not be used.
  1657. - A child address of zero must be translatable, even if no reg resources
  1658. contain it.
  1659. A child "data" node must exist, compatible with "fsl,cpm-muram-data", to
  1660. indicate the portion of muram that is usable by the OS for arbitrary
  1661. purposes. The data node may have an arbitrary number of reg resources,
  1662. all of which contribute to the allocatable muram pool.
  1663. Example, based on mpc8272:
  1664. muram@0 {
  1665. #address-cells = <1>;
  1666. #size-cells = <1>;
  1667. ranges = <0 0 10000>;
  1668. data@0 {
  1669. compatible = "fsl,cpm-muram-data";
  1670. reg = <0 2000 9800 800>;
  1671. };
  1672. };
  1673. m) Chipselect/Local Bus
  1674. Properties:
  1675. - name : Should be localbus
  1676. - #address-cells : Should be either two or three. The first cell is the
  1677. chipselect number, and the remaining cells are the
  1678. offset into the chipselect.
  1679. - #size-cells : Either one or two, depending on how large each chipselect
  1680. can be.
  1681. - ranges : Each range corresponds to a single chipselect, and cover
  1682. the entire access window as configured.
  1683. Example:
  1684. localbus@f0010100 {
  1685. compatible = "fsl,mpc8272ads-localbus",
  1686. "fsl,mpc8272-localbus",
  1687. "fsl,pq2-localbus";
  1688. #address-cells = <2>;
  1689. #size-cells = <1>;
  1690. reg = <f0010100 40>;
  1691. ranges = <0 0 fe000000 02000000
  1692. 1 0 f4500000 00008000>;
  1693. flash@0,0 {
  1694. compatible = "jedec-flash";
  1695. reg = <0 0 2000000>;
  1696. bank-width = <4>;
  1697. device-width = <1>;
  1698. };
  1699. board-control@1,0 {
  1700. reg = <1 0 20>;
  1701. compatible = "fsl,mpc8272ads-bcsr";
  1702. };
  1703. };
  1704. n) 4xx/Axon EMAC ethernet nodes
  1705. The EMAC ethernet controller in IBM and AMCC 4xx chips, and also
  1706. the Axon bridge. To operate this needs to interact with a ths
  1707. special McMAL DMA controller, and sometimes an RGMII or ZMII
  1708. interface. In addition to the nodes and properties described
  1709. below, the node for the OPB bus on which the EMAC sits must have a
  1710. correct clock-frequency property.
  1711. i) The EMAC node itself
  1712. Required properties:
  1713. - device_type : "network"
  1714. - compatible : compatible list, contains 2 entries, first is
  1715. "ibm,emac-CHIP" where CHIP is the host ASIC (440gx,
  1716. 405gp, Axon) and second is either "ibm,emac" or
  1717. "ibm,emac4". For Axon, thus, we have: "ibm,emac-axon",
  1718. "ibm,emac4"
  1719. - interrupts : <interrupt mapping for EMAC IRQ and WOL IRQ>
  1720. - interrupt-parent : optional, if needed for interrupt mapping
  1721. - reg : <registers mapping>
  1722. - local-mac-address : 6 bytes, MAC address
  1723. - mal-device : phandle of the associated McMAL node
  1724. - mal-tx-channel : 1 cell, index of the tx channel on McMAL associated
  1725. with this EMAC
  1726. - mal-rx-channel : 1 cell, index of the rx channel on McMAL associated
  1727. with this EMAC
  1728. - cell-index : 1 cell, hardware index of the EMAC cell on a given
  1729. ASIC (typically 0x0 and 0x1 for EMAC0 and EMAC1 on
  1730. each Axon chip)
  1731. - max-frame-size : 1 cell, maximum frame size supported in bytes
  1732. - rx-fifo-size : 1 cell, Rx fifo size in bytes for 10 and 100 Mb/sec
  1733. operations.
  1734. For Axon, 2048
  1735. - tx-fifo-size : 1 cell, Tx fifo size in bytes for 10 and 100 Mb/sec
  1736. operations.
  1737. For Axon, 2048.
  1738. - fifo-entry-size : 1 cell, size of a fifo entry (used to calculate
  1739. thresholds).
  1740. For Axon, 0x00000010
  1741. - mal-burst-size : 1 cell, MAL burst size (used to calculate thresholds)
  1742. in bytes.
  1743. For Axon, 0x00000100 (I think ...)
  1744. - phy-mode : string, mode of operations of the PHY interface.
  1745. Supported values are: "mii", "rmii", "smii", "rgmii",
  1746. "tbi", "gmii", rtbi", "sgmii".
  1747. For Axon on CAB, it is "rgmii"
  1748. - mdio-device : 1 cell, required iff using shared MDIO registers
  1749. (440EP). phandle of the EMAC to use to drive the
  1750. MDIO lines for the PHY used by this EMAC.
  1751. - zmii-device : 1 cell, required iff connected to a ZMII. phandle of
  1752. the ZMII device node
  1753. - zmii-channel : 1 cell, required iff connected to a ZMII. Which ZMII
  1754. channel or 0xffffffff if ZMII is only used for MDIO.
  1755. - rgmii-device : 1 cell, required iff connected to an RGMII. phandle
  1756. of the RGMII device node.
  1757. For Axon: phandle of plb5/plb4/opb/rgmii
  1758. - rgmii-channel : 1 cell, required iff connected to an RGMII. Which
  1759. RGMII channel is used by this EMAC.
  1760. Fox Axon: present, whatever value is appropriate for each
  1761. EMAC, that is the content of the current (bogus) "phy-port"
  1762. property.
  1763. Recommended properties:
  1764. - linux,network-index : This is the intended "index" of this
  1765. network device. This is used by the bootwrapper to interpret
  1766. MAC addresses passed by the firmware when no information other
  1767. than indices is available to associate an address with a device.
  1768. Optional properties:
  1769. - phy-address : 1 cell, optional, MDIO address of the PHY. If absent,
  1770. a search is performed.
  1771. - phy-map : 1 cell, optional, bitmap of addresses to probe the PHY
  1772. for, used if phy-address is absent. bit 0x00000001 is
  1773. MDIO address 0.
  1774. For Axon it can be absent, thouugh my current driver
  1775. doesn't handle phy-address yet so for now, keep
  1776. 0x00ffffff in it.
  1777. - rx-fifo-size-gige : 1 cell, Rx fifo size in bytes for 1000 Mb/sec
  1778. operations (if absent the value is the same as
  1779. rx-fifo-size). For Axon, either absent or 2048.
  1780. - tx-fifo-size-gige : 1 cell, Tx fifo size in bytes for 1000 Mb/sec
  1781. operations (if absent the value is the same as
  1782. tx-fifo-size). For Axon, either absent or 2048.
  1783. - tah-device : 1 cell, optional. If connected to a TAH engine for
  1784. offload, phandle of the TAH device node.
  1785. - tah-channel : 1 cell, optional. If appropriate, channel used on the
  1786. TAH engine.
  1787. Example:
  1788. EMAC0: ethernet@40000800 {
  1789. linux,network-index = <0>;
  1790. device_type = "network";
  1791. compatible = "ibm,emac-440gp", "ibm,emac";
  1792. interrupt-parent = <&UIC1>;
  1793. interrupts = <1c 4 1d 4>;
  1794. reg = <40000800 70>;
  1795. local-mac-address = [00 04 AC E3 1B 1E];
  1796. mal-device = <&MAL0>;
  1797. mal-tx-channel = <0 1>;
  1798. mal-rx-channel = <0>;
  1799. cell-index = <0>;
  1800. max-frame-size = <5dc>;
  1801. rx-fifo-size = <1000>;
  1802. tx-fifo-size = <800>;
  1803. phy-mode = "rmii";
  1804. phy-map = <00000001>;
  1805. zmii-device = <&ZMII0>;
  1806. zmii-channel = <0>;
  1807. };
  1808. ii) McMAL node
  1809. Required properties:
  1810. - device_type : "dma-controller"
  1811. - compatible : compatible list, containing 2 entries, first is
  1812. "ibm,mcmal-CHIP" where CHIP is the host ASIC (like
  1813. emac) and the second is either "ibm,mcmal" or
  1814. "ibm,mcmal2".
  1815. For Axon, "ibm,mcmal-axon","ibm,mcmal2"
  1816. - interrupts : <interrupt mapping for the MAL interrupts sources:
  1817. 5 sources: tx_eob, rx_eob, serr, txde, rxde>.
  1818. For Axon: This is _different_ from the current
  1819. firmware. We use the "delayed" interrupts for txeob
  1820. and rxeob. Thus we end up with mapping those 5 MPIC
  1821. interrupts, all level positive sensitive: 10, 11, 32,
  1822. 33, 34 (in decimal)
  1823. - dcr-reg : < DCR registers range >
  1824. - dcr-parent : if needed for dcr-reg
  1825. - num-tx-chans : 1 cell, number of Tx channels
  1826. - num-rx-chans : 1 cell, number of Rx channels
  1827. iii) ZMII node
  1828. Required properties:
  1829. - compatible : compatible list, containing 2 entries, first is
  1830. "ibm,zmii-CHIP" where CHIP is the host ASIC (like
  1831. EMAC) and the second is "ibm,zmii".
  1832. For Axon, there is no ZMII node.
  1833. - reg : <registers mapping>
  1834. iv) RGMII node
  1835. Required properties:
  1836. - compatible : compatible list, containing 2 entries, first is
  1837. "ibm,rgmii-CHIP" where CHIP is the host ASIC (like
  1838. EMAC) and the second is "ibm,rgmii".
  1839. For Axon, "ibm,rgmii-axon","ibm,rgmii"
  1840. - reg : <registers mapping>
  1841. - revision : as provided by the RGMII new version register if
  1842. available.
  1843. For Axon: 0x0000012a
  1844. l) Xilinx IP cores
  1845. The Xilinx EDK toolchain ships with a set of IP cores (devices) for use
  1846. in Xilinx Spartan and Virtex FPGAs. The devices cover the whole range
  1847. of standard device types (network, serial, etc.) and miscellanious
  1848. devices (gpio, LCD, spi, etc). Also, since these devices are
  1849. implemented within the fpga fabric every instance of the device can be
  1850. synthesised with different options that change the behaviour.
  1851. Each IP-core has a set of parameters which the FPGA designer can use to
  1852. control how the core is synthesized. Historically, the EDK tool would
  1853. extract the device parameters relevant to device drivers and copy them
  1854. into an 'xparameters.h' in the form of #define symbols. This tells the
  1855. device drivers how the IP cores are configured, but it requres the kernel
  1856. to be recompiled every time the FPGA bitstream is resynthesized.
  1857. The new approach is to export the parameters into the device tree and
  1858. generate a new device tree each time the FPGA bitstream changes. The
  1859. parameters which used to be exported as #defines will now become
  1860. properties of the device node. In general, device nodes for IP-cores
  1861. will take the following form:
  1862. (name)@(base-address) {
  1863. compatible = "xlnx,(ip-core-name)-(HW_VER)"
  1864. [, (list of compatible devices), ...];
  1865. reg = <(baseaddr) (size)>;
  1866. interrupt-parent = <&interrupt-controller-phandle>;
  1867. interrupts = < ... >;
  1868. xlnx,(parameter1) = "(string-value)";
  1869. xlnx,(parameter2) = <(int-value)>;
  1870. };
  1871. (ip-core-name): the name of the ip block (given after the BEGIN
  1872. directive in system.mhs). Should be in lowercase
  1873. and all underscores '_' converted to dashes '-'.
  1874. (name): is derived from the "PARAMETER INSTANCE" value.
  1875. (parameter#): C_* parameters from system.mhs. The C_ prefix is
  1876. dropped from the parameter name, the name is converted
  1877. to lowercase and all underscore '_' characters are
  1878. converted to dashes '-'.
  1879. (baseaddr): the C_BASEADDR parameter.
  1880. (HW_VER): from the HW_VER parameter.
  1881. (size): equals C_HIGHADDR - C_BASEADDR + 1
  1882. Typically, the compatible list will include the exact IP core version
  1883. followed by an older IP core version which implements the same
  1884. interface or any other device with the same interface.
  1885. 'reg', 'interrupt-parent' and 'interrupts' are all optional properties.
  1886. For example, the following block from system.mhs:
  1887. BEGIN opb_uartlite
  1888. PARAMETER INSTANCE = opb_uartlite_0
  1889. PARAMETER HW_VER = 1.00.b
  1890. PARAMETER C_BAUDRATE = 115200
  1891. PARAMETER C_DATA_BITS = 8
  1892. PARAMETER C_ODD_PARITY = 0
  1893. PARAMETER C_USE_PARITY = 0
  1894. PARAMETER C_CLK_FREQ = 50000000
  1895. PARAMETER C_BASEADDR = 0xEC100000
  1896. PARAMETER C_HIGHADDR = 0xEC10FFFF
  1897. BUS_INTERFACE SOPB = opb_7
  1898. PORT OPB_Clk = CLK_50MHz
  1899. PORT Interrupt = opb_uartlite_0_Interrupt
  1900. PORT RX = opb_uartlite_0_RX
  1901. PORT TX = opb_uartlite_0_TX
  1902. PORT OPB_Rst = sys_bus_reset_0
  1903. END
  1904. becomes the following device tree node:
  1905. opb-uartlite-0@ec100000 {
  1906. device_type = "serial";
  1907. compatible = "xlnx,opb-uartlite-1.00.b";
  1908. reg = <ec100000 10000>;
  1909. interrupt-parent = <&opb-intc>;
  1910. interrupts = <1 0>; // got this from the opb_intc parameters
  1911. current-speed = <d#115200>; // standard serial device prop
  1912. clock-frequency = <d#50000000>; // standard serial device prop
  1913. xlnx,data-bits = <8>;
  1914. xlnx,odd-parity = <0>;
  1915. xlnx,use-parity = <0>;
  1916. };
  1917. Some IP cores actually implement 2 or more logical devices. In this case,
  1918. the device should still describe the whole IP core with a single node
  1919. and add a child node for each logical device. The ranges property can
  1920. be used to translate from parent IP-core to the registers of each device.
  1921. (Note: this makes the assumption that both logical devices have the same
  1922. bus binding. If this is not true, then separate nodes should be used for
  1923. each logical device). The 'cell-index' property can be used to enumerate
  1924. logical devices within an IP core. For example, the following is the
  1925. system.mhs entry for the dual ps2 controller found on the ml403 reference
  1926. design.
  1927. BEGIN opb_ps2_dual_ref
  1928. PARAMETER INSTANCE = opb_ps2_dual_ref_0
  1929. PARAMETER HW_VER = 1.00.a
  1930. PARAMETER C_BASEADDR = 0xA9000000
  1931. PARAMETER C_HIGHADDR = 0xA9001FFF
  1932. BUS_INTERFACE SOPB = opb_v20_0
  1933. PORT Sys_Intr1 = ps2_1_intr
  1934. PORT Sys_Intr2 = ps2_2_intr
  1935. PORT Clkin1 = ps2_clk_rx_1
  1936. PORT Clkin2 = ps2_clk_rx_2
  1937. PORT Clkpd1 = ps2_clk_tx_1
  1938. PORT Clkpd2 = ps2_clk_tx_2
  1939. PORT Rx1 = ps2_d_rx_1
  1940. PORT Rx2 = ps2_d_rx_2
  1941. PORT Txpd1 = ps2_d_tx_1
  1942. PORT Txpd2 = ps2_d_tx_2
  1943. END
  1944. It would result in the following device tree nodes:
  1945. opb_ps2_dual_ref_0@a9000000 {
  1946. ranges = <0 a9000000 2000>;
  1947. // If this device had extra parameters, then they would
  1948. // go here.
  1949. ps2@0 {
  1950. compatible = "xlnx,opb-ps2-dual-ref-1.00.a";
  1951. reg = <0 40>;
  1952. interrupt-parent = <&opb-intc>;
  1953. interrupts = <3 0>;
  1954. cell-index = <0>;
  1955. };
  1956. ps2@1000 {
  1957. compatible = "xlnx,opb-ps2-dual-ref-1.00.a";
  1958. reg = <1000 40>;
  1959. interrupt-parent = <&opb-intc>;
  1960. interrupts = <3 0>;
  1961. cell-index = <0>;
  1962. };
  1963. };
  1964. Also, the system.mhs file defines bus attachments from the processor
  1965. to the devices. The device tree structure should reflect the bus
  1966. attachments. Again an example; this system.mhs fragment:
  1967. BEGIN ppc405_virtex4
  1968. PARAMETER INSTANCE = ppc405_0
  1969. PARAMETER HW_VER = 1.01.a
  1970. BUS_INTERFACE DPLB = plb_v34_0
  1971. BUS_INTERFACE IPLB = plb_v34_0
  1972. END
  1973. BEGIN opb_intc
  1974. PARAMETER INSTANCE = opb_intc_0
  1975. PARAMETER HW_VER = 1.00.c
  1976. PARAMETER C_BASEADDR = 0xD1000FC0
  1977. PARAMETER C_HIGHADDR = 0xD1000FDF
  1978. BUS_INTERFACE SOPB = opb_v20_0
  1979. END
  1980. BEGIN opb_uart16550
  1981. PARAMETER INSTANCE = opb_uart16550_0
  1982. PARAMETER HW_VER = 1.00.d
  1983. PARAMETER C_BASEADDR = 0xa0000000
  1984. PARAMETER C_HIGHADDR = 0xa0001FFF
  1985. BUS_INTERFACE SOPB = opb_v20_0
  1986. END
  1987. BEGIN plb_v34
  1988. PARAMETER INSTANCE = plb_v34_0
  1989. PARAMETER HW_VER = 1.02.a
  1990. END
  1991. BEGIN plb_bram_if_cntlr
  1992. PARAMETER INSTANCE = plb_bram_if_cntlr_0
  1993. PARAMETER HW_VER = 1.00.b
  1994. PARAMETER C_BASEADDR = 0xFFFF0000
  1995. PARAMETER C_HIGHADDR = 0xFFFFFFFF
  1996. BUS_INTERFACE SPLB = plb_v34_0
  1997. END
  1998. BEGIN plb2opb_bridge
  1999. PARAMETER INSTANCE = plb2opb_bridge_0
  2000. PARAMETER HW_VER = 1.01.a
  2001. PARAMETER C_RNG0_BASEADDR = 0x20000000
  2002. PARAMETER C_RNG0_HIGHADDR = 0x3FFFFFFF
  2003. PARAMETER C_RNG1_BASEADDR = 0x60000000
  2004. PARAMETER C_RNG1_HIGHADDR = 0x7FFFFFFF
  2005. PARAMETER C_RNG2_BASEADDR = 0x80000000
  2006. PARAMETER C_RNG2_HIGHADDR = 0xBFFFFFFF
  2007. PARAMETER C_RNG3_BASEADDR = 0xC0000000
  2008. PARAMETER C_RNG3_HIGHADDR = 0xDFFFFFFF
  2009. BUS_INTERFACE SPLB = plb_v34_0
  2010. BUS_INTERFACE MOPB = opb_v20_0
  2011. END
  2012. Gives this device tree (some properties removed for clarity):
  2013. plb-v34-0 {
  2014. #address-cells = <1>;
  2015. #size-cells = <1>;
  2016. device_type = "ibm,plb";
  2017. ranges; // 1:1 translation
  2018. plb-bram-if-cntrl-0@ffff0000 {
  2019. reg = <ffff0000 10000>;
  2020. }
  2021. opb-v20-0 {
  2022. #address-cells = <1>;
  2023. #size-cells = <1>;
  2024. ranges = <20000000 20000000 20000000
  2025. 60000000 60000000 20000000
  2026. 80000000 80000000 40000000
  2027. c0000000 c0000000 20000000>;
  2028. opb-uart16550-0@a0000000 {
  2029. reg = <a00000000 2000>;
  2030. };
  2031. opb-intc-0@d1000fc0 {
  2032. reg = <d1000fc0 20>;
  2033. };
  2034. };
  2035. };
  2036. That covers the general approach to binding xilinx IP cores into the
  2037. device tree. The following are bindings for specific devices:
  2038. i) Xilinx ML300 Framebuffer
  2039. Simple framebuffer device from the ML300 reference design (also on the
  2040. ML403 reference design as well as others).
  2041. Optional properties:
  2042. - resolution = <xres yres> : pixel resolution of framebuffer. Some
  2043. implementations use a different resolution.
  2044. Default is <d#640 d#480>
  2045. - virt-resolution = <xvirt yvirt> : Size of framebuffer in memory.
  2046. Default is <d#1024 d#480>.
  2047. - rotate-display (empty) : rotate display 180 degrees.
  2048. ii) Xilinx SystemACE
  2049. The Xilinx SystemACE device is used to program FPGAs from an FPGA
  2050. bitstream stored on a CF card. It can also be used as a generic CF
  2051. interface device.
  2052. Optional properties:
  2053. - 8-bit (empty) : Set this property for SystemACE in 8 bit mode
  2054. iii) Xilinx EMAC and Xilinx TEMAC
  2055. Xilinx Ethernet devices. In addition to general xilinx properties
  2056. listed above, nodes for these devices should include a phy-handle
  2057. property, and may include other common network device properties
  2058. like local-mac-address.
  2059. iv) Xilinx Uartlite
  2060. Xilinx uartlite devices are simple fixed speed serial ports.
  2061. Requred properties:
  2062. - current-speed : Baud rate of uartlite
  2063. More devices will be defined as this spec matures.
  2064. VII - Specifying interrupt information for devices
  2065. ===================================================
  2066. The device tree represents the busses and devices of a hardware
  2067. system in a form similar to the physical bus topology of the
  2068. hardware.
  2069. In addition, a logical 'interrupt tree' exists which represents the
  2070. hierarchy and routing of interrupts in the hardware.
  2071. The interrupt tree model is fully described in the
  2072. document "Open Firmware Recommended Practice: Interrupt
  2073. Mapping Version 0.9". The document is available at:
  2074. <http://playground.sun.com/1275/practice>.
  2075. 1) interrupts property
  2076. ----------------------
  2077. Devices that generate interrupts to a single interrupt controller
  2078. should use the conventional OF representation described in the
  2079. OF interrupt mapping documentation.
  2080. Each device which generates interrupts must have an 'interrupt'
  2081. property. The interrupt property value is an arbitrary number of
  2082. of 'interrupt specifier' values which describe the interrupt or
  2083. interrupts for the device.
  2084. The encoding of an interrupt specifier is determined by the
  2085. interrupt domain in which the device is located in the
  2086. interrupt tree. The root of an interrupt domain specifies in
  2087. its #interrupt-cells property the number of 32-bit cells
  2088. required to encode an interrupt specifier. See the OF interrupt
  2089. mapping documentation for a detailed description of domains.
  2090. For example, the binding for the OpenPIC interrupt controller
  2091. specifies an #interrupt-cells value of 2 to encode the interrupt
  2092. number and level/sense information. All interrupt children in an
  2093. OpenPIC interrupt domain use 2 cells per interrupt in their interrupts
  2094. property.
  2095. The PCI bus binding specifies a #interrupt-cell value of 1 to encode
  2096. which interrupt pin (INTA,INTB,INTC,INTD) is used.
  2097. 2) interrupt-parent property
  2098. ----------------------------
  2099. The interrupt-parent property is specified to define an explicit
  2100. link between a device node and its interrupt parent in
  2101. the interrupt tree. The value of interrupt-parent is the
  2102. phandle of the parent node.
  2103. If the interrupt-parent property is not defined for a node, it's
  2104. interrupt parent is assumed to be an ancestor in the node's
  2105. _device tree_ hierarchy.
  2106. 3) OpenPIC Interrupt Controllers
  2107. --------------------------------
  2108. OpenPIC interrupt controllers require 2 cells to encode
  2109. interrupt information. The first cell defines the interrupt
  2110. number. The second cell defines the sense and level
  2111. information.
  2112. Sense and level information should be encoded as follows:
  2113. 0 = low to high edge sensitive type enabled
  2114. 1 = active low level sensitive type enabled
  2115. 2 = active high level sensitive type enabled
  2116. 3 = high to low edge sensitive type enabled
  2117. 4) ISA Interrupt Controllers
  2118. ----------------------------
  2119. ISA PIC interrupt controllers require 2 cells to encode
  2120. interrupt information. The first cell defines the interrupt
  2121. number. The second cell defines the sense and level
  2122. information.
  2123. ISA PIC interrupt controllers should adhere to the ISA PIC
  2124. encodings listed below:
  2125. 0 = active low level sensitive type enabled
  2126. 1 = active high level sensitive type enabled
  2127. 2 = high to low edge sensitive type enabled
  2128. 3 = low to high edge sensitive type enabled
  2129. Appendix A - Sample SOC node for MPC8540
  2130. ========================================
  2131. Note that the #address-cells and #size-cells for the SoC node
  2132. in this example have been explicitly listed; these are likely
  2133. not necessary as they are usually the same as the root node.
  2134. soc8540@e0000000 {
  2135. #address-cells = <1>;
  2136. #size-cells = <1>;
  2137. #interrupt-cells = <2>;
  2138. device_type = "soc";
  2139. ranges = <00000000 e0000000 00100000>
  2140. reg = <e0000000 00003000>;
  2141. bus-frequency = <0>;
  2142. mdio@24520 {
  2143. reg = <24520 20>;
  2144. device_type = "mdio";
  2145. compatible = "gianfar";
  2146. ethernet-phy@0 {
  2147. linux,phandle = <2452000>
  2148. interrupt-parent = <40000>;
  2149. interrupts = <35 1>;
  2150. reg = <0>;
  2151. device_type = "ethernet-phy";
  2152. };
  2153. ethernet-phy@1 {
  2154. linux,phandle = <2452001>
  2155. interrupt-parent = <40000>;
  2156. interrupts = <35 1>;
  2157. reg = <1>;
  2158. device_type = "ethernet-phy";
  2159. };
  2160. ethernet-phy@3 {
  2161. linux,phandle = <2452002>
  2162. interrupt-parent = <40000>;
  2163. interrupts = <35 1>;
  2164. reg = <3>;
  2165. device_type = "ethernet-phy";
  2166. };
  2167. };
  2168. ethernet@24000 {
  2169. #size-cells = <0>;
  2170. device_type = "network";
  2171. model = "TSEC";
  2172. compatible = "gianfar";
  2173. reg = <24000 1000>;
  2174. mac-address = [ 00 E0 0C 00 73 00 ];
  2175. interrupts = <d 3 e 3 12 3>;
  2176. interrupt-parent = <40000>;
  2177. phy-handle = <2452000>;
  2178. };
  2179. ethernet@25000 {
  2180. #address-cells = <1>;
  2181. #size-cells = <0>;
  2182. device_type = "network";
  2183. model = "TSEC";
  2184. compatible = "gianfar";
  2185. reg = <25000 1000>;
  2186. mac-address = [ 00 E0 0C 00 73 01 ];
  2187. interrupts = <13 3 14 3 18 3>;
  2188. interrupt-parent = <40000>;
  2189. phy-handle = <2452001>;
  2190. };
  2191. ethernet@26000 {
  2192. #address-cells = <1>;
  2193. #size-cells = <0>;
  2194. device_type = "network";
  2195. model = "FEC";
  2196. compatible = "gianfar";
  2197. reg = <26000 1000>;
  2198. mac-address = [ 00 E0 0C 00 73 02 ];
  2199. interrupts = <19 3>;
  2200. interrupt-parent = <40000>;
  2201. phy-handle = <2452002>;
  2202. };
  2203. serial@4500 {
  2204. device_type = "serial";
  2205. compatible = "ns16550";
  2206. reg = <4500 100>;
  2207. clock-frequency = <0>;
  2208. interrupts = <1a 3>;
  2209. interrupt-parent = <40000>;
  2210. };
  2211. pic@40000 {
  2212. linux,phandle = <40000>;
  2213. clock-frequency = <0>;
  2214. interrupt-controller;
  2215. #address-cells = <0>;
  2216. reg = <40000 40000>;
  2217. built-in;
  2218. compatible = "chrp,open-pic";
  2219. device_type = "open-pic";
  2220. big-endian;
  2221. };
  2222. i2c@3000 {
  2223. interrupt-parent = <40000>;
  2224. interrupts = <1b 3>;
  2225. reg = <3000 18>;
  2226. device_type = "i2c";
  2227. compatible = "fsl-i2c";
  2228. dfsrr;
  2229. };
  2230. };