Merge to kernel-2.6.20-1.2949.fc6.vs2.2.0.1
[linux-2.6.git] / arch / mips / pci / ops-tx4927.c
index 43863ab..150419c 100644 (file)
@@ -1,16 +1,16 @@
 /*
  * Copyright 2001 MontaVista Software Inc.
  * Author: MontaVista Software, Inc.
- *              ahennessy@mvista.com       
+ *              ahennessy@mvista.com
  *
- * Copyright (C) 2000-2001 Toshiba Corporation 
+ * Copyright (C) 2000-2001 Toshiba Corporation
  * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
  *
  * Based on arch/mips/ddb5xxx/ddb5477/pci_ops.c
  *
  *     Define the pci_ops for the Toshiba rbtx4927
  *
- * Much of the code is derived from the original DDB5074 port by 
+ * Much of the code is derived from the original DDB5074 port by
  * Geert Uytterhoeven <geert@sonycom.com>
  *
  * Copyright 2004 MontaVista Software Inc.
@@ -42,8 +42,8 @@
 #include <linux/init.h>
 
 #include <asm/addrspace.h>
+#include <asm/byteorder.h>
 #include <asm/tx4927/tx4927_pci.h>
-#include <asm/debug.h>
 
 /* initialize in setup */
 struct resource pci_io_resource = {
@@ -107,16 +107,6 @@ static int tx4927_pcibios_read_config(struct pci_bus *bus, unsigned int devfn, i
         dev = PCI_SLOT(devfn);
         func = PCI_FUNC(devfn);
 
-       if (size == 2) {
-               if (where & 1)
-                       return PCIBIOS_BAD_REGISTER_NUMBER;
-       }
-
-       if (size == 4) {
-               if (where & 3)
-                       return PCIBIOS_BAD_REGISTER_NUMBER;
-       }
-
        /* check if the bus is top-level */
        if (bus->parent != NULL) {
                busno = bus->number;
@@ -129,12 +119,22 @@ static int tx4927_pcibios_read_config(struct pci_bus *bus, unsigned int devfn, i
 
        switch (size) {
        case 1:
-               *val = *(volatile u8 *) ((ulong) & tx4927_pcicptr->
-                              g2pcfgdata | (where & 3));
+               *val = *(volatile u8 *) ((unsigned long) & tx4927_pcicptr->
+                              g2pcfgdata |
+#ifdef __LITTLE_ENDIAN
+                                               (where & 3));
+#else
+                                               ((where & 0x3) ^ 0x3));
+#endif
                break;
        case 2:
-               *val = *(volatile u16 *) ((ulong) & tx4927_pcicptr->
-                               g2pcfgdata | (where & 3));
+               *val = *(volatile u16 *) ((unsigned long) & tx4927_pcicptr->
+                               g2pcfgdata |
+#ifdef __LITTLE_ENDIAN
+                                               (where & 3));
+#else
+                                               ((where & 0x3) ^ 0x2));
+#endif
                break;
        case 4:
                *val = tx4927_pcicptr->g2pcfgdata;
@@ -156,16 +156,6 @@ static int tx4927_pcibios_write_config(struct pci_bus *bus, unsigned int devfn,
         dev = PCI_SLOT(devfn);
         func = PCI_FUNC(devfn);
 
-       if (size == 1) {
-               if (where & 1)
-                       return PCIBIOS_BAD_REGISTER_NUMBER;
-       }
-
-       if (size == 4) {
-               if (where & 3)
-                       return PCIBIOS_BAD_REGISTER_NUMBER;
-       }
-
        /* check if the bus is top-level */
        if (bus->parent != NULL) {
                busno = bus->number;
@@ -178,13 +168,23 @@ static int tx4927_pcibios_write_config(struct pci_bus *bus, unsigned int devfn,
 
        switch (size) {
        case 1:
-                *(volatile u8 *) ((ulong) & tx4927_pcicptr->
-                          g2pcfgdata | (where & 3)) = val;
+                *(volatile u8 *) ((unsigned long) & tx4927_pcicptr->
+                          g2pcfgdata |
+#ifdef __LITTLE_ENDIAN
+                                       (where & 3)) = val;
+#else
+                                       ((where & 0x3) ^ 0x3)) = val;
+#endif
                break;
 
        case 2:
-               *(volatile u16 *) ((ulong) & tx4927_pcicptr->
-                           g2pcfgdata | (where & 3)) = val;
+               *(volatile u16 *) ((unsigned long) & tx4927_pcicptr->
+                           g2pcfgdata |
+#ifdef __LITTLE_ENDIAN
+                                       (where & 3)) = val;
+#else
+                                       ((where & 0x3) ^ 0x2)) = val;
+#endif
                break;
        case 4:
                tx4927_pcicptr->g2pcfgdata = val;