dt.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. /*
  2. * Copyright (c) 2005-2006 Michael Ellerman, IBM Corporation
  3. *
  4. * Description:
  5. * This file contains all the routines to build a flattened device
  6. * tree for a legacy iSeries machine.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version
  11. * 2 of the License, or (at your option) any later version.
  12. */
  13. #undef DEBUG
  14. #include <linux/types.h>
  15. #include <linux/init.h>
  16. #include <linux/pci.h>
  17. #include <linux/pci_regs.h>
  18. #include <linux/pci_ids.h>
  19. #include <linux/threads.h>
  20. #include <linux/bitops.h>
  21. #include <linux/string.h>
  22. #include <linux/kernel.h>
  23. #include <linux/if_ether.h> /* ETH_ALEN */
  24. #include <asm/machdep.h>
  25. #include <asm/prom.h>
  26. #include <asm/lppaca.h>
  27. #include <asm/page.h>
  28. #include <asm/cputable.h>
  29. #include <asm/abs_addr.h>
  30. #include <asm/system.h>
  31. #include <asm/iseries/hv_types.h>
  32. #include <asm/iseries/hv_lp_config.h>
  33. #include <asm/iseries/hv_call_xm.h>
  34. #include <asm/iseries/it_exp_vpd_panel.h>
  35. #include <asm/udbg.h>
  36. #include "processor_vpd.h"
  37. #include "call_hpt.h"
  38. #include "call_pci.h"
  39. #include "pci.h"
  40. #ifdef DEBUG
  41. #define DBG(fmt...) udbg_printf(fmt)
  42. #else
  43. #define DBG(fmt...)
  44. #endif
  45. extern char __dt_strings_start[];
  46. extern char __dt_strings_end[];
  47. struct blob {
  48. unsigned char data[PAGE_SIZE * 2];
  49. unsigned long next;
  50. };
  51. struct iseries_flat_dt {
  52. struct boot_param_header header;
  53. u64 reserve_map[2];
  54. struct blob *dt;
  55. };
  56. static struct iseries_flat_dt *iseries_dt;
  57. static struct iseries_flat_dt * __init dt_init(void)
  58. {
  59. struct iseries_flat_dt *dt;
  60. unsigned long str_len;
  61. str_len = __dt_strings_end - __dt_strings_start;
  62. dt = (struct iseries_flat_dt *)ALIGN(klimit, 8);
  63. dt->header.off_mem_rsvmap =
  64. offsetof(struct iseries_flat_dt, reserve_map);
  65. dt->header.off_dt_strings = ALIGN(sizeof(*dt), 8);
  66. dt->header.off_dt_struct = dt->header.off_dt_strings
  67. + ALIGN(str_len, 8);
  68. dt->dt = (struct blob *)((unsigned long)dt + dt->header.off_dt_struct);
  69. klimit = ALIGN((unsigned long)(dt->dt) + sizeof(struct blob), 8);
  70. dt->header.totalsize = klimit - (unsigned long)dt;
  71. dt->header.dt_strings_size = str_len;
  72. /* There is no notion of hardware cpu id on iSeries */
  73. dt->header.boot_cpuid_phys = smp_processor_id();
  74. dt->dt->next = (unsigned long)&dt->dt->data;
  75. memcpy((char *)dt + dt->header.off_dt_strings, __dt_strings_start,
  76. str_len);
  77. dt->header.magic = OF_DT_HEADER;
  78. dt->header.version = 0x10;
  79. dt->header.last_comp_version = 0x10;
  80. dt->reserve_map[0] = 0;
  81. dt->reserve_map[1] = 0;
  82. return dt;
  83. }
  84. static void __init dt_check_blob(struct blob *b)
  85. {
  86. if (b->next >= (unsigned long)&b->next) {
  87. DBG("Ran out of space in flat device tree blob!\n");
  88. BUG();
  89. }
  90. }
  91. static void __init dt_push_u32(struct iseries_flat_dt *dt, u32 value)
  92. {
  93. *((u32*)dt->dt->next) = value;
  94. dt->dt->next += sizeof(u32);
  95. dt_check_blob(dt->dt);
  96. }
  97. #ifdef notyet
  98. static void __init dt_push_u64(struct iseries_flat_dt *dt, u64 value)
  99. {
  100. *((u64*)dt->dt->next) = value;
  101. dt->dt->next += sizeof(u64);
  102. dt_check_blob(dt->dt);
  103. }
  104. #endif
  105. static unsigned long __init dt_push_bytes(struct blob *blob, char *data, int len)
  106. {
  107. unsigned long start = blob->next - (unsigned long)blob->data;
  108. memcpy((char *)blob->next, data, len);
  109. blob->next = _ALIGN(blob->next + len, 4);
  110. dt_check_blob(blob);
  111. return start;
  112. }
  113. static void __init dt_start_node(struct iseries_flat_dt *dt, char *name)
  114. {
  115. dt_push_u32(dt, OF_DT_BEGIN_NODE);
  116. dt_push_bytes(dt->dt, name, strlen(name) + 1);
  117. }
  118. #define dt_end_node(dt) dt_push_u32(dt, OF_DT_END_NODE)
  119. static void __init dt_prop(struct iseries_flat_dt *dt, char *name,
  120. char *data, int len)
  121. {
  122. unsigned long offset;
  123. dt_push_u32(dt, OF_DT_PROP);
  124. /* Length of the data */
  125. dt_push_u32(dt, len);
  126. offset = name - __dt_strings_start;
  127. /* The offset of the properties name in the string blob. */
  128. dt_push_u32(dt, (u32)offset);
  129. /* The actual data. */
  130. dt_push_bytes(dt->dt, data, len);
  131. }
  132. static void __init dt_prop_str(struct iseries_flat_dt *dt, char *name,
  133. char *data)
  134. {
  135. dt_prop(dt, name, data, strlen(data) + 1); /* + 1 for NULL */
  136. }
  137. static void __init dt_prop_u32(struct iseries_flat_dt *dt, char *name, u32 data)
  138. {
  139. dt_prop(dt, name, (char *)&data, sizeof(u32));
  140. }
  141. static void __init dt_prop_u64(struct iseries_flat_dt *dt, char *name, u64 data)
  142. {
  143. dt_prop(dt, name, (char *)&data, sizeof(u64));
  144. }
  145. static void __init dt_prop_u64_list(struct iseries_flat_dt *dt, char *name,
  146. u64 *data, int n)
  147. {
  148. dt_prop(dt, name, (char *)data, sizeof(u64) * n);
  149. }
  150. static void __init dt_prop_u32_list(struct iseries_flat_dt *dt, char *name,
  151. u32 *data, int n)
  152. {
  153. dt_prop(dt, name, (char *)data, sizeof(u32) * n);
  154. }
  155. #ifdef notyet
  156. static void __init dt_prop_empty(struct iseries_flat_dt *dt, char *name)
  157. {
  158. dt_prop(dt, name, NULL, 0);
  159. }
  160. #endif
  161. static void __init dt_cpus(struct iseries_flat_dt *dt)
  162. {
  163. unsigned char buf[32];
  164. unsigned char *p;
  165. unsigned int i, index;
  166. struct IoHriProcessorVpd *d;
  167. u32 pft_size[2];
  168. /* yuck */
  169. snprintf(buf, 32, "PowerPC,%s", cur_cpu_spec->cpu_name);
  170. p = strchr(buf, ' ');
  171. if (!p) p = buf + strlen(buf);
  172. dt_start_node(dt, "cpus");
  173. dt_prop_u32(dt, "#address-cells", 1);
  174. dt_prop_u32(dt, "#size-cells", 0);
  175. pft_size[0] = 0; /* NUMA CEC cookie, 0 for non NUMA */
  176. pft_size[1] = __ilog2(HvCallHpt_getHptPages() * HW_PAGE_SIZE);
  177. for (i = 0; i < NR_CPUS; i++) {
  178. if (lppaca[i].dyn_proc_status >= 2)
  179. continue;
  180. snprintf(p, 32 - (p - buf), "@%d", i);
  181. dt_start_node(dt, buf);
  182. dt_prop_str(dt, "device_type", "cpu");
  183. index = lppaca[i].dyn_hv_phys_proc_index;
  184. d = &xIoHriProcessorVpd[index];
  185. dt_prop_u32(dt, "i-cache-size", d->xInstCacheSize * 1024);
  186. dt_prop_u32(dt, "i-cache-line-size", d->xInstCacheOperandSize);
  187. dt_prop_u32(dt, "d-cache-size", d->xDataL1CacheSizeKB * 1024);
  188. dt_prop_u32(dt, "d-cache-line-size", d->xDataCacheOperandSize);
  189. /* magic conversions to Hz copied from old code */
  190. dt_prop_u32(dt, "clock-frequency",
  191. ((1UL << 34) * 1000000) / d->xProcFreq);
  192. dt_prop_u32(dt, "timebase-frequency",
  193. ((1UL << 32) * 1000000) / d->xTimeBaseFreq);
  194. dt_prop_u32(dt, "reg", i);
  195. dt_prop_u32_list(dt, "ibm,pft-size", pft_size, 2);
  196. dt_end_node(dt);
  197. }
  198. dt_end_node(dt);
  199. }
  200. static void __init dt_model(struct iseries_flat_dt *dt)
  201. {
  202. char buf[16] = "IBM,";
  203. /* "IBM," + mfgId[2:3] + systemSerial[1:5] */
  204. strne2a(buf + 4, xItExtVpdPanel.mfgID + 2, 2);
  205. strne2a(buf + 6, xItExtVpdPanel.systemSerial + 1, 5);
  206. buf[11] = '\0';
  207. dt_prop_str(dt, "system-id", buf);
  208. /* "IBM," + machineType[0:4] */
  209. strne2a(buf + 4, xItExtVpdPanel.machineType, 4);
  210. buf[8] = '\0';
  211. dt_prop_str(dt, "model", buf);
  212. dt_prop_str(dt, "compatible", "IBM,iSeries");
  213. }
  214. static void __init dt_vdevices(struct iseries_flat_dt *dt)
  215. {
  216. u32 reg = 0;
  217. HvLpIndexMap vlan_map;
  218. int i;
  219. char buf[32];
  220. dt_start_node(dt, "vdevice");
  221. dt_prop_str(dt, "device_type", "vdevice");
  222. dt_prop_str(dt, "compatible", "IBM,iSeries-vdevice");
  223. dt_prop_u32(dt, "#address-cells", 1);
  224. dt_prop_u32(dt, "#size-cells", 0);
  225. snprintf(buf, sizeof(buf), "vty@%08x", reg);
  226. dt_start_node(dt, buf);
  227. dt_prop_str(dt, "device_type", "serial");
  228. dt_prop_u32(dt, "reg", reg);
  229. dt_end_node(dt);
  230. reg++;
  231. snprintf(buf, sizeof(buf), "v-scsi@%08x", reg);
  232. dt_start_node(dt, buf);
  233. dt_prop_str(dt, "device_type", "vscsi");
  234. dt_prop_str(dt, "compatible", "IBM,v-scsi");
  235. dt_prop_u32(dt, "reg", reg);
  236. dt_end_node(dt);
  237. reg++;
  238. vlan_map = HvLpConfig_getVirtualLanIndexMap();
  239. for (i = 0; i < HVMAXARCHITECTEDVIRTUALLANS; i++) {
  240. unsigned char mac_addr[ETH_ALEN];
  241. if ((vlan_map & (0x8000 >> i)) == 0)
  242. continue;
  243. snprintf(buf, 32, "l-lan@%08x", reg + i);
  244. dt_start_node(dt, buf);
  245. dt_prop_str(dt, "device_type", "network");
  246. dt_prop_str(dt, "compatible", "IBM,iSeries-l-lan");
  247. dt_prop_u32(dt, "reg", reg + i);
  248. dt_prop_u32(dt, "linux,unit_address", i);
  249. mac_addr[0] = 0x02;
  250. mac_addr[1] = 0x01;
  251. mac_addr[2] = 0xff;
  252. mac_addr[3] = i;
  253. mac_addr[4] = 0xff;
  254. mac_addr[5] = HvLpConfig_getLpIndex_outline();
  255. dt_prop(dt, "local-mac-address", (char *)mac_addr, ETH_ALEN);
  256. dt_prop(dt, "mac-address", (char *)mac_addr, ETH_ALEN);
  257. dt_prop_u32(dt, "max-frame-size", 9000);
  258. dt_prop_u32(dt, "address-bits", 48);
  259. dt_end_node(dt);
  260. }
  261. reg += HVMAXARCHITECTEDVIRTUALLANS;
  262. for (i = 0; i < HVMAXARCHITECTEDVIRTUALDISKS; i++) {
  263. snprintf(buf, 32, "viodasd@%08x", reg + i);
  264. dt_start_node(dt, buf);
  265. dt_prop_str(dt, "device_type", "block");
  266. dt_prop_str(dt, "compatible", "IBM,iSeries-viodasd");
  267. dt_prop_u32(dt, "reg", reg + i);
  268. dt_prop_u32(dt, "linux,unit_address", i);
  269. dt_end_node(dt);
  270. }
  271. reg += HVMAXARCHITECTEDVIRTUALDISKS;
  272. for (i = 0; i < HVMAXARCHITECTEDVIRTUALCDROMS; i++) {
  273. snprintf(buf, 32, "viocd@%08x", reg + i);
  274. dt_start_node(dt, buf);
  275. dt_prop_str(dt, "device_type", "block");
  276. dt_prop_str(dt, "compatible", "IBM,iSeries-viocd");
  277. dt_prop_u32(dt, "reg", reg + i);
  278. dt_prop_u32(dt, "linux,unit_address", i);
  279. dt_end_node(dt);
  280. }
  281. reg += HVMAXARCHITECTEDVIRTUALCDROMS;
  282. for (i = 0; i < HVMAXARCHITECTEDVIRTUALTAPES; i++) {
  283. snprintf(buf, 32, "viotape@%08x", reg + i);
  284. dt_start_node(dt, buf);
  285. dt_prop_str(dt, "device_type", "byte");
  286. dt_prop_str(dt, "compatible", "IBM,iSeries-viotape");
  287. dt_prop_u32(dt, "reg", reg + i);
  288. dt_prop_u32(dt, "linux,unit_address", i);
  289. dt_end_node(dt);
  290. }
  291. dt_end_node(dt);
  292. }
  293. struct pci_class_name {
  294. u16 code;
  295. char *name;
  296. char *type;
  297. };
  298. static struct pci_class_name __initdata pci_class_name[] = {
  299. { PCI_CLASS_NETWORK_ETHERNET, "ethernet", "network" },
  300. };
  301. static struct pci_class_name * __init dt_find_pci_class_name(u16 class_code)
  302. {
  303. struct pci_class_name *cp;
  304. for (cp = pci_class_name;
  305. cp < &pci_class_name[ARRAY_SIZE(pci_class_name)]; cp++)
  306. if (cp->code == class_code)
  307. return cp;
  308. return NULL;
  309. }
  310. /*
  311. * This assumes that the node slot is always on the primary bus!
  312. */
  313. static void __init scan_bridge_slot(struct iseries_flat_dt *dt,
  314. HvBusNumber bus, struct HvCallPci_BridgeInfo *bridge_info)
  315. {
  316. HvSubBusNumber sub_bus = bridge_info->subBusNumber;
  317. u16 vendor_id;
  318. u16 device_id;
  319. u32 class_id;
  320. int err;
  321. char buf[32];
  322. u32 reg[5];
  323. int id_sel = ISERIES_GET_DEVICE_FROM_SUBBUS(sub_bus);
  324. int function = ISERIES_GET_FUNCTION_FROM_SUBBUS(sub_bus);
  325. HvAgentId eads_id_sel = ISERIES_PCI_AGENTID(id_sel, function);
  326. u8 devfn;
  327. struct pci_class_name *cp;
  328. /*
  329. * Connect all functions of any device found.
  330. */
  331. for (id_sel = 1; id_sel <= bridge_info->maxAgents; id_sel++) {
  332. for (function = 0; function < 8; function++) {
  333. HvAgentId agent_id = ISERIES_PCI_AGENTID(id_sel,
  334. function);
  335. err = HvCallXm_connectBusUnit(bus, sub_bus,
  336. agent_id, 0);
  337. if (err) {
  338. if (err != 0x302)
  339. printk(KERN_DEBUG
  340. "connectBusUnit(%x, %x, %x) "
  341. "== %x\n",
  342. bus, sub_bus, agent_id, err);
  343. continue;
  344. }
  345. err = HvCallPci_configLoad16(bus, sub_bus, agent_id,
  346. PCI_VENDOR_ID, &vendor_id);
  347. if (err) {
  348. printk(KERN_DEBUG
  349. "ReadVendor(%x, %x, %x) == %x\n",
  350. bus, sub_bus, agent_id, err);
  351. continue;
  352. }
  353. err = HvCallPci_configLoad16(bus, sub_bus, agent_id,
  354. PCI_DEVICE_ID, &device_id);
  355. if (err) {
  356. printk(KERN_DEBUG
  357. "ReadDevice(%x, %x, %x) == %x\n",
  358. bus, sub_bus, agent_id, err);
  359. continue;
  360. }
  361. err = HvCallPci_configLoad32(bus, sub_bus, agent_id,
  362. PCI_CLASS_REVISION , &class_id);
  363. if (err) {
  364. printk(KERN_DEBUG
  365. "ReadClass(%x, %x, %x) == %x\n",
  366. bus, sub_bus, agent_id, err);
  367. continue;
  368. }
  369. devfn = PCI_DEVFN(ISERIES_ENCODE_DEVICE(eads_id_sel),
  370. function);
  371. cp = dt_find_pci_class_name(class_id >> 16);
  372. if (cp && cp->name)
  373. strncpy(buf, cp->name, sizeof(buf) - 1);
  374. else
  375. snprintf(buf, sizeof(buf), "pci%x,%x",
  376. vendor_id, device_id);
  377. buf[sizeof(buf) - 1] = '\0';
  378. snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
  379. "@%x", PCI_SLOT(devfn));
  380. buf[sizeof(buf) - 1] = '\0';
  381. if (function != 0)
  382. snprintf(buf + strlen(buf),
  383. sizeof(buf) - strlen(buf),
  384. ",%x", function);
  385. dt_start_node(dt, buf);
  386. reg[0] = (bus << 16) | (devfn << 8);
  387. reg[1] = 0;
  388. reg[2] = 0;
  389. reg[3] = 0;
  390. reg[4] = 0;
  391. dt_prop_u32_list(dt, "reg", reg, 5);
  392. if (cp && (cp->type || cp->name))
  393. dt_prop_str(dt, "device_type",
  394. cp->type ? cp->type : cp->name);
  395. dt_prop_u32(dt, "vendor-id", vendor_id);
  396. dt_prop_u32(dt, "device-id", device_id);
  397. dt_prop_u32(dt, "class-code", class_id >> 8);
  398. dt_prop_u32(dt, "revision-id", class_id & 0xff);
  399. dt_prop_u32(dt, "linux,subbus", sub_bus);
  400. dt_prop_u32(dt, "linux,agent-id", agent_id);
  401. dt_prop_u32(dt, "linux,logical-slot-number",
  402. bridge_info->logicalSlotNumber);
  403. dt_end_node(dt);
  404. }
  405. }
  406. }
  407. static void __init scan_bridge(struct iseries_flat_dt *dt, HvBusNumber bus,
  408. HvSubBusNumber sub_bus, int id_sel)
  409. {
  410. struct HvCallPci_BridgeInfo bridge_info;
  411. HvAgentId agent_id;
  412. int function;
  413. int ret;
  414. /* Note: hvSubBus and irq is always be 0 at this level! */
  415. for (function = 0; function < 8; ++function) {
  416. agent_id = ISERIES_PCI_AGENTID(id_sel, function);
  417. ret = HvCallXm_connectBusUnit(bus, sub_bus, agent_id, 0);
  418. if (ret != 0) {
  419. if (ret != 0xb)
  420. printk(KERN_DEBUG "connectBusUnit(%x, %x, %x) "
  421. "== %x\n",
  422. bus, sub_bus, agent_id, ret);
  423. continue;
  424. }
  425. printk("found device at bus %d idsel %d func %d (AgentId %x)\n",
  426. bus, id_sel, function, agent_id);
  427. ret = HvCallPci_getBusUnitInfo(bus, sub_bus, agent_id,
  428. iseries_hv_addr(&bridge_info),
  429. sizeof(struct HvCallPci_BridgeInfo));
  430. if (ret != 0)
  431. continue;
  432. printk("bridge info: type %x subbus %x "
  433. "maxAgents %x maxsubbus %x logslot %x\n",
  434. bridge_info.busUnitInfo.deviceType,
  435. bridge_info.subBusNumber,
  436. bridge_info.maxAgents,
  437. bridge_info.maxSubBusNumber,
  438. bridge_info.logicalSlotNumber);
  439. if (bridge_info.busUnitInfo.deviceType ==
  440. HvCallPci_BridgeDevice)
  441. scan_bridge_slot(dt, bus, &bridge_info);
  442. else
  443. printk("PCI: Invalid Bridge Configuration(0x%02X)",
  444. bridge_info.busUnitInfo.deviceType);
  445. }
  446. }
  447. static void __init scan_phb(struct iseries_flat_dt *dt, HvBusNumber bus)
  448. {
  449. struct HvCallPci_DeviceInfo dev_info;
  450. const HvSubBusNumber sub_bus = 0; /* EADs is always 0. */
  451. int err;
  452. int id_sel;
  453. const int max_agents = 8;
  454. /*
  455. * Probe for EADs Bridges
  456. */
  457. for (id_sel = 1; id_sel < max_agents; ++id_sel) {
  458. err = HvCallPci_getDeviceInfo(bus, sub_bus, id_sel,
  459. iseries_hv_addr(&dev_info),
  460. sizeof(struct HvCallPci_DeviceInfo));
  461. if (err) {
  462. if (err != 0x302)
  463. printk(KERN_DEBUG "getDeviceInfo(%x, %x, %x) "
  464. "== %x\n",
  465. bus, sub_bus, id_sel, err);
  466. continue;
  467. }
  468. if (dev_info.deviceType != HvCallPci_NodeDevice) {
  469. printk(KERN_DEBUG "PCI: Invalid System Configuration"
  470. "(0x%02X) for bus 0x%02x id 0x%02x.\n",
  471. dev_info.deviceType, bus, id_sel);
  472. continue;
  473. }
  474. scan_bridge(dt, bus, sub_bus, id_sel);
  475. }
  476. }
  477. static void __init dt_pci_devices(struct iseries_flat_dt *dt)
  478. {
  479. HvBusNumber bus;
  480. char buf[32];
  481. u32 buses[2];
  482. int phb_num = 0;
  483. /* Check all possible buses. */
  484. for (bus = 0; bus < 256; bus++) {
  485. int err = HvCallXm_testBus(bus);
  486. if (err) {
  487. /*
  488. * Check for Unexpected Return code, a clue that
  489. * something has gone wrong.
  490. */
  491. if (err != 0x0301)
  492. printk(KERN_ERR "Unexpected Return on Probe"
  493. "(0x%02X): 0x%04X", bus, err);
  494. continue;
  495. }
  496. printk("bus %d appears to exist\n", bus);
  497. snprintf(buf, 32, "pci@%d", phb_num);
  498. dt_start_node(dt, buf);
  499. dt_prop_str(dt, "device_type", "pci");
  500. dt_prop_str(dt, "compatible", "IBM,iSeries-Logical-PHB");
  501. dt_prop_u32(dt, "#address-cells", 3);
  502. dt_prop_u32(dt, "#size-cells", 2);
  503. buses[0] = buses[1] = bus;
  504. dt_prop_u32_list(dt, "bus-range", buses, 2);
  505. scan_phb(dt, bus);
  506. dt_end_node(dt);
  507. phb_num++;
  508. }
  509. }
  510. static void dt_finish(struct iseries_flat_dt *dt)
  511. {
  512. dt_push_u32(dt, OF_DT_END);
  513. }
  514. void * __init build_flat_dt(unsigned long phys_mem_size)
  515. {
  516. u64 tmp[2];
  517. iseries_dt = dt_init();
  518. dt_start_node(iseries_dt, "");
  519. dt_prop_u32(iseries_dt, "#address-cells", 2);
  520. dt_prop_u32(iseries_dt, "#size-cells", 2);
  521. dt_model(iseries_dt);
  522. /* /memory */
  523. dt_start_node(iseries_dt, "memory@0");
  524. dt_prop_str(iseries_dt, "name", "memory");
  525. dt_prop_str(iseries_dt, "device_type", "memory");
  526. tmp[0] = 0;
  527. tmp[1] = phys_mem_size;
  528. dt_prop_u64_list(iseries_dt, "reg", tmp, 2);
  529. dt_end_node(iseries_dt);
  530. /* /chosen */
  531. dt_start_node(iseries_dt, "chosen");
  532. dt_prop_str(iseries_dt, "bootargs", cmd_line);
  533. dt_end_node(iseries_dt);
  534. dt_cpus(iseries_dt);
  535. dt_vdevices(iseries_dt);
  536. dt_pci_devices(iseries_dt);
  537. dt_end_node(iseries_dt);
  538. dt_finish(iseries_dt);
  539. return iseries_dt;
  540. }