[amazon] work on pci.
authorhauke <hauke@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Sat, 26 Dec 2009 00:09:00 +0000 (00:09 +0000)
committerhauke <hauke@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Sat, 26 Dec 2009 00:09:00 +0000 (00:09 +0000)
This is from ticket #6374

Michael Richter thanks for your patch.

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@18933 3c298f89-4303-0410-b956-a3cf2f4a3e73

target/linux/amazon/files/arch/mips/amazon/pci.c
target/linux/amazon/patches-2.6.30/230-fix_pci.patch [deleted file]

index ab305a983cc8958854b5a3b390ec745f3d7ae5c6..a5596c80d4cace98e3ac4c8de7e591a65da5abab 100644 (file)
@@ -95,7 +95,7 @@ static int amazon_pci_config_access(unsigned char access_type,
    
        /* Amazon support slot from 0 to 15 */
        /* devfn 0 & 0x20 is itself */
-       if ((bus != 0) || (devfn == 0) || (devfn == 0x20))
+       if ((bus->number != 0) || (devfn == 0) || (devfn == 0x20))
                return 1;
 
        pci_addr=AMAZON_PCI_CFG_BASE |
@@ -124,49 +124,42 @@ static int amazon_pci_config_access(unsigned char access_type,
 static int amazon_pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val)
 {
        u32 data = 0;
-       int ret = PCIBIOS_SUCCESSFUL;
 
-       if (amazon_pci_config_access(PCI_ACCESS_READ, bus, devfn, where, &data)) {
-               data = ~0;
-               ret = -1;
-       }
+       if (amazon_pci_config_access(PCI_ACCESS_READ, bus, devfn, where, &data))
+               return PCIBIOS_DEVICE_NOT_FOUND;
 
-       switch (size) {
-               case 1:
-                       *((u8 *) val) = (data >> ((where & 3) << 3)) & 0xff;
-                       break;
-               case 2:
-                       *((u16 *) val) = (data >> ((where & 3) << 3)) & 0xffff;
-                       break;
-               case 4:
-                       *val = data;
-                       break;
-               default:
-                       return -1;
-       }
+       if (size == 1)
+               *val = (data >> ((where & 3) << 3)) & 0xff;
+       else if (size == 2)
+               *val = (data >> ((where & 3) << 3)) & 0xffff;
+       else
+               *val = data;
 
-       return ret;
+       return PCIBIOS_SUCCESSFUL;
 }
 
 
 static int amazon_pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val)
 {
-       if (size != 4) {
-               u32 data;
+       u32 data = 0;
 
+       if (size == 4)
+       {
+               data = val;
+       } else {
                if (amazon_pci_config_access(PCI_ACCESS_READ, bus, devfn, where, &data))
-                       return -1;
+                       return PCIBIOS_DEVICE_NOT_FOUND;
 
                if (size == 1)
-                       val = (data & ~(0xff << ((where & 3) << 3))) | (val << ((where & 3) << 3));
+                       data = (data & ~(0xff << ((where & 3) << 3))) |
+                               (val << ((where & 3) << 3));
                else if (size == 2)
-                       val = (data & ~(0xffff << ((where & 3) << 3))) | (val << ((where & 3) << 3));
-               else
-                       return -1;
+                       data = (data & ~(0xffff << ((where & 3) << 3))) |
+                               (val << ((where & 3) << 3));
        }
 
-       if (amazon_pci_config_access(PCI_ACCESS_WRITE, bus, devfn, where, &val))
-              return -1;
+       if (amazon_pci_config_access(PCI_ACCESS_WRITE, bus, devfn, where, &data))
+               return PCIBIOS_DEVICE_NOT_FOUND;
 
        return PCIBIOS_SUCCESSFUL;
 }
@@ -182,7 +175,7 @@ static struct pci_controller amazon_pci_controller = {
        .io_resource = &pci_io_resource
 };
 
-int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
+int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 {
        switch (slot) {
                case 13:
@@ -240,7 +233,7 @@ int pcibios_plat_dev_init(struct pci_dev *dev)
        return 0;
 }
 
-int amazon_pci_init(void)
+int __init amazon_pci_init(void)
 {
        u32 temp_buffer;
 
@@ -286,7 +279,7 @@ int amazon_pci_init(void)
        //use 8 dw burse length
        AMAZON_PCI_REG32(FPI_BURST_LENGTH) = 0x303;
 
-       set_io_port_base(ioremap(AMAZON_PCI_IO_BASE, AMAZON_PCI_IO_SIZE));
+       amazon_pci_controller.io_map_base = (unsigned long)ioremap(AMAZON_PCI_IO_BASE, AMAZON_PCI_IO_SIZE);
        register_pci_controller(&amazon_pci_controller);
        return 0;
 }
diff --git a/target/linux/amazon/patches-2.6.30/230-fix_pci.patch b/target/linux/amazon/patches-2.6.30/230-fix_pci.patch
deleted file mode 100644 (file)
index 84d88dd..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/arch/mips/amazon/pci.c
-+++ b/arch/mips/amazon/pci.c
-@@ -182,7 +182,7 @@ static struct pci_controller amazon_pci_
-       .io_resource = &pci_io_resource
- };
--int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
-+int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
- {
-       switch (slot) {
-               case 13:
-@@ -240,7 +240,7 @@ int pcibios_plat_dev_init(struct pci_dev
-       return 0;
- }
--int amazon_pci_init(void)
-+int __init amazon_pci_init(void)
- {
-       u32 temp_buffer;