aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/renesas
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2006-09-27 03:43:28 -0400
committerPaul Mundt <lethal@linux-sh.org>2006-09-27 03:43:28 -0400
commit959f85f8a3223c116bbe95dd8a9b207790b5d4d3 (patch)
treee7da9ccf292f860bfa0ff9cc8b2682cd1d6bad4d /arch/sh/boards/renesas
parente108b2ca2349f510ce7d7f910eda89f71d710d84 (diff)
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>
Diffstat (limited to 'arch/sh/boards/renesas')
-rw-r--r--arch/sh/boards/renesas/hs7751rvoip/io.c116
-rw-r--r--arch/sh/boards/renesas/r7780rp/io.c103
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/io.c89
-rw-r--r--arch/sh/boards/renesas/systemh/io.c67
4 files changed, 121 insertions, 254 deletions
diff --git a/arch/sh/boards/renesas/hs7751rvoip/io.c b/arch/sh/boards/renesas/hs7751rvoip/io.c
index ecdce7ef6a34..8c26550ca2e4 100644
--- a/arch/sh/boards/renesas/hs7751rvoip/io.c
+++ b/arch/sh/boards/renesas/hs7751rvoip/io.c
@@ -13,14 +13,11 @@
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/types.h> 15#include <linux/types.h>
16#include <linux/module.h>
16#include <asm/io.h> 17#include <asm/io.h>
17#include <asm/hs7751rvoip/hs7751rvoip.h> 18#include <asm/hs7751rvoip/hs7751rvoip.h>
18#include <asm/addrspace.h> 19#include <asm/addrspace.h>
19 20
20#include <linux/module.h>
21#include <linux/pci.h>
22#include "../../../drivers/pci/pci-sh7751.h"
23
24extern void *area6_io8_base; /* Area 6 8bit I/O Base address */ 21extern void *area6_io8_base; /* Area 6 8bit I/O Base address */
25extern void *area5_io16_base; /* Area 5 16bit I/O Base address */ 22extern void *area5_io16_base; /* Area 5 16bit I/O Base address */
26 23
@@ -31,27 +28,17 @@ extern void *area5_io16_base; /* Area 5 16bit I/O Base address */
31 * like the other Solution Engine boards. 28 * like the other Solution Engine boards.
32 */ 29 */
33 30
34#define PCIIOBR (volatile long *)PCI_REG(SH7751_PCIIOBR)
35#define PCIMBR (volatile long *)PCI_REG(SH7751_PCIMBR)
36#define PCI_IO_AREA SH7751_PCI_IO_BASE
37#define PCI_MEM_AREA SH7751_PCI_CONFIG_BASE
38#define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
39
40#define CODEC_IO_BASE 0x1000 31#define CODEC_IO_BASE 0x1000
41#define CODEC_IOMAP(a) ((unsigned long)area6_io8_base + ((a) - CODEC_IO_BASE)) 32#define CODEC_IOMAP(a) ((unsigned long)area6_io8_base + ((a) - CODEC_IO_BASE))
42 33
43static inline void delay(void)
44{
45 ctrl_inw(0xa0000000);
46}
47
48static inline unsigned long port2adr(unsigned int port) 34static inline unsigned long port2adr(unsigned int port)
49{ 35{
50 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6) 36 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
51 if (port == 0x3f6) 37 if (port == 0x3f6)
52 return ((unsigned long)area5_io16_base + 0x0c); 38 return ((unsigned long)area5_io16_base + 0x0c);
53 else 39 else
54 return ((unsigned long)area5_io16_base + 0x800 + ((port-0x1f0) << 1)); 40 return ((unsigned long)area5_io16_base + 0x800 +
41 ((port-0x1f0) << 1));
55 else 42 else
56 maybebadio((unsigned long)port); 43 maybebadio((unsigned long)port);
57 return port; 44 return port;
@@ -70,25 +57,10 @@ static inline int shifted_port(unsigned long port)
70} 57}
71 58
72#if defined(CONFIG_HS7751RVOIP_CODEC) 59#if defined(CONFIG_HS7751RVOIP_CODEC)
73static inline int 60#define codec_port(port) \
74codec_port(unsigned long port) 61 ((CODEC_IO_BASE <= (port)) && ((port) < (CODEC_IO_BASE + 0x20)))
75{
76 if (CODEC_IO_BASE <= port && port < (CODEC_IO_BASE+0x20))
77 return 1;
78 else
79 return 0;
80}
81#endif
82
83/* In case someone configures the kernel w/o PCI support: in that */
84/* scenario, don't ever bother to check for PCI-window addresses */
85
86/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
87#if defined(CONFIG_PCI)
88#define CHECK_SH7751_PCIIO(port) \
89 ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
90#else 62#else
91#define CHECK_SH7751_PCIIO(port) (0) 63#define codec_port(port) (0)
92#endif 64#endif
93 65
94/* 66/*
@@ -102,12 +74,10 @@ unsigned char hs7751rvoip_inb(unsigned long port)
102{ 74{
103 if (PXSEG(port)) 75 if (PXSEG(port))
104 return ctrl_inb(port); 76 return ctrl_inb(port);
105#if defined(CONFIG_HS7751RVOIP_CODEC)
106 else if (codec_port(port)) 77 else if (codec_port(port))
107 return ctrl_inb(CODEC_IOMAP(port)); 78 return ctrl_inb(CODEC_IOMAP(port));
108#endif 79 else if (is_pci_ioaddr(port) || shifted_port(port))
109 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 80 return ctrl_inb(pci_ioaddr(port));
110 return ctrl_inb(PCI_IOMAP(port));
111 else 81 else
112 return ctrl_inw(port2adr(port)) & 0xff; 82 return ctrl_inw(port2adr(port)) & 0xff;
113} 83}
@@ -118,15 +88,13 @@ unsigned char hs7751rvoip_inb_p(unsigned long port)
118 88
119 if (PXSEG(port)) 89 if (PXSEG(port))
120 v = ctrl_inb(port); 90 v = ctrl_inb(port);
121#if defined(CONFIG_HS7751RVOIP_CODEC)
122 else if (codec_port(port)) 91 else if (codec_port(port))
123 v = ctrl_inb(CODEC_IOMAP(port)); 92 v = ctrl_inb(CODEC_IOMAP(port));
124#endif 93 else if (is_pci_ioaddr(port) || shifted_port(port))
125 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 94 v = ctrl_inb(pci_ioaddr(port));
126 v = ctrl_inb(PCI_IOMAP(port));
127 else 95 else
128 v = ctrl_inw(port2adr(port)) & 0xff; 96 v = ctrl_inw(port2adr(port)) & 0xff;
129 delay(); 97 ctrl_delay();
130 return v; 98 return v;
131} 99}
132 100
@@ -134,8 +102,8 @@ unsigned short hs7751rvoip_inw(unsigned long port)
134{ 102{
135 if (PXSEG(port)) 103 if (PXSEG(port))
136 return ctrl_inw(port); 104 return ctrl_inw(port);
137 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 105 else if (is_pci_ioaddr(port) || shifted_port(port))
138 return ctrl_inw(PCI_IOMAP(port)); 106 return ctrl_inw(pci_ioaddr(port));
139 else 107 else
140 maybebadio(port); 108 maybebadio(port);
141 return 0; 109 return 0;
@@ -145,8 +113,8 @@ unsigned int hs7751rvoip_inl(unsigned long port)
145{ 113{
146 if (PXSEG(port)) 114 if (PXSEG(port))
147 return ctrl_inl(port); 115 return ctrl_inl(port);
148 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 116 else if (is_pci_ioaddr(port) || shifted_port(port))
149 return ctrl_inl(PCI_IOMAP(port)); 117 return ctrl_inl(pci_ioaddr(port));
150 else 118 else
151 maybebadio(port); 119 maybebadio(port);
152 return 0; 120 return 0;
@@ -157,12 +125,10 @@ void hs7751rvoip_outb(unsigned char value, unsigned long port)
157 125
158 if (PXSEG(port)) 126 if (PXSEG(port))
159 ctrl_outb(value, port); 127 ctrl_outb(value, port);
160#if defined(CONFIG_HS7751RVOIP_CODEC)
161 else if (codec_port(port)) 128 else if (codec_port(port))
162 ctrl_outb(value, CODEC_IOMAP(port)); 129 ctrl_outb(value, CODEC_IOMAP(port));
163#endif 130 else if (is_pci_ioaddr(port) || shifted_port(port))
164 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 131 ctrl_outb(value, pci_ioaddr(port));
165 ctrl_outb(value, PCI_IOMAP(port));
166 else 132 else
167 ctrl_outb(value, port2adr(port)); 133 ctrl_outb(value, port2adr(port));
168} 134}
@@ -171,24 +137,22 @@ void hs7751rvoip_outb_p(unsigned char value, unsigned long port)
171{ 137{
172 if (PXSEG(port)) 138 if (PXSEG(port))
173 ctrl_outb(value, port); 139 ctrl_outb(value, port);
174#if defined(CONFIG_HS7751RVOIP_CODEC)
175 else if (codec_port(port)) 140 else if (codec_port(port))
176 ctrl_outb(value, CODEC_IOMAP(port)); 141 ctrl_outb(value, CODEC_IOMAP(port));
177#endif 142 else if (is_pci_ioaddr(port) || shifted_port(port))
178 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 143 ctrl_outb(value, pci_ioaddr(port));
179 ctrl_outb(value, PCI_IOMAP(port));
180 else 144 else
181 ctrl_outw(value, port2adr(port)); 145 ctrl_outw(value, port2adr(port));
182 146
183 delay(); 147 ctrl_delay();
184} 148}
185 149
186void hs7751rvoip_outw(unsigned short value, unsigned long port) 150void hs7751rvoip_outw(unsigned short value, unsigned long port)
187{ 151{
188 if (PXSEG(port)) 152 if (PXSEG(port))
189 ctrl_outw(value, port); 153 ctrl_outw(value, port);
190 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 154 else if (is_pci_ioaddr(port) || shifted_port(port))
191 ctrl_outw(value, PCI_IOMAP(port)); 155 ctrl_outw(value, pci_ioaddr(port));
192 else 156 else
193 maybebadio(port); 157 maybebadio(port);
194} 158}
@@ -197,8 +161,8 @@ void hs7751rvoip_outl(unsigned int value, unsigned long port)
197{ 161{
198 if (PXSEG(port)) 162 if (PXSEG(port))
199 ctrl_outl(value, port); 163 ctrl_outl(value, port);
200 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 164 else if (is_pci_ioaddr(port) || shifted_port(port))
201 ctrl_outl(value, PCI_IOMAP(port)); 165 ctrl_outl(value, pci_ioaddr(port));
202 else 166 else
203 maybebadio(port); 167 maybebadio(port);
204} 168}
@@ -210,13 +174,11 @@ void hs7751rvoip_insb(unsigned long port, void *addr, unsigned long count)
210 if (PXSEG(port)) 174 if (PXSEG(port))
211 while (count--) 175 while (count--)
212 *buf++ = ctrl_inb(port); 176 *buf++ = ctrl_inb(port);
213#if defined(CONFIG_HS7751RVOIP_CODEC)
214 else if (codec_port(port)) 177 else if (codec_port(port))
215 while (count--) 178 while (count--)
216 *buf++ = ctrl_inb(CODEC_IOMAP(port)); 179 *buf++ = ctrl_inb(CODEC_IOMAP(port));
217#endif 180 else if (is_pci_ioaddr(port) || shifted_port(port)) {
218 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { 181 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);
219 volatile u8 *bp = (volatile u8 *)PCI_IOMAP(port);
220 182
221 while (count--) 183 while (count--)
222 *buf++ = *bp; 184 *buf++ = *bp;
@@ -235,8 +197,8 @@ void hs7751rvoip_insw(unsigned long port, void *addr, unsigned long count)
235 197
236 if (PXSEG(port)) 198 if (PXSEG(port))
237 p = (volatile u16 *)port; 199 p = (volatile u16 *)port;
238 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 200 else if (is_pci_ioaddr(port) || shifted_port(port))
239 p = (volatile u16 *)PCI_IOMAP(port); 201 p = (volatile u16 *)pci_ioaddr(port);
240 else 202 else
241 p = (volatile u16 *)port2adr(port); 203 p = (volatile u16 *)port2adr(port);
242 while (count--) 204 while (count--)
@@ -246,8 +208,8 @@ void hs7751rvoip_insw(unsigned long port, void *addr, unsigned long count)
246void hs7751rvoip_insl(unsigned long port, void *addr, unsigned long count) 208void hs7751rvoip_insl(unsigned long port, void *addr, unsigned long count)
247{ 209{
248 210
249 if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { 211 if (is_pci_ioaddr(port) || shifted_port(port)) {
250 volatile u32 *p = (volatile u32 *)PCI_IOMAP(port); 212 volatile u32 *p = (volatile u32 *)pci_ioaddr(port);
251 u32 *buf = addr; 213 u32 *buf = addr;
252 214
253 while (count--) 215 while (count--)
@@ -263,13 +225,11 @@ void hs7751rvoip_outsb(unsigned long port, const void *addr, unsigned long count
263 if (PXSEG(port)) 225 if (PXSEG(port))
264 while (count--) 226 while (count--)
265 ctrl_outb(*buf++, port); 227 ctrl_outb(*buf++, port);
266#if defined(CONFIG_HS7751RVOIP_CODEC)
267 else if (codec_port(port)) 228 else if (codec_port(port))
268 while (count--) 229 while (count--)
269 ctrl_outb(*buf++, CODEC_IOMAP(port)); 230 ctrl_outb(*buf++, CODEC_IOMAP(port));
270#endif 231 else if (is_pci_ioaddr(port) || shifted_port(port)) {
271 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { 232 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);
272 volatile u8 *bp = (volatile u8 *)PCI_IOMAP(port);
273 233
274 while (count--) 234 while (count--)
275 *bp = *buf++; 235 *bp = *buf++;
@@ -288,8 +248,8 @@ void hs7751rvoip_outsw(unsigned long port, const void *addr, unsigned long count
288 248
289 if (PXSEG(port)) 249 if (PXSEG(port))
290 p = (volatile u16 *)port; 250 p = (volatile u16 *)port;
291 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 251 else if (is_pci_ioaddr(port) || shifted_port(port))
292 p = (volatile u16 *)PCI_IOMAP(port); 252 p = (volatile u16 *)pci_ioaddr(port);
293 else 253 else
294 p = (volatile u16 *)port2adr(port); 254 p = (volatile u16 *)port2adr(port);
295 255
@@ -301,8 +261,8 @@ void hs7751rvoip_outsl(unsigned long port, const void *addr, unsigned long count
301{ 261{
302 const u32 *buf = addr; 262 const u32 *buf = addr;
303 263
304 if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { 264 if (is_pci_ioaddr(port) || shifted_port(port)) {
305 volatile u32 *p = (volatile u32 *)PCI_IOMAP(port); 265 volatile u32 *p = (volatile u32 *)pci_ioaddr(port);
306 266
307 while (count--) 267 while (count--)
308 *p = *buf++; 268 *p = *buf++;
@@ -316,8 +276,8 @@ void __iomem *hs7751rvoip_ioport_map(unsigned long port, unsigned int size)
316 return (void __iomem *)port; 276 return (void __iomem *)port;
317 else if (unlikely(codec_port(port) && (size == 1))) 277 else if (unlikely(codec_port(port) && (size == 1)))
318 return (void __iomem *)CODEC_IOMAP(port); 278 return (void __iomem *)CODEC_IOMAP(port);
319 else if (CHECK_SH7751_PCIIO(port)) 279 else if (is_pci_ioaddr(port))
320 return (void __iomem *)PCI_IOMAP(port); 280 return (void __iomem *)pci_ioaddr(port);
321 281
322 return (void __iomem *)port2adr(port); 282 return (void __iomem *)port2adr(port);
323} 283}
diff --git a/arch/sh/boards/renesas/r7780rp/io.c b/arch/sh/boards/renesas/r7780rp/io.c
index f73ca3f0f5a1..db92d6e6ae99 100644
--- a/arch/sh/boards/renesas/r7780rp/io.c
+++ b/arch/sh/boards/renesas/r7780rp/io.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/sh/kernel/io_r7780rp.c
3 *
4 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel 2 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
5 * Based largely on io_se.c. 3 * Based largely on io_se.c.
6 * 4 *
@@ -10,37 +8,13 @@
10 * placeholder code from io_r7780rp.c left in with the 8 * placeholder code from io_r7780rp.c left in with the
11 * expectation of later SuperIO and PCMCIA access. 9 * expectation of later SuperIO and PCMCIA access.
12 */ 10 */
13 11#include <linux/pci.h>
14#include <linux/kernel.h> 12#include <linux/kernel.h>
15#include <linux/types.h> 13#include <linux/types.h>
16#include <asm/r7780rp/r7780rp.h> 14#include <asm/r7780rp/r7780rp.h>
17#include <asm/addrspace.h> 15#include <asm/addrspace.h>
18#include <asm/io.h> 16#include <asm/io.h>
19 17
20#include <linux/module.h>
21#include <linux/pci.h>
22#include "../../../drivers/pci/pci-sh7780.h"
23
24/*
25 * The 7780 R7780RP-1 uses the built-in PCI controller (PCIC)
26 * of the 7780 processor, and has a SuperIO accessible via the PCI.
27 * The board also includes a PCMCIA controller on its memory bus,
28 * like the other Solution Engine boards.
29 */
30
31#define SH7780_PCIIOBR_MASK 0xFFFC0000 /* IO Space Mask */
32#define PCIIOBR (volatile long *)PCI_REG(SH7780_PCIIOBR)
33#define PCIMBR (volatile long *)PCI_REG(SH7780_PCIMBR)
34#define PCI_IO_AREA SH7780_PCI_IO_BASE
35#define PCI_MEM_AREA SH7780_PCI_CONFIG_BASE
36
37#define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7780_PCIIOBR_MASK))
38
39static inline void delay(void)
40{
41 ctrl_inw(0xa0000000);
42}
43
44static inline unsigned long port2adr(unsigned int port) 18static inline unsigned long port2adr(unsigned int port)
45{ 19{
46 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6) 20 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
@@ -78,17 +52,6 @@ static inline int shifted_port(unsigned long port)
78 return 1; 52 return 1;
79} 53}
80 54
81/* In case someone configures the kernel w/o PCI support: in that */
82/* scenario, don't ever bother to check for PCI-window addresses */
83
84/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
85#if defined(CONFIG_PCI)
86#define CHECK_SH7780_PCIIO(port) \
87 ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7780_PCI_IO_SIZE)))
88#else
89#define CHECK_SH7780_PCIIO(port) (0)
90#endif
91
92#if defined(CONFIG_NE2000) || defined(CONFIG_NE2000_MODULE) 55#if defined(CONFIG_NE2000) || defined(CONFIG_NE2000_MODULE)
93#define CHECK_AX88796L_PORT(port) \ 56#define CHECK_AX88796L_PORT(port) \
94 ((port >= AX88796L_IO_BASE) && (port < (AX88796L_IO_BASE+0x20))) 57 ((port >= AX88796L_IO_BASE) && (port < (AX88796L_IO_BASE+0x20)))
@@ -109,8 +72,8 @@ u8 r7780rp_inb(unsigned long port)
109 return ctrl_inw(port88796l(port, 0)) & 0xff; 72 return ctrl_inw(port88796l(port, 0)) & 0xff;
110 else if (PXSEG(port)) 73 else if (PXSEG(port))
111 return ctrl_inb(port); 74 return ctrl_inb(port);
112 else if (CHECK_SH7780_PCIIO(port) || shifted_port(port)) 75 else if (is_pci_ioaddr(port) || shifted_port(port))
113 return ctrl_inb(PCI_IOMAP(port)); 76 return ctrl_inb(pci_ioaddr(port));
114 77
115 return ctrl_inw(port2adr(port)) & 0xff; 78 return ctrl_inw(port2adr(port)) & 0xff;
116} 79}
@@ -123,12 +86,12 @@ u8 r7780rp_inb_p(unsigned long port)
123 v = ctrl_inw(port88796l(port, 0)) & 0xff; 86 v = ctrl_inw(port88796l(port, 0)) & 0xff;
124 else if (PXSEG(port)) 87 else if (PXSEG(port))
125 v = ctrl_inb(port); 88 v = ctrl_inb(port);
126 else if (CHECK_SH7780_PCIIO(port) || shifted_port(port)) 89 else if (is_pci_ioaddr(port) || shifted_port(port))
127 v = ctrl_inb(PCI_IOMAP(port)); 90 v = ctrl_inb(pci_ioaddr(port));
128 else 91 else
129 v = ctrl_inw(port2adr(port)) & 0xff; 92 v = ctrl_inw(port2adr(port)) & 0xff;
130 93
131 delay(); 94 ctrl_delay();
132 95
133 return v; 96 return v;
134} 97}
@@ -139,8 +102,8 @@ u16 r7780rp_inw(unsigned long port)
139 maybebadio(port); 102 maybebadio(port);
140 else if (PXSEG(port)) 103 else if (PXSEG(port))
141 return ctrl_inw(port); 104 return ctrl_inw(port);
142 else if (CHECK_SH7780_PCIIO(port) || shifted_port(port)) 105 else if (is_pci_ioaddr(port) || shifted_port(port))
143 return ctrl_inw(PCI_IOMAP(port)); 106 return ctrl_inw(pci_ioaddr(port));
144 else 107 else
145 maybebadio(port); 108 maybebadio(port);
146 109
@@ -153,8 +116,8 @@ u32 r7780rp_inl(unsigned long port)
153 maybebadio(port); 116 maybebadio(port);
154 else if (PXSEG(port)) 117 else if (PXSEG(port))
155 return ctrl_inl(port); 118 return ctrl_inl(port);
156 else if (CHECK_SH7780_PCIIO(port) || shifted_port(port)) 119 else if (is_pci_ioaddr(port) || shifted_port(port))
157 return ctrl_inl(PCI_IOMAP(port)); 120 return ctrl_inl(pci_ioaddr(port));
158 else 121 else
159 maybebadio(port); 122 maybebadio(port);
160 123
@@ -167,8 +130,8 @@ void r7780rp_outb(u8 value, unsigned long port)
167 ctrl_outw(value, port88796l(port, 0)); 130 ctrl_outw(value, port88796l(port, 0));
168 else if (PXSEG(port)) 131 else if (PXSEG(port))
169 ctrl_outb(value, port); 132 ctrl_outb(value, port);
170 else if (CHECK_SH7780_PCIIO(port) || shifted_port(port)) 133 else if (is_pci_ioaddr(port) || shifted_port(port))
171 ctrl_outb(value, PCI_IOMAP(port)); 134 ctrl_outb(value, pci_ioaddr(port));
172 else 135 else
173 ctrl_outw(value, port2adr(port)); 136 ctrl_outw(value, port2adr(port));
174} 137}
@@ -179,12 +142,12 @@ void r7780rp_outb_p(u8 value, unsigned long port)
179 ctrl_outw(value, port88796l(port, 0)); 142 ctrl_outw(value, port88796l(port, 0));
180 else if (PXSEG(port)) 143 else if (PXSEG(port))
181 ctrl_outb(value, port); 144 ctrl_outb(value, port);
182 else if (CHECK_SH7780_PCIIO(port) || shifted_port(port)) 145 else if (is_pci_ioaddr(port) || shifted_port(port))
183 ctrl_outb(value, PCI_IOMAP(port)); 146 ctrl_outb(value, pci_ioaddr(port));
184 else 147 else
185 ctrl_outw(value, port2adr(port)); 148 ctrl_outw(value, port2adr(port));
186 149
187 delay(); 150 ctrl_delay();
188} 151}
189 152
190void r7780rp_outw(u16 value, unsigned long port) 153void r7780rp_outw(u16 value, unsigned long port)
@@ -193,8 +156,8 @@ void r7780rp_outw(u16 value, unsigned long port)
193 maybebadio(port); 156 maybebadio(port);
194 else if (PXSEG(port)) 157 else if (PXSEG(port))
195 ctrl_outw(value, port); 158 ctrl_outw(value, port);
196 else if (CHECK_SH7780_PCIIO(port) || shifted_port(port)) 159 else if (is_pci_ioaddr(port) || shifted_port(port))
197 ctrl_outw(value, PCI_IOMAP(port)); 160 ctrl_outw(value, pci_ioaddr(port));
198 else 161 else
199 maybebadio(port); 162 maybebadio(port);
200} 163}
@@ -205,8 +168,8 @@ void r7780rp_outl(u32 value, unsigned long port)
205 maybebadio(port); 168 maybebadio(port);
206 else if (PXSEG(port)) 169 else if (PXSEG(port))
207 ctrl_outl(value, port); 170 ctrl_outl(value, port);
208 else if (CHECK_SH7780_PCIIO(port) || shifted_port(port)) 171 else if (is_pci_ioaddr(port) || shifted_port(port))
209 ctrl_outl(value, PCI_IOMAP(port)); 172 ctrl_outl(value, pci_ioaddr(port));
210 else 173 else
211 maybebadio(port); 174 maybebadio(port);
212} 175}
@@ -223,8 +186,8 @@ void r7780rp_insb(unsigned long port, void *dst, unsigned long count)
223 } else if (PXSEG(port)) { 186 } else if (PXSEG(port)) {
224 while (count--) 187 while (count--)
225 *buf++ = *(volatile u8 *)port; 188 *buf++ = *(volatile u8 *)port;
226 } else if (CHECK_SH7780_PCIIO(port) || shifted_port(port)) { 189 } else if (is_pci_ioaddr(port) || shifted_port(port)) {
227 volatile u8 *bp = (volatile u8 *)PCI_IOMAP(port); 190 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);
228 191
229 while (count--) 192 while (count--)
230 *buf++ = *bp; 193 *buf++ = *bp;
@@ -244,8 +207,8 @@ void r7780rp_insw(unsigned long port, void *dst, unsigned long count)
244 p = (volatile u16 *)port88796l(port, 1); 207 p = (volatile u16 *)port88796l(port, 1);
245 else if (PXSEG(port)) 208 else if (PXSEG(port))
246 p = (volatile u16 *)port; 209 p = (volatile u16 *)port;
247 else if (CHECK_SH7780_PCIIO(port) || shifted_port(port)) 210 else if (is_pci_ioaddr(port) || shifted_port(port))
248 p = (volatile u16 *)PCI_IOMAP(port); 211 p = (volatile u16 *)pci_ioaddr(port);
249 else 212 else
250 p = (volatile u16 *)port2adr(port); 213 p = (volatile u16 *)port2adr(port);
251 214
@@ -259,8 +222,8 @@ void r7780rp_insl(unsigned long port, void *dst, unsigned long count)
259 222
260 if (CHECK_AX88796L_PORT(port)) 223 if (CHECK_AX88796L_PORT(port))
261 maybebadio(port); 224 maybebadio(port);
262 else if (CHECK_SH7780_PCIIO(port) || shifted_port(port)) { 225 else if (is_pci_ioaddr(port) || shifted_port(port)) {
263 volatile u32 *p = (volatile u32 *)PCI_IOMAP(port); 226 volatile u32 *p = (volatile u32 *)pci_ioaddr(port);
264 227
265 while (count--) 228 while (count--)
266 *buf++ = *p; 229 *buf++ = *p;
@@ -280,8 +243,8 @@ void r7780rp_outsb(unsigned long port, const void *src, unsigned long count)
280 } else if (PXSEG(port)) 243 } else if (PXSEG(port))
281 while (count--) 244 while (count--)
282 ctrl_outb(*buf++, port); 245 ctrl_outb(*buf++, port);
283 else if (CHECK_SH7780_PCIIO(port) || shifted_port(port)) { 246 else if (is_pci_ioaddr(port) || shifted_port(port)) {
284 volatile u8 *bp = (volatile u8 *)PCI_IOMAP(port); 247 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);
285 248
286 while (count--) 249 while (count--)
287 *bp = *buf++; 250 *bp = *buf++;
@@ -301,8 +264,8 @@ void r7780rp_outsw(unsigned long port, const void *src, unsigned long count)
301 p = (volatile u16 *)port88796l(port, 1); 264 p = (volatile u16 *)port88796l(port, 1);
302 else if (PXSEG(port)) 265 else if (PXSEG(port))
303 p = (volatile u16 *)port; 266 p = (volatile u16 *)port;
304 else if (CHECK_SH7780_PCIIO(port) || shifted_port(port)) 267 else if (is_pci_ioaddr(port) || shifted_port(port))
305 p = (volatile u16 *)PCI_IOMAP(port); 268 p = (volatile u16 *)pci_ioaddr(port);
306 else 269 else
307 p = (volatile u16 *)port2adr(port); 270 p = (volatile u16 *)port2adr(port);
308 271
@@ -316,8 +279,8 @@ void r7780rp_outsl(unsigned long port, const void *src, unsigned long count)
316 279
317 if (CHECK_AX88796L_PORT(port)) 280 if (CHECK_AX88796L_PORT(port))
318 maybebadio(port); 281 maybebadio(port);
319 else if (CHECK_SH7780_PCIIO(port) || shifted_port(port)) { 282 else if (is_pci_ioaddr(port) || shifted_port(port)) {
320 volatile u32 *p = (volatile u32 *)PCI_IOMAP(port); 283 volatile u32 *p = (volatile u32 *)pci_ioaddr(port);
321 284
322 while (count--) 285 while (count--)
323 *p = *buf++; 286 *p = *buf++;
@@ -331,8 +294,8 @@ void __iomem *r7780rp_ioport_map(unsigned long port, unsigned int size)
331 return (void __iomem *)port88796l(port, size > 1); 294 return (void __iomem *)port88796l(port, size > 1);
332 else if (PXSEG(port)) 295 else if (PXSEG(port))
333 return (void __iomem *)port; 296 return (void __iomem *)port;
334 else if (CHECK_SH7780_PCIIO(port) || shifted_port(port)) 297 else if (is_pci_ioaddr(port) || shifted_port(port))
335 return (void __iomem *)PCI_IOMAP(port); 298 return (void __iomem *)pci_ioaddr(port);
336 299
337 return (void __iomem *)port2adr(port); 300 return (void __iomem *)port2adr(port);
338} 301}
diff --git a/arch/sh/boards/renesas/rts7751r2d/io.c b/arch/sh/boards/renesas/rts7751r2d/io.c
index 8dc2a2e2e5df..135aa0b5e62d 100644
--- a/arch/sh/boards/renesas/rts7751r2d/io.c
+++ b/arch/sh/boards/renesas/rts7751r2d/io.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/sh/kernel/io_rts7751r2d.c
3 *
4 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel 2 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
5 * Based largely on io_se.c. 3 * Based largely on io_se.c.
6 * 4 *
@@ -10,11 +8,9 @@
10 * placeholder code from io_rts7751r2d.c left in with the 8 * placeholder code from io_rts7751r2d.c left in with the
11 * expectation of later SuperIO and PCMCIA access. 9 * expectation of later SuperIO and PCMCIA access.
12 */ 10 */
13
14#include <linux/kernel.h> 11#include <linux/kernel.h>
15#include <linux/types.h> 12#include <linux/types.h>
16#include <linux/pci.h> 13#include <linux/pci.h>
17#include "../../../drivers/pci/pci-sh7751.h"
18#include <asm/rts7751r2d/rts7751r2d.h> 14#include <asm/rts7751r2d/rts7751r2d.h>
19#include <asm/io.h> 15#include <asm/io.h>
20#include <asm/addrspace.h> 16#include <asm/addrspace.h>
@@ -26,18 +22,6 @@
26 * like the other Solution Engine boards. 22 * like the other Solution Engine boards.
27 */ 23 */
28 24
29#define PCIIOBR (volatile long *)PCI_REG(SH7751_PCIIOBR)
30#define PCIMBR (volatile long *)PCI_REG(SH7751_PCIMBR)
31#define PCI_IO_AREA SH7751_PCI_IO_BASE
32#define PCI_MEM_AREA SH7751_PCI_CONFIG_BASE
33
34#define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
35
36static inline void delay(void)
37{
38 ctrl_inw(0xa0000000);
39}
40
41static inline unsigned long port2adr(unsigned int port) 25static inline unsigned long port2adr(unsigned int port)
42{ 26{
43 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6) 27 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
@@ -75,17 +59,6 @@ static inline int shifted_port(unsigned long port)
75 return 1; 59 return 1;
76} 60}
77 61
78/* In case someone configures the kernel w/o PCI support: in that */
79/* scenario, don't ever bother to check for PCI-window addresses */
80
81/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
82#if defined(CONFIG_PCI)
83#define CHECK_SH7751_PCIIO(port) \
84 ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
85#else
86#define CHECK_SH7751_PCIIO(port) (0)
87#endif
88
89#if defined(CONFIG_NE2000) || defined(CONFIG_NE2000_MODULE) 62#if defined(CONFIG_NE2000) || defined(CONFIG_NE2000_MODULE)
90#define CHECK_AX88796L_PORT(port) \ 63#define CHECK_AX88796L_PORT(port) \
91 ((port >= AX88796L_IO_BASE) && (port < (AX88796L_IO_BASE+0x20))) 64 ((port >= AX88796L_IO_BASE) && (port < (AX88796L_IO_BASE+0x20)))
@@ -106,8 +79,8 @@ unsigned char rts7751r2d_inb(unsigned long port)
106 return (*(volatile unsigned short *)port88796l(port, 0)) & 0xff; 79 return (*(volatile unsigned short *)port88796l(port, 0)) & 0xff;
107 else if (PXSEG(port)) 80 else if (PXSEG(port))
108 return *(volatile unsigned char *)port; 81 return *(volatile unsigned char *)port;
109 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 82 else if (is_pci_ioaddr(port) || shifted_port(port))
110 return *(volatile unsigned char *)PCI_IOMAP(port); 83 return *(volatile unsigned char *)pci_ioaddr(port);
111 else 84 else
112 return (*(volatile unsigned short *)port2adr(port) & 0xff); 85 return (*(volatile unsigned short *)port2adr(port) & 0xff);
113} 86}
@@ -120,11 +93,12 @@ unsigned char rts7751r2d_inb_p(unsigned long port)
120 v = (*(volatile unsigned short *)port88796l(port, 0)) & 0xff; 93 v = (*(volatile unsigned short *)port88796l(port, 0)) & 0xff;
121 else if (PXSEG(port)) 94 else if (PXSEG(port))
122 v = *(volatile unsigned char *)port; 95 v = *(volatile unsigned char *)port;
123 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 96 else if (is_pci_ioaddr(port) || shifted_port(port))
124 v = *(volatile unsigned char *)PCI_IOMAP(port); 97 v = *(volatile unsigned char *)pci_ioaddr(port);
125 else 98 else
126 v = (*(volatile unsigned short *)port2adr(port) & 0xff); 99 v = (*(volatile unsigned short *)port2adr(port) & 0xff);
127 delay(); 100
101 ctrl_delay();
128 102
129 return v; 103 return v;
130} 104}
@@ -135,8 +109,8 @@ unsigned short rts7751r2d_inw(unsigned long port)
135 maybebadio(port); 109 maybebadio(port);
136 else if (PXSEG(port)) 110 else if (PXSEG(port))
137 return *(volatile unsigned short *)port; 111 return *(volatile unsigned short *)port;
138 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 112 else if (is_pci_ioaddr(port) || shifted_port(port))
139 return *(volatile unsigned short *)PCI_IOMAP(port); 113 return *(volatile unsigned short *)pci_ioaddr(port);
140 else 114 else
141 maybebadio(port); 115 maybebadio(port);
142 116
@@ -149,8 +123,8 @@ unsigned int rts7751r2d_inl(unsigned long port)
149 maybebadio(port); 123 maybebadio(port);
150 else if (PXSEG(port)) 124 else if (PXSEG(port))
151 return *(volatile unsigned long *)port; 125 return *(volatile unsigned long *)port;
152 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 126 else if (is_pci_ioaddr(port) || shifted_port(port))
153 return *(volatile unsigned long *)PCI_IOMAP(port); 127 return *(volatile unsigned long *)pci_ioaddr(port);
154 else 128 else
155 maybebadio(port); 129 maybebadio(port);
156 130
@@ -163,8 +137,8 @@ void rts7751r2d_outb(unsigned char value, unsigned long port)
163 *((volatile unsigned short *)port88796l(port, 0)) = value; 137 *((volatile unsigned short *)port88796l(port, 0)) = value;
164 else if (PXSEG(port)) 138 else if (PXSEG(port))
165 *(volatile unsigned char *)port = value; 139 *(volatile unsigned char *)port = value;
166 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 140 else if (is_pci_ioaddr(port) || shifted_port(port))
167 *(volatile unsigned char *)PCI_IOMAP(port) = value; 141 *(volatile unsigned char *)pci_ioaddr(port) = value;
168 else 142 else
169 *(volatile unsigned short *)port2adr(port) = value; 143 *(volatile unsigned short *)port2adr(port) = value;
170} 144}
@@ -175,11 +149,12 @@ void rts7751r2d_outb_p(unsigned char value, unsigned long port)
175 *((volatile unsigned short *)port88796l(port, 0)) = value; 149 *((volatile unsigned short *)port88796l(port, 0)) = value;
176 else if (PXSEG(port)) 150 else if (PXSEG(port))
177 *(volatile unsigned char *)port = value; 151 *(volatile unsigned char *)port = value;
178 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 152 else if (is_pci_ioaddr(port) || shifted_port(port))
179 *(volatile unsigned char *)PCI_IOMAP(port) = value; 153 *(volatile unsigned char *)pci_ioaddr(port) = value;
180 else 154 else
181 *(volatile unsigned short *)port2adr(port) = value; 155 *(volatile unsigned short *)port2adr(port) = value;
182 delay(); 156
157 ctrl_delay();
183} 158}
184 159
185void rts7751r2d_outw(unsigned short value, unsigned long port) 160void rts7751r2d_outw(unsigned short value, unsigned long port)
@@ -188,8 +163,8 @@ void rts7751r2d_outw(unsigned short value, unsigned long port)
188 maybebadio(port); 163 maybebadio(port);
189 else if (PXSEG(port)) 164 else if (PXSEG(port))
190 *(volatile unsigned short *)port = value; 165 *(volatile unsigned short *)port = value;
191 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 166 else if (is_pci_ioaddr(port) || shifted_port(port))
192 *(volatile unsigned short *)PCI_IOMAP(port) = value; 167 *(volatile unsigned short *)pci_ioaddr(port) = value;
193 else 168 else
194 maybebadio(port); 169 maybebadio(port);
195} 170}
@@ -200,8 +175,8 @@ void rts7751r2d_outl(unsigned int value, unsigned long port)
200 maybebadio(port); 175 maybebadio(port);
201 else if (PXSEG(port)) 176 else if (PXSEG(port))
202 *(volatile unsigned long *)port = value; 177 *(volatile unsigned long *)port = value;
203 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 178 else if (is_pci_ioaddr(port) || shifted_port(port))
204 *(volatile unsigned long *)PCI_IOMAP(port) = value; 179 *(volatile unsigned long *)pci_ioaddr(port) = value;
205 else 180 else
206 maybebadio(port); 181 maybebadio(port);
207} 182}
@@ -219,8 +194,8 @@ void rts7751r2d_insb(unsigned long port, void *addr, unsigned long count)
219 } else if (PXSEG(port)) 194 } else if (PXSEG(port))
220 while (count--) 195 while (count--)
221 ctrl_outb(ctrl_inb(port), a++); 196 ctrl_outb(ctrl_inb(port), a++);
222 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { 197 else if (is_pci_ioaddr(port) || shifted_port(port)) {
223 bp = (__u8 *)PCI_IOMAP(port); 198 bp = (__u8 *)pci_ioaddr(port);
224 while (count--) 199 while (count--)
225 ctrl_outb(*bp, a++); 200 ctrl_outb(*bp, a++);
226 } else { 201 } else {
@@ -239,8 +214,8 @@ void rts7751r2d_insw(unsigned long port, void *addr, unsigned long count)
239 p = (volatile unsigned short *)port88796l(port, 1); 214 p = (volatile unsigned short *)port88796l(port, 1);
240 else if (PXSEG(port)) 215 else if (PXSEG(port))
241 p = (volatile unsigned short *)port; 216 p = (volatile unsigned short *)port;
242 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 217 else if (is_pci_ioaddr(port) || shifted_port(port))
243 p = (volatile unsigned short *)PCI_IOMAP(port); 218 p = (volatile unsigned short *)pci_ioaddr(port);
244 else 219 else
245 p = (volatile unsigned short *)port2adr(port); 220 p = (volatile unsigned short *)port2adr(port);
246 while (count--) 221 while (count--)
@@ -251,11 +226,11 @@ void rts7751r2d_insl(unsigned long port, void *addr, unsigned long count)
251{ 226{
252 if (CHECK_AX88796L_PORT(port)) 227 if (CHECK_AX88796L_PORT(port))
253 maybebadio(port); 228 maybebadio(port);
254 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { 229 else if (is_pci_ioaddr(port) || shifted_port(port)) {
255 unsigned long a = (unsigned long)addr; 230 unsigned long a = (unsigned long)addr;
256 231
257 while (count--) { 232 while (count--) {
258 ctrl_outl(ctrl_inl(PCI_IOMAP(port)), a); 233 ctrl_outl(ctrl_inl(pci_ioaddr(port)), a);
259 a += 4; 234 a += 4;
260 } 235 }
261 } else 236 } else
@@ -275,8 +250,8 @@ void rts7751r2d_outsb(unsigned long port, const void *addr, unsigned long count)
275 } else if (PXSEG(port)) 250 } else if (PXSEG(port))
276 while (count--) 251 while (count--)
277 ctrl_outb(a++, port); 252 ctrl_outb(a++, port);
278 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { 253 else if (is_pci_ioaddr(port) || shifted_port(port)) {
279 bp = (__u8 *)PCI_IOMAP(port); 254 bp = (__u8 *)pci_ioaddr(port);
280 while (count--) 255 while (count--)
281 *bp = ctrl_inb(a++); 256 *bp = ctrl_inb(a++);
282 } else { 257 } else {
@@ -295,8 +270,8 @@ void rts7751r2d_outsw(unsigned long port, const void *addr, unsigned long count)
295 p = (volatile unsigned short *)port88796l(port, 1); 270 p = (volatile unsigned short *)port88796l(port, 1);
296 else if (PXSEG(port)) 271 else if (PXSEG(port))
297 p = (volatile unsigned short *)port; 272 p = (volatile unsigned short *)port;
298 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 273 else if (is_pci_ioaddr(port) || shifted_port(port))
299 p = (volatile unsigned short *)PCI_IOMAP(port); 274 p = (volatile unsigned short *)pci_ioaddr(port);
300 else 275 else
301 p = (volatile unsigned short *)port2adr(port); 276 p = (volatile unsigned short *)port2adr(port);
302 277
@@ -310,11 +285,11 @@ void rts7751r2d_outsl(unsigned long port, const void *addr, unsigned long count)
310{ 285{
311 if (CHECK_AX88796L_PORT(port)) 286 if (CHECK_AX88796L_PORT(port))
312 maybebadio(port); 287 maybebadio(port);
313 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { 288 else if (is_pci_ioaddr(port) || shifted_port(port)) {
314 unsigned long a = (unsigned long)addr; 289 unsigned long a = (unsigned long)addr;
315 290
316 while (count--) { 291 while (count--) {
317 ctrl_outl(ctrl_inl(a), PCI_IOMAP(port)); 292 ctrl_outl(ctrl_inl(a), pci_ioaddr(port));
318 a += 4; 293 a += 4;
319 } 294 }
320 } else 295 } else
diff --git a/arch/sh/boards/renesas/systemh/io.c b/arch/sh/boards/renesas/systemh/io.c
index 0befd4f9894c..cde6e5d192c4 100644
--- a/arch/sh/boards/renesas/systemh/io.c
+++ b/arch/sh/boards/renesas/systemh/io.c
@@ -5,36 +5,16 @@
5 * Based largely on io_se.c. 5 * Based largely on io_se.c.
6 * 6 *
7 * I/O routine for Hitachi 7751 Systemh. 7 * I/O routine for Hitachi 7751 Systemh.
8 *
9 */ 8 */
10
11#include <linux/kernel.h> 9#include <linux/kernel.h>
12#include <linux/types.h> 10#include <linux/types.h>
13#include <linux/pci.h> 11#include <linux/pci.h>
14#include <asm/systemh7751.h> 12#include <asm/systemh7751.h>
15#include <asm/addrspace.h> 13#include <asm/addrspace.h>
16#include <asm/io.h> 14#include <asm/io.h>
17#include "../../../drivers/pci/pci-sh7751.h"
18
19/*
20 * The 7751 SystemH Engine uses the built-in PCI controller (PCIC)
21 * of the 7751 processor, and has a SuperIO accessible on its memory
22 * bus.
23 */
24
25#define PCIIOBR (volatile long *)PCI_REG(SH7751_PCIIOBR)
26#define PCIMBR (volatile long *)PCI_REG(SH7751_PCIMBR)
27#define PCI_IO_AREA SH7751_PCI_IO_BASE
28#define PCI_MEM_AREA SH7751_PCI_CONFIG_BASE
29 15
30#define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
31#define ETHER_IOMAP(adr) (0xB3000000 + (adr)) /*map to 16bits access area 16#define ETHER_IOMAP(adr) (0xB3000000 + (adr)) /*map to 16bits access area
32 of smc lan chip*/ 17 of smc lan chip*/
33static inline void delay(void)
34{
35 ctrl_inw(0xa0000000);
36}
37
38static inline volatile __u16 * 18static inline volatile __u16 *
39port2adr(unsigned int port) 19port2adr(unsigned int port)
40{ 20{
@@ -44,17 +24,6 @@ port2adr(unsigned int port)
44 return (volatile __u16*)port; 24 return (volatile __u16*)port;
45} 25}
46 26
47/* In case someone configures the kernel w/o PCI support: in that */
48/* scenario, don't ever bother to check for PCI-window addresses */
49
50/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
51#if defined(CONFIG_PCI)
52#define CHECK_SH7751_PCIIO(port) \
53 ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
54#else
55#define CHECK_SH7751_PCIIO(port) (0)
56#endif
57
58/* 27/*
59 * General outline: remap really low stuff [eventually] to SuperIO, 28 * General outline: remap really low stuff [eventually] to SuperIO,
60 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO) 29 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
@@ -66,8 +35,8 @@ unsigned char sh7751systemh_inb(unsigned long port)
66{ 35{
67 if (PXSEG(port)) 36 if (PXSEG(port))
68 return *(volatile unsigned char *)port; 37 return *(volatile unsigned char *)port;
69 else if (CHECK_SH7751_PCIIO(port)) 38 else if (is_pci_ioaddr(port))
70 return *(volatile unsigned char *)PCI_IOMAP(port); 39 return *(volatile unsigned char *)pci_ioaddr(port);
71 else if (port <= 0x3F1) 40 else if (port <= 0x3F1)
72 return *(volatile unsigned char *)ETHER_IOMAP(port); 41 return *(volatile unsigned char *)ETHER_IOMAP(port);
73 else 42 else
@@ -80,13 +49,13 @@ unsigned char sh7751systemh_inb_p(unsigned long port)
80 49
81 if (PXSEG(port)) 50 if (PXSEG(port))
82 v = *(volatile unsigned char *)port; 51 v = *(volatile unsigned char *)port;
83 else if (CHECK_SH7751_PCIIO(port)) 52 else if (is_pci_ioaddr(port))
84 v = *(volatile unsigned char *)PCI_IOMAP(port); 53 v = *(volatile unsigned char *)pci_ioaddr(port);
85 else if (port <= 0x3F1) 54 else if (port <= 0x3F1)
86 v = *(volatile unsigned char *)ETHER_IOMAP(port); 55 v = *(volatile unsigned char *)ETHER_IOMAP(port);
87 else 56 else
88 v = (*port2adr(port))&0xff; 57 v = (*port2adr(port))&0xff;
89 delay(); 58 ctrl_delay();
90 return v; 59 return v;
91} 60}
92 61
@@ -94,8 +63,8 @@ unsigned short sh7751systemh_inw(unsigned long port)
94{ 63{
95 if (PXSEG(port)) 64 if (PXSEG(port))
96 return *(volatile unsigned short *)port; 65 return *(volatile unsigned short *)port;
97 else if (CHECK_SH7751_PCIIO(port)) 66 else if (is_pci_ioaddr(port))
98 return *(volatile unsigned short *)PCI_IOMAP(port); 67 return *(volatile unsigned short *)pci_ioaddr(port);
99 else if (port >= 0x2000) 68 else if (port >= 0x2000)
100 return *port2adr(port); 69 return *port2adr(port);
101 else if (port <= 0x3F1) 70 else if (port <= 0x3F1)
@@ -109,8 +78,8 @@ unsigned int sh7751systemh_inl(unsigned long port)
109{ 78{
110 if (PXSEG(port)) 79 if (PXSEG(port))
111 return *(volatile unsigned long *)port; 80 return *(volatile unsigned long *)port;
112 else if (CHECK_SH7751_PCIIO(port)) 81 else if (is_pci_ioaddr(port))
113 return *(volatile unsigned int *)PCI_IOMAP(port); 82 return *(volatile unsigned int *)pci_ioaddr(port);
114 else if (port >= 0x2000) 83 else if (port >= 0x2000)
115 return *port2adr(port); 84 return *port2adr(port);
116 else if (port <= 0x3F1) 85 else if (port <= 0x3F1)
@@ -125,8 +94,8 @@ void sh7751systemh_outb(unsigned char value, unsigned long port)
125 94
126 if (PXSEG(port)) 95 if (PXSEG(port))
127 *(volatile unsigned char *)port = value; 96 *(volatile unsigned char *)port = value;
128 else if (CHECK_SH7751_PCIIO(port)) 97 else if (is_pci_ioaddr(port))
129 *((unsigned char*)PCI_IOMAP(port)) = value; 98 *((unsigned char*)pci_ioaddr(port)) = value;
130 else if (port <= 0x3F1) 99 else if (port <= 0x3F1)
131 *(volatile unsigned char *)ETHER_IOMAP(port) = value; 100 *(volatile unsigned char *)ETHER_IOMAP(port) = value;
132 else 101 else
@@ -137,21 +106,21 @@ void sh7751systemh_outb_p(unsigned char value, unsigned long port)
137{ 106{
138 if (PXSEG(port)) 107 if (PXSEG(port))
139 *(volatile unsigned char *)port = value; 108 *(volatile unsigned char *)port = value;
140 else if (CHECK_SH7751_PCIIO(port)) 109 else if (is_pci_ioaddr(port))
141 *((unsigned char*)PCI_IOMAP(port)) = value; 110 *((unsigned char*)pci_ioaddr(port)) = value;
142 else if (port <= 0x3F1) 111 else if (port <= 0x3F1)
143 *(volatile unsigned char *)ETHER_IOMAP(port) = value; 112 *(volatile unsigned char *)ETHER_IOMAP(port) = value;
144 else 113 else
145 *(port2adr(port)) = value; 114 *(port2adr(port)) = value;
146 delay(); 115 ctrl_delay();
147} 116}
148 117
149void sh7751systemh_outw(unsigned short value, unsigned long port) 118void sh7751systemh_outw(unsigned short value, unsigned long port)
150{ 119{
151 if (PXSEG(port)) 120 if (PXSEG(port))
152 *(volatile unsigned short *)port = value; 121 *(volatile unsigned short *)port = value;
153 else if (CHECK_SH7751_PCIIO(port)) 122 else if (is_pci_ioaddr(port))
154 *((unsigned short *)PCI_IOMAP(port)) = value; 123 *((unsigned short *)pci_ioaddr(port)) = value;
155 else if (port >= 0x2000) 124 else if (port >= 0x2000)
156 *port2adr(port) = value; 125 *port2adr(port) = value;
157 else if (port <= 0x3F1) 126 else if (port <= 0x3F1)
@@ -164,8 +133,8 @@ void sh7751systemh_outl(unsigned int value, unsigned long port)
164{ 133{
165 if (PXSEG(port)) 134 if (PXSEG(port))
166 *(volatile unsigned long *)port = value; 135 *(volatile unsigned long *)port = value;
167 else if (CHECK_SH7751_PCIIO(port)) 136 else if (is_pci_ioaddr(port))
168 *((unsigned long*)PCI_IOMAP(port)) = value; 137 *((unsigned long*)pci_ioaddr(port)) = value;
169 else 138 else
170 maybebadio(port); 139 maybebadio(port);
171} 140}