2 * I/O routines for Titan
6 #include <asm/machvec.h>
7 #include <asm/addrspace.h>
10 #include "../../drivers/pci/pci-sh7751.h"
12 #define PCIIOBR (volatile long *)PCI_REG(SH7751_PCIIOBR)
13 #define PCIMBR (volatile long *)PCI_REG(SH7751_PCIMBR)
14 #define PCI_IO_AREA SH7751_PCI_IO_BASE
15 #define PCI_MEM_AREA SH7751_PCI_CONFIG_BASE
17 #define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
19 #if defined(CONFIG_PCI)
20 #define CHECK_SH7751_PCIIO(port) \
21 ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
22 #define CHECK_SH7751_PCIMEMIO(port) \
23 ((port >= PCIBIOS_MIN_MEM) && (port < (PCIBIOS_MIN_MEM + SH7751_PCI_MEM_SIZE)))
25 #define CHECK_SH7751_PCIIO(port) (0)
28 static inline void delay(void)
33 static inline unsigned int port2adr(unsigned int port)
35 maybebadio((unsigned long)port);
39 u8 titan_inb(unsigned long port)
42 return ctrl_inb(port);
43 else if (CHECK_SH7751_PCIIO(port))
44 return ctrl_inb(PCI_IOMAP(port));
45 return ctrl_inw(port2adr(port)) & 0xff;
48 u8 titan_inb_p(unsigned long port)
54 else if (CHECK_SH7751_PCIIO(port))
55 v = ctrl_inb(PCI_IOMAP(port));
57 v = ctrl_inw(port2adr(port)) & 0xff;
62 u16 titan_inw(unsigned long port)
65 return ctrl_inw(port);
66 else if (CHECK_SH7751_PCIIO(port))
67 return ctrl_inw(PCI_IOMAP(port));
68 else if (port >= 0x2000)
69 return ctrl_inw(port2adr(port));
75 u32 titan_inl(unsigned long port)
78 return ctrl_inl(port);
79 else if (CHECK_SH7751_PCIIO(port))
80 return ctrl_inl(PCI_IOMAP(port));
81 else if (port >= 0x2000)
82 return ctrl_inw(port2adr(port));
88 void titan_outb(u8 value, unsigned long port)
91 ctrl_outb(value, port);
92 else if (CHECK_SH7751_PCIIO(port))
93 ctrl_outb(value, PCI_IOMAP(port));
95 ctrl_outw(value, port2adr(port));
98 void titan_outb_p(u8 value, unsigned long port)
101 ctrl_outb(value, port);
102 else if (CHECK_SH7751_PCIIO(port))
103 ctrl_outb(value, PCI_IOMAP(port));
105 ctrl_outw(value, port2adr(port));
109 void titan_outw(u16 value, unsigned long port)
112 ctrl_outw(value, port);
113 else if (CHECK_SH7751_PCIIO(port))
114 ctrl_outw(value, PCI_IOMAP(port));
115 else if (port >= 0x2000)
116 ctrl_outw(value, port2adr(port));
121 void titan_outl(u32 value, unsigned long port)
124 ctrl_outl(value, port);
125 else if (CHECK_SH7751_PCIIO(port))
126 ctrl_outl(value, PCI_IOMAP(port));
131 void titan_insl(unsigned long port, void *dst, unsigned long count)
136 void titan_outsl(unsigned long port, const void *src, unsigned long count)
141 void __iomem *titan_ioport_map(unsigned long port, unsigned int size)
143 if (PXSEG(port) || CHECK_SH7751_PCIMEMIO(port))
144 return (void __iomem *)port;
145 else if (CHECK_SH7751_PCIIO(port))
146 return (void __iomem *)PCI_IOMAP(port);
148 return (void __iomem *)port2adr(port);