]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/sparc64/kernel/prom.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/drzeus/mmc
[linux-2.6-omap-h63xx.git] / arch / sparc64 / kernel / prom.c
index fa484d4f241e57d6eed4fa8407327efad4ca2b99..0917c24c4f08fe993967b64ae35ff89466185731 100644 (file)
@@ -15,7 +15,6 @@
  *      2 of the License, or (at your option) any later version.
  */
 
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/string.h>
@@ -344,10 +343,12 @@ static unsigned long __psycho_onboard_imap_off[] = {
 /*0x2f*/       PSYCHO_IMAP_CE,
 /*0x30*/       PSYCHO_IMAP_A_ERR,
 /*0x31*/       PSYCHO_IMAP_B_ERR,
-/*0x32*/       PSYCHO_IMAP_PMGMT
+/*0x32*/       PSYCHO_IMAP_PMGMT,
+/*0x33*/       PSYCHO_IMAP_GFX,
+/*0x34*/       PSYCHO_IMAP_EUPA,
 };
 #define PSYCHO_ONBOARD_IRQ_BASE                0x20
-#define PSYCHO_ONBOARD_IRQ_LAST                0x32
+#define PSYCHO_ONBOARD_IRQ_LAST                0x34
 #define psycho_onboard_imap_offset(__ino) \
        __psycho_onboard_imap_off[(__ino) - PSYCHO_ONBOARD_IRQ_BASE]
 
@@ -529,6 +530,10 @@ static unsigned long __sabre_onboard_imap_off[] = {
 /*0x2e*/       SABRE_IMAP_UE,
 /*0x2f*/       SABRE_IMAP_CE,
 /*0x30*/       SABRE_IMAP_PCIERR,
+/*0x31*/       0 /* reserved */,
+/*0x32*/       0 /* reserved */,
+/*0x33*/       SABRE_IMAP_GFX,
+/*0x34*/       SABRE_IMAP_EUPA,
 };
 #define SABRE_ONBOARD_IRQ_BASE         0x20
 #define SABRE_ONBOARD_IRQ_LAST         0x30
@@ -539,6 +544,45 @@ static unsigned long __sabre_onboard_imap_off[] = {
        ((ino & 0x20) ? (SABRE_ICLR_SCSI + (((ino) & 0x1f) << 3)) :  \
                        (SABRE_ICLR_A_SLOT0 + (((ino) & 0x1f)<<3)))
 
+static int sabre_device_needs_wsync(struct device_node *dp)
+{
+       struct device_node *parent = dp->parent;
+       char *parent_model, *parent_compat;
+
+       /* This traversal up towards the root is meant to
+        * handle two cases:
+        *
+        * 1) non-PCI bus sitting under PCI, such as 'ebus'
+        * 2) the PCI controller interrupts themselves, which
+        *    will use the sabre_irq_build but do not need
+        *    the DMA synchronization handling
+        */
+       while (parent) {
+               if (!strcmp(parent->type, "pci"))
+                       break;
+               parent = parent->parent;
+       }
+
+       if (!parent)
+               return 0;
+
+       parent_model = of_get_property(parent,
+                                      "model", NULL);
+       if (parent_model &&
+           (!strcmp(parent_model, "SUNW,sabre") ||
+            !strcmp(parent_model, "SUNW,simba")))
+               return 0;
+
+       parent_compat = of_get_property(parent,
+                                       "compatible", NULL);
+       if (parent_compat &&
+           (!strcmp(parent_compat, "pci108e,a000") ||
+            !strcmp(parent_compat, "pci108e,a001")))
+               return 0;
+
+       return 1;
+}
+
 static unsigned int sabre_irq_build(struct device_node *dp,
                                    unsigned int ino,
                                    void *_data)
@@ -577,15 +621,17 @@ static unsigned int sabre_irq_build(struct device_node *dp,
 
        virt_irq = build_irq(inofixup, iclr, imap);
 
+       /* If the parent device is a PCI<->PCI bridge other than
+        * APB, we have to install a pre-handler to ensure that
+        * all pending DMA is drained before the interrupt handler
+        * is run.
+        */
        regs = of_get_property(dp, "reg", NULL);
-       if (regs &&
-           ((regs->phys_hi >> 16) & 0xff) != irq_data->pci_first_busno) {
+       if (regs && sabre_device_needs_wsync(dp)) {
                irq_install_pre_handler(virt_irq,
                                        sabre_wsync_handler,
                                        (void *) (long) regs->phys_hi,
-                                       (void *)
-                                       controller_regs +
-                                       SABRE_WRSYNC);
+                                       (void *) irq_data);
        }
 
        return virt_irq;
@@ -747,7 +793,7 @@ static unsigned int schizo_irq_build(struct device_node *dp,
        return virt_irq;
 }
 
-static void schizo_irq_trans_init(struct device_node *dp)
+static void __schizo_irq_trans_init(struct device_node *dp, int is_tomatillo)
 {
        struct linux_prom64_registers *regs;
        struct schizo_irq_data *irq_data;
@@ -761,11 +807,24 @@ static void schizo_irq_trans_init(struct device_node *dp)
        dp->irq_trans->data = irq_data;
 
        irq_data->pbm_regs = regs[0].phys_addr;
-       irq_data->sync_reg = regs[3].phys_addr + 0x1a18UL;
+       if (is_tomatillo)
+               irq_data->sync_reg = regs[3].phys_addr + 0x1a18UL;
+       else
+               irq_data->sync_reg = 0UL;
        irq_data->portid = of_getintprop_default(dp, "portid", 0);
        irq_data->chip_version = of_getintprop_default(dp, "version#", 0);
 }
 
+static void schizo_irq_trans_init(struct device_node *dp)
+{
+       __schizo_irq_trans_init(dp, 0);
+}
+
+static void tomatillo_irq_trans_init(struct device_node *dp)
+{
+       __schizo_irq_trans_init(dp, 1);
+}
+
 static unsigned int pci_sun4v_irq_build(struct device_node *dp,
                                        unsigned int devino,
                                        void *_data)
@@ -854,6 +913,8 @@ static unsigned long sysio_irq_offsets[] = {
        SYSIO_IMAP_CE,
        SYSIO_IMAP_SBERR,
        SYSIO_IMAP_PMGMT,
+       SYSIO_IMAP_GFX,
+       SYSIO_IMAP_EUPA,
 };
 
 #undef bogon
@@ -1002,8 +1063,8 @@ static struct irq_trans pci_irq_trans_table[] = {
        { "pci108e,8001", schizo_irq_trans_init },
        { "SUNW,schizo+", schizo_irq_trans_init },
        { "pci108e,8002", schizo_irq_trans_init },
-       { "SUNW,tomatillo", schizo_irq_trans_init },
-       { "pci108e,a801", schizo_irq_trans_init },
+       { "SUNW,tomatillo", tomatillo_irq_trans_init },
+       { "pci108e,a801", tomatillo_irq_trans_init },
        { "SUNW,sun4v-pci", pci_sun4v_irq_trans_init },
 };
 #endif
@@ -1031,21 +1092,22 @@ static void sun4v_vdev_irq_trans_init(struct device_node *dp)
 
 static void irq_trans_init(struct device_node *dp)
 {
+#ifdef CONFIG_PCI
        const char *model;
        int i;
+#endif
 
+#ifdef CONFIG_PCI
        model = of_get_property(dp, "model", NULL);
        if (!model)
                model = of_get_property(dp, "compatible", NULL);
-       if (!model)
-               return;
-
-#ifdef CONFIG_PCI
-       for (i = 0; i < ARRAY_SIZE(pci_irq_trans_table); i++) {
-               struct irq_trans *t = &pci_irq_trans_table[i];
+       if (model) {
+               for (i = 0; i < ARRAY_SIZE(pci_irq_trans_table); i++) {
+                       struct irq_trans *t = &pci_irq_trans_table[i];
 
-               if (!strcmp(model, t->name))
-                       return t->init(dp);
+                       if (!strcmp(model, t->name))
+                               return t->init(dp);
+               }
        }
 #endif
 #ifdef CONFIG_SBUS
@@ -1053,8 +1115,9 @@ static void irq_trans_init(struct device_node *dp)
            !strcmp(dp->name, "sbi"))
                return sbus_irq_trans_init(dp);
 #endif
-       if (!strcmp(dp->name, "central"))
-               return central_irq_trans_init(dp->child);
+       if (!strcmp(dp->name, "fhc") &&
+           !strcmp(dp->parent->name, "central"))
+               return central_irq_trans_init(dp);
        if (!strcmp(dp->name, "virtual-devices"))
                return sun4v_vdev_irq_trans_init(dp);
 }
@@ -1466,7 +1529,7 @@ static char * __init get_one_property(phandle node, const char *name)
        return buf;
 }
 
-static struct device_node * __init create_node(phandle node)
+static struct device_node * __init create_node(phandle node, struct device_node *parent)
 {
        struct device_node *dp;
 
@@ -1475,6 +1538,7 @@ static struct device_node * __init create_node(phandle node)
 
        dp = prom_early_alloc(sizeof(*dp));
        dp->unique_id = unique_id++;
+       dp->parent = parent;
 
        kref_init(&dp->kref);
 
@@ -1493,12 +1557,11 @@ static struct device_node * __init build_tree(struct device_node *parent, phandl
 {
        struct device_node *dp;
 
-       dp = create_node(node);
+       dp = create_node(node, parent);
        if (dp) {
                *(*nextp) = dp;
                *nextp = &dp->allnext;
 
-               dp->parent = parent;
                dp->path_component_name = build_path_component(dp);
                dp->full_name = build_full_name(dp);
 
@@ -1514,7 +1577,7 @@ void __init prom_build_devicetree(void)
 {
        struct device_node **nextp;
 
-       allnodes = create_node(prom_root_node);
+       allnodes = create_node(prom_root_node, NULL);
        allnodes->path_component_name = "";
        allnodes->full_name = "/";