prom.c 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011
  1. /*
  2. * Procedures for creating, accessing and interpreting the device tree.
  3. *
  4. * Paul Mackerras August 1996.
  5. * Copyright (C) 1996-2005 Paul Mackerras.
  6. *
  7. * Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner.
  8. * {engebret|bergner}@us.ibm.com
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version
  13. * 2 of the License, or (at your option) any later version.
  14. */
  15. #undef DEBUG
  16. #include <stdarg.h>
  17. #include <linux/config.h>
  18. #include <linux/kernel.h>
  19. #include <linux/string.h>
  20. #include <linux/init.h>
  21. #include <linux/threads.h>
  22. #include <linux/spinlock.h>
  23. #include <linux/types.h>
  24. #include <linux/pci.h>
  25. #include <linux/stringify.h>
  26. #include <linux/delay.h>
  27. #include <linux/initrd.h>
  28. #include <linux/bitops.h>
  29. #include <linux/module.h>
  30. #include <linux/kexec.h>
  31. #include <asm/prom.h>
  32. #include <asm/rtas.h>
  33. #include <asm/lmb.h>
  34. #include <asm/page.h>
  35. #include <asm/processor.h>
  36. #include <asm/irq.h>
  37. #include <asm/io.h>
  38. #include <asm/kdump.h>
  39. #include <asm/smp.h>
  40. #include <asm/system.h>
  41. #include <asm/mmu.h>
  42. #include <asm/pgtable.h>
  43. #include <asm/pci.h>
  44. #include <asm/iommu.h>
  45. #include <asm/btext.h>
  46. #include <asm/sections.h>
  47. #include <asm/machdep.h>
  48. #include <asm/pSeries_reconfig.h>
  49. #include <asm/pci-bridge.h>
  50. #ifdef DEBUG
  51. #define DBG(fmt...) printk(KERN_ERR fmt)
  52. #else
  53. #define DBG(fmt...)
  54. #endif
  55. static int __initdata dt_root_addr_cells;
  56. static int __initdata dt_root_size_cells;
  57. #ifdef CONFIG_PPC64
  58. static int __initdata iommu_is_off;
  59. int __initdata iommu_force_on;
  60. unsigned long tce_alloc_start, tce_alloc_end;
  61. #endif
  62. typedef u32 cell_t;
  63. #if 0
  64. static struct boot_param_header *initial_boot_params __initdata;
  65. #else
  66. struct boot_param_header *initial_boot_params;
  67. #endif
  68. static struct device_node *allnodes = NULL;
  69. /* use when traversing tree through the allnext, child, sibling,
  70. * or parent members of struct device_node.
  71. */
  72. static DEFINE_RWLOCK(devtree_lock);
  73. /* export that to outside world */
  74. struct device_node *of_chosen;
  75. struct device_node *dflt_interrupt_controller;
  76. int num_interrupt_controllers;
  77. /*
  78. * Wrapper for allocating memory for various data that needs to be
  79. * attached to device nodes as they are processed at boot or when
  80. * added to the device tree later (e.g. DLPAR). At boot there is
  81. * already a region reserved so we just increment *mem_start by size;
  82. * otherwise we call kmalloc.
  83. */
  84. static void * prom_alloc(unsigned long size, unsigned long *mem_start)
  85. {
  86. unsigned long tmp;
  87. if (!mem_start)
  88. return kmalloc(size, GFP_KERNEL);
  89. tmp = *mem_start;
  90. *mem_start += size;
  91. return (void *)tmp;
  92. }
  93. /*
  94. * Find the device_node with a given phandle.
  95. */
  96. static struct device_node * find_phandle(phandle ph)
  97. {
  98. struct device_node *np;
  99. for (np = allnodes; np != 0; np = np->allnext)
  100. if (np->linux_phandle == ph)
  101. return np;
  102. return NULL;
  103. }
  104. /*
  105. * Find the interrupt parent of a node.
  106. */
  107. static struct device_node * __devinit intr_parent(struct device_node *p)
  108. {
  109. phandle *parp;
  110. parp = (phandle *) get_property(p, "interrupt-parent", NULL);
  111. if (parp == NULL)
  112. return p->parent;
  113. p = find_phandle(*parp);
  114. if (p != NULL)
  115. return p;
  116. /*
  117. * On a powermac booted with BootX, we don't get to know the
  118. * phandles for any nodes, so find_phandle will return NULL.
  119. * Fortunately these machines only have one interrupt controller
  120. * so there isn't in fact any ambiguity. -- paulus
  121. */
  122. if (num_interrupt_controllers == 1)
  123. p = dflt_interrupt_controller;
  124. return p;
  125. }
  126. /*
  127. * Find out the size of each entry of the interrupts property
  128. * for a node.
  129. */
  130. int __devinit prom_n_intr_cells(struct device_node *np)
  131. {
  132. struct device_node *p;
  133. unsigned int *icp;
  134. for (p = np; (p = intr_parent(p)) != NULL; ) {
  135. icp = (unsigned int *)
  136. get_property(p, "#interrupt-cells", NULL);
  137. if (icp != NULL)
  138. return *icp;
  139. if (get_property(p, "interrupt-controller", NULL) != NULL
  140. || get_property(p, "interrupt-map", NULL) != NULL) {
  141. printk("oops, node %s doesn't have #interrupt-cells\n",
  142. p->full_name);
  143. return 1;
  144. }
  145. }
  146. #ifdef DEBUG_IRQ
  147. printk("prom_n_intr_cells failed for %s\n", np->full_name);
  148. #endif
  149. return 1;
  150. }
  151. /*
  152. * Map an interrupt from a device up to the platform interrupt
  153. * descriptor.
  154. */
  155. static int __devinit map_interrupt(unsigned int **irq, struct device_node **ictrler,
  156. struct device_node *np, unsigned int *ints,
  157. int nintrc)
  158. {
  159. struct device_node *p, *ipar;
  160. unsigned int *imap, *imask, *ip;
  161. int i, imaplen, match;
  162. int newintrc = 0, newaddrc = 0;
  163. unsigned int *reg;
  164. int naddrc;
  165. reg = (unsigned int *) get_property(np, "reg", NULL);
  166. naddrc = prom_n_addr_cells(np);
  167. p = intr_parent(np);
  168. while (p != NULL) {
  169. if (get_property(p, "interrupt-controller", NULL) != NULL)
  170. /* this node is an interrupt controller, stop here */
  171. break;
  172. imap = (unsigned int *)
  173. get_property(p, "interrupt-map", &imaplen);
  174. if (imap == NULL) {
  175. p = intr_parent(p);
  176. continue;
  177. }
  178. imask = (unsigned int *)
  179. get_property(p, "interrupt-map-mask", NULL);
  180. if (imask == NULL) {
  181. printk("oops, %s has interrupt-map but no mask\n",
  182. p->full_name);
  183. return 0;
  184. }
  185. imaplen /= sizeof(unsigned int);
  186. match = 0;
  187. ipar = NULL;
  188. while (imaplen > 0 && !match) {
  189. /* check the child-interrupt field */
  190. match = 1;
  191. for (i = 0; i < naddrc && match; ++i)
  192. match = ((reg[i] ^ imap[i]) & imask[i]) == 0;
  193. for (; i < naddrc + nintrc && match; ++i)
  194. match = ((ints[i-naddrc] ^ imap[i]) & imask[i]) == 0;
  195. imap += naddrc + nintrc;
  196. imaplen -= naddrc + nintrc;
  197. /* grab the interrupt parent */
  198. ipar = find_phandle((phandle) *imap++);
  199. --imaplen;
  200. if (ipar == NULL && num_interrupt_controllers == 1)
  201. /* cope with BootX not giving us phandles */
  202. ipar = dflt_interrupt_controller;
  203. if (ipar == NULL) {
  204. printk("oops, no int parent %x in map of %s\n",
  205. imap[-1], p->full_name);
  206. return 0;
  207. }
  208. /* find the parent's # addr and intr cells */
  209. ip = (unsigned int *)
  210. get_property(ipar, "#interrupt-cells", NULL);
  211. if (ip == NULL) {
  212. printk("oops, no #interrupt-cells on %s\n",
  213. ipar->full_name);
  214. return 0;
  215. }
  216. newintrc = *ip;
  217. ip = (unsigned int *)
  218. get_property(ipar, "#address-cells", NULL);
  219. newaddrc = (ip == NULL)? 0: *ip;
  220. imap += newaddrc + newintrc;
  221. imaplen -= newaddrc + newintrc;
  222. }
  223. if (imaplen < 0) {
  224. printk("oops, error decoding int-map on %s, len=%d\n",
  225. p->full_name, imaplen);
  226. return 0;
  227. }
  228. if (!match) {
  229. #ifdef DEBUG_IRQ
  230. printk("oops, no match in %s int-map for %s\n",
  231. p->full_name, np->full_name);
  232. #endif
  233. return 0;
  234. }
  235. p = ipar;
  236. naddrc = newaddrc;
  237. nintrc = newintrc;
  238. ints = imap - nintrc;
  239. reg = ints - naddrc;
  240. }
  241. if (p == NULL) {
  242. #ifdef DEBUG_IRQ
  243. printk("hmmm, int tree for %s doesn't have ctrler\n",
  244. np->full_name);
  245. #endif
  246. return 0;
  247. }
  248. *irq = ints;
  249. *ictrler = p;
  250. return nintrc;
  251. }
  252. static unsigned char map_isa_senses[4] = {
  253. IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE,
  254. IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE,
  255. IRQ_SENSE_EDGE | IRQ_POLARITY_NEGATIVE,
  256. IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE
  257. };
  258. static unsigned char map_mpic_senses[4] = {
  259. IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE,
  260. IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE,
  261. /* 2 seems to be used for the 8259 cascade... */
  262. IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE,
  263. IRQ_SENSE_EDGE | IRQ_POLARITY_NEGATIVE,
  264. };
  265. static int __devinit finish_node_interrupts(struct device_node *np,
  266. unsigned long *mem_start,
  267. int measure_only)
  268. {
  269. unsigned int *ints;
  270. int intlen, intrcells, intrcount;
  271. int i, j, n, sense;
  272. unsigned int *irq, virq;
  273. struct device_node *ic;
  274. int trace = 0;
  275. //#define TRACE(fmt...) do { if (trace) { printk(fmt); mdelay(1000); } } while(0)
  276. #define TRACE(fmt...)
  277. if (!strcmp(np->name, "smu-doorbell"))
  278. trace = 1;
  279. TRACE("Finishing SMU doorbell ! num_interrupt_controllers = %d\n",
  280. num_interrupt_controllers);
  281. if (num_interrupt_controllers == 0) {
  282. /*
  283. * Old machines just have a list of interrupt numbers
  284. * and no interrupt-controller nodes.
  285. */
  286. ints = (unsigned int *) get_property(np, "AAPL,interrupts",
  287. &intlen);
  288. /* XXX old interpret_pci_props looked in parent too */
  289. /* XXX old interpret_macio_props looked for interrupts
  290. before AAPL,interrupts */
  291. if (ints == NULL)
  292. ints = (unsigned int *) get_property(np, "interrupts",
  293. &intlen);
  294. if (ints == NULL)
  295. return 0;
  296. np->n_intrs = intlen / sizeof(unsigned int);
  297. np->intrs = prom_alloc(np->n_intrs * sizeof(np->intrs[0]),
  298. mem_start);
  299. if (!np->intrs)
  300. return -ENOMEM;
  301. if (measure_only)
  302. return 0;
  303. for (i = 0; i < np->n_intrs; ++i) {
  304. np->intrs[i].line = *ints++;
  305. np->intrs[i].sense = IRQ_SENSE_LEVEL
  306. | IRQ_POLARITY_NEGATIVE;
  307. }
  308. return 0;
  309. }
  310. ints = (unsigned int *) get_property(np, "interrupts", &intlen);
  311. TRACE("ints=%p, intlen=%d\n", ints, intlen);
  312. if (ints == NULL)
  313. return 0;
  314. intrcells = prom_n_intr_cells(np);
  315. intlen /= intrcells * sizeof(unsigned int);
  316. TRACE("intrcells=%d, new intlen=%d\n", intrcells, intlen);
  317. np->intrs = prom_alloc(intlen * sizeof(*(np->intrs)), mem_start);
  318. if (!np->intrs)
  319. return -ENOMEM;
  320. if (measure_only)
  321. return 0;
  322. intrcount = 0;
  323. for (i = 0; i < intlen; ++i, ints += intrcells) {
  324. n = map_interrupt(&irq, &ic, np, ints, intrcells);
  325. TRACE("map, irq=%d, ic=%p, n=%d\n", irq, ic, n);
  326. if (n <= 0)
  327. continue;
  328. /* don't map IRQ numbers under a cascaded 8259 controller */
  329. if (ic && device_is_compatible(ic, "chrp,iic")) {
  330. np->intrs[intrcount].line = irq[0];
  331. sense = (n > 1)? (irq[1] & 3): 3;
  332. np->intrs[intrcount].sense = map_isa_senses[sense];
  333. } else {
  334. virq = virt_irq_create_mapping(irq[0]);
  335. TRACE("virq=%d\n", virq);
  336. #ifdef CONFIG_PPC64
  337. if (virq == NO_IRQ) {
  338. printk(KERN_CRIT "Could not allocate interrupt"
  339. " number for %s\n", np->full_name);
  340. continue;
  341. }
  342. #endif
  343. np->intrs[intrcount].line = irq_offset_up(virq);
  344. sense = (n > 1)? (irq[1] & 3): 1;
  345. /* Apple uses bits in there in a different way, let's
  346. * only keep the real sense bit on macs
  347. */
  348. if (machine_is(powermac))
  349. sense &= 0x1;
  350. np->intrs[intrcount].sense = map_mpic_senses[sense];
  351. }
  352. #ifdef CONFIG_PPC64
  353. /* We offset irq numbers for the u3 MPIC by 128 in PowerMac */
  354. if (machine_is(powermac) && ic && ic->parent) {
  355. char *name = get_property(ic->parent, "name", NULL);
  356. if (name && !strcmp(name, "u3"))
  357. np->intrs[intrcount].line += 128;
  358. else if (!(name && (!strcmp(name, "mac-io") ||
  359. !strcmp(name, "u4"))))
  360. /* ignore other cascaded controllers, such as
  361. the k2-sata-root */
  362. break;
  363. }
  364. #endif /* CONFIG_PPC64 */
  365. if (n > 2) {
  366. printk("hmmm, got %d intr cells for %s:", n,
  367. np->full_name);
  368. for (j = 0; j < n; ++j)
  369. printk(" %d", irq[j]);
  370. printk("\n");
  371. }
  372. ++intrcount;
  373. }
  374. np->n_intrs = intrcount;
  375. return 0;
  376. }
  377. static int __devinit finish_node(struct device_node *np,
  378. unsigned long *mem_start,
  379. int measure_only)
  380. {
  381. struct device_node *child;
  382. int rc = 0;
  383. rc = finish_node_interrupts(np, mem_start, measure_only);
  384. if (rc)
  385. goto out;
  386. for (child = np->child; child != NULL; child = child->sibling) {
  387. rc = finish_node(child, mem_start, measure_only);
  388. if (rc)
  389. goto out;
  390. }
  391. out:
  392. return rc;
  393. }
  394. static void __init scan_interrupt_controllers(void)
  395. {
  396. struct device_node *np;
  397. int n = 0;
  398. char *name, *ic;
  399. int iclen;
  400. for (np = allnodes; np != NULL; np = np->allnext) {
  401. ic = get_property(np, "interrupt-controller", &iclen);
  402. name = get_property(np, "name", NULL);
  403. /* checking iclen makes sure we don't get a false
  404. match on /chosen.interrupt_controller */
  405. if ((name != NULL
  406. && strcmp(name, "interrupt-controller") == 0)
  407. || (ic != NULL && iclen == 0
  408. && strcmp(name, "AppleKiwi"))) {
  409. if (n == 0)
  410. dflt_interrupt_controller = np;
  411. ++n;
  412. }
  413. }
  414. num_interrupt_controllers = n;
  415. }
  416. /**
  417. * finish_device_tree is called once things are running normally
  418. * (i.e. with text and data mapped to the address they were linked at).
  419. * It traverses the device tree and fills in some of the additional,
  420. * fields in each node like {n_}addrs and {n_}intrs, the virt interrupt
  421. * mapping is also initialized at this point.
  422. */
  423. void __init finish_device_tree(void)
  424. {
  425. unsigned long start, end, size = 0;
  426. DBG(" -> finish_device_tree\n");
  427. #ifdef CONFIG_PPC64
  428. /* Initialize virtual IRQ map */
  429. virt_irq_init();
  430. #endif
  431. scan_interrupt_controllers();
  432. /*
  433. * Finish device-tree (pre-parsing some properties etc...)
  434. * We do this in 2 passes. One with "measure_only" set, which
  435. * will only measure the amount of memory needed, then we can
  436. * allocate that memory, and call finish_node again. However,
  437. * we must be careful as most routines will fail nowadays when
  438. * prom_alloc() returns 0, so we must make sure our first pass
  439. * doesn't start at 0. We pre-initialize size to 16 for that
  440. * reason and then remove those additional 16 bytes
  441. */
  442. size = 16;
  443. finish_node(allnodes, &size, 1);
  444. size -= 16;
  445. if (0 == size)
  446. end = start = 0;
  447. else
  448. end = start = (unsigned long)__va(lmb_alloc(size, 128));
  449. finish_node(allnodes, &end, 0);
  450. BUG_ON(end != start + size);
  451. DBG(" <- finish_device_tree\n");
  452. }
  453. static inline char *find_flat_dt_string(u32 offset)
  454. {
  455. return ((char *)initial_boot_params) +
  456. initial_boot_params->off_dt_strings + offset;
  457. }
  458. /**
  459. * This function is used to scan the flattened device-tree, it is
  460. * used to extract the memory informations at boot before we can
  461. * unflatten the tree
  462. */
  463. int __init of_scan_flat_dt(int (*it)(unsigned long node,
  464. const char *uname, int depth,
  465. void *data),
  466. void *data)
  467. {
  468. unsigned long p = ((unsigned long)initial_boot_params) +
  469. initial_boot_params->off_dt_struct;
  470. int rc = 0;
  471. int depth = -1;
  472. do {
  473. u32 tag = *((u32 *)p);
  474. char *pathp;
  475. p += 4;
  476. if (tag == OF_DT_END_NODE) {
  477. depth --;
  478. continue;
  479. }
  480. if (tag == OF_DT_NOP)
  481. continue;
  482. if (tag == OF_DT_END)
  483. break;
  484. if (tag == OF_DT_PROP) {
  485. u32 sz = *((u32 *)p);
  486. p += 8;
  487. if (initial_boot_params->version < 0x10)
  488. p = _ALIGN(p, sz >= 8 ? 8 : 4);
  489. p += sz;
  490. p = _ALIGN(p, 4);
  491. continue;
  492. }
  493. if (tag != OF_DT_BEGIN_NODE) {
  494. printk(KERN_WARNING "Invalid tag %x scanning flattened"
  495. " device tree !\n", tag);
  496. return -EINVAL;
  497. }
  498. depth++;
  499. pathp = (char *)p;
  500. p = _ALIGN(p + strlen(pathp) + 1, 4);
  501. if ((*pathp) == '/') {
  502. char *lp, *np;
  503. for (lp = NULL, np = pathp; *np; np++)
  504. if ((*np) == '/')
  505. lp = np+1;
  506. if (lp != NULL)
  507. pathp = lp;
  508. }
  509. rc = it(p, pathp, depth, data);
  510. if (rc != 0)
  511. break;
  512. } while(1);
  513. return rc;
  514. }
  515. unsigned long __init of_get_flat_dt_root(void)
  516. {
  517. unsigned long p = ((unsigned long)initial_boot_params) +
  518. initial_boot_params->off_dt_struct;
  519. while(*((u32 *)p) == OF_DT_NOP)
  520. p += 4;
  521. BUG_ON (*((u32 *)p) != OF_DT_BEGIN_NODE);
  522. p += 4;
  523. return _ALIGN(p + strlen((char *)p) + 1, 4);
  524. }
  525. /**
  526. * This function can be used within scan_flattened_dt callback to get
  527. * access to properties
  528. */
  529. void* __init of_get_flat_dt_prop(unsigned long node, const char *name,
  530. unsigned long *size)
  531. {
  532. unsigned long p = node;
  533. do {
  534. u32 tag = *((u32 *)p);
  535. u32 sz, noff;
  536. const char *nstr;
  537. p += 4;
  538. if (tag == OF_DT_NOP)
  539. continue;
  540. if (tag != OF_DT_PROP)
  541. return NULL;
  542. sz = *((u32 *)p);
  543. noff = *((u32 *)(p + 4));
  544. p += 8;
  545. if (initial_boot_params->version < 0x10)
  546. p = _ALIGN(p, sz >= 8 ? 8 : 4);
  547. nstr = find_flat_dt_string(noff);
  548. if (nstr == NULL) {
  549. printk(KERN_WARNING "Can't find property index"
  550. " name !\n");
  551. return NULL;
  552. }
  553. if (strcmp(name, nstr) == 0) {
  554. if (size)
  555. *size = sz;
  556. return (void *)p;
  557. }
  558. p += sz;
  559. p = _ALIGN(p, 4);
  560. } while(1);
  561. }
  562. int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
  563. {
  564. const char* cp;
  565. unsigned long cplen, l;
  566. cp = of_get_flat_dt_prop(node, "compatible", &cplen);
  567. if (cp == NULL)
  568. return 0;
  569. while (cplen > 0) {
  570. if (strncasecmp(cp, compat, strlen(compat)) == 0)
  571. return 1;
  572. l = strlen(cp) + 1;
  573. cp += l;
  574. cplen -= l;
  575. }
  576. return 0;
  577. }
  578. static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,
  579. unsigned long align)
  580. {
  581. void *res;
  582. *mem = _ALIGN(*mem, align);
  583. res = (void *)*mem;
  584. *mem += size;
  585. return res;
  586. }
  587. static unsigned long __init unflatten_dt_node(unsigned long mem,
  588. unsigned long *p,
  589. struct device_node *dad,
  590. struct device_node ***allnextpp,
  591. unsigned long fpsize)
  592. {
  593. struct device_node *np;
  594. struct property *pp, **prev_pp = NULL;
  595. char *pathp;
  596. u32 tag;
  597. unsigned int l, allocl;
  598. int has_name = 0;
  599. int new_format = 0;
  600. tag = *((u32 *)(*p));
  601. if (tag != OF_DT_BEGIN_NODE) {
  602. printk("Weird tag at start of node: %x\n", tag);
  603. return mem;
  604. }
  605. *p += 4;
  606. pathp = (char *)*p;
  607. l = allocl = strlen(pathp) + 1;
  608. *p = _ALIGN(*p + l, 4);
  609. /* version 0x10 has a more compact unit name here instead of the full
  610. * path. we accumulate the full path size using "fpsize", we'll rebuild
  611. * it later. We detect this because the first character of the name is
  612. * not '/'.
  613. */
  614. if ((*pathp) != '/') {
  615. new_format = 1;
  616. if (fpsize == 0) {
  617. /* root node: special case. fpsize accounts for path
  618. * plus terminating zero. root node only has '/', so
  619. * fpsize should be 2, but we want to avoid the first
  620. * level nodes to have two '/' so we use fpsize 1 here
  621. */
  622. fpsize = 1;
  623. allocl = 2;
  624. } else {
  625. /* account for '/' and path size minus terminal 0
  626. * already in 'l'
  627. */
  628. fpsize += l;
  629. allocl = fpsize;
  630. }
  631. }
  632. np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl,
  633. __alignof__(struct device_node));
  634. if (allnextpp) {
  635. memset(np, 0, sizeof(*np));
  636. np->full_name = ((char*)np) + sizeof(struct device_node);
  637. if (new_format) {
  638. char *p = np->full_name;
  639. /* rebuild full path for new format */
  640. if (dad && dad->parent) {
  641. strcpy(p, dad->full_name);
  642. #ifdef DEBUG
  643. if ((strlen(p) + l + 1) != allocl) {
  644. DBG("%s: p: %d, l: %d, a: %d\n",
  645. pathp, (int)strlen(p), l, allocl);
  646. }
  647. #endif
  648. p += strlen(p);
  649. }
  650. *(p++) = '/';
  651. memcpy(p, pathp, l);
  652. } else
  653. memcpy(np->full_name, pathp, l);
  654. prev_pp = &np->properties;
  655. **allnextpp = np;
  656. *allnextpp = &np->allnext;
  657. if (dad != NULL) {
  658. np->parent = dad;
  659. /* we temporarily use the next field as `last_child'*/
  660. if (dad->next == 0)
  661. dad->child = np;
  662. else
  663. dad->next->sibling = np;
  664. dad->next = np;
  665. }
  666. kref_init(&np->kref);
  667. }
  668. while(1) {
  669. u32 sz, noff;
  670. char *pname;
  671. tag = *((u32 *)(*p));
  672. if (tag == OF_DT_NOP) {
  673. *p += 4;
  674. continue;
  675. }
  676. if (tag != OF_DT_PROP)
  677. break;
  678. *p += 4;
  679. sz = *((u32 *)(*p));
  680. noff = *((u32 *)((*p) + 4));
  681. *p += 8;
  682. if (initial_boot_params->version < 0x10)
  683. *p = _ALIGN(*p, sz >= 8 ? 8 : 4);
  684. pname = find_flat_dt_string(noff);
  685. if (pname == NULL) {
  686. printk("Can't find property name in list !\n");
  687. break;
  688. }
  689. if (strcmp(pname, "name") == 0)
  690. has_name = 1;
  691. l = strlen(pname) + 1;
  692. pp = unflatten_dt_alloc(&mem, sizeof(struct property),
  693. __alignof__(struct property));
  694. if (allnextpp) {
  695. if (strcmp(pname, "linux,phandle") == 0) {
  696. np->node = *((u32 *)*p);
  697. if (np->linux_phandle == 0)
  698. np->linux_phandle = np->node;
  699. }
  700. if (strcmp(pname, "ibm,phandle") == 0)
  701. np->linux_phandle = *((u32 *)*p);
  702. pp->name = pname;
  703. pp->length = sz;
  704. pp->value = (void *)*p;
  705. *prev_pp = pp;
  706. prev_pp = &pp->next;
  707. }
  708. *p = _ALIGN((*p) + sz, 4);
  709. }
  710. /* with version 0x10 we may not have the name property, recreate
  711. * it here from the unit name if absent
  712. */
  713. if (!has_name) {
  714. char *p = pathp, *ps = pathp, *pa = NULL;
  715. int sz;
  716. while (*p) {
  717. if ((*p) == '@')
  718. pa = p;
  719. if ((*p) == '/')
  720. ps = p + 1;
  721. p++;
  722. }
  723. if (pa < ps)
  724. pa = p;
  725. sz = (pa - ps) + 1;
  726. pp = unflatten_dt_alloc(&mem, sizeof(struct property) + sz,
  727. __alignof__(struct property));
  728. if (allnextpp) {
  729. pp->name = "name";
  730. pp->length = sz;
  731. pp->value = (unsigned char *)(pp + 1);
  732. *prev_pp = pp;
  733. prev_pp = &pp->next;
  734. memcpy(pp->value, ps, sz - 1);
  735. ((char *)pp->value)[sz - 1] = 0;
  736. DBG("fixed up name for %s -> %s\n", pathp, pp->value);
  737. }
  738. }
  739. if (allnextpp) {
  740. *prev_pp = NULL;
  741. np->name = get_property(np, "name", NULL);
  742. np->type = get_property(np, "device_type", NULL);
  743. if (!np->name)
  744. np->name = "<NULL>";
  745. if (!np->type)
  746. np->type = "<NULL>";
  747. }
  748. while (tag == OF_DT_BEGIN_NODE) {
  749. mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize);
  750. tag = *((u32 *)(*p));
  751. }
  752. if (tag != OF_DT_END_NODE) {
  753. printk("Weird tag at end of node: %x\n", tag);
  754. return mem;
  755. }
  756. *p += 4;
  757. return mem;
  758. }
  759. /**
  760. * unflattens the device-tree passed by the firmware, creating the
  761. * tree of struct device_node. It also fills the "name" and "type"
  762. * pointers of the nodes so the normal device-tree walking functions
  763. * can be used (this used to be done by finish_device_tree)
  764. */
  765. void __init unflatten_device_tree(void)
  766. {
  767. unsigned long start, mem, size;
  768. struct device_node **allnextp = &allnodes;
  769. DBG(" -> unflatten_device_tree()\n");
  770. /* First pass, scan for size */
  771. start = ((unsigned long)initial_boot_params) +
  772. initial_boot_params->off_dt_struct;
  773. size = unflatten_dt_node(0, &start, NULL, NULL, 0);
  774. size = (size | 3) + 1;
  775. DBG(" size is %lx, allocating...\n", size);
  776. /* Allocate memory for the expanded device tree */
  777. mem = lmb_alloc(size + 4, __alignof__(struct device_node));
  778. mem = (unsigned long) __va(mem);
  779. ((u32 *)mem)[size / 4] = 0xdeadbeef;
  780. DBG(" unflattening %lx...\n", mem);
  781. /* Second pass, do actual unflattening */
  782. start = ((unsigned long)initial_boot_params) +
  783. initial_boot_params->off_dt_struct;
  784. unflatten_dt_node(mem, &start, NULL, &allnextp, 0);
  785. if (*((u32 *)start) != OF_DT_END)
  786. printk(KERN_WARNING "Weird tag at end of tree: %08x\n", *((u32 *)start));
  787. if (((u32 *)mem)[size / 4] != 0xdeadbeef)
  788. printk(KERN_WARNING "End of tree marker overwritten: %08x\n",
  789. ((u32 *)mem)[size / 4] );
  790. *allnextp = NULL;
  791. /* Get pointer to OF "/chosen" node for use everywhere */
  792. of_chosen = of_find_node_by_path("/chosen");
  793. if (of_chosen == NULL)
  794. of_chosen = of_find_node_by_path("/chosen@0");
  795. DBG(" <- unflatten_device_tree()\n");
  796. }
  797. static int __init early_init_dt_scan_cpus(unsigned long node,
  798. const char *uname, int depth,
  799. void *data)
  800. {
  801. static int logical_cpuid = 0;
  802. char *type = of_get_flat_dt_prop(node, "device_type", NULL);
  803. #ifdef CONFIG_ALTIVEC
  804. u32 *prop;
  805. #endif
  806. u32 *intserv;
  807. int i, nthreads;
  808. unsigned long len;
  809. int found = 0;
  810. /* We are scanning "cpu" nodes only */
  811. if (type == NULL || strcmp(type, "cpu") != 0)
  812. return 0;
  813. /* Get physical cpuid */
  814. intserv = of_get_flat_dt_prop(node, "ibm,ppc-interrupt-server#s", &len);
  815. if (intserv) {
  816. nthreads = len / sizeof(int);
  817. } else {
  818. intserv = of_get_flat_dt_prop(node, "reg", NULL);
  819. nthreads = 1;
  820. }
  821. /*
  822. * Now see if any of these threads match our boot cpu.
  823. * NOTE: This must match the parsing done in smp_setup_cpu_maps.
  824. */
  825. for (i = 0; i < nthreads; i++) {
  826. /*
  827. * version 2 of the kexec param format adds the phys cpuid of
  828. * booted proc.
  829. */
  830. if (initial_boot_params && initial_boot_params->version >= 2) {
  831. if (intserv[i] ==
  832. initial_boot_params->boot_cpuid_phys) {
  833. found = 1;
  834. break;
  835. }
  836. } else {
  837. /*
  838. * Check if it's the boot-cpu, set it's hw index now,
  839. * unfortunately this format did not support booting
  840. * off secondary threads.
  841. */
  842. if (of_get_flat_dt_prop(node,
  843. "linux,boot-cpu", NULL) != NULL) {
  844. found = 1;
  845. break;
  846. }
  847. }
  848. #ifdef CONFIG_SMP
  849. /* logical cpu id is always 0 on UP kernels */
  850. logical_cpuid++;
  851. #endif
  852. }
  853. if (found) {
  854. DBG("boot cpu: logical %d physical %d\n", logical_cpuid,
  855. intserv[i]);
  856. boot_cpuid = logical_cpuid;
  857. set_hard_smp_processor_id(boot_cpuid, intserv[i]);
  858. }
  859. #ifdef CONFIG_ALTIVEC
  860. /* Check if we have a VMX and eventually update CPU features */
  861. prop = (u32 *)of_get_flat_dt_prop(node, "ibm,vmx", NULL);
  862. if (prop && (*prop) > 0) {
  863. cur_cpu_spec->cpu_features |= CPU_FTR_ALTIVEC;
  864. cur_cpu_spec->cpu_user_features |= PPC_FEATURE_HAS_ALTIVEC;
  865. }
  866. /* Same goes for Apple's "altivec" property */
  867. prop = (u32 *)of_get_flat_dt_prop(node, "altivec", NULL);
  868. if (prop) {
  869. cur_cpu_spec->cpu_features |= CPU_FTR_ALTIVEC;
  870. cur_cpu_spec->cpu_user_features |= PPC_FEATURE_HAS_ALTIVEC;
  871. }
  872. #endif /* CONFIG_ALTIVEC */
  873. #ifdef CONFIG_PPC_PSERIES
  874. if (nthreads > 1)
  875. cur_cpu_spec->cpu_features |= CPU_FTR_SMT;
  876. else
  877. cur_cpu_spec->cpu_features &= ~CPU_FTR_SMT;
  878. #endif
  879. return 0;
  880. }
  881. static int __init early_init_dt_scan_chosen(unsigned long node,
  882. const char *uname, int depth, void *data)
  883. {
  884. unsigned long *lprop;
  885. unsigned long l;
  886. char *p;
  887. DBG("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
  888. if (depth != 1 ||
  889. (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0))
  890. return 0;
  891. #ifdef CONFIG_PPC64
  892. /* check if iommu is forced on or off */
  893. if (of_get_flat_dt_prop(node, "linux,iommu-off", NULL) != NULL)
  894. iommu_is_off = 1;
  895. if (of_get_flat_dt_prop(node, "linux,iommu-force-on", NULL) != NULL)
  896. iommu_force_on = 1;
  897. #endif
  898. lprop = of_get_flat_dt_prop(node, "linux,memory-limit", NULL);
  899. if (lprop)
  900. memory_limit = *lprop;
  901. #ifdef CONFIG_PPC64
  902. lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-start", NULL);
  903. if (lprop)
  904. tce_alloc_start = *lprop;
  905. lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-end", NULL);
  906. if (lprop)
  907. tce_alloc_end = *lprop;
  908. #endif
  909. #ifdef CONFIG_PPC_RTAS
  910. /* To help early debugging via the front panel, we retrieve a minimal
  911. * set of RTAS infos now if available
  912. */
  913. {
  914. u64 *basep, *entryp, *sizep;
  915. basep = of_get_flat_dt_prop(node, "linux,rtas-base", NULL);
  916. entryp = of_get_flat_dt_prop(node, "linux,rtas-entry", NULL);
  917. sizep = of_get_flat_dt_prop(node, "linux,rtas-size", NULL);
  918. if (basep && entryp && sizep) {
  919. rtas.base = *basep;
  920. rtas.entry = *entryp;
  921. rtas.size = *sizep;
  922. }
  923. }
  924. #endif /* CONFIG_PPC_RTAS */
  925. #ifdef CONFIG_KEXEC
  926. lprop = (u64*)of_get_flat_dt_prop(node, "linux,crashkernel-base", NULL);
  927. if (lprop)
  928. crashk_res.start = *lprop;
  929. lprop = (u64*)of_get_flat_dt_prop(node, "linux,crashkernel-size", NULL);
  930. if (lprop)
  931. crashk_res.end = crashk_res.start + *lprop - 1;
  932. #endif
  933. /* Retreive command line */
  934. p = of_get_flat_dt_prop(node, "bootargs", &l);
  935. if (p != NULL && l > 0)
  936. strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
  937. #ifdef CONFIG_CMDLINE
  938. if (l == 0 || (l == 1 && (*p) == 0))
  939. strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
  940. #endif /* CONFIG_CMDLINE */
  941. DBG("Command line is: %s\n", cmd_line);
  942. if (strstr(cmd_line, "mem=")) {
  943. char *p, *q;
  944. for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
  945. q = p + 4;
  946. if (p > cmd_line && p[-1] != ' ')
  947. continue;
  948. memory_limit = memparse(q, &q);
  949. }
  950. }
  951. /* break now */
  952. return 1;
  953. }
  954. static int __init early_init_dt_scan_root(unsigned long node,
  955. const char *uname, int depth, void *data)
  956. {
  957. u32 *prop;
  958. if (depth != 0)
  959. return 0;
  960. prop = of_get_flat_dt_prop(node, "#size-cells", NULL);
  961. dt_root_size_cells = (prop == NULL) ? 1 : *prop;
  962. DBG("dt_root_size_cells = %x\n", dt_root_size_cells);
  963. prop = of_get_flat_dt_prop(node, "#address-cells", NULL);
  964. dt_root_addr_cells = (prop == NULL) ? 2 : *prop;
  965. DBG("dt_root_addr_cells = %x\n", dt_root_addr_cells);
  966. /* break now */
  967. return 1;
  968. }
  969. static unsigned long __init dt_mem_next_cell(int s, cell_t **cellp)
  970. {
  971. cell_t *p = *cellp;
  972. unsigned long r;
  973. /* Ignore more than 2 cells */
  974. while (s > sizeof(unsigned long) / 4) {
  975. p++;
  976. s--;
  977. }
  978. r = *p++;
  979. #ifdef CONFIG_PPC64
  980. if (s > 1) {
  981. r <<= 32;
  982. r |= *(p++);
  983. s--;
  984. }
  985. #endif
  986. *cellp = p;
  987. return r;
  988. }
  989. static int __init early_init_dt_scan_memory(unsigned long node,
  990. const char *uname, int depth, void *data)
  991. {
  992. char *type = of_get_flat_dt_prop(node, "device_type", NULL);
  993. cell_t *reg, *endp;
  994. unsigned long l;
  995. /* We are scanning "memory" nodes only */
  996. if (type == NULL) {
  997. /*
  998. * The longtrail doesn't have a device_type on the
  999. * /memory node, so look for the node called /memory@0.
  1000. */
  1001. if (depth != 1 || strcmp(uname, "memory@0") != 0)
  1002. return 0;
  1003. } else if (strcmp(type, "memory") != 0)
  1004. return 0;
  1005. reg = (cell_t *)of_get_flat_dt_prop(node, "linux,usable-memory", &l);
  1006. if (reg == NULL)
  1007. reg = (cell_t *)of_get_flat_dt_prop(node, "reg", &l);
  1008. if (reg == NULL)
  1009. return 0;
  1010. endp = reg + (l / sizeof(cell_t));
  1011. DBG("memory scan node %s, reg size %ld, data: %x %x %x %x,\n",
  1012. uname, l, reg[0], reg[1], reg[2], reg[3]);
  1013. while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {
  1014. unsigned long base, size;
  1015. base = dt_mem_next_cell(dt_root_addr_cells, &reg);
  1016. size = dt_mem_next_cell(dt_root_size_cells, &reg);
  1017. if (size == 0)
  1018. continue;
  1019. DBG(" - %lx , %lx\n", base, size);
  1020. #ifdef CONFIG_PPC64
  1021. if (iommu_is_off) {
  1022. if (base >= 0x80000000ul)
  1023. continue;
  1024. if ((base + size) > 0x80000000ul)
  1025. size = 0x80000000ul - base;
  1026. }
  1027. #endif
  1028. lmb_add(base, size);
  1029. }
  1030. return 0;
  1031. }
  1032. static void __init early_reserve_mem(void)
  1033. {
  1034. u64 base, size;
  1035. u64 *reserve_map;
  1036. reserve_map = (u64 *)(((unsigned long)initial_boot_params) +
  1037. initial_boot_params->off_mem_rsvmap);
  1038. #ifdef CONFIG_PPC32
  1039. /*
  1040. * Handle the case where we might be booting from an old kexec
  1041. * image that setup the mem_rsvmap as pairs of 32-bit values
  1042. */
  1043. if (*reserve_map > 0xffffffffull) {
  1044. u32 base_32, size_32;
  1045. u32 *reserve_map_32 = (u32 *)reserve_map;
  1046. while (1) {
  1047. base_32 = *(reserve_map_32++);
  1048. size_32 = *(reserve_map_32++);
  1049. if (size_32 == 0)
  1050. break;
  1051. DBG("reserving: %x -> %x\n", base_32, size_32);
  1052. lmb_reserve(base_32, size_32);
  1053. }
  1054. return;
  1055. }
  1056. #endif
  1057. while (1) {
  1058. base = *(reserve_map++);
  1059. size = *(reserve_map++);
  1060. if (size == 0)
  1061. break;
  1062. DBG("reserving: %llx -> %llx\n", base, size);
  1063. lmb_reserve(base, size);
  1064. }
  1065. #if 0
  1066. DBG("memory reserved, lmbs :\n");
  1067. lmb_dump_all();
  1068. #endif
  1069. }
  1070. void __init early_init_devtree(void *params)
  1071. {
  1072. DBG(" -> early_init_devtree()\n");
  1073. /* Setup flat device-tree pointer */
  1074. initial_boot_params = params;
  1075. /* Retrieve various informations from the /chosen node of the
  1076. * device-tree, including the platform type, initrd location and
  1077. * size, TCE reserve, and more ...
  1078. */
  1079. of_scan_flat_dt(early_init_dt_scan_chosen, NULL);
  1080. /* Scan memory nodes and rebuild LMBs */
  1081. lmb_init();
  1082. of_scan_flat_dt(early_init_dt_scan_root, NULL);
  1083. of_scan_flat_dt(early_init_dt_scan_memory, NULL);
  1084. lmb_enforce_memory_limit(memory_limit);
  1085. lmb_analyze();
  1086. DBG("Phys. mem: %lx\n", lmb_phys_mem_size());
  1087. /* Reserve LMB regions used by kernel, initrd, dt, etc... */
  1088. lmb_reserve(PHYSICAL_START, __pa(klimit) - PHYSICAL_START);
  1089. #ifdef CONFIG_CRASH_DUMP
  1090. lmb_reserve(0, KDUMP_RESERVE_LIMIT);
  1091. #endif
  1092. early_reserve_mem();
  1093. DBG("Scanning CPUs ...\n");
  1094. /* Retreive CPU related informations from the flat tree
  1095. * (altivec support, boot CPU ID, ...)
  1096. */
  1097. of_scan_flat_dt(early_init_dt_scan_cpus, NULL);
  1098. DBG(" <- early_init_devtree()\n");
  1099. }
  1100. #undef printk
  1101. int
  1102. prom_n_addr_cells(struct device_node* np)
  1103. {
  1104. int* ip;
  1105. do {
  1106. if (np->parent)
  1107. np = np->parent;
  1108. ip = (int *) get_property(np, "#address-cells", NULL);
  1109. if (ip != NULL)
  1110. return *ip;
  1111. } while (np->parent);
  1112. /* No #address-cells property for the root node, default to 1 */
  1113. return 1;
  1114. }
  1115. EXPORT_SYMBOL(prom_n_addr_cells);
  1116. int
  1117. prom_n_size_cells(struct device_node* np)
  1118. {
  1119. int* ip;
  1120. do {
  1121. if (np->parent)
  1122. np = np->parent;
  1123. ip = (int *) get_property(np, "#size-cells", NULL);
  1124. if (ip != NULL)
  1125. return *ip;
  1126. } while (np->parent);
  1127. /* No #size-cells property for the root node, default to 1 */
  1128. return 1;
  1129. }
  1130. EXPORT_SYMBOL(prom_n_size_cells);
  1131. /**
  1132. * Work out the sense (active-low level / active-high edge)
  1133. * of each interrupt from the device tree.
  1134. */
  1135. void __init prom_get_irq_senses(unsigned char *senses, int off, int max)
  1136. {
  1137. struct device_node *np;
  1138. int i, j;
  1139. /* default to level-triggered */
  1140. memset(senses, IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE, max - off);
  1141. for (np = allnodes; np != 0; np = np->allnext) {
  1142. for (j = 0; j < np->n_intrs; j++) {
  1143. i = np->intrs[j].line;
  1144. if (i >= off && i < max)
  1145. senses[i-off] = np->intrs[j].sense;
  1146. }
  1147. }
  1148. }
  1149. /**
  1150. * Construct and return a list of the device_nodes with a given name.
  1151. */
  1152. struct device_node *find_devices(const char *name)
  1153. {
  1154. struct device_node *head, **prevp, *np;
  1155. prevp = &head;
  1156. for (np = allnodes; np != 0; np = np->allnext) {
  1157. if (np->name != 0 && strcasecmp(np->name, name) == 0) {
  1158. *prevp = np;
  1159. prevp = &np->next;
  1160. }
  1161. }
  1162. *prevp = NULL;
  1163. return head;
  1164. }
  1165. EXPORT_SYMBOL(find_devices);
  1166. /**
  1167. * Construct and return a list of the device_nodes with a given type.
  1168. */
  1169. struct device_node *find_type_devices(const char *type)
  1170. {
  1171. struct device_node *head, **prevp, *np;
  1172. prevp = &head;
  1173. for (np = allnodes; np != 0; np = np->allnext) {
  1174. if (np->type != 0 && strcasecmp(np->type, type) == 0) {
  1175. *prevp = np;
  1176. prevp = &np->next;
  1177. }
  1178. }
  1179. *prevp = NULL;
  1180. return head;
  1181. }
  1182. EXPORT_SYMBOL(find_type_devices);
  1183. /**
  1184. * Returns all nodes linked together
  1185. */
  1186. struct device_node *find_all_nodes(void)
  1187. {
  1188. struct device_node *head, **prevp, *np;
  1189. prevp = &head;
  1190. for (np = allnodes; np != 0; np = np->allnext) {
  1191. *prevp = np;
  1192. prevp = &np->next;
  1193. }
  1194. *prevp = NULL;
  1195. return head;
  1196. }
  1197. EXPORT_SYMBOL(find_all_nodes);
  1198. /** Checks if the given "compat" string matches one of the strings in
  1199. * the device's "compatible" property
  1200. */
  1201. int device_is_compatible(struct device_node *device, const char *compat)
  1202. {
  1203. const char* cp;
  1204. int cplen, l;
  1205. cp = (char *) get_property(device, "compatible", &cplen);
  1206. if (cp == NULL)
  1207. return 0;
  1208. while (cplen > 0) {
  1209. if (strncasecmp(cp, compat, strlen(compat)) == 0)
  1210. return 1;
  1211. l = strlen(cp) + 1;
  1212. cp += l;
  1213. cplen -= l;
  1214. }
  1215. return 0;
  1216. }
  1217. EXPORT_SYMBOL(device_is_compatible);
  1218. /**
  1219. * Indicates whether the root node has a given value in its
  1220. * compatible property.
  1221. */
  1222. int machine_is_compatible(const char *compat)
  1223. {
  1224. struct device_node *root;
  1225. int rc = 0;
  1226. root = of_find_node_by_path("/");
  1227. if (root) {
  1228. rc = device_is_compatible(root, compat);
  1229. of_node_put(root);
  1230. }
  1231. return rc;
  1232. }
  1233. EXPORT_SYMBOL(machine_is_compatible);
  1234. /**
  1235. * Construct and return a list of the device_nodes with a given type
  1236. * and compatible property.
  1237. */
  1238. struct device_node *find_compatible_devices(const char *type,
  1239. const char *compat)
  1240. {
  1241. struct device_node *head, **prevp, *np;
  1242. prevp = &head;
  1243. for (np = allnodes; np != 0; np = np->allnext) {
  1244. if (type != NULL
  1245. && !(np->type != 0 && strcasecmp(np->type, type) == 0))
  1246. continue;
  1247. if (device_is_compatible(np, compat)) {
  1248. *prevp = np;
  1249. prevp = &np->next;
  1250. }
  1251. }
  1252. *prevp = NULL;
  1253. return head;
  1254. }
  1255. EXPORT_SYMBOL(find_compatible_devices);
  1256. /**
  1257. * Find the device_node with a given full_name.
  1258. */
  1259. struct device_node *find_path_device(const char *path)
  1260. {
  1261. struct device_node *np;
  1262. for (np = allnodes; np != 0; np = np->allnext)
  1263. if (np->full_name != 0 && strcasecmp(np->full_name, path) == 0)
  1264. return np;
  1265. return NULL;
  1266. }
  1267. EXPORT_SYMBOL(find_path_device);
  1268. /*******
  1269. *
  1270. * New implementation of the OF "find" APIs, return a refcounted
  1271. * object, call of_node_put() when done. The device tree and list
  1272. * are protected by a rw_lock.
  1273. *
  1274. * Note that property management will need some locking as well,
  1275. * this isn't dealt with yet.
  1276. *
  1277. *******/
  1278. /**
  1279. * of_find_node_by_name - Find a node by its "name" property
  1280. * @from: The node to start searching from or NULL, the node
  1281. * you pass will not be searched, only the next one
  1282. * will; typically, you pass what the previous call
  1283. * returned. of_node_put() will be called on it
  1284. * @name: The name string to match against
  1285. *
  1286. * Returns a node pointer with refcount incremented, use
  1287. * of_node_put() on it when done.
  1288. */
  1289. struct device_node *of_find_node_by_name(struct device_node *from,
  1290. const char *name)
  1291. {
  1292. struct device_node *np;
  1293. read_lock(&devtree_lock);
  1294. np = from ? from->allnext : allnodes;
  1295. for (; np != NULL; np = np->allnext)
  1296. if (np->name != NULL && strcasecmp(np->name, name) == 0
  1297. && of_node_get(np))
  1298. break;
  1299. if (from)
  1300. of_node_put(from);
  1301. read_unlock(&devtree_lock);
  1302. return np;
  1303. }
  1304. EXPORT_SYMBOL(of_find_node_by_name);
  1305. /**
  1306. * of_find_node_by_type - Find a node by its "device_type" property
  1307. * @from: The node to start searching from or NULL, the node
  1308. * you pass will not be searched, only the next one
  1309. * will; typically, you pass what the previous call
  1310. * returned. of_node_put() will be called on it
  1311. * @name: The type string to match against
  1312. *
  1313. * Returns a node pointer with refcount incremented, use
  1314. * of_node_put() on it when done.
  1315. */
  1316. struct device_node *of_find_node_by_type(struct device_node *from,
  1317. const char *type)
  1318. {
  1319. struct device_node *np;
  1320. read_lock(&devtree_lock);
  1321. np = from ? from->allnext : allnodes;
  1322. for (; np != 0; np = np->allnext)
  1323. if (np->type != 0 && strcasecmp(np->type, type) == 0
  1324. && of_node_get(np))
  1325. break;
  1326. if (from)
  1327. of_node_put(from);
  1328. read_unlock(&devtree_lock);
  1329. return np;
  1330. }
  1331. EXPORT_SYMBOL(of_find_node_by_type);
  1332. /**
  1333. * of_find_compatible_node - Find a node based on type and one of the
  1334. * tokens in its "compatible" property
  1335. * @from: The node to start searching from or NULL, the node
  1336. * you pass will not be searched, only the next one
  1337. * will; typically, you pass what the previous call
  1338. * returned. of_node_put() will be called on it
  1339. * @type: The type string to match "device_type" or NULL to ignore
  1340. * @compatible: The string to match to one of the tokens in the device
  1341. * "compatible" list.
  1342. *
  1343. * Returns a node pointer with refcount incremented, use
  1344. * of_node_put() on it when done.
  1345. */
  1346. struct device_node *of_find_compatible_node(struct device_node *from,
  1347. const char *type, const char *compatible)
  1348. {
  1349. struct device_node *np;
  1350. read_lock(&devtree_lock);
  1351. np = from ? from->allnext : allnodes;
  1352. for (; np != 0; np = np->allnext) {
  1353. if (type != NULL
  1354. && !(np->type != 0 && strcasecmp(np->type, type) == 0))
  1355. continue;
  1356. if (device_is_compatible(np, compatible) && of_node_get(np))
  1357. break;
  1358. }
  1359. if (from)
  1360. of_node_put(from);
  1361. read_unlock(&devtree_lock);
  1362. return np;
  1363. }
  1364. EXPORT_SYMBOL(of_find_compatible_node);
  1365. /**
  1366. * of_find_node_by_path - Find a node matching a full OF path
  1367. * @path: The full path to match
  1368. *
  1369. * Returns a node pointer with refcount incremented, use
  1370. * of_node_put() on it when done.
  1371. */
  1372. struct device_node *of_find_node_by_path(const char *path)
  1373. {
  1374. struct device_node *np = allnodes;
  1375. read_lock(&devtree_lock);
  1376. for (; np != 0; np = np->allnext) {
  1377. if (np->full_name != 0 && strcasecmp(np->full_name, path) == 0
  1378. && of_node_get(np))
  1379. break;
  1380. }
  1381. read_unlock(&devtree_lock);
  1382. return np;
  1383. }
  1384. EXPORT_SYMBOL(of_find_node_by_path);
  1385. /**
  1386. * of_find_node_by_phandle - Find a node given a phandle
  1387. * @handle: phandle of the node to find
  1388. *
  1389. * Returns a node pointer with refcount incremented, use
  1390. * of_node_put() on it when done.
  1391. */
  1392. struct device_node *of_find_node_by_phandle(phandle handle)
  1393. {
  1394. struct device_node *np;
  1395. read_lock(&devtree_lock);
  1396. for (np = allnodes; np != 0; np = np->allnext)
  1397. if (np->linux_phandle == handle)
  1398. break;
  1399. if (np)
  1400. of_node_get(np);
  1401. read_unlock(&devtree_lock);
  1402. return np;
  1403. }
  1404. EXPORT_SYMBOL(of_find_node_by_phandle);
  1405. /**
  1406. * of_find_all_nodes - Get next node in global list
  1407. * @prev: Previous node or NULL to start iteration
  1408. * of_node_put() will be called on it
  1409. *
  1410. * Returns a node pointer with refcount incremented, use
  1411. * of_node_put() on it when done.
  1412. */
  1413. struct device_node *of_find_all_nodes(struct device_node *prev)
  1414. {
  1415. struct device_node *np;
  1416. read_lock(&devtree_lock);
  1417. np = prev ? prev->allnext : allnodes;
  1418. for (; np != 0; np = np->allnext)
  1419. if (of_node_get(np))
  1420. break;
  1421. if (prev)
  1422. of_node_put(prev);
  1423. read_unlock(&devtree_lock);
  1424. return np;
  1425. }
  1426. EXPORT_SYMBOL(of_find_all_nodes);
  1427. /**
  1428. * of_get_parent - Get a node's parent if any
  1429. * @node: Node to get parent
  1430. *
  1431. * Returns a node pointer with refcount incremented, use
  1432. * of_node_put() on it when done.
  1433. */
  1434. struct device_node *of_get_parent(const struct device_node *node)
  1435. {
  1436. struct device_node *np;
  1437. if (!node)
  1438. return NULL;
  1439. read_lock(&devtree_lock);
  1440. np = of_node_get(node->parent);
  1441. read_unlock(&devtree_lock);
  1442. return np;
  1443. }
  1444. EXPORT_SYMBOL(of_get_parent);
  1445. /**
  1446. * of_get_next_child - Iterate a node childs
  1447. * @node: parent node
  1448. * @prev: previous child of the parent node, or NULL to get first
  1449. *
  1450. * Returns a node pointer with refcount incremented, use
  1451. * of_node_put() on it when done.
  1452. */
  1453. struct device_node *of_get_next_child(const struct device_node *node,
  1454. struct device_node *prev)
  1455. {
  1456. struct device_node *next;
  1457. read_lock(&devtree_lock);
  1458. next = prev ? prev->sibling : node->child;
  1459. for (; next != 0; next = next->sibling)
  1460. if (of_node_get(next))
  1461. break;
  1462. if (prev)
  1463. of_node_put(prev);
  1464. read_unlock(&devtree_lock);
  1465. return next;
  1466. }
  1467. EXPORT_SYMBOL(of_get_next_child);
  1468. /**
  1469. * of_node_get - Increment refcount of a node
  1470. * @node: Node to inc refcount, NULL is supported to
  1471. * simplify writing of callers
  1472. *
  1473. * Returns node.
  1474. */
  1475. struct device_node *of_node_get(struct device_node *node)
  1476. {
  1477. if (node)
  1478. kref_get(&node->kref);
  1479. return node;
  1480. }
  1481. EXPORT_SYMBOL(of_node_get);
  1482. static inline struct device_node * kref_to_device_node(struct kref *kref)
  1483. {
  1484. return container_of(kref, struct device_node, kref);
  1485. }
  1486. /**
  1487. * of_node_release - release a dynamically allocated node
  1488. * @kref: kref element of the node to be released
  1489. *
  1490. * In of_node_put() this function is passed to kref_put()
  1491. * as the destructor.
  1492. */
  1493. static void of_node_release(struct kref *kref)
  1494. {
  1495. struct device_node *node = kref_to_device_node(kref);
  1496. struct property *prop = node->properties;
  1497. if (!OF_IS_DYNAMIC(node))
  1498. return;
  1499. while (prop) {
  1500. struct property *next = prop->next;
  1501. kfree(prop->name);
  1502. kfree(prop->value);
  1503. kfree(prop);
  1504. prop = next;
  1505. if (!prop) {
  1506. prop = node->deadprops;
  1507. node->deadprops = NULL;
  1508. }
  1509. }
  1510. kfree(node->intrs);
  1511. kfree(node->full_name);
  1512. kfree(node->data);
  1513. kfree(node);
  1514. }
  1515. /**
  1516. * of_node_put - Decrement refcount of a node
  1517. * @node: Node to dec refcount, NULL is supported to
  1518. * simplify writing of callers
  1519. *
  1520. */
  1521. void of_node_put(struct device_node *node)
  1522. {
  1523. if (node)
  1524. kref_put(&node->kref, of_node_release);
  1525. }
  1526. EXPORT_SYMBOL(of_node_put);
  1527. /*
  1528. * Plug a device node into the tree and global list.
  1529. */
  1530. void of_attach_node(struct device_node *np)
  1531. {
  1532. write_lock(&devtree_lock);
  1533. np->sibling = np->parent->child;
  1534. np->allnext = allnodes;
  1535. np->parent->child = np;
  1536. allnodes = np;
  1537. write_unlock(&devtree_lock);
  1538. }
  1539. /*
  1540. * "Unplug" a node from the device tree. The caller must hold
  1541. * a reference to the node. The memory associated with the node
  1542. * is not freed until its refcount goes to zero.
  1543. */
  1544. void of_detach_node(const struct device_node *np)
  1545. {
  1546. struct device_node *parent;
  1547. write_lock(&devtree_lock);
  1548. parent = np->parent;
  1549. if (allnodes == np)
  1550. allnodes = np->allnext;
  1551. else {
  1552. struct device_node *prev;
  1553. for (prev = allnodes;
  1554. prev->allnext != np;
  1555. prev = prev->allnext)
  1556. ;
  1557. prev->allnext = np->allnext;
  1558. }
  1559. if (parent->child == np)
  1560. parent->child = np->sibling;
  1561. else {
  1562. struct device_node *prevsib;
  1563. for (prevsib = np->parent->child;
  1564. prevsib->sibling != np;
  1565. prevsib = prevsib->sibling)
  1566. ;
  1567. prevsib->sibling = np->sibling;
  1568. }
  1569. write_unlock(&devtree_lock);
  1570. }
  1571. #ifdef CONFIG_PPC_PSERIES
  1572. /*
  1573. * Fix up the uninitialized fields in a new device node:
  1574. * name, type, n_addrs, addrs, n_intrs, intrs, and pci-specific fields
  1575. *
  1576. * A lot of boot-time code is duplicated here, because functions such
  1577. * as finish_node_interrupts, interpret_pci_props, etc. cannot use the
  1578. * slab allocator.
  1579. *
  1580. * This should probably be split up into smaller chunks.
  1581. */
  1582. static int of_finish_dynamic_node(struct device_node *node)
  1583. {
  1584. struct device_node *parent = of_get_parent(node);
  1585. int err = 0;
  1586. phandle *ibm_phandle;
  1587. node->name = get_property(node, "name", NULL);
  1588. node->type = get_property(node, "device_type", NULL);
  1589. if (!parent) {
  1590. err = -ENODEV;
  1591. goto out;
  1592. }
  1593. /* We don't support that function on PowerMac, at least
  1594. * not yet
  1595. */
  1596. if (machine_is(powermac))
  1597. return -ENODEV;
  1598. /* fix up new node's linux_phandle field */
  1599. if ((ibm_phandle = (unsigned int *)get_property(node,
  1600. "ibm,phandle", NULL)))
  1601. node->linux_phandle = *ibm_phandle;
  1602. out:
  1603. of_node_put(parent);
  1604. return err;
  1605. }
  1606. static int prom_reconfig_notifier(struct notifier_block *nb,
  1607. unsigned long action, void *node)
  1608. {
  1609. int err;
  1610. switch (action) {
  1611. case PSERIES_RECONFIG_ADD:
  1612. err = of_finish_dynamic_node(node);
  1613. if (!err)
  1614. finish_node(node, NULL, 0);
  1615. if (err < 0) {
  1616. printk(KERN_ERR "finish_node returned %d\n", err);
  1617. err = NOTIFY_BAD;
  1618. }
  1619. break;
  1620. default:
  1621. err = NOTIFY_DONE;
  1622. break;
  1623. }
  1624. return err;
  1625. }
  1626. static struct notifier_block prom_reconfig_nb = {
  1627. .notifier_call = prom_reconfig_notifier,
  1628. .priority = 10, /* This one needs to run first */
  1629. };
  1630. static int __init prom_reconfig_setup(void)
  1631. {
  1632. return pSeries_reconfig_notifier_register(&prom_reconfig_nb);
  1633. }
  1634. __initcall(prom_reconfig_setup);
  1635. #endif
  1636. struct property *of_find_property(struct device_node *np, const char *name,
  1637. int *lenp)
  1638. {
  1639. struct property *pp;
  1640. read_lock(&devtree_lock);
  1641. for (pp = np->properties; pp != 0; pp = pp->next)
  1642. if (strcmp(pp->name, name) == 0) {
  1643. if (lenp != 0)
  1644. *lenp = pp->length;
  1645. break;
  1646. }
  1647. read_unlock(&devtree_lock);
  1648. return pp;
  1649. }
  1650. /*
  1651. * Find a property with a given name for a given node
  1652. * and return the value.
  1653. */
  1654. unsigned char *get_property(struct device_node *np, const char *name,
  1655. int *lenp)
  1656. {
  1657. struct property *pp = of_find_property(np,name,lenp);
  1658. return pp ? pp->value : NULL;
  1659. }
  1660. EXPORT_SYMBOL(get_property);
  1661. /*
  1662. * Add a property to a node
  1663. */
  1664. int prom_add_property(struct device_node* np, struct property* prop)
  1665. {
  1666. struct property **next;
  1667. prop->next = NULL;
  1668. write_lock(&devtree_lock);
  1669. next = &np->properties;
  1670. while (*next) {
  1671. if (strcmp(prop->name, (*next)->name) == 0) {
  1672. /* duplicate ! don't insert it */
  1673. write_unlock(&devtree_lock);
  1674. return -1;
  1675. }
  1676. next = &(*next)->next;
  1677. }
  1678. *next = prop;
  1679. write_unlock(&devtree_lock);
  1680. #ifdef CONFIG_PROC_DEVICETREE
  1681. /* try to add to proc as well if it was initialized */
  1682. if (np->pde)
  1683. proc_device_tree_add_prop(np->pde, prop);
  1684. #endif /* CONFIG_PROC_DEVICETREE */
  1685. return 0;
  1686. }
  1687. /*
  1688. * Remove a property from a node. Note that we don't actually
  1689. * remove it, since we have given out who-knows-how-many pointers
  1690. * to the data using get-property. Instead we just move the property
  1691. * to the "dead properties" list, so it won't be found any more.
  1692. */
  1693. int prom_remove_property(struct device_node *np, struct property *prop)
  1694. {
  1695. struct property **next;
  1696. int found = 0;
  1697. write_lock(&devtree_lock);
  1698. next = &np->properties;
  1699. while (*next) {
  1700. if (*next == prop) {
  1701. /* found the node */
  1702. *next = prop->next;
  1703. prop->next = np->deadprops;
  1704. np->deadprops = prop;
  1705. found = 1;
  1706. break;
  1707. }
  1708. next = &(*next)->next;
  1709. }
  1710. write_unlock(&devtree_lock);
  1711. if (!found)
  1712. return -ENODEV;
  1713. #ifdef CONFIG_PROC_DEVICETREE
  1714. /* try to remove the proc node as well */
  1715. if (np->pde)
  1716. proc_device_tree_remove_prop(np->pde, prop);
  1717. #endif /* CONFIG_PROC_DEVICETREE */
  1718. return 0;
  1719. }
  1720. /*
  1721. * Update a property in a node. Note that we don't actually
  1722. * remove it, since we have given out who-knows-how-many pointers
  1723. * to the data using get-property. Instead we just move the property
  1724. * to the "dead properties" list, and add the new property to the
  1725. * property list
  1726. */
  1727. int prom_update_property(struct device_node *np,
  1728. struct property *newprop,
  1729. struct property *oldprop)
  1730. {
  1731. struct property **next;
  1732. int found = 0;
  1733. write_lock(&devtree_lock);
  1734. next = &np->properties;
  1735. while (*next) {
  1736. if (*next == oldprop) {
  1737. /* found the node */
  1738. newprop->next = oldprop->next;
  1739. *next = newprop;
  1740. oldprop->next = np->deadprops;
  1741. np->deadprops = oldprop;
  1742. found = 1;
  1743. break;
  1744. }
  1745. next = &(*next)->next;
  1746. }
  1747. write_unlock(&devtree_lock);
  1748. if (!found)
  1749. return -ENODEV;
  1750. #ifdef CONFIG_PROC_DEVICETREE
  1751. /* try to add to proc as well if it was initialized */
  1752. if (np->pde)
  1753. proc_device_tree_update_prop(np->pde, newprop, oldprop);
  1754. #endif /* CONFIG_PROC_DEVICETREE */
  1755. return 0;
  1756. }
  1757. #ifdef CONFIG_KEXEC
  1758. /* We may have allocated the flat device tree inside the crash kernel region
  1759. * in prom_init. If so we need to move it out into regular memory. */
  1760. void kdump_move_device_tree(void)
  1761. {
  1762. unsigned long start, end;
  1763. struct boot_param_header *new;
  1764. start = __pa((unsigned long)initial_boot_params);
  1765. end = start + initial_boot_params->totalsize;
  1766. if (end < crashk_res.start || start > crashk_res.end)
  1767. return;
  1768. new = (struct boot_param_header*)
  1769. __va(lmb_alloc(initial_boot_params->totalsize, PAGE_SIZE));
  1770. memcpy(new, initial_boot_params, initial_boot_params->totalsize);
  1771. initial_boot_params = new;
  1772. DBG("Flat device tree blob moved to %p\n", initial_boot_params);
  1773. /* XXX should we unreserve the old DT? */
  1774. }
  1775. #endif /* CONFIG_KEXEC */