netns xfrm: fix "ip xfrm state|policy count" misreport
[safe/jmp/linux-2.6] / arch / arm / mach-ixp4xx / common-pci.c
index 94bcdb9..c4a0159 100644 (file)
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/device.h>
+#include <linux/io.h>
 #include <asm/dma-mapping.h>
 
-#include <asm/io.h>
+#include <asm/cputype.h>
 #include <asm/irq.h>
 #include <asm/sizes.h>
 #include <asm/system.h>
 #include <asm/mach/pci.h>
-#include <asm/hardware.h>
+#include <mach/hardware.h>
 
 
 /*
@@ -87,7 +88,7 @@ static inline int check_master_abort(void)
        if (isr & PCI_ISR_PFE) {
                /* make sure the Master Abort bit is reset */    
                *PCI_ISR = PCI_ISR_PFE;
-               pr_debug("%s failed\n", __FUNCTION__);
+               pr_debug("%s failed\n", __func__);
                return 1;
        }
 
@@ -341,17 +342,38 @@ int dma_needs_bounce(struct device *dev, dma_addr_t dma_addr, size_t size)
        return (dev->bus == &pci_bus_type ) && ((dma_addr + size) >= SZ_64M);
 }
 
-void __init ixp4xx_pci_preinit(void)
-{  
-       unsigned long processor_id;
+/*
+ * Only first 64MB of memory can be accessed via PCI.
+ * We use GFP_DMA to allocate safe buffers to do map/unmap.
+ * This is really ugly and we need a better way of specifying
+ * DMA-capable regions of memory.
+ */
+void __init ixp4xx_adjust_zones(int node, unsigned long *zone_size,
+       unsigned long *zhole_size)
+{
+       unsigned int sz = SZ_64M >> PAGE_SHIFT;
 
-       asm("mrc p15, 0, %0, cr0, cr0, 0;" : "=r"(processor_id) :);
+       /*
+        * Only adjust if > 64M on current system
+        */
+       if (node || (zone_size[0] <= sz))
+               return;
+
+       zone_size[1] = zone_size[0] - sz;
+       zone_size[0] = sz;
+       zhole_size[1] = zhole_size[0];
+       zhole_size[0] = 0;
+}
+
+void __init ixp4xx_pci_preinit(void)
+{
+       unsigned long cpuid = read_cpuid_id();
 
        /*
         * Determine which PCI read method to use.
         * Rev 0 IXP425 requires workaround.
         */
-       if (!(processor_id & 0xf) && !cpu_is_ixp46x()) {
+       if (!(cpuid & 0xf) && cpu_is_ixp42x()) {
                printk("PCI: IXP42x A0 silicon detected - "
                        "PCI Non-Prefetch Workaround Enabled\n");
                ixp4xx_pci_read = ixp4xx_pci_read_errata;
@@ -364,17 +386,17 @@ void __init ixp4xx_pci_preinit(void)
 
        pr_debug("setup PCI-AHB(inbound) and AHB-PCI(outbound) address mappings\n");
 
-       /* 
+       /*
         * We use identity AHB->PCI address translation
         * in the 0x48000000 to 0x4bffffff address space
         */
        *PCI_PCIMEMBASE = 0x48494A4B;
 
-       /* 
+       /*
         * We also use identity PCI->AHB address translation
         * in 4 16MB BARs that begin at the physical memory start
         */
-       *PCI_AHBMEMBASE = (PHYS_OFFSET & 0xFF000000) + 
+       *PCI_AHBMEMBASE = (PHYS_OFFSET & 0xFF000000) +
                ((PHYS_OFFSET & 0xFF000000) >> 8) +
                ((PHYS_OFFSET & 0xFF000000) >> 16) +
                ((PHYS_OFFSET & 0xFF000000) >> 24) +
@@ -386,18 +408,19 @@ void __init ixp4xx_pci_preinit(void)
                pr_debug("setup BARs in controller\n");
 
                /*
-                * We configure the PCI inbound memory windows to be 
+                * We configure the PCI inbound memory windows to be
                 * 1:1 mapped to SDRAM
                 */
-               local_write_config(PCI_BASE_ADDRESS_0, 4, PHYS_OFFSET + 0x00000000);
-               local_write_config(PCI_BASE_ADDRESS_1, 4, PHYS_OFFSET + 0x01000000);
-               local_write_config(PCI_BASE_ADDRESS_2, 4, PHYS_OFFSET + 0x02000000);
-               local_write_config(PCI_BASE_ADDRESS_3, 4, PHYS_OFFSET + 0x03000000);
+               local_write_config(PCI_BASE_ADDRESS_0, 4, PHYS_OFFSET);
+               local_write_config(PCI_BASE_ADDRESS_1, 4, PHYS_OFFSET + SZ_16M);
+               local_write_config(PCI_BASE_ADDRESS_2, 4, PHYS_OFFSET + SZ_32M);
+               local_write_config(PCI_BASE_ADDRESS_3, 4, PHYS_OFFSET + SZ_48M);
 
                /*
-                * Enable CSR window at 0xff000000.
+                * Enable CSR window at 64 MiB to allow PCI masters
+                * to continue prefetching past 64 MiB boundary.
                 */
-               local_write_config(PCI_BASE_ADDRESS_4, 4, 0xff000008);
+               local_write_config(PCI_BASE_ADDRESS_4, 4, PHYS_OFFSET + SZ_64M);
 
                /*
                 * Enable the IO window to be way up high, at 0xfffffc00
@@ -427,7 +450,7 @@ void __init ixp4xx_pci_preinit(void)
 #ifdef __ARMEB__
        *PCI_CSR = PCI_CSR_IC | PCI_CSR_ABE | PCI_CSR_PDS | PCI_CSR_ADS;
 #else
-       *PCI_CSR = PCI_CSR_IC;
+       *PCI_CSR = PCI_CSR_IC | PCI_CSR_ABE;
 #endif
 
        pr_debug("DONE\n");
@@ -440,7 +463,7 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys)
        if (nr >= 1)
                return 0;
 
-       res = kmalloc(sizeof(*res) * 2, GFP_KERNEL);
+       res = kzalloc(sizeof(*res) * 2, GFP_KERNEL);
        if (res == NULL) {
                /* 
                 * If we're out of memory this early, something is wrong,
@@ -448,22 +471,17 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys)
                 */
                panic("PCI: unable to allocate resources?\n");
        }
-       memset(res, 0, sizeof(*res) * 2);
 
        local_write_config(PCI_COMMAND, 2, PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
 
        res[0].name = "PCI I/O Space";
-       res[0].start = 0x00001000;
-       res[0].end = 0xffff0000;
+       res[0].start = 0x00000000;
+       res[0].end = 0x0000ffff;
        res[0].flags = IORESOURCE_IO;
 
        res[1].name = "PCI Memory Space";
-       res[1].start = 0x48000000;
-#ifndef CONFIG_IXP4XX_INDIRECT_PCI
-       res[1].end = 0x4bffffff;
-#else
-       res[1].end = 0x4fffffff;
-#endif
+       res[1].start = PCIBIOS_MIN_MEM;
+       res[1].end = PCIBIOS_MAX_MEM;
        res[1].flags = IORESOURCE_MEM;
 
        request_resource(&ioport_resource, &res[0]);
@@ -479,7 +497,7 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys)
        return 1;
 }
 
-struct pci_bus *ixp4xx_scan_bus(int nr, struct pci_sys_data *sys)
+struct pci_bus * __devinit ixp4xx_scan_bus(int nr, struct pci_sys_data *sys)
 {
        return pci_scan_bus(sys->busnr, &ixp4xx_ops, sys);
 }
@@ -502,15 +520,6 @@ pci_set_dma_mask(struct pci_dev *dev, u64 mask)
 }
     
 int
-pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask)
-{
-       if (mask >= SZ_64M - 1 )
-               return 0;
-
-       return -EIO;
-}
-
-int
 pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
 {
        if (mask >= SZ_64M - 1 )
@@ -519,9 +528,6 @@ pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
        return -EIO;
 }
 
-EXPORT_SYMBOL(pci_set_dma_mask);
-EXPORT_SYMBOL(pci_dac_set_dma_mask);
-EXPORT_SYMBOL(pci_set_consistent_dma_mask);
 EXPORT_SYMBOL(ixp4xx_pci_read);
 EXPORT_SYMBOL(ixp4xx_pci_write);