dt.c 16 KB

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