sh: Consolidated SH7751/SH7780 PCI support.

This cleans up quite a lot of the PCI mess that we
currently have, and attempts to consolidate the
duplication in the SH7780 and SH7751 PCI controllers.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
diff --git a/arch/sh/boards/titan/io.c b/arch/sh/boards/titan/io.c
index 48f3494..4730c1d 100644
--- a/arch/sh/boards/titan/io.c
+++ b/arch/sh/boards/titan/io.c
@@ -1,34 +1,11 @@
 /*
  *	I/O routines for Titan
  */
-
 #include <linux/pci.h>
 #include <asm/machvec.h>
 #include <asm/addrspace.h>
 #include <asm/titan.h>
 #include <asm/io.h>
-#include "../../drivers/pci/pci-sh7751.h"
-
-#define PCIIOBR         (volatile long *)PCI_REG(SH7751_PCIIOBR)
-#define PCIMBR          (volatile long *)PCI_REG(SH7751_PCIMBR)
-#define PCI_IO_AREA     SH7751_PCI_IO_BASE
-#define PCI_MEM_AREA    SH7751_PCI_CONFIG_BASE
-
-#define PCI_IOMAP(adr)  (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
-
-#if defined(CONFIG_PCI)
-#define CHECK_SH7751_PCIIO(port) \
-  ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
-#define CHECK_SH7751_PCIMEMIO(port) \
-  ((port >= PCIBIOS_MIN_MEM) && (port < (PCIBIOS_MIN_MEM + SH7751_PCI_MEM_SIZE)))
-#else
-#define CHECK_SH7751_PCIIO(port) (0)
-#endif
-
-static inline void delay(void)
-{
-        ctrl_inw(0xa0000000);
-}
 
 static inline unsigned int port2adr(unsigned int port)
 {
@@ -40,8 +17,8 @@
 {
         if (PXSEG(port))
                 return ctrl_inb(port);
-        else if (CHECK_SH7751_PCIIO(port))
-                return ctrl_inb(PCI_IOMAP(port));
+        else if (is_pci_ioaddr(port))
+                return ctrl_inb(pci_ioaddr(port));
         return ctrl_inw(port2adr(port)) & 0xff;
 }
 
@@ -51,11 +28,11 @@
 
         if (PXSEG(port))
                 v = ctrl_inb(port);
-        else if (CHECK_SH7751_PCIIO(port))
-                v = ctrl_inb(PCI_IOMAP(port));
+        else if (is_pci_ioaddr(port))
+                v = ctrl_inb(pci_ioaddr(port));
         else
                 v = ctrl_inw(port2adr(port)) & 0xff;
-        delay();
+        ctrl_delay();
         return v;
 }
 
@@ -63,8 +40,8 @@
 {
         if (PXSEG(port))
                 return ctrl_inw(port);
-        else if (CHECK_SH7751_PCIIO(port))
-                return ctrl_inw(PCI_IOMAP(port));
+        else if (is_pci_ioaddr(port))
+                return ctrl_inw(pci_ioaddr(port));
         else if (port >= 0x2000)
                 return ctrl_inw(port2adr(port));
         else
@@ -76,8 +53,8 @@
 {
         if (PXSEG(port))
                 return ctrl_inl(port);
-        else if (CHECK_SH7751_PCIIO(port))
-                return ctrl_inl(PCI_IOMAP(port));
+        else if (is_pci_ioaddr(port))
+                return ctrl_inl(pci_ioaddr(port));
         else if (port >= 0x2000)
                 return ctrl_inw(port2adr(port));
         else
@@ -89,8 +66,8 @@
 {
         if (PXSEG(port))
                 ctrl_outb(value, port);
-        else if (CHECK_SH7751_PCIIO(port))
-                ctrl_outb(value, PCI_IOMAP(port));
+        else if (is_pci_ioaddr(port))
+                ctrl_outb(value, pci_ioaddr(port));
         else
                 ctrl_outw(value, port2adr(port));
 }
@@ -99,19 +76,19 @@
 {
         if (PXSEG(port))
                 ctrl_outb(value, port);
-        else if (CHECK_SH7751_PCIIO(port))
-                ctrl_outb(value, PCI_IOMAP(port));
+        else if (is_pci_ioaddr(port))
+                ctrl_outb(value, pci_ioaddr(port));
         else
                 ctrl_outw(value, port2adr(port));
-        delay();
+        ctrl_delay();
 }
 
 void titan_outw(u16 value, unsigned long port)
 {
         if (PXSEG(port))
                 ctrl_outw(value, port);
-        else if (CHECK_SH7751_PCIIO(port))
-                ctrl_outw(value, PCI_IOMAP(port));
+        else if (is_pci_ioaddr(port))
+                ctrl_outw(value, pci_ioaddr(port));
         else if (port >= 0x2000)
                 ctrl_outw(value, port2adr(port));
         else
@@ -122,8 +99,8 @@
 {
         if (PXSEG(port))
                 ctrl_outl(value, port);
-        else if (CHECK_SH7751_PCIIO(port))
-                ctrl_outl(value, PCI_IOMAP(port));
+        else if (is_pci_ioaddr(port))
+                ctrl_outl(value, pci_ioaddr(port));
         else
                 maybebadio(port);
 }
@@ -140,10 +117,10 @@
 
 void __iomem *titan_ioport_map(unsigned long port, unsigned int size)
 {
-	if (PXSEG(port) || CHECK_SH7751_PCIMEMIO(port))
+	if (PXSEG(port) || is_pci_memaddr(port))
 		return (void __iomem *)port;
-	else if (CHECK_SH7751_PCIIO(port))
-		return (void __iomem *)PCI_IOMAP(port);
+	else if (is_pci_ioaddr(port))
+		return (void __iomem *)pci_ioaddr(port);
 
 	return (void __iomem *)port2adr(port);
 }