dt.c 17 KB

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