diff options
author | Paul Mundt <lethal@linux-sh.org> | 2007-02-14 00:49:04 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2007-02-14 00:49:04 -0500 |
commit | 71074d3a2c70aa8a213222fef5014bfd9b3daf1f (patch) | |
tree | a8676aff8f72826910ede93a69f0afcb67ded2ea /arch/sh/boards/renesas | |
parent | db2e1fa3f0eefbbe04e90d6e4d290ee176b28248 (diff) |
sh: Fixup r7780rp pata_platform for devres conversion.
Tidy up the R7780RP I/O mapping routines and switch the
pata_platform resources to IORESOURCE_MEM types, killing off
the useless port->addr conversion.
This fixes up R7780RP to boot after the recent devres conversion.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/boards/renesas')
-rw-r--r-- | arch/sh/boards/renesas/r7780rp/io.c | 148 | ||||
-rw-r--r-- | arch/sh/boards/renesas/r7780rp/setup.c | 22 |
2 files changed, 53 insertions, 117 deletions
diff --git a/arch/sh/boards/renesas/r7780rp/io.c b/arch/sh/boards/renesas/r7780rp/io.c index 369cbf1cd471..f74d2ffb3851 100644 --- a/arch/sh/boards/renesas/r7780rp/io.c +++ b/arch/sh/boards/renesas/r7780rp/io.c | |||
@@ -11,22 +11,9 @@ | |||
11 | #include <linux/pci.h> | 11 | #include <linux/pci.h> |
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/types.h> | 13 | #include <linux/types.h> |
14 | #include <linux/io.h> | ||
14 | #include <asm/r7780rp.h> | 15 | #include <asm/r7780rp.h> |
15 | #include <asm/addrspace.h> | 16 | #include <asm/addrspace.h> |
16 | #include <asm/io.h> | ||
17 | |||
18 | static inline unsigned long port2adr(unsigned int port) | ||
19 | { | ||
20 | if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6) | ||
21 | if (port == 0x3f6) | ||
22 | return (PA_AREA5_IO + 0x80c); | ||
23 | else | ||
24 | return (PA_AREA5_IO + 0x1000 + ((port-0x1f0) << 1)); | ||
25 | else | ||
26 | maybebadio((unsigned long)port); | ||
27 | |||
28 | return port; | ||
29 | } | ||
30 | 17 | ||
31 | static inline unsigned long port88796l(unsigned int port, int flag) | 18 | static inline unsigned long port88796l(unsigned int port, int flag) |
32 | { | 19 | { |
@@ -40,18 +27,6 @@ static inline unsigned long port88796l(unsigned int port, int flag) | |||
40 | return addr; | 27 | return addr; |
41 | } | 28 | } |
42 | 29 | ||
43 | /* The 7780 R7780RP-1 seems to have everything hooked */ | ||
44 | /* up pretty normally (nothing on high-bytes only...) so this */ | ||
45 | /* shouldn't be needed */ | ||
46 | static inline int shifted_port(unsigned long port) | ||
47 | { | ||
48 | /* For IDE registers, value is not shifted */ | ||
49 | if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6) | ||
50 | return 0; | ||
51 | else | ||
52 | return 1; | ||
53 | } | ||
54 | |||
55 | #if defined(CONFIG_NE2000) || defined(CONFIG_NE2000_MODULE) | 30 | #if defined(CONFIG_NE2000) || defined(CONFIG_NE2000_MODULE) |
56 | #define CHECK_AX88796L_PORT(port) \ | 31 | #define CHECK_AX88796L_PORT(port) \ |
57 | ((port >= AX88796L_IO_BASE) && (port < (AX88796L_IO_BASE+0x20))) | 32 | ((port >= AX88796L_IO_BASE) && (port < (AX88796L_IO_BASE+0x20))) |
@@ -70,12 +45,10 @@ u8 r7780rp_inb(unsigned long port) | |||
70 | { | 45 | { |
71 | if (CHECK_AX88796L_PORT(port)) | 46 | if (CHECK_AX88796L_PORT(port)) |
72 | return ctrl_inw(port88796l(port, 0)) & 0xff; | 47 | return ctrl_inw(port88796l(port, 0)) & 0xff; |
73 | else if (PXSEG(port)) | 48 | else if (is_pci_ioaddr(port)) |
74 | return ctrl_inb(port); | ||
75 | else if (is_pci_ioaddr(port) || shifted_port(port)) | ||
76 | return ctrl_inb(pci_ioaddr(port)); | 49 | return ctrl_inb(pci_ioaddr(port)); |
77 | 50 | ||
78 | return ctrl_inw(port2adr(port)) & 0xff; | 51 | return ctrl_inw(port) & 0xff; |
79 | } | 52 | } |
80 | 53 | ||
81 | u8 r7780rp_inb_p(unsigned long port) | 54 | u8 r7780rp_inb_p(unsigned long port) |
@@ -84,12 +57,10 @@ u8 r7780rp_inb_p(unsigned long port) | |||
84 | 57 | ||
85 | if (CHECK_AX88796L_PORT(port)) | 58 | if (CHECK_AX88796L_PORT(port)) |
86 | v = ctrl_inw(port88796l(port, 0)) & 0xff; | 59 | v = ctrl_inw(port88796l(port, 0)) & 0xff; |
87 | else if (PXSEG(port)) | 60 | else if (is_pci_ioaddr(port)) |
88 | v = ctrl_inb(port); | ||
89 | else if (is_pci_ioaddr(port) || shifted_port(port)) | ||
90 | v = ctrl_inb(pci_ioaddr(port)); | 61 | v = ctrl_inb(pci_ioaddr(port)); |
91 | else | 62 | else |
92 | v = ctrl_inw(port2adr(port)) & 0xff; | 63 | v = ctrl_inw(port) & 0xff; |
93 | 64 | ||
94 | ctrl_delay(); | 65 | ctrl_delay(); |
95 | 66 | ||
@@ -98,80 +69,56 @@ u8 r7780rp_inb_p(unsigned long port) | |||
98 | 69 | ||
99 | u16 r7780rp_inw(unsigned long port) | 70 | u16 r7780rp_inw(unsigned long port) |
100 | { | 71 | { |
101 | if (CHECK_AX88796L_PORT(port)) | 72 | if (is_pci_ioaddr(port)) |
102 | maybebadio(port); | ||
103 | else if (PXSEG(port)) | ||
104 | return ctrl_inw(port); | ||
105 | else if (is_pci_ioaddr(port) || shifted_port(port)) | ||
106 | return ctrl_inw(pci_ioaddr(port)); | 73 | return ctrl_inw(pci_ioaddr(port)); |
107 | else | ||
108 | maybebadio(port); | ||
109 | 74 | ||
110 | return 0; | 75 | return ctrl_inw(port); |
111 | } | 76 | } |
112 | 77 | ||
113 | u32 r7780rp_inl(unsigned long port) | 78 | u32 r7780rp_inl(unsigned long port) |
114 | { | 79 | { |
115 | if (CHECK_AX88796L_PORT(port)) | 80 | if (is_pci_ioaddr(port)) |
116 | maybebadio(port); | ||
117 | else if (PXSEG(port)) | ||
118 | return ctrl_inl(port); | ||
119 | else if (is_pci_ioaddr(port) || shifted_port(port)) | ||
120 | return ctrl_inl(pci_ioaddr(port)); | 81 | return ctrl_inl(pci_ioaddr(port)); |
121 | else | ||
122 | maybebadio(port); | ||
123 | 82 | ||
124 | return 0; | 83 | return ctrl_inl(port); |
125 | } | 84 | } |
126 | 85 | ||
127 | void r7780rp_outb(u8 value, unsigned long port) | 86 | void r7780rp_outb(u8 value, unsigned long port) |
128 | { | 87 | { |
129 | if (CHECK_AX88796L_PORT(port)) | 88 | if (CHECK_AX88796L_PORT(port)) |
130 | ctrl_outw(value, port88796l(port, 0)); | 89 | ctrl_outw(value, port88796l(port, 0)); |
131 | else if (PXSEG(port)) | 90 | else if (is_pci_ioaddr(port)) |
132 | ctrl_outb(value, port); | ||
133 | else if (is_pci_ioaddr(port) || shifted_port(port)) | ||
134 | ctrl_outb(value, pci_ioaddr(port)); | 91 | ctrl_outb(value, pci_ioaddr(port)); |
135 | else | 92 | else |
136 | ctrl_outw(value, port2adr(port)); | 93 | ctrl_outb(value, port); |
137 | } | 94 | } |
138 | 95 | ||
139 | void r7780rp_outb_p(u8 value, unsigned long port) | 96 | void r7780rp_outb_p(u8 value, unsigned long port) |
140 | { | 97 | { |
141 | if (CHECK_AX88796L_PORT(port)) | 98 | if (CHECK_AX88796L_PORT(port)) |
142 | ctrl_outw(value, port88796l(port, 0)); | 99 | ctrl_outw(value, port88796l(port, 0)); |
143 | else if (PXSEG(port)) | 100 | else if (is_pci_ioaddr(port)) |
144 | ctrl_outb(value, port); | ||
145 | else if (is_pci_ioaddr(port) || shifted_port(port)) | ||
146 | ctrl_outb(value, pci_ioaddr(port)); | 101 | ctrl_outb(value, pci_ioaddr(port)); |
147 | else | 102 | else |
148 | ctrl_outw(value, port2adr(port)); | 103 | ctrl_outb(value, port); |
149 | 104 | ||
150 | ctrl_delay(); | 105 | ctrl_delay(); |
151 | } | 106 | } |
152 | 107 | ||
153 | void r7780rp_outw(u16 value, unsigned long port) | 108 | void r7780rp_outw(u16 value, unsigned long port) |
154 | { | 109 | { |
155 | if (CHECK_AX88796L_PORT(port)) | 110 | if (is_pci_ioaddr(port)) |
156 | maybebadio(port); | ||
157 | else if (PXSEG(port)) | ||
158 | ctrl_outw(value, port); | ||
159 | else if (is_pci_ioaddr(port) || shifted_port(port)) | ||
160 | ctrl_outw(value, pci_ioaddr(port)); | 111 | ctrl_outw(value, pci_ioaddr(port)); |
161 | else | 112 | else |
162 | maybebadio(port); | 113 | ctrl_outw(value, port); |
163 | } | 114 | } |
164 | 115 | ||
165 | void r7780rp_outl(u32 value, unsigned long port) | 116 | void r7780rp_outl(u32 value, unsigned long port) |
166 | { | 117 | { |
167 | if (CHECK_AX88796L_PORT(port)) | 118 | if (is_pci_ioaddr(port)) |
168 | maybebadio(port); | ||
169 | else if (PXSEG(port)) | ||
170 | ctrl_outl(value, port); | ||
171 | else if (is_pci_ioaddr(port) || shifted_port(port)) | ||
172 | ctrl_outl(value, pci_ioaddr(port)); | 119 | ctrl_outl(value, pci_ioaddr(port)); |
173 | else | 120 | else |
174 | maybebadio(port); | 121 | ctrl_outl(value, port); |
175 | } | 122 | } |
176 | 123 | ||
177 | void r7780rp_insb(unsigned long port, void *dst, unsigned long count) | 124 | void r7780rp_insb(unsigned long port, void *dst, unsigned long count) |
@@ -183,16 +130,13 @@ void r7780rp_insb(unsigned long port, void *dst, unsigned long count) | |||
183 | p = (volatile u16 *)port88796l(port, 0); | 130 | p = (volatile u16 *)port88796l(port, 0); |
184 | while (count--) | 131 | while (count--) |
185 | *buf++ = *p & 0xff; | 132 | *buf++ = *p & 0xff; |
186 | } else if (PXSEG(port)) { | 133 | } else if (is_pci_ioaddr(port)) { |
187 | while (count--) | ||
188 | *buf++ = *(volatile u8 *)port; | ||
189 | } else if (is_pci_ioaddr(port) || shifted_port(port)) { | ||
190 | volatile u8 *bp = (volatile u8 *)pci_ioaddr(port); | 134 | volatile u8 *bp = (volatile u8 *)pci_ioaddr(port); |
191 | 135 | ||
192 | while (count--) | 136 | while (count--) |
193 | *buf++ = *bp; | 137 | *buf++ = *bp; |
194 | } else { | 138 | } else { |
195 | p = (volatile u16 *)port2adr(port); | 139 | p = (volatile u16 *)port; |
196 | while (count--) | 140 | while (count--) |
197 | *buf++ = *p & 0xff; | 141 | *buf++ = *p & 0xff; |
198 | } | 142 | } |
@@ -205,12 +149,10 @@ void r7780rp_insw(unsigned long port, void *dst, unsigned long count) | |||
205 | 149 | ||
206 | if (CHECK_AX88796L_PORT(port)) | 150 | if (CHECK_AX88796L_PORT(port)) |
207 | p = (volatile u16 *)port88796l(port, 1); | 151 | p = (volatile u16 *)port88796l(port, 1); |
208 | else if (PXSEG(port)) | 152 | else if (is_pci_ioaddr(port)) |
209 | p = (volatile u16 *)port; | ||
210 | else if (is_pci_ioaddr(port) || shifted_port(port)) | ||
211 | p = (volatile u16 *)pci_ioaddr(port); | 153 | p = (volatile u16 *)pci_ioaddr(port); |
212 | else | 154 | else |
213 | p = (volatile u16 *)port2adr(port); | 155 | p = (volatile u16 *)port; |
214 | 156 | ||
215 | while (count--) | 157 | while (count--) |
216 | *buf++ = *p; | 158 | *buf++ = *p; |
@@ -220,17 +162,13 @@ void r7780rp_insw(unsigned long port, void *dst, unsigned long count) | |||
220 | 162 | ||
221 | void r7780rp_insl(unsigned long port, void *dst, unsigned long count) | 163 | void r7780rp_insl(unsigned long port, void *dst, unsigned long count) |
222 | { | 164 | { |
223 | u32 *buf = dst; | 165 | if (is_pci_ioaddr(port)) { |
224 | |||
225 | if (CHECK_AX88796L_PORT(port)) | ||
226 | maybebadio(port); | ||
227 | else if (is_pci_ioaddr(port) || shifted_port(port)) { | ||
228 | volatile u32 *p = (volatile u32 *)pci_ioaddr(port); | 166 | volatile u32 *p = (volatile u32 *)pci_ioaddr(port); |
167 | u32 *buf = dst; | ||
229 | 168 | ||
230 | while (count--) | 169 | while (count--) |
231 | *buf++ = *p; | 170 | *buf++ = *p; |
232 | } else | 171 | } |
233 | maybebadio(port); | ||
234 | } | 172 | } |
235 | 173 | ||
236 | void r7780rp_outsb(unsigned long port, const void *src, unsigned long count) | 174 | void r7780rp_outsb(unsigned long port, const void *src, unsigned long count) |
@@ -242,19 +180,14 @@ void r7780rp_outsb(unsigned long port, const void *src, unsigned long count) | |||
242 | p = (volatile u16 *)port88796l(port, 0); | 180 | p = (volatile u16 *)port88796l(port, 0); |
243 | while (count--) | 181 | while (count--) |
244 | *p = *buf++; | 182 | *p = *buf++; |
245 | } else if (PXSEG(port)) | 183 | } else if (is_pci_ioaddr(port)) { |
246 | while (count--) | ||
247 | ctrl_outb(*buf++, port); | ||
248 | else if (is_pci_ioaddr(port) || shifted_port(port)) { | ||
249 | volatile u8 *bp = (volatile u8 *)pci_ioaddr(port); | 184 | volatile u8 *bp = (volatile u8 *)pci_ioaddr(port); |
250 | 185 | ||
251 | while (count--) | 186 | while (count--) |
252 | *bp = *buf++; | 187 | *bp = *buf++; |
253 | } else { | 188 | } else |
254 | p = (volatile u16 *)port2adr(port); | ||
255 | while (count--) | 189 | while (count--) |
256 | *p = *buf++; | 190 | ctrl_outb(*buf++, port); |
257 | } | ||
258 | } | 191 | } |
259 | 192 | ||
260 | void r7780rp_outsw(unsigned long port, const void *src, unsigned long count) | 193 | void r7780rp_outsw(unsigned long port, const void *src, unsigned long count) |
@@ -264,12 +197,10 @@ void r7780rp_outsw(unsigned long port, const void *src, unsigned long count) | |||
264 | 197 | ||
265 | if (CHECK_AX88796L_PORT(port)) | 198 | if (CHECK_AX88796L_PORT(port)) |
266 | p = (volatile u16 *)port88796l(port, 1); | 199 | p = (volatile u16 *)port88796l(port, 1); |
267 | else if (PXSEG(port)) | 200 | else if (is_pci_ioaddr(port)) |
268 | p = (volatile u16 *)port; | ||
269 | else if (is_pci_ioaddr(port) || shifted_port(port)) | ||
270 | p = (volatile u16 *)pci_ioaddr(port); | 201 | p = (volatile u16 *)pci_ioaddr(port); |
271 | else | 202 | else |
272 | p = (volatile u16 *)port2adr(port); | 203 | p = (volatile u16 *)port; |
273 | 204 | ||
274 | while (count--) | 205 | while (count--) |
275 | *p = *buf++; | 206 | *p = *buf++; |
@@ -280,26 +211,23 @@ void r7780rp_outsw(unsigned long port, const void *src, unsigned long count) | |||
280 | void r7780rp_outsl(unsigned long port, const void *src, unsigned long count) | 211 | void r7780rp_outsl(unsigned long port, const void *src, unsigned long count) |
281 | { | 212 | { |
282 | const u32 *buf = src; | 213 | const u32 *buf = src; |
214 | u32 *p; | ||
283 | 215 | ||
284 | if (CHECK_AX88796L_PORT(port)) | 216 | if (is_pci_ioaddr(port)) |
285 | maybebadio(port); | 217 | p = (u32 *)pci_ioaddr(port); |
286 | else if (is_pci_ioaddr(port) || shifted_port(port)) { | 218 | else |
287 | volatile u32 *p = (volatile u32 *)pci_ioaddr(port); | 219 | p = (u32 *)port; |
288 | 220 | ||
289 | while (count--) | 221 | while (count--) |
290 | *p = *buf++; | 222 | ctrl_outl(*buf++, (unsigned long)p); |
291 | } else | ||
292 | maybebadio(port); | ||
293 | } | 223 | } |
294 | 224 | ||
295 | void __iomem *r7780rp_ioport_map(unsigned long port, unsigned int size) | 225 | void __iomem *r7780rp_ioport_map(unsigned long port, unsigned int size) |
296 | { | 226 | { |
297 | if (CHECK_AX88796L_PORT(port)) | 227 | if (CHECK_AX88796L_PORT(port)) |
298 | return (void __iomem *)port88796l(port, size > 1); | 228 | return (void __iomem *)port88796l(port, size > 1); |
299 | else if (PXSEG(port)) | 229 | else if (is_pci_ioaddr(port)) |
300 | return (void __iomem *)port; | ||
301 | else if (is_pci_ioaddr(port) || shifted_port(port)) | ||
302 | return (void __iomem *)pci_ioaddr(port); | 230 | return (void __iomem *)pci_ioaddr(port); |
303 | 231 | ||
304 | return (void __iomem *)port2adr(port); | 232 | return (void __iomem *)port; |
305 | } | 233 | } |
diff --git a/arch/sh/boards/renesas/r7780rp/setup.c b/arch/sh/boards/renesas/r7780rp/setup.c index c40f85cc3e5e..0d74db9f1792 100644 --- a/arch/sh/boards/renesas/r7780rp/setup.c +++ b/arch/sh/boards/renesas/r7780rp/setup.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * arch/sh/boards/renesas/r7780rp/setup.c | 2 | * arch/sh/boards/renesas/r7780rp/setup.c |
3 | * | 3 | * |
4 | * Copyright (C) 2002 Atom Create Engineering Co., Ltd. | 4 | * Copyright (C) 2002 Atom Create Engineering Co., Ltd. |
5 | * Copyright (C) 2005, 2006 Paul Mundt | 5 | * Copyright (C) 2005 - 2007 Paul Mundt |
6 | * | 6 | * |
7 | * Renesas Solutions Highlander R7780RP-1 Support. | 7 | * Renesas Solutions Highlander R7780RP-1 Support. |
8 | * | 8 | * |
@@ -12,6 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/pata_platform.h> | ||
15 | #include <asm/machvec.h> | 16 | #include <asm/machvec.h> |
16 | #include <asm/r7780rp.h> | 17 | #include <asm/r7780rp.h> |
17 | #include <asm/clock.h> | 18 | #include <asm/clock.h> |
@@ -45,14 +46,14 @@ static struct platform_device m66596_usb_host_device = { | |||
45 | 46 | ||
46 | static struct resource cf_ide_resources[] = { | 47 | static struct resource cf_ide_resources[] = { |
47 | [0] = { | 48 | [0] = { |
48 | .start = 0x1f0, | 49 | .start = PA_AREA5_IO + 0x1000, |
49 | .end = 0x1f0 + 8, | 50 | .end = PA_AREA5_IO + 0x1000 + 0x08 - 1, |
50 | .flags = IORESOURCE_IO, | 51 | .flags = IORESOURCE_MEM, |
51 | }, | 52 | }, |
52 | [1] = { | 53 | [1] = { |
53 | .start = 0x1f0 + 0x206, | 54 | .start = PA_AREA5_IO + 0x80c, |
54 | .end = 0x1f0 + 8 + 0x206 + 8, | 55 | .end = PA_AREA5_IO + 0x80c + 0x16 - 1, |
55 | .flags = IORESOURCE_IO, | 56 | .flags = IORESOURCE_MEM, |
56 | }, | 57 | }, |
57 | [2] = { | 58 | [2] = { |
58 | #ifdef CONFIG_SH_R7780MP | 59 | #ifdef CONFIG_SH_R7780MP |
@@ -64,11 +65,18 @@ static struct resource cf_ide_resources[] = { | |||
64 | }, | 65 | }, |
65 | }; | 66 | }; |
66 | 67 | ||
68 | static struct pata_platform_info pata_info = { | ||
69 | .ioport_shift = 1, | ||
70 | }; | ||
71 | |||
67 | static struct platform_device cf_ide_device = { | 72 | static struct platform_device cf_ide_device = { |
68 | .name = "pata_platform", | 73 | .name = "pata_platform", |
69 | .id = -1, | 74 | .id = -1, |
70 | .num_resources = ARRAY_SIZE(cf_ide_resources), | 75 | .num_resources = ARRAY_SIZE(cf_ide_resources), |
71 | .resource = cf_ide_resources, | 76 | .resource = cf_ide_resources, |
77 | .dev = { | ||
78 | .platform_data = &pata_info, | ||
79 | }, | ||
72 | }; | 80 | }; |
73 | 81 | ||
74 | static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 }; | 82 | static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 }; |