diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sh/boards/se/770x/io.c | 59 |
1 files changed, 14 insertions, 45 deletions
diff --git a/arch/sh/boards/se/770x/io.c b/arch/sh/boards/se/770x/io.c index c4550473d4c3..b1ec085b8673 100644 --- a/arch/sh/boards/se/770x/io.c +++ b/arch/sh/boards/se/770x/io.c | |||
@@ -1,25 +1,13 @@ | |||
1 | /* $Id: io.c,v 1.7 2006/02/05 21:55:29 lethal Exp $ | 1 | /* |
2 | * | ||
3 | * linux/arch/sh/kernel/io_se.c | ||
4 | * | ||
5 | * Copyright (C) 2000 Kazumoto Kojima | 2 | * Copyright (C) 2000 Kazumoto Kojima |
6 | * | 3 | * |
7 | * I/O routine for Hitachi SolutionEngine. | 4 | * I/O routine for Hitachi SolutionEngine. |
8 | * | ||
9 | */ | 5 | */ |
10 | |||
11 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
12 | #include <linux/types.h> | 7 | #include <linux/types.h> |
13 | #include <asm/io.h> | 8 | #include <asm/io.h> |
14 | #include <asm/se.h> | 9 | #include <asm/se.h> |
15 | 10 | ||
16 | /* SH pcmcia io window base, start and end. */ | ||
17 | int sh_pcic_io_wbase = 0xb8400000; | ||
18 | int sh_pcic_io_start; | ||
19 | int sh_pcic_io_stop; | ||
20 | int sh_pcic_io_type; | ||
21 | int sh_pcic_io_dummy; | ||
22 | |||
23 | /* MS7750 requires special versions of in*, out* routines, since | 11 | /* MS7750 requires special versions of in*, out* routines, since |
24 | PC-like io ports are located at upper half byte of 16-bit word which | 12 | PC-like io ports are located at upper half byte of 16-bit word which |
25 | can be accessed only with 16-bit wide. */ | 13 | can be accessed only with 16-bit wide. */ |
@@ -33,8 +21,6 @@ port2adr(unsigned int port) | |||
33 | return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000)); | 21 | return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000)); |
34 | else if (port >= 0x1000) | 22 | else if (port >= 0x1000) |
35 | return (volatile __u16 *) (PA_83902 + (port << 1)); | 23 | return (volatile __u16 *) (PA_83902 + (port << 1)); |
36 | else if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) | ||
37 | return (volatile __u16 *) (sh_pcic_io_wbase + (port &~ 1)); | ||
38 | else | 24 | else |
39 | return (volatile __u16 *) (PA_SUPERIO + (port << 1)); | 25 | return (volatile __u16 *) (PA_SUPERIO + (port << 1)); |
40 | } | 26 | } |
@@ -51,32 +37,27 @@ shifted_port(unsigned long port) | |||
51 | 37 | ||
52 | unsigned char se_inb(unsigned long port) | 38 | unsigned char se_inb(unsigned long port) |
53 | { | 39 | { |
54 | if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) | 40 | if (shifted_port(port)) |
55 | return *(__u8 *) (sh_pcic_io_wbase + 0x40000 + port); | 41 | return (*port2adr(port) >> 8); |
56 | else if (shifted_port(port)) | ||
57 | return (*port2adr(port) >> 8); | ||
58 | else | 42 | else |
59 | return (*port2adr(port))&0xff; | 43 | return (*port2adr(port))&0xff; |
60 | } | 44 | } |
61 | 45 | ||
62 | unsigned char se_inb_p(unsigned long port) | 46 | unsigned char se_inb_p(unsigned long port) |
63 | { | 47 | { |
64 | unsigned long v; | 48 | unsigned long v; |
65 | 49 | ||
66 | if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) | 50 | if (shifted_port(port)) |
67 | v = *(__u8 *) (sh_pcic_io_wbase + 0x40000 + port); | 51 | v = (*port2adr(port) >> 8); |
68 | else if (shifted_port(port)) | ||
69 | v = (*port2adr(port) >> 8); | ||
70 | else | 52 | else |
71 | v = (*port2adr(port))&0xff; | 53 | v = (*port2adr(port))&0xff; |
72 | ctrl_delay(); | 54 | ctrl_delay(); |
73 | return v; | 55 | return v; |
74 | } | 56 | } |
75 | 57 | ||
76 | unsigned short se_inw(unsigned long port) | 58 | unsigned short se_inw(unsigned long port) |
77 | { | 59 | { |
78 | if (port >= 0x2000 || | 60 | if (port >= 0x2000) |
79 | (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)) | ||
80 | return *port2adr(port); | 61 | return *port2adr(port); |
81 | else | 62 | else |
82 | maybebadio(port); | 63 | maybebadio(port); |
@@ -91,9 +72,7 @@ unsigned int se_inl(unsigned long port) | |||
91 | 72 | ||
92 | void se_outb(unsigned char value, unsigned long port) | 73 | void se_outb(unsigned char value, unsigned long port) |
93 | { | 74 | { |
94 | if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) | 75 | if (shifted_port(port)) |
95 | *(__u8 *)(sh_pcic_io_wbase + port) = value; | ||
96 | else if (shifted_port(port)) | ||
97 | *(port2adr(port)) = value << 8; | 76 | *(port2adr(port)) = value << 8; |
98 | else | 77 | else |
99 | *(port2adr(port)) = value; | 78 | *(port2adr(port)) = value; |
@@ -101,9 +80,7 @@ void se_outb(unsigned char value, unsigned long port) | |||
101 | 80 | ||
102 | void se_outb_p(unsigned char value, unsigned long port) | 81 | void se_outb_p(unsigned char value, unsigned long port) |
103 | { | 82 | { |
104 | if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) | 83 | if (shifted_port(port)) |
105 | *(__u8 *)(sh_pcic_io_wbase + port) = value; | ||
106 | else if (shifted_port(port)) | ||
107 | *(port2adr(port)) = value << 8; | 84 | *(port2adr(port)) = value << 8; |
108 | else | 85 | else |
109 | *(port2adr(port)) = value; | 86 | *(port2adr(port)) = value; |
@@ -112,8 +89,7 @@ void se_outb_p(unsigned char value, unsigned long port) | |||
112 | 89 | ||
113 | void se_outw(unsigned short value, unsigned long port) | 90 | void se_outw(unsigned short value, unsigned long port) |
114 | { | 91 | { |
115 | if (port >= 0x2000 || | 92 | if (port >= 0x2000) |
116 | (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)) | ||
117 | *port2adr(port) = value; | 93 | *port2adr(port) = value; |
118 | else | 94 | else |
119 | maybebadio(port); | 95 | maybebadio(port); |
@@ -129,11 +105,7 @@ void se_insb(unsigned long port, void *addr, unsigned long count) | |||
129 | volatile __u16 *p = port2adr(port); | 105 | volatile __u16 *p = port2adr(port); |
130 | __u8 *ap = addr; | 106 | __u8 *ap = addr; |
131 | 107 | ||
132 | if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) { | 108 | if (shifted_port(port)) { |
133 | volatile __u8 *bp = (__u8 *) (sh_pcic_io_wbase + 0x40000 + port); | ||
134 | while (count--) | ||
135 | *ap++ = *bp; | ||
136 | } else if (shifted_port(port)) { | ||
137 | while (count--) | 109 | while (count--) |
138 | *ap++ = *p >> 8; | 110 | *ap++ = *p >> 8; |
139 | } else { | 111 | } else { |
@@ -160,11 +132,7 @@ void se_outsb(unsigned long port, const void *addr, unsigned long count) | |||
160 | volatile __u16 *p = port2adr(port); | 132 | volatile __u16 *p = port2adr(port); |
161 | const __u8 *ap = addr; | 133 | const __u8 *ap = addr; |
162 | 134 | ||
163 | if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) { | 135 | if (shifted_port(port)) { |
164 | volatile __u8 *bp = (__u8 *) (sh_pcic_io_wbase + port); | ||
165 | while (count--) | ||
166 | *bp = *ap++; | ||
167 | } else if (shifted_port(port)) { | ||
168 | while (count--) | 136 | while (count--) |
169 | *p = *ap++ << 8; | 137 | *p = *ap++ << 8; |
170 | } else { | 138 | } else { |
@@ -177,6 +145,7 @@ void se_outsw(unsigned long port, const void *addr, unsigned long count) | |||
177 | { | 145 | { |
178 | volatile __u16 *p = port2adr(port); | 146 | volatile __u16 *p = port2adr(port); |
179 | const __u16 *ap = addr; | 147 | const __u16 *ap = addr; |
148 | |||
180 | while (count--) | 149 | while (count--) |
181 | *p = *ap++; | 150 | *p = *ap++; |
182 | } | 151 | } |