io_init.c 18 KB

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