source: trunk/packages/xen-3.1/xen-3.1/xen/arch/ia64/linux-xen/sn/kernel/io_init.c @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

File size: 20.6 KB
Line 
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
9#include <linux/bootmem.h>
10#include <linux/nodemask.h>
11#ifdef XEN
12#include <linux/init.h>
13#endif
14#include <asm/sn/types.h>
15#include <asm/sn/addrs.h>
16#include <asm/sn/sn_feature_sets.h>
17#include <asm/sn/geo.h>
18#include <asm/sn/io.h>
19#include <asm/sn/l1.h>
20#include <asm/sn/module.h>
21#include <asm/sn/pcibr_provider.h>
22#include <asm/sn/pcibus_provider_defs.h>
23#include <asm/sn/pcidev.h>
24#include <asm/sn/simulator.h>
25#include <asm/sn/sn_sal.h>
26#ifndef XEN
27#include <asm/sn/tioca_provider.h>
28#include <asm/sn/tioce_provider.h>
29#endif
30#ifdef XEN
31#include "asm/sn/hubdev.h"
32#include "asm/sn/xwidgetdev.h"
33#else
34#include "xtalk/hubdev.h"
35#include "xtalk/xwidgetdev.h"
36#endif
37
38
39extern void sn_init_cpei_timer(void);
40extern void register_sn_procfs(void);
41#ifdef XEN
42#define pci_dev_get(dev)        do{}while(0)
43extern void sn_irq_lh_init(void);
44#endif
45
46static struct list_head sn_sysdata_list;
47
48/* sysdata list struct */
49struct sysdata_el {
50        struct list_head entry;
51        void *sysdata;
52};
53
54struct slab_info {
55        struct hubdev_info hubdev;
56};
57
58struct brick {
59        moduleid_t id;          /* Module ID of this module        */
60        struct slab_info slab_info[MAX_SLABS + 1];
61};
62
63int sn_ioif_inited;             /* SN I/O infrastructure initialized? */
64
65struct sn_pcibus_provider *sn_pci_provider[PCIIO_ASIC_MAX_TYPES];       /* indexed by asic type */
66
67static int max_segment_number;           /* Default highest segment number */
68static int max_pcibus_number = 255;     /* Default highest pci bus number */
69
70/*
71 * Hooks and struct for unsupported pci providers
72 */
73
74static dma_addr_t
75sn_default_pci_map(struct pci_dev *pdev, unsigned long paddr, size_t size, int type)
76{
77        return 0;
78}
79
80static void
81sn_default_pci_unmap(struct pci_dev *pdev, dma_addr_t addr, int direction)
82{
83        return;
84}
85
86static void *
87sn_default_pci_bus_fixup(struct pcibus_bussoft *soft, struct pci_controller *controller)
88{
89        return NULL;
90}
91
92static struct sn_pcibus_provider sn_pci_default_provider = {
93        .dma_map = sn_default_pci_map,
94        .dma_map_consistent = sn_default_pci_map,
95        .dma_unmap = sn_default_pci_unmap,
96        .bus_fixup = sn_default_pci_bus_fixup,
97};
98
99/*
100 * Retrieve the DMA Flush List given nasid, widget, and device.
101 * This list is needed to implement the WAR - Flush DMA data on PIO Reads.
102 */
103static inline u64
104sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num,
105                             u64 address)
106{
107        struct ia64_sal_retval ret_stuff;
108        ret_stuff.status = 0;
109        ret_stuff.v0 = 0;
110
111        SAL_CALL_NOLOCK(ret_stuff,
112                        (u64) SN_SAL_IOIF_GET_DEVICE_DMAFLUSH_LIST,
113                        (u64) nasid, (u64) widget_num,
114                        (u64) device_num, (u64) address, 0, 0, 0);
115        return ret_stuff.status;
116}
117
118/*
119 * Retrieve the hub device info structure for the given nasid.
120 */
121static inline u64 sal_get_hubdev_info(u64 handle, u64 address)
122{
123        struct ia64_sal_retval ret_stuff;
124        ret_stuff.status = 0;
125        ret_stuff.v0 = 0;
126
127        SAL_CALL_NOLOCK(ret_stuff,
128                        (u64) SN_SAL_IOIF_GET_HUBDEV_INFO,
129                        (u64) handle, (u64) address, 0, 0, 0, 0, 0);
130        return ret_stuff.v0;
131}
132
133/*
134 * Retrieve the pci bus information given the bus number.
135 */
136static inline u64 sal_get_pcibus_info(u64 segment, u64 busnum, u64 address)
137{
138        struct ia64_sal_retval ret_stuff;
139        ret_stuff.status = 0;
140        ret_stuff.v0 = 0;
141
142        SAL_CALL_NOLOCK(ret_stuff,
143                        (u64) SN_SAL_IOIF_GET_PCIBUS_INFO,
144                        (u64) segment, (u64) busnum, (u64) address, 0, 0, 0, 0);
145        return ret_stuff.v0;
146}
147
148/*
149 * Retrieve the pci device information given the bus and device|function number.
150 */
151static inline u64
152sal_get_pcidev_info(u64 segment, u64 bus_number, u64 devfn, u64 pci_dev,
153                    u64 sn_irq_info)
154{
155        struct ia64_sal_retval ret_stuff;
156        ret_stuff.status = 0;
157        ret_stuff.v0 = 0;
158
159        SAL_CALL_NOLOCK(ret_stuff,
160                        (u64) SN_SAL_IOIF_GET_PCIDEV_INFO,
161                        (u64) segment, (u64) bus_number, (u64) devfn,
162                        (u64) pci_dev,
163                        sn_irq_info, 0, 0);
164        return ret_stuff.v0;
165}
166
167#ifndef XEN
168/*
169 * sn_pcidev_info_get() - Retrieve the pcidev_info struct for the specified
170 *                        device.
171 */
172inline struct pcidev_info *
173sn_pcidev_info_get(struct pci_dev *dev)
174{
175        struct pcidev_info *pcidev;
176
177        list_for_each_entry(pcidev,
178                            &(SN_PCI_CONTROLLER(dev)->pcidev_info), pdi_list) {
179                if (pcidev->pdi_linux_pcidev == dev) {
180                        return pcidev;
181                }
182        }
183        return NULL;
184}
185
186/* Older PROM flush WAR
187 *
188 * 01/16/06 -- This war will be in place until a new official PROM is released.
189 * Additionally note that the struct sn_flush_device_war also has to be
190 * removed from arch/ia64/sn/include/xtalk/hubdev.h
191 */
192static u8 war_implemented = 0;
193
194static s64 sn_device_fixup_war(u64 nasid, u64 widget, int device,
195                               struct sn_flush_device_common *common)
196{
197        struct sn_flush_device_war *war_list;
198        struct sn_flush_device_war *dev_entry;
199        struct ia64_sal_retval isrv = {0,0,0,0};
200
201        if (!war_implemented) {
202                printk(KERN_WARNING "PROM version < 4.50 -- implementing old "
203                       "PROM flush WAR\n");
204                war_implemented = 1;
205        }
206
207        war_list = kzalloc(DEV_PER_WIDGET * sizeof(*war_list), GFP_KERNEL);
208        if (!war_list)
209                BUG();
210
211        SAL_CALL_NOLOCK(isrv, SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST,
212                        nasid, widget, __pa(war_list), 0, 0, 0 ,0);
213        if (isrv.status)
214                panic("sn_device_fixup_war failed: %s\n",
215                      ia64_sal_strerror(isrv.status));
216
217        dev_entry = war_list + device;
218        memcpy(common,dev_entry, sizeof(*common));
219        kfree(war_list);
220
221        return isrv.status;
222}
223
224/*
225 * sn_fixup_ionodes() - This routine initializes the HUB data strcuture for
226 *      each node in the system.
227 */
228static void __init sn_fixup_ionodes(void)
229{
230        struct sn_flush_device_kernel *sn_flush_device_kernel;
231        struct sn_flush_device_kernel *dev_entry;
232        struct hubdev_info *hubdev;
233        u64 status;
234        u64 nasid;
235        int i, widget, device, size;
236
237        /*
238         * Get SGI Specific HUB chipset information.
239         * Inform Prom that this kernel can support domain bus numbering.
240         */
241        for (i = 0; i < num_cnodes; i++) {
242                hubdev = (struct hubdev_info *)(NODEPDA(i)->pdinfo);
243                nasid = cnodeid_to_nasid(i);
244                hubdev->max_segment_number = 0xffffffff;
245                hubdev->max_pcibus_number = 0xff;
246                status = sal_get_hubdev_info(nasid, (u64) __pa(hubdev));
247                if (status)
248                        continue;
249
250                /* Save the largest Domain and pcibus numbers found. */
251                if (hubdev->max_segment_number) {
252                        /*
253                         * Dealing with a Prom that supports segments.
254                         */
255                        max_segment_number = hubdev->max_segment_number;
256                        max_pcibus_number = hubdev->max_pcibus_number;
257                }
258
259                /* Attach the error interrupt handlers */
260                if (nasid & 1)
261                        ice_error_init(hubdev);
262                else
263                        hub_error_init(hubdev);
264
265                for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++)
266                        hubdev->hdi_xwidget_info[widget].xwi_hubinfo = hubdev;
267
268                if (!hubdev->hdi_flush_nasid_list.widget_p)
269                        continue;
270
271                size = (HUB_WIDGET_ID_MAX + 1) *
272                        sizeof(struct sn_flush_device_kernel *);
273                hubdev->hdi_flush_nasid_list.widget_p =
274                        kzalloc(size, GFP_KERNEL);
275                if (!hubdev->hdi_flush_nasid_list.widget_p)
276                        BUG();
277
278                for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) {
279                        size = DEV_PER_WIDGET *
280                                sizeof(struct sn_flush_device_kernel);
281                        sn_flush_device_kernel = kzalloc(size, GFP_KERNEL);
282                        if (!sn_flush_device_kernel)
283                                BUG();
284
285                        dev_entry = sn_flush_device_kernel;
286                        for (device = 0; device < DEV_PER_WIDGET;
287                             device++,dev_entry++) {
288                                size = sizeof(struct sn_flush_device_common);
289                                dev_entry->common = kzalloc(size, GFP_KERNEL);
290                                if (!dev_entry->common)
291                                        BUG();
292
293                                if (sn_prom_feature_available(
294                                                       PRF_DEVICE_FLUSH_LIST))
295                                        status = sal_get_device_dmaflush_list(
296                                                     nasid, widget, device,
297                                                     (u64)(dev_entry->common));
298                                else
299#ifdef XEN
300                                        BUG();
301#else
302                                        status = sn_device_fixup_war(nasid,
303                                                     widget, device,
304                                                     dev_entry->common);
305#endif
306                                if (status != SALRET_OK)
307                                        panic("SAL call failed: %s\n",
308                                              ia64_sal_strerror(status));
309
310                                spin_lock_init(&dev_entry->sfdl_flush_lock);
311                        }
312
313                        if (sn_flush_device_kernel)
314                                hubdev->hdi_flush_nasid_list.widget_p[widget] =
315                                                       sn_flush_device_kernel;
316                }
317        }
318}
319
320/*
321 * sn_pci_window_fixup() - Create a pci_window for each device resource.
322 *                         Until ACPI support is added, we need this code
323 *                         to setup pci_windows for use by
324 *                         pcibios_bus_to_resource(),
325 *                         pcibios_resource_to_bus(), etc.
326 */
327static void
328sn_pci_window_fixup(struct pci_dev *dev, unsigned int count,
329                    s64 * pci_addrs)
330{
331        struct pci_controller *controller = PCI_CONTROLLER(dev->bus);
332        unsigned int i;
333        unsigned int idx;
334        unsigned int new_count;
335        struct pci_window *new_window;
336
337        if (count == 0)
338                return;
339        idx = controller->windows;
340        new_count = controller->windows + count;
341        new_window = kcalloc(new_count, sizeof(struct pci_window), GFP_KERNEL);
342        if (new_window == NULL)
343                BUG();
344        if (controller->window) {
345                memcpy(new_window, controller->window,
346                       sizeof(struct pci_window) * controller->windows);
347                kfree(controller->window);
348        }
349
350        /* Setup a pci_window for each device resource. */
351        for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
352                if (pci_addrs[i] == -1)
353                        continue;
354
355                new_window[idx].offset = dev->resource[i].start - pci_addrs[i];
356                new_window[idx].resource = dev->resource[i];
357                idx++;
358        }
359
360        controller->windows = new_count;
361        controller->window = new_window;
362}
363
364void sn_pci_unfixup_slot(struct pci_dev *dev)
365{
366        struct pci_dev *host_pci_dev = SN_PCIDEV_INFO(dev)->host_pci_dev;
367
368        sn_irq_unfixup(dev);
369        pci_dev_put(host_pci_dev);
370        pci_dev_put(dev);
371}
372#endif
373
374#ifndef XEN
375/*
376 * sn_pci_fixup_slot() - This routine sets up a slot's resources
377 * consistent with the Linux PCI abstraction layer.  Resources acquired
378 * from our PCI provider include PIO maps to BAR space and interrupt
379 * objects.
380 */
381void sn_pci_fixup_slot(struct pci_dev *dev)
382{
383        unsigned int count = 0;
384        int idx;
385        int segment = pci_domain_nr(dev->bus);
386        int status = 0;
387        struct pcibus_bussoft *bs;
388        struct pci_bus *host_pci_bus;
389        struct pci_dev *host_pci_dev;
390        struct pcidev_info *pcidev_info;
391        s64 pci_addrs[PCI_ROM_RESOURCE + 1];
392        struct sn_irq_info *sn_irq_info;
393        unsigned long size;
394        unsigned int bus_no, devfn;
395
396        pci_dev_get(dev); /* for the sysdata pointer */
397        pcidev_info = kzalloc(sizeof(struct pcidev_info), GFP_KERNEL);
398        if (!pcidev_info)
399                BUG();          /* Cannot afford to run out of memory */
400
401        sn_irq_info = kzalloc(sizeof(struct sn_irq_info), GFP_KERNEL);
402        if (!sn_irq_info)
403                BUG();          /* Cannot afford to run out of memory */
404
405        /* Call to retrieve pci device information needed by kernel. */
406        status = sal_get_pcidev_info((u64) segment, (u64) dev->bus->number, 
407                                     dev->devfn,
408                                     (u64) __pa(pcidev_info),
409                                     (u64) __pa(sn_irq_info));
410        if (status)
411                BUG(); /* Cannot get platform pci device information */
412
413        /* Add pcidev_info to list in sn_pci_controller struct */
414        list_add_tail(&pcidev_info->pdi_list,
415                      &(SN_PCI_CONTROLLER(dev->bus)->pcidev_info));
416
417        /* Copy over PIO Mapped Addresses */
418        for (idx = 0; idx <= PCI_ROM_RESOURCE; idx++) {
419                unsigned long start, end, addr;
420
421                if (!pcidev_info->pdi_pio_mapped_addr[idx]) {
422                        pci_addrs[idx] = -1;
423                        continue;
424                }
425
426                start = dev->resource[idx].start;
427                end = dev->resource[idx].end;
428                size = end - start;
429                if (size == 0) {
430                        pci_addrs[idx] = -1;
431                        continue;
432                }
433                pci_addrs[idx] = start;
434                count++;
435                addr = pcidev_info->pdi_pio_mapped_addr[idx];
436                addr = ((addr << 4) >> 4) | __IA64_UNCACHED_OFFSET;
437                dev->resource[idx].start = addr;
438                dev->resource[idx].end = addr + size;
439#ifndef XEN
440                if (dev->resource[idx].flags & IORESOURCE_IO)
441                        dev->resource[idx].parent = &ioport_resource;
442                else
443                        dev->resource[idx].parent = &iomem_resource;
444#endif
445        }
446        /* Create a pci_window in the pci_controller struct for
447         * each device resource.
448         */
449        if (count > 0)
450                sn_pci_window_fixup(dev, count, pci_addrs);
451
452        /*
453         * Using the PROMs values for the PCI host bus, get the Linux
454         * PCI host_pci_dev struct and set up host bus linkages
455         */
456
457        bus_no = (pcidev_info->pdi_slot_host_handle >> 32) & 0xff;
458        devfn = pcidev_info->pdi_slot_host_handle & 0xffffffff;
459        host_pci_bus = pci_find_bus(segment, bus_no);
460        host_pci_dev = pci_get_slot(host_pci_bus, devfn);
461
462        pcidev_info->host_pci_dev = host_pci_dev;
463        pcidev_info->pdi_linux_pcidev = dev;
464        pcidev_info->pdi_host_pcidev_info = SN_PCIDEV_INFO(host_pci_dev);
465        bs = SN_PCIBUS_BUSSOFT(dev->bus);
466        pcidev_info->pdi_pcibus_info = bs;
467
468        if (bs && bs->bs_asic_type < PCIIO_ASIC_MAX_TYPES) {
469                SN_PCIDEV_BUSPROVIDER(dev) = sn_pci_provider[bs->bs_asic_type];
470        } else {
471                SN_PCIDEV_BUSPROVIDER(dev) = &sn_pci_default_provider;
472        }
473
474        /* Only set up IRQ stuff if this device has a host bus context */
475        if (bs && sn_irq_info->irq_irq) {
476                pcidev_info->pdi_sn_irq_info = sn_irq_info;
477                dev->irq = pcidev_info->pdi_sn_irq_info->irq_irq;
478                sn_irq_fixup(dev, sn_irq_info);
479        } else {
480                pcidev_info->pdi_sn_irq_info = NULL;
481                kfree(sn_irq_info);
482        }
483}
484#endif
485
486/*
487 * sn_pci_controller_fixup() - This routine sets up a bus's resources
488 * consistent with the Linux PCI abstraction layer.
489 */
490void sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
491{
492        int status;
493        int nasid, cnode;
494        struct pci_controller *controller;
495        struct sn_pci_controller *sn_controller;
496        struct pcibus_bussoft *prom_bussoft_ptr;
497        struct hubdev_info *hubdev_info;
498        void *provider_soft;
499        struct sn_pcibus_provider *provider;
500
501        status = sal_get_pcibus_info((u64) segment, (u64) busnum,
502                                     (u64) ia64_tpa(&prom_bussoft_ptr));
503        if (status > 0)
504                return;         /*bus # does not exist */
505        prom_bussoft_ptr = __va(prom_bussoft_ptr);
506
507        /* Allocate a sn_pci_controller, which has a pci_controller struct
508         * as the first member.
509         */
510        sn_controller = kzalloc(sizeof(struct sn_pci_controller), GFP_KERNEL);
511        if (!sn_controller)
512                BUG();
513        INIT_LIST_HEAD(&sn_controller->pcidev_info);
514        controller = &sn_controller->pci_controller;
515        controller->segment = segment;
516
517#ifndef XEN
518        if (bus == NULL) {
519                bus = pci_scan_bus(busnum, &pci_root_ops, controller);
520                if (bus == NULL)
521                        goto error_return; /* error, or bus already scanned */
522                bus->sysdata = NULL;
523        }
524
525        if (bus->sysdata)
526                goto error_return; /* sysdata already alloc'd */
527
528        /*
529         * Per-provider fixup.  Copies the contents from prom to local
530         * area and links SN_PCIBUS_BUSSOFT().
531         */
532
533        if (prom_bussoft_ptr->bs_asic_type >= PCIIO_ASIC_MAX_TYPES)
534                goto error_return; /* unsupported asic type */
535
536        if (prom_bussoft_ptr->bs_asic_type == PCIIO_ASIC_TYPE_PPB)
537                goto error_return; /* no further fixup necessary */
538
539#endif
540        provider = sn_pci_provider[prom_bussoft_ptr->bs_asic_type];
541        if (provider == NULL)
542                goto error_return; /* no provider registerd for this asic */
543
544        bus->sysdata = controller;
545        if (provider->bus_fixup)
546                provider_soft = (*provider->bus_fixup) (prom_bussoft_ptr, controller);
547        else
548                provider_soft = NULL;
549
550        if (provider_soft == NULL) {
551                /* fixup failed or not applicable */
552                bus->sysdata = NULL;
553                goto error_return;
554        }
555
556        /*
557         * Setup pci_windows for legacy IO and MEM space.
558         * (Temporary until ACPI support is in place.)
559         */
560        controller->window = kcalloc(2, sizeof(struct pci_window), GFP_KERNEL);
561        if (controller->window == NULL)
562                BUG();
563        controller->window[0].offset = prom_bussoft_ptr->bs_legacy_io;
564        controller->window[0].resource.name = "legacy_io";
565        controller->window[0].resource.flags = IORESOURCE_IO;
566        controller->window[0].resource.start = prom_bussoft_ptr->bs_legacy_io;
567        controller->window[0].resource.end =
568            controller->window[0].resource.start + 0xffff;
569#ifndef XEN
570        controller->window[0].resource.parent = &ioport_resource;
571#endif
572        controller->window[1].offset = prom_bussoft_ptr->bs_legacy_mem;
573        controller->window[1].resource.name = "legacy_mem";
574        controller->window[1].resource.flags = IORESOURCE_MEM;
575        controller->window[1].resource.start = prom_bussoft_ptr->bs_legacy_mem;
576        controller->window[1].resource.end =
577            controller->window[1].resource.start + (1024 * 1024) - 1;
578#ifndef XEN
579        controller->window[1].resource.parent = &iomem_resource;
580#endif
581        controller->windows = 2;
582
583        /*
584         * Generic bus fixup goes here.  Don't reference prom_bussoft_ptr
585         * after this point.
586         */
587
588        PCI_CONTROLLER(bus)->platform_data = provider_soft;
589        nasid = NASID_GET(SN_PCIBUS_BUSSOFT(bus)->bs_base);
590        cnode = nasid_to_cnodeid(nasid);
591        hubdev_info = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo);
592        SN_PCIBUS_BUSSOFT(bus)->bs_xwidget_info =
593            &(hubdev_info->hdi_xwidget_info[SN_PCIBUS_BUSSOFT(bus)->bs_xid]);
594
595        /*
596         * If the node information we obtained during the fixup phase is invalid
597         * then set controller->node to -1 (undetermined)
598         */
599        if (controller->node >= num_online_nodes()) {
600                struct pcibus_bussoft *b = SN_PCIBUS_BUSSOFT(bus);
601
602                printk(KERN_WARNING "Device ASIC=%u XID=%u PBUSNUM=%u"
603                                    "L_IO=%lx L_MEM=%lx BASE=%lx\n",
604                        b->bs_asic_type, b->bs_xid, b->bs_persist_busnum,
605                        b->bs_legacy_io, b->bs_legacy_mem, b->bs_base);
606                printk(KERN_WARNING "on node %d but only %d nodes online."
607                        "Association set to undetermined.\n",
608                        controller->node, num_online_nodes());
609                controller->node = -1;
610        }
611        return;
612
613error_return:
614
615        kfree(sn_controller);
616        return;
617}
618
619#ifndef XEN
620void sn_bus_store_sysdata(struct pci_dev *dev)
621{
622        struct sysdata_el *element;
623
624        element = kzalloc(sizeof(struct sysdata_el), GFP_KERNEL);
625        if (!element) {
626                dev_dbg(dev, "%s: out of memory!\n", __FUNCTION__);
627                return;
628        }
629        element->sysdata = SN_PCIDEV_INFO(dev);
630        list_add(&element->entry, &sn_sysdata_list);
631}
632
633void sn_bus_free_sysdata(void)
634{
635        struct sysdata_el *element;
636        struct list_head *list, *safe;
637
638        list_for_each_safe(list, safe, &sn_sysdata_list) {
639                element = list_entry(list, struct sysdata_el, entry);
640                list_del(&element->entry);
641                list_del(&(((struct pcidev_info *)
642                             (element->sysdata))->pdi_list));
643                kfree(element->sysdata);
644                kfree(element);
645        }
646        return;
647}
648#endif
649
650/*
651 * Ugly hack to get PCI setup until we have a proper ACPI namespace.
652 */
653
654#define PCI_BUSES_TO_SCAN 256
655
656static int __init sn_io_early_init(void)
657{
658        int i, j;
659#ifndef XEN
660        struct pci_dev *pci_dev = NULL;
661#endif
662
663        if (!ia64_platform_is("sn2") || IS_RUNNING_ON_FAKE_PROM())
664                return 0;
665
666        /*
667         * prime sn_pci_provider[].  Individial provider init routines will
668         * override their respective default entries.
669         */
670
671        for (i = 0; i < PCIIO_ASIC_MAX_TYPES; i++)
672                sn_pci_provider[i] = &sn_pci_default_provider;
673
674#ifndef XEN
675        pcibr_init_provider();
676        tioca_init_provider();
677        tioce_init_provider();
678#endif
679
680        /*
681         * This is needed to avoid bounce limit checks in the blk layer
682         */
683        ia64_max_iommu_merge_mask = ~PAGE_MASK;
684#ifndef XEN
685        sn_fixup_ionodes();
686#endif
687        sn_irq_lh_init();
688        INIT_LIST_HEAD(&sn_sysdata_list);
689#ifndef XEN
690        sn_init_cpei_timer();
691
692#ifdef CONFIG_PROC_FS
693        register_sn_procfs();
694#endif
695#endif
696        /* busses are not known yet ... */
697        for (i = 0; i <= max_segment_number; i++)
698                for (j = 0; j <= max_pcibus_number; j++)
699                        sn_pci_controller_fixup(i, j, NULL);
700
701        /*
702         * Generic Linux PCI Layer has created the pci_bus and pci_dev
703         * structures - time for us to add our SN PLatform specific
704         * information.
705         */
706
707#ifndef XEN
708        while ((pci_dev =
709                pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) != NULL)
710                sn_pci_fixup_slot(pci_dev);
711#endif
712
713        sn_ioif_inited = 1;     /* sn I/O infrastructure now initialized */
714
715        return 0;
716}
717
718/*
719 * hubdev_init_node() - Creates the HUB data structure and link them to it's
720 *      own NODE specific data area.
721 */
722void hubdev_init_node(nodepda_t * npda, cnodeid_t node)
723{
724        struct hubdev_info *hubdev_info;
725        int size;
726#ifndef XEN
727        pg_data_t *pg;
728#else
729        struct pglist_data *pg;
730#endif
731
732        size = sizeof(struct hubdev_info);
733
734        if (node >= num_online_nodes()) /* Headless/memless IO nodes */
735                pg = NODE_DATA(0);
736        else
737                pg = NODE_DATA(node);
738
739        hubdev_info = (struct hubdev_info *)alloc_bootmem_node(pg, size);
740
741        npda->pdinfo = (void *)hubdev_info;
742}
743
744geoid_t
745cnodeid_get_geoid(cnodeid_t cnode)
746{
747        struct hubdev_info *hubdev;
748
749        hubdev = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo);
750        return hubdev->hdi_geoid;
751}
752
753#ifndef XEN
754void sn_generate_path(struct pci_bus *pci_bus, char *address)
755{
756        nasid_t nasid;
757        cnodeid_t cnode;
758        geoid_t geoid;
759        moduleid_t moduleid;
760        u16 bricktype;
761
762        nasid = NASID_GET(SN_PCIBUS_BUSSOFT(pci_bus)->bs_base);
763        cnode = nasid_to_cnodeid(nasid);
764        geoid = cnodeid_get_geoid(cnode);
765        moduleid = geo_module(geoid);
766
767        snprintf(address, 15, "module_%c%c%c%c%.2d",
768                '0'+RACK_GET_CLASS(MODULE_GET_RACK(moduleid)),
769                '0'+RACK_GET_GROUP(MODULE_GET_RACK(moduleid)),
770                '0'+RACK_GET_NUM(MODULE_GET_RACK(moduleid)),
771                MODULE_GET_BTCHAR(moduleid), MODULE_GET_BPOS(moduleid));
772
773        /* Tollhouse requires slot id to be displayed */
774        bricktype = MODULE_GET_BTYPE(moduleid);
775        if ((bricktype == L1_BRICKTYPE_191010) ||
776            (bricktype == L1_BRICKTYPE_1932))
777                        snprintf(address, 15+8, "%s^%d", address, geo_slot(geoid));
778}
779#endif
780
781#ifdef XEN
782__initcall(sn_io_early_init);
783#else
784subsys_initcall(sn_io_early_init);
785#endif
786#ifndef XEN
787EXPORT_SYMBOL(sn_pci_fixup_slot);
788EXPORT_SYMBOL(sn_pci_unfixup_slot);
789EXPORT_SYMBOL(sn_pci_controller_fixup);
790EXPORT_SYMBOL(sn_bus_store_sysdata);
791EXPORT_SYMBOL(sn_bus_free_sysdata);
792EXPORT_SYMBOL(sn_generate_path);
793#endif
Note: See TracBrowser for help on using the repository browser.