]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/powerpc/sysdev/indirect_pci.c
Merge branch 'release' of git://lm-sensors.org/kernel/mhoffman/hwmon-2.6
[linux-2.6-omap-h63xx.git] / arch / powerpc / sysdev / indirect_pci.c
index ad341f5ff94f56ac552e9d5c4ab1b9945cf43025..7fd49c97501aa965058a12d9b62f484fdde0cc56 100644 (file)
 #include <asm/pci-bridge.h>
 #include <asm/machdep.h>
 
-#ifdef CONFIG_PPC_INDIRECT_PCI_BE
-#define PCI_CFG_OUT out_be32
-#else
-#define PCI_CFG_OUT out_le32
-#endif
-
 static int
 indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
                     int len, u32 *val)
@@ -58,9 +52,12 @@ indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
        else
                reg = offset & 0xfc;
 
-       PCI_CFG_OUT(hose->cfg_addr,
-                (0x80000000 | (bus_no << 16)
-                 | (devfn << 8) | reg | cfg_type));
+       if (hose->indirect_type & PPC_INDIRECT_TYPE_BIG_ENDIAN)
+               out_be32(hose->cfg_addr, (0x80000000 | (bus_no << 16) |
+                        (devfn << 8) | reg | cfg_type));
+       else
+               out_le32(hose->cfg_addr, (0x80000000 | (bus_no << 16) |
+                        (devfn << 8) | reg | cfg_type));
 
        /*
         * Note: the caller has already checked that offset is
@@ -113,9 +110,12 @@ indirect_write_config(struct pci_bus *bus, unsigned int devfn, int offset,
        else
                reg = offset & 0xfc;
 
-       PCI_CFG_OUT(hose->cfg_addr,
-                (0x80000000 | (bus_no << 16)
-                 | (devfn << 8) | reg | cfg_type));
+       if (hose->indirect_type & PPC_INDIRECT_TYPE_BIG_ENDIAN)
+               out_be32(hose->cfg_addr, (0x80000000 | (bus_no << 16) |
+                        (devfn << 8) | reg | cfg_type));
+       else
+               out_le32(hose->cfg_addr, (0x80000000 | (bus_no << 16) |
+                        (devfn << 8) | reg | cfg_type));
 
        /* surpress setting of PCI_PRIMARY_BUS */
        if (hose->indirect_type & PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS)
@@ -123,6 +123,12 @@ indirect_write_config(struct pci_bus *bus, unsigned int devfn, int offset,
                        (bus->number == hose->first_busno))
                val &= 0xffffff00;
 
+       /* Workaround for PCI_28 Errata in 440EPx/GRx */
+       if ((hose->indirect_type & PPC_INDIRECT_TYPE_BROKEN_MRM) &&
+                       offset == PCI_CACHE_LINE_SIZE) {
+               val = 0;
+       }
+
        /*
         * Note: the caller has already checked that offset is
         * suitably aligned and that len is 1, 2 or 4.
@@ -144,14 +150,16 @@ indirect_write_config(struct pci_bus *bus, unsigned int devfn, int offset,
 
 static struct pci_ops indirect_pci_ops =
 {
-       indirect_read_config,
-       indirect_write_config
+       .read = indirect_read_config,
+       .write = indirect_write_config,
 };
 
 void __init
-setup_indirect_pci(struct pci_controller* hose, u32 cfg_addr, u32 cfg_data)
+setup_indirect_pci(struct pci_controller* hose,
+                  resource_size_t cfg_addr,
+                  resource_size_t cfg_data, u32 flags)
 {
-       unsigned long base = cfg_addr & PAGE_MASK;
+       resource_size_t base = cfg_addr & PAGE_MASK;
        void __iomem *mbase;
 
        mbase = ioremap(base, PAGE_SIZE);
@@ -160,4 +168,5 @@ setup_indirect_pci(struct pci_controller* hose, u32 cfg_addr, u32 cfg_data)
                mbase = ioremap(cfg_data & PAGE_MASK, PAGE_SIZE);
        hose->cfg_data = mbase + (cfg_data & ~PAGE_MASK);
        hose->ops = &indirect_pci_ops;
+       hose->indirect_type = flags;
 }