booting-without-of.txt 102 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747
  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 is
  587. 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, i.e., the registers are not visible on the
  592. parent bus. The format of the "ranges" property for a bus is a list
  593. of:
  594. bus address, parent bus address, size
  595. "bus address" is in the format of the bus this bus node is defining,
  596. that is, for a PCI bridge, it would be a PCI address. Thus, (bus
  597. address, size) defines a range of addresses for child devices. "parent
  598. bus address" is in the format of the parent bus of this bus. For
  599. example, for a PCI host controller, that would be a CPU address. For a
  600. PCI<->ISA bridge, that would be a PCI address. It defines the base
  601. address in the parent bus where the beginning of that range is mapped.
  602. For a new 64-bit powerpc board, I recommend either the 2/2 format or
  603. Apple's 2/1 format which is slightly more compact since sizes usually
  604. fit in a single 32-bit word. New 32-bit powerpc boards should use a
  605. 1/1 format, unless the processor supports physical addresses greater
  606. than 32-bits, in which case a 2/1 format is recommended.
  607. Alternatively, the "ranges" property may be empty, indicating that the
  608. registers are visible on the parent bus using an identity mapping
  609. translation. In other words, the parent bus address space is the same
  610. as the child bus address space.
  611. 2) Note about "compatible" properties
  612. -------------------------------------
  613. These properties are optional, but recommended in devices and the root
  614. node. The format of a "compatible" property is a list of concatenated
  615. zero terminated strings. They allow a device to express its
  616. compatibility with a family of similar devices, in some cases,
  617. allowing a single driver to match against several devices regardless
  618. of their actual names.
  619. 3) Note about "name" properties
  620. -------------------------------
  621. While earlier users of Open Firmware like OldWorld macintoshes tended
  622. to use the actual device name for the "name" property, it's nowadays
  623. considered a good practice to use a name that is closer to the device
  624. class (often equal to device_type). For example, nowadays, ethernet
  625. controllers are named "ethernet", an additional "model" property
  626. defining precisely the chip type/model, and "compatible" property
  627. defining the family in case a single driver can driver more than one
  628. of these chips. However, the kernel doesn't generally put any
  629. restriction on the "name" property; it is simply considered good
  630. practice to follow the standard and its evolutions as closely as
  631. possible.
  632. Note also that the new format version 16 makes the "name" property
  633. optional. If it's absent for a node, then the node's unit name is then
  634. used to reconstruct the name. That is, the part of the unit name
  635. before the "@" sign is used (or the entire unit name if no "@" sign
  636. is present).
  637. 4) Note about node and property names and character set
  638. -------------------------------------------------------
  639. While open firmware provides more flexible usage of 8859-1, this
  640. specification enforces more strict rules. Nodes and properties should
  641. be comprised only of ASCII characters 'a' to 'z', '0' to
  642. '9', ',', '.', '_', '+', '#', '?', and '-'. Node names additionally
  643. allow uppercase characters 'A' to 'Z' (property names should be
  644. lowercase. The fact that vendors like Apple don't respect this rule is
  645. irrelevant here). Additionally, node and property names should always
  646. begin with a character in the range 'a' to 'z' (or 'A' to 'Z' for node
  647. names).
  648. The maximum number of characters for both nodes and property names
  649. is 31. In the case of node names, this is only the leftmost part of
  650. a unit name (the pure "name" property), it doesn't include the unit
  651. address which can extend beyond that limit.
  652. 5) Required nodes and properties
  653. --------------------------------
  654. These are all that are currently required. However, it is strongly
  655. recommended that you expose PCI host bridges as documented in the
  656. PCI binding to open firmware, and your interrupt tree as documented
  657. in OF interrupt tree specification.
  658. a) The root node
  659. The root node requires some properties to be present:
  660. - model : this is your board name/model
  661. - #address-cells : address representation for "root" devices
  662. - #size-cells: the size representation for "root" devices
  663. - device_type : This property shouldn't be necessary. However, if
  664. you decide to create a device_type for your root node, make sure it
  665. is _not_ "chrp" unless your platform is a pSeries or PAPR compliant
  666. one for 64-bit, or a CHRP-type machine for 32-bit as this will
  667. matched by the kernel this way.
  668. Additionally, some recommended properties are:
  669. - compatible : the board "family" generally finds its way here,
  670. for example, if you have 2 board models with a similar layout,
  671. that typically get driven by the same platform code in the
  672. kernel, you would use a different "model" property but put a
  673. value in "compatible". The kernel doesn't directly use that
  674. value but it is generally useful.
  675. The root node is also generally where you add additional properties
  676. specific to your board like the serial number if any, that sort of
  677. thing. It is recommended that if you add any "custom" property whose
  678. name may clash with standard defined ones, you prefix them with your
  679. vendor name and a comma.
  680. b) The /cpus node
  681. This node is the parent of all individual CPU nodes. It doesn't
  682. have any specific requirements, though it's generally good practice
  683. to have at least:
  684. #address-cells = <00000001>
  685. #size-cells = <00000000>
  686. This defines that the "address" for a CPU is a single cell, and has
  687. no meaningful size. This is not necessary but the kernel will assume
  688. that format when reading the "reg" properties of a CPU node, see
  689. below
  690. c) The /cpus/* nodes
  691. So under /cpus, you are supposed to create a node for every CPU on
  692. the machine. There is no specific restriction on the name of the
  693. CPU, though It's common practice to call it PowerPC,<name>. For
  694. example, Apple uses PowerPC,G5 while IBM uses PowerPC,970FX.
  695. Required properties:
  696. - device_type : has to be "cpu"
  697. - reg : This is the physical CPU number, it's a single 32-bit cell
  698. and is also used as-is as the unit number for constructing the
  699. unit name in the full path. For example, with 2 CPUs, you would
  700. have the full path:
  701. /cpus/PowerPC,970FX@0
  702. /cpus/PowerPC,970FX@1
  703. (unit addresses do not require leading zeroes)
  704. - d-cache-block-size : one cell, L1 data cache block size in bytes (*)
  705. - i-cache-block-size : one cell, L1 instruction cache block size in
  706. bytes
  707. - d-cache-size : one cell, size of L1 data cache in bytes
  708. - i-cache-size : one cell, size of L1 instruction cache in bytes
  709. (*) The cache "block" size is the size on which the cache management
  710. instructions operate. Historically, this document used the cache
  711. "line" size here which is incorrect. The kernel will prefer the cache
  712. block size and will fallback to cache line size for backward
  713. compatibility.
  714. Recommended properties:
  715. - timebase-frequency : a cell indicating the frequency of the
  716. timebase in Hz. This is not directly used by the generic code,
  717. but you are welcome to copy/paste the pSeries code for setting
  718. the kernel timebase/decrementer calibration based on this
  719. value.
  720. - clock-frequency : a cell indicating the CPU core clock frequency
  721. in Hz. A new property will be defined for 64-bit values, but if
  722. your frequency is < 4Ghz, one cell is enough. Here as well as
  723. for the above, the common code doesn't use that property, but
  724. you are welcome to re-use the pSeries or Maple one. A future
  725. kernel version might provide a common function for this.
  726. - d-cache-line-size : one cell, L1 data cache line size in bytes
  727. if different from the block size
  728. - i-cache-line-size : one cell, L1 instruction cache line size in
  729. bytes if different from the block size
  730. You are welcome to add any property you find relevant to your board,
  731. like some information about the mechanism used to soft-reset the
  732. CPUs. For example, Apple puts the GPIO number for CPU soft reset
  733. lines in there as a "soft-reset" property since they start secondary
  734. CPUs by soft-resetting them.
  735. d) the /memory node(s)
  736. To define the physical memory layout of your board, you should
  737. create one or more memory node(s). You can either create a single
  738. node with all memory ranges in its reg property, or you can create
  739. several nodes, as you wish. The unit address (@ part) used for the
  740. full path is the address of the first range of memory defined by a
  741. given node. If you use a single memory node, this will typically be
  742. @0.
  743. Required properties:
  744. - device_type : has to be "memory"
  745. - reg : This property contains all the physical memory ranges of
  746. your board. It's a list of addresses/sizes concatenated
  747. together, with the number of cells of each defined by the
  748. #address-cells and #size-cells of the root node. For example,
  749. with both of these properties being 2 like in the example given
  750. earlier, a 970 based machine with 6Gb of RAM could typically
  751. have a "reg" property here that looks like:
  752. 00000000 00000000 00000000 80000000
  753. 00000001 00000000 00000001 00000000
  754. That is a range starting at 0 of 0x80000000 bytes and a range
  755. starting at 0x100000000 and of 0x100000000 bytes. You can see
  756. that there is no memory covering the IO hole between 2Gb and
  757. 4Gb. Some vendors prefer splitting those ranges into smaller
  758. segments, but the kernel doesn't care.
  759. e) The /chosen node
  760. This node is a bit "special". Normally, that's where open firmware
  761. puts some variable environment information, like the arguments, or
  762. the default input/output devices.
  763. This specification makes a few of these mandatory, but also defines
  764. some linux-specific properties that would be normally constructed by
  765. the prom_init() trampoline when booting with an OF client interface,
  766. but that you have to provide yourself when using the flattened format.
  767. Recommended properties:
  768. - bootargs : This zero-terminated string is passed as the kernel
  769. command line
  770. - linux,stdout-path : This is the full path to your standard
  771. console device if any. Typically, if you have serial devices on
  772. your board, you may want to put the full path to the one set as
  773. the default console in the firmware here, for the kernel to pick
  774. it up as its own default console. If you look at the function
  775. set_preferred_console() in arch/ppc64/kernel/setup.c, you'll see
  776. that the kernel tries to find out the default console and has
  777. knowledge of various types like 8250 serial ports. You may want
  778. to extend this function to add your own.
  779. Note that u-boot creates and fills in the chosen node for platforms
  780. that use it.
  781. (Note: a practice that is now obsolete was to include a property
  782. under /chosen called interrupt-controller which had a phandle value
  783. that pointed to the main interrupt controller)
  784. f) the /soc<SOCname> node
  785. This node is used to represent a system-on-a-chip (SOC) and must be
  786. present if the processor is a SOC. The top-level soc node contains
  787. information that is global to all devices on the SOC. The node name
  788. should contain a unit address for the SOC, which is the base address
  789. of the memory-mapped register set for the SOC. The name of an soc
  790. node should start with "soc", and the remainder of the name should
  791. represent the part number for the soc. For example, the MPC8540's
  792. soc node would be called "soc8540".
  793. Required properties:
  794. - device_type : Should be "soc"
  795. - ranges : Should be defined as specified in 1) to describe the
  796. translation of SOC addresses for memory mapped SOC registers.
  797. - bus-frequency: Contains the bus frequency for the SOC node.
  798. Typically, the value of this field is filled in by the boot
  799. loader.
  800. Recommended properties:
  801. - reg : This property defines the address and size of the
  802. memory-mapped registers that are used for the SOC node itself.
  803. It does not include the child device registers - these will be
  804. defined inside each child node. The address specified in the
  805. "reg" property should match the unit address of the SOC node.
  806. - #address-cells : Address representation for "soc" devices. The
  807. format of this field may vary depending on whether or not the
  808. device registers are memory mapped. For memory mapped
  809. registers, this field represents the number of cells needed to
  810. represent the address of the registers. For SOCs that do not
  811. use MMIO, a special address format should be defined that
  812. contains enough cells to represent the required information.
  813. See 1) above for more details on defining #address-cells.
  814. - #size-cells : Size representation for "soc" devices
  815. - #interrupt-cells : Defines the width of cells used to represent
  816. interrupts. Typically this value is <2>, which includes a
  817. 32-bit number that represents the interrupt number, and a
  818. 32-bit number that represents the interrupt sense and level.
  819. This field is only needed if the SOC contains an interrupt
  820. controller.
  821. The SOC node may contain child nodes for each SOC device that the
  822. platform uses. Nodes should not be created for devices which exist
  823. on the SOC but are not used by a particular platform. See chapter VI
  824. for more information on how to specify devices that are part of a SOC.
  825. Example SOC node for the MPC8540:
  826. soc8540@e0000000 {
  827. #address-cells = <1>;
  828. #size-cells = <1>;
  829. #interrupt-cells = <2>;
  830. device_type = "soc";
  831. ranges = <00000000 e0000000 00100000>
  832. reg = <e0000000 00003000>;
  833. bus-frequency = <0>;
  834. }
  835. IV - "dtc", the device tree compiler
  836. ====================================
  837. dtc source code can be found at
  838. <http://ozlabs.org/~dgibson/dtc/dtc.tar.gz>
  839. WARNING: This version is still in early development stage; the
  840. resulting device-tree "blobs" have not yet been validated with the
  841. kernel. The current generated bloc lacks a useful reserve map (it will
  842. be fixed to generate an empty one, it's up to the bootloader to fill
  843. it up) among others. The error handling needs work, bugs are lurking,
  844. etc...
  845. dtc basically takes a device-tree in a given format and outputs a
  846. device-tree in another format. The currently supported formats are:
  847. Input formats:
  848. -------------
  849. - "dtb": "blob" format, that is a flattened device-tree block
  850. with
  851. header all in a binary blob.
  852. - "dts": "source" format. This is a text file containing a
  853. "source" for a device-tree. The format is defined later in this
  854. chapter.
  855. - "fs" format. This is a representation equivalent to the
  856. output of /proc/device-tree, that is nodes are directories and
  857. properties are files
  858. Output formats:
  859. ---------------
  860. - "dtb": "blob" format
  861. - "dts": "source" format
  862. - "asm": assembly language file. This is a file that can be
  863. sourced by gas to generate a device-tree "blob". That file can
  864. then simply be added to your Makefile. Additionally, the
  865. assembly file exports some symbols that can be used.
  866. The syntax of the dtc tool is
  867. dtc [-I <input-format>] [-O <output-format>]
  868. [-o output-filename] [-V output_version] input_filename
  869. The "output_version" defines what version of the "blob" format will be
  870. generated. Supported versions are 1,2,3 and 16. The default is
  871. currently version 3 but that may change in the future to version 16.
  872. Additionally, dtc performs various sanity checks on the tree, like the
  873. uniqueness of linux, phandle properties, validity of strings, etc...
  874. The format of the .dts "source" file is "C" like, supports C and C++
  875. style comments.
  876. / {
  877. }
  878. The above is the "device-tree" definition. It's the only statement
  879. supported currently at the toplevel.
  880. / {
  881. property1 = "string_value"; /* define a property containing a 0
  882. * terminated string
  883. */
  884. property2 = <1234abcd>; /* define a property containing a
  885. * numerical 32-bit value (hexadecimal)
  886. */
  887. property3 = <12345678 12345678 deadbeef>;
  888. /* define a property containing 3
  889. * numerical 32-bit values (cells) in
  890. * hexadecimal
  891. */
  892. property4 = [0a 0b 0c 0d de ea ad be ef];
  893. /* define a property whose content is
  894. * an arbitrary array of bytes
  895. */
  896. childnode@addresss { /* define a child node named "childnode"
  897. * whose unit name is "childnode at
  898. * address"
  899. */
  900. childprop = "hello\n"; /* define a property "childprop" of
  901. * childnode (in this case, a string)
  902. */
  903. };
  904. };
  905. Nodes can contain other nodes etc... thus defining the hierarchical
  906. structure of the tree.
  907. Strings support common escape sequences from C: "\n", "\t", "\r",
  908. "\(octal value)", "\x(hex value)".
  909. It is also suggested that you pipe your source file through cpp (gcc
  910. preprocessor) so you can use #include's, #define for constants, etc...
  911. Finally, various options are planned but not yet implemented, like
  912. automatic generation of phandles, labels (exported to the asm file so
  913. you can point to a property content and change it easily from whatever
  914. you link the device-tree with), label or path instead of numeric value
  915. in some cells to "point" to a node (replaced by a phandle at compile
  916. time), export of reserve map address to the asm file, ability to
  917. specify reserve map content at compile time, etc...
  918. We may provide a .h include file with common definitions of that
  919. proves useful for some properties (like building PCI properties or
  920. interrupt maps) though it may be better to add a notion of struct
  921. definitions to the compiler...
  922. V - Recommendations for a bootloader
  923. ====================================
  924. Here are some various ideas/recommendations that have been proposed
  925. while all this has been defined and implemented.
  926. - The bootloader may want to be able to use the device-tree itself
  927. and may want to manipulate it (to add/edit some properties,
  928. like physical memory size or kernel arguments). At this point, 2
  929. choices can be made. Either the bootloader works directly on the
  930. flattened format, or the bootloader has its own internal tree
  931. representation with pointers (similar to the kernel one) and
  932. re-flattens the tree when booting the kernel. The former is a bit
  933. more difficult to edit/modify, the later requires probably a bit
  934. more code to handle the tree structure. Note that the structure
  935. format has been designed so it's relatively easy to "insert"
  936. properties or nodes or delete them by just memmoving things
  937. around. It contains no internal offsets or pointers for this
  938. purpose.
  939. - An example of code for iterating nodes & retrieving properties
  940. directly from the flattened tree format can be found in the kernel
  941. file arch/ppc64/kernel/prom.c, look at scan_flat_dt() function,
  942. its usage in early_init_devtree(), and the corresponding various
  943. early_init_dt_scan_*() callbacks. That code can be re-used in a
  944. GPL bootloader, and as the author of that code, I would be happy
  945. to discuss possible free licensing to any vendor who wishes to
  946. integrate all or part of this code into a non-GPL bootloader.
  947. VI - System-on-a-chip devices and nodes
  948. =======================================
  949. Many companies are now starting to develop system-on-a-chip
  950. processors, where the processor core (CPU) and many peripheral devices
  951. exist on a single piece of silicon. For these SOCs, an SOC node
  952. should be used that defines child nodes for the devices that make
  953. up the SOC. While platforms are not required to use this model in
  954. order to boot the kernel, it is highly encouraged that all SOC
  955. implementations define as complete a flat-device-tree as possible to
  956. describe the devices on the SOC. This will allow for the
  957. genericization of much of the kernel code.
  958. 1) Defining child nodes of an SOC
  959. ---------------------------------
  960. Each device that is part of an SOC may have its own node entry inside
  961. the SOC node. For each device that is included in the SOC, the unit
  962. address property represents the address offset for this device's
  963. memory-mapped registers in the parent's address space. The parent's
  964. address space is defined by the "ranges" property in the top-level soc
  965. node. The "reg" property for each node that exists directly under the
  966. SOC node should contain the address mapping from the child address space
  967. to the parent SOC address space and the size of the device's
  968. memory-mapped register file.
  969. For many devices that may exist inside an SOC, there are predefined
  970. specifications for the format of the device tree node. All SOC child
  971. nodes should follow these specifications, except where noted in this
  972. document.
  973. See appendix A for an example partial SOC node definition for the
  974. MPC8540.
  975. 2) Representing devices without a current OF specification
  976. ----------------------------------------------------------
  977. Currently, there are many devices on SOCs that do not have a standard
  978. representation pre-defined as part of the open firmware
  979. specifications, mainly because the boards that contain these SOCs are
  980. not currently booted using open firmware. This section contains
  981. descriptions for the SOC devices for which new nodes have been
  982. defined; this list will expand as more and more SOC-containing
  983. platforms are moved over to use the flattened-device-tree model.
  984. a) MDIO IO device
  985. The MDIO is a bus to which the PHY devices are connected. For each
  986. device that exists on this bus, a child node should be created. See
  987. the definition of the PHY node below for an example of how to define
  988. a PHY.
  989. Required properties:
  990. - reg : Offset and length of the register set for the device
  991. - compatible : Should define the compatible device type for the
  992. mdio. Currently, this is most likely to be "fsl,gianfar-mdio"
  993. Example:
  994. mdio@24520 {
  995. reg = <24520 20>;
  996. compatible = "fsl,gianfar-mdio";
  997. ethernet-phy@0 {
  998. ......
  999. };
  1000. };
  1001. b) Gianfar-compatible ethernet nodes
  1002. Required properties:
  1003. - device_type : Should be "network"
  1004. - model : Model of the device. Can be "TSEC", "eTSEC", or "FEC"
  1005. - compatible : Should be "gianfar"
  1006. - reg : Offset and length of the register set for the device
  1007. - mac-address : List of bytes representing the ethernet address of
  1008. this controller
  1009. - interrupts : <a b> where a is the interrupt number and b is a
  1010. field that represents an encoding of the sense and level
  1011. information for the interrupt. This should be encoded based on
  1012. the information in section 2) depending on the type of interrupt
  1013. controller you have.
  1014. - interrupt-parent : the phandle for the interrupt controller that
  1015. services interrupts for this device.
  1016. - phy-handle : The phandle for the PHY connected to this ethernet
  1017. controller.
  1018. Recommended properties:
  1019. - linux,network-index : This is the intended "index" of this
  1020. network device. This is used by the bootwrapper to interpret
  1021. MAC addresses passed by the firmware when no information other
  1022. than indices is available to associate an address with a device.
  1023. - phy-connection-type : a string naming the controller/PHY interface type,
  1024. i.e., "mii" (default), "rmii", "gmii", "rgmii", "rgmii-id", "sgmii",
  1025. "tbi", or "rtbi". This property is only really needed if the connection
  1026. is of type "rgmii-id", as all other connection types are detected by
  1027. hardware.
  1028. Example:
  1029. ethernet@24000 {
  1030. #size-cells = <0>;
  1031. device_type = "network";
  1032. model = "TSEC";
  1033. compatible = "gianfar";
  1034. reg = <24000 1000>;
  1035. mac-address = [ 00 E0 0C 00 73 00 ];
  1036. interrupts = <d 3 e 3 12 3>;
  1037. interrupt-parent = <40000>;
  1038. phy-handle = <2452000>
  1039. };
  1040. c) PHY nodes
  1041. Required properties:
  1042. - device_type : Should be "ethernet-phy"
  1043. - interrupts : <a b> where a is the interrupt number and b is a
  1044. field that represents an encoding of the sense and level
  1045. information for the interrupt. This should be encoded based on
  1046. the information in section 2) depending on the type of interrupt
  1047. controller you have.
  1048. - interrupt-parent : the phandle for the interrupt controller that
  1049. services interrupts for this device.
  1050. - reg : The ID number for the phy, usually a small integer
  1051. - linux,phandle : phandle for this node; likely referenced by an
  1052. ethernet controller node.
  1053. Example:
  1054. ethernet-phy@0 {
  1055. linux,phandle = <2452000>
  1056. interrupt-parent = <40000>;
  1057. interrupts = <35 1>;
  1058. reg = <0>;
  1059. device_type = "ethernet-phy";
  1060. };
  1061. d) Interrupt controllers
  1062. Some SOC devices contain interrupt controllers that are different
  1063. from the standard Open PIC specification. The SOC device nodes for
  1064. these types of controllers should be specified just like a standard
  1065. OpenPIC controller. Sense and level information should be encoded
  1066. as specified in section 2) of this chapter for each device that
  1067. specifies an interrupt.
  1068. Example :
  1069. pic@40000 {
  1070. linux,phandle = <40000>;
  1071. clock-frequency = <0>;
  1072. interrupt-controller;
  1073. #address-cells = <0>;
  1074. reg = <40000 40000>;
  1075. built-in;
  1076. compatible = "chrp,open-pic";
  1077. device_type = "open-pic";
  1078. big-endian;
  1079. };
  1080. e) I2C
  1081. Required properties :
  1082. - device_type : Should be "i2c"
  1083. - reg : Offset and length of the register set for the device
  1084. Recommended properties :
  1085. - compatible : Should be "fsl-i2c" for parts compatible with
  1086. Freescale I2C specifications.
  1087. - interrupts : <a b> where a is the interrupt number and b is a
  1088. field that represents an encoding of the sense and level
  1089. information for the interrupt. This should be encoded based on
  1090. the information in section 2) depending on the type of interrupt
  1091. controller you have.
  1092. - interrupt-parent : the phandle for the interrupt controller that
  1093. services interrupts for this device.
  1094. - dfsrr : boolean; if defined, indicates that this I2C device has
  1095. a digital filter sampling rate register
  1096. - fsl5200-clocking : boolean; if defined, indicated that this device
  1097. uses the FSL 5200 clocking mechanism.
  1098. Example :
  1099. i2c@3000 {
  1100. interrupt-parent = <40000>;
  1101. interrupts = <1b 3>;
  1102. reg = <3000 18>;
  1103. device_type = "i2c";
  1104. compatible = "fsl-i2c";
  1105. dfsrr;
  1106. };
  1107. f) Freescale SOC USB controllers
  1108. The device node for a USB controller that is part of a Freescale
  1109. SOC is as described in the document "Open Firmware Recommended
  1110. Practice : Universal Serial Bus" with the following modifications
  1111. and additions :
  1112. Required properties :
  1113. - compatible : Should be "fsl-usb2-mph" for multi port host USB
  1114. controllers, or "fsl-usb2-dr" for dual role USB controllers
  1115. - phy_type : For multi port host USB controllers, should be one of
  1116. "ulpi", or "serial". For dual role USB controllers, should be
  1117. one of "ulpi", "utmi", "utmi_wide", or "serial".
  1118. - reg : Offset and length of the register set for the device
  1119. - port0 : boolean; if defined, indicates port0 is connected for
  1120. fsl-usb2-mph compatible controllers. Either this property or
  1121. "port1" (or both) must be defined for "fsl-usb2-mph" compatible
  1122. controllers.
  1123. - port1 : boolean; if defined, indicates port1 is connected for
  1124. fsl-usb2-mph compatible controllers. Either this property or
  1125. "port0" (or both) must be defined for "fsl-usb2-mph" compatible
  1126. controllers.
  1127. - dr_mode : indicates the working mode for "fsl-usb2-dr" compatible
  1128. controllers. Can be "host", "peripheral", or "otg". Default to
  1129. "host" if not defined for backward compatibility.
  1130. Recommended properties :
  1131. - interrupts : <a b> where a is the interrupt number and b is a
  1132. field that represents an encoding of the sense and level
  1133. information for the interrupt. This should be encoded based on
  1134. the information in section 2) depending on the type of interrupt
  1135. controller you have.
  1136. - interrupt-parent : the phandle for the interrupt controller that
  1137. services interrupts for this device.
  1138. Example multi port host USB controller device node :
  1139. usb@22000 {
  1140. device_type = "usb";
  1141. compatible = "fsl-usb2-mph";
  1142. reg = <22000 1000>;
  1143. #address-cells = <1>;
  1144. #size-cells = <0>;
  1145. interrupt-parent = <700>;
  1146. interrupts = <27 1>;
  1147. phy_type = "ulpi";
  1148. port0;
  1149. port1;
  1150. };
  1151. Example dual role USB controller device node :
  1152. usb@23000 {
  1153. device_type = "usb";
  1154. compatible = "fsl-usb2-dr";
  1155. reg = <23000 1000>;
  1156. #address-cells = <1>;
  1157. #size-cells = <0>;
  1158. interrupt-parent = <700>;
  1159. interrupts = <26 1>;
  1160. dr_mode = "otg";
  1161. phy = "ulpi";
  1162. };
  1163. g) Freescale SOC SEC Security Engines
  1164. Required properties:
  1165. - device_type : Should be "crypto"
  1166. - model : Model of the device. Should be "SEC1" or "SEC2"
  1167. - compatible : Should be "talitos"
  1168. - reg : Offset and length of the register set for the device
  1169. - interrupts : <a b> where a is the interrupt number and b is a
  1170. field that represents an encoding of the sense and level
  1171. information for the interrupt. This should be encoded based on
  1172. the information in section 2) depending on the type of interrupt
  1173. controller you have.
  1174. - interrupt-parent : the phandle for the interrupt controller that
  1175. services interrupts for this device.
  1176. - num-channels : An integer representing the number of channels
  1177. available.
  1178. - channel-fifo-len : An integer representing the number of
  1179. descriptor pointers each channel fetch fifo can hold.
  1180. - exec-units-mask : The bitmask representing what execution units
  1181. (EUs) are available. It's a single 32-bit cell. EU information
  1182. should be encoded following the SEC's Descriptor Header Dword
  1183. EU_SEL0 field documentation, i.e. as follows:
  1184. bit 0 = reserved - should be 0
  1185. bit 1 = set if SEC has the ARC4 EU (AFEU)
  1186. bit 2 = set if SEC has the DES/3DES EU (DEU)
  1187. bit 3 = set if SEC has the message digest EU (MDEU)
  1188. bit 4 = set if SEC has the random number generator EU (RNG)
  1189. bit 5 = set if SEC has the public key EU (PKEU)
  1190. bit 6 = set if SEC has the AES EU (AESU)
  1191. bit 7 = set if SEC has the Kasumi EU (KEU)
  1192. bits 8 through 31 are reserved for future SEC EUs.
  1193. - descriptor-types-mask : The bitmask representing what descriptors
  1194. are available. It's a single 32-bit cell. Descriptor type
  1195. information should be encoded following the SEC's Descriptor
  1196. Header Dword DESC_TYPE field documentation, i.e. as follows:
  1197. bit 0 = set if SEC supports the aesu_ctr_nonsnoop desc. type
  1198. bit 1 = set if SEC supports the ipsec_esp descriptor type
  1199. bit 2 = set if SEC supports the common_nonsnoop desc. type
  1200. bit 3 = set if SEC supports the 802.11i AES ccmp desc. type
  1201. bit 4 = set if SEC supports the hmac_snoop_no_afeu desc. type
  1202. bit 5 = set if SEC supports the srtp descriptor type
  1203. bit 6 = set if SEC supports the non_hmac_snoop_no_afeu desc.type
  1204. bit 7 = set if SEC supports the pkeu_assemble descriptor type
  1205. bit 8 = set if SEC supports the aesu_key_expand_output desc.type
  1206. bit 9 = set if SEC supports the pkeu_ptmul descriptor type
  1207. bit 10 = set if SEC supports the common_nonsnoop_afeu desc. type
  1208. bit 11 = set if SEC supports the pkeu_ptadd_dbl descriptor type
  1209. ..and so on and so forth.
  1210. Example:
  1211. /* MPC8548E */
  1212. crypto@30000 {
  1213. device_type = "crypto";
  1214. model = "SEC2";
  1215. compatible = "talitos";
  1216. reg = <30000 10000>;
  1217. interrupts = <1d 3>;
  1218. interrupt-parent = <40000>;
  1219. num-channels = <4>;
  1220. channel-fifo-len = <18>;
  1221. exec-units-mask = <000000fe>;
  1222. descriptor-types-mask = <012b0ebf>;
  1223. };
  1224. h) Board Control and Status (BCSR)
  1225. Required properties:
  1226. - device_type : Should be "board-control"
  1227. - reg : Offset and length of the register set for the device
  1228. Example:
  1229. bcsr@f8000000 {
  1230. device_type = "board-control";
  1231. reg = <f8000000 8000>;
  1232. };
  1233. i) Freescale QUICC Engine module (QE)
  1234. This represents qe module that is installed on PowerQUICC II Pro.
  1235. NOTE: This is an interim binding; it should be updated to fit
  1236. in with the CPM binding later in this document.
  1237. Basically, it is a bus of devices, that could act more or less
  1238. as a complete entity (UCC, USB etc ). All of them should be siblings on
  1239. the "root" qe node, using the common properties from there.
  1240. The description below applies to the qe of MPC8360 and
  1241. more nodes and properties would be extended in the future.
  1242. i) Root QE device
  1243. Required properties:
  1244. - device_type : should be "qe";
  1245. - model : precise model of the QE, Can be "QE", "CPM", or "CPM2"
  1246. - reg : offset and length of the device registers.
  1247. - bus-frequency : the clock frequency for QUICC Engine.
  1248. Recommended properties
  1249. - brg-frequency : the internal clock source frequency for baud-rate
  1250. generators in Hz.
  1251. Example:
  1252. qe@e0100000 {
  1253. #address-cells = <1>;
  1254. #size-cells = <1>;
  1255. #interrupt-cells = <2>;
  1256. device_type = "qe";
  1257. model = "QE";
  1258. ranges = <0 e0100000 00100000>;
  1259. reg = <e0100000 480>;
  1260. brg-frequency = <0>;
  1261. bus-frequency = <179A7B00>;
  1262. }
  1263. ii) SPI (Serial Peripheral Interface)
  1264. Required properties:
  1265. - device_type : should be "spi".
  1266. - compatible : should be "fsl_spi".
  1267. - mode : the SPI operation mode, it can be "cpu" or "cpu-qe".
  1268. - reg : Offset and length of the register set for the device
  1269. - interrupts : <a b> where a is the interrupt number and b is a
  1270. field that represents an encoding of the sense and level
  1271. information for the interrupt. This should be encoded based on
  1272. the information in section 2) depending on the type of interrupt
  1273. controller you have.
  1274. - interrupt-parent : the phandle for the interrupt controller that
  1275. services interrupts for this device.
  1276. Example:
  1277. spi@4c0 {
  1278. device_type = "spi";
  1279. compatible = "fsl_spi";
  1280. reg = <4c0 40>;
  1281. interrupts = <82 0>;
  1282. interrupt-parent = <700>;
  1283. mode = "cpu";
  1284. };
  1285. iii) USB (Universal Serial Bus Controller)
  1286. Required properties:
  1287. - device_type : should be "usb".
  1288. - compatible : could be "qe_udc" or "fhci-hcd".
  1289. - mode : the could be "host" or "slave".
  1290. - reg : Offset and length of the register set for the device
  1291. - interrupts : <a b> where a is the interrupt number and b is a
  1292. field that represents an encoding of the sense and level
  1293. information for the interrupt. This should be encoded based on
  1294. the information in section 2) depending on the type of interrupt
  1295. controller you have.
  1296. - interrupt-parent : the phandle for the interrupt controller that
  1297. services interrupts for this device.
  1298. Example(slave):
  1299. usb@6c0 {
  1300. device_type = "usb";
  1301. compatible = "qe_udc";
  1302. reg = <6c0 40>;
  1303. interrupts = <8b 0>;
  1304. interrupt-parent = <700>;
  1305. mode = "slave";
  1306. };
  1307. iv) UCC (Unified Communications Controllers)
  1308. Required properties:
  1309. - device_type : should be "network", "hldc", "uart", "transparent"
  1310. "bisync" or "atm".
  1311. - compatible : could be "ucc_geth" or "fsl_atm" and so on.
  1312. - model : should be "UCC".
  1313. - device-id : the ucc number(1-8), corresponding to UCCx in UM.
  1314. - reg : Offset and length of the register set for the device
  1315. - interrupts : <a b> where a is the interrupt number and b is a
  1316. field that represents an encoding of the sense and level
  1317. information for the interrupt. This should be encoded based on
  1318. the information in section 2) depending on the type of interrupt
  1319. controller you have.
  1320. - interrupt-parent : the phandle for the interrupt controller that
  1321. services interrupts for this device.
  1322. - pio-handle : The phandle for the Parallel I/O port configuration.
  1323. - rx-clock-name: the UCC receive clock source
  1324. "none": clock source is disabled
  1325. "brg1" through "brg16": clock source is BRG1-BRG16, respectively
  1326. "clk1" through "clk24": clock source is CLK1-CLK24, respectively
  1327. - tx-clock-name: the UCC transmit clock source
  1328. "none": clock source is disabled
  1329. "brg1" through "brg16": clock source is BRG1-BRG16, respectively
  1330. "clk1" through "clk24": clock source is CLK1-CLK24, respectively
  1331. The following two properties are deprecated. rx-clock has been replaced
  1332. with rx-clock-name, and tx-clock has been replaced with tx-clock-name.
  1333. Drivers that currently use the deprecated properties should continue to
  1334. do so, in order to support older device trees, but they should be updated
  1335. to check for the new properties first.
  1336. - rx-clock : represents the UCC receive clock source.
  1337. 0x00 : clock source is disabled;
  1338. 0x1~0x10 : clock source is BRG1~BRG16 respectively;
  1339. 0x11~0x28: clock source is QE_CLK1~QE_CLK24 respectively.
  1340. - tx-clock: represents the UCC transmit clock source;
  1341. 0x00 : clock source is disabled;
  1342. 0x1~0x10 : clock source is BRG1~BRG16 respectively;
  1343. 0x11~0x28: clock source is QE_CLK1~QE_CLK24 respectively.
  1344. Required properties for network device_type:
  1345. - mac-address : list of bytes representing the ethernet address.
  1346. - phy-handle : The phandle for the PHY connected to this controller.
  1347. Recommended properties:
  1348. - linux,network-index : This is the intended "index" of this
  1349. network device. This is used by the bootwrapper to interpret
  1350. MAC addresses passed by the firmware when no information other
  1351. than indices is available to associate an address with a device.
  1352. - phy-connection-type : a string naming the controller/PHY interface type,
  1353. i.e., "mii" (default), "rmii", "gmii", "rgmii", "rgmii-id" (Internal
  1354. Delay), "rgmii-txid" (delay on TX only), "rgmii-rxid" (delay on RX only),
  1355. "tbi", or "rtbi".
  1356. Example:
  1357. ucc@2000 {
  1358. device_type = "network";
  1359. compatible = "ucc_geth";
  1360. model = "UCC";
  1361. device-id = <1>;
  1362. reg = <2000 200>;
  1363. interrupts = <a0 0>;
  1364. interrupt-parent = <700>;
  1365. mac-address = [ 00 04 9f 00 23 23 ];
  1366. rx-clock = "none";
  1367. tx-clock = "clk9";
  1368. phy-handle = <212000>;
  1369. phy-connection-type = "gmii";
  1370. pio-handle = <140001>;
  1371. };
  1372. v) Parallel I/O Ports
  1373. This node configures Parallel I/O ports for CPUs with QE support.
  1374. The node should reside in the "soc" node of the tree. For each
  1375. device that using parallel I/O ports, a child node should be created.
  1376. See the definition of the Pin configuration nodes below for more
  1377. information.
  1378. Required properties:
  1379. - device_type : should be "par_io".
  1380. - reg : offset to the register set and its length.
  1381. - num-ports : number of Parallel I/O ports
  1382. Example:
  1383. par_io@1400 {
  1384. reg = <1400 100>;
  1385. #address-cells = <1>;
  1386. #size-cells = <0>;
  1387. device_type = "par_io";
  1388. num-ports = <7>;
  1389. ucc_pin@01 {
  1390. ......
  1391. };
  1392. vi) Pin configuration nodes
  1393. Required properties:
  1394. - linux,phandle : phandle of this node; likely referenced by a QE
  1395. device.
  1396. - pio-map : array of pin configurations. Each pin is defined by 6
  1397. integers. The six numbers are respectively: port, pin, dir,
  1398. open_drain, assignment, has_irq.
  1399. - port : port number of the pin; 0-6 represent port A-G in UM.
  1400. - pin : pin number in the port.
  1401. - dir : direction of the pin, should encode as follows:
  1402. 0 = The pin is disabled
  1403. 1 = The pin is an output
  1404. 2 = The pin is an input
  1405. 3 = The pin is I/O
  1406. - open_drain : indicates the pin is normal or wired-OR:
  1407. 0 = The pin is actively driven as an output
  1408. 1 = The pin is an open-drain driver. As an output, the pin is
  1409. driven active-low, otherwise it is three-stated.
  1410. - assignment : function number of the pin according to the Pin Assignment
  1411. tables in User Manual. Each pin can have up to 4 possible functions in
  1412. QE and two options for CPM.
  1413. - has_irq : indicates if the pin is used as source of external
  1414. interrupts.
  1415. Example:
  1416. ucc_pin@01 {
  1417. linux,phandle = <140001>;
  1418. pio-map = <
  1419. /* port pin dir open_drain assignment has_irq */
  1420. 0 3 1 0 1 0 /* TxD0 */
  1421. 0 4 1 0 1 0 /* TxD1 */
  1422. 0 5 1 0 1 0 /* TxD2 */
  1423. 0 6 1 0 1 0 /* TxD3 */
  1424. 1 6 1 0 3 0 /* TxD4 */
  1425. 1 7 1 0 1 0 /* TxD5 */
  1426. 1 9 1 0 2 0 /* TxD6 */
  1427. 1 a 1 0 2 0 /* TxD7 */
  1428. 0 9 2 0 1 0 /* RxD0 */
  1429. 0 a 2 0 1 0 /* RxD1 */
  1430. 0 b 2 0 1 0 /* RxD2 */
  1431. 0 c 2 0 1 0 /* RxD3 */
  1432. 0 d 2 0 1 0 /* RxD4 */
  1433. 1 1 2 0 2 0 /* RxD5 */
  1434. 1 0 2 0 2 0 /* RxD6 */
  1435. 1 4 2 0 2 0 /* RxD7 */
  1436. 0 7 1 0 1 0 /* TX_EN */
  1437. 0 8 1 0 1 0 /* TX_ER */
  1438. 0 f 2 0 1 0 /* RX_DV */
  1439. 0 10 2 0 1 0 /* RX_ER */
  1440. 0 0 2 0 1 0 /* RX_CLK */
  1441. 2 9 1 0 3 0 /* GTX_CLK - CLK10 */
  1442. 2 8 2 0 1 0>; /* GTX125 - CLK9 */
  1443. };
  1444. vii) Multi-User RAM (MURAM)
  1445. Required properties:
  1446. - device_type : should be "muram".
  1447. - mode : the could be "host" or "slave".
  1448. - ranges : Should be defined as specified in 1) to describe the
  1449. translation of MURAM addresses.
  1450. - data-only : sub-node which defines the address area under MURAM
  1451. bus that can be allocated as data/parameter
  1452. Example:
  1453. muram@10000 {
  1454. device_type = "muram";
  1455. ranges = <0 00010000 0000c000>;
  1456. data-only@0{
  1457. reg = <0 c000>;
  1458. };
  1459. };
  1460. j) CFI or JEDEC memory-mapped NOR flash
  1461. Flash chips (Memory Technology Devices) are often used for solid state
  1462. file systems on embedded devices.
  1463. - compatible : should contain the specific model of flash chip(s)
  1464. used, if known, followed by either "cfi-flash" or "jedec-flash"
  1465. - reg : Address range of the flash chip
  1466. - bank-width : Width (in bytes) of the flash bank. Equal to the
  1467. device width times the number of interleaved chips.
  1468. - device-width : (optional) Width of a single flash chip. If
  1469. omitted, assumed to be equal to 'bank-width'.
  1470. - #address-cells, #size-cells : Must be present if the flash has
  1471. sub-nodes representing partitions (see below). In this case
  1472. both #address-cells and #size-cells must be equal to 1.
  1473. For JEDEC compatible devices, the following additional properties
  1474. are defined:
  1475. - vendor-id : Contains the flash chip's vendor id (1 byte).
  1476. - device-id : Contains the flash chip's device id (1 byte).
  1477. In addition to the information on the flash bank itself, the
  1478. device tree may optionally contain additional information
  1479. describing partitions of the flash address space. This can be
  1480. used on platforms which have strong conventions about which
  1481. portions of the flash are used for what purposes, but which don't
  1482. use an on-flash partition table such as RedBoot.
  1483. Each partition is represented as a sub-node of the flash device.
  1484. Each node's name represents the name of the corresponding
  1485. partition of the flash device.
  1486. Flash partitions
  1487. - reg : The partition's offset and size within the flash bank.
  1488. - label : (optional) The label / name for this flash partition.
  1489. If omitted, the label is taken from the node name (excluding
  1490. the unit address).
  1491. - read-only : (optional) This parameter, if present, is a hint to
  1492. Linux that this flash partition should only be mounted
  1493. read-only. This is usually used for flash partitions
  1494. containing early-boot firmware images or data which should not
  1495. be clobbered.
  1496. Example:
  1497. flash@ff000000 {
  1498. compatible = "amd,am29lv128ml", "cfi-flash";
  1499. reg = <ff000000 01000000>;
  1500. bank-width = <4>;
  1501. device-width = <1>;
  1502. #address-cells = <1>;
  1503. #size-cells = <1>;
  1504. fs@0 {
  1505. label = "fs";
  1506. reg = <0 f80000>;
  1507. };
  1508. firmware@f80000 {
  1509. label ="firmware";
  1510. reg = <f80000 80000>;
  1511. read-only;
  1512. };
  1513. };
  1514. k) Global Utilities Block
  1515. The global utilities block controls power management, I/O device
  1516. enabling, power-on-reset configuration monitoring, general-purpose
  1517. I/O signal configuration, alternate function selection for multiplexed
  1518. signals, and clock control.
  1519. Required properties:
  1520. - compatible : Should define the compatible device type for
  1521. global-utilities.
  1522. - reg : Offset and length of the register set for the device.
  1523. Recommended properties:
  1524. - fsl,has-rstcr : Indicates that the global utilities register set
  1525. contains a functioning "reset control register" (i.e. the board
  1526. is wired to reset upon setting the HRESET_REQ bit in this register).
  1527. Example:
  1528. global-utilities@e0000 { /* global utilities block */
  1529. compatible = "fsl,mpc8548-guts";
  1530. reg = <e0000 1000>;
  1531. fsl,has-rstcr;
  1532. };
  1533. l) Freescale Communications Processor Module
  1534. NOTE: This is an interim binding, and will likely change slightly,
  1535. as more devices are supported. The QE bindings especially are
  1536. incomplete.
  1537. i) Root CPM node
  1538. Properties:
  1539. - compatible : "fsl,cpm1", "fsl,cpm2", or "fsl,qe".
  1540. - reg : A 48-byte region beginning with CPCR.
  1541. Example:
  1542. cpm@119c0 {
  1543. #address-cells = <1>;
  1544. #size-cells = <1>;
  1545. #interrupt-cells = <2>;
  1546. compatible = "fsl,mpc8272-cpm", "fsl,cpm2";
  1547. reg = <119c0 30>;
  1548. }
  1549. ii) Properties common to mulitple CPM/QE devices
  1550. - fsl,cpm-command : This value is ORed with the opcode and command flag
  1551. to specify the device on which a CPM command operates.
  1552. - fsl,cpm-brg : Indicates which baud rate generator the device
  1553. is associated with. If absent, an unused BRG
  1554. should be dynamically allocated. If zero, the
  1555. device uses an external clock rather than a BRG.
  1556. - reg : Unless otherwise specified, the first resource represents the
  1557. scc/fcc/ucc registers, and the second represents the device's
  1558. parameter RAM region (if it has one).
  1559. iii) Serial
  1560. Currently defined compatibles:
  1561. - fsl,cpm1-smc-uart
  1562. - fsl,cpm2-smc-uart
  1563. - fsl,cpm1-scc-uart
  1564. - fsl,cpm2-scc-uart
  1565. - fsl,qe-uart
  1566. Example:
  1567. serial@11a00 {
  1568. device_type = "serial";
  1569. compatible = "fsl,mpc8272-scc-uart",
  1570. "fsl,cpm2-scc-uart";
  1571. reg = <11a00 20 8000 100>;
  1572. interrupts = <28 8>;
  1573. interrupt-parent = <&PIC>;
  1574. fsl,cpm-brg = <1>;
  1575. fsl,cpm-command = <00800000>;
  1576. };
  1577. iii) Network
  1578. Currently defined compatibles:
  1579. - fsl,cpm1-scc-enet
  1580. - fsl,cpm2-scc-enet
  1581. - fsl,cpm1-fec-enet
  1582. - fsl,cpm2-fcc-enet (third resource is GFEMR)
  1583. - fsl,qe-enet
  1584. Example:
  1585. ethernet@11300 {
  1586. device_type = "network";
  1587. compatible = "fsl,mpc8272-fcc-enet",
  1588. "fsl,cpm2-fcc-enet";
  1589. reg = <11300 20 8400 100 11390 1>;
  1590. local-mac-address = [ 00 00 00 00 00 00 ];
  1591. interrupts = <20 8>;
  1592. interrupt-parent = <&PIC>;
  1593. phy-handle = <&PHY0>;
  1594. linux,network-index = <0>;
  1595. fsl,cpm-command = <12000300>;
  1596. };
  1597. iv) MDIO
  1598. Currently defined compatibles:
  1599. fsl,pq1-fec-mdio (reg is same as first resource of FEC device)
  1600. fsl,cpm2-mdio-bitbang (reg is port C registers)
  1601. Properties for fsl,cpm2-mdio-bitbang:
  1602. fsl,mdio-pin : pin of port C controlling mdio data
  1603. fsl,mdc-pin : pin of port C controlling mdio clock
  1604. Example:
  1605. mdio@10d40 {
  1606. device_type = "mdio";
  1607. compatible = "fsl,mpc8272ads-mdio-bitbang",
  1608. "fsl,mpc8272-mdio-bitbang",
  1609. "fsl,cpm2-mdio-bitbang";
  1610. reg = <10d40 14>;
  1611. #address-cells = <1>;
  1612. #size-cells = <0>;
  1613. fsl,mdio-pin = <12>;
  1614. fsl,mdc-pin = <13>;
  1615. };
  1616. v) Baud Rate Generators
  1617. Currently defined compatibles:
  1618. fsl,cpm-brg
  1619. fsl,cpm1-brg
  1620. fsl,cpm2-brg
  1621. Properties:
  1622. - reg : There may be an arbitrary number of reg resources; BRG
  1623. numbers are assigned to these in order.
  1624. - clock-frequency : Specifies the base frequency driving
  1625. the BRG.
  1626. Example:
  1627. brg@119f0 {
  1628. compatible = "fsl,mpc8272-brg",
  1629. "fsl,cpm2-brg",
  1630. "fsl,cpm-brg";
  1631. reg = <119f0 10 115f0 10>;
  1632. clock-frequency = <d#25000000>;
  1633. };
  1634. vi) Interrupt Controllers
  1635. Currently defined compatibles:
  1636. - fsl,cpm1-pic
  1637. - only one interrupt cell
  1638. - fsl,pq1-pic
  1639. - fsl,cpm2-pic
  1640. - second interrupt cell is level/sense:
  1641. - 2 is falling edge
  1642. - 8 is active low
  1643. Example:
  1644. interrupt-controller@10c00 {
  1645. #interrupt-cells = <2>;
  1646. interrupt-controller;
  1647. reg = <10c00 80>;
  1648. compatible = "mpc8272-pic", "fsl,cpm2-pic";
  1649. };
  1650. vii) USB (Universal Serial Bus Controller)
  1651. Properties:
  1652. - compatible : "fsl,cpm1-usb", "fsl,cpm2-usb", "fsl,qe-usb"
  1653. Example:
  1654. usb@11bc0 {
  1655. #address-cells = <1>;
  1656. #size-cells = <0>;
  1657. compatible = "fsl,cpm2-usb";
  1658. reg = <11b60 18 8b00 100>;
  1659. interrupts = <b 8>;
  1660. interrupt-parent = <&PIC>;
  1661. fsl,cpm-command = <2e600000>;
  1662. };
  1663. viii) Multi-User RAM (MURAM)
  1664. The multi-user/dual-ported RAM is expressed as a bus under the CPM node.
  1665. Ranges must be set up subject to the following restrictions:
  1666. - Children's reg nodes must be offsets from the start of all muram, even
  1667. if the user-data area does not begin at zero.
  1668. - If multiple range entries are used, the difference between the parent
  1669. address and the child address must be the same in all, so that a single
  1670. mapping can cover them all while maintaining the ability to determine
  1671. CPM-side offsets with pointer subtraction. It is recommended that
  1672. multiple range entries not be used.
  1673. - A child address of zero must be translatable, even if no reg resources
  1674. contain it.
  1675. A child "data" node must exist, compatible with "fsl,cpm-muram-data", to
  1676. indicate the portion of muram that is usable by the OS for arbitrary
  1677. purposes. The data node may have an arbitrary number of reg resources,
  1678. all of which contribute to the allocatable muram pool.
  1679. Example, based on mpc8272:
  1680. muram@0 {
  1681. #address-cells = <1>;
  1682. #size-cells = <1>;
  1683. ranges = <0 0 10000>;
  1684. data@0 {
  1685. compatible = "fsl,cpm-muram-data";
  1686. reg = <0 2000 9800 800>;
  1687. };
  1688. };
  1689. m) Chipselect/Local Bus
  1690. Properties:
  1691. - name : Should be localbus
  1692. - #address-cells : Should be either two or three. The first cell is the
  1693. chipselect number, and the remaining cells are the
  1694. offset into the chipselect.
  1695. - #size-cells : Either one or two, depending on how large each chipselect
  1696. can be.
  1697. - ranges : Each range corresponds to a single chipselect, and cover
  1698. the entire access window as configured.
  1699. Example:
  1700. localbus@f0010100 {
  1701. compatible = "fsl,mpc8272ads-localbus",
  1702. "fsl,mpc8272-localbus",
  1703. "fsl,pq2-localbus";
  1704. #address-cells = <2>;
  1705. #size-cells = <1>;
  1706. reg = <f0010100 40>;
  1707. ranges = <0 0 fe000000 02000000
  1708. 1 0 f4500000 00008000>;
  1709. flash@0,0 {
  1710. compatible = "jedec-flash";
  1711. reg = <0 0 2000000>;
  1712. bank-width = <4>;
  1713. device-width = <1>;
  1714. };
  1715. board-control@1,0 {
  1716. reg = <1 0 20>;
  1717. compatible = "fsl,mpc8272ads-bcsr";
  1718. };
  1719. };
  1720. n) 4xx/Axon EMAC ethernet nodes
  1721. The EMAC ethernet controller in IBM and AMCC 4xx chips, and also
  1722. the Axon bridge. To operate this needs to interact with a ths
  1723. special McMAL DMA controller, and sometimes an RGMII or ZMII
  1724. interface. In addition to the nodes and properties described
  1725. below, the node for the OPB bus on which the EMAC sits must have a
  1726. correct clock-frequency property.
  1727. i) The EMAC node itself
  1728. Required properties:
  1729. - device_type : "network"
  1730. - compatible : compatible list, contains 2 entries, first is
  1731. "ibm,emac-CHIP" where CHIP is the host ASIC (440gx,
  1732. 405gp, Axon) and second is either "ibm,emac" or
  1733. "ibm,emac4". For Axon, thus, we have: "ibm,emac-axon",
  1734. "ibm,emac4"
  1735. - interrupts : <interrupt mapping for EMAC IRQ and WOL IRQ>
  1736. - interrupt-parent : optional, if needed for interrupt mapping
  1737. - reg : <registers mapping>
  1738. - local-mac-address : 6 bytes, MAC address
  1739. - mal-device : phandle of the associated McMAL node
  1740. - mal-tx-channel : 1 cell, index of the tx channel on McMAL associated
  1741. with this EMAC
  1742. - mal-rx-channel : 1 cell, index of the rx channel on McMAL associated
  1743. with this EMAC
  1744. - cell-index : 1 cell, hardware index of the EMAC cell on a given
  1745. ASIC (typically 0x0 and 0x1 for EMAC0 and EMAC1 on
  1746. each Axon chip)
  1747. - max-frame-size : 1 cell, maximum frame size supported in bytes
  1748. - rx-fifo-size : 1 cell, Rx fifo size in bytes for 10 and 100 Mb/sec
  1749. operations.
  1750. For Axon, 2048
  1751. - tx-fifo-size : 1 cell, Tx fifo size in bytes for 10 and 100 Mb/sec
  1752. operations.
  1753. For Axon, 2048.
  1754. - fifo-entry-size : 1 cell, size of a fifo entry (used to calculate
  1755. thresholds).
  1756. For Axon, 0x00000010
  1757. - mal-burst-size : 1 cell, MAL burst size (used to calculate thresholds)
  1758. in bytes.
  1759. For Axon, 0x00000100 (I think ...)
  1760. - phy-mode : string, mode of operations of the PHY interface.
  1761. Supported values are: "mii", "rmii", "smii", "rgmii",
  1762. "tbi", "gmii", rtbi", "sgmii".
  1763. For Axon on CAB, it is "rgmii"
  1764. - mdio-device : 1 cell, required iff using shared MDIO registers
  1765. (440EP). phandle of the EMAC to use to drive the
  1766. MDIO lines for the PHY used by this EMAC.
  1767. - zmii-device : 1 cell, required iff connected to a ZMII. phandle of
  1768. the ZMII device node
  1769. - zmii-channel : 1 cell, required iff connected to a ZMII. Which ZMII
  1770. channel or 0xffffffff if ZMII is only used for MDIO.
  1771. - rgmii-device : 1 cell, required iff connected to an RGMII. phandle
  1772. of the RGMII device node.
  1773. For Axon: phandle of plb5/plb4/opb/rgmii
  1774. - rgmii-channel : 1 cell, required iff connected to an RGMII. Which
  1775. RGMII channel is used by this EMAC.
  1776. Fox Axon: present, whatever value is appropriate for each
  1777. EMAC, that is the content of the current (bogus) "phy-port"
  1778. property.
  1779. Recommended properties:
  1780. - linux,network-index : This is the intended "index" of this
  1781. network device. This is used by the bootwrapper to interpret
  1782. MAC addresses passed by the firmware when no information other
  1783. than indices is available to associate an address with a device.
  1784. Optional properties:
  1785. - phy-address : 1 cell, optional, MDIO address of the PHY. If absent,
  1786. a search is performed.
  1787. - phy-map : 1 cell, optional, bitmap of addresses to probe the PHY
  1788. for, used if phy-address is absent. bit 0x00000001 is
  1789. MDIO address 0.
  1790. For Axon it can be absent, thouugh my current driver
  1791. doesn't handle phy-address yet so for now, keep
  1792. 0x00ffffff in it.
  1793. - rx-fifo-size-gige : 1 cell, Rx fifo size in bytes for 1000 Mb/sec
  1794. operations (if absent the value is the same as
  1795. rx-fifo-size). For Axon, either absent or 2048.
  1796. - tx-fifo-size-gige : 1 cell, Tx fifo size in bytes for 1000 Mb/sec
  1797. operations (if absent the value is the same as
  1798. tx-fifo-size). For Axon, either absent or 2048.
  1799. - tah-device : 1 cell, optional. If connected to a TAH engine for
  1800. offload, phandle of the TAH device node.
  1801. - tah-channel : 1 cell, optional. If appropriate, channel used on the
  1802. TAH engine.
  1803. Example:
  1804. EMAC0: ethernet@40000800 {
  1805. linux,network-index = <0>;
  1806. device_type = "network";
  1807. compatible = "ibm,emac-440gp", "ibm,emac";
  1808. interrupt-parent = <&UIC1>;
  1809. interrupts = <1c 4 1d 4>;
  1810. reg = <40000800 70>;
  1811. local-mac-address = [00 04 AC E3 1B 1E];
  1812. mal-device = <&MAL0>;
  1813. mal-tx-channel = <0 1>;
  1814. mal-rx-channel = <0>;
  1815. cell-index = <0>;
  1816. max-frame-size = <5dc>;
  1817. rx-fifo-size = <1000>;
  1818. tx-fifo-size = <800>;
  1819. phy-mode = "rmii";
  1820. phy-map = <00000001>;
  1821. zmii-device = <&ZMII0>;
  1822. zmii-channel = <0>;
  1823. };
  1824. ii) McMAL node
  1825. Required properties:
  1826. - device_type : "dma-controller"
  1827. - compatible : compatible list, containing 2 entries, first is
  1828. "ibm,mcmal-CHIP" where CHIP is the host ASIC (like
  1829. emac) and the second is either "ibm,mcmal" or
  1830. "ibm,mcmal2".
  1831. For Axon, "ibm,mcmal-axon","ibm,mcmal2"
  1832. - interrupts : <interrupt mapping for the MAL interrupts sources:
  1833. 5 sources: tx_eob, rx_eob, serr, txde, rxde>.
  1834. For Axon: This is _different_ from the current
  1835. firmware. We use the "delayed" interrupts for txeob
  1836. and rxeob. Thus we end up with mapping those 5 MPIC
  1837. interrupts, all level positive sensitive: 10, 11, 32,
  1838. 33, 34 (in decimal)
  1839. - dcr-reg : < DCR registers range >
  1840. - dcr-parent : if needed for dcr-reg
  1841. - num-tx-chans : 1 cell, number of Tx channels
  1842. - num-rx-chans : 1 cell, number of Rx channels
  1843. iii) ZMII node
  1844. Required properties:
  1845. - compatible : compatible list, containing 2 entries, first is
  1846. "ibm,zmii-CHIP" where CHIP is the host ASIC (like
  1847. EMAC) and the second is "ibm,zmii".
  1848. For Axon, there is no ZMII node.
  1849. - reg : <registers mapping>
  1850. iv) RGMII node
  1851. Required properties:
  1852. - compatible : compatible list, containing 2 entries, first is
  1853. "ibm,rgmii-CHIP" where CHIP is the host ASIC (like
  1854. EMAC) and the second is "ibm,rgmii".
  1855. For Axon, "ibm,rgmii-axon","ibm,rgmii"
  1856. - reg : <registers mapping>
  1857. - revision : as provided by the RGMII new version register if
  1858. available.
  1859. For Axon: 0x0000012a
  1860. l) Xilinx IP cores
  1861. The Xilinx EDK toolchain ships with a set of IP cores (devices) for use
  1862. in Xilinx Spartan and Virtex FPGAs. The devices cover the whole range
  1863. of standard device types (network, serial, etc.) and miscellanious
  1864. devices (gpio, LCD, spi, etc). Also, since these devices are
  1865. implemented within the fpga fabric every instance of the device can be
  1866. synthesised with different options that change the behaviour.
  1867. Each IP-core has a set of parameters which the FPGA designer can use to
  1868. control how the core is synthesized. Historically, the EDK tool would
  1869. extract the device parameters relevant to device drivers and copy them
  1870. into an 'xparameters.h' in the form of #define symbols. This tells the
  1871. device drivers how the IP cores are configured, but it requres the kernel
  1872. to be recompiled every time the FPGA bitstream is resynthesized.
  1873. The new approach is to export the parameters into the device tree and
  1874. generate a new device tree each time the FPGA bitstream changes. The
  1875. parameters which used to be exported as #defines will now become
  1876. properties of the device node. In general, device nodes for IP-cores
  1877. will take the following form:
  1878. (name): (generic-name)@(base-address) {
  1879. compatible = "xlnx,(ip-core-name)-(HW_VER)"
  1880. [, (list of compatible devices), ...];
  1881. reg = <(baseaddr) (size)>;
  1882. interrupt-parent = <&interrupt-controller-phandle>;
  1883. interrupts = < ... >;
  1884. xlnx,(parameter1) = "(string-value)";
  1885. xlnx,(parameter2) = <(int-value)>;
  1886. };
  1887. (generic-name): an open firmware-style name that describes the
  1888. generic class of device. Preferably, this is one word, such
  1889. as 'serial' or 'ethernet'.
  1890. (ip-core-name): the name of the ip block (given after the BEGIN
  1891. directive in system.mhs). Should be in lowercase
  1892. and all underscores '_' converted to dashes '-'.
  1893. (name): is derived from the "PARAMETER INSTANCE" value.
  1894. (parameter#): C_* parameters from system.mhs. The C_ prefix is
  1895. dropped from the parameter name, the name is converted
  1896. to lowercase and all underscore '_' characters are
  1897. converted to dashes '-'.
  1898. (baseaddr): the baseaddr parameter value (often named C_BASEADDR).
  1899. (HW_VER): from the HW_VER parameter.
  1900. (size): the address range size (often C_HIGHADDR - C_BASEADDR + 1).
  1901. Typically, the compatible list will include the exact IP core version
  1902. followed by an older IP core version which implements the same
  1903. interface or any other device with the same interface.
  1904. 'reg', 'interrupt-parent' and 'interrupts' are all optional properties.
  1905. For example, the following block from system.mhs:
  1906. BEGIN opb_uartlite
  1907. PARAMETER INSTANCE = opb_uartlite_0
  1908. PARAMETER HW_VER = 1.00.b
  1909. PARAMETER C_BAUDRATE = 115200
  1910. PARAMETER C_DATA_BITS = 8
  1911. PARAMETER C_ODD_PARITY = 0
  1912. PARAMETER C_USE_PARITY = 0
  1913. PARAMETER C_CLK_FREQ = 50000000
  1914. PARAMETER C_BASEADDR = 0xEC100000
  1915. PARAMETER C_HIGHADDR = 0xEC10FFFF
  1916. BUS_INTERFACE SOPB = opb_7
  1917. PORT OPB_Clk = CLK_50MHz
  1918. PORT Interrupt = opb_uartlite_0_Interrupt
  1919. PORT RX = opb_uartlite_0_RX
  1920. PORT TX = opb_uartlite_0_TX
  1921. PORT OPB_Rst = sys_bus_reset_0
  1922. END
  1923. becomes the following device tree node:
  1924. opb_uartlite_0: serial@ec100000 {
  1925. device_type = "serial";
  1926. compatible = "xlnx,opb-uartlite-1.00.b";
  1927. reg = <ec100000 10000>;
  1928. interrupt-parent = <&opb_intc_0>;
  1929. interrupts = <1 0>; // got this from the opb_intc parameters
  1930. current-speed = <d#115200>; // standard serial device prop
  1931. clock-frequency = <d#50000000>; // standard serial device prop
  1932. xlnx,data-bits = <8>;
  1933. xlnx,odd-parity = <0>;
  1934. xlnx,use-parity = <0>;
  1935. };
  1936. Some IP cores actually implement 2 or more logical devices. In
  1937. this case, the device should still describe the whole IP core with
  1938. a single node and add a child node for each logical device. The
  1939. ranges property can be used to translate from parent IP-core to the
  1940. registers of each device. In addition, the parent node should be
  1941. compatible with the bus type 'xlnx,compound', and should contain
  1942. #address-cells and #size-cells, as with any other bus. (Note: this
  1943. makes the assumption that both logical devices have the same bus
  1944. binding. If this is not true, then separate nodes should be used
  1945. for each logical device). The 'cell-index' property can be used to
  1946. enumerate logical devices within an IP core. For example, the
  1947. following is the system.mhs entry for the dual ps2 controller found
  1948. on the ml403 reference design.
  1949. BEGIN opb_ps2_dual_ref
  1950. PARAMETER INSTANCE = opb_ps2_dual_ref_0
  1951. PARAMETER HW_VER = 1.00.a
  1952. PARAMETER C_BASEADDR = 0xA9000000
  1953. PARAMETER C_HIGHADDR = 0xA9001FFF
  1954. BUS_INTERFACE SOPB = opb_v20_0
  1955. PORT Sys_Intr1 = ps2_1_intr
  1956. PORT Sys_Intr2 = ps2_2_intr
  1957. PORT Clkin1 = ps2_clk_rx_1
  1958. PORT Clkin2 = ps2_clk_rx_2
  1959. PORT Clkpd1 = ps2_clk_tx_1
  1960. PORT Clkpd2 = ps2_clk_tx_2
  1961. PORT Rx1 = ps2_d_rx_1
  1962. PORT Rx2 = ps2_d_rx_2
  1963. PORT Txpd1 = ps2_d_tx_1
  1964. PORT Txpd2 = ps2_d_tx_2
  1965. END
  1966. It would result in the following device tree nodes:
  1967. opb_ps2_dual_ref_0: opb-ps2-dual-ref@a9000000 {
  1968. #address-cells = <1>;
  1969. #size-cells = <1>;
  1970. compatible = "xlnx,compound";
  1971. ranges = <0 a9000000 2000>;
  1972. // If this device had extra parameters, then they would
  1973. // go here.
  1974. ps2@0 {
  1975. compatible = "xlnx,opb-ps2-dual-ref-1.00.a";
  1976. reg = <0 40>;
  1977. interrupt-parent = <&opb_intc_0>;
  1978. interrupts = <3 0>;
  1979. cell-index = <0>;
  1980. };
  1981. ps2@1000 {
  1982. compatible = "xlnx,opb-ps2-dual-ref-1.00.a";
  1983. reg = <1000 40>;
  1984. interrupt-parent = <&opb_intc_0>;
  1985. interrupts = <3 0>;
  1986. cell-index = <0>;
  1987. };
  1988. };
  1989. Also, the system.mhs file defines bus attachments from the processor
  1990. to the devices. The device tree structure should reflect the bus
  1991. attachments. Again an example; this system.mhs fragment:
  1992. BEGIN ppc405_virtex4
  1993. PARAMETER INSTANCE = ppc405_0
  1994. PARAMETER HW_VER = 1.01.a
  1995. BUS_INTERFACE DPLB = plb_v34_0
  1996. BUS_INTERFACE IPLB = plb_v34_0
  1997. END
  1998. BEGIN opb_intc
  1999. PARAMETER INSTANCE = opb_intc_0
  2000. PARAMETER HW_VER = 1.00.c
  2001. PARAMETER C_BASEADDR = 0xD1000FC0
  2002. PARAMETER C_HIGHADDR = 0xD1000FDF
  2003. BUS_INTERFACE SOPB = opb_v20_0
  2004. END
  2005. BEGIN opb_uart16550
  2006. PARAMETER INSTANCE = opb_uart16550_0
  2007. PARAMETER HW_VER = 1.00.d
  2008. PARAMETER C_BASEADDR = 0xa0000000
  2009. PARAMETER C_HIGHADDR = 0xa0001FFF
  2010. BUS_INTERFACE SOPB = opb_v20_0
  2011. END
  2012. BEGIN plb_v34
  2013. PARAMETER INSTANCE = plb_v34_0
  2014. PARAMETER HW_VER = 1.02.a
  2015. END
  2016. BEGIN plb_bram_if_cntlr
  2017. PARAMETER INSTANCE = plb_bram_if_cntlr_0
  2018. PARAMETER HW_VER = 1.00.b
  2019. PARAMETER C_BASEADDR = 0xFFFF0000
  2020. PARAMETER C_HIGHADDR = 0xFFFFFFFF
  2021. BUS_INTERFACE SPLB = plb_v34_0
  2022. END
  2023. BEGIN plb2opb_bridge
  2024. PARAMETER INSTANCE = plb2opb_bridge_0
  2025. PARAMETER HW_VER = 1.01.a
  2026. PARAMETER C_RNG0_BASEADDR = 0x20000000
  2027. PARAMETER C_RNG0_HIGHADDR = 0x3FFFFFFF
  2028. PARAMETER C_RNG1_BASEADDR = 0x60000000
  2029. PARAMETER C_RNG1_HIGHADDR = 0x7FFFFFFF
  2030. PARAMETER C_RNG2_BASEADDR = 0x80000000
  2031. PARAMETER C_RNG2_HIGHADDR = 0xBFFFFFFF
  2032. PARAMETER C_RNG3_BASEADDR = 0xC0000000
  2033. PARAMETER C_RNG3_HIGHADDR = 0xDFFFFFFF
  2034. BUS_INTERFACE SPLB = plb_v34_0
  2035. BUS_INTERFACE MOPB = opb_v20_0
  2036. END
  2037. Gives this device tree (some properties removed for clarity):
  2038. plb@0 {
  2039. #address-cells = <1>;
  2040. #size-cells = <1>;
  2041. compatible = "xlnx,plb-v34-1.02.a";
  2042. device_type = "ibm,plb";
  2043. ranges; // 1:1 translation
  2044. plb_bram_if_cntrl_0: bram@ffff0000 {
  2045. reg = <ffff0000 10000>;
  2046. }
  2047. opb@20000000 {
  2048. #address-cells = <1>;
  2049. #size-cells = <1>;
  2050. ranges = <20000000 20000000 20000000
  2051. 60000000 60000000 20000000
  2052. 80000000 80000000 40000000
  2053. c0000000 c0000000 20000000>;
  2054. opb_uart16550_0: serial@a0000000 {
  2055. reg = <a00000000 2000>;
  2056. };
  2057. opb_intc_0: interrupt-controller@d1000fc0 {
  2058. reg = <d1000fc0 20>;
  2059. };
  2060. };
  2061. };
  2062. That covers the general approach to binding xilinx IP cores into the
  2063. device tree. The following are bindings for specific devices:
  2064. i) Xilinx ML300 Framebuffer
  2065. Simple framebuffer device from the ML300 reference design (also on the
  2066. ML403 reference design as well as others).
  2067. Optional properties:
  2068. - resolution = <xres yres> : pixel resolution of framebuffer. Some
  2069. implementations use a different resolution.
  2070. Default is <d#640 d#480>
  2071. - virt-resolution = <xvirt yvirt> : Size of framebuffer in memory.
  2072. Default is <d#1024 d#480>.
  2073. - rotate-display (empty) : rotate display 180 degrees.
  2074. ii) Xilinx SystemACE
  2075. The Xilinx SystemACE device is used to program FPGAs from an FPGA
  2076. bitstream stored on a CF card. It can also be used as a generic CF
  2077. interface device.
  2078. Optional properties:
  2079. - 8-bit (empty) : Set this property for SystemACE in 8 bit mode
  2080. iii) Xilinx EMAC and Xilinx TEMAC
  2081. Xilinx Ethernet devices. In addition to general xilinx properties
  2082. listed above, nodes for these devices should include a phy-handle
  2083. property, and may include other common network device properties
  2084. like local-mac-address.
  2085. iv) Xilinx Uartlite
  2086. Xilinx uartlite devices are simple fixed speed serial ports.
  2087. Requred properties:
  2088. - current-speed : Baud rate of uartlite
  2089. More devices will be defined as this spec matures.
  2090. VII - Specifying interrupt information for devices
  2091. ===================================================
  2092. The device tree represents the busses and devices of a hardware
  2093. system in a form similar to the physical bus topology of the
  2094. hardware.
  2095. In addition, a logical 'interrupt tree' exists which represents the
  2096. hierarchy and routing of interrupts in the hardware.
  2097. The interrupt tree model is fully described in the
  2098. document "Open Firmware Recommended Practice: Interrupt
  2099. Mapping Version 0.9". The document is available at:
  2100. <http://playground.sun.com/1275/practice>.
  2101. 1) interrupts property
  2102. ----------------------
  2103. Devices that generate interrupts to a single interrupt controller
  2104. should use the conventional OF representation described in the
  2105. OF interrupt mapping documentation.
  2106. Each device which generates interrupts must have an 'interrupt'
  2107. property. The interrupt property value is an arbitrary number of
  2108. of 'interrupt specifier' values which describe the interrupt or
  2109. interrupts for the device.
  2110. The encoding of an interrupt specifier is determined by the
  2111. interrupt domain in which the device is located in the
  2112. interrupt tree. The root of an interrupt domain specifies in
  2113. its #interrupt-cells property the number of 32-bit cells
  2114. required to encode an interrupt specifier. See the OF interrupt
  2115. mapping documentation for a detailed description of domains.
  2116. For example, the binding for the OpenPIC interrupt controller
  2117. specifies an #interrupt-cells value of 2 to encode the interrupt
  2118. number and level/sense information. All interrupt children in an
  2119. OpenPIC interrupt domain use 2 cells per interrupt in their interrupts
  2120. property.
  2121. The PCI bus binding specifies a #interrupt-cell value of 1 to encode
  2122. which interrupt pin (INTA,INTB,INTC,INTD) is used.
  2123. 2) interrupt-parent property
  2124. ----------------------------
  2125. The interrupt-parent property is specified to define an explicit
  2126. link between a device node and its interrupt parent in
  2127. the interrupt tree. The value of interrupt-parent is the
  2128. phandle of the parent node.
  2129. If the interrupt-parent property is not defined for a node, it's
  2130. interrupt parent is assumed to be an ancestor in the node's
  2131. _device tree_ hierarchy.
  2132. 3) OpenPIC Interrupt Controllers
  2133. --------------------------------
  2134. OpenPIC interrupt controllers require 2 cells to encode
  2135. interrupt information. The first cell defines the interrupt
  2136. number. The second cell defines the sense and level
  2137. information.
  2138. Sense and level information should be encoded as follows:
  2139. 0 = low to high edge sensitive type enabled
  2140. 1 = active low level sensitive type enabled
  2141. 2 = active high level sensitive type enabled
  2142. 3 = high to low edge sensitive type enabled
  2143. 4) ISA Interrupt Controllers
  2144. ----------------------------
  2145. ISA PIC interrupt controllers require 2 cells to encode
  2146. interrupt information. The first cell defines the interrupt
  2147. number. The second cell defines the sense and level
  2148. information.
  2149. ISA PIC interrupt controllers should adhere to the ISA PIC
  2150. encodings listed below:
  2151. 0 = active low level sensitive type enabled
  2152. 1 = active high level sensitive type enabled
  2153. 2 = high to low edge sensitive type enabled
  2154. 3 = low to high edge sensitive type enabled
  2155. Appendix A - Sample SOC node for MPC8540
  2156. ========================================
  2157. Note that the #address-cells and #size-cells for the SoC node
  2158. in this example have been explicitly listed; these are likely
  2159. not necessary as they are usually the same as the root node.
  2160. soc8540@e0000000 {
  2161. #address-cells = <1>;
  2162. #size-cells = <1>;
  2163. #interrupt-cells = <2>;
  2164. device_type = "soc";
  2165. ranges = <00000000 e0000000 00100000>
  2166. reg = <e0000000 00003000>;
  2167. bus-frequency = <0>;
  2168. mdio@24520 {
  2169. reg = <24520 20>;
  2170. device_type = "mdio";
  2171. compatible = "gianfar";
  2172. ethernet-phy@0 {
  2173. linux,phandle = <2452000>
  2174. interrupt-parent = <40000>;
  2175. interrupts = <35 1>;
  2176. reg = <0>;
  2177. device_type = "ethernet-phy";
  2178. };
  2179. ethernet-phy@1 {
  2180. linux,phandle = <2452001>
  2181. interrupt-parent = <40000>;
  2182. interrupts = <35 1>;
  2183. reg = <1>;
  2184. device_type = "ethernet-phy";
  2185. };
  2186. ethernet-phy@3 {
  2187. linux,phandle = <2452002>
  2188. interrupt-parent = <40000>;
  2189. interrupts = <35 1>;
  2190. reg = <3>;
  2191. device_type = "ethernet-phy";
  2192. };
  2193. };
  2194. ethernet@24000 {
  2195. #size-cells = <0>;
  2196. device_type = "network";
  2197. model = "TSEC";
  2198. compatible = "gianfar";
  2199. reg = <24000 1000>;
  2200. mac-address = [ 00 E0 0C 00 73 00 ];
  2201. interrupts = <d 3 e 3 12 3>;
  2202. interrupt-parent = <40000>;
  2203. phy-handle = <2452000>;
  2204. };
  2205. ethernet@25000 {
  2206. #address-cells = <1>;
  2207. #size-cells = <0>;
  2208. device_type = "network";
  2209. model = "TSEC";
  2210. compatible = "gianfar";
  2211. reg = <25000 1000>;
  2212. mac-address = [ 00 E0 0C 00 73 01 ];
  2213. interrupts = <13 3 14 3 18 3>;
  2214. interrupt-parent = <40000>;
  2215. phy-handle = <2452001>;
  2216. };
  2217. ethernet@26000 {
  2218. #address-cells = <1>;
  2219. #size-cells = <0>;
  2220. device_type = "network";
  2221. model = "FEC";
  2222. compatible = "gianfar";
  2223. reg = <26000 1000>;
  2224. mac-address = [ 00 E0 0C 00 73 02 ];
  2225. interrupts = <19 3>;
  2226. interrupt-parent = <40000>;
  2227. phy-handle = <2452002>;
  2228. };
  2229. serial@4500 {
  2230. device_type = "serial";
  2231. compatible = "ns16550";
  2232. reg = <4500 100>;
  2233. clock-frequency = <0>;
  2234. interrupts = <1a 3>;
  2235. interrupt-parent = <40000>;
  2236. };
  2237. pic@40000 {
  2238. linux,phandle = <40000>;
  2239. clock-frequency = <0>;
  2240. interrupt-controller;
  2241. #address-cells = <0>;
  2242. reg = <40000 40000>;
  2243. built-in;
  2244. compatible = "chrp,open-pic";
  2245. device_type = "open-pic";
  2246. big-endian;
  2247. };
  2248. i2c@3000 {
  2249. interrupt-parent = <40000>;
  2250. interrupts = <1b 3>;
  2251. reg = <3000 18>;
  2252. device_type = "i2c";
  2253. compatible = "fsl-i2c";
  2254. dfsrr;
  2255. };
  2256. };