prom_64.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  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. * Adapted for sparc64 by David S. Miller davem@davemloft.net
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License
  14. * as published by the Free Software Foundation; either version
  15. * 2 of the License, or (at your option) any later version.
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/types.h>
  19. #include <linux/string.h>
  20. #include <linux/mm.h>
  21. #include <linux/module.h>
  22. #include <linux/lmb.h>
  23. #include <linux/of_device.h>
  24. #include <asm/prom.h>
  25. #include <asm/oplib.h>
  26. #include <asm/irq.h>
  27. #include <asm/asi.h>
  28. #include <asm/upa.h>
  29. #include <asm/smp.h>
  30. #include "prom.h"
  31. static unsigned int prom_early_allocated __initdata;
  32. void * __init prom_early_alloc(unsigned long size)
  33. {
  34. unsigned long paddr = lmb_alloc(size, SMP_CACHE_BYTES);
  35. void *ret;
  36. if (!paddr) {
  37. prom_printf("prom_early_alloc(%lu) failed\n");
  38. prom_halt();
  39. }
  40. ret = __va(paddr);
  41. memset(ret, 0, size);
  42. prom_early_allocated += size;
  43. return ret;
  44. }
  45. static int is_root_node(const struct device_node *dp)
  46. {
  47. if (!dp)
  48. return 0;
  49. return (dp->parent == NULL);
  50. }
  51. /* The following routines deal with the black magic of fully naming a
  52. * node.
  53. *
  54. * Certain well known named nodes are just the simple name string.
  55. *
  56. * Actual devices have an address specifier appended to the base name
  57. * string, like this "foo@addr". The "addr" can be in any number of
  58. * formats, and the platform plus the type of the node determine the
  59. * format and how it is constructed.
  60. *
  61. * For children of the ROOT node, the naming convention is fixed and
  62. * determined by whether this is a sun4u or sun4v system.
  63. *
  64. * For children of other nodes, it is bus type specific. So
  65. * we walk up the tree until we discover a "device_type" property
  66. * we recognize and we go from there.
  67. *
  68. * As an example, the boot device on my workstation has a full path:
  69. *
  70. * /pci@1e,600000/ide@d/disk@0,0:c
  71. */
  72. static void __init sun4v_path_component(struct device_node *dp, char *tmp_buf)
  73. {
  74. struct linux_prom64_registers *regs;
  75. struct property *rprop;
  76. u32 high_bits, low_bits, type;
  77. rprop = of_find_property(dp, "reg", NULL);
  78. if (!rprop)
  79. return;
  80. regs = rprop->value;
  81. if (!is_root_node(dp->parent)) {
  82. sprintf(tmp_buf, "%s@%x,%x",
  83. dp->name,
  84. (unsigned int) (regs->phys_addr >> 32UL),
  85. (unsigned int) (regs->phys_addr & 0xffffffffUL));
  86. return;
  87. }
  88. type = regs->phys_addr >> 60UL;
  89. high_bits = (regs->phys_addr >> 32UL) & 0x0fffffffUL;
  90. low_bits = (regs->phys_addr & 0xffffffffUL);
  91. if (type == 0 || type == 8) {
  92. const char *prefix = (type == 0) ? "m" : "i";
  93. if (low_bits)
  94. sprintf(tmp_buf, "%s@%s%x,%x",
  95. dp->name, prefix,
  96. high_bits, low_bits);
  97. else
  98. sprintf(tmp_buf, "%s@%s%x",
  99. dp->name,
  100. prefix,
  101. high_bits);
  102. } else if (type == 12) {
  103. sprintf(tmp_buf, "%s@%x",
  104. dp->name, high_bits);
  105. }
  106. }
  107. static void __init sun4u_path_component(struct device_node *dp, char *tmp_buf)
  108. {
  109. struct linux_prom64_registers *regs;
  110. struct property *prop;
  111. prop = of_find_property(dp, "reg", NULL);
  112. if (!prop)
  113. return;
  114. regs = prop->value;
  115. if (!is_root_node(dp->parent)) {
  116. sprintf(tmp_buf, "%s@%x,%x",
  117. dp->name,
  118. (unsigned int) (regs->phys_addr >> 32UL),
  119. (unsigned int) (regs->phys_addr & 0xffffffffUL));
  120. return;
  121. }
  122. prop = of_find_property(dp, "upa-portid", NULL);
  123. if (!prop)
  124. prop = of_find_property(dp, "portid", NULL);
  125. if (prop) {
  126. unsigned long mask = 0xffffffffUL;
  127. if (tlb_type >= cheetah)
  128. mask = 0x7fffff;
  129. sprintf(tmp_buf, "%s@%x,%x",
  130. dp->name,
  131. *(u32 *)prop->value,
  132. (unsigned int) (regs->phys_addr & mask));
  133. }
  134. }
  135. /* "name@slot,offset" */
  136. static void __init sbus_path_component(struct device_node *dp, char *tmp_buf)
  137. {
  138. struct linux_prom_registers *regs;
  139. struct property *prop;
  140. prop = of_find_property(dp, "reg", NULL);
  141. if (!prop)
  142. return;
  143. regs = prop->value;
  144. sprintf(tmp_buf, "%s@%x,%x",
  145. dp->name,
  146. regs->which_io,
  147. regs->phys_addr);
  148. }
  149. /* "name@devnum[,func]" */
  150. static void __init pci_path_component(struct device_node *dp, char *tmp_buf)
  151. {
  152. struct linux_prom_pci_registers *regs;
  153. struct property *prop;
  154. unsigned int devfn;
  155. prop = of_find_property(dp, "reg", NULL);
  156. if (!prop)
  157. return;
  158. regs = prop->value;
  159. devfn = (regs->phys_hi >> 8) & 0xff;
  160. if (devfn & 0x07) {
  161. sprintf(tmp_buf, "%s@%x,%x",
  162. dp->name,
  163. devfn >> 3,
  164. devfn & 0x07);
  165. } else {
  166. sprintf(tmp_buf, "%s@%x",
  167. dp->name,
  168. devfn >> 3);
  169. }
  170. }
  171. /* "name@UPA_PORTID,offset" */
  172. static void __init upa_path_component(struct device_node *dp, char *tmp_buf)
  173. {
  174. struct linux_prom64_registers *regs;
  175. struct property *prop;
  176. prop = of_find_property(dp, "reg", NULL);
  177. if (!prop)
  178. return;
  179. regs = prop->value;
  180. prop = of_find_property(dp, "upa-portid", NULL);
  181. if (!prop)
  182. return;
  183. sprintf(tmp_buf, "%s@%x,%x",
  184. dp->name,
  185. *(u32 *) prop->value,
  186. (unsigned int) (regs->phys_addr & 0xffffffffUL));
  187. }
  188. /* "name@reg" */
  189. static void __init vdev_path_component(struct device_node *dp, char *tmp_buf)
  190. {
  191. struct property *prop;
  192. u32 *regs;
  193. prop = of_find_property(dp, "reg", NULL);
  194. if (!prop)
  195. return;
  196. regs = prop->value;
  197. sprintf(tmp_buf, "%s@%x", dp->name, *regs);
  198. }
  199. /* "name@addrhi,addrlo" */
  200. static void __init ebus_path_component(struct device_node *dp, char *tmp_buf)
  201. {
  202. struct linux_prom64_registers *regs;
  203. struct property *prop;
  204. prop = of_find_property(dp, "reg", NULL);
  205. if (!prop)
  206. return;
  207. regs = prop->value;
  208. sprintf(tmp_buf, "%s@%x,%x",
  209. dp->name,
  210. (unsigned int) (regs->phys_addr >> 32UL),
  211. (unsigned int) (regs->phys_addr & 0xffffffffUL));
  212. }
  213. /* "name@bus,addr" */
  214. static void __init i2c_path_component(struct device_node *dp, char *tmp_buf)
  215. {
  216. struct property *prop;
  217. u32 *regs;
  218. prop = of_find_property(dp, "reg", NULL);
  219. if (!prop)
  220. return;
  221. regs = prop->value;
  222. /* This actually isn't right... should look at the #address-cells
  223. * property of the i2c bus node etc. etc.
  224. */
  225. sprintf(tmp_buf, "%s@%x,%x",
  226. dp->name, regs[0], regs[1]);
  227. }
  228. /* "name@reg0[,reg1]" */
  229. static void __init usb_path_component(struct device_node *dp, char *tmp_buf)
  230. {
  231. struct property *prop;
  232. u32 *regs;
  233. prop = of_find_property(dp, "reg", NULL);
  234. if (!prop)
  235. return;
  236. regs = prop->value;
  237. if (prop->length == sizeof(u32) || regs[1] == 1) {
  238. sprintf(tmp_buf, "%s@%x",
  239. dp->name, regs[0]);
  240. } else {
  241. sprintf(tmp_buf, "%s@%x,%x",
  242. dp->name, regs[0], regs[1]);
  243. }
  244. }
  245. /* "name@reg0reg1[,reg2reg3]" */
  246. static void __init ieee1394_path_component(struct device_node *dp, char *tmp_buf)
  247. {
  248. struct property *prop;
  249. u32 *regs;
  250. prop = of_find_property(dp, "reg", NULL);
  251. if (!prop)
  252. return;
  253. regs = prop->value;
  254. if (regs[2] || regs[3]) {
  255. sprintf(tmp_buf, "%s@%08x%08x,%04x%08x",
  256. dp->name, regs[0], regs[1], regs[2], regs[3]);
  257. } else {
  258. sprintf(tmp_buf, "%s@%08x%08x",
  259. dp->name, regs[0], regs[1]);
  260. }
  261. }
  262. static void __init __build_path_component(struct device_node *dp, char *tmp_buf)
  263. {
  264. struct device_node *parent = dp->parent;
  265. if (parent != NULL) {
  266. if (!strcmp(parent->type, "pci") ||
  267. !strcmp(parent->type, "pciex")) {
  268. pci_path_component(dp, tmp_buf);
  269. return;
  270. }
  271. if (!strcmp(parent->type, "sbus")) {
  272. sbus_path_component(dp, tmp_buf);
  273. return;
  274. }
  275. if (!strcmp(parent->type, "upa")) {
  276. upa_path_component(dp, tmp_buf);
  277. return;
  278. }
  279. if (!strcmp(parent->type, "ebus")) {
  280. ebus_path_component(dp, tmp_buf);
  281. return;
  282. }
  283. if (!strcmp(parent->name, "usb") ||
  284. !strcmp(parent->name, "hub")) {
  285. usb_path_component(dp, tmp_buf);
  286. return;
  287. }
  288. if (!strcmp(parent->type, "i2c")) {
  289. i2c_path_component(dp, tmp_buf);
  290. return;
  291. }
  292. if (!strcmp(parent->type, "firewire")) {
  293. ieee1394_path_component(dp, tmp_buf);
  294. return;
  295. }
  296. if (!strcmp(parent->type, "virtual-devices")) {
  297. vdev_path_component(dp, tmp_buf);
  298. return;
  299. }
  300. /* "isa" is handled with platform naming */
  301. }
  302. /* Use platform naming convention. */
  303. if (tlb_type == hypervisor) {
  304. sun4v_path_component(dp, tmp_buf);
  305. return;
  306. } else {
  307. sun4u_path_component(dp, tmp_buf);
  308. }
  309. }
  310. static char * __init build_path_component(struct device_node *dp)
  311. {
  312. char tmp_buf[64], *n;
  313. tmp_buf[0] = '\0';
  314. __build_path_component(dp, tmp_buf);
  315. if (tmp_buf[0] == '\0')
  316. strcpy(tmp_buf, dp->name);
  317. n = prom_early_alloc(strlen(tmp_buf) + 1);
  318. strcpy(n, tmp_buf);
  319. return n;
  320. }
  321. static char * __init build_full_name(struct device_node *dp)
  322. {
  323. int len, ourlen, plen;
  324. char *n;
  325. plen = strlen(dp->parent->full_name);
  326. ourlen = strlen(dp->path_component_name);
  327. len = ourlen + plen + 2;
  328. n = prom_early_alloc(len);
  329. strcpy(n, dp->parent->full_name);
  330. if (!is_root_node(dp->parent)) {
  331. strcpy(n + plen, "/");
  332. plen++;
  333. }
  334. strcpy(n + plen, dp->path_component_name);
  335. return n;
  336. }
  337. static struct property * __init build_one_prop(phandle node, char *prev, char *special_name, void *special_val, int special_len)
  338. {
  339. static struct property *tmp = NULL;
  340. struct property *p;
  341. if (tmp) {
  342. p = tmp;
  343. memset(p, 0, sizeof(*p) + 32);
  344. tmp = NULL;
  345. } else {
  346. p = prom_early_alloc(sizeof(struct property) + 32);
  347. p->unique_id = prom_unique_id++;
  348. }
  349. p->name = (char *) (p + 1);
  350. if (special_name) {
  351. strcpy(p->name, special_name);
  352. p->length = special_len;
  353. p->value = prom_early_alloc(special_len);
  354. memcpy(p->value, special_val, special_len);
  355. } else {
  356. if (prev == NULL) {
  357. prom_firstprop(node, p->name);
  358. } else {
  359. prom_nextprop(node, prev, p->name);
  360. }
  361. if (strlen(p->name) == 0) {
  362. tmp = p;
  363. return NULL;
  364. }
  365. p->length = prom_getproplen(node, p->name);
  366. if (p->length <= 0) {
  367. p->length = 0;
  368. } else {
  369. p->value = prom_early_alloc(p->length + 1);
  370. prom_getproperty(node, p->name, p->value, p->length);
  371. ((unsigned char *)p->value)[p->length] = '\0';
  372. }
  373. }
  374. return p;
  375. }
  376. static struct property * __init build_prop_list(phandle node)
  377. {
  378. struct property *head, *tail;
  379. head = tail = build_one_prop(node, NULL,
  380. ".node", &node, sizeof(node));
  381. tail->next = build_one_prop(node, NULL, NULL, NULL, 0);
  382. tail = tail->next;
  383. while(tail) {
  384. tail->next = build_one_prop(node, tail->name,
  385. NULL, NULL, 0);
  386. tail = tail->next;
  387. }
  388. return head;
  389. }
  390. static char * __init get_one_property(phandle node, const char *name)
  391. {
  392. char *buf = "<NULL>";
  393. int len;
  394. len = prom_getproplen(node, name);
  395. if (len > 0) {
  396. buf = prom_early_alloc(len);
  397. prom_getproperty(node, name, buf, len);
  398. }
  399. return buf;
  400. }
  401. static struct device_node * __init create_node(phandle node, struct device_node *parent)
  402. {
  403. struct device_node *dp;
  404. if (!node)
  405. return NULL;
  406. dp = prom_early_alloc(sizeof(*dp));
  407. dp->unique_id = prom_unique_id++;
  408. dp->parent = parent;
  409. kref_init(&dp->kref);
  410. dp->name = get_one_property(node, "name");
  411. dp->type = get_one_property(node, "device_type");
  412. dp->node = node;
  413. dp->properties = build_prop_list(node);
  414. irq_trans_init(dp);
  415. return dp;
  416. }
  417. static struct device_node * __init build_tree(struct device_node *parent, phandle node, struct device_node ***nextp)
  418. {
  419. struct device_node *ret = NULL, *prev_sibling = NULL;
  420. struct device_node *dp;
  421. while (1) {
  422. dp = create_node(node, parent);
  423. if (!dp)
  424. break;
  425. if (prev_sibling)
  426. prev_sibling->sibling = dp;
  427. if (!ret)
  428. ret = dp;
  429. prev_sibling = dp;
  430. *(*nextp) = dp;
  431. *nextp = &dp->allnext;
  432. dp->path_component_name = build_path_component(dp);
  433. dp->full_name = build_full_name(dp);
  434. dp->child = build_tree(dp, prom_getchild(node), nextp);
  435. node = prom_getsibling(node);
  436. }
  437. return ret;
  438. }
  439. static const char *get_mid_prop(void)
  440. {
  441. return (tlb_type == spitfire ? "upa-portid" : "portid");
  442. }
  443. struct device_node *of_find_node_by_cpuid(int cpuid)
  444. {
  445. struct device_node *dp;
  446. const char *mid_prop = get_mid_prop();
  447. for_each_node_by_type(dp, "cpu") {
  448. int id = of_getintprop_default(dp, mid_prop, -1);
  449. const char *this_mid_prop = mid_prop;
  450. if (id < 0) {
  451. this_mid_prop = "cpuid";
  452. id = of_getintprop_default(dp, this_mid_prop, -1);
  453. }
  454. if (id < 0) {
  455. prom_printf("OF: Serious problem, cpu lacks "
  456. "%s property", this_mid_prop);
  457. prom_halt();
  458. }
  459. if (cpuid == id)
  460. return dp;
  461. }
  462. return NULL;
  463. }
  464. static void __init of_fill_in_cpu_data(void)
  465. {
  466. struct device_node *dp;
  467. const char *mid_prop = get_mid_prop();
  468. ncpus_probed = 0;
  469. for_each_node_by_type(dp, "cpu") {
  470. int cpuid = of_getintprop_default(dp, mid_prop, -1);
  471. const char *this_mid_prop = mid_prop;
  472. struct device_node *portid_parent;
  473. int portid = -1;
  474. portid_parent = NULL;
  475. if (cpuid < 0) {
  476. this_mid_prop = "cpuid";
  477. cpuid = of_getintprop_default(dp, this_mid_prop, -1);
  478. if (cpuid >= 0) {
  479. int limit = 2;
  480. portid_parent = dp;
  481. while (limit--) {
  482. portid_parent = portid_parent->parent;
  483. if (!portid_parent)
  484. break;
  485. portid = of_getintprop_default(portid_parent,
  486. "portid", -1);
  487. if (portid >= 0)
  488. break;
  489. }
  490. }
  491. }
  492. if (cpuid < 0) {
  493. prom_printf("OF: Serious problem, cpu lacks "
  494. "%s property", this_mid_prop);
  495. prom_halt();
  496. }
  497. ncpus_probed++;
  498. #ifdef CONFIG_SMP
  499. if (cpuid >= NR_CPUS) {
  500. printk(KERN_WARNING "Ignoring CPU %d which is "
  501. ">= NR_CPUS (%d)\n",
  502. cpuid, NR_CPUS);
  503. continue;
  504. }
  505. #else
  506. /* On uniprocessor we only want the values for the
  507. * real physical cpu the kernel booted onto, however
  508. * cpu_data() only has one entry at index 0.
  509. */
  510. if (cpuid != real_hard_smp_processor_id())
  511. continue;
  512. cpuid = 0;
  513. #endif
  514. cpu_data(cpuid).clock_tick =
  515. of_getintprop_default(dp, "clock-frequency", 0);
  516. if (portid_parent) {
  517. cpu_data(cpuid).dcache_size =
  518. of_getintprop_default(dp, "l1-dcache-size",
  519. 16 * 1024);
  520. cpu_data(cpuid).dcache_line_size =
  521. of_getintprop_default(dp, "l1-dcache-line-size",
  522. 32);
  523. cpu_data(cpuid).icache_size =
  524. of_getintprop_default(dp, "l1-icache-size",
  525. 8 * 1024);
  526. cpu_data(cpuid).icache_line_size =
  527. of_getintprop_default(dp, "l1-icache-line-size",
  528. 32);
  529. cpu_data(cpuid).ecache_size =
  530. of_getintprop_default(dp, "l2-cache-size", 0);
  531. cpu_data(cpuid).ecache_line_size =
  532. of_getintprop_default(dp, "l2-cache-line-size", 0);
  533. if (!cpu_data(cpuid).ecache_size ||
  534. !cpu_data(cpuid).ecache_line_size) {
  535. cpu_data(cpuid).ecache_size =
  536. of_getintprop_default(portid_parent,
  537. "l2-cache-size",
  538. (4 * 1024 * 1024));
  539. cpu_data(cpuid).ecache_line_size =
  540. of_getintprop_default(portid_parent,
  541. "l2-cache-line-size", 64);
  542. }
  543. cpu_data(cpuid).core_id = portid + 1;
  544. cpu_data(cpuid).proc_id = portid;
  545. #ifdef CONFIG_SMP
  546. sparc64_multi_core = 1;
  547. #endif
  548. } else {
  549. cpu_data(cpuid).dcache_size =
  550. of_getintprop_default(dp, "dcache-size", 16 * 1024);
  551. cpu_data(cpuid).dcache_line_size =
  552. of_getintprop_default(dp, "dcache-line-size", 32);
  553. cpu_data(cpuid).icache_size =
  554. of_getintprop_default(dp, "icache-size", 16 * 1024);
  555. cpu_data(cpuid).icache_line_size =
  556. of_getintprop_default(dp, "icache-line-size", 32);
  557. cpu_data(cpuid).ecache_size =
  558. of_getintprop_default(dp, "ecache-size",
  559. (4 * 1024 * 1024));
  560. cpu_data(cpuid).ecache_line_size =
  561. of_getintprop_default(dp, "ecache-line-size", 64);
  562. cpu_data(cpuid).core_id = 0;
  563. cpu_data(cpuid).proc_id = -1;
  564. }
  565. #ifdef CONFIG_SMP
  566. cpu_set(cpuid, cpu_present_map);
  567. cpu_set(cpuid, cpu_possible_map);
  568. #endif
  569. }
  570. smp_fill_in_sib_core_maps();
  571. }
  572. struct device_node *of_console_device;
  573. EXPORT_SYMBOL(of_console_device);
  574. char *of_console_path;
  575. EXPORT_SYMBOL(of_console_path);
  576. char *of_console_options;
  577. EXPORT_SYMBOL(of_console_options);
  578. static void __init of_console_init(void)
  579. {
  580. char *msg = "OF stdout device is: %s\n";
  581. struct device_node *dp;
  582. const char *type;
  583. phandle node;
  584. of_console_path = prom_early_alloc(256);
  585. if (prom_ihandle2path(prom_stdout, of_console_path, 256) < 0) {
  586. prom_printf("Cannot obtain path of stdout.\n");
  587. prom_halt();
  588. }
  589. of_console_options = strrchr(of_console_path, ':');
  590. if (of_console_options) {
  591. of_console_options++;
  592. if (*of_console_options == '\0')
  593. of_console_options = NULL;
  594. }
  595. node = prom_inst2pkg(prom_stdout);
  596. if (!node) {
  597. prom_printf("Cannot resolve stdout node from "
  598. "instance %08x.\n", prom_stdout);
  599. prom_halt();
  600. }
  601. dp = of_find_node_by_phandle(node);
  602. type = of_get_property(dp, "device_type", NULL);
  603. if (!type) {
  604. prom_printf("Console stdout lacks device_type property.\n");
  605. prom_halt();
  606. }
  607. if (strcmp(type, "display") && strcmp(type, "serial")) {
  608. prom_printf("Console device_type is neither display "
  609. "nor serial.\n");
  610. prom_halt();
  611. }
  612. of_console_device = dp;
  613. printk(msg, of_console_path);
  614. }
  615. void __init prom_build_devicetree(void)
  616. {
  617. struct device_node **nextp;
  618. allnodes = create_node(prom_root_node, NULL);
  619. allnodes->path_component_name = "";
  620. allnodes->full_name = "/";
  621. nextp = &allnodes->allnext;
  622. allnodes->child = build_tree(allnodes,
  623. prom_getchild(allnodes->node),
  624. &nextp);
  625. of_console_init();
  626. printk("PROM: Built device tree with %u bytes of memory.\n",
  627. prom_early_allocated);
  628. if (tlb_type != hypervisor)
  629. of_fill_in_cpu_data();
  630. }