]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - arch/ia64/sn/kernel/io_init.c
[IA64] Tollhouse HP: IA64 arch changes
[net-next-2.6.git] / arch / ia64 / sn / kernel / io_init.c
index 3437c2390429daff50c60e1700dde33e66645198..5101ac462643361ee6bca3de5a459e8946de9c0a 100644 (file)
@@ -13,6 +13,8 @@
 #include <asm/sn/sn_feature_sets.h>
 #include <asm/sn/geo.h>
 #include <asm/sn/io.h>
+#include <asm/sn/l1.h>
+#include <asm/sn/module.h>
 #include <asm/sn/pcibr_provider.h>
 #include <asm/sn/pcibus_provider_defs.h>
 #include <asm/sn/pcidev.h>
 #include "xtalk/hubdev.h"
 #include "xtalk/xwidgetdev.h"
 
+
+extern void sn_init_cpei_timer(void);
+extern void register_sn_procfs(void);
+
 static struct list_head sn_sysdata_list;
 
 /* sysdata list struct */
@@ -40,12 +46,12 @@ struct brick {
        struct slab_info slab_info[MAX_SLABS + 1];
 };
 
-int sn_ioif_inited = 0;                /* SN I/O infrastructure initialized? */
+int sn_ioif_inited;            /* SN I/O infrastructure initialized? */
 
 struct sn_pcibus_provider *sn_pci_provider[PCIIO_ASIC_MAX_TYPES];      /* indexed by asic type */
 
-static int max_segment_number = 0; /* Default highest segment number */
-static int max_pcibus_number = 255; /* Default highest pci bus number */
+static int max_segment_number;          /* Default highest segment number */
+static int max_pcibus_number = 255;    /* Default highest pci bus number */
 
 /*
  * Hooks and struct for unsupported pci providers
@@ -84,7 +90,6 @@ static inline u64
 sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num,
                             u64 address)
 {
-
        struct ia64_sal_retval ret_stuff;
        ret_stuff.status = 0;
        ret_stuff.v0 = 0;
@@ -94,7 +99,6 @@ sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num,
                        (u64) nasid, (u64) widget_num,
                        (u64) device_num, (u64) address, 0, 0, 0);
        return ret_stuff.status;
-
 }
 
 /*
@@ -102,7 +106,6 @@ sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num,
  */
 static inline u64 sal_get_hubdev_info(u64 handle, u64 address)
 {
-
        struct ia64_sal_retval ret_stuff;
        ret_stuff.status = 0;
        ret_stuff.v0 = 0;
@@ -118,7 +121,6 @@ static inline u64 sal_get_hubdev_info(u64 handle, u64 address)
  */
 static inline u64 sal_get_pcibus_info(u64 segment, u64 busnum, u64 address)
 {
-
        struct ia64_sal_retval ret_stuff;
        ret_stuff.status = 0;
        ret_stuff.v0 = 0;
@@ -215,7 +217,7 @@ static void __init sn_fixup_ionodes(void)
        struct hubdev_info *hubdev;
        u64 status;
        u64 nasid;
-       int i, widget, device;
+       int i, widget, device, size;
 
        /*
         * Get SGI Specific HUB chipset information.
@@ -251,48 +253,37 @@ static void __init sn_fixup_ionodes(void)
                if (!hubdev->hdi_flush_nasid_list.widget_p)
                        continue;
 
+               size = (HUB_WIDGET_ID_MAX + 1) *
+                       sizeof(struct sn_flush_device_kernel *);
                hubdev->hdi_flush_nasid_list.widget_p =
-                   kmalloc((HUB_WIDGET_ID_MAX + 1) *
-                           sizeof(struct sn_flush_device_kernel *),
-                           GFP_KERNEL);
-               memset(hubdev->hdi_flush_nasid_list.widget_p, 0x0,
-                      (HUB_WIDGET_ID_MAX + 1) *
-                      sizeof(struct sn_flush_device_kernel *));
+                       kzalloc(size, GFP_KERNEL);
+               if (!hubdev->hdi_flush_nasid_list.widget_p)
+                       BUG();
 
                for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) {
-                       sn_flush_device_kernel = kmalloc(DEV_PER_WIDGET *
-                                                        sizeof(struct
-                                                       sn_flush_device_kernel),
-                                                       GFP_KERNEL);
+                       size = DEV_PER_WIDGET *
+                               sizeof(struct sn_flush_device_kernel);
+                       sn_flush_device_kernel = kzalloc(size, GFP_KERNEL);
                        if (!sn_flush_device_kernel)
                                BUG();
-                       memset(sn_flush_device_kernel, 0x0,
-                              DEV_PER_WIDGET *
-                              sizeof(struct sn_flush_device_kernel));
 
                        dev_entry = sn_flush_device_kernel;
                        for (device = 0; device < DEV_PER_WIDGET;
                             device++,dev_entry++) {
-                               dev_entry->common = kmalloc(sizeof(struct
-                                                       sn_flush_device_common),
-                                                           GFP_KERNEL);
+                               size = sizeof(struct sn_flush_device_common);
+                               dev_entry->common = kzalloc(size, GFP_KERNEL);
                                if (!dev_entry->common)
                                        BUG();
-                               memset(dev_entry->common, 0x0, sizeof(struct
-                                                      sn_flush_device_common));
 
                                if (sn_prom_feature_available(
                                                       PRF_DEVICE_FLUSH_LIST))
                                        status = sal_get_device_dmaflush_list(
-                                                                         nasid,
-                                                                        widget,
-                                                                        device,
-                                                     (u64)(dev_entry->common));
+                                                    nasid, widget, device,
+                                                    (u64)(dev_entry->common));
                                else
                                        status = sn_device_fixup_war(nasid,
-                                                                    widget,
-                                                                    device,
-                                                            dev_entry->common);
+                                                    widget, device,
+                                                    dev_entry->common);
                                if (status != SALRET_OK)
                                        panic("SAL call failed: %s\n",
                                              ia64_sal_strerror(status));
@@ -383,13 +374,12 @@ void sn_pci_fixup_slot(struct pci_dev *dev)
 
        pci_dev_get(dev); /* for the sysdata pointer */
        pcidev_info = kzalloc(sizeof(struct pcidev_info), GFP_KERNEL);
-       if (pcidev_info <= 0)
+       if (!pcidev_info)
                BUG();          /* Cannot afford to run out of memory */
 
-       sn_irq_info = kmalloc(sizeof(struct sn_irq_info), GFP_KERNEL);
-       if (sn_irq_info <= 0)
+       sn_irq_info = kzalloc(sizeof(struct sn_irq_info), GFP_KERNEL);
+       if (!sn_irq_info)
                BUG();          /* Cannot afford to run out of memory */
-       memset(sn_irq_info, 0, sizeof(struct sn_irq_info));
 
        /* Call to retrieve pci device information needed by kernel. */
        status = sal_get_pcidev_info((u64) segment, (u64) dev->bus->number, 
@@ -482,13 +472,13 @@ void sn_pci_fixup_slot(struct pci_dev *dev)
  */
 void sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
 {
-       int status = 0;
+       int status;
        int nasid, cnode;
        struct pci_controller *controller;
        struct sn_pci_controller *sn_controller;
        struct pcibus_bussoft *prom_bussoft_ptr;
        struct hubdev_info *hubdev_info;
-       void *provider_soft = NULL;
+       void *provider_soft;
        struct sn_pcibus_provider *provider;
 
        status = sal_get_pcibus_info((u64) segment, (u64) busnum,
@@ -535,6 +525,8 @@ void sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
        bus->sysdata = controller;
        if (provider->bus_fixup)
                provider_soft = (*provider->bus_fixup) (prom_bussoft_ptr, controller);
+       else
+               provider_soft = NULL;
 
        if (provider_soft == NULL) {
                /* fixup failed or not applicable */
@@ -638,13 +630,8 @@ void sn_bus_free_sysdata(void)
 
 static int __init sn_pci_init(void)
 {
-       int i = 0;
-       int j = 0;
+       int i, j;
        struct pci_dev *pci_dev = NULL;
-       extern void sn_init_cpei_timer(void);
-#ifdef CONFIG_PROC_FS
-       extern void register_sn_procfs(void);
-#endif
 
        if (!ia64_platform_is("sn2") || IS_RUNNING_ON_FAKE_PROM())
                return 0;
@@ -700,32 +687,55 @@ static int __init sn_pci_init(void)
  */
 void hubdev_init_node(nodepda_t * npda, cnodeid_t node)
 {
-
        struct hubdev_info *hubdev_info;
+       int size;
+       pg_data_t *pg;
+
+       size = sizeof(struct hubdev_info);
 
        if (node >= num_online_nodes()) /* Headless/memless IO nodes */
-               hubdev_info =
-                   (struct hubdev_info *)alloc_bootmem_node(NODE_DATA(0),
-                                                            sizeof(struct
-                                                                   hubdev_info));
+               pg = NODE_DATA(0);
        else
-               hubdev_info =
-                   (struct hubdev_info *)alloc_bootmem_node(NODE_DATA(node),
-                                                            sizeof(struct
-                                                                   hubdev_info));
-       npda->pdinfo = (void *)hubdev_info;
+               pg = NODE_DATA(node);
 
+       hubdev_info = (struct hubdev_info *)alloc_bootmem_node(pg, size);
+
+       npda->pdinfo = (void *)hubdev_info;
 }
 
 geoid_t
 cnodeid_get_geoid(cnodeid_t cnode)
 {
-
        struct hubdev_info *hubdev;
 
        hubdev = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo);
        return hubdev->hdi_geoid;
+}
 
+void sn_generate_path(struct pci_bus *pci_bus, char *address)
+{
+       nasid_t nasid;
+       cnodeid_t cnode;
+       geoid_t geoid;
+       moduleid_t moduleid;
+       u16 bricktype;
+
+       nasid = NASID_GET(SN_PCIBUS_BUSSOFT(pci_bus)->bs_base);
+       cnode = nasid_to_cnodeid(nasid);
+       geoid = cnodeid_get_geoid(cnode);
+       moduleid = geo_module(geoid);
+
+       sprintf(address, "module_%c%c%c%c%.2d",
+               '0'+RACK_GET_CLASS(MODULE_GET_RACK(moduleid)),
+               '0'+RACK_GET_GROUP(MODULE_GET_RACK(moduleid)),
+               '0'+RACK_GET_NUM(MODULE_GET_RACK(moduleid)),
+               MODULE_GET_BTCHAR(moduleid), MODULE_GET_BPOS(moduleid));
+
+       /* Tollhouse requires slot id to be displayed */
+       bricktype = MODULE_GET_BTYPE(moduleid);
+       if ((bricktype == L1_BRICKTYPE_191010) ||
+           (bricktype == L1_BRICKTYPE_1932))
+                       sprintf(address, "%s^%d", address, geo_slot(geoid));
 }
 
 subsys_initcall(sn_pci_init);
@@ -734,3 +744,4 @@ EXPORT_SYMBOL(sn_pci_unfixup_slot);
 EXPORT_SYMBOL(sn_pci_controller_fixup);
 EXPORT_SYMBOL(sn_bus_store_sysdata);
 EXPORT_SYMBOL(sn_bus_free_sysdata);
+EXPORT_SYMBOL(sn_generate_path);