io_init.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1992 - 1997, 2000-2005 Silicon Graphics, Inc. All rights reserved.
  7. */
  8. #include <linux/bootmem.h>
  9. #include <linux/nodemask.h>
  10. #include <asm/sn/types.h>
  11. #include <asm/sn/addrs.h>
  12. #include <asm/sn/geo.h>
  13. #include <asm/sn/io.h>
  14. #include <asm/sn/pcibr_provider.h>
  15. #include <asm/sn/pcibus_provider_defs.h>
  16. #include <asm/sn/pcidev.h>
  17. #include <asm/sn/simulator.h>
  18. #include <asm/sn/sn_sal.h>
  19. #include <asm/sn/tioca_provider.h>
  20. #include <asm/sn/tioce_provider.h>
  21. #include "xtalk/hubdev.h"
  22. #include "xtalk/xwidgetdev.h"
  23. static struct list_head sn_sysdata_list;
  24. /* sysdata list struct */
  25. struct sysdata_el {
  26. struct list_head entry;
  27. void *sysdata;
  28. };
  29. struct slab_info {
  30. struct hubdev_info hubdev;
  31. };
  32. struct brick {
  33. moduleid_t id; /* Module ID of this module */
  34. struct slab_info slab_info[MAX_SLABS + 1];
  35. };
  36. int sn_ioif_inited = 0; /* SN I/O infrastructure initialized? */
  37. struct sn_pcibus_provider *sn_pci_provider[PCIIO_ASIC_MAX_TYPES]; /* indexed by asic type */
  38. static int max_segment_number = 0; /* Default highest segment number */
  39. static int max_pcibus_number = 255; /* Default highest pci bus number */
  40. /*
  41. * Hooks and struct for unsupported pci providers
  42. */
  43. static dma_addr_t
  44. sn_default_pci_map(struct pci_dev *pdev, unsigned long paddr, size_t size)
  45. {
  46. return 0;
  47. }
  48. static void
  49. sn_default_pci_unmap(struct pci_dev *pdev, dma_addr_t addr, int direction)
  50. {
  51. return;
  52. }
  53. static void *
  54. sn_default_pci_bus_fixup(struct pcibus_bussoft *soft, struct pci_controller *controller)
  55. {
  56. return NULL;
  57. }
  58. static struct sn_pcibus_provider sn_pci_default_provider = {
  59. .dma_map = sn_default_pci_map,
  60. .dma_map_consistent = sn_default_pci_map,
  61. .dma_unmap = sn_default_pci_unmap,
  62. .bus_fixup = sn_default_pci_bus_fixup,
  63. };
  64. /*
  65. * Retrieve the DMA Flush List given nasid. This list is needed
  66. * to implement the WAR - Flush DMA data on PIO Reads.
  67. */
  68. static inline uint64_t
  69. sal_get_widget_dmaflush_list(u64 nasid, u64 widget_num, u64 address)
  70. {
  71. struct ia64_sal_retval ret_stuff;
  72. ret_stuff.status = 0;
  73. ret_stuff.v0 = 0;
  74. SAL_CALL_NOLOCK(ret_stuff,
  75. (u64) SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST,
  76. (u64) nasid, (u64) widget_num, (u64) address, 0, 0, 0,
  77. 0);
  78. return ret_stuff.v0;
  79. }
  80. /*
  81. * Retrieve the hub device info structure for the given nasid.
  82. */
  83. static inline uint64_t sal_get_hubdev_info(u64 handle, u64 address)
  84. {
  85. struct ia64_sal_retval ret_stuff;
  86. ret_stuff.status = 0;
  87. ret_stuff.v0 = 0;
  88. SAL_CALL_NOLOCK(ret_stuff,
  89. (u64) SN_SAL_IOIF_GET_HUBDEV_INFO,
  90. (u64) handle, (u64) address, 0, 0, 0, 0, 0);
  91. return ret_stuff.v0;
  92. }
  93. /*
  94. * Retrieve the pci bus information given the bus number.
  95. */
  96. static inline uint64_t sal_get_pcibus_info(u64 segment, u64 busnum, u64 address)
  97. {
  98. struct ia64_sal_retval ret_stuff;
  99. ret_stuff.status = 0;
  100. ret_stuff.v0 = 0;
  101. SAL_CALL_NOLOCK(ret_stuff,
  102. (u64) SN_SAL_IOIF_GET_PCIBUS_INFO,
  103. (u64) segment, (u64) busnum, (u64) address, 0, 0, 0, 0);
  104. return ret_stuff.v0;
  105. }
  106. /*
  107. * Retrieve the pci device information given the bus and device|function number.
  108. */
  109. static inline uint64_t
  110. sal_get_pcidev_info(u64 segment, u64 bus_number, u64 devfn, u64 pci_dev,
  111. u64 sn_irq_info)
  112. {
  113. struct ia64_sal_retval ret_stuff;
  114. ret_stuff.status = 0;
  115. ret_stuff.v0 = 0;
  116. SAL_CALL_NOLOCK(ret_stuff,
  117. (u64) SN_SAL_IOIF_GET_PCIDEV_INFO,
  118. (u64) segment, (u64) bus_number, (u64) devfn,
  119. (u64) pci_dev,
  120. sn_irq_info, 0, 0);
  121. return ret_stuff.v0;
  122. }
  123. /*
  124. * sn_pcidev_info_get() - Retrieve the pcidev_info struct for the specified
  125. * device.
  126. */
  127. inline struct pcidev_info *
  128. sn_pcidev_info_get(struct pci_dev *dev)
  129. {
  130. struct pcidev_info *pcidev;
  131. list_for_each_entry(pcidev,
  132. &(SN_PCI_CONTROLLER(dev)->pcidev_info), pdi_list) {
  133. if (pcidev->pdi_linux_pcidev == dev) {
  134. return pcidev;
  135. }
  136. }
  137. return NULL;
  138. }
  139. /*
  140. * sn_fixup_ionodes() - This routine initializes the HUB data strcuture for
  141. * each node in the system.
  142. */
  143. static void sn_fixup_ionodes(void)
  144. {
  145. struct sn_flush_device_list *sn_flush_device_list;
  146. struct hubdev_info *hubdev;
  147. uint64_t status;
  148. uint64_t nasid;
  149. int i, widget;
  150. /*
  151. * Get SGI Specific HUB chipset information.
  152. * Inform Prom that this kernel can support domain bus numbering.
  153. */
  154. for (i = 0; i < num_cnodes; i++) {
  155. hubdev = (struct hubdev_info *)(NODEPDA(i)->pdinfo);
  156. nasid = cnodeid_to_nasid(i);
  157. hubdev->max_segment_number = 0xffffffff;
  158. hubdev->max_pcibus_number = 0xff;
  159. status = sal_get_hubdev_info(nasid, (uint64_t) __pa(hubdev));
  160. if (status)
  161. continue;
  162. /* Save the largest Domain and pcibus numbers found. */
  163. if (hubdev->max_segment_number) {
  164. /*
  165. * Dealing with a Prom that supports segments.
  166. */
  167. max_segment_number = hubdev->max_segment_number;
  168. max_pcibus_number = hubdev->max_pcibus_number;
  169. }
  170. /* Attach the error interrupt handlers */
  171. if (nasid & 1)
  172. ice_error_init(hubdev);
  173. else
  174. hub_error_init(hubdev);
  175. for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++)
  176. hubdev->hdi_xwidget_info[widget].xwi_hubinfo = hubdev;
  177. if (!hubdev->hdi_flush_nasid_list.widget_p)
  178. continue;
  179. hubdev->hdi_flush_nasid_list.widget_p =
  180. kmalloc((HUB_WIDGET_ID_MAX + 1) *
  181. sizeof(struct sn_flush_device_list *), GFP_KERNEL);
  182. memset(hubdev->hdi_flush_nasid_list.widget_p, 0x0,
  183. (HUB_WIDGET_ID_MAX + 1) *
  184. sizeof(struct sn_flush_device_list *));
  185. for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) {
  186. sn_flush_device_list = kmalloc(DEV_PER_WIDGET *
  187. sizeof(struct
  188. sn_flush_device_list),
  189. GFP_KERNEL);
  190. memset(sn_flush_device_list, 0x0,
  191. DEV_PER_WIDGET *
  192. sizeof(struct sn_flush_device_list));
  193. status =
  194. sal_get_widget_dmaflush_list(nasid, widget,
  195. (uint64_t)
  196. __pa
  197. (sn_flush_device_list));
  198. if (status) {
  199. kfree(sn_flush_device_list);
  200. continue;
  201. }
  202. spin_lock_init(&sn_flush_device_list->sfdl_flush_lock);
  203. hubdev->hdi_flush_nasid_list.widget_p[widget] =
  204. sn_flush_device_list;
  205. }
  206. }
  207. }
  208. /*
  209. * sn_pci_window_fixup() - Create a pci_window for each device resource.
  210. * Until ACPI support is added, we need this code
  211. * to setup pci_windows for use by
  212. * pcibios_bus_to_resource(),
  213. * pcibios_resource_to_bus(), etc.
  214. */
  215. static void
  216. sn_pci_window_fixup(struct pci_dev *dev, unsigned int count,
  217. int64_t * pci_addrs)
  218. {
  219. struct pci_controller *controller = PCI_CONTROLLER(dev->bus);
  220. unsigned int i;
  221. unsigned int idx;
  222. unsigned int new_count;
  223. struct pci_window *new_window;
  224. if (count == 0)
  225. return;
  226. idx = controller->windows;
  227. new_count = controller->windows + count;
  228. new_window = kcalloc(new_count, sizeof(struct pci_window), GFP_KERNEL);
  229. if (new_window == NULL)
  230. BUG();
  231. if (controller->window) {
  232. memcpy(new_window, controller->window,
  233. sizeof(struct pci_window) * controller->windows);
  234. kfree(controller->window);
  235. }
  236. /* Setup a pci_window for each device resource. */
  237. for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
  238. if (pci_addrs[i] == -1)
  239. continue;
  240. new_window[idx].offset = dev->resource[i].start - pci_addrs[i];
  241. new_window[idx].resource = dev->resource[i];
  242. idx++;
  243. }
  244. controller->windows = new_count;
  245. controller->window = new_window;
  246. }
  247. void sn_pci_unfixup_slot(struct pci_dev *dev)
  248. {
  249. struct pci_dev *host_pci_dev = SN_PCIDEV_INFO(dev)->host_pci_dev;
  250. sn_irq_unfixup(dev);
  251. pci_dev_put(host_pci_dev);
  252. pci_dev_put(dev);
  253. }
  254. /*
  255. * sn_pci_fixup_slot() - This routine sets up a slot's resources
  256. * consistent with the Linux PCI abstraction layer. Resources acquired
  257. * from our PCI provider include PIO maps to BAR space and interrupt
  258. * objects.
  259. */
  260. void sn_pci_fixup_slot(struct pci_dev *dev)
  261. {
  262. unsigned int count = 0;
  263. int idx;
  264. int segment = pci_domain_nr(dev->bus);
  265. int status = 0;
  266. struct pcibus_bussoft *bs;
  267. struct pci_bus *host_pci_bus;
  268. struct pci_dev *host_pci_dev;
  269. struct pcidev_info *pcidev_info;
  270. int64_t pci_addrs[PCI_ROM_RESOURCE + 1];
  271. struct sn_irq_info *sn_irq_info;
  272. unsigned long size;
  273. unsigned int bus_no, devfn;
  274. pci_dev_get(dev); /* for the sysdata pointer */
  275. pcidev_info = kzalloc(sizeof(struct pcidev_info), GFP_KERNEL);
  276. if (pcidev_info <= 0)
  277. BUG(); /* Cannot afford to run out of memory */
  278. sn_irq_info = kmalloc(sizeof(struct sn_irq_info), GFP_KERNEL);
  279. if (sn_irq_info <= 0)
  280. BUG(); /* Cannot afford to run out of memory */
  281. memset(sn_irq_info, 0, sizeof(struct sn_irq_info));
  282. /* Call to retrieve pci device information needed by kernel. */
  283. status = sal_get_pcidev_info((u64) segment, (u64) dev->bus->number,
  284. dev->devfn,
  285. (u64) __pa(pcidev_info),
  286. (u64) __pa(sn_irq_info));
  287. if (status)
  288. BUG(); /* Cannot get platform pci device information */
  289. /* Add pcidev_info to list in sn_pci_controller struct */
  290. list_add_tail(&pcidev_info->pdi_list,
  291. &(SN_PCI_CONTROLLER(dev->bus)->pcidev_info));
  292. /* Copy over PIO Mapped Addresses */
  293. for (idx = 0; idx <= PCI_ROM_RESOURCE; idx++) {
  294. unsigned long start, end, addr;
  295. if (!pcidev_info->pdi_pio_mapped_addr[idx]) {
  296. pci_addrs[idx] = -1;
  297. continue;
  298. }
  299. start = dev->resource[idx].start;
  300. end = dev->resource[idx].end;
  301. size = end - start;
  302. if (size == 0) {
  303. pci_addrs[idx] = -1;
  304. continue;
  305. }
  306. pci_addrs[idx] = start;
  307. count++;
  308. addr = pcidev_info->pdi_pio_mapped_addr[idx];
  309. addr = ((addr << 4) >> 4) | __IA64_UNCACHED_OFFSET;
  310. dev->resource[idx].start = addr;
  311. dev->resource[idx].end = addr + size;
  312. if (dev->resource[idx].flags & IORESOURCE_IO)
  313. dev->resource[idx].parent = &ioport_resource;
  314. else
  315. dev->resource[idx].parent = &iomem_resource;
  316. }
  317. /* Create a pci_window in the pci_controller struct for
  318. * each device resource.
  319. */
  320. if (count > 0)
  321. sn_pci_window_fixup(dev, count, pci_addrs);
  322. /*
  323. * Using the PROMs values for the PCI host bus, get the Linux
  324. * PCI host_pci_dev struct and set up host bus linkages
  325. */
  326. bus_no = (pcidev_info->pdi_slot_host_handle >> 32) & 0xff;
  327. devfn = pcidev_info->pdi_slot_host_handle & 0xffffffff;
  328. host_pci_bus = pci_find_bus(segment, bus_no);
  329. host_pci_dev = pci_get_slot(host_pci_bus, devfn);
  330. pcidev_info->host_pci_dev = host_pci_dev;
  331. pcidev_info->pdi_linux_pcidev = dev;
  332. pcidev_info->pdi_host_pcidev_info = SN_PCIDEV_INFO(host_pci_dev);
  333. bs = SN_PCIBUS_BUSSOFT(dev->bus);
  334. pcidev_info->pdi_pcibus_info = bs;
  335. if (bs && bs->bs_asic_type < PCIIO_ASIC_MAX_TYPES) {
  336. SN_PCIDEV_BUSPROVIDER(dev) = sn_pci_provider[bs->bs_asic_type];
  337. } else {
  338. SN_PCIDEV_BUSPROVIDER(dev) = &sn_pci_default_provider;
  339. }
  340. /* Only set up IRQ stuff if this device has a host bus context */
  341. if (bs && sn_irq_info->irq_irq) {
  342. pcidev_info->pdi_sn_irq_info = sn_irq_info;
  343. dev->irq = pcidev_info->pdi_sn_irq_info->irq_irq;
  344. sn_irq_fixup(dev, sn_irq_info);
  345. } else {
  346. pcidev_info->pdi_sn_irq_info = NULL;
  347. kfree(sn_irq_info);
  348. }
  349. }
  350. /*
  351. * sn_pci_controller_fixup() - This routine sets up a bus's resources
  352. * consistent with the Linux PCI abstraction layer.
  353. */
  354. void sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
  355. {
  356. int status = 0;
  357. int nasid, cnode;
  358. struct pci_controller *controller;
  359. struct sn_pci_controller *sn_controller;
  360. struct pcibus_bussoft *prom_bussoft_ptr;
  361. struct hubdev_info *hubdev_info;
  362. void *provider_soft = NULL;
  363. struct sn_pcibus_provider *provider;
  364. status = sal_get_pcibus_info((u64) segment, (u64) busnum,
  365. (u64) ia64_tpa(&prom_bussoft_ptr));
  366. if (status > 0)
  367. return; /*bus # does not exist */
  368. prom_bussoft_ptr = __va(prom_bussoft_ptr);
  369. /* Allocate a sn_pci_controller, which has a pci_controller struct
  370. * as the first member.
  371. */
  372. sn_controller = kzalloc(sizeof(struct sn_pci_controller), GFP_KERNEL);
  373. if (!sn_controller)
  374. BUG();
  375. INIT_LIST_HEAD(&sn_controller->pcidev_info);
  376. controller = &sn_controller->pci_controller;
  377. controller->segment = segment;
  378. if (bus == NULL) {
  379. bus = pci_scan_bus(busnum, &pci_root_ops, controller);
  380. if (bus == NULL)
  381. goto error_return; /* error, or bus already scanned */
  382. bus->sysdata = NULL;
  383. }
  384. if (bus->sysdata)
  385. goto error_return; /* sysdata already alloc'd */
  386. /*
  387. * Per-provider fixup. Copies the contents from prom to local
  388. * area and links SN_PCIBUS_BUSSOFT().
  389. */
  390. if (prom_bussoft_ptr->bs_asic_type >= PCIIO_ASIC_MAX_TYPES)
  391. goto error_return; /* unsupported asic type */
  392. if (prom_bussoft_ptr->bs_asic_type == PCIIO_ASIC_TYPE_PPB)
  393. goto error_return; /* no further fixup necessary */
  394. provider = sn_pci_provider[prom_bussoft_ptr->bs_asic_type];
  395. if (provider == NULL)
  396. goto error_return; /* no provider registerd for this asic */
  397. bus->sysdata = controller;
  398. if (provider->bus_fixup)
  399. provider_soft = (*provider->bus_fixup) (prom_bussoft_ptr, controller);
  400. if (provider_soft == NULL) {
  401. /* fixup failed or not applicable */
  402. bus->sysdata = NULL;
  403. goto error_return;
  404. }
  405. /*
  406. * Setup pci_windows for legacy IO and MEM space.
  407. * (Temporary until ACPI support is in place.)
  408. */
  409. controller->window = kcalloc(2, sizeof(struct pci_window), GFP_KERNEL);
  410. if (controller->window == NULL)
  411. BUG();
  412. controller->window[0].offset = prom_bussoft_ptr->bs_legacy_io;
  413. controller->window[0].resource.name = "legacy_io";
  414. controller->window[0].resource.flags = IORESOURCE_IO;
  415. controller->window[0].resource.start = prom_bussoft_ptr->bs_legacy_io;
  416. controller->window[0].resource.end =
  417. controller->window[0].resource.start + 0xffff;
  418. controller->window[0].resource.parent = &ioport_resource;
  419. controller->window[1].offset = prom_bussoft_ptr->bs_legacy_mem;
  420. controller->window[1].resource.name = "legacy_mem";
  421. controller->window[1].resource.flags = IORESOURCE_MEM;
  422. controller->window[1].resource.start = prom_bussoft_ptr->bs_legacy_mem;
  423. controller->window[1].resource.end =
  424. controller->window[1].resource.start + (1024 * 1024) - 1;
  425. controller->window[1].resource.parent = &iomem_resource;
  426. controller->windows = 2;
  427. /*
  428. * Generic bus fixup goes here. Don't reference prom_bussoft_ptr
  429. * after this point.
  430. */
  431. PCI_CONTROLLER(bus)->platform_data = provider_soft;
  432. nasid = NASID_GET(SN_PCIBUS_BUSSOFT(bus)->bs_base);
  433. cnode = nasid_to_cnodeid(nasid);
  434. hubdev_info = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo);
  435. SN_PCIBUS_BUSSOFT(bus)->bs_xwidget_info =
  436. &(hubdev_info->hdi_xwidget_info[SN_PCIBUS_BUSSOFT(bus)->bs_xid]);
  437. /*
  438. * If the node information we obtained during the fixup phase is invalid
  439. * then set controller->node to -1 (undetermined)
  440. */
  441. if (controller->node >= num_online_nodes()) {
  442. struct pcibus_bussoft *b = SN_PCIBUS_BUSSOFT(bus);
  443. printk(KERN_WARNING "Device ASIC=%u XID=%u PBUSNUM=%u"
  444. "L_IO=%lx L_MEM=%lx BASE=%lx\n",
  445. b->bs_asic_type, b->bs_xid, b->bs_persist_busnum,
  446. b->bs_legacy_io, b->bs_legacy_mem, b->bs_base);
  447. printk(KERN_WARNING "on node %d but only %d nodes online."
  448. "Association set to undetermined.\n",
  449. controller->node, num_online_nodes());
  450. controller->node = -1;
  451. }
  452. return;
  453. error_return:
  454. kfree(sn_controller);
  455. return;
  456. }
  457. void sn_bus_store_sysdata(struct pci_dev *dev)
  458. {
  459. struct sysdata_el *element;
  460. element = kzalloc(sizeof(struct sysdata_el), GFP_KERNEL);
  461. if (!element) {
  462. dev_dbg(dev, "%s: out of memory!\n", __FUNCTION__);
  463. return;
  464. }
  465. element->sysdata = SN_PCIDEV_INFO(dev);
  466. list_add(&element->entry, &sn_sysdata_list);
  467. }
  468. void sn_bus_free_sysdata(void)
  469. {
  470. struct sysdata_el *element;
  471. struct list_head *list;
  472. sn_sysdata_free_start:
  473. list_for_each(list, &sn_sysdata_list) {
  474. element = list_entry(list, struct sysdata_el, entry);
  475. list_del(&element->entry);
  476. kfree(element->sysdata);
  477. kfree(element);
  478. goto sn_sysdata_free_start;
  479. }
  480. return;
  481. }
  482. /*
  483. * Ugly hack to get PCI setup until we have a proper ACPI namespace.
  484. */
  485. #define PCI_BUSES_TO_SCAN 256
  486. static int __init sn_pci_init(void)
  487. {
  488. int i = 0;
  489. int j = 0;
  490. struct pci_dev *pci_dev = NULL;
  491. extern void sn_init_cpei_timer(void);
  492. #ifdef CONFIG_PROC_FS
  493. extern void register_sn_procfs(void);
  494. #endif
  495. if (!ia64_platform_is("sn2") || IS_RUNNING_ON_FAKE_PROM())
  496. return 0;
  497. /*
  498. * prime sn_pci_provider[]. Individial provider init routines will
  499. * override their respective default entries.
  500. */
  501. for (i = 0; i < PCIIO_ASIC_MAX_TYPES; i++)
  502. sn_pci_provider[i] = &sn_pci_default_provider;
  503. pcibr_init_provider();
  504. tioca_init_provider();
  505. tioce_init_provider();
  506. /*
  507. * This is needed to avoid bounce limit checks in the blk layer
  508. */
  509. ia64_max_iommu_merge_mask = ~PAGE_MASK;
  510. sn_fixup_ionodes();
  511. sn_irq_lh_init();
  512. INIT_LIST_HEAD(&sn_sysdata_list);
  513. sn_init_cpei_timer();
  514. #ifdef CONFIG_PROC_FS
  515. register_sn_procfs();
  516. #endif
  517. /* busses are not known yet ... */
  518. for (i = 0; i <= max_segment_number; i++)
  519. for (j = 0; j <= max_pcibus_number; j++)
  520. sn_pci_controller_fixup(i, j, NULL);
  521. /*
  522. * Generic Linux PCI Layer has created the pci_bus and pci_dev
  523. * structures - time for us to add our SN PLatform specific
  524. * information.
  525. */
  526. while ((pci_dev =
  527. pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) != NULL)
  528. sn_pci_fixup_slot(pci_dev);
  529. sn_ioif_inited = 1; /* sn I/O infrastructure now initialized */
  530. return 0;
  531. }
  532. /*
  533. * hubdev_init_node() - Creates the HUB data structure and link them to it's
  534. * own NODE specific data area.
  535. */
  536. void hubdev_init_node(nodepda_t * npda, cnodeid_t node)
  537. {
  538. struct hubdev_info *hubdev_info;
  539. if (node >= num_online_nodes()) /* Headless/memless IO nodes */
  540. hubdev_info =
  541. (struct hubdev_info *)alloc_bootmem_node(NODE_DATA(0),
  542. sizeof(struct
  543. hubdev_info));
  544. else
  545. hubdev_info =
  546. (struct hubdev_info *)alloc_bootmem_node(NODE_DATA(node),
  547. sizeof(struct
  548. hubdev_info));
  549. npda->pdinfo = (void *)hubdev_info;
  550. }
  551. geoid_t
  552. cnodeid_get_geoid(cnodeid_t cnode)
  553. {
  554. struct hubdev_info *hubdev;
  555. hubdev = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo);
  556. return hubdev->hdi_geoid;
  557. }
  558. subsys_initcall(sn_pci_init);
  559. EXPORT_SYMBOL(sn_pci_fixup_slot);
  560. EXPORT_SYMBOL(sn_pci_unfixup_slot);
  561. EXPORT_SYMBOL(sn_pci_controller_fixup);
  562. EXPORT_SYMBOL(sn_bus_store_sysdata);
  563. EXPORT_SYMBOL(sn_bus_free_sysdata);