]>
Commit | Line | Data |
---|---|---|
8ea6091f JK |
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) 2006 Silicon Graphics, Inc. All rights reserved. | |
7 | */ | |
8 | ||
9 | #include <linux/bootmem.h> | |
10 | #include <asm/sn/types.h> | |
11 | #include <asm/sn/addrs.h> | |
12 | #include <asm/sn/sn_feature_sets.h> | |
13 | #include <asm/sn/geo.h> | |
14 | #include <asm/sn/io.h> | |
15 | #include <asm/sn/l1.h> | |
16 | #include <asm/sn/module.h> | |
17 | #include <asm/sn/pcibr_provider.h> | |
18 | #include <asm/sn/pcibus_provider_defs.h> | |
19 | #include <asm/sn/pcidev.h> | |
20 | #include <asm/sn/simulator.h> | |
21 | #include <asm/sn/sn_sal.h> | |
22 | #include <asm/sn/tioca_provider.h> | |
23 | #include <asm/sn/tioce_provider.h> | |
24 | #include "xtalk/hubdev.h" | |
25 | #include "xtalk/xwidgetdev.h" | |
26 | #include <linux/acpi.h> | |
27 | #include <asm/sn/sn2/sn_hwperf.h> | |
647fb47d | 28 | #include <asm/sn/acpi.h> |
8ea6091f JK |
29 | |
30 | extern void sn_init_cpei_timer(void); | |
31 | extern void register_sn_procfs(void); | |
8ea6091f JK |
32 | extern void sn_io_acpi_init(void); |
33 | extern void sn_io_init(void); | |
34 | ||
647fb47d | 35 | |
8ea6091f JK |
36 | static struct list_head sn_sysdata_list; |
37 | ||
38 | /* sysdata list struct */ | |
39 | struct sysdata_el { | |
40 | struct list_head entry; | |
41 | void *sysdata; | |
42 | }; | |
43 | ||
44 | int sn_ioif_inited; /* SN I/O infrastructure initialized? */ | |
45 | ||
6f09a925 JK |
46 | int sn_acpi_rev; /* SN ACPI revision */ |
47 | EXPORT_SYMBOL_GPL(sn_acpi_rev); | |
8ea6091f | 48 | |
6f09a925 | 49 | struct sn_pcibus_provider *sn_pci_provider[PCIIO_ASIC_MAX_TYPES]; /* indexed by asic type */ |
ad71860a | 50 | |
8ea6091f JK |
51 | /* |
52 | * Hooks and struct for unsupported pci providers | |
53 | */ | |
54 | ||
55 | static dma_addr_t | |
56 | sn_default_pci_map(struct pci_dev *pdev, unsigned long paddr, size_t size, int type) | |
57 | { | |
58 | return 0; | |
59 | } | |
60 | ||
61 | static void | |
62 | sn_default_pci_unmap(struct pci_dev *pdev, dma_addr_t addr, int direction) | |
63 | { | |
64 | return; | |
65 | } | |
66 | ||
67 | static void * | |
68 | sn_default_pci_bus_fixup(struct pcibus_bussoft *soft, struct pci_controller *controller) | |
69 | { | |
70 | return NULL; | |
71 | } | |
72 | ||
73 | static struct sn_pcibus_provider sn_pci_default_provider = { | |
74 | .dma_map = sn_default_pci_map, | |
75 | .dma_map_consistent = sn_default_pci_map, | |
76 | .dma_unmap = sn_default_pci_unmap, | |
77 | .bus_fixup = sn_default_pci_bus_fixup, | |
78 | }; | |
79 | ||
80 | /* | |
81 | * Retrieve the DMA Flush List given nasid, widget, and device. | |
82 | * This list is needed to implement the WAR - Flush DMA data on PIO Reads. | |
83 | */ | |
84 | static inline u64 | |
85 | sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num, | |
86 | u64 address) | |
87 | { | |
88 | struct ia64_sal_retval ret_stuff; | |
89 | ret_stuff.status = 0; | |
90 | ret_stuff.v0 = 0; | |
91 | ||
92 | SAL_CALL_NOLOCK(ret_stuff, | |
93 | (u64) SN_SAL_IOIF_GET_DEVICE_DMAFLUSH_LIST, | |
94 | (u64) nasid, (u64) widget_num, | |
95 | (u64) device_num, (u64) address, 0, 0, 0); | |
96 | return ret_stuff.status; | |
97 | } | |
98 | ||
8ea6091f JK |
99 | /* |
100 | * sn_pcidev_info_get() - Retrieve the pcidev_info struct for the specified | |
101 | * device. | |
102 | */ | |
103 | inline struct pcidev_info * | |
104 | sn_pcidev_info_get(struct pci_dev *dev) | |
105 | { | |
106 | struct pcidev_info *pcidev; | |
107 | ||
108 | list_for_each_entry(pcidev, | |
109 | &(SN_PLATFORM_DATA(dev)->pcidev_info), pdi_list) { | |
110 | if (pcidev->pdi_linux_pcidev == dev) | |
111 | return pcidev; | |
112 | } | |
113 | return NULL; | |
114 | } | |
115 | ||
116 | /* Older PROM flush WAR | |
117 | * | |
118 | * 01/16/06 -- This war will be in place until a new official PROM is released. | |
119 | * Additionally note that the struct sn_flush_device_war also has to be | |
120 | * removed from arch/ia64/sn/include/xtalk/hubdev.h | |
121 | */ | |
122 | static u8 war_implemented = 0; | |
123 | ||
124 | static s64 sn_device_fixup_war(u64 nasid, u64 widget, int device, | |
125 | struct sn_flush_device_common *common) | |
126 | { | |
127 | struct sn_flush_device_war *war_list; | |
128 | struct sn_flush_device_war *dev_entry; | |
129 | struct ia64_sal_retval isrv = {0,0,0,0}; | |
130 | ||
131 | if (!war_implemented) { | |
132 | printk(KERN_WARNING "PROM version < 4.50 -- implementing old " | |
133 | "PROM flush WAR\n"); | |
134 | war_implemented = 1; | |
135 | } | |
136 | ||
137 | war_list = kzalloc(DEV_PER_WIDGET * sizeof(*war_list), GFP_KERNEL); | |
80a03e29 | 138 | BUG_ON(!war_list); |
8ea6091f JK |
139 | |
140 | SAL_CALL_NOLOCK(isrv, SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST, | |
141 | nasid, widget, __pa(war_list), 0, 0, 0 ,0); | |
142 | if (isrv.status) | |
143 | panic("sn_device_fixup_war failed: %s\n", | |
144 | ia64_sal_strerror(isrv.status)); | |
145 | ||
146 | dev_entry = war_list + device; | |
147 | memcpy(common,dev_entry, sizeof(*common)); | |
148 | kfree(war_list); | |
149 | ||
150 | return isrv.status; | |
151 | } | |
152 | ||
153 | /* | |
154 | * sn_common_hubdev_init() - This routine is called to initialize the HUB data | |
155 | * structure for each node in the system. | |
156 | */ | |
157 | void __init | |
158 | sn_common_hubdev_init(struct hubdev_info *hubdev) | |
159 | { | |
160 | ||
161 | struct sn_flush_device_kernel *sn_flush_device_kernel; | |
162 | struct sn_flush_device_kernel *dev_entry; | |
163 | s64 status; | |
164 | int widget, device, size; | |
165 | ||
166 | /* Attach the error interrupt handlers */ | |
167 | if (hubdev->hdi_nasid & 1) /* If TIO */ | |
168 | ice_error_init(hubdev); | |
169 | else | |
170 | hub_error_init(hubdev); | |
171 | ||
172 | for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) | |
173 | hubdev->hdi_xwidget_info[widget].xwi_hubinfo = hubdev; | |
174 | ||
175 | if (!hubdev->hdi_flush_nasid_list.widget_p) | |
176 | return; | |
177 | ||
178 | size = (HUB_WIDGET_ID_MAX + 1) * | |
179 | sizeof(struct sn_flush_device_kernel *); | |
180 | hubdev->hdi_flush_nasid_list.widget_p = | |
181 | kzalloc(size, GFP_KERNEL); | |
80a03e29 | 182 | BUG_ON(!hubdev->hdi_flush_nasid_list.widget_p); |
8ea6091f JK |
183 | |
184 | for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) { | |
185 | size = DEV_PER_WIDGET * | |
186 | sizeof(struct sn_flush_device_kernel); | |
187 | sn_flush_device_kernel = kzalloc(size, GFP_KERNEL); | |
80a03e29 | 188 | BUG_ON(!sn_flush_device_kernel); |
8ea6091f JK |
189 | |
190 | dev_entry = sn_flush_device_kernel; | |
191 | for (device = 0; device < DEV_PER_WIDGET; | |
192 | device++, dev_entry++) { | |
193 | size = sizeof(struct sn_flush_device_common); | |
194 | dev_entry->common = kzalloc(size, GFP_KERNEL); | |
80a03e29 | 195 | BUG_ON(!dev_entry->common); |
8ea6091f JK |
196 | if (sn_prom_feature_available(PRF_DEVICE_FLUSH_LIST)) |
197 | status = sal_get_device_dmaflush_list( | |
198 | hubdev->hdi_nasid, widget, device, | |
199 | (u64)(dev_entry->common)); | |
200 | else | |
201 | status = sn_device_fixup_war(hubdev->hdi_nasid, | |
202 | widget, device, | |
203 | dev_entry->common); | |
204 | if (status != SALRET_OK) | |
205 | panic("SAL call failed: %s\n", | |
206 | ia64_sal_strerror(status)); | |
207 | ||
208 | spin_lock_init(&dev_entry->sfdl_flush_lock); | |
209 | } | |
210 | ||
211 | if (sn_flush_device_kernel) | |
212 | hubdev->hdi_flush_nasid_list.widget_p[widget] = | |
213 | sn_flush_device_kernel; | |
214 | } | |
215 | } | |
216 | ||
217 | void sn_pci_unfixup_slot(struct pci_dev *dev) | |
218 | { | |
219 | struct pci_dev *host_pci_dev = SN_PCIDEV_INFO(dev)->host_pci_dev; | |
220 | ||
221 | sn_irq_unfixup(dev); | |
222 | pci_dev_put(host_pci_dev); | |
223 | pci_dev_put(dev); | |
224 | } | |
225 | ||
226 | /* | |
6f09a925 | 227 | * sn_pci_fixup_slot() |
8ea6091f | 228 | */ |
6f09a925 JK |
229 | void sn_pci_fixup_slot(struct pci_dev *dev, struct pcidev_info *pcidev_info, |
230 | struct sn_irq_info *sn_irq_info) | |
8ea6091f JK |
231 | { |
232 | int segment = pci_domain_nr(dev->bus); | |
8ea6091f | 233 | struct pcibus_bussoft *bs; |
6f09a925 JK |
234 | struct pci_bus *host_pci_bus; |
235 | struct pci_dev *host_pci_dev; | |
236 | unsigned int bus_no, devfn; | |
8ea6091f JK |
237 | |
238 | pci_dev_get(dev); /* for the sysdata pointer */ | |
8ea6091f JK |
239 | |
240 | /* Add pcidev_info to list in pci_controller.platform_data */ | |
241 | list_add_tail(&pcidev_info->pdi_list, | |
242 | &(SN_PLATFORM_DATA(dev->bus)->pcidev_info)); | |
8ea6091f JK |
243 | /* |
244 | * Using the PROMs values for the PCI host bus, get the Linux | |
6f09a925 | 245 | * PCI host_pci_dev struct and set up host bus linkages |
8ea6091f JK |
246 | */ |
247 | ||
248 | bus_no = (pcidev_info->pdi_slot_host_handle >> 32) & 0xff; | |
249 | devfn = pcidev_info->pdi_slot_host_handle & 0xffffffff; | |
250 | host_pci_bus = pci_find_bus(segment, bus_no); | |
251 | host_pci_dev = pci_get_slot(host_pci_bus, devfn); | |
252 | ||
253 | pcidev_info->host_pci_dev = host_pci_dev; | |
254 | pcidev_info->pdi_linux_pcidev = dev; | |
255 | pcidev_info->pdi_host_pcidev_info = SN_PCIDEV_INFO(host_pci_dev); | |
256 | bs = SN_PCIBUS_BUSSOFT(dev->bus); | |
257 | pcidev_info->pdi_pcibus_info = bs; | |
258 | ||
259 | if (bs && bs->bs_asic_type < PCIIO_ASIC_MAX_TYPES) { | |
260 | SN_PCIDEV_BUSPROVIDER(dev) = sn_pci_provider[bs->bs_asic_type]; | |
261 | } else { | |
262 | SN_PCIDEV_BUSPROVIDER(dev) = &sn_pci_default_provider; | |
263 | } | |
264 | ||
265 | /* Only set up IRQ stuff if this device has a host bus context */ | |
266 | if (bs && sn_irq_info->irq_irq) { | |
267 | pcidev_info->pdi_sn_irq_info = sn_irq_info; | |
268 | dev->irq = pcidev_info->pdi_sn_irq_info->irq_irq; | |
269 | sn_irq_fixup(dev, sn_irq_info); | |
270 | } else { | |
271 | pcidev_info->pdi_sn_irq_info = NULL; | |
272 | kfree(sn_irq_info); | |
273 | } | |
274 | } | |
275 | ||
276 | /* | |
277 | * sn_common_bus_fixup - Perform platform specific bus fixup. | |
278 | * Execute the ASIC specific fixup routine | |
279 | * for this bus. | |
280 | */ | |
281 | void | |
282 | sn_common_bus_fixup(struct pci_bus *bus, | |
283 | struct pcibus_bussoft *prom_bussoft_ptr) | |
284 | { | |
285 | int cnode; | |
286 | struct pci_controller *controller; | |
287 | struct hubdev_info *hubdev_info; | |
288 | int nasid; | |
289 | void *provider_soft; | |
290 | struct sn_pcibus_provider *provider; | |
291 | struct sn_platform_data *sn_platform_data; | |
292 | ||
293 | controller = PCI_CONTROLLER(bus); | |
294 | /* | |
295 | * Per-provider fixup. Copies the bus soft structure from prom | |
296 | * to local area and links SN_PCIBUS_BUSSOFT(). | |
297 | */ | |
298 | ||
299 | if (prom_bussoft_ptr->bs_asic_type >= PCIIO_ASIC_MAX_TYPES) { | |
300 | printk(KERN_WARNING "sn_common_bus_fixup: Unsupported asic type, %d", | |
301 | prom_bussoft_ptr->bs_asic_type); | |
302 | return; | |
303 | } | |
304 | ||
305 | if (prom_bussoft_ptr->bs_asic_type == PCIIO_ASIC_TYPE_PPB) | |
306 | return; /* no further fixup necessary */ | |
307 | ||
308 | provider = sn_pci_provider[prom_bussoft_ptr->bs_asic_type]; | |
309 | if (provider == NULL) | |
310 | panic("sn_common_bus_fixup: No provider registered for this asic type, %d", | |
311 | prom_bussoft_ptr->bs_asic_type); | |
312 | ||
313 | if (provider->bus_fixup) | |
314 | provider_soft = (*provider->bus_fixup) (prom_bussoft_ptr, | |
315 | controller); | |
316 | else | |
317 | provider_soft = NULL; | |
318 | ||
319 | /* | |
320 | * Generic bus fixup goes here. Don't reference prom_bussoft_ptr | |
321 | * after this point. | |
322 | */ | |
323 | controller->platform_data = kzalloc(sizeof(struct sn_platform_data), | |
324 | GFP_KERNEL); | |
80a03e29 | 325 | BUG_ON(controller->platform_data == NULL); |
8ea6091f JK |
326 | sn_platform_data = |
327 | (struct sn_platform_data *) controller->platform_data; | |
328 | sn_platform_data->provider_soft = provider_soft; | |
329 | INIT_LIST_HEAD(&((struct sn_platform_data *) | |
330 | controller->platform_data)->pcidev_info); | |
331 | nasid = NASID_GET(SN_PCIBUS_BUSSOFT(bus)->bs_base); | |
332 | cnode = nasid_to_cnodeid(nasid); | |
333 | hubdev_info = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo); | |
334 | SN_PCIBUS_BUSSOFT(bus)->bs_xwidget_info = | |
335 | &(hubdev_info->hdi_xwidget_info[SN_PCIBUS_BUSSOFT(bus)->bs_xid]); | |
336 | ||
337 | /* | |
338 | * If the node information we obtained during the fixup phase is | |
339 | * invalid then set controller->node to -1 (undetermined) | |
340 | */ | |
341 | if (controller->node >= num_online_nodes()) { | |
342 | struct pcibus_bussoft *b = SN_PCIBUS_BUSSOFT(bus); | |
343 | ||
c2eeb321 | 344 | printk(KERN_WARNING "Device ASIC=%u XID=%u PBUSNUM=%u " |
e088a4ad | 345 | "L_IO=%llx L_MEM=%llx BASE=%llx\n", |
8ea6091f JK |
346 | b->bs_asic_type, b->bs_xid, b->bs_persist_busnum, |
347 | b->bs_legacy_io, b->bs_legacy_mem, b->bs_base); | |
348 | printk(KERN_WARNING "on node %d but only %d nodes online." | |
349 | "Association set to undetermined.\n", | |
350 | controller->node, num_online_nodes()); | |
351 | controller->node = -1; | |
352 | } | |
353 | } | |
354 | ||
355 | void sn_bus_store_sysdata(struct pci_dev *dev) | |
356 | { | |
357 | struct sysdata_el *element; | |
358 | ||
359 | element = kzalloc(sizeof(struct sysdata_el), GFP_KERNEL); | |
360 | if (!element) { | |
d4ed8084 | 361 | dev_dbg(&dev->dev, "%s: out of memory!\n", __func__); |
8ea6091f JK |
362 | return; |
363 | } | |
364 | element->sysdata = SN_PCIDEV_INFO(dev); | |
365 | list_add(&element->entry, &sn_sysdata_list); | |
366 | } | |
367 | ||
368 | void sn_bus_free_sysdata(void) | |
369 | { | |
370 | struct sysdata_el *element; | |
371 | struct list_head *list, *safe; | |
372 | ||
373 | list_for_each_safe(list, safe, &sn_sysdata_list) { | |
374 | element = list_entry(list, struct sysdata_el, entry); | |
375 | list_del(&element->entry); | |
376 | list_del(&(((struct pcidev_info *) | |
377 | (element->sysdata))->pdi_list)); | |
378 | kfree(element->sysdata); | |
379 | kfree(element); | |
380 | } | |
381 | return; | |
382 | } | |
383 | ||
384 | /* | |
385 | * hubdev_init_node() - Creates the HUB data structure and link them to it's | |
386 | * own NODE specific data area. | |
387 | */ | |
056e6d89 | 388 | void __init hubdev_init_node(nodepda_t * npda, cnodeid_t node) |
8ea6091f JK |
389 | { |
390 | struct hubdev_info *hubdev_info; | |
391 | int size; | |
392 | pg_data_t *pg; | |
393 | ||
394 | size = sizeof(struct hubdev_info); | |
395 | ||
396 | if (node >= num_online_nodes()) /* Headless/memless IO nodes */ | |
397 | pg = NODE_DATA(0); | |
398 | else | |
399 | pg = NODE_DATA(node); | |
400 | ||
401 | hubdev_info = (struct hubdev_info *)alloc_bootmem_node(pg, size); | |
402 | ||
403 | npda->pdinfo = (void *)hubdev_info; | |
404 | } | |
405 | ||
406 | geoid_t | |
407 | cnodeid_get_geoid(cnodeid_t cnode) | |
408 | { | |
409 | struct hubdev_info *hubdev; | |
410 | ||
411 | hubdev = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo); | |
412 | return hubdev->hdi_geoid; | |
413 | } | |
414 | ||
415 | void sn_generate_path(struct pci_bus *pci_bus, char *address) | |
416 | { | |
417 | nasid_t nasid; | |
418 | cnodeid_t cnode; | |
419 | geoid_t geoid; | |
420 | moduleid_t moduleid; | |
421 | u16 bricktype; | |
422 | ||
423 | nasid = NASID_GET(SN_PCIBUS_BUSSOFT(pci_bus)->bs_base); | |
424 | cnode = nasid_to_cnodeid(nasid); | |
425 | geoid = cnodeid_get_geoid(cnode); | |
426 | moduleid = geo_module(geoid); | |
427 | ||
428 | sprintf(address, "module_%c%c%c%c%.2d", | |
429 | '0'+RACK_GET_CLASS(MODULE_GET_RACK(moduleid)), | |
430 | '0'+RACK_GET_GROUP(MODULE_GET_RACK(moduleid)), | |
431 | '0'+RACK_GET_NUM(MODULE_GET_RACK(moduleid)), | |
432 | MODULE_GET_BTCHAR(moduleid), MODULE_GET_BPOS(moduleid)); | |
433 | ||
434 | /* Tollhouse requires slot id to be displayed */ | |
435 | bricktype = MODULE_GET_BTYPE(moduleid); | |
436 | if ((bricktype == L1_BRICKTYPE_191010) || | |
437 | (bricktype == L1_BRICKTYPE_1932)) | |
2be8412c AC |
438 | sprintf(address + strlen(address), "^%d", |
439 | geo_slot(geoid)); | |
8ea6091f JK |
440 | } |
441 | ||
8ea6091f JK |
442 | void __devinit |
443 | sn_pci_fixup_bus(struct pci_bus *bus) | |
444 | { | |
445 | ||
647fb47d | 446 | if (SN_ACPI_BASE_SUPPORT()) |
8ea6091f JK |
447 | sn_acpi_bus_fixup(bus); |
448 | else | |
449 | sn_bus_fixup(bus); | |
450 | } | |
451 | ||
452 | /* | |
453 | * sn_io_early_init - Perform early IO (and some non-IO) initialization. | |
454 | * In particular, setup the sn_pci_provider[] array. | |
455 | * This needs to be done prior to any bus scanning | |
456 | * (acpi_scan_init()) in the ACPI case, as the SN | |
457 | * bus fixup code will reference the array. | |
458 | */ | |
459 | static int __init | |
460 | sn_io_early_init(void) | |
461 | { | |
462 | int i; | |
463 | ||
464 | if (!ia64_platform_is("sn2") || IS_RUNNING_ON_FAKE_PROM()) | |
465 | return 0; | |
466 | ||
6f09a925 JK |
467 | /* we set the acpi revision to that of the DSDT table OEM rev. */ |
468 | { | |
469 | struct acpi_table_header *header = NULL; | |
470 | ||
385c4d98 | 471 | acpi_get_table(ACPI_SIG_DSDT, 1, &header); |
6f09a925 JK |
472 | BUG_ON(header == NULL); |
473 | sn_acpi_rev = header->oem_revision; | |
474 | } | |
475 | ||
8ea6091f | 476 | /* |
72fdbdce | 477 | * prime sn_pci_provider[]. Individual provider init routines will |
8ea6091f JK |
478 | * override their respective default entries. |
479 | */ | |
480 | ||
481 | for (i = 0; i < PCIIO_ASIC_MAX_TYPES; i++) | |
482 | sn_pci_provider[i] = &sn_pci_default_provider; | |
483 | ||
484 | pcibr_init_provider(); | |
485 | tioca_init_provider(); | |
486 | tioce_init_provider(); | |
487 | ||
488 | /* | |
489 | * This is needed to avoid bounce limit checks in the blk layer | |
490 | */ | |
491 | ia64_max_iommu_merge_mask = ~PAGE_MASK; | |
492 | ||
493 | sn_irq_lh_init(); | |
494 | INIT_LIST_HEAD(&sn_sysdata_list); | |
495 | sn_init_cpei_timer(); | |
496 | ||
497 | #ifdef CONFIG_PROC_FS | |
498 | register_sn_procfs(); | |
499 | #endif | |
500 | ||
647fb47d LB |
501 | { |
502 | struct acpi_table_header *header; | |
385c4d98 | 503 | (void)acpi_get_table(ACPI_SIG_DSDT, 1, &header); |
647fb47d LB |
504 | printk(KERN_INFO "ACPI DSDT OEM Rev 0x%x\n", |
505 | header->oem_revision); | |
506 | } | |
507 | if (SN_ACPI_BASE_SUPPORT()) | |
8ea6091f JK |
508 | sn_io_acpi_init(); |
509 | else | |
510 | sn_io_init(); | |
511 | return 0; | |
512 | } | |
513 | ||
514 | arch_initcall(sn_io_early_init); | |
515 | ||
516 | /* | |
517 | * sn_io_late_init() - Perform any final platform specific IO initialization. | |
518 | */ | |
519 | ||
520 | int __init | |
521 | sn_io_late_init(void) | |
522 | { | |
523 | struct pci_bus *bus; | |
524 | struct pcibus_bussoft *bussoft; | |
525 | cnodeid_t cnode; | |
526 | nasid_t nasid; | |
527 | cnodeid_t near_cnode; | |
528 | ||
529 | if (!ia64_platform_is("sn2") || IS_RUNNING_ON_FAKE_PROM()) | |
530 | return 0; | |
531 | ||
532 | /* | |
533 | * Setup closest node in pci_controller->node for | |
534 | * PIC, TIOCP, TIOCE (TIOCA does it during bus fixup using | |
535 | * info from the PROM). | |
536 | */ | |
537 | bus = NULL; | |
538 | while ((bus = pci_find_next_bus(bus)) != NULL) { | |
539 | bussoft = SN_PCIBUS_BUSSOFT(bus); | |
540 | nasid = NASID_GET(bussoft->bs_base); | |
541 | cnode = nasid_to_cnodeid(nasid); | |
542 | if ((bussoft->bs_asic_type == PCIIO_ASIC_TYPE_TIOCP) || | |
afc2cf35 MH |
543 | (bussoft->bs_asic_type == PCIIO_ASIC_TYPE_TIOCE) || |
544 | (bussoft->bs_asic_type == PCIIO_ASIC_TYPE_PIC)) { | |
545 | /* PCI Bridge: find nearest node with CPUs */ | |
8ea6091f JK |
546 | int e = sn_hwperf_get_nearest_node(cnode, NULL, |
547 | &near_cnode); | |
548 | if (e < 0) { | |
549 | near_cnode = (cnodeid_t)-1; /* use any node */ | |
afc2cf35 MH |
550 | printk(KERN_WARNING "sn_io_late_init: failed " |
551 | "to find near node with CPUs for " | |
8ea6091f JK |
552 | "node %d, err=%d\n", cnode, e); |
553 | } | |
554 | PCI_CONTROLLER(bus)->node = near_cnode; | |
8ea6091f JK |
555 | } |
556 | } | |
557 | ||
558 | sn_ioif_inited = 1; /* SN I/O infrastructure now initialized */ | |
559 | ||
560 | return 0; | |
561 | } | |
562 | ||
563 | fs_initcall(sn_io_late_init); | |
564 | ||
8ea6091f JK |
565 | EXPORT_SYMBOL(sn_pci_unfixup_slot); |
566 | EXPORT_SYMBOL(sn_bus_store_sysdata); | |
567 | EXPORT_SYMBOL(sn_bus_free_sysdata); | |
568 | EXPORT_SYMBOL(sn_generate_path); | |
569 |