Commit b5391e29f428d11755ca2c91074c6db6f5c69d7c
Committed by
Linus Torvalds
1 parent
4982d6b37a
Exists in
master
and in
7 other branches
gs: use tty_port
Switch drivers using the old "generic serial" driver to use the tty_port structures Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 8 changed files with 166 additions and 173 deletions Inline Diff
drivers/char/generic_serial.c
1 | /* | 1 | /* |
2 | * generic_serial.c | 2 | * generic_serial.c |
3 | * | 3 | * |
4 | * Copyright (C) 1998/1999 R.E.Wolff@BitWizard.nl | 4 | * Copyright (C) 1998/1999 R.E.Wolff@BitWizard.nl |
5 | * | 5 | * |
6 | * written for the SX serial driver. | 6 | * written for the SX serial driver. |
7 | * Contains the code that should be shared over all the serial drivers. | 7 | * Contains the code that should be shared over all the serial drivers. |
8 | * | 8 | * |
9 | * Credit for the idea to do it this way might go to Alan Cox. | 9 | * Credit for the idea to do it this way might go to Alan Cox. |
10 | * | 10 | * |
11 | * | 11 | * |
12 | * Version 0.1 -- December, 1998. Initial version. | 12 | * Version 0.1 -- December, 1998. Initial version. |
13 | * Version 0.2 -- March, 1999. Some more routines. Bugfixes. Etc. | 13 | * Version 0.2 -- March, 1999. Some more routines. Bugfixes. Etc. |
14 | * Version 0.5 -- August, 1999. Some more fixes. Reformat for Linus. | 14 | * Version 0.5 -- August, 1999. Some more fixes. Reformat for Linus. |
15 | * | 15 | * |
16 | * BitWizard is actively maintaining this file. We sometimes find | 16 | * BitWizard is actively maintaining this file. We sometimes find |
17 | * that someone submitted changes to this file. We really appreciate | 17 | * that someone submitted changes to this file. We really appreciate |
18 | * your help, but please submit changes through us. We're doing our | 18 | * your help, but please submit changes through us. We're doing our |
19 | * best to be responsive. -- REW | 19 | * best to be responsive. -- REW |
20 | * */ | 20 | * */ |
21 | 21 | ||
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
24 | #include <linux/tty.h> | 24 | #include <linux/tty.h> |
25 | #include <linux/serial.h> | 25 | #include <linux/serial.h> |
26 | #include <linux/mm.h> | 26 | #include <linux/mm.h> |
27 | #include <linux/generic_serial.h> | 27 | #include <linux/generic_serial.h> |
28 | #include <linux/interrupt.h> | 28 | #include <linux/interrupt.h> |
29 | #include <linux/tty_flip.h> | 29 | #include <linux/tty_flip.h> |
30 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
31 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
32 | 32 | ||
33 | #define DEBUG | 33 | #define DEBUG |
34 | 34 | ||
35 | static int gs_debug; | 35 | static int gs_debug; |
36 | 36 | ||
37 | #ifdef DEBUG | 37 | #ifdef DEBUG |
38 | #define gs_dprintk(f, str...) if (gs_debug & f) printk (str) | 38 | #define gs_dprintk(f, str...) if (gs_debug & f) printk (str) |
39 | #else | 39 | #else |
40 | #define gs_dprintk(f, str...) /* nothing */ | 40 | #define gs_dprintk(f, str...) /* nothing */ |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #define func_enter() gs_dprintk (GS_DEBUG_FLOW, "gs: enter %s\n", __func__) | 43 | #define func_enter() gs_dprintk (GS_DEBUG_FLOW, "gs: enter %s\n", __func__) |
44 | #define func_exit() gs_dprintk (GS_DEBUG_FLOW, "gs: exit %s\n", __func__) | 44 | #define func_exit() gs_dprintk (GS_DEBUG_FLOW, "gs: exit %s\n", __func__) |
45 | 45 | ||
46 | #define RS_EVENT_WRITE_WAKEUP 1 | 46 | #define RS_EVENT_WRITE_WAKEUP 1 |
47 | 47 | ||
48 | module_param(gs_debug, int, 0644); | 48 | module_param(gs_debug, int, 0644); |
49 | 49 | ||
50 | 50 | ||
51 | int gs_put_char(struct tty_struct * tty, unsigned char ch) | 51 | int gs_put_char(struct tty_struct * tty, unsigned char ch) |
52 | { | 52 | { |
53 | struct gs_port *port; | 53 | struct gs_port *port; |
54 | 54 | ||
55 | func_enter (); | 55 | func_enter (); |
56 | 56 | ||
57 | if (!tty) return 0; | 57 | if (!tty) return 0; |
58 | 58 | ||
59 | port = tty->driver_data; | 59 | port = tty->driver_data; |
60 | 60 | ||
61 | if (!port) return 0; | 61 | if (!port) return 0; |
62 | 62 | ||
63 | if (! (port->flags & ASYNC_INITIALIZED)) return 0; | 63 | if (! (port->port.flags & ASYNC_INITIALIZED)) return 0; |
64 | 64 | ||
65 | /* Take a lock on the serial tranmit buffer! */ | 65 | /* Take a lock on the serial tranmit buffer! */ |
66 | mutex_lock(& port->port_write_mutex); | 66 | mutex_lock(& port->port_write_mutex); |
67 | 67 | ||
68 | if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1) { | 68 | if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1) { |
69 | /* Sorry, buffer is full, drop character. Update statistics???? -- REW */ | 69 | /* Sorry, buffer is full, drop character. Update statistics???? -- REW */ |
70 | mutex_unlock(&port->port_write_mutex); | 70 | mutex_unlock(&port->port_write_mutex); |
71 | return 0; | 71 | return 0; |
72 | } | 72 | } |
73 | 73 | ||
74 | port->xmit_buf[port->xmit_head++] = ch; | 74 | port->xmit_buf[port->xmit_head++] = ch; |
75 | port->xmit_head &= SERIAL_XMIT_SIZE - 1; | 75 | port->xmit_head &= SERIAL_XMIT_SIZE - 1; |
76 | port->xmit_cnt++; /* Characters in buffer */ | 76 | port->xmit_cnt++; /* Characters in buffer */ |
77 | 77 | ||
78 | mutex_unlock(&port->port_write_mutex); | 78 | mutex_unlock(&port->port_write_mutex); |
79 | func_exit (); | 79 | func_exit (); |
80 | return 1; | 80 | return 1; |
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | /* | 84 | /* |
85 | > Problems to take into account are: | 85 | > Problems to take into account are: |
86 | > -1- Interrupts that empty part of the buffer. | 86 | > -1- Interrupts that empty part of the buffer. |
87 | > -2- page faults on the access to userspace. | 87 | > -2- page faults on the access to userspace. |
88 | > -3- Other processes that are also trying to do a "write". | 88 | > -3- Other processes that are also trying to do a "write". |
89 | */ | 89 | */ |
90 | 90 | ||
91 | int gs_write(struct tty_struct * tty, | 91 | int gs_write(struct tty_struct * tty, |
92 | const unsigned char *buf, int count) | 92 | const unsigned char *buf, int count) |
93 | { | 93 | { |
94 | struct gs_port *port; | 94 | struct gs_port *port; |
95 | int c, total = 0; | 95 | int c, total = 0; |
96 | int t; | 96 | int t; |
97 | 97 | ||
98 | func_enter (); | 98 | func_enter (); |
99 | 99 | ||
100 | if (!tty) return 0; | 100 | if (!tty) return 0; |
101 | 101 | ||
102 | port = tty->driver_data; | 102 | port = tty->driver_data; |
103 | 103 | ||
104 | if (!port) return 0; | 104 | if (!port) return 0; |
105 | 105 | ||
106 | if (! (port->flags & ASYNC_INITIALIZED)) | 106 | if (! (port->port.flags & ASYNC_INITIALIZED)) |
107 | return 0; | 107 | return 0; |
108 | 108 | ||
109 | /* get exclusive "write" access to this port (problem 3) */ | 109 | /* get exclusive "write" access to this port (problem 3) */ |
110 | /* This is not a spinlock because we can have a disk access (page | 110 | /* This is not a spinlock because we can have a disk access (page |
111 | fault) in copy_from_user */ | 111 | fault) in copy_from_user */ |
112 | mutex_lock(& port->port_write_mutex); | 112 | mutex_lock(& port->port_write_mutex); |
113 | 113 | ||
114 | while (1) { | 114 | while (1) { |
115 | 115 | ||
116 | c = count; | 116 | c = count; |
117 | 117 | ||
118 | /* This is safe because we "OWN" the "head". Noone else can | 118 | /* This is safe because we "OWN" the "head". Noone else can |
119 | change the "head": we own the port_write_mutex. */ | 119 | change the "head": we own the port_write_mutex. */ |
120 | /* Don't overrun the end of the buffer */ | 120 | /* Don't overrun the end of the buffer */ |
121 | t = SERIAL_XMIT_SIZE - port->xmit_head; | 121 | t = SERIAL_XMIT_SIZE - port->xmit_head; |
122 | if (t < c) c = t; | 122 | if (t < c) c = t; |
123 | 123 | ||
124 | /* This is safe because the xmit_cnt can only decrease. This | 124 | /* This is safe because the xmit_cnt can only decrease. This |
125 | would increase "t", so we might copy too little chars. */ | 125 | would increase "t", so we might copy too little chars. */ |
126 | /* Don't copy past the "head" of the buffer */ | 126 | /* Don't copy past the "head" of the buffer */ |
127 | t = SERIAL_XMIT_SIZE - 1 - port->xmit_cnt; | 127 | t = SERIAL_XMIT_SIZE - 1 - port->xmit_cnt; |
128 | if (t < c) c = t; | 128 | if (t < c) c = t; |
129 | 129 | ||
130 | /* Can't copy more? break out! */ | 130 | /* Can't copy more? break out! */ |
131 | if (c <= 0) break; | 131 | if (c <= 0) break; |
132 | 132 | ||
133 | memcpy (port->xmit_buf + port->xmit_head, buf, c); | 133 | memcpy (port->xmit_buf + port->xmit_head, buf, c); |
134 | 134 | ||
135 | port -> xmit_cnt += c; | 135 | port -> xmit_cnt += c; |
136 | port -> xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE -1); | 136 | port -> xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE -1); |
137 | buf += c; | 137 | buf += c; |
138 | count -= c; | 138 | count -= c; |
139 | total += c; | 139 | total += c; |
140 | } | 140 | } |
141 | mutex_unlock(& port->port_write_mutex); | 141 | mutex_unlock(& port->port_write_mutex); |
142 | 142 | ||
143 | gs_dprintk (GS_DEBUG_WRITE, "write: interrupts are %s\n", | 143 | gs_dprintk (GS_DEBUG_WRITE, "write: interrupts are %s\n", |
144 | (port->flags & GS_TX_INTEN)?"enabled": "disabled"); | 144 | (port->port.flags & GS_TX_INTEN)?"enabled": "disabled"); |
145 | 145 | ||
146 | if (port->xmit_cnt && | 146 | if (port->xmit_cnt && |
147 | !tty->stopped && | 147 | !tty->stopped && |
148 | !tty->hw_stopped && | 148 | !tty->hw_stopped && |
149 | !(port->flags & GS_TX_INTEN)) { | 149 | !(port->port.flags & GS_TX_INTEN)) { |
150 | port->flags |= GS_TX_INTEN; | 150 | port->port.flags |= GS_TX_INTEN; |
151 | port->rd->enable_tx_interrupts (port); | 151 | port->rd->enable_tx_interrupts (port); |
152 | } | 152 | } |
153 | func_exit (); | 153 | func_exit (); |
154 | return total; | 154 | return total; |
155 | } | 155 | } |
156 | 156 | ||
157 | 157 | ||
158 | 158 | ||
159 | int gs_write_room(struct tty_struct * tty) | 159 | int gs_write_room(struct tty_struct * tty) |
160 | { | 160 | { |
161 | struct gs_port *port = tty->driver_data; | 161 | struct gs_port *port = tty->driver_data; |
162 | int ret; | 162 | int ret; |
163 | 163 | ||
164 | func_enter (); | 164 | func_enter (); |
165 | ret = SERIAL_XMIT_SIZE - port->xmit_cnt - 1; | 165 | ret = SERIAL_XMIT_SIZE - port->xmit_cnt - 1; |
166 | if (ret < 0) | 166 | if (ret < 0) |
167 | ret = 0; | 167 | ret = 0; |
168 | func_exit (); | 168 | func_exit (); |
169 | return ret; | 169 | return ret; |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | int gs_chars_in_buffer(struct tty_struct *tty) | 173 | int gs_chars_in_buffer(struct tty_struct *tty) |
174 | { | 174 | { |
175 | struct gs_port *port = tty->driver_data; | 175 | struct gs_port *port = tty->driver_data; |
176 | func_enter (); | 176 | func_enter (); |
177 | 177 | ||
178 | func_exit (); | 178 | func_exit (); |
179 | return port->xmit_cnt; | 179 | return port->xmit_cnt; |
180 | } | 180 | } |
181 | 181 | ||
182 | 182 | ||
183 | static int gs_real_chars_in_buffer(struct tty_struct *tty) | 183 | static int gs_real_chars_in_buffer(struct tty_struct *tty) |
184 | { | 184 | { |
185 | struct gs_port *port; | 185 | struct gs_port *port; |
186 | func_enter (); | 186 | func_enter (); |
187 | 187 | ||
188 | if (!tty) return 0; | 188 | if (!tty) return 0; |
189 | port = tty->driver_data; | 189 | port = tty->driver_data; |
190 | 190 | ||
191 | if (!port->rd) return 0; | 191 | if (!port->rd) return 0; |
192 | if (!port->rd->chars_in_buffer) return 0; | 192 | if (!port->rd->chars_in_buffer) return 0; |
193 | 193 | ||
194 | func_exit (); | 194 | func_exit (); |
195 | return port->xmit_cnt + port->rd->chars_in_buffer (port); | 195 | return port->xmit_cnt + port->rd->chars_in_buffer (port); |
196 | } | 196 | } |
197 | 197 | ||
198 | 198 | ||
199 | static int gs_wait_tx_flushed (void * ptr, unsigned long timeout) | 199 | static int gs_wait_tx_flushed (void * ptr, unsigned long timeout) |
200 | { | 200 | { |
201 | struct gs_port *port = ptr; | 201 | struct gs_port *port = ptr; |
202 | unsigned long end_jiffies; | 202 | unsigned long end_jiffies; |
203 | int jiffies_to_transmit, charsleft = 0, rv = 0; | 203 | int jiffies_to_transmit, charsleft = 0, rv = 0; |
204 | int rcib; | 204 | int rcib; |
205 | 205 | ||
206 | func_enter(); | 206 | func_enter(); |
207 | 207 | ||
208 | gs_dprintk (GS_DEBUG_FLUSH, "port=%p.\n", port); | 208 | gs_dprintk (GS_DEBUG_FLUSH, "port=%p.\n", port); |
209 | if (port) { | 209 | if (port) { |
210 | gs_dprintk (GS_DEBUG_FLUSH, "xmit_cnt=%x, xmit_buf=%p, tty=%p.\n", | 210 | gs_dprintk (GS_DEBUG_FLUSH, "xmit_cnt=%x, xmit_buf=%p, tty=%p.\n", |
211 | port->xmit_cnt, port->xmit_buf, port->tty); | 211 | port->xmit_cnt, port->xmit_buf, port->port.tty); |
212 | } | 212 | } |
213 | 213 | ||
214 | if (!port || port->xmit_cnt < 0 || !port->xmit_buf) { | 214 | if (!port || port->xmit_cnt < 0 || !port->xmit_buf) { |
215 | gs_dprintk (GS_DEBUG_FLUSH, "ERROR: !port, !port->xmit_buf or prot->xmit_cnt < 0.\n"); | 215 | gs_dprintk (GS_DEBUG_FLUSH, "ERROR: !port, !port->xmit_buf or prot->xmit_cnt < 0.\n"); |
216 | func_exit(); | 216 | func_exit(); |
217 | return -EINVAL; /* This is an error which we don't know how to handle. */ | 217 | return -EINVAL; /* This is an error which we don't know how to handle. */ |
218 | } | 218 | } |
219 | 219 | ||
220 | rcib = gs_real_chars_in_buffer(port->tty); | 220 | rcib = gs_real_chars_in_buffer(port->port.tty); |
221 | 221 | ||
222 | if(rcib <= 0) { | 222 | if(rcib <= 0) { |
223 | gs_dprintk (GS_DEBUG_FLUSH, "nothing to wait for.\n"); | 223 | gs_dprintk (GS_DEBUG_FLUSH, "nothing to wait for.\n"); |
224 | func_exit(); | 224 | func_exit(); |
225 | return rv; | 225 | return rv; |
226 | } | 226 | } |
227 | /* stop trying: now + twice the time it would normally take + seconds */ | 227 | /* stop trying: now + twice the time it would normally take + seconds */ |
228 | if (timeout == 0) timeout = MAX_SCHEDULE_TIMEOUT; | 228 | if (timeout == 0) timeout = MAX_SCHEDULE_TIMEOUT; |
229 | end_jiffies = jiffies; | 229 | end_jiffies = jiffies; |
230 | if (timeout != MAX_SCHEDULE_TIMEOUT) | 230 | if (timeout != MAX_SCHEDULE_TIMEOUT) |
231 | end_jiffies += port->baud?(2 * rcib * 10 * HZ / port->baud):0; | 231 | end_jiffies += port->baud?(2 * rcib * 10 * HZ / port->baud):0; |
232 | end_jiffies += timeout; | 232 | end_jiffies += timeout; |
233 | 233 | ||
234 | gs_dprintk (GS_DEBUG_FLUSH, "now=%lx, end=%lx (%ld).\n", | 234 | gs_dprintk (GS_DEBUG_FLUSH, "now=%lx, end=%lx (%ld).\n", |
235 | jiffies, end_jiffies, end_jiffies-jiffies); | 235 | jiffies, end_jiffies, end_jiffies-jiffies); |
236 | 236 | ||
237 | /* the expression is actually jiffies < end_jiffies, but that won't | 237 | /* the expression is actually jiffies < end_jiffies, but that won't |
238 | work around the wraparound. Tricky eh? */ | 238 | work around the wraparound. Tricky eh? */ |
239 | while ((charsleft = gs_real_chars_in_buffer (port->tty)) && | 239 | while ((charsleft = gs_real_chars_in_buffer (port->port.tty)) && |
240 | time_after (end_jiffies, jiffies)) { | 240 | time_after (end_jiffies, jiffies)) { |
241 | /* Units check: | 241 | /* Units check: |
242 | chars * (bits/char) * (jiffies /sec) / (bits/sec) = jiffies! | 242 | chars * (bits/char) * (jiffies /sec) / (bits/sec) = jiffies! |
243 | check! */ | 243 | check! */ |
244 | 244 | ||
245 | charsleft += 16; /* Allow 16 chars more to be transmitted ... */ | 245 | charsleft += 16; /* Allow 16 chars more to be transmitted ... */ |
246 | jiffies_to_transmit = port->baud?(1 + charsleft * 10 * HZ / port->baud):0; | 246 | jiffies_to_transmit = port->baud?(1 + charsleft * 10 * HZ / port->baud):0; |
247 | /* ^^^ Round up.... */ | 247 | /* ^^^ Round up.... */ |
248 | if (jiffies_to_transmit <= 0) jiffies_to_transmit = 1; | 248 | if (jiffies_to_transmit <= 0) jiffies_to_transmit = 1; |
249 | 249 | ||
250 | gs_dprintk (GS_DEBUG_FLUSH, "Expect to finish in %d jiffies " | 250 | gs_dprintk (GS_DEBUG_FLUSH, "Expect to finish in %d jiffies " |
251 | "(%d chars).\n", jiffies_to_transmit, charsleft); | 251 | "(%d chars).\n", jiffies_to_transmit, charsleft); |
252 | 252 | ||
253 | msleep_interruptible(jiffies_to_msecs(jiffies_to_transmit)); | 253 | msleep_interruptible(jiffies_to_msecs(jiffies_to_transmit)); |
254 | if (signal_pending (current)) { | 254 | if (signal_pending (current)) { |
255 | gs_dprintk (GS_DEBUG_FLUSH, "Signal pending. Bombing out: "); | 255 | gs_dprintk (GS_DEBUG_FLUSH, "Signal pending. Bombing out: "); |
256 | rv = -EINTR; | 256 | rv = -EINTR; |
257 | break; | 257 | break; |
258 | } | 258 | } |
259 | } | 259 | } |
260 | 260 | ||
261 | gs_dprintk (GS_DEBUG_FLUSH, "charsleft = %d.\n", charsleft); | 261 | gs_dprintk (GS_DEBUG_FLUSH, "charsleft = %d.\n", charsleft); |
262 | set_current_state (TASK_RUNNING); | 262 | set_current_state (TASK_RUNNING); |
263 | 263 | ||
264 | func_exit(); | 264 | func_exit(); |
265 | return rv; | 265 | return rv; |
266 | } | 266 | } |
267 | 267 | ||
268 | 268 | ||
269 | 269 | ||
270 | void gs_flush_buffer(struct tty_struct *tty) | 270 | void gs_flush_buffer(struct tty_struct *tty) |
271 | { | 271 | { |
272 | struct gs_port *port; | 272 | struct gs_port *port; |
273 | unsigned long flags; | 273 | unsigned long flags; |
274 | 274 | ||
275 | func_enter (); | 275 | func_enter (); |
276 | 276 | ||
277 | if (!tty) return; | 277 | if (!tty) return; |
278 | 278 | ||
279 | port = tty->driver_data; | 279 | port = tty->driver_data; |
280 | 280 | ||
281 | if (!port) return; | 281 | if (!port) return; |
282 | 282 | ||
283 | /* XXX Would the write semaphore do? */ | 283 | /* XXX Would the write semaphore do? */ |
284 | spin_lock_irqsave (&port->driver_lock, flags); | 284 | spin_lock_irqsave (&port->driver_lock, flags); |
285 | port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; | 285 | port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; |
286 | spin_unlock_irqrestore (&port->driver_lock, flags); | 286 | spin_unlock_irqrestore (&port->driver_lock, flags); |
287 | 287 | ||
288 | tty_wakeup(tty); | 288 | tty_wakeup(tty); |
289 | func_exit (); | 289 | func_exit (); |
290 | } | 290 | } |
291 | 291 | ||
292 | 292 | ||
293 | void gs_flush_chars(struct tty_struct * tty) | 293 | void gs_flush_chars(struct tty_struct * tty) |
294 | { | 294 | { |
295 | struct gs_port *port; | 295 | struct gs_port *port; |
296 | 296 | ||
297 | func_enter (); | 297 | func_enter (); |
298 | 298 | ||
299 | if (!tty) return; | 299 | if (!tty) return; |
300 | 300 | ||
301 | port = tty->driver_data; | 301 | port = tty->driver_data; |
302 | 302 | ||
303 | if (!port) return; | 303 | if (!port) return; |
304 | 304 | ||
305 | if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || | 305 | if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || |
306 | !port->xmit_buf) { | 306 | !port->xmit_buf) { |
307 | func_exit (); | 307 | func_exit (); |
308 | return; | 308 | return; |
309 | } | 309 | } |
310 | 310 | ||
311 | /* Beats me -- REW */ | 311 | /* Beats me -- REW */ |
312 | port->flags |= GS_TX_INTEN; | 312 | port->port.flags |= GS_TX_INTEN; |
313 | port->rd->enable_tx_interrupts (port); | 313 | port->rd->enable_tx_interrupts (port); |
314 | func_exit (); | 314 | func_exit (); |
315 | } | 315 | } |
316 | 316 | ||
317 | 317 | ||
318 | void gs_stop(struct tty_struct * tty) | 318 | void gs_stop(struct tty_struct * tty) |
319 | { | 319 | { |
320 | struct gs_port *port; | 320 | struct gs_port *port; |
321 | 321 | ||
322 | func_enter (); | 322 | func_enter (); |
323 | 323 | ||
324 | if (!tty) return; | 324 | if (!tty) return; |
325 | 325 | ||
326 | port = tty->driver_data; | 326 | port = tty->driver_data; |
327 | 327 | ||
328 | if (!port) return; | 328 | if (!port) return; |
329 | 329 | ||
330 | if (port->xmit_cnt && | 330 | if (port->xmit_cnt && |
331 | port->xmit_buf && | 331 | port->xmit_buf && |
332 | (port->flags & GS_TX_INTEN) ) { | 332 | (port->port.flags & GS_TX_INTEN) ) { |
333 | port->flags &= ~GS_TX_INTEN; | 333 | port->port.flags &= ~GS_TX_INTEN; |
334 | port->rd->disable_tx_interrupts (port); | 334 | port->rd->disable_tx_interrupts (port); |
335 | } | 335 | } |
336 | func_exit (); | 336 | func_exit (); |
337 | } | 337 | } |
338 | 338 | ||
339 | 339 | ||
340 | void gs_start(struct tty_struct * tty) | 340 | void gs_start(struct tty_struct * tty) |
341 | { | 341 | { |
342 | struct gs_port *port; | 342 | struct gs_port *port; |
343 | 343 | ||
344 | if (!tty) return; | 344 | if (!tty) return; |
345 | 345 | ||
346 | port = tty->driver_data; | 346 | port = tty->driver_data; |
347 | 347 | ||
348 | if (!port) return; | 348 | if (!port) return; |
349 | 349 | ||
350 | if (port->xmit_cnt && | 350 | if (port->xmit_cnt && |
351 | port->xmit_buf && | 351 | port->xmit_buf && |
352 | !(port->flags & GS_TX_INTEN) ) { | 352 | !(port->port.flags & GS_TX_INTEN) ) { |
353 | port->flags |= GS_TX_INTEN; | 353 | port->port.flags |= GS_TX_INTEN; |
354 | port->rd->enable_tx_interrupts (port); | 354 | port->rd->enable_tx_interrupts (port); |
355 | } | 355 | } |
356 | func_exit (); | 356 | func_exit (); |
357 | } | 357 | } |
358 | 358 | ||
359 | 359 | ||
360 | static void gs_shutdown_port (struct gs_port *port) | 360 | static void gs_shutdown_port (struct gs_port *port) |
361 | { | 361 | { |
362 | unsigned long flags; | 362 | unsigned long flags; |
363 | 363 | ||
364 | func_enter(); | 364 | func_enter(); |
365 | 365 | ||
366 | if (!port) return; | 366 | if (!port) return; |
367 | 367 | ||
368 | if (!(port->flags & ASYNC_INITIALIZED)) | 368 | if (!(port->port.flags & ASYNC_INITIALIZED)) |
369 | return; | 369 | return; |
370 | 370 | ||
371 | spin_lock_irqsave(&port->driver_lock, flags); | 371 | spin_lock_irqsave(&port->driver_lock, flags); |
372 | 372 | ||
373 | if (port->xmit_buf) { | 373 | if (port->xmit_buf) { |
374 | free_page((unsigned long) port->xmit_buf); | 374 | free_page((unsigned long) port->xmit_buf); |
375 | port->xmit_buf = NULL; | 375 | port->xmit_buf = NULL; |
376 | } | 376 | } |
377 | 377 | ||
378 | if (port->tty) | 378 | if (port->port.tty) |
379 | set_bit(TTY_IO_ERROR, &port->tty->flags); | 379 | set_bit(TTY_IO_ERROR, &port->port.tty->flags); |
380 | 380 | ||
381 | port->rd->shutdown_port (port); | 381 | port->rd->shutdown_port (port); |
382 | 382 | ||
383 | port->flags &= ~ASYNC_INITIALIZED; | 383 | port->port.flags &= ~ASYNC_INITIALIZED; |
384 | spin_unlock_irqrestore(&port->driver_lock, flags); | 384 | spin_unlock_irqrestore(&port->driver_lock, flags); |
385 | 385 | ||
386 | func_exit(); | 386 | func_exit(); |
387 | } | 387 | } |
388 | 388 | ||
389 | 389 | ||
390 | void gs_hangup(struct tty_struct *tty) | 390 | void gs_hangup(struct tty_struct *tty) |
391 | { | 391 | { |
392 | struct gs_port *port; | 392 | struct gs_port *port; |
393 | 393 | ||
394 | func_enter (); | 394 | func_enter (); |
395 | 395 | ||
396 | if (!tty) return; | 396 | if (!tty) return; |
397 | 397 | ||
398 | port = tty->driver_data; | 398 | port = tty->driver_data; |
399 | tty = port->tty; | 399 | tty = port->port.tty; |
400 | if (!tty) | 400 | if (!tty) |
401 | return; | 401 | return; |
402 | 402 | ||
403 | gs_shutdown_port (port); | 403 | gs_shutdown_port (port); |
404 | port->flags &= ~(ASYNC_NORMAL_ACTIVE|GS_ACTIVE); | 404 | port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|GS_ACTIVE); |
405 | port->tty = NULL; | 405 | port->port.tty = NULL; |
406 | port->count = 0; | 406 | port->port.count = 0; |
407 | 407 | ||
408 | wake_up_interruptible(&port->open_wait); | 408 | wake_up_interruptible(&port->port.open_wait); |
409 | func_exit (); | 409 | func_exit (); |
410 | } | 410 | } |
411 | 411 | ||
412 | 412 | ||
413 | int gs_block_til_ready(void *port_, struct file * filp) | 413 | int gs_block_til_ready(void *port_, struct file * filp) |
414 | { | 414 | { |
415 | struct gs_port *port = port_; | 415 | struct gs_port *port = port_; |
416 | DECLARE_WAITQUEUE(wait, current); | 416 | DECLARE_WAITQUEUE(wait, current); |
417 | int retval; | 417 | int retval; |
418 | int do_clocal = 0; | 418 | int do_clocal = 0; |
419 | int CD; | 419 | int CD; |
420 | struct tty_struct *tty; | 420 | struct tty_struct *tty; |
421 | unsigned long flags; | 421 | unsigned long flags; |
422 | 422 | ||
423 | func_enter (); | 423 | func_enter (); |
424 | 424 | ||
425 | if (!port) return 0; | 425 | if (!port) return 0; |
426 | 426 | ||
427 | tty = port->tty; | 427 | tty = port->port.tty; |
428 | 428 | ||
429 | if (!tty) return 0; | 429 | if (!tty) return 0; |
430 | 430 | ||
431 | gs_dprintk (GS_DEBUG_BTR, "Entering gs_block_till_ready.\n"); | 431 | gs_dprintk (GS_DEBUG_BTR, "Entering gs_block_till_ready.\n"); |
432 | /* | 432 | /* |
433 | * If the device is in the middle of being closed, then block | 433 | * If the device is in the middle of being closed, then block |
434 | * until it's done, and then try again. | 434 | * until it's done, and then try again. |
435 | */ | 435 | */ |
436 | if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) { | 436 | if (tty_hung_up_p(filp) || port->port.flags & ASYNC_CLOSING) { |
437 | interruptible_sleep_on(&port->close_wait); | 437 | interruptible_sleep_on(&port->port.close_wait); |
438 | if (port->flags & ASYNC_HUP_NOTIFY) | 438 | if (port->port.flags & ASYNC_HUP_NOTIFY) |
439 | return -EAGAIN; | 439 | return -EAGAIN; |
440 | else | 440 | else |
441 | return -ERESTARTSYS; | 441 | return -ERESTARTSYS; |
442 | } | 442 | } |
443 | 443 | ||
444 | gs_dprintk (GS_DEBUG_BTR, "after hung up\n"); | 444 | gs_dprintk (GS_DEBUG_BTR, "after hung up\n"); |
445 | 445 | ||
446 | /* | 446 | /* |
447 | * If non-blocking mode is set, or the port is not enabled, | 447 | * If non-blocking mode is set, or the port is not enabled, |
448 | * then make the check up front and then exit. | 448 | * then make the check up front and then exit. |
449 | */ | 449 | */ |
450 | if ((filp->f_flags & O_NONBLOCK) || | 450 | if ((filp->f_flags & O_NONBLOCK) || |
451 | (tty->flags & (1 << TTY_IO_ERROR))) { | 451 | (tty->flags & (1 << TTY_IO_ERROR))) { |
452 | port->flags |= ASYNC_NORMAL_ACTIVE; | 452 | port->port.flags |= ASYNC_NORMAL_ACTIVE; |
453 | return 0; | 453 | return 0; |
454 | } | 454 | } |
455 | 455 | ||
456 | gs_dprintk (GS_DEBUG_BTR, "after nonblock\n"); | 456 | gs_dprintk (GS_DEBUG_BTR, "after nonblock\n"); |
457 | 457 | ||
458 | if (C_CLOCAL(tty)) | 458 | if (C_CLOCAL(tty)) |
459 | do_clocal = 1; | 459 | do_clocal = 1; |
460 | 460 | ||
461 | /* | 461 | /* |
462 | * Block waiting for the carrier detect and the line to become | 462 | * Block waiting for the carrier detect and the line to become |
463 | * free (i.e., not in use by the callout). While we are in | 463 | * free (i.e., not in use by the callout). While we are in |
464 | * this loop, port->count is dropped by one, so that | 464 | * this loop, port->port.count is dropped by one, so that |
465 | * rs_close() knows when to free things. We restore it upon | 465 | * rs_close() knows when to free things. We restore it upon |
466 | * exit, either normal or abnormal. | 466 | * exit, either normal or abnormal. |
467 | */ | 467 | */ |
468 | retval = 0; | 468 | retval = 0; |
469 | 469 | ||
470 | add_wait_queue(&port->open_wait, &wait); | 470 | add_wait_queue(&port->port.open_wait, &wait); |
471 | 471 | ||
472 | gs_dprintk (GS_DEBUG_BTR, "after add waitq.\n"); | 472 | gs_dprintk (GS_DEBUG_BTR, "after add waitq.\n"); |
473 | spin_lock_irqsave(&port->driver_lock, flags); | 473 | spin_lock_irqsave(&port->driver_lock, flags); |
474 | if (!tty_hung_up_p(filp)) { | 474 | if (!tty_hung_up_p(filp)) { |
475 | port->count--; | 475 | port->port.count--; |
476 | } | 476 | } |
477 | spin_unlock_irqrestore(&port->driver_lock, flags); | 477 | spin_unlock_irqrestore(&port->driver_lock, flags); |
478 | port->blocked_open++; | 478 | port->port.blocked_open++; |
479 | while (1) { | 479 | while (1) { |
480 | CD = port->rd->get_CD (port); | 480 | CD = port->rd->get_CD (port); |
481 | gs_dprintk (GS_DEBUG_BTR, "CD is now %d.\n", CD); | 481 | gs_dprintk (GS_DEBUG_BTR, "CD is now %d.\n", CD); |
482 | set_current_state (TASK_INTERRUPTIBLE); | 482 | set_current_state (TASK_INTERRUPTIBLE); |
483 | if (tty_hung_up_p(filp) || | 483 | if (tty_hung_up_p(filp) || |
484 | !(port->flags & ASYNC_INITIALIZED)) { | 484 | !(port->port.flags & ASYNC_INITIALIZED)) { |
485 | if (port->flags & ASYNC_HUP_NOTIFY) | 485 | if (port->port.flags & ASYNC_HUP_NOTIFY) |
486 | retval = -EAGAIN; | 486 | retval = -EAGAIN; |
487 | else | 487 | else |
488 | retval = -ERESTARTSYS; | 488 | retval = -ERESTARTSYS; |
489 | break; | 489 | break; |
490 | } | 490 | } |
491 | if (!(port->flags & ASYNC_CLOSING) && | 491 | if (!(port->port.flags & ASYNC_CLOSING) && |
492 | (do_clocal || CD)) | 492 | (do_clocal || CD)) |
493 | break; | 493 | break; |
494 | gs_dprintk (GS_DEBUG_BTR, "signal_pending is now: %d (%lx)\n", | 494 | gs_dprintk (GS_DEBUG_BTR, "signal_pending is now: %d (%lx)\n", |
495 | (int)signal_pending (current), *(long*)(¤t->blocked)); | 495 | (int)signal_pending (current), *(long*)(¤t->blocked)); |
496 | if (signal_pending(current)) { | 496 | if (signal_pending(current)) { |
497 | retval = -ERESTARTSYS; | 497 | retval = -ERESTARTSYS; |
498 | break; | 498 | break; |
499 | } | 499 | } |
500 | schedule(); | 500 | schedule(); |
501 | } | 501 | } |
502 | gs_dprintk (GS_DEBUG_BTR, "Got out of the loop. (%d)\n", | 502 | gs_dprintk (GS_DEBUG_BTR, "Got out of the loop. (%d)\n", |
503 | port->blocked_open); | 503 | port->port.blocked_open); |
504 | set_current_state (TASK_RUNNING); | 504 | set_current_state (TASK_RUNNING); |
505 | remove_wait_queue(&port->open_wait, &wait); | 505 | remove_wait_queue(&port->port.open_wait, &wait); |
506 | if (!tty_hung_up_p(filp)) { | 506 | if (!tty_hung_up_p(filp)) { |
507 | port->count++; | 507 | port->port.count++; |
508 | } | 508 | } |
509 | port->blocked_open--; | 509 | port->port.blocked_open--; |
510 | if (retval) | 510 | if (retval) |
511 | return retval; | 511 | return retval; |
512 | 512 | ||
513 | port->flags |= ASYNC_NORMAL_ACTIVE; | 513 | port->port.flags |= ASYNC_NORMAL_ACTIVE; |
514 | func_exit (); | 514 | func_exit (); |
515 | return 0; | 515 | return 0; |
516 | } | 516 | } |
517 | 517 | ||
518 | 518 | ||
519 | void gs_close(struct tty_struct * tty, struct file * filp) | 519 | void gs_close(struct tty_struct * tty, struct file * filp) |
520 | { | 520 | { |
521 | unsigned long flags; | 521 | unsigned long flags; |
522 | struct gs_port *port; | 522 | struct gs_port *port; |
523 | 523 | ||
524 | func_enter (); | 524 | func_enter (); |
525 | 525 | ||
526 | if (!tty) return; | 526 | if (!tty) return; |
527 | 527 | ||
528 | port = (struct gs_port *) tty->driver_data; | 528 | port = (struct gs_port *) tty->driver_data; |
529 | 529 | ||
530 | if (!port) return; | 530 | if (!port) return; |
531 | 531 | ||
532 | if (!port->tty) { | 532 | if (!port->port.tty) { |
533 | /* This seems to happen when this is called from vhangup. */ | 533 | /* This seems to happen when this is called from vhangup. */ |
534 | gs_dprintk (GS_DEBUG_CLOSE, "gs: Odd: port->tty is NULL\n"); | 534 | gs_dprintk (GS_DEBUG_CLOSE, "gs: Odd: port->port.tty is NULL\n"); |
535 | port->tty = tty; | 535 | port->port.tty = tty; |
536 | } | 536 | } |
537 | 537 | ||
538 | spin_lock_irqsave(&port->driver_lock, flags); | 538 | spin_lock_irqsave(&port->driver_lock, flags); |
539 | 539 | ||
540 | if (tty_hung_up_p(filp)) { | 540 | if (tty_hung_up_p(filp)) { |
541 | spin_unlock_irqrestore(&port->driver_lock, flags); | 541 | spin_unlock_irqrestore(&port->driver_lock, flags); |
542 | if (port->rd->hungup) | 542 | if (port->rd->hungup) |
543 | port->rd->hungup (port); | 543 | port->rd->hungup (port); |
544 | func_exit (); | 544 | func_exit (); |
545 | return; | 545 | return; |
546 | } | 546 | } |
547 | 547 | ||
548 | if ((tty->count == 1) && (port->count != 1)) { | 548 | if ((tty->count == 1) && (port->port.count != 1)) { |
549 | printk(KERN_ERR "gs: gs_close port %p: bad port count;" | 549 | printk(KERN_ERR "gs: gs_close port %p: bad port count;" |
550 | " tty->count is 1, port count is %d\n", port, port->count); | 550 | " tty->count is 1, port count is %d\n", port, port->port.count); |
551 | port->count = 1; | 551 | port->port.count = 1; |
552 | } | 552 | } |
553 | if (--port->count < 0) { | 553 | if (--port->port.count < 0) { |
554 | printk(KERN_ERR "gs: gs_close port %p: bad port count: %d\n", port, port->count); | 554 | printk(KERN_ERR "gs: gs_close port %p: bad port count: %d\n", port, port->port.count); |
555 | port->count = 0; | 555 | port->port.count = 0; |
556 | } | 556 | } |
557 | 557 | ||
558 | if (port->count) { | 558 | if (port->port.count) { |
559 | gs_dprintk(GS_DEBUG_CLOSE, "gs_close port %p: count: %d\n", port, port->count); | 559 | gs_dprintk(GS_DEBUG_CLOSE, "gs_close port %p: count: %d\n", port, port->port.count); |
560 | spin_unlock_irqrestore(&port->driver_lock, flags); | 560 | spin_unlock_irqrestore(&port->driver_lock, flags); |
561 | func_exit (); | 561 | func_exit (); |
562 | return; | 562 | return; |
563 | } | 563 | } |
564 | port->flags |= ASYNC_CLOSING; | 564 | port->port.flags |= ASYNC_CLOSING; |
565 | 565 | ||
566 | /* | 566 | /* |
567 | * Now we wait for the transmit buffer to clear; and we notify | 567 | * Now we wait for the transmit buffer to clear; and we notify |
568 | * the line discipline to only process XON/XOFF characters. | 568 | * the line discipline to only process XON/XOFF characters. |
569 | */ | 569 | */ |
570 | tty->closing = 1; | 570 | tty->closing = 1; |
571 | /* if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) | 571 | /* if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) |
572 | tty_wait_until_sent(tty, port->closing_wait); */ | 572 | tty_wait_until_sent(tty, port->closing_wait); */ |
573 | 573 | ||
574 | /* | 574 | /* |
575 | * At this point we stop accepting input. To do this, we | 575 | * At this point we stop accepting input. To do this, we |
576 | * disable the receive line status interrupts, and tell the | 576 | * disable the receive line status interrupts, and tell the |
577 | * interrupt driver to stop checking the data ready bit in the | 577 | * interrupt driver to stop checking the data ready bit in the |
578 | * line status register. | 578 | * line status register. |
579 | */ | 579 | */ |
580 | 580 | ||
581 | port->rd->disable_rx_interrupts (port); | 581 | port->rd->disable_rx_interrupts (port); |
582 | spin_unlock_irqrestore(&port->driver_lock, flags); | 582 | spin_unlock_irqrestore(&port->driver_lock, flags); |
583 | 583 | ||
584 | /* close has no way of returning "EINTR", so discard return value */ | 584 | /* close has no way of returning "EINTR", so discard return value */ |
585 | if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) | 585 | if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) |
586 | gs_wait_tx_flushed (port, port->closing_wait); | 586 | gs_wait_tx_flushed (port, port->closing_wait); |
587 | 587 | ||
588 | port->flags &= ~GS_ACTIVE; | 588 | port->port.flags &= ~GS_ACTIVE; |
589 | 589 | ||
590 | gs_flush_buffer(tty); | 590 | gs_flush_buffer(tty); |
591 | 591 | ||
592 | tty_ldisc_flush(tty); | 592 | tty_ldisc_flush(tty); |
593 | tty->closing = 0; | 593 | tty->closing = 0; |
594 | 594 | ||
595 | port->event = 0; | 595 | port->event = 0; |
596 | port->rd->close (port); | 596 | port->rd->close (port); |
597 | port->rd->shutdown_port (port); | 597 | port->rd->shutdown_port (port); |
598 | port->tty = NULL; | 598 | port->port.tty = NULL; |
599 | 599 | ||
600 | if (port->blocked_open) { | 600 | if (port->port.blocked_open) { |
601 | if (port->close_delay) { | 601 | if (port->close_delay) { |
602 | spin_unlock_irqrestore(&port->driver_lock, flags); | 602 | spin_unlock_irqrestore(&port->driver_lock, flags); |
603 | msleep_interruptible(jiffies_to_msecs(port->close_delay)); | 603 | msleep_interruptible(jiffies_to_msecs(port->close_delay)); |
604 | spin_lock_irqsave(&port->driver_lock, flags); | 604 | spin_lock_irqsave(&port->driver_lock, flags); |
605 | } | 605 | } |
606 | wake_up_interruptible(&port->open_wait); | 606 | wake_up_interruptible(&port->port.open_wait); |
607 | } | 607 | } |
608 | port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING | ASYNC_INITIALIZED); | 608 | port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING | ASYNC_INITIALIZED); |
609 | wake_up_interruptible(&port->close_wait); | 609 | wake_up_interruptible(&port->port.close_wait); |
610 | 610 | ||
611 | func_exit (); | 611 | func_exit (); |
612 | } | 612 | } |
613 | 613 | ||
614 | 614 | ||
615 | void gs_set_termios (struct tty_struct * tty, | 615 | void gs_set_termios (struct tty_struct * tty, |
616 | struct ktermios * old_termios) | 616 | struct ktermios * old_termios) |
617 | { | 617 | { |
618 | struct gs_port *port; | 618 | struct gs_port *port; |
619 | int baudrate, tmp, rv; | 619 | int baudrate, tmp, rv; |
620 | struct ktermios *tiosp; | 620 | struct ktermios *tiosp; |
621 | 621 | ||
622 | func_enter(); | 622 | func_enter(); |
623 | 623 | ||
624 | if (!tty) return; | 624 | if (!tty) return; |
625 | 625 | ||
626 | port = tty->driver_data; | 626 | port = tty->driver_data; |
627 | 627 | ||
628 | if (!port) return; | 628 | if (!port) return; |
629 | if (!port->tty) { | 629 | if (!port->port.tty) { |
630 | /* This seems to happen when this is called after gs_close. */ | 630 | /* This seems to happen when this is called after gs_close. */ |
631 | gs_dprintk (GS_DEBUG_TERMIOS, "gs: Odd: port->tty is NULL\n"); | 631 | gs_dprintk (GS_DEBUG_TERMIOS, "gs: Odd: port->port.tty is NULL\n"); |
632 | port->tty = tty; | 632 | port->port.tty = tty; |
633 | } | 633 | } |
634 | 634 | ||
635 | 635 | ||
636 | tiosp = tty->termios; | 636 | tiosp = tty->termios; |
637 | 637 | ||
638 | if (gs_debug & GS_DEBUG_TERMIOS) { | 638 | if (gs_debug & GS_DEBUG_TERMIOS) { |
639 | gs_dprintk (GS_DEBUG_TERMIOS, "termios structure (%p):\n", tiosp); | 639 | gs_dprintk (GS_DEBUG_TERMIOS, "termios structure (%p):\n", tiosp); |
640 | } | 640 | } |
641 | 641 | ||
642 | if(old_termios && (gs_debug & GS_DEBUG_TERMIOS)) { | 642 | if(old_termios && (gs_debug & GS_DEBUG_TERMIOS)) { |
643 | if(tiosp->c_iflag != old_termios->c_iflag) printk("c_iflag changed\n"); | 643 | if(tiosp->c_iflag != old_termios->c_iflag) printk("c_iflag changed\n"); |
644 | if(tiosp->c_oflag != old_termios->c_oflag) printk("c_oflag changed\n"); | 644 | if(tiosp->c_oflag != old_termios->c_oflag) printk("c_oflag changed\n"); |
645 | if(tiosp->c_cflag != old_termios->c_cflag) printk("c_cflag changed\n"); | 645 | if(tiosp->c_cflag != old_termios->c_cflag) printk("c_cflag changed\n"); |
646 | if(tiosp->c_lflag != old_termios->c_lflag) printk("c_lflag changed\n"); | 646 | if(tiosp->c_lflag != old_termios->c_lflag) printk("c_lflag changed\n"); |
647 | if(tiosp->c_line != old_termios->c_line) printk("c_line changed\n"); | 647 | if(tiosp->c_line != old_termios->c_line) printk("c_line changed\n"); |
648 | if(!memcmp(tiosp->c_cc, old_termios->c_cc, NCC)) printk("c_cc changed\n"); | 648 | if(!memcmp(tiosp->c_cc, old_termios->c_cc, NCC)) printk("c_cc changed\n"); |
649 | } | 649 | } |
650 | 650 | ||
651 | baudrate = tty_get_baud_rate(tty); | 651 | baudrate = tty_get_baud_rate(tty); |
652 | 652 | ||
653 | if ((tiosp->c_cflag & CBAUD) == B38400) { | 653 | if ((tiosp->c_cflag & CBAUD) == B38400) { |
654 | if ( (port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) | 654 | if ( (port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) |
655 | baudrate = 57600; | 655 | baudrate = 57600; |
656 | else if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) | 656 | else if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) |
657 | baudrate = 115200; | 657 | baudrate = 115200; |
658 | else if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) | 658 | else if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) |
659 | baudrate = 230400; | 659 | baudrate = 230400; |
660 | else if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) | 660 | else if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) |
661 | baudrate = 460800; | 661 | baudrate = 460800; |
662 | else if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) | 662 | else if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) |
663 | baudrate = (port->baud_base / port->custom_divisor); | 663 | baudrate = (port->baud_base / port->custom_divisor); |
664 | } | 664 | } |
665 | 665 | ||
666 | /* I recommend using THIS instead of the mess in termios (and | 666 | /* I recommend using THIS instead of the mess in termios (and |
667 | duplicating the above code). Next we should create a clean | 667 | duplicating the above code). Next we should create a clean |
668 | interface towards this variable. If your card supports arbitrary | 668 | interface towards this variable. If your card supports arbitrary |
669 | baud rates, (e.g. CD1400 or 16550 based cards) then everything | 669 | baud rates, (e.g. CD1400 or 16550 based cards) then everything |
670 | will be very easy..... */ | 670 | will be very easy..... */ |
671 | port->baud = baudrate; | 671 | port->baud = baudrate; |
672 | 672 | ||
673 | /* Two timer ticks seems enough to wakeup something like SLIP driver */ | 673 | /* Two timer ticks seems enough to wakeup something like SLIP driver */ |
674 | /* Baudrate/10 is cps. Divide by HZ to get chars per tick. */ | 674 | /* Baudrate/10 is cps. Divide by HZ to get chars per tick. */ |
675 | tmp = (baudrate / 10 / HZ) * 2; | 675 | tmp = (baudrate / 10 / HZ) * 2; |
676 | 676 | ||
677 | if (tmp < 0) tmp = 0; | 677 | if (tmp < 0) tmp = 0; |
678 | if (tmp >= SERIAL_XMIT_SIZE) tmp = SERIAL_XMIT_SIZE-1; | 678 | if (tmp >= SERIAL_XMIT_SIZE) tmp = SERIAL_XMIT_SIZE-1; |
679 | 679 | ||
680 | port->wakeup_chars = tmp; | 680 | port->wakeup_chars = tmp; |
681 | 681 | ||
682 | /* We should really wait for the characters to be all sent before | 682 | /* We should really wait for the characters to be all sent before |
683 | changing the settings. -- CAL */ | 683 | changing the settings. -- CAL */ |
684 | rv = gs_wait_tx_flushed (port, MAX_SCHEDULE_TIMEOUT); | 684 | rv = gs_wait_tx_flushed (port, MAX_SCHEDULE_TIMEOUT); |
685 | if (rv < 0) return /* rv */; | 685 | if (rv < 0) return /* rv */; |
686 | 686 | ||
687 | rv = port->rd->set_real_termios(port); | 687 | rv = port->rd->set_real_termios(port); |
688 | if (rv < 0) return /* rv */; | 688 | if (rv < 0) return /* rv */; |
689 | 689 | ||
690 | if ((!old_termios || | 690 | if ((!old_termios || |
691 | (old_termios->c_cflag & CRTSCTS)) && | 691 | (old_termios->c_cflag & CRTSCTS)) && |
692 | !( tiosp->c_cflag & CRTSCTS)) { | 692 | !( tiosp->c_cflag & CRTSCTS)) { |
693 | tty->stopped = 0; | 693 | tty->stopped = 0; |
694 | gs_start(tty); | 694 | gs_start(tty); |
695 | } | 695 | } |
696 | 696 | ||
697 | #ifdef tytso_patch_94Nov25_1726 | 697 | #ifdef tytso_patch_94Nov25_1726 |
698 | /* This "makes sense", Why is it commented out? */ | 698 | /* This "makes sense", Why is it commented out? */ |
699 | 699 | ||
700 | if (!(old_termios->c_cflag & CLOCAL) && | 700 | if (!(old_termios->c_cflag & CLOCAL) && |
701 | (tty->termios->c_cflag & CLOCAL)) | 701 | (tty->termios->c_cflag & CLOCAL)) |
702 | wake_up_interruptible(&port->gs.open_wait); | 702 | wake_up_interruptible(&port->gs.open_wait); |
703 | #endif | 703 | #endif |
704 | 704 | ||
705 | func_exit(); | 705 | func_exit(); |
706 | return /* 0 */; | 706 | return /* 0 */; |
707 | } | 707 | } |
708 | 708 | ||
709 | 709 | ||
710 | 710 | ||
711 | /* Must be called with interrupts enabled */ | 711 | /* Must be called with interrupts enabled */ |
712 | int gs_init_port(struct gs_port *port) | 712 | int gs_init_port(struct gs_port *port) |
713 | { | 713 | { |
714 | unsigned long flags; | 714 | unsigned long flags; |
715 | 715 | ||
716 | func_enter (); | 716 | func_enter (); |
717 | 717 | ||
718 | if (port->flags & ASYNC_INITIALIZED) { | 718 | if (port->port.flags & ASYNC_INITIALIZED) { |
719 | func_exit (); | 719 | func_exit (); |
720 | return 0; | 720 | return 0; |
721 | } | 721 | } |
722 | if (!port->xmit_buf) { | 722 | if (!port->xmit_buf) { |
723 | /* We may sleep in get_zeroed_page() */ | 723 | /* We may sleep in get_zeroed_page() */ |
724 | unsigned long tmp; | 724 | unsigned long tmp; |
725 | 725 | ||
726 | tmp = get_zeroed_page(GFP_KERNEL); | 726 | tmp = get_zeroed_page(GFP_KERNEL); |
727 | spin_lock_irqsave (&port->driver_lock, flags); | 727 | spin_lock_irqsave (&port->driver_lock, flags); |
728 | if (port->xmit_buf) | 728 | if (port->xmit_buf) |
729 | free_page (tmp); | 729 | free_page (tmp); |
730 | else | 730 | else |
731 | port->xmit_buf = (unsigned char *) tmp; | 731 | port->xmit_buf = (unsigned char *) tmp; |
732 | spin_unlock_irqrestore(&port->driver_lock, flags); | 732 | spin_unlock_irqrestore(&port->driver_lock, flags); |
733 | if (!port->xmit_buf) { | 733 | if (!port->xmit_buf) { |
734 | func_exit (); | 734 | func_exit (); |
735 | return -ENOMEM; | 735 | return -ENOMEM; |
736 | } | 736 | } |
737 | } | 737 | } |
738 | 738 | ||
739 | spin_lock_irqsave (&port->driver_lock, flags); | 739 | spin_lock_irqsave (&port->driver_lock, flags); |
740 | if (port->tty) | 740 | if (port->port.tty) |
741 | clear_bit(TTY_IO_ERROR, &port->tty->flags); | 741 | clear_bit(TTY_IO_ERROR, &port->port.tty->flags); |
742 | mutex_init(&port->port_write_mutex); | 742 | mutex_init(&port->port_write_mutex); |
743 | port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; | 743 | port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; |
744 | spin_unlock_irqrestore(&port->driver_lock, flags); | 744 | spin_unlock_irqrestore(&port->driver_lock, flags); |
745 | gs_set_termios(port->tty, NULL); | 745 | gs_set_termios(port->port.tty, NULL); |
746 | spin_lock_irqsave (&port->driver_lock, flags); | 746 | spin_lock_irqsave (&port->driver_lock, flags); |
747 | port->flags |= ASYNC_INITIALIZED; | 747 | port->port.flags |= ASYNC_INITIALIZED; |
748 | port->flags &= ~GS_TX_INTEN; | 748 | port->port.flags &= ~GS_TX_INTEN; |
749 | 749 | ||
750 | spin_unlock_irqrestore(&port->driver_lock, flags); | 750 | spin_unlock_irqrestore(&port->driver_lock, flags); |
751 | func_exit (); | 751 | func_exit (); |
752 | return 0; | 752 | return 0; |
753 | } | 753 | } |
754 | 754 | ||
755 | 755 | ||
756 | int gs_setserial(struct gs_port *port, struct serial_struct __user *sp) | 756 | int gs_setserial(struct gs_port *port, struct serial_struct __user *sp) |
757 | { | 757 | { |
758 | struct serial_struct sio; | 758 | struct serial_struct sio; |
759 | 759 | ||
760 | if (copy_from_user(&sio, sp, sizeof(struct serial_struct))) | 760 | if (copy_from_user(&sio, sp, sizeof(struct serial_struct))) |
761 | return(-EFAULT); | 761 | return(-EFAULT); |
762 | 762 | ||
763 | if (!capable(CAP_SYS_ADMIN)) { | 763 | if (!capable(CAP_SYS_ADMIN)) { |
764 | if ((sio.baud_base != port->baud_base) || | 764 | if ((sio.baud_base != port->baud_base) || |
765 | (sio.close_delay != port->close_delay) || | 765 | (sio.close_delay != port->close_delay) || |
766 | ((sio.flags & ~ASYNC_USR_MASK) != | 766 | ((sio.flags & ~ASYNC_USR_MASK) != |
767 | (port->flags & ~ASYNC_USR_MASK))) | 767 | (port->port.flags & ~ASYNC_USR_MASK))) |
768 | return(-EPERM); | 768 | return(-EPERM); |
769 | } | 769 | } |
770 | 770 | ||
771 | port->flags = (port->flags & ~ASYNC_USR_MASK) | | 771 | port->port.flags = (port->port.flags & ~ASYNC_USR_MASK) | |
772 | (sio.flags & ASYNC_USR_MASK); | 772 | (sio.flags & ASYNC_USR_MASK); |
773 | 773 | ||
774 | port->baud_base = sio.baud_base; | 774 | port->baud_base = sio.baud_base; |
775 | port->close_delay = sio.close_delay; | 775 | port->close_delay = sio.close_delay; |
776 | port->closing_wait = sio.closing_wait; | 776 | port->closing_wait = sio.closing_wait; |
777 | port->custom_divisor = sio.custom_divisor; | 777 | port->custom_divisor = sio.custom_divisor; |
778 | 778 | ||
779 | gs_set_termios (port->tty, NULL); | 779 | gs_set_termios (port->port.tty, NULL); |
780 | 780 | ||
781 | return 0; | 781 | return 0; |
782 | } | 782 | } |
783 | 783 | ||
784 | 784 | ||
785 | /*****************************************************************************/ | 785 | /*****************************************************************************/ |
786 | 786 | ||
787 | /* | 787 | /* |
788 | * Generate the serial struct info. | 788 | * Generate the serial struct info. |
789 | */ | 789 | */ |
790 | 790 | ||
791 | int gs_getserial(struct gs_port *port, struct serial_struct __user *sp) | 791 | int gs_getserial(struct gs_port *port, struct serial_struct __user *sp) |
792 | { | 792 | { |
793 | struct serial_struct sio; | 793 | struct serial_struct sio; |
794 | 794 | ||
795 | memset(&sio, 0, sizeof(struct serial_struct)); | 795 | memset(&sio, 0, sizeof(struct serial_struct)); |
796 | sio.flags = port->flags; | 796 | sio.flags = port->port.flags; |
797 | sio.baud_base = port->baud_base; | 797 | sio.baud_base = port->baud_base; |
798 | sio.close_delay = port->close_delay; | 798 | sio.close_delay = port->close_delay; |
799 | sio.closing_wait = port->closing_wait; | 799 | sio.closing_wait = port->closing_wait; |
800 | sio.custom_divisor = port->custom_divisor; | 800 | sio.custom_divisor = port->custom_divisor; |
801 | sio.hub6 = 0; | 801 | sio.hub6 = 0; |
802 | 802 | ||
803 | /* If you want you can override these. */ | 803 | /* If you want you can override these. */ |
804 | sio.type = PORT_UNKNOWN; | 804 | sio.type = PORT_UNKNOWN; |
805 | sio.xmit_fifo_size = -1; | 805 | sio.xmit_fifo_size = -1; |
806 | sio.line = -1; | 806 | sio.line = -1; |
807 | sio.port = -1; | 807 | sio.port = -1; |
808 | sio.irq = -1; | 808 | sio.irq = -1; |
809 | 809 | ||
810 | if (port->rd->getserial) | 810 | if (port->rd->getserial) |
811 | port->rd->getserial (port, &sio); | 811 | port->rd->getserial (port, &sio); |
812 | 812 | ||
813 | if (copy_to_user(sp, &sio, sizeof(struct serial_struct))) | 813 | if (copy_to_user(sp, &sio, sizeof(struct serial_struct))) |
814 | return -EFAULT; | 814 | return -EFAULT; |
815 | return 0; | 815 | return 0; |
816 | 816 | ||
817 | } | 817 | } |
818 | 818 | ||
819 | 819 | ||
820 | void gs_got_break(struct gs_port *port) | 820 | void gs_got_break(struct gs_port *port) |
821 | { | 821 | { |
822 | func_enter (); | 822 | func_enter (); |
823 | 823 | ||
824 | tty_insert_flip_char(port->tty, 0, TTY_BREAK); | 824 | tty_insert_flip_char(port->port.tty, 0, TTY_BREAK); |
825 | tty_schedule_flip(port->tty); | 825 | tty_schedule_flip(port->port.tty); |
826 | if (port->flags & ASYNC_SAK) { | 826 | if (port->port.flags & ASYNC_SAK) { |
827 | do_SAK (port->tty); | 827 | do_SAK (port->port.tty); |
828 | } | 828 | } |
829 | 829 | ||
830 | func_exit (); | 830 | func_exit (); |
831 | } | 831 | } |
832 | 832 | ||
833 | 833 | ||
834 | EXPORT_SYMBOL(gs_put_char); | 834 | EXPORT_SYMBOL(gs_put_char); |
835 | EXPORT_SYMBOL(gs_write); | 835 | EXPORT_SYMBOL(gs_write); |
836 | EXPORT_SYMBOL(gs_write_room); | 836 | EXPORT_SYMBOL(gs_write_room); |
837 | EXPORT_SYMBOL(gs_chars_in_buffer); | 837 | EXPORT_SYMBOL(gs_chars_in_buffer); |
838 | EXPORT_SYMBOL(gs_flush_buffer); | 838 | EXPORT_SYMBOL(gs_flush_buffer); |
839 | EXPORT_SYMBOL(gs_flush_chars); | 839 | EXPORT_SYMBOL(gs_flush_chars); |
840 | EXPORT_SYMBOL(gs_stop); | 840 | EXPORT_SYMBOL(gs_stop); |
841 | EXPORT_SYMBOL(gs_start); | 841 | EXPORT_SYMBOL(gs_start); |
842 | EXPORT_SYMBOL(gs_hangup); | 842 | EXPORT_SYMBOL(gs_hangup); |
843 | EXPORT_SYMBOL(gs_block_til_ready); | 843 | EXPORT_SYMBOL(gs_block_til_ready); |
844 | EXPORT_SYMBOL(gs_close); | 844 | EXPORT_SYMBOL(gs_close); |
845 | EXPORT_SYMBOL(gs_set_termios); | 845 | EXPORT_SYMBOL(gs_set_termios); |
846 | EXPORT_SYMBOL(gs_init_port); | 846 | EXPORT_SYMBOL(gs_init_port); |
847 | EXPORT_SYMBOL(gs_setserial); | 847 | EXPORT_SYMBOL(gs_setserial); |
848 | EXPORT_SYMBOL(gs_getserial); | 848 | EXPORT_SYMBOL(gs_getserial); |
849 | EXPORT_SYMBOL(gs_got_break); | 849 | EXPORT_SYMBOL(gs_got_break); |
850 | 850 | ||
851 | MODULE_LICENSE("GPL"); | 851 | MODULE_LICENSE("GPL"); |
852 | 852 |
drivers/char/rio/rio_linux.c
1 | 1 | ||
2 | /* rio_linux.c -- Linux driver for the Specialix RIO series cards. | 2 | /* rio_linux.c -- Linux driver for the Specialix RIO series cards. |
3 | * | 3 | * |
4 | * | 4 | * |
5 | * (C) 1999 R.E.Wolff@BitWizard.nl | 5 | * (C) 1999 R.E.Wolff@BitWizard.nl |
6 | * | 6 | * |
7 | * Specialix pays for the development and support of this driver. | 7 | * Specialix pays for the development and support of this driver. |
8 | * Please DO contact support@specialix.co.uk if you require | 8 | * Please DO contact support@specialix.co.uk if you require |
9 | * support. But please read the documentation (rio.txt) first. | 9 | * support. But please read the documentation (rio.txt) first. |
10 | * | 10 | * |
11 | * | 11 | * |
12 | * | 12 | * |
13 | * This program is free software; you can redistribute it and/or | 13 | * This program is free software; you can redistribute it and/or |
14 | * modify it under the terms of the GNU General Public License as | 14 | * modify it under the terms of the GNU General Public License as |
15 | * published by the Free Software Foundation; either version 2 of | 15 | * published by the Free Software Foundation; either version 2 of |
16 | * the License, or (at your option) any later version. | 16 | * the License, or (at your option) any later version. |
17 | * | 17 | * |
18 | * This program is distributed in the hope that it will be | 18 | * This program is distributed in the hope that it will be |
19 | * useful, but WITHOUT ANY WARRANTY; without even the implied | 19 | * useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | 20 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
21 | * PURPOSE. See the GNU General Public License for more details. | 21 | * PURPOSE. See the GNU General Public License for more details. |
22 | * | 22 | * |
23 | * You should have received a copy of the GNU General Public | 23 | * You should have received a copy of the GNU General Public |
24 | * License along with this program; if not, write to the Free | 24 | * License along with this program; if not, write to the Free |
25 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, | 25 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, |
26 | * USA. | 26 | * USA. |
27 | * | 27 | * |
28 | * */ | 28 | * */ |
29 | 29 | ||
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/kdev_t.h> | 31 | #include <linux/kdev_t.h> |
32 | #include <asm/io.h> | 32 | #include <asm/io.h> |
33 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
34 | #include <linux/sched.h> | 34 | #include <linux/sched.h> |
35 | #include <linux/ioport.h> | 35 | #include <linux/ioport.h> |
36 | #include <linux/interrupt.h> | 36 | #include <linux/interrupt.h> |
37 | #include <linux/errno.h> | 37 | #include <linux/errno.h> |
38 | #include <linux/tty.h> | 38 | #include <linux/tty.h> |
39 | #include <linux/tty_flip.h> | 39 | #include <linux/tty_flip.h> |
40 | #include <linux/mm.h> | 40 | #include <linux/mm.h> |
41 | #include <linux/serial.h> | 41 | #include <linux/serial.h> |
42 | #include <linux/fcntl.h> | 42 | #include <linux/fcntl.h> |
43 | #include <linux/major.h> | 43 | #include <linux/major.h> |
44 | #include <linux/delay.h> | 44 | #include <linux/delay.h> |
45 | #include <linux/pci.h> | 45 | #include <linux/pci.h> |
46 | #include <linux/slab.h> | 46 | #include <linux/slab.h> |
47 | #include <linux/miscdevice.h> | 47 | #include <linux/miscdevice.h> |
48 | #include <linux/init.h> | 48 | #include <linux/init.h> |
49 | 49 | ||
50 | #include <linux/generic_serial.h> | 50 | #include <linux/generic_serial.h> |
51 | #include <asm/uaccess.h> | 51 | #include <asm/uaccess.h> |
52 | 52 | ||
53 | #include "linux_compat.h" | 53 | #include "linux_compat.h" |
54 | #include "pkt.h" | 54 | #include "pkt.h" |
55 | #include "daemon.h" | 55 | #include "daemon.h" |
56 | #include "rio.h" | 56 | #include "rio.h" |
57 | #include "riospace.h" | 57 | #include "riospace.h" |
58 | #include "cmdpkt.h" | 58 | #include "cmdpkt.h" |
59 | #include "map.h" | 59 | #include "map.h" |
60 | #include "rup.h" | 60 | #include "rup.h" |
61 | #include "port.h" | 61 | #include "port.h" |
62 | #include "riodrvr.h" | 62 | #include "riodrvr.h" |
63 | #include "rioinfo.h" | 63 | #include "rioinfo.h" |
64 | #include "func.h" | 64 | #include "func.h" |
65 | #include "errors.h" | 65 | #include "errors.h" |
66 | #include "pci.h" | 66 | #include "pci.h" |
67 | 67 | ||
68 | #include "parmmap.h" | 68 | #include "parmmap.h" |
69 | #include "unixrup.h" | 69 | #include "unixrup.h" |
70 | #include "board.h" | 70 | #include "board.h" |
71 | #include "host.h" | 71 | #include "host.h" |
72 | #include "phb.h" | 72 | #include "phb.h" |
73 | #include "link.h" | 73 | #include "link.h" |
74 | #include "cmdblk.h" | 74 | #include "cmdblk.h" |
75 | #include "route.h" | 75 | #include "route.h" |
76 | #include "cirrus.h" | 76 | #include "cirrus.h" |
77 | #include "rioioctl.h" | 77 | #include "rioioctl.h" |
78 | #include "param.h" | 78 | #include "param.h" |
79 | #include "protsts.h" | 79 | #include "protsts.h" |
80 | #include "rioboard.h" | 80 | #include "rioboard.h" |
81 | 81 | ||
82 | 82 | ||
83 | #include "rio_linux.h" | 83 | #include "rio_linux.h" |
84 | 84 | ||
85 | /* I don't think that this driver can handle more than 512 ports on | 85 | /* I don't think that this driver can handle more than 512 ports on |
86 | one machine. Specialix specifies max 4 boards in one machine. I don't | 86 | one machine. Specialix specifies max 4 boards in one machine. I don't |
87 | know why. If you want to try anyway you'll have to increase the number | 87 | know why. If you want to try anyway you'll have to increase the number |
88 | of boards in rio.h. You'll have to allocate more majors if you need | 88 | of boards in rio.h. You'll have to allocate more majors if you need |
89 | more than 512 ports.... */ | 89 | more than 512 ports.... */ |
90 | 90 | ||
91 | #ifndef RIO_NORMAL_MAJOR0 | 91 | #ifndef RIO_NORMAL_MAJOR0 |
92 | /* This allows overriding on the compiler commandline, or in a "major.h" | 92 | /* This allows overriding on the compiler commandline, or in a "major.h" |
93 | include or something like that */ | 93 | include or something like that */ |
94 | #define RIO_NORMAL_MAJOR0 154 | 94 | #define RIO_NORMAL_MAJOR0 154 |
95 | #define RIO_NORMAL_MAJOR1 156 | 95 | #define RIO_NORMAL_MAJOR1 156 |
96 | #endif | 96 | #endif |
97 | 97 | ||
98 | #ifndef PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8 | 98 | #ifndef PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8 |
99 | #define PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8 0x2000 | 99 | #define PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8 0x2000 |
100 | #endif | 100 | #endif |
101 | 101 | ||
102 | #ifndef RIO_WINDOW_LEN | 102 | #ifndef RIO_WINDOW_LEN |
103 | #define RIO_WINDOW_LEN 0x10000 | 103 | #define RIO_WINDOW_LEN 0x10000 |
104 | #endif | 104 | #endif |
105 | 105 | ||
106 | 106 | ||
107 | /* Configurable options: | 107 | /* Configurable options: |
108 | (Don't be too sure that it'll work if you toggle them) */ | 108 | (Don't be too sure that it'll work if you toggle them) */ |
109 | 109 | ||
110 | /* Am I paranoid or not ? ;-) */ | 110 | /* Am I paranoid or not ? ;-) */ |
111 | #undef RIO_PARANOIA_CHECK | 111 | #undef RIO_PARANOIA_CHECK |
112 | 112 | ||
113 | 113 | ||
114 | /* 20 -> 2000 per second. The card should rate-limit interrupts at 1000 | 114 | /* 20 -> 2000 per second. The card should rate-limit interrupts at 1000 |
115 | Hz, but it is user configurable. I don't recommend going above 1000 | 115 | Hz, but it is user configurable. I don't recommend going above 1000 |
116 | Hz. The interrupt ratelimit might trigger if the interrupt is | 116 | Hz. The interrupt ratelimit might trigger if the interrupt is |
117 | shared with a very active other device. | 117 | shared with a very active other device. |
118 | undef this if you want to disable the check.... | 118 | undef this if you want to disable the check.... |
119 | */ | 119 | */ |
120 | #define IRQ_RATE_LIMIT 200 | 120 | #define IRQ_RATE_LIMIT 200 |
121 | 121 | ||
122 | 122 | ||
123 | /* These constants are derived from SCO Source */ | 123 | /* These constants are derived from SCO Source */ |
124 | static struct Conf | 124 | static struct Conf |
125 | RIOConf = { | 125 | RIOConf = { |
126 | /* locator */ "RIO Config here", | 126 | /* locator */ "RIO Config here", |
127 | /* startuptime */ HZ * 2, | 127 | /* startuptime */ HZ * 2, |
128 | /* how long to wait for card to run */ | 128 | /* how long to wait for card to run */ |
129 | /* slowcook */ 0, | 129 | /* slowcook */ 0, |
130 | /* TRUE -> always use line disc. */ | 130 | /* TRUE -> always use line disc. */ |
131 | /* intrpolltime */ 1, | 131 | /* intrpolltime */ 1, |
132 | /* The frequency of OUR polls */ | 132 | /* The frequency of OUR polls */ |
133 | /* breakinterval */ 25, | 133 | /* breakinterval */ 25, |
134 | /* x10 mS XXX: units seem to be 1ms not 10! -- REW */ | 134 | /* x10 mS XXX: units seem to be 1ms not 10! -- REW */ |
135 | /* timer */ 10, | 135 | /* timer */ 10, |
136 | /* mS */ | 136 | /* mS */ |
137 | /* RtaLoadBase */ 0x7000, | 137 | /* RtaLoadBase */ 0x7000, |
138 | /* HostLoadBase */ 0x7C00, | 138 | /* HostLoadBase */ 0x7C00, |
139 | /* XpHz */ 5, | 139 | /* XpHz */ 5, |
140 | /* number of Xprint hits per second */ | 140 | /* number of Xprint hits per second */ |
141 | /* XpCps */ 120, | 141 | /* XpCps */ 120, |
142 | /* Xprint characters per second */ | 142 | /* Xprint characters per second */ |
143 | /* XpOn */ "\033d#", | 143 | /* XpOn */ "\033d#", |
144 | /* start Xprint for a wyse 60 */ | 144 | /* start Xprint for a wyse 60 */ |
145 | /* XpOff */ "\024", | 145 | /* XpOff */ "\024", |
146 | /* end Xprint for a wyse 60 */ | 146 | /* end Xprint for a wyse 60 */ |
147 | /* MaxXpCps */ 2000, | 147 | /* MaxXpCps */ 2000, |
148 | /* highest Xprint speed */ | 148 | /* highest Xprint speed */ |
149 | /* MinXpCps */ 10, | 149 | /* MinXpCps */ 10, |
150 | /* slowest Xprint speed */ | 150 | /* slowest Xprint speed */ |
151 | /* SpinCmds */ 1, | 151 | /* SpinCmds */ 1, |
152 | /* non-zero for mega fast boots */ | 152 | /* non-zero for mega fast boots */ |
153 | /* First Addr */ 0x0A0000, | 153 | /* First Addr */ 0x0A0000, |
154 | /* First address to look at */ | 154 | /* First address to look at */ |
155 | /* Last Addr */ 0xFF0000, | 155 | /* Last Addr */ 0xFF0000, |
156 | /* Last address looked at */ | 156 | /* Last address looked at */ |
157 | /* BufferSize */ 1024, | 157 | /* BufferSize */ 1024, |
158 | /* Bytes per port of buffering */ | 158 | /* Bytes per port of buffering */ |
159 | /* LowWater */ 256, | 159 | /* LowWater */ 256, |
160 | /* how much data left before wakeup */ | 160 | /* how much data left before wakeup */ |
161 | /* LineLength */ 80, | 161 | /* LineLength */ 80, |
162 | /* how wide is the console? */ | 162 | /* how wide is the console? */ |
163 | /* CmdTimeout */ HZ, | 163 | /* CmdTimeout */ HZ, |
164 | /* how long a close command may take */ | 164 | /* how long a close command may take */ |
165 | }; | 165 | }; |
166 | 166 | ||
167 | 167 | ||
168 | 168 | ||
169 | 169 | ||
170 | /* Function prototypes */ | 170 | /* Function prototypes */ |
171 | 171 | ||
172 | static void rio_disable_tx_interrupts(void *ptr); | 172 | static void rio_disable_tx_interrupts(void *ptr); |
173 | static void rio_enable_tx_interrupts(void *ptr); | 173 | static void rio_enable_tx_interrupts(void *ptr); |
174 | static void rio_disable_rx_interrupts(void *ptr); | 174 | static void rio_disable_rx_interrupts(void *ptr); |
175 | static void rio_enable_rx_interrupts(void *ptr); | 175 | static void rio_enable_rx_interrupts(void *ptr); |
176 | static int rio_get_CD(void *ptr); | 176 | static int rio_get_CD(void *ptr); |
177 | static void rio_shutdown_port(void *ptr); | 177 | static void rio_shutdown_port(void *ptr); |
178 | static int rio_set_real_termios(void *ptr); | 178 | static int rio_set_real_termios(void *ptr); |
179 | static void rio_hungup(void *ptr); | 179 | static void rio_hungup(void *ptr); |
180 | static void rio_close(void *ptr); | 180 | static void rio_close(void *ptr); |
181 | static int rio_chars_in_buffer(void *ptr); | 181 | static int rio_chars_in_buffer(void *ptr); |
182 | static int rio_fw_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); | 182 | static int rio_fw_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); |
183 | static int rio_init_drivers(void); | 183 | static int rio_init_drivers(void); |
184 | 184 | ||
185 | static void my_hd(void *addr, int len); | 185 | static void my_hd(void *addr, int len); |
186 | 186 | ||
187 | static struct tty_driver *rio_driver, *rio_driver2; | 187 | static struct tty_driver *rio_driver, *rio_driver2; |
188 | 188 | ||
189 | /* The name "p" is a bit non-descript. But that's what the rio-lynxos | 189 | /* The name "p" is a bit non-descript. But that's what the rio-lynxos |
190 | sources use all over the place. */ | 190 | sources use all over the place. */ |
191 | struct rio_info *p; | 191 | struct rio_info *p; |
192 | 192 | ||
193 | int rio_debug; | 193 | int rio_debug; |
194 | 194 | ||
195 | 195 | ||
196 | /* You can have the driver poll your card. | 196 | /* You can have the driver poll your card. |
197 | - Set rio_poll to 1 to poll every timer tick (10ms on Intel). | 197 | - Set rio_poll to 1 to poll every timer tick (10ms on Intel). |
198 | This is used when the card cannot use an interrupt for some reason. | 198 | This is used when the card cannot use an interrupt for some reason. |
199 | */ | 199 | */ |
200 | static int rio_poll = 1; | 200 | static int rio_poll = 1; |
201 | 201 | ||
202 | 202 | ||
203 | /* These are the only open spaces in my computer. Yours may have more | 203 | /* These are the only open spaces in my computer. Yours may have more |
204 | or less.... */ | 204 | or less.... */ |
205 | static int rio_probe_addrs[] = { 0xc0000, 0xd0000, 0xe0000 }; | 205 | static int rio_probe_addrs[] = { 0xc0000, 0xd0000, 0xe0000 }; |
206 | 206 | ||
207 | #define NR_RIO_ADDRS ARRAY_SIZE(rio_probe_addrs) | 207 | #define NR_RIO_ADDRS ARRAY_SIZE(rio_probe_addrs) |
208 | 208 | ||
209 | 209 | ||
210 | /* Set the mask to all-ones. This alas, only supports 32 interrupts. | 210 | /* Set the mask to all-ones. This alas, only supports 32 interrupts. |
211 | Some architectures may need more. -- Changed to LONG to | 211 | Some architectures may need more. -- Changed to LONG to |
212 | support up to 64 bits on 64bit architectures. -- REW 20/06/99 */ | 212 | support up to 64 bits on 64bit architectures. -- REW 20/06/99 */ |
213 | static long rio_irqmask = -1; | 213 | static long rio_irqmask = -1; |
214 | 214 | ||
215 | MODULE_AUTHOR("Rogier Wolff <R.E.Wolff@bitwizard.nl>, Patrick van de Lageweg <patrick@bitwizard.nl>"); | 215 | MODULE_AUTHOR("Rogier Wolff <R.E.Wolff@bitwizard.nl>, Patrick van de Lageweg <patrick@bitwizard.nl>"); |
216 | MODULE_DESCRIPTION("RIO driver"); | 216 | MODULE_DESCRIPTION("RIO driver"); |
217 | MODULE_LICENSE("GPL"); | 217 | MODULE_LICENSE("GPL"); |
218 | module_param(rio_poll, int, 0); | 218 | module_param(rio_poll, int, 0); |
219 | module_param(rio_debug, int, 0644); | 219 | module_param(rio_debug, int, 0644); |
220 | module_param(rio_irqmask, long, 0); | 220 | module_param(rio_irqmask, long, 0); |
221 | 221 | ||
222 | static struct real_driver rio_real_driver = { | 222 | static struct real_driver rio_real_driver = { |
223 | rio_disable_tx_interrupts, | 223 | rio_disable_tx_interrupts, |
224 | rio_enable_tx_interrupts, | 224 | rio_enable_tx_interrupts, |
225 | rio_disable_rx_interrupts, | 225 | rio_disable_rx_interrupts, |
226 | rio_enable_rx_interrupts, | 226 | rio_enable_rx_interrupts, |
227 | rio_get_CD, | 227 | rio_get_CD, |
228 | rio_shutdown_port, | 228 | rio_shutdown_port, |
229 | rio_set_real_termios, | 229 | rio_set_real_termios, |
230 | rio_chars_in_buffer, | 230 | rio_chars_in_buffer, |
231 | rio_close, | 231 | rio_close, |
232 | rio_hungup, | 232 | rio_hungup, |
233 | NULL | 233 | NULL |
234 | }; | 234 | }; |
235 | 235 | ||
236 | /* | 236 | /* |
237 | * Firmware loader driver specific routines | 237 | * Firmware loader driver specific routines |
238 | * | 238 | * |
239 | */ | 239 | */ |
240 | 240 | ||
241 | static const struct file_operations rio_fw_fops = { | 241 | static const struct file_operations rio_fw_fops = { |
242 | .owner = THIS_MODULE, | 242 | .owner = THIS_MODULE, |
243 | .ioctl = rio_fw_ioctl, | 243 | .ioctl = rio_fw_ioctl, |
244 | }; | 244 | }; |
245 | 245 | ||
246 | static struct miscdevice rio_fw_device = { | 246 | static struct miscdevice rio_fw_device = { |
247 | RIOCTL_MISC_MINOR, "rioctl", &rio_fw_fops | 247 | RIOCTL_MISC_MINOR, "rioctl", &rio_fw_fops |
248 | }; | 248 | }; |
249 | 249 | ||
250 | 250 | ||
251 | 251 | ||
252 | 252 | ||
253 | 253 | ||
254 | #ifdef RIO_PARANOIA_CHECK | 254 | #ifdef RIO_PARANOIA_CHECK |
255 | 255 | ||
256 | /* This doesn't work. Who's paranoid around here? Not me! */ | 256 | /* This doesn't work. Who's paranoid around here? Not me! */ |
257 | 257 | ||
258 | static inline int rio_paranoia_check(struct rio_port const *port, char *name, const char *routine) | 258 | static inline int rio_paranoia_check(struct rio_port const *port, char *name, const char *routine) |
259 | { | 259 | { |
260 | 260 | ||
261 | static const char *badmagic = KERN_ERR "rio: Warning: bad rio port magic number for device %s in %s\n"; | 261 | static const char *badmagic = KERN_ERR "rio: Warning: bad rio port magic number for device %s in %s\n"; |
262 | static const char *badinfo = KERN_ERR "rio: Warning: null rio port for device %s in %s\n"; | 262 | static const char *badinfo = KERN_ERR "rio: Warning: null rio port for device %s in %s\n"; |
263 | 263 | ||
264 | if (!port) { | 264 | if (!port) { |
265 | printk(badinfo, name, routine); | 265 | printk(badinfo, name, routine); |
266 | return 1; | 266 | return 1; |
267 | } | 267 | } |
268 | if (port->magic != RIO_MAGIC) { | 268 | if (port->magic != RIO_MAGIC) { |
269 | printk(badmagic, name, routine); | 269 | printk(badmagic, name, routine); |
270 | return 1; | 270 | return 1; |
271 | } | 271 | } |
272 | 272 | ||
273 | return 0; | 273 | return 0; |
274 | } | 274 | } |
275 | #else | 275 | #else |
276 | #define rio_paranoia_check(a,b,c) 0 | 276 | #define rio_paranoia_check(a,b,c) 0 |
277 | #endif | 277 | #endif |
278 | 278 | ||
279 | 279 | ||
280 | #ifdef DEBUG | 280 | #ifdef DEBUG |
281 | static void my_hd(void *ad, int len) | 281 | static void my_hd(void *ad, int len) |
282 | { | 282 | { |
283 | int i, j, ch; | 283 | int i, j, ch; |
284 | unsigned char *addr = ad; | 284 | unsigned char *addr = ad; |
285 | 285 | ||
286 | for (i = 0; i < len; i += 16) { | 286 | for (i = 0; i < len; i += 16) { |
287 | rio_dprintk(RIO_DEBUG_PARAM, "%08lx ", (unsigned long) addr + i); | 287 | rio_dprintk(RIO_DEBUG_PARAM, "%08lx ", (unsigned long) addr + i); |
288 | for (j = 0; j < 16; j++) { | 288 | for (j = 0; j < 16; j++) { |
289 | rio_dprintk(RIO_DEBUG_PARAM, "%02x %s", addr[j + i], (j == 7) ? " " : ""); | 289 | rio_dprintk(RIO_DEBUG_PARAM, "%02x %s", addr[j + i], (j == 7) ? " " : ""); |
290 | } | 290 | } |
291 | for (j = 0; j < 16; j++) { | 291 | for (j = 0; j < 16; j++) { |
292 | ch = addr[j + i]; | 292 | ch = addr[j + i]; |
293 | rio_dprintk(RIO_DEBUG_PARAM, "%c", (ch < 0x20) ? '.' : ((ch > 0x7f) ? '.' : ch)); | 293 | rio_dprintk(RIO_DEBUG_PARAM, "%c", (ch < 0x20) ? '.' : ((ch > 0x7f) ? '.' : ch)); |
294 | } | 294 | } |
295 | rio_dprintk(RIO_DEBUG_PARAM, "\n"); | 295 | rio_dprintk(RIO_DEBUG_PARAM, "\n"); |
296 | } | 296 | } |
297 | } | 297 | } |
298 | #else | 298 | #else |
299 | #define my_hd(ad,len) do{/* nothing*/ } while (0) | 299 | #define my_hd(ad,len) do{/* nothing*/ } while (0) |
300 | #endif | 300 | #endif |
301 | 301 | ||
302 | 302 | ||
303 | /* Delay a number of jiffies, allowing a signal to interrupt */ | 303 | /* Delay a number of jiffies, allowing a signal to interrupt */ |
304 | int RIODelay(struct Port *PortP, int njiffies) | 304 | int RIODelay(struct Port *PortP, int njiffies) |
305 | { | 305 | { |
306 | func_enter(); | 306 | func_enter(); |
307 | 307 | ||
308 | rio_dprintk(RIO_DEBUG_DELAY, "delaying %d jiffies\n", njiffies); | 308 | rio_dprintk(RIO_DEBUG_DELAY, "delaying %d jiffies\n", njiffies); |
309 | msleep_interruptible(jiffies_to_msecs(njiffies)); | 309 | msleep_interruptible(jiffies_to_msecs(njiffies)); |
310 | func_exit(); | 310 | func_exit(); |
311 | 311 | ||
312 | if (signal_pending(current)) | 312 | if (signal_pending(current)) |
313 | return RIO_FAIL; | 313 | return RIO_FAIL; |
314 | else | 314 | else |
315 | return !RIO_FAIL; | 315 | return !RIO_FAIL; |
316 | } | 316 | } |
317 | 317 | ||
318 | 318 | ||
319 | /* Delay a number of jiffies, disallowing a signal to interrupt */ | 319 | /* Delay a number of jiffies, disallowing a signal to interrupt */ |
320 | int RIODelay_ni(struct Port *PortP, int njiffies) | 320 | int RIODelay_ni(struct Port *PortP, int njiffies) |
321 | { | 321 | { |
322 | func_enter(); | 322 | func_enter(); |
323 | 323 | ||
324 | rio_dprintk(RIO_DEBUG_DELAY, "delaying %d jiffies (ni)\n", njiffies); | 324 | rio_dprintk(RIO_DEBUG_DELAY, "delaying %d jiffies (ni)\n", njiffies); |
325 | msleep(jiffies_to_msecs(njiffies)); | 325 | msleep(jiffies_to_msecs(njiffies)); |
326 | func_exit(); | 326 | func_exit(); |
327 | return !RIO_FAIL; | 327 | return !RIO_FAIL; |
328 | } | 328 | } |
329 | 329 | ||
330 | void rio_copy_to_card(void *from, void __iomem *to, int len) | 330 | void rio_copy_to_card(void *from, void __iomem *to, int len) |
331 | { | 331 | { |
332 | rio_copy_toio(to, from, len); | 332 | rio_copy_toio(to, from, len); |
333 | } | 333 | } |
334 | 334 | ||
335 | int rio_minor(struct tty_struct *tty) | 335 | int rio_minor(struct tty_struct *tty) |
336 | { | 336 | { |
337 | return tty->index + (tty->driver == rio_driver) ? 0 : 256; | 337 | return tty->index + (tty->driver == rio_driver) ? 0 : 256; |
338 | } | 338 | } |
339 | 339 | ||
340 | static int rio_set_real_termios(void *ptr) | 340 | static int rio_set_real_termios(void *ptr) |
341 | { | 341 | { |
342 | return RIOParam((struct Port *) ptr, RIOC_CONFIG, 1, 1); | 342 | return RIOParam((struct Port *) ptr, RIOC_CONFIG, 1, 1); |
343 | } | 343 | } |
344 | 344 | ||
345 | 345 | ||
346 | static void rio_reset_interrupt(struct Host *HostP) | 346 | static void rio_reset_interrupt(struct Host *HostP) |
347 | { | 347 | { |
348 | func_enter(); | 348 | func_enter(); |
349 | 349 | ||
350 | switch (HostP->Type) { | 350 | switch (HostP->Type) { |
351 | case RIO_AT: | 351 | case RIO_AT: |
352 | case RIO_MCA: | 352 | case RIO_MCA: |
353 | case RIO_PCI: | 353 | case RIO_PCI: |
354 | writeb(0xFF, &HostP->ResetInt); | 354 | writeb(0xFF, &HostP->ResetInt); |
355 | } | 355 | } |
356 | 356 | ||
357 | func_exit(); | 357 | func_exit(); |
358 | } | 358 | } |
359 | 359 | ||
360 | 360 | ||
361 | static irqreturn_t rio_interrupt(int irq, void *ptr) | 361 | static irqreturn_t rio_interrupt(int irq, void *ptr) |
362 | { | 362 | { |
363 | struct Host *HostP; | 363 | struct Host *HostP; |
364 | func_enter(); | 364 | func_enter(); |
365 | 365 | ||
366 | HostP = ptr; /* &p->RIOHosts[(long)ptr]; */ | 366 | HostP = ptr; /* &p->RIOHosts[(long)ptr]; */ |
367 | rio_dprintk(RIO_DEBUG_IFLOW, "rio: enter rio_interrupt (%d/%d)\n", irq, HostP->Ivec); | 367 | rio_dprintk(RIO_DEBUG_IFLOW, "rio: enter rio_interrupt (%d/%d)\n", irq, HostP->Ivec); |
368 | 368 | ||
369 | /* AAargh! The order in which to do these things is essential and | 369 | /* AAargh! The order in which to do these things is essential and |
370 | not trivial. | 370 | not trivial. |
371 | 371 | ||
372 | - hardware twiddling goes before "recursive". Otherwise when we | 372 | - hardware twiddling goes before "recursive". Otherwise when we |
373 | poll the card, and a recursive interrupt happens, we won't | 373 | poll the card, and a recursive interrupt happens, we won't |
374 | ack the card, so it might keep on interrupting us. (especially | 374 | ack the card, so it might keep on interrupting us. (especially |
375 | level sensitive interrupt systems like PCI). | 375 | level sensitive interrupt systems like PCI). |
376 | 376 | ||
377 | - Rate limit goes before hardware twiddling. Otherwise we won't | 377 | - Rate limit goes before hardware twiddling. Otherwise we won't |
378 | catch a card that has gone bonkers. | 378 | catch a card that has gone bonkers. |
379 | 379 | ||
380 | - The "initialized" test goes after the hardware twiddling. Otherwise | 380 | - The "initialized" test goes after the hardware twiddling. Otherwise |
381 | the card will stick us in the interrupt routine again. | 381 | the card will stick us in the interrupt routine again. |
382 | 382 | ||
383 | - The initialized test goes before recursive. | 383 | - The initialized test goes before recursive. |
384 | */ | 384 | */ |
385 | 385 | ||
386 | rio_dprintk(RIO_DEBUG_IFLOW, "rio: We've have noticed the interrupt\n"); | 386 | rio_dprintk(RIO_DEBUG_IFLOW, "rio: We've have noticed the interrupt\n"); |
387 | if (HostP->Ivec == irq) { | 387 | if (HostP->Ivec == irq) { |
388 | /* Tell the card we've noticed the interrupt. */ | 388 | /* Tell the card we've noticed the interrupt. */ |
389 | rio_reset_interrupt(HostP); | 389 | rio_reset_interrupt(HostP); |
390 | } | 390 | } |
391 | 391 | ||
392 | if ((HostP->Flags & RUN_STATE) != RC_RUNNING) | 392 | if ((HostP->Flags & RUN_STATE) != RC_RUNNING) |
393 | return IRQ_HANDLED; | 393 | return IRQ_HANDLED; |
394 | 394 | ||
395 | if (test_and_set_bit(RIO_BOARD_INTR_LOCK, &HostP->locks)) { | 395 | if (test_and_set_bit(RIO_BOARD_INTR_LOCK, &HostP->locks)) { |
396 | printk(KERN_ERR "Recursive interrupt! (host %p/irq%d)\n", ptr, HostP->Ivec); | 396 | printk(KERN_ERR "Recursive interrupt! (host %p/irq%d)\n", ptr, HostP->Ivec); |
397 | return IRQ_HANDLED; | 397 | return IRQ_HANDLED; |
398 | } | 398 | } |
399 | 399 | ||
400 | RIOServiceHost(p, HostP); | 400 | RIOServiceHost(p, HostP); |
401 | 401 | ||
402 | rio_dprintk(RIO_DEBUG_IFLOW, "riointr() doing host %p type %d\n", ptr, HostP->Type); | 402 | rio_dprintk(RIO_DEBUG_IFLOW, "riointr() doing host %p type %d\n", ptr, HostP->Type); |
403 | 403 | ||
404 | clear_bit(RIO_BOARD_INTR_LOCK, &HostP->locks); | 404 | clear_bit(RIO_BOARD_INTR_LOCK, &HostP->locks); |
405 | rio_dprintk(RIO_DEBUG_IFLOW, "rio: exit rio_interrupt (%d/%d)\n", irq, HostP->Ivec); | 405 | rio_dprintk(RIO_DEBUG_IFLOW, "rio: exit rio_interrupt (%d/%d)\n", irq, HostP->Ivec); |
406 | func_exit(); | 406 | func_exit(); |
407 | return IRQ_HANDLED; | 407 | return IRQ_HANDLED; |
408 | } | 408 | } |
409 | 409 | ||
410 | 410 | ||
411 | static void rio_pollfunc(unsigned long data) | 411 | static void rio_pollfunc(unsigned long data) |
412 | { | 412 | { |
413 | func_enter(); | 413 | func_enter(); |
414 | 414 | ||
415 | rio_interrupt(0, &p->RIOHosts[data]); | 415 | rio_interrupt(0, &p->RIOHosts[data]); |
416 | mod_timer(&p->RIOHosts[data].timer, jiffies + rio_poll); | 416 | mod_timer(&p->RIOHosts[data].timer, jiffies + rio_poll); |
417 | 417 | ||
418 | func_exit(); | 418 | func_exit(); |
419 | } | 419 | } |
420 | 420 | ||
421 | 421 | ||
422 | /* ********************************************************************** * | 422 | /* ********************************************************************** * |
423 | * Here are the routines that actually * | 423 | * Here are the routines that actually * |
424 | * interface with the generic_serial driver * | 424 | * interface with the generic_serial driver * |
425 | * ********************************************************************** */ | 425 | * ********************************************************************** */ |
426 | 426 | ||
427 | /* Ehhm. I don't know how to fiddle with interrupts on the Specialix | 427 | /* Ehhm. I don't know how to fiddle with interrupts on the Specialix |
428 | cards. .... Hmm. Ok I figured it out. You don't. -- REW */ | 428 | cards. .... Hmm. Ok I figured it out. You don't. -- REW */ |
429 | 429 | ||
430 | static void rio_disable_tx_interrupts(void *ptr) | 430 | static void rio_disable_tx_interrupts(void *ptr) |
431 | { | 431 | { |
432 | func_enter(); | 432 | func_enter(); |
433 | 433 | ||
434 | /* port->gs.flags &= ~GS_TX_INTEN; */ | 434 | /* port->gs.port.flags &= ~GS_TX_INTEN; */ |
435 | 435 | ||
436 | func_exit(); | 436 | func_exit(); |
437 | } | 437 | } |
438 | 438 | ||
439 | 439 | ||
440 | static void rio_enable_tx_interrupts(void *ptr) | 440 | static void rio_enable_tx_interrupts(void *ptr) |
441 | { | 441 | { |
442 | struct Port *PortP = ptr; | 442 | struct Port *PortP = ptr; |
443 | /* int hn; */ | 443 | /* int hn; */ |
444 | 444 | ||
445 | func_enter(); | 445 | func_enter(); |
446 | 446 | ||
447 | /* hn = PortP->HostP - p->RIOHosts; | 447 | /* hn = PortP->HostP - p->RIOHosts; |
448 | 448 | ||
449 | rio_dprintk (RIO_DEBUG_TTY, "Pushing host %d\n", hn); | 449 | rio_dprintk (RIO_DEBUG_TTY, "Pushing host %d\n", hn); |
450 | rio_interrupt (-1,(void *) hn, NULL); */ | 450 | rio_interrupt (-1,(void *) hn, NULL); */ |
451 | 451 | ||
452 | RIOTxEnable((char *) PortP); | 452 | RIOTxEnable((char *) PortP); |
453 | 453 | ||
454 | /* | 454 | /* |
455 | * In general we cannot count on "tx empty" interrupts, although | 455 | * In general we cannot count on "tx empty" interrupts, although |
456 | * the interrupt routine seems to be able to tell the difference. | 456 | * the interrupt routine seems to be able to tell the difference. |
457 | */ | 457 | */ |
458 | PortP->gs.flags &= ~GS_TX_INTEN; | 458 | PortP->gs.port.flags &= ~GS_TX_INTEN; |
459 | 459 | ||
460 | func_exit(); | 460 | func_exit(); |
461 | } | 461 | } |
462 | 462 | ||
463 | 463 | ||
464 | static void rio_disable_rx_interrupts(void *ptr) | 464 | static void rio_disable_rx_interrupts(void *ptr) |
465 | { | 465 | { |
466 | func_enter(); | 466 | func_enter(); |
467 | func_exit(); | 467 | func_exit(); |
468 | } | 468 | } |
469 | 469 | ||
470 | static void rio_enable_rx_interrupts(void *ptr) | 470 | static void rio_enable_rx_interrupts(void *ptr) |
471 | { | 471 | { |
472 | /* struct rio_port *port = ptr; */ | 472 | /* struct rio_port *port = ptr; */ |
473 | func_enter(); | 473 | func_enter(); |
474 | func_exit(); | 474 | func_exit(); |
475 | } | 475 | } |
476 | 476 | ||
477 | 477 | ||
478 | /* Jeez. Isn't this simple? */ | 478 | /* Jeez. Isn't this simple? */ |
479 | static int rio_get_CD(void *ptr) | 479 | static int rio_get_CD(void *ptr) |
480 | { | 480 | { |
481 | struct Port *PortP = ptr; | 481 | struct Port *PortP = ptr; |
482 | int rv; | 482 | int rv; |
483 | 483 | ||
484 | func_enter(); | 484 | func_enter(); |
485 | rv = (PortP->ModemState & RIOC_MSVR1_CD) != 0; | 485 | rv = (PortP->ModemState & RIOC_MSVR1_CD) != 0; |
486 | 486 | ||
487 | rio_dprintk(RIO_DEBUG_INIT, "Getting CD status: %d\n", rv); | 487 | rio_dprintk(RIO_DEBUG_INIT, "Getting CD status: %d\n", rv); |
488 | 488 | ||
489 | func_exit(); | 489 | func_exit(); |
490 | return rv; | 490 | return rv; |
491 | } | 491 | } |
492 | 492 | ||
493 | 493 | ||
494 | /* Jeez. Isn't this simple? Actually, we can sync with the actual port | 494 | /* Jeez. Isn't this simple? Actually, we can sync with the actual port |
495 | by just pushing stuff into the queue going to the port... */ | 495 | by just pushing stuff into the queue going to the port... */ |
496 | static int rio_chars_in_buffer(void *ptr) | 496 | static int rio_chars_in_buffer(void *ptr) |
497 | { | 497 | { |
498 | func_enter(); | 498 | func_enter(); |
499 | 499 | ||
500 | func_exit(); | 500 | func_exit(); |
501 | return 0; | 501 | return 0; |
502 | } | 502 | } |
503 | 503 | ||
504 | 504 | ||
505 | /* Nothing special here... */ | 505 | /* Nothing special here... */ |
506 | static void rio_shutdown_port(void *ptr) | 506 | static void rio_shutdown_port(void *ptr) |
507 | { | 507 | { |
508 | struct Port *PortP; | 508 | struct Port *PortP; |
509 | 509 | ||
510 | func_enter(); | 510 | func_enter(); |
511 | 511 | ||
512 | PortP = (struct Port *) ptr; | 512 | PortP = (struct Port *) ptr; |
513 | PortP->gs.tty = NULL; | 513 | PortP->gs.port.tty = NULL; |
514 | func_exit(); | 514 | func_exit(); |
515 | } | 515 | } |
516 | 516 | ||
517 | 517 | ||
518 | /* I haven't the foggiest why the decrement use count has to happen | 518 | /* I haven't the foggiest why the decrement use count has to happen |
519 | here. The whole linux serial drivers stuff needs to be redesigned. | 519 | here. The whole linux serial drivers stuff needs to be redesigned. |
520 | My guess is that this is a hack to minimize the impact of a bug | 520 | My guess is that this is a hack to minimize the impact of a bug |
521 | elsewhere. Thinking about it some more. (try it sometime) Try | 521 | elsewhere. Thinking about it some more. (try it sometime) Try |
522 | running minicom on a serial port that is driven by a modularized | 522 | running minicom on a serial port that is driven by a modularized |
523 | driver. Have the modem hangup. Then remove the driver module. Then | 523 | driver. Have the modem hangup. Then remove the driver module. Then |
524 | exit minicom. I expect an "oops". -- REW */ | 524 | exit minicom. I expect an "oops". -- REW */ |
525 | static void rio_hungup(void *ptr) | 525 | static void rio_hungup(void *ptr) |
526 | { | 526 | { |
527 | struct Port *PortP; | 527 | struct Port *PortP; |
528 | 528 | ||
529 | func_enter(); | 529 | func_enter(); |
530 | 530 | ||
531 | PortP = (struct Port *) ptr; | 531 | PortP = (struct Port *) ptr; |
532 | PortP->gs.tty = NULL; | 532 | PortP->gs.port.tty = NULL; |
533 | 533 | ||
534 | func_exit(); | 534 | func_exit(); |
535 | } | 535 | } |
536 | 536 | ||
537 | 537 | ||
538 | /* The standard serial_close would become shorter if you'd wrap it like | 538 | /* The standard serial_close would become shorter if you'd wrap it like |
539 | this. | 539 | this. |
540 | rs_close (...){save_flags;cli;real_close();dec_use_count;restore_flags;} | 540 | rs_close (...){save_flags;cli;real_close();dec_use_count;restore_flags;} |
541 | */ | 541 | */ |
542 | static void rio_close(void *ptr) | 542 | static void rio_close(void *ptr) |
543 | { | 543 | { |
544 | struct Port *PortP; | 544 | struct Port *PortP; |
545 | 545 | ||
546 | func_enter(); | 546 | func_enter(); |
547 | 547 | ||
548 | PortP = (struct Port *) ptr; | 548 | PortP = (struct Port *) ptr; |
549 | 549 | ||
550 | riotclose(ptr); | 550 | riotclose(ptr); |
551 | 551 | ||
552 | if (PortP->gs.count) { | 552 | if (PortP->gs.port.count) { |
553 | printk(KERN_ERR "WARNING port count:%d\n", PortP->gs.count); | 553 | printk(KERN_ERR "WARNING port count:%d\n", PortP->gs.port.count); |
554 | PortP->gs.count = 0; | 554 | PortP->gs.port.count = 0; |
555 | } | 555 | } |
556 | 556 | ||
557 | PortP->gs.tty = NULL; | 557 | PortP->gs.port.tty = NULL; |
558 | func_exit(); | 558 | func_exit(); |
559 | } | 559 | } |
560 | 560 | ||
561 | 561 | ||
562 | 562 | ||
563 | static int rio_fw_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) | 563 | static int rio_fw_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) |
564 | { | 564 | { |
565 | int rc = 0; | 565 | int rc = 0; |
566 | func_enter(); | 566 | func_enter(); |
567 | 567 | ||
568 | /* The "dev" argument isn't used. */ | 568 | /* The "dev" argument isn't used. */ |
569 | rc = riocontrol(p, 0, cmd, arg, capable(CAP_SYS_ADMIN)); | 569 | rc = riocontrol(p, 0, cmd, arg, capable(CAP_SYS_ADMIN)); |
570 | 570 | ||
571 | func_exit(); | 571 | func_exit(); |
572 | return rc; | 572 | return rc; |
573 | } | 573 | } |
574 | 574 | ||
575 | extern int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg); | 575 | extern int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg); |
576 | 576 | ||
577 | static int rio_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, unsigned long arg) | 577 | static int rio_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, unsigned long arg) |
578 | { | 578 | { |
579 | void __user *argp = (void __user *)arg; | 579 | void __user *argp = (void __user *)arg; |
580 | int rc; | 580 | int rc; |
581 | struct Port *PortP; | 581 | struct Port *PortP; |
582 | int ival; | 582 | int ival; |
583 | 583 | ||
584 | func_enter(); | 584 | func_enter(); |
585 | 585 | ||
586 | PortP = (struct Port *) tty->driver_data; | 586 | PortP = (struct Port *) tty->driver_data; |
587 | 587 | ||
588 | rc = 0; | 588 | rc = 0; |
589 | switch (cmd) { | 589 | switch (cmd) { |
590 | case TIOCSSOFTCAR: | 590 | case TIOCSSOFTCAR: |
591 | if ((rc = get_user(ival, (unsigned __user *) argp)) == 0) { | 591 | if ((rc = get_user(ival, (unsigned __user *) argp)) == 0) { |
592 | tty->termios->c_cflag = (tty->termios->c_cflag & ~CLOCAL) | (ival ? CLOCAL : 0); | 592 | tty->termios->c_cflag = (tty->termios->c_cflag & ~CLOCAL) | (ival ? CLOCAL : 0); |
593 | } | 593 | } |
594 | break; | 594 | break; |
595 | case TIOCGSERIAL: | 595 | case TIOCGSERIAL: |
596 | rc = -EFAULT; | 596 | rc = -EFAULT; |
597 | if (access_ok(VERIFY_WRITE, argp, sizeof(struct serial_struct))) | 597 | if (access_ok(VERIFY_WRITE, argp, sizeof(struct serial_struct))) |
598 | rc = gs_getserial(&PortP->gs, argp); | 598 | rc = gs_getserial(&PortP->gs, argp); |
599 | break; | 599 | break; |
600 | case TCSBRK: | 600 | case TCSBRK: |
601 | if (PortP->State & RIO_DELETED) { | 601 | if (PortP->State & RIO_DELETED) { |
602 | rio_dprintk(RIO_DEBUG_TTY, "BREAK on deleted RTA\n"); | 602 | rio_dprintk(RIO_DEBUG_TTY, "BREAK on deleted RTA\n"); |
603 | rc = -EIO; | 603 | rc = -EIO; |
604 | } else { | 604 | } else { |
605 | if (RIOShortCommand(p, PortP, RIOC_SBREAK, 2, 250) == | 605 | if (RIOShortCommand(p, PortP, RIOC_SBREAK, 2, 250) == |
606 | RIO_FAIL) { | 606 | RIO_FAIL) { |
607 | rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n"); | 607 | rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n"); |
608 | rc = -EIO; | 608 | rc = -EIO; |
609 | } | 609 | } |
610 | } | 610 | } |
611 | break; | 611 | break; |
612 | case TCSBRKP: | 612 | case TCSBRKP: |
613 | if (PortP->State & RIO_DELETED) { | 613 | if (PortP->State & RIO_DELETED) { |
614 | rio_dprintk(RIO_DEBUG_TTY, "BREAK on deleted RTA\n"); | 614 | rio_dprintk(RIO_DEBUG_TTY, "BREAK on deleted RTA\n"); |
615 | rc = -EIO; | 615 | rc = -EIO; |
616 | } else { | 616 | } else { |
617 | int l; | 617 | int l; |
618 | l = arg ? arg * 100 : 250; | 618 | l = arg ? arg * 100 : 250; |
619 | if (l > 255) | 619 | if (l > 255) |
620 | l = 255; | 620 | l = 255; |
621 | if (RIOShortCommand(p, PortP, RIOC_SBREAK, 2, | 621 | if (RIOShortCommand(p, PortP, RIOC_SBREAK, 2, |
622 | arg ? arg * 100 : 250) == RIO_FAIL) { | 622 | arg ? arg * 100 : 250) == RIO_FAIL) { |
623 | rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n"); | 623 | rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n"); |
624 | rc = -EIO; | 624 | rc = -EIO; |
625 | } | 625 | } |
626 | } | 626 | } |
627 | break; | 627 | break; |
628 | case TIOCSSERIAL: | 628 | case TIOCSSERIAL: |
629 | rc = -EFAULT; | 629 | rc = -EFAULT; |
630 | if (access_ok(VERIFY_READ, argp, sizeof(struct serial_struct))) | 630 | if (access_ok(VERIFY_READ, argp, sizeof(struct serial_struct))) |
631 | rc = gs_setserial(&PortP->gs, argp); | 631 | rc = gs_setserial(&PortP->gs, argp); |
632 | break; | 632 | break; |
633 | default: | 633 | default: |
634 | rc = -ENOIOCTLCMD; | 634 | rc = -ENOIOCTLCMD; |
635 | break; | 635 | break; |
636 | } | 636 | } |
637 | func_exit(); | 637 | func_exit(); |
638 | return rc; | 638 | return rc; |
639 | } | 639 | } |
640 | 640 | ||
641 | 641 | ||
642 | /* The throttle/unthrottle scheme for the Specialix card is different | 642 | /* The throttle/unthrottle scheme for the Specialix card is different |
643 | * from other drivers and deserves some explanation. | 643 | * from other drivers and deserves some explanation. |
644 | * The Specialix hardware takes care of XON/XOFF | 644 | * The Specialix hardware takes care of XON/XOFF |
645 | * and CTS/RTS flow control itself. This means that all we have to | 645 | * and CTS/RTS flow control itself. This means that all we have to |
646 | * do when signalled by the upper tty layer to throttle/unthrottle is | 646 | * do when signalled by the upper tty layer to throttle/unthrottle is |
647 | * to make a note of it here. When we come to read characters from the | 647 | * to make a note of it here. When we come to read characters from the |
648 | * rx buffers on the card (rio_receive_chars()) we look to see if the | 648 | * rx buffers on the card (rio_receive_chars()) we look to see if the |
649 | * upper layer can accept more (as noted here in rio_rx_throt[]). | 649 | * upper layer can accept more (as noted here in rio_rx_throt[]). |
650 | * If it can't we simply don't remove chars from the cards buffer. | 650 | * If it can't we simply don't remove chars from the cards buffer. |
651 | * When the tty layer can accept chars, we again note that here and when | 651 | * When the tty layer can accept chars, we again note that here and when |
652 | * rio_receive_chars() is called it will remove them from the cards buffer. | 652 | * rio_receive_chars() is called it will remove them from the cards buffer. |
653 | * The card will notice that a ports buffer has drained below some low | 653 | * The card will notice that a ports buffer has drained below some low |
654 | * water mark and will unflow control the line itself, using whatever | 654 | * water mark and will unflow control the line itself, using whatever |
655 | * flow control scheme is in use for that port. -- Simon Allen | 655 | * flow control scheme is in use for that port. -- Simon Allen |
656 | */ | 656 | */ |
657 | 657 | ||
658 | static void rio_throttle(struct tty_struct *tty) | 658 | static void rio_throttle(struct tty_struct *tty) |
659 | { | 659 | { |
660 | struct Port *port = (struct Port *) tty->driver_data; | 660 | struct Port *port = (struct Port *) tty->driver_data; |
661 | 661 | ||
662 | func_enter(); | 662 | func_enter(); |
663 | /* If the port is using any type of input flow | 663 | /* If the port is using any type of input flow |
664 | * control then throttle the port. | 664 | * control then throttle the port. |
665 | */ | 665 | */ |
666 | 666 | ||
667 | if ((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty))) { | 667 | if ((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty))) { |
668 | port->State |= RIO_THROTTLE_RX; | 668 | port->State |= RIO_THROTTLE_RX; |
669 | } | 669 | } |
670 | 670 | ||
671 | func_exit(); | 671 | func_exit(); |
672 | } | 672 | } |
673 | 673 | ||
674 | 674 | ||
675 | static void rio_unthrottle(struct tty_struct *tty) | 675 | static void rio_unthrottle(struct tty_struct *tty) |
676 | { | 676 | { |
677 | struct Port *port = (struct Port *) tty->driver_data; | 677 | struct Port *port = (struct Port *) tty->driver_data; |
678 | 678 | ||
679 | func_enter(); | 679 | func_enter(); |
680 | /* Always unthrottle even if flow control is not enabled on | 680 | /* Always unthrottle even if flow control is not enabled on |
681 | * this port in case we disabled flow control while the port | 681 | * this port in case we disabled flow control while the port |
682 | * was throttled | 682 | * was throttled |
683 | */ | 683 | */ |
684 | 684 | ||
685 | port->State &= ~RIO_THROTTLE_RX; | 685 | port->State &= ~RIO_THROTTLE_RX; |
686 | 686 | ||
687 | func_exit(); | 687 | func_exit(); |
688 | return; | 688 | return; |
689 | } | 689 | } |
690 | 690 | ||
691 | 691 | ||
692 | 692 | ||
693 | 693 | ||
694 | 694 | ||
695 | /* ********************************************************************** * | 695 | /* ********************************************************************** * |
696 | * Here are the initialization routines. * | 696 | * Here are the initialization routines. * |
697 | * ********************************************************************** */ | 697 | * ********************************************************************** */ |
698 | 698 | ||
699 | 699 | ||
700 | static struct vpd_prom *get_VPD_PROM(struct Host *hp) | 700 | static struct vpd_prom *get_VPD_PROM(struct Host *hp) |
701 | { | 701 | { |
702 | static struct vpd_prom vpdp; | 702 | static struct vpd_prom vpdp; |
703 | char *p; | 703 | char *p; |
704 | int i; | 704 | int i; |
705 | 705 | ||
706 | func_enter(); | 706 | func_enter(); |
707 | rio_dprintk(RIO_DEBUG_PROBE, "Going to verify vpd prom at %p.\n", hp->Caddr + RIO_VPD_ROM); | 707 | rio_dprintk(RIO_DEBUG_PROBE, "Going to verify vpd prom at %p.\n", hp->Caddr + RIO_VPD_ROM); |
708 | 708 | ||
709 | p = (char *) &vpdp; | 709 | p = (char *) &vpdp; |
710 | for (i = 0; i < sizeof(struct vpd_prom); i++) | 710 | for (i = 0; i < sizeof(struct vpd_prom); i++) |
711 | *p++ = readb(hp->Caddr + RIO_VPD_ROM + i * 2); | 711 | *p++ = readb(hp->Caddr + RIO_VPD_ROM + i * 2); |
712 | /* read_rio_byte (hp, RIO_VPD_ROM + i*2); */ | 712 | /* read_rio_byte (hp, RIO_VPD_ROM + i*2); */ |
713 | 713 | ||
714 | /* Terminate the identifier string. | 714 | /* Terminate the identifier string. |
715 | *** requires one extra byte in struct vpd_prom *** */ | 715 | *** requires one extra byte in struct vpd_prom *** */ |
716 | *p++ = 0; | 716 | *p++ = 0; |
717 | 717 | ||
718 | if (rio_debug & RIO_DEBUG_PROBE) | 718 | if (rio_debug & RIO_DEBUG_PROBE) |
719 | my_hd((char *) &vpdp, 0x20); | 719 | my_hd((char *) &vpdp, 0x20); |
720 | 720 | ||
721 | func_exit(); | 721 | func_exit(); |
722 | 722 | ||
723 | return &vpdp; | 723 | return &vpdp; |
724 | } | 724 | } |
725 | 725 | ||
726 | static const struct tty_operations rio_ops = { | 726 | static const struct tty_operations rio_ops = { |
727 | .open = riotopen, | 727 | .open = riotopen, |
728 | .close = gs_close, | 728 | .close = gs_close, |
729 | .write = gs_write, | 729 | .write = gs_write, |
730 | .put_char = gs_put_char, | 730 | .put_char = gs_put_char, |
731 | .flush_chars = gs_flush_chars, | 731 | .flush_chars = gs_flush_chars, |
732 | .write_room = gs_write_room, | 732 | .write_room = gs_write_room, |
733 | .chars_in_buffer = gs_chars_in_buffer, | 733 | .chars_in_buffer = gs_chars_in_buffer, |
734 | .flush_buffer = gs_flush_buffer, | 734 | .flush_buffer = gs_flush_buffer, |
735 | .ioctl = rio_ioctl, | 735 | .ioctl = rio_ioctl, |
736 | .throttle = rio_throttle, | 736 | .throttle = rio_throttle, |
737 | .unthrottle = rio_unthrottle, | 737 | .unthrottle = rio_unthrottle, |
738 | .set_termios = gs_set_termios, | 738 | .set_termios = gs_set_termios, |
739 | .stop = gs_stop, | 739 | .stop = gs_stop, |
740 | .start = gs_start, | 740 | .start = gs_start, |
741 | .hangup = gs_hangup, | 741 | .hangup = gs_hangup, |
742 | }; | 742 | }; |
743 | 743 | ||
744 | static int rio_init_drivers(void) | 744 | static int rio_init_drivers(void) |
745 | { | 745 | { |
746 | int error = -ENOMEM; | 746 | int error = -ENOMEM; |
747 | 747 | ||
748 | rio_driver = alloc_tty_driver(256); | 748 | rio_driver = alloc_tty_driver(256); |
749 | if (!rio_driver) | 749 | if (!rio_driver) |
750 | goto out; | 750 | goto out; |
751 | rio_driver2 = alloc_tty_driver(256); | 751 | rio_driver2 = alloc_tty_driver(256); |
752 | if (!rio_driver2) | 752 | if (!rio_driver2) |
753 | goto out1; | 753 | goto out1; |
754 | 754 | ||
755 | func_enter(); | 755 | func_enter(); |
756 | 756 | ||
757 | rio_driver->owner = THIS_MODULE; | 757 | rio_driver->owner = THIS_MODULE; |
758 | rio_driver->driver_name = "specialix_rio"; | 758 | rio_driver->driver_name = "specialix_rio"; |
759 | rio_driver->name = "ttySR"; | 759 | rio_driver->name = "ttySR"; |
760 | rio_driver->major = RIO_NORMAL_MAJOR0; | 760 | rio_driver->major = RIO_NORMAL_MAJOR0; |
761 | rio_driver->type = TTY_DRIVER_TYPE_SERIAL; | 761 | rio_driver->type = TTY_DRIVER_TYPE_SERIAL; |
762 | rio_driver->subtype = SERIAL_TYPE_NORMAL; | 762 | rio_driver->subtype = SERIAL_TYPE_NORMAL; |
763 | rio_driver->init_termios = tty_std_termios; | 763 | rio_driver->init_termios = tty_std_termios; |
764 | rio_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; | 764 | rio_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; |
765 | rio_driver->flags = TTY_DRIVER_REAL_RAW; | 765 | rio_driver->flags = TTY_DRIVER_REAL_RAW; |
766 | tty_set_operations(rio_driver, &rio_ops); | 766 | tty_set_operations(rio_driver, &rio_ops); |
767 | 767 | ||
768 | rio_driver2->owner = THIS_MODULE; | 768 | rio_driver2->owner = THIS_MODULE; |
769 | rio_driver2->driver_name = "specialix_rio"; | 769 | rio_driver2->driver_name = "specialix_rio"; |
770 | rio_driver2->name = "ttySR"; | 770 | rio_driver2->name = "ttySR"; |
771 | rio_driver2->major = RIO_NORMAL_MAJOR1; | 771 | rio_driver2->major = RIO_NORMAL_MAJOR1; |
772 | rio_driver2->type = TTY_DRIVER_TYPE_SERIAL; | 772 | rio_driver2->type = TTY_DRIVER_TYPE_SERIAL; |
773 | rio_driver2->subtype = SERIAL_TYPE_NORMAL; | 773 | rio_driver2->subtype = SERIAL_TYPE_NORMAL; |
774 | rio_driver2->init_termios = tty_std_termios; | 774 | rio_driver2->init_termios = tty_std_termios; |
775 | rio_driver2->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; | 775 | rio_driver2->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; |
776 | rio_driver2->flags = TTY_DRIVER_REAL_RAW; | 776 | rio_driver2->flags = TTY_DRIVER_REAL_RAW; |
777 | tty_set_operations(rio_driver2, &rio_ops); | 777 | tty_set_operations(rio_driver2, &rio_ops); |
778 | 778 | ||
779 | rio_dprintk(RIO_DEBUG_INIT, "set_termios = %p\n", gs_set_termios); | 779 | rio_dprintk(RIO_DEBUG_INIT, "set_termios = %p\n", gs_set_termios); |
780 | 780 | ||
781 | if ((error = tty_register_driver(rio_driver))) | 781 | if ((error = tty_register_driver(rio_driver))) |
782 | goto out2; | 782 | goto out2; |
783 | if ((error = tty_register_driver(rio_driver2))) | 783 | if ((error = tty_register_driver(rio_driver2))) |
784 | goto out3; | 784 | goto out3; |
785 | func_exit(); | 785 | func_exit(); |
786 | return 0; | 786 | return 0; |
787 | out3: | 787 | out3: |
788 | tty_unregister_driver(rio_driver); | 788 | tty_unregister_driver(rio_driver); |
789 | out2: | 789 | out2: |
790 | put_tty_driver(rio_driver2); | 790 | put_tty_driver(rio_driver2); |
791 | out1: | 791 | out1: |
792 | put_tty_driver(rio_driver); | 792 | put_tty_driver(rio_driver); |
793 | out: | 793 | out: |
794 | printk(KERN_ERR "rio: Couldn't register a rio driver, error = %d\n", error); | 794 | printk(KERN_ERR "rio: Couldn't register a rio driver, error = %d\n", error); |
795 | return 1; | 795 | return 1; |
796 | } | 796 | } |
797 | 797 | ||
798 | 798 | ||
799 | static void *ckmalloc(int size) | 799 | static void *ckmalloc(int size) |
800 | { | 800 | { |
801 | void *p; | 801 | void *p; |
802 | 802 | ||
803 | p = kzalloc(size, GFP_KERNEL); | 803 | p = kzalloc(size, GFP_KERNEL); |
804 | return p; | 804 | return p; |
805 | } | 805 | } |
806 | 806 | ||
807 | 807 | ||
808 | 808 | ||
809 | static int rio_init_datastructures(void) | 809 | static int rio_init_datastructures(void) |
810 | { | 810 | { |
811 | int i; | 811 | int i; |
812 | struct Port *port; | 812 | struct Port *port; |
813 | func_enter(); | 813 | func_enter(); |
814 | 814 | ||
815 | /* Many drivers statically allocate the maximum number of ports | 815 | /* Many drivers statically allocate the maximum number of ports |
816 | There is no reason not to allocate them dynamically. Is there? -- REW */ | 816 | There is no reason not to allocate them dynamically. Is there? -- REW */ |
817 | /* However, the RIO driver allows users to configure their first | 817 | /* However, the RIO driver allows users to configure their first |
818 | RTA as the ports numbered 504-511. We therefore need to allocate | 818 | RTA as the ports numbered 504-511. We therefore need to allocate |
819 | the whole range. :-( -- REW */ | 819 | the whole range. :-( -- REW */ |
820 | 820 | ||
821 | #define RI_SZ sizeof(struct rio_info) | 821 | #define RI_SZ sizeof(struct rio_info) |
822 | #define HOST_SZ sizeof(struct Host) | 822 | #define HOST_SZ sizeof(struct Host) |
823 | #define PORT_SZ sizeof(struct Port *) | 823 | #define PORT_SZ sizeof(struct Port *) |
824 | #define TMIO_SZ sizeof(struct termios *) | 824 | #define TMIO_SZ sizeof(struct termios *) |
825 | rio_dprintk(RIO_DEBUG_INIT, "getting : %Zd %Zd %Zd %Zd %Zd bytes\n", RI_SZ, RIO_HOSTS * HOST_SZ, RIO_PORTS * PORT_SZ, RIO_PORTS * TMIO_SZ, RIO_PORTS * TMIO_SZ); | 825 | rio_dprintk(RIO_DEBUG_INIT, "getting : %Zd %Zd %Zd %Zd %Zd bytes\n", RI_SZ, RIO_HOSTS * HOST_SZ, RIO_PORTS * PORT_SZ, RIO_PORTS * TMIO_SZ, RIO_PORTS * TMIO_SZ); |
826 | 826 | ||
827 | if (!(p = ckmalloc(RI_SZ))) | 827 | if (!(p = ckmalloc(RI_SZ))) |
828 | goto free0; | 828 | goto free0; |
829 | if (!(p->RIOHosts = ckmalloc(RIO_HOSTS * HOST_SZ))) | 829 | if (!(p->RIOHosts = ckmalloc(RIO_HOSTS * HOST_SZ))) |
830 | goto free1; | 830 | goto free1; |
831 | if (!(p->RIOPortp = ckmalloc(RIO_PORTS * PORT_SZ))) | 831 | if (!(p->RIOPortp = ckmalloc(RIO_PORTS * PORT_SZ))) |
832 | goto free2; | 832 | goto free2; |
833 | p->RIOConf = RIOConf; | 833 | p->RIOConf = RIOConf; |
834 | rio_dprintk(RIO_DEBUG_INIT, "Got : %p %p %p\n", p, p->RIOHosts, p->RIOPortp); | 834 | rio_dprintk(RIO_DEBUG_INIT, "Got : %p %p %p\n", p, p->RIOHosts, p->RIOPortp); |
835 | 835 | ||
836 | #if 1 | 836 | #if 1 |
837 | for (i = 0; i < RIO_PORTS; i++) { | 837 | for (i = 0; i < RIO_PORTS; i++) { |
838 | port = p->RIOPortp[i] = ckmalloc(sizeof(struct Port)); | 838 | port = p->RIOPortp[i] = ckmalloc(sizeof(struct Port)); |
839 | if (!port) { | 839 | if (!port) { |
840 | goto free6; | 840 | goto free6; |
841 | } | 841 | } |
842 | rio_dprintk(RIO_DEBUG_INIT, "initing port %d (%d)\n", i, port->Mapped); | 842 | rio_dprintk(RIO_DEBUG_INIT, "initing port %d (%d)\n", i, port->Mapped); |
843 | port->PortNum = i; | 843 | port->PortNum = i; |
844 | port->gs.magic = RIO_MAGIC; | 844 | port->gs.magic = RIO_MAGIC; |
845 | port->gs.close_delay = HZ / 2; | 845 | port->gs.close_delay = HZ / 2; |
846 | port->gs.closing_wait = 30 * HZ; | 846 | port->gs.closing_wait = 30 * HZ; |
847 | port->gs.rd = &rio_real_driver; | 847 | port->gs.rd = &rio_real_driver; |
848 | spin_lock_init(&port->portSem); | 848 | spin_lock_init(&port->portSem); |
849 | /* | 849 | /* |
850 | * Initializing wait queue | 850 | * Initializing wait queue |
851 | */ | 851 | */ |
852 | init_waitqueue_head(&port->gs.open_wait); | 852 | init_waitqueue_head(&port->gs.port.open_wait); |
853 | init_waitqueue_head(&port->gs.close_wait); | 853 | init_waitqueue_head(&port->gs.port.close_wait); |
854 | } | 854 | } |
855 | #else | 855 | #else |
856 | /* We could postpone initializing them to when they are configured. */ | 856 | /* We could postpone initializing them to when they are configured. */ |
857 | #endif | 857 | #endif |
858 | 858 | ||
859 | 859 | ||
860 | 860 | ||
861 | if (rio_debug & RIO_DEBUG_INIT) { | 861 | if (rio_debug & RIO_DEBUG_INIT) { |
862 | my_hd(&rio_real_driver, sizeof(rio_real_driver)); | 862 | my_hd(&rio_real_driver, sizeof(rio_real_driver)); |
863 | } | 863 | } |
864 | 864 | ||
865 | 865 | ||
866 | func_exit(); | 866 | func_exit(); |
867 | return 0; | 867 | return 0; |
868 | 868 | ||
869 | free6:for (i--; i >= 0; i--) | 869 | free6:for (i--; i >= 0; i--) |
870 | kfree(p->RIOPortp[i]); | 870 | kfree(p->RIOPortp[i]); |
871 | /*free5: | 871 | /*free5: |
872 | free4: | 872 | free4: |
873 | free3:*/ kfree(p->RIOPortp); | 873 | free3:*/ kfree(p->RIOPortp); |
874 | free2:kfree(p->RIOHosts); | 874 | free2:kfree(p->RIOHosts); |
875 | free1: | 875 | free1: |
876 | rio_dprintk(RIO_DEBUG_INIT, "Not enough memory! %p %p %p\n", p, p->RIOHosts, p->RIOPortp); | 876 | rio_dprintk(RIO_DEBUG_INIT, "Not enough memory! %p %p %p\n", p, p->RIOHosts, p->RIOPortp); |
877 | kfree(p); | 877 | kfree(p); |
878 | free0: | 878 | free0: |
879 | return -ENOMEM; | 879 | return -ENOMEM; |
880 | } | 880 | } |
881 | 881 | ||
882 | static void __exit rio_release_drivers(void) | 882 | static void __exit rio_release_drivers(void) |
883 | { | 883 | { |
884 | func_enter(); | 884 | func_enter(); |
885 | tty_unregister_driver(rio_driver2); | 885 | tty_unregister_driver(rio_driver2); |
886 | tty_unregister_driver(rio_driver); | 886 | tty_unregister_driver(rio_driver); |
887 | put_tty_driver(rio_driver2); | 887 | put_tty_driver(rio_driver2); |
888 | put_tty_driver(rio_driver); | 888 | put_tty_driver(rio_driver); |
889 | func_exit(); | 889 | func_exit(); |
890 | } | 890 | } |
891 | 891 | ||
892 | 892 | ||
893 | #ifdef CONFIG_PCI | 893 | #ifdef CONFIG_PCI |
894 | /* This was written for SX, but applies to RIO too... | 894 | /* This was written for SX, but applies to RIO too... |
895 | (including bugs....) | 895 | (including bugs....) |
896 | 896 | ||
897 | There is another bit besides Bit 17. Turning that bit off | 897 | There is another bit besides Bit 17. Turning that bit off |
898 | (on boards shipped with the fix in the eeprom) results in a | 898 | (on boards shipped with the fix in the eeprom) results in a |
899 | hang on the next access to the card. | 899 | hang on the next access to the card. |
900 | */ | 900 | */ |
901 | 901 | ||
902 | /******************************************************** | 902 | /******************************************************** |
903 | * Setting bit 17 in the CNTRL register of the PLX 9050 * | 903 | * Setting bit 17 in the CNTRL register of the PLX 9050 * |
904 | * chip forces a retry on writes while a read is pending.* | 904 | * chip forces a retry on writes while a read is pending.* |
905 | * This is to prevent the card locking up on Intel Xeon * | 905 | * This is to prevent the card locking up on Intel Xeon * |
906 | * multiprocessor systems with the NX chipset. -- NV * | 906 | * multiprocessor systems with the NX chipset. -- NV * |
907 | ********************************************************/ | 907 | ********************************************************/ |
908 | 908 | ||
909 | /* Newer cards are produced with this bit set from the configuration | 909 | /* Newer cards are produced with this bit set from the configuration |
910 | EEprom. As the bit is read/write for the CPU, we can fix it here, | 910 | EEprom. As the bit is read/write for the CPU, we can fix it here, |
911 | if we detect that it isn't set correctly. -- REW */ | 911 | if we detect that it isn't set correctly. -- REW */ |
912 | 912 | ||
913 | static void fix_rio_pci(struct pci_dev *pdev) | 913 | static void fix_rio_pci(struct pci_dev *pdev) |
914 | { | 914 | { |
915 | unsigned long hwbase; | 915 | unsigned long hwbase; |
916 | unsigned char __iomem *rebase; | 916 | unsigned char __iomem *rebase; |
917 | unsigned int t; | 917 | unsigned int t; |
918 | 918 | ||
919 | #define CNTRL_REG_OFFSET 0x50 | 919 | #define CNTRL_REG_OFFSET 0x50 |
920 | #define CNTRL_REG_GOODVALUE 0x18260000 | 920 | #define CNTRL_REG_GOODVALUE 0x18260000 |
921 | 921 | ||
922 | hwbase = pci_resource_start(pdev, 0); | 922 | hwbase = pci_resource_start(pdev, 0); |
923 | rebase = ioremap(hwbase, 0x80); | 923 | rebase = ioremap(hwbase, 0x80); |
924 | t = readl(rebase + CNTRL_REG_OFFSET); | 924 | t = readl(rebase + CNTRL_REG_OFFSET); |
925 | if (t != CNTRL_REG_GOODVALUE) { | 925 | if (t != CNTRL_REG_GOODVALUE) { |
926 | printk(KERN_DEBUG "rio: performing cntrl reg fix: %08x -> %08x\n", t, CNTRL_REG_GOODVALUE); | 926 | printk(KERN_DEBUG "rio: performing cntrl reg fix: %08x -> %08x\n", t, CNTRL_REG_GOODVALUE); |
927 | writel(CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET); | 927 | writel(CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET); |
928 | } | 928 | } |
929 | iounmap(rebase); | 929 | iounmap(rebase); |
930 | } | 930 | } |
931 | #endif | 931 | #endif |
932 | 932 | ||
933 | 933 | ||
934 | static int __init rio_init(void) | 934 | static int __init rio_init(void) |
935 | { | 935 | { |
936 | int found = 0; | 936 | int found = 0; |
937 | int i; | 937 | int i; |
938 | struct Host *hp; | 938 | struct Host *hp; |
939 | int retval; | 939 | int retval; |
940 | struct vpd_prom *vpdp; | 940 | struct vpd_prom *vpdp; |
941 | int okboard; | 941 | int okboard; |
942 | 942 | ||
943 | #ifdef CONFIG_PCI | 943 | #ifdef CONFIG_PCI |
944 | struct pci_dev *pdev = NULL; | 944 | struct pci_dev *pdev = NULL; |
945 | unsigned short tshort; | 945 | unsigned short tshort; |
946 | #endif | 946 | #endif |
947 | 947 | ||
948 | func_enter(); | 948 | func_enter(); |
949 | rio_dprintk(RIO_DEBUG_INIT, "Initing rio module... (rio_debug=%d)\n", rio_debug); | 949 | rio_dprintk(RIO_DEBUG_INIT, "Initing rio module... (rio_debug=%d)\n", rio_debug); |
950 | 950 | ||
951 | if (abs((long) (&rio_debug) - rio_debug) < 0x10000) { | 951 | if (abs((long) (&rio_debug) - rio_debug) < 0x10000) { |
952 | printk(KERN_WARNING "rio: rio_debug is an address, instead of a value. " "Assuming -1. Was %x/%p.\n", rio_debug, &rio_debug); | 952 | printk(KERN_WARNING "rio: rio_debug is an address, instead of a value. " "Assuming -1. Was %x/%p.\n", rio_debug, &rio_debug); |
953 | rio_debug = -1; | 953 | rio_debug = -1; |
954 | } | 954 | } |
955 | 955 | ||
956 | if (misc_register(&rio_fw_device) < 0) { | 956 | if (misc_register(&rio_fw_device) < 0) { |
957 | printk(KERN_ERR "RIO: Unable to register firmware loader driver.\n"); | 957 | printk(KERN_ERR "RIO: Unable to register firmware loader driver.\n"); |
958 | return -EIO; | 958 | return -EIO; |
959 | } | 959 | } |
960 | 960 | ||
961 | retval = rio_init_datastructures(); | 961 | retval = rio_init_datastructures(); |
962 | if (retval < 0) { | 962 | if (retval < 0) { |
963 | misc_deregister(&rio_fw_device); | 963 | misc_deregister(&rio_fw_device); |
964 | return retval; | 964 | return retval; |
965 | } | 965 | } |
966 | #ifdef CONFIG_PCI | 966 | #ifdef CONFIG_PCI |
967 | /* First look for the JET devices: */ | 967 | /* First look for the JET devices: */ |
968 | while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, pdev))) { | 968 | while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, pdev))) { |
969 | u32 tint; | 969 | u32 tint; |
970 | 970 | ||
971 | if (pci_enable_device(pdev)) | 971 | if (pci_enable_device(pdev)) |
972 | continue; | 972 | continue; |
973 | 973 | ||
974 | /* Specialix has a whole bunch of cards with | 974 | /* Specialix has a whole bunch of cards with |
975 | 0x2000 as the device ID. They say its because | 975 | 0x2000 as the device ID. They say its because |
976 | the standard requires it. Stupid standard. */ | 976 | the standard requires it. Stupid standard. */ |
977 | /* It seems that reading a word doesn't work reliably on 2.0. | 977 | /* It seems that reading a word doesn't work reliably on 2.0. |
978 | Also, reading a non-aligned dword doesn't work. So we read the | 978 | Also, reading a non-aligned dword doesn't work. So we read the |
979 | whole dword at 0x2c and extract the word at 0x2e (SUBSYSTEM_ID) | 979 | whole dword at 0x2c and extract the word at 0x2e (SUBSYSTEM_ID) |
980 | ourselves */ | 980 | ourselves */ |
981 | pci_read_config_dword(pdev, 0x2c, &tint); | 981 | pci_read_config_dword(pdev, 0x2c, &tint); |
982 | tshort = (tint >> 16) & 0xffff; | 982 | tshort = (tint >> 16) & 0xffff; |
983 | rio_dprintk(RIO_DEBUG_PROBE, "Got a specialix card: %x.\n", tint); | 983 | rio_dprintk(RIO_DEBUG_PROBE, "Got a specialix card: %x.\n", tint); |
984 | if (tshort != 0x0100) { | 984 | if (tshort != 0x0100) { |
985 | rio_dprintk(RIO_DEBUG_PROBE, "But it's not a RIO card (%d)...\n", tshort); | 985 | rio_dprintk(RIO_DEBUG_PROBE, "But it's not a RIO card (%d)...\n", tshort); |
986 | continue; | 986 | continue; |
987 | } | 987 | } |
988 | rio_dprintk(RIO_DEBUG_PROBE, "cp1\n"); | 988 | rio_dprintk(RIO_DEBUG_PROBE, "cp1\n"); |
989 | 989 | ||
990 | hp = &p->RIOHosts[p->RIONumHosts]; | 990 | hp = &p->RIOHosts[p->RIONumHosts]; |
991 | hp->PaddrP = pci_resource_start(pdev, 2); | 991 | hp->PaddrP = pci_resource_start(pdev, 2); |
992 | hp->Ivec = pdev->irq; | 992 | hp->Ivec = pdev->irq; |
993 | if (((1 << hp->Ivec) & rio_irqmask) == 0) | 993 | if (((1 << hp->Ivec) & rio_irqmask) == 0) |
994 | hp->Ivec = 0; | 994 | hp->Ivec = 0; |
995 | hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); | 995 | hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); |
996 | hp->CardP = (struct DpRam __iomem *) hp->Caddr; | 996 | hp->CardP = (struct DpRam __iomem *) hp->Caddr; |
997 | hp->Type = RIO_PCI; | 997 | hp->Type = RIO_PCI; |
998 | hp->Copy = rio_copy_to_card; | 998 | hp->Copy = rio_copy_to_card; |
999 | hp->Mode = RIO_PCI_BOOT_FROM_RAM; | 999 | hp->Mode = RIO_PCI_BOOT_FROM_RAM; |
1000 | spin_lock_init(&hp->HostLock); | 1000 | spin_lock_init(&hp->HostLock); |
1001 | rio_reset_interrupt(hp); | 1001 | rio_reset_interrupt(hp); |
1002 | rio_start_card_running(hp); | 1002 | rio_start_card_running(hp); |
1003 | 1003 | ||
1004 | rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr); | 1004 | rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr); |
1005 | if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == 0) { | 1005 | if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == 0) { |
1006 | rio_dprintk(RIO_DEBUG_INIT, "Done RIOBoardTest\n"); | 1006 | rio_dprintk(RIO_DEBUG_INIT, "Done RIOBoardTest\n"); |
1007 | writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt); | 1007 | writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt); |
1008 | p->RIOHosts[p->RIONumHosts].UniqueNum = | 1008 | p->RIOHosts[p->RIONumHosts].UniqueNum = |
1009 | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) | | 1009 | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) | |
1010 | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24); | 1010 | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24); |
1011 | rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); | 1011 | rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); |
1012 | 1012 | ||
1013 | fix_rio_pci(pdev); | 1013 | fix_rio_pci(pdev); |
1014 | 1014 | ||
1015 | p->RIOHosts[p->RIONumHosts].pdev = pdev; | 1015 | p->RIOHosts[p->RIONumHosts].pdev = pdev; |
1016 | pci_dev_get(pdev); | 1016 | pci_dev_get(pdev); |
1017 | 1017 | ||
1018 | p->RIOLastPCISearch = 0; | 1018 | p->RIOLastPCISearch = 0; |
1019 | p->RIONumHosts++; | 1019 | p->RIONumHosts++; |
1020 | found++; | 1020 | found++; |
1021 | } else { | 1021 | } else { |
1022 | iounmap(p->RIOHosts[p->RIONumHosts].Caddr); | 1022 | iounmap(p->RIOHosts[p->RIONumHosts].Caddr); |
1023 | p->RIOHosts[p->RIONumHosts].Caddr = NULL; | 1023 | p->RIOHosts[p->RIONumHosts].Caddr = NULL; |
1024 | } | 1024 | } |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | /* Then look for the older PCI card.... : */ | 1027 | /* Then look for the older PCI card.... : */ |
1028 | 1028 | ||
1029 | /* These older PCI cards have problems (only byte-mode access is | 1029 | /* These older PCI cards have problems (only byte-mode access is |
1030 | supported), which makes them a bit awkward to support. | 1030 | supported), which makes them a bit awkward to support. |
1031 | They also have problems sharing interrupts. Be careful. | 1031 | They also have problems sharing interrupts. Be careful. |
1032 | (The driver now refuses to share interrupts for these | 1032 | (The driver now refuses to share interrupts for these |
1033 | cards. This should be sufficient). | 1033 | cards. This should be sufficient). |
1034 | */ | 1034 | */ |
1035 | 1035 | ||
1036 | /* Then look for the older RIO/PCI devices: */ | 1036 | /* Then look for the older RIO/PCI devices: */ |
1037 | while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_RIO, pdev))) { | 1037 | while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_RIO, pdev))) { |
1038 | if (pci_enable_device(pdev)) | 1038 | if (pci_enable_device(pdev)) |
1039 | continue; | 1039 | continue; |
1040 | 1040 | ||
1041 | #ifdef CONFIG_RIO_OLDPCI | 1041 | #ifdef CONFIG_RIO_OLDPCI |
1042 | hp = &p->RIOHosts[p->RIONumHosts]; | 1042 | hp = &p->RIOHosts[p->RIONumHosts]; |
1043 | hp->PaddrP = pci_resource_start(pdev, 0); | 1043 | hp->PaddrP = pci_resource_start(pdev, 0); |
1044 | hp->Ivec = pdev->irq; | 1044 | hp->Ivec = pdev->irq; |
1045 | if (((1 << hp->Ivec) & rio_irqmask) == 0) | 1045 | if (((1 << hp->Ivec) & rio_irqmask) == 0) |
1046 | hp->Ivec = 0; | 1046 | hp->Ivec = 0; |
1047 | hp->Ivec |= 0x8000; /* Mark as non-sharable */ | 1047 | hp->Ivec |= 0x8000; /* Mark as non-sharable */ |
1048 | hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); | 1048 | hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); |
1049 | hp->CardP = (struct DpRam __iomem *) hp->Caddr; | 1049 | hp->CardP = (struct DpRam __iomem *) hp->Caddr; |
1050 | hp->Type = RIO_PCI; | 1050 | hp->Type = RIO_PCI; |
1051 | hp->Copy = rio_copy_to_card; | 1051 | hp->Copy = rio_copy_to_card; |
1052 | hp->Mode = RIO_PCI_BOOT_FROM_RAM; | 1052 | hp->Mode = RIO_PCI_BOOT_FROM_RAM; |
1053 | spin_lock_init(&hp->HostLock); | 1053 | spin_lock_init(&hp->HostLock); |
1054 | 1054 | ||
1055 | rio_dprintk(RIO_DEBUG_PROBE, "Ivec: %x\n", hp->Ivec); | 1055 | rio_dprintk(RIO_DEBUG_PROBE, "Ivec: %x\n", hp->Ivec); |
1056 | rio_dprintk(RIO_DEBUG_PROBE, "Mode: %x\n", hp->Mode); | 1056 | rio_dprintk(RIO_DEBUG_PROBE, "Mode: %x\n", hp->Mode); |
1057 | 1057 | ||
1058 | rio_reset_interrupt(hp); | 1058 | rio_reset_interrupt(hp); |
1059 | rio_start_card_running(hp); | 1059 | rio_start_card_running(hp); |
1060 | rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr); | 1060 | rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr); |
1061 | if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == 0) { | 1061 | if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == 0) { |
1062 | writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt); | 1062 | writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt); |
1063 | p->RIOHosts[p->RIONumHosts].UniqueNum = | 1063 | p->RIOHosts[p->RIONumHosts].UniqueNum = |
1064 | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) | | 1064 | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) | |
1065 | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24); | 1065 | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24); |
1066 | rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); | 1066 | rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); |
1067 | 1067 | ||
1068 | p->RIOHosts[p->RIONumHosts].pdev = pdev; | 1068 | p->RIOHosts[p->RIONumHosts].pdev = pdev; |
1069 | pci_dev_get(pdev); | 1069 | pci_dev_get(pdev); |
1070 | 1070 | ||
1071 | p->RIOLastPCISearch = 0; | 1071 | p->RIOLastPCISearch = 0; |
1072 | p->RIONumHosts++; | 1072 | p->RIONumHosts++; |
1073 | found++; | 1073 | found++; |
1074 | } else { | 1074 | } else { |
1075 | iounmap(p->RIOHosts[p->RIONumHosts].Caddr); | 1075 | iounmap(p->RIOHosts[p->RIONumHosts].Caddr); |
1076 | p->RIOHosts[p->RIONumHosts].Caddr = NULL; | 1076 | p->RIOHosts[p->RIONumHosts].Caddr = NULL; |
1077 | } | 1077 | } |
1078 | #else | 1078 | #else |
1079 | printk(KERN_ERR "Found an older RIO PCI card, but the driver is not " "compiled to support it.\n"); | 1079 | printk(KERN_ERR "Found an older RIO PCI card, but the driver is not " "compiled to support it.\n"); |
1080 | #endif | 1080 | #endif |
1081 | } | 1081 | } |
1082 | #endif /* PCI */ | 1082 | #endif /* PCI */ |
1083 | 1083 | ||
1084 | /* Now probe for ISA cards... */ | 1084 | /* Now probe for ISA cards... */ |
1085 | for (i = 0; i < NR_RIO_ADDRS; i++) { | 1085 | for (i = 0; i < NR_RIO_ADDRS; i++) { |
1086 | hp = &p->RIOHosts[p->RIONumHosts]; | 1086 | hp = &p->RIOHosts[p->RIONumHosts]; |
1087 | hp->PaddrP = rio_probe_addrs[i]; | 1087 | hp->PaddrP = rio_probe_addrs[i]; |
1088 | /* There was something about the IRQs of these cards. 'Forget what.--REW */ | 1088 | /* There was something about the IRQs of these cards. 'Forget what.--REW */ |
1089 | hp->Ivec = 0; | 1089 | hp->Ivec = 0; |
1090 | hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); | 1090 | hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); |
1091 | hp->CardP = (struct DpRam __iomem *) hp->Caddr; | 1091 | hp->CardP = (struct DpRam __iomem *) hp->Caddr; |
1092 | hp->Type = RIO_AT; | 1092 | hp->Type = RIO_AT; |
1093 | hp->Copy = rio_copy_to_card; /* AT card PCI???? - PVDL | 1093 | hp->Copy = rio_copy_to_card; /* AT card PCI???? - PVDL |
1094 | * -- YES! this is now a normal copy. Only the | 1094 | * -- YES! this is now a normal copy. Only the |
1095 | * old PCI card uses the special PCI copy. | 1095 | * old PCI card uses the special PCI copy. |
1096 | * Moreover, the ISA card will work with the | 1096 | * Moreover, the ISA card will work with the |
1097 | * special PCI copy anyway. -- REW */ | 1097 | * special PCI copy anyway. -- REW */ |
1098 | hp->Mode = 0; | 1098 | hp->Mode = 0; |
1099 | spin_lock_init(&hp->HostLock); | 1099 | spin_lock_init(&hp->HostLock); |
1100 | 1100 | ||
1101 | vpdp = get_VPD_PROM(hp); | 1101 | vpdp = get_VPD_PROM(hp); |
1102 | rio_dprintk(RIO_DEBUG_PROBE, "Got VPD ROM\n"); | 1102 | rio_dprintk(RIO_DEBUG_PROBE, "Got VPD ROM\n"); |
1103 | okboard = 0; | 1103 | okboard = 0; |
1104 | if ((strncmp(vpdp->identifier, RIO_ISA_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA2_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA3_IDENT, 16) == 0)) { | 1104 | if ((strncmp(vpdp->identifier, RIO_ISA_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA2_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA3_IDENT, 16) == 0)) { |
1105 | /* Board is present... */ | 1105 | /* Board is present... */ |
1106 | if (RIOBoardTest(hp->PaddrP, hp->Caddr, RIO_AT, 0) == 0) { | 1106 | if (RIOBoardTest(hp->PaddrP, hp->Caddr, RIO_AT, 0) == 0) { |
1107 | /* ... and feeling fine!!!! */ | 1107 | /* ... and feeling fine!!!! */ |
1108 | rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); | 1108 | rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); |
1109 | if (RIOAssignAT(p, hp->PaddrP, hp->Caddr, 0)) { | 1109 | if (RIOAssignAT(p, hp->PaddrP, hp->Caddr, 0)) { |
1110 | rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, host%d uniqid = %x.\n", p->RIONumHosts, p->RIOHosts[p->RIONumHosts - 1].UniqueNum); | 1110 | rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, host%d uniqid = %x.\n", p->RIONumHosts, p->RIOHosts[p->RIONumHosts - 1].UniqueNum); |
1111 | okboard++; | 1111 | okboard++; |
1112 | found++; | 1112 | found++; |
1113 | } | 1113 | } |
1114 | } | 1114 | } |
1115 | 1115 | ||
1116 | if (!okboard) { | 1116 | if (!okboard) { |
1117 | iounmap(hp->Caddr); | 1117 | iounmap(hp->Caddr); |
1118 | hp->Caddr = NULL; | 1118 | hp->Caddr = NULL; |
1119 | } | 1119 | } |
1120 | } | 1120 | } |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | 1123 | ||
1124 | for (i = 0; i < p->RIONumHosts; i++) { | 1124 | for (i = 0; i < p->RIONumHosts; i++) { |
1125 | hp = &p->RIOHosts[i]; | 1125 | hp = &p->RIOHosts[i]; |
1126 | if (hp->Ivec) { | 1126 | if (hp->Ivec) { |
1127 | int mode = IRQF_SHARED; | 1127 | int mode = IRQF_SHARED; |
1128 | if (hp->Ivec & 0x8000) { | 1128 | if (hp->Ivec & 0x8000) { |
1129 | mode = 0; | 1129 | mode = 0; |
1130 | hp->Ivec &= 0x7fff; | 1130 | hp->Ivec &= 0x7fff; |
1131 | } | 1131 | } |
1132 | rio_dprintk(RIO_DEBUG_INIT, "Requesting interrupt hp: %p rio_interrupt: %d Mode: %x\n", hp, hp->Ivec, hp->Mode); | 1132 | rio_dprintk(RIO_DEBUG_INIT, "Requesting interrupt hp: %p rio_interrupt: %d Mode: %x\n", hp, hp->Ivec, hp->Mode); |
1133 | retval = request_irq(hp->Ivec, rio_interrupt, mode, "rio", hp); | 1133 | retval = request_irq(hp->Ivec, rio_interrupt, mode, "rio", hp); |
1134 | rio_dprintk(RIO_DEBUG_INIT, "Return value from request_irq: %d\n", retval); | 1134 | rio_dprintk(RIO_DEBUG_INIT, "Return value from request_irq: %d\n", retval); |
1135 | if (retval) { | 1135 | if (retval) { |
1136 | printk(KERN_ERR "rio: Cannot allocate irq %d.\n", hp->Ivec); | 1136 | printk(KERN_ERR "rio: Cannot allocate irq %d.\n", hp->Ivec); |
1137 | hp->Ivec = 0; | 1137 | hp->Ivec = 0; |
1138 | } | 1138 | } |
1139 | rio_dprintk(RIO_DEBUG_INIT, "Got irq %d.\n", hp->Ivec); | 1139 | rio_dprintk(RIO_DEBUG_INIT, "Got irq %d.\n", hp->Ivec); |
1140 | if (hp->Ivec != 0) { | 1140 | if (hp->Ivec != 0) { |
1141 | rio_dprintk(RIO_DEBUG_INIT, "Enabling interrupts on rio card.\n"); | 1141 | rio_dprintk(RIO_DEBUG_INIT, "Enabling interrupts on rio card.\n"); |
1142 | hp->Mode |= RIO_PCI_INT_ENABLE; | 1142 | hp->Mode |= RIO_PCI_INT_ENABLE; |
1143 | } else | 1143 | } else |
1144 | hp->Mode &= ~RIO_PCI_INT_ENABLE; | 1144 | hp->Mode &= ~RIO_PCI_INT_ENABLE; |
1145 | rio_dprintk(RIO_DEBUG_INIT, "New Mode: %x\n", hp->Mode); | 1145 | rio_dprintk(RIO_DEBUG_INIT, "New Mode: %x\n", hp->Mode); |
1146 | rio_start_card_running(hp); | 1146 | rio_start_card_running(hp); |
1147 | } | 1147 | } |
1148 | /* Init the timer "always" to make sure that it can safely be | 1148 | /* Init the timer "always" to make sure that it can safely be |
1149 | deleted when we unload... */ | 1149 | deleted when we unload... */ |
1150 | 1150 | ||
1151 | setup_timer(&hp->timer, rio_pollfunc, i); | 1151 | setup_timer(&hp->timer, rio_pollfunc, i); |
1152 | if (!hp->Ivec) { | 1152 | if (!hp->Ivec) { |
1153 | rio_dprintk(RIO_DEBUG_INIT, "Starting polling at %dj intervals.\n", rio_poll); | 1153 | rio_dprintk(RIO_DEBUG_INIT, "Starting polling at %dj intervals.\n", rio_poll); |
1154 | mod_timer(&hp->timer, jiffies + rio_poll); | 1154 | mod_timer(&hp->timer, jiffies + rio_poll); |
1155 | } | 1155 | } |
1156 | } | 1156 | } |
1157 | 1157 | ||
1158 | if (found) { | 1158 | if (found) { |
1159 | rio_dprintk(RIO_DEBUG_INIT, "rio: total of %d boards detected.\n", found); | 1159 | rio_dprintk(RIO_DEBUG_INIT, "rio: total of %d boards detected.\n", found); |
1160 | rio_init_drivers(); | 1160 | rio_init_drivers(); |
1161 | } else { | 1161 | } else { |
1162 | /* deregister the misc device we created earlier */ | 1162 | /* deregister the misc device we created earlier */ |
1163 | misc_deregister(&rio_fw_device); | 1163 | misc_deregister(&rio_fw_device); |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | func_exit(); | 1166 | func_exit(); |
1167 | return found ? 0 : -EIO; | 1167 | return found ? 0 : -EIO; |
1168 | } | 1168 | } |
1169 | 1169 | ||
1170 | 1170 | ||
1171 | static void __exit rio_exit(void) | 1171 | static void __exit rio_exit(void) |
1172 | { | 1172 | { |
1173 | int i; | 1173 | int i; |
1174 | struct Host *hp; | 1174 | struct Host *hp; |
1175 | 1175 | ||
1176 | func_enter(); | 1176 | func_enter(); |
1177 | 1177 | ||
1178 | for (i = 0, hp = p->RIOHosts; i < p->RIONumHosts; i++, hp++) { | 1178 | for (i = 0, hp = p->RIOHosts; i < p->RIONumHosts; i++, hp++) { |
1179 | RIOHostReset(hp->Type, hp->CardP, hp->Slot); | 1179 | RIOHostReset(hp->Type, hp->CardP, hp->Slot); |
1180 | if (hp->Ivec) { | 1180 | if (hp->Ivec) { |
1181 | free_irq(hp->Ivec, hp); | 1181 | free_irq(hp->Ivec, hp); |
1182 | rio_dprintk(RIO_DEBUG_INIT, "freed irq %d.\n", hp->Ivec); | 1182 | rio_dprintk(RIO_DEBUG_INIT, "freed irq %d.\n", hp->Ivec); |
1183 | } | 1183 | } |
1184 | /* It is safe/allowed to del_timer a non-active timer */ | 1184 | /* It is safe/allowed to del_timer a non-active timer */ |
1185 | del_timer_sync(&hp->timer); | 1185 | del_timer_sync(&hp->timer); |
1186 | if (hp->Caddr) | 1186 | if (hp->Caddr) |
1187 | iounmap(hp->Caddr); | 1187 | iounmap(hp->Caddr); |
1188 | if (hp->Type == RIO_PCI) | 1188 | if (hp->Type == RIO_PCI) |
1189 | pci_dev_put(hp->pdev); | 1189 | pci_dev_put(hp->pdev); |
1190 | } | 1190 | } |
1191 | 1191 | ||
1192 | if (misc_deregister(&rio_fw_device) < 0) { | 1192 | if (misc_deregister(&rio_fw_device) < 0) { |
1193 | printk(KERN_INFO "rio: couldn't deregister control-device\n"); | 1193 | printk(KERN_INFO "rio: couldn't deregister control-device\n"); |
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | 1196 | ||
1197 | rio_dprintk(RIO_DEBUG_CLEANUP, "Cleaning up drivers\n"); | 1197 | rio_dprintk(RIO_DEBUG_CLEANUP, "Cleaning up drivers\n"); |
1198 | 1198 | ||
1199 | rio_release_drivers(); | 1199 | rio_release_drivers(); |
1200 | 1200 | ||
1201 | /* Release dynamically allocated memory */ | 1201 | /* Release dynamically allocated memory */ |
1202 | kfree(p->RIOPortp); | 1202 | kfree(p->RIOPortp); |
1203 | kfree(p->RIOHosts); | 1203 | kfree(p->RIOHosts); |
1204 | kfree(p); | 1204 | kfree(p); |
1205 | 1205 | ||
1206 | func_exit(); | 1206 | func_exit(); |
1207 | } | 1207 | } |
1208 | 1208 | ||
1209 | module_init(rio_init); | 1209 | module_init(rio_init); |
1210 | module_exit(rio_exit); | 1210 | module_exit(rio_exit); |
1211 | 1211 |
drivers/char/rio/riocmd.c
1 | /* | 1 | /* |
2 | ** ----------------------------------------------------------------------------- | 2 | ** ----------------------------------------------------------------------------- |
3 | ** | 3 | ** |
4 | ** Perle Specialix driver for Linux | 4 | ** Perle Specialix driver for Linux |
5 | ** ported from the existing SCO driver source | 5 | ** ported from the existing SCO driver source |
6 | ** | 6 | ** |
7 | * | 7 | * |
8 | * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK. | 8 | * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK. |
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
12 | * the Free Software Foundation; either version 2 of the License, or | 12 | * the Free Software Foundation; either version 2 of the License, or |
13 | * (at your option) any later version. | 13 | * (at your option) any later version. |
14 | * | 14 | * |
15 | * This program is distributed in the hope that it will be useful, | 15 | * This program is distributed in the hope that it will be useful, |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | * GNU General Public License for more details. | 18 | * GNU General Public License for more details. |
19 | * | 19 | * |
20 | * You should have received a copy of the GNU General Public License | 20 | * You should have received a copy of the GNU General Public License |
21 | * along with this program; if not, write to the Free Software | 21 | * along with this program; if not, write to the Free Software |
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
23 | ** | 23 | ** |
24 | ** Module : riocmd.c | 24 | ** Module : riocmd.c |
25 | ** SID : 1.2 | 25 | ** SID : 1.2 |
26 | ** Last Modified : 11/6/98 10:33:41 | 26 | ** Last Modified : 11/6/98 10:33:41 |
27 | ** Retrieved : 11/6/98 10:33:49 | 27 | ** Retrieved : 11/6/98 10:33:49 |
28 | ** | 28 | ** |
29 | ** ident @(#)riocmd.c 1.2 | 29 | ** ident @(#)riocmd.c 1.2 |
30 | ** | 30 | ** |
31 | ** ----------------------------------------------------------------------------- | 31 | ** ----------------------------------------------------------------------------- |
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <linux/module.h> | 34 | #include <linux/module.h> |
35 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
36 | #include <linux/errno.h> | 36 | #include <linux/errno.h> |
37 | #include <linux/tty.h> | 37 | #include <linux/tty.h> |
38 | #include <asm/io.h> | 38 | #include <asm/io.h> |
39 | #include <asm/system.h> | 39 | #include <asm/system.h> |
40 | #include <asm/string.h> | 40 | #include <asm/string.h> |
41 | #include <asm/uaccess.h> | 41 | #include <asm/uaccess.h> |
42 | 42 | ||
43 | #include <linux/termios.h> | 43 | #include <linux/termios.h> |
44 | #include <linux/serial.h> | 44 | #include <linux/serial.h> |
45 | 45 | ||
46 | #include <linux/generic_serial.h> | 46 | #include <linux/generic_serial.h> |
47 | 47 | ||
48 | #include "linux_compat.h" | 48 | #include "linux_compat.h" |
49 | #include "rio_linux.h" | 49 | #include "rio_linux.h" |
50 | #include "pkt.h" | 50 | #include "pkt.h" |
51 | #include "daemon.h" | 51 | #include "daemon.h" |
52 | #include "rio.h" | 52 | #include "rio.h" |
53 | #include "riospace.h" | 53 | #include "riospace.h" |
54 | #include "cmdpkt.h" | 54 | #include "cmdpkt.h" |
55 | #include "map.h" | 55 | #include "map.h" |
56 | #include "rup.h" | 56 | #include "rup.h" |
57 | #include "port.h" | 57 | #include "port.h" |
58 | #include "riodrvr.h" | 58 | #include "riodrvr.h" |
59 | #include "rioinfo.h" | 59 | #include "rioinfo.h" |
60 | #include "func.h" | 60 | #include "func.h" |
61 | #include "errors.h" | 61 | #include "errors.h" |
62 | #include "pci.h" | 62 | #include "pci.h" |
63 | 63 | ||
64 | #include "parmmap.h" | 64 | #include "parmmap.h" |
65 | #include "unixrup.h" | 65 | #include "unixrup.h" |
66 | #include "board.h" | 66 | #include "board.h" |
67 | #include "host.h" | 67 | #include "host.h" |
68 | #include "phb.h" | 68 | #include "phb.h" |
69 | #include "link.h" | 69 | #include "link.h" |
70 | #include "cmdblk.h" | 70 | #include "cmdblk.h" |
71 | #include "route.h" | 71 | #include "route.h" |
72 | #include "cirrus.h" | 72 | #include "cirrus.h" |
73 | 73 | ||
74 | 74 | ||
75 | static struct IdentifyRta IdRta; | 75 | static struct IdentifyRta IdRta; |
76 | static struct KillNeighbour KillUnit; | 76 | static struct KillNeighbour KillUnit; |
77 | 77 | ||
78 | int RIOFoadRta(struct Host *HostP, struct Map *MapP) | 78 | int RIOFoadRta(struct Host *HostP, struct Map *MapP) |
79 | { | 79 | { |
80 | struct CmdBlk *CmdBlkP; | 80 | struct CmdBlk *CmdBlkP; |
81 | 81 | ||
82 | rio_dprintk(RIO_DEBUG_CMD, "FOAD RTA\n"); | 82 | rio_dprintk(RIO_DEBUG_CMD, "FOAD RTA\n"); |
83 | 83 | ||
84 | CmdBlkP = RIOGetCmdBlk(); | 84 | CmdBlkP = RIOGetCmdBlk(); |
85 | 85 | ||
86 | if (!CmdBlkP) { | 86 | if (!CmdBlkP) { |
87 | rio_dprintk(RIO_DEBUG_CMD, "FOAD RTA: GetCmdBlk failed\n"); | 87 | rio_dprintk(RIO_DEBUG_CMD, "FOAD RTA: GetCmdBlk failed\n"); |
88 | return -ENXIO; | 88 | return -ENXIO; |
89 | } | 89 | } |
90 | 90 | ||
91 | CmdBlkP->Packet.dest_unit = MapP->ID; | 91 | CmdBlkP->Packet.dest_unit = MapP->ID; |
92 | CmdBlkP->Packet.dest_port = BOOT_RUP; | 92 | CmdBlkP->Packet.dest_port = BOOT_RUP; |
93 | CmdBlkP->Packet.src_unit = 0; | 93 | CmdBlkP->Packet.src_unit = 0; |
94 | CmdBlkP->Packet.src_port = BOOT_RUP; | 94 | CmdBlkP->Packet.src_port = BOOT_RUP; |
95 | CmdBlkP->Packet.len = 0x84; | 95 | CmdBlkP->Packet.len = 0x84; |
96 | CmdBlkP->Packet.data[0] = IFOAD; | 96 | CmdBlkP->Packet.data[0] = IFOAD; |
97 | CmdBlkP->Packet.data[1] = 0; | 97 | CmdBlkP->Packet.data[1] = 0; |
98 | CmdBlkP->Packet.data[2] = IFOAD_MAGIC & 0xFF; | 98 | CmdBlkP->Packet.data[2] = IFOAD_MAGIC & 0xFF; |
99 | CmdBlkP->Packet.data[3] = (IFOAD_MAGIC >> 8) & 0xFF; | 99 | CmdBlkP->Packet.data[3] = (IFOAD_MAGIC >> 8) & 0xFF; |
100 | 100 | ||
101 | if (RIOQueueCmdBlk(HostP, MapP->ID - 1, CmdBlkP) == RIO_FAIL) { | 101 | if (RIOQueueCmdBlk(HostP, MapP->ID - 1, CmdBlkP) == RIO_FAIL) { |
102 | rio_dprintk(RIO_DEBUG_CMD, "FOAD RTA: Failed to queue foad command\n"); | 102 | rio_dprintk(RIO_DEBUG_CMD, "FOAD RTA: Failed to queue foad command\n"); |
103 | return -EIO; | 103 | return -EIO; |
104 | } | 104 | } |
105 | return 0; | 105 | return 0; |
106 | } | 106 | } |
107 | 107 | ||
108 | int RIOZombieRta(struct Host *HostP, struct Map *MapP) | 108 | int RIOZombieRta(struct Host *HostP, struct Map *MapP) |
109 | { | 109 | { |
110 | struct CmdBlk *CmdBlkP; | 110 | struct CmdBlk *CmdBlkP; |
111 | 111 | ||
112 | rio_dprintk(RIO_DEBUG_CMD, "ZOMBIE RTA\n"); | 112 | rio_dprintk(RIO_DEBUG_CMD, "ZOMBIE RTA\n"); |
113 | 113 | ||
114 | CmdBlkP = RIOGetCmdBlk(); | 114 | CmdBlkP = RIOGetCmdBlk(); |
115 | 115 | ||
116 | if (!CmdBlkP) { | 116 | if (!CmdBlkP) { |
117 | rio_dprintk(RIO_DEBUG_CMD, "ZOMBIE RTA: GetCmdBlk failed\n"); | 117 | rio_dprintk(RIO_DEBUG_CMD, "ZOMBIE RTA: GetCmdBlk failed\n"); |
118 | return -ENXIO; | 118 | return -ENXIO; |
119 | } | 119 | } |
120 | 120 | ||
121 | CmdBlkP->Packet.dest_unit = MapP->ID; | 121 | CmdBlkP->Packet.dest_unit = MapP->ID; |
122 | CmdBlkP->Packet.dest_port = BOOT_RUP; | 122 | CmdBlkP->Packet.dest_port = BOOT_RUP; |
123 | CmdBlkP->Packet.src_unit = 0; | 123 | CmdBlkP->Packet.src_unit = 0; |
124 | CmdBlkP->Packet.src_port = BOOT_RUP; | 124 | CmdBlkP->Packet.src_port = BOOT_RUP; |
125 | CmdBlkP->Packet.len = 0x84; | 125 | CmdBlkP->Packet.len = 0x84; |
126 | CmdBlkP->Packet.data[0] = ZOMBIE; | 126 | CmdBlkP->Packet.data[0] = ZOMBIE; |
127 | CmdBlkP->Packet.data[1] = 0; | 127 | CmdBlkP->Packet.data[1] = 0; |
128 | CmdBlkP->Packet.data[2] = ZOMBIE_MAGIC & 0xFF; | 128 | CmdBlkP->Packet.data[2] = ZOMBIE_MAGIC & 0xFF; |
129 | CmdBlkP->Packet.data[3] = (ZOMBIE_MAGIC >> 8) & 0xFF; | 129 | CmdBlkP->Packet.data[3] = (ZOMBIE_MAGIC >> 8) & 0xFF; |
130 | 130 | ||
131 | if (RIOQueueCmdBlk(HostP, MapP->ID - 1, CmdBlkP) == RIO_FAIL) { | 131 | if (RIOQueueCmdBlk(HostP, MapP->ID - 1, CmdBlkP) == RIO_FAIL) { |
132 | rio_dprintk(RIO_DEBUG_CMD, "ZOMBIE RTA: Failed to queue zombie command\n"); | 132 | rio_dprintk(RIO_DEBUG_CMD, "ZOMBIE RTA: Failed to queue zombie command\n"); |
133 | return -EIO; | 133 | return -EIO; |
134 | } | 134 | } |
135 | return 0; | 135 | return 0; |
136 | } | 136 | } |
137 | 137 | ||
138 | int RIOCommandRta(struct rio_info *p, unsigned long RtaUnique, int (*func) (struct Host * HostP, struct Map * MapP)) | 138 | int RIOCommandRta(struct rio_info *p, unsigned long RtaUnique, int (*func) (struct Host * HostP, struct Map * MapP)) |
139 | { | 139 | { |
140 | unsigned int Host; | 140 | unsigned int Host; |
141 | 141 | ||
142 | rio_dprintk(RIO_DEBUG_CMD, "Command RTA 0x%lx func %p\n", RtaUnique, func); | 142 | rio_dprintk(RIO_DEBUG_CMD, "Command RTA 0x%lx func %p\n", RtaUnique, func); |
143 | 143 | ||
144 | if (!RtaUnique) | 144 | if (!RtaUnique) |
145 | return (0); | 145 | return (0); |
146 | 146 | ||
147 | for (Host = 0; Host < p->RIONumHosts; Host++) { | 147 | for (Host = 0; Host < p->RIONumHosts; Host++) { |
148 | unsigned int Rta; | 148 | unsigned int Rta; |
149 | struct Host *HostP = &p->RIOHosts[Host]; | 149 | struct Host *HostP = &p->RIOHosts[Host]; |
150 | 150 | ||
151 | for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) { | 151 | for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) { |
152 | struct Map *MapP = &HostP->Mapping[Rta]; | 152 | struct Map *MapP = &HostP->Mapping[Rta]; |
153 | 153 | ||
154 | if (MapP->RtaUniqueNum == RtaUnique) { | 154 | if (MapP->RtaUniqueNum == RtaUnique) { |
155 | uint Link; | 155 | uint Link; |
156 | 156 | ||
157 | /* | 157 | /* |
158 | ** now, lets just check we have a route to it... | 158 | ** now, lets just check we have a route to it... |
159 | ** IF the routing stuff is working, then one of the | 159 | ** IF the routing stuff is working, then one of the |
160 | ** topology entries for this unit will have a legit | 160 | ** topology entries for this unit will have a legit |
161 | ** route *somewhere*. We care not where - if its got | 161 | ** route *somewhere*. We care not where - if its got |
162 | ** any connections, we can get to it. | 162 | ** any connections, we can get to it. |
163 | */ | 163 | */ |
164 | for (Link = 0; Link < LINKS_PER_UNIT; Link++) { | 164 | for (Link = 0; Link < LINKS_PER_UNIT; Link++) { |
165 | if (MapP->Topology[Link].Unit <= (u8) MAX_RUP) { | 165 | if (MapP->Topology[Link].Unit <= (u8) MAX_RUP) { |
166 | /* | 166 | /* |
167 | ** Its worth trying the operation... | 167 | ** Its worth trying the operation... |
168 | */ | 168 | */ |
169 | return (*func) (HostP, MapP); | 169 | return (*func) (HostP, MapP); |
170 | } | 170 | } |
171 | } | 171 | } |
172 | } | 172 | } |
173 | } | 173 | } |
174 | } | 174 | } |
175 | return -ENXIO; | 175 | return -ENXIO; |
176 | } | 176 | } |
177 | 177 | ||
178 | 178 | ||
179 | int RIOIdentifyRta(struct rio_info *p, void __user * arg) | 179 | int RIOIdentifyRta(struct rio_info *p, void __user * arg) |
180 | { | 180 | { |
181 | unsigned int Host; | 181 | unsigned int Host; |
182 | 182 | ||
183 | if (copy_from_user(&IdRta, arg, sizeof(IdRta))) { | 183 | if (copy_from_user(&IdRta, arg, sizeof(IdRta))) { |
184 | rio_dprintk(RIO_DEBUG_CMD, "RIO_IDENTIFY_RTA copy failed\n"); | 184 | rio_dprintk(RIO_DEBUG_CMD, "RIO_IDENTIFY_RTA copy failed\n"); |
185 | p->RIOError.Error = COPYIN_FAILED; | 185 | p->RIOError.Error = COPYIN_FAILED; |
186 | return -EFAULT; | 186 | return -EFAULT; |
187 | } | 187 | } |
188 | 188 | ||
189 | for (Host = 0; Host < p->RIONumHosts; Host++) { | 189 | for (Host = 0; Host < p->RIONumHosts; Host++) { |
190 | unsigned int Rta; | 190 | unsigned int Rta; |
191 | struct Host *HostP = &p->RIOHosts[Host]; | 191 | struct Host *HostP = &p->RIOHosts[Host]; |
192 | 192 | ||
193 | for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) { | 193 | for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) { |
194 | struct Map *MapP = &HostP->Mapping[Rta]; | 194 | struct Map *MapP = &HostP->Mapping[Rta]; |
195 | 195 | ||
196 | if (MapP->RtaUniqueNum == IdRta.RtaUnique) { | 196 | if (MapP->RtaUniqueNum == IdRta.RtaUnique) { |
197 | uint Link; | 197 | uint Link; |
198 | /* | 198 | /* |
199 | ** now, lets just check we have a route to it... | 199 | ** now, lets just check we have a route to it... |
200 | ** IF the routing stuff is working, then one of the | 200 | ** IF the routing stuff is working, then one of the |
201 | ** topology entries for this unit will have a legit | 201 | ** topology entries for this unit will have a legit |
202 | ** route *somewhere*. We care not where - if its got | 202 | ** route *somewhere*. We care not where - if its got |
203 | ** any connections, we can get to it. | 203 | ** any connections, we can get to it. |
204 | */ | 204 | */ |
205 | for (Link = 0; Link < LINKS_PER_UNIT; Link++) { | 205 | for (Link = 0; Link < LINKS_PER_UNIT; Link++) { |
206 | if (MapP->Topology[Link].Unit <= (u8) MAX_RUP) { | 206 | if (MapP->Topology[Link].Unit <= (u8) MAX_RUP) { |
207 | /* | 207 | /* |
208 | ** Its worth trying the operation... | 208 | ** Its worth trying the operation... |
209 | */ | 209 | */ |
210 | struct CmdBlk *CmdBlkP; | 210 | struct CmdBlk *CmdBlkP; |
211 | 211 | ||
212 | rio_dprintk(RIO_DEBUG_CMD, "IDENTIFY RTA\n"); | 212 | rio_dprintk(RIO_DEBUG_CMD, "IDENTIFY RTA\n"); |
213 | 213 | ||
214 | CmdBlkP = RIOGetCmdBlk(); | 214 | CmdBlkP = RIOGetCmdBlk(); |
215 | 215 | ||
216 | if (!CmdBlkP) { | 216 | if (!CmdBlkP) { |
217 | rio_dprintk(RIO_DEBUG_CMD, "IDENTIFY RTA: GetCmdBlk failed\n"); | 217 | rio_dprintk(RIO_DEBUG_CMD, "IDENTIFY RTA: GetCmdBlk failed\n"); |
218 | return -ENXIO; | 218 | return -ENXIO; |
219 | } | 219 | } |
220 | 220 | ||
221 | CmdBlkP->Packet.dest_unit = MapP->ID; | 221 | CmdBlkP->Packet.dest_unit = MapP->ID; |
222 | CmdBlkP->Packet.dest_port = BOOT_RUP; | 222 | CmdBlkP->Packet.dest_port = BOOT_RUP; |
223 | CmdBlkP->Packet.src_unit = 0; | 223 | CmdBlkP->Packet.src_unit = 0; |
224 | CmdBlkP->Packet.src_port = BOOT_RUP; | 224 | CmdBlkP->Packet.src_port = BOOT_RUP; |
225 | CmdBlkP->Packet.len = 0x84; | 225 | CmdBlkP->Packet.len = 0x84; |
226 | CmdBlkP->Packet.data[0] = IDENTIFY; | 226 | CmdBlkP->Packet.data[0] = IDENTIFY; |
227 | CmdBlkP->Packet.data[1] = 0; | 227 | CmdBlkP->Packet.data[1] = 0; |
228 | CmdBlkP->Packet.data[2] = IdRta.ID; | 228 | CmdBlkP->Packet.data[2] = IdRta.ID; |
229 | 229 | ||
230 | if (RIOQueueCmdBlk(HostP, MapP->ID - 1, CmdBlkP) == RIO_FAIL) { | 230 | if (RIOQueueCmdBlk(HostP, MapP->ID - 1, CmdBlkP) == RIO_FAIL) { |
231 | rio_dprintk(RIO_DEBUG_CMD, "IDENTIFY RTA: Failed to queue command\n"); | 231 | rio_dprintk(RIO_DEBUG_CMD, "IDENTIFY RTA: Failed to queue command\n"); |
232 | return -EIO; | 232 | return -EIO; |
233 | } | 233 | } |
234 | return 0; | 234 | return 0; |
235 | } | 235 | } |
236 | } | 236 | } |
237 | } | 237 | } |
238 | } | 238 | } |
239 | } | 239 | } |
240 | return -ENOENT; | 240 | return -ENOENT; |
241 | } | 241 | } |
242 | 242 | ||
243 | 243 | ||
244 | int RIOKillNeighbour(struct rio_info *p, void __user * arg) | 244 | int RIOKillNeighbour(struct rio_info *p, void __user * arg) |
245 | { | 245 | { |
246 | uint Host; | 246 | uint Host; |
247 | uint ID; | 247 | uint ID; |
248 | struct Host *HostP; | 248 | struct Host *HostP; |
249 | struct CmdBlk *CmdBlkP; | 249 | struct CmdBlk *CmdBlkP; |
250 | 250 | ||
251 | rio_dprintk(RIO_DEBUG_CMD, "KILL HOST NEIGHBOUR\n"); | 251 | rio_dprintk(RIO_DEBUG_CMD, "KILL HOST NEIGHBOUR\n"); |
252 | 252 | ||
253 | if (copy_from_user(&KillUnit, arg, sizeof(KillUnit))) { | 253 | if (copy_from_user(&KillUnit, arg, sizeof(KillUnit))) { |
254 | rio_dprintk(RIO_DEBUG_CMD, "RIO_KILL_NEIGHBOUR copy failed\n"); | 254 | rio_dprintk(RIO_DEBUG_CMD, "RIO_KILL_NEIGHBOUR copy failed\n"); |
255 | p->RIOError.Error = COPYIN_FAILED; | 255 | p->RIOError.Error = COPYIN_FAILED; |
256 | return -EFAULT; | 256 | return -EFAULT; |
257 | } | 257 | } |
258 | 258 | ||
259 | if (KillUnit.Link > 3) | 259 | if (KillUnit.Link > 3) |
260 | return -ENXIO; | 260 | return -ENXIO; |
261 | 261 | ||
262 | CmdBlkP = RIOGetCmdBlk(); | 262 | CmdBlkP = RIOGetCmdBlk(); |
263 | 263 | ||
264 | if (!CmdBlkP) { | 264 | if (!CmdBlkP) { |
265 | rio_dprintk(RIO_DEBUG_CMD, "UFOAD: GetCmdBlk failed\n"); | 265 | rio_dprintk(RIO_DEBUG_CMD, "UFOAD: GetCmdBlk failed\n"); |
266 | return -ENXIO; | 266 | return -ENXIO; |
267 | } | 267 | } |
268 | 268 | ||
269 | CmdBlkP->Packet.dest_unit = 0; | 269 | CmdBlkP->Packet.dest_unit = 0; |
270 | CmdBlkP->Packet.src_unit = 0; | 270 | CmdBlkP->Packet.src_unit = 0; |
271 | CmdBlkP->Packet.dest_port = BOOT_RUP; | 271 | CmdBlkP->Packet.dest_port = BOOT_RUP; |
272 | CmdBlkP->Packet.src_port = BOOT_RUP; | 272 | CmdBlkP->Packet.src_port = BOOT_RUP; |
273 | CmdBlkP->Packet.len = 0x84; | 273 | CmdBlkP->Packet.len = 0x84; |
274 | CmdBlkP->Packet.data[0] = UFOAD; | 274 | CmdBlkP->Packet.data[0] = UFOAD; |
275 | CmdBlkP->Packet.data[1] = KillUnit.Link; | 275 | CmdBlkP->Packet.data[1] = KillUnit.Link; |
276 | CmdBlkP->Packet.data[2] = UFOAD_MAGIC & 0xFF; | 276 | CmdBlkP->Packet.data[2] = UFOAD_MAGIC & 0xFF; |
277 | CmdBlkP->Packet.data[3] = (UFOAD_MAGIC >> 8) & 0xFF; | 277 | CmdBlkP->Packet.data[3] = (UFOAD_MAGIC >> 8) & 0xFF; |
278 | 278 | ||
279 | for (Host = 0; Host < p->RIONumHosts; Host++) { | 279 | for (Host = 0; Host < p->RIONumHosts; Host++) { |
280 | ID = 0; | 280 | ID = 0; |
281 | HostP = &p->RIOHosts[Host]; | 281 | HostP = &p->RIOHosts[Host]; |
282 | 282 | ||
283 | if (HostP->UniqueNum == KillUnit.UniqueNum) { | 283 | if (HostP->UniqueNum == KillUnit.UniqueNum) { |
284 | if (RIOQueueCmdBlk(HostP, RTAS_PER_HOST + KillUnit.Link, CmdBlkP) == RIO_FAIL) { | 284 | if (RIOQueueCmdBlk(HostP, RTAS_PER_HOST + KillUnit.Link, CmdBlkP) == RIO_FAIL) { |
285 | rio_dprintk(RIO_DEBUG_CMD, "UFOAD: Failed queue command\n"); | 285 | rio_dprintk(RIO_DEBUG_CMD, "UFOAD: Failed queue command\n"); |
286 | return -EIO; | 286 | return -EIO; |
287 | } | 287 | } |
288 | return 0; | 288 | return 0; |
289 | } | 289 | } |
290 | 290 | ||
291 | for (ID = 0; ID < RTAS_PER_HOST; ID++) { | 291 | for (ID = 0; ID < RTAS_PER_HOST; ID++) { |
292 | if (HostP->Mapping[ID].RtaUniqueNum == KillUnit.UniqueNum) { | 292 | if (HostP->Mapping[ID].RtaUniqueNum == KillUnit.UniqueNum) { |
293 | CmdBlkP->Packet.dest_unit = ID + 1; | 293 | CmdBlkP->Packet.dest_unit = ID + 1; |
294 | if (RIOQueueCmdBlk(HostP, ID, CmdBlkP) == RIO_FAIL) { | 294 | if (RIOQueueCmdBlk(HostP, ID, CmdBlkP) == RIO_FAIL) { |
295 | rio_dprintk(RIO_DEBUG_CMD, "UFOAD: Failed queue command\n"); | 295 | rio_dprintk(RIO_DEBUG_CMD, "UFOAD: Failed queue command\n"); |
296 | return -EIO; | 296 | return -EIO; |
297 | } | 297 | } |
298 | return 0; | 298 | return 0; |
299 | } | 299 | } |
300 | } | 300 | } |
301 | } | 301 | } |
302 | RIOFreeCmdBlk(CmdBlkP); | 302 | RIOFreeCmdBlk(CmdBlkP); |
303 | return -ENXIO; | 303 | return -ENXIO; |
304 | } | 304 | } |
305 | 305 | ||
306 | int RIOSuspendBootRta(struct Host *HostP, int ID, int Link) | 306 | int RIOSuspendBootRta(struct Host *HostP, int ID, int Link) |
307 | { | 307 | { |
308 | struct CmdBlk *CmdBlkP; | 308 | struct CmdBlk *CmdBlkP; |
309 | 309 | ||
310 | rio_dprintk(RIO_DEBUG_CMD, "SUSPEND BOOT ON RTA ID %d, link %c\n", ID, 'A' + Link); | 310 | rio_dprintk(RIO_DEBUG_CMD, "SUSPEND BOOT ON RTA ID %d, link %c\n", ID, 'A' + Link); |
311 | 311 | ||
312 | CmdBlkP = RIOGetCmdBlk(); | 312 | CmdBlkP = RIOGetCmdBlk(); |
313 | 313 | ||
314 | if (!CmdBlkP) { | 314 | if (!CmdBlkP) { |
315 | rio_dprintk(RIO_DEBUG_CMD, "SUSPEND BOOT ON RTA: GetCmdBlk failed\n"); | 315 | rio_dprintk(RIO_DEBUG_CMD, "SUSPEND BOOT ON RTA: GetCmdBlk failed\n"); |
316 | return -ENXIO; | 316 | return -ENXIO; |
317 | } | 317 | } |
318 | 318 | ||
319 | CmdBlkP->Packet.dest_unit = ID; | 319 | CmdBlkP->Packet.dest_unit = ID; |
320 | CmdBlkP->Packet.dest_port = BOOT_RUP; | 320 | CmdBlkP->Packet.dest_port = BOOT_RUP; |
321 | CmdBlkP->Packet.src_unit = 0; | 321 | CmdBlkP->Packet.src_unit = 0; |
322 | CmdBlkP->Packet.src_port = BOOT_RUP; | 322 | CmdBlkP->Packet.src_port = BOOT_RUP; |
323 | CmdBlkP->Packet.len = 0x84; | 323 | CmdBlkP->Packet.len = 0x84; |
324 | CmdBlkP->Packet.data[0] = IWAIT; | 324 | CmdBlkP->Packet.data[0] = IWAIT; |
325 | CmdBlkP->Packet.data[1] = Link; | 325 | CmdBlkP->Packet.data[1] = Link; |
326 | CmdBlkP->Packet.data[2] = IWAIT_MAGIC & 0xFF; | 326 | CmdBlkP->Packet.data[2] = IWAIT_MAGIC & 0xFF; |
327 | CmdBlkP->Packet.data[3] = (IWAIT_MAGIC >> 8) & 0xFF; | 327 | CmdBlkP->Packet.data[3] = (IWAIT_MAGIC >> 8) & 0xFF; |
328 | 328 | ||
329 | if (RIOQueueCmdBlk(HostP, ID - 1, CmdBlkP) == RIO_FAIL) { | 329 | if (RIOQueueCmdBlk(HostP, ID - 1, CmdBlkP) == RIO_FAIL) { |
330 | rio_dprintk(RIO_DEBUG_CMD, "SUSPEND BOOT ON RTA: Failed to queue iwait command\n"); | 330 | rio_dprintk(RIO_DEBUG_CMD, "SUSPEND BOOT ON RTA: Failed to queue iwait command\n"); |
331 | return -EIO; | 331 | return -EIO; |
332 | } | 332 | } |
333 | return 0; | 333 | return 0; |
334 | } | 334 | } |
335 | 335 | ||
336 | int RIOFoadWakeup(struct rio_info *p) | 336 | int RIOFoadWakeup(struct rio_info *p) |
337 | { | 337 | { |
338 | int port; | 338 | int port; |
339 | struct Port *PortP; | 339 | struct Port *PortP; |
340 | unsigned long flags; | 340 | unsigned long flags; |
341 | 341 | ||
342 | for (port = 0; port < RIO_PORTS; port++) { | 342 | for (port = 0; port < RIO_PORTS; port++) { |
343 | PortP = p->RIOPortp[port]; | 343 | PortP = p->RIOPortp[port]; |
344 | 344 | ||
345 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 345 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
346 | PortP->Config = 0; | 346 | PortP->Config = 0; |
347 | PortP->State = 0; | 347 | PortP->State = 0; |
348 | PortP->InUse = NOT_INUSE; | 348 | PortP->InUse = NOT_INUSE; |
349 | PortP->PortState = 0; | 349 | PortP->PortState = 0; |
350 | PortP->FlushCmdBodge = 0; | 350 | PortP->FlushCmdBodge = 0; |
351 | PortP->ModemLines = 0; | 351 | PortP->ModemLines = 0; |
352 | PortP->ModemState = 0; | 352 | PortP->ModemState = 0; |
353 | PortP->CookMode = 0; | 353 | PortP->CookMode = 0; |
354 | PortP->ParamSem = 0; | 354 | PortP->ParamSem = 0; |
355 | PortP->Mapped = 0; | 355 | PortP->Mapped = 0; |
356 | PortP->WflushFlag = 0; | 356 | PortP->WflushFlag = 0; |
357 | PortP->MagicFlags = 0; | 357 | PortP->MagicFlags = 0; |
358 | PortP->RxDataStart = 0; | 358 | PortP->RxDataStart = 0; |
359 | PortP->TxBufferIn = 0; | 359 | PortP->TxBufferIn = 0; |
360 | PortP->TxBufferOut = 0; | 360 | PortP->TxBufferOut = 0; |
361 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 361 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
362 | } | 362 | } |
363 | return (0); | 363 | return (0); |
364 | } | 364 | } |
365 | 365 | ||
366 | /* | 366 | /* |
367 | ** Incoming command on the COMMAND_RUP to be processed. | 367 | ** Incoming command on the COMMAND_RUP to be processed. |
368 | */ | 368 | */ |
369 | static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struct PKT __iomem *PacketP) | 369 | static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struct PKT __iomem *PacketP) |
370 | { | 370 | { |
371 | struct PktCmd __iomem *PktCmdP = (struct PktCmd __iomem *)PacketP->data; | 371 | struct PktCmd __iomem *PktCmdP = (struct PktCmd __iomem *)PacketP->data; |
372 | struct Port *PortP; | 372 | struct Port *PortP; |
373 | struct UnixRup *UnixRupP; | 373 | struct UnixRup *UnixRupP; |
374 | unsigned short SysPort; | 374 | unsigned short SysPort; |
375 | unsigned short ReportedModemStatus; | 375 | unsigned short ReportedModemStatus; |
376 | unsigned short rup; | 376 | unsigned short rup; |
377 | unsigned short subCommand; | 377 | unsigned short subCommand; |
378 | unsigned long flags; | 378 | unsigned long flags; |
379 | 379 | ||
380 | func_enter(); | 380 | func_enter(); |
381 | 381 | ||
382 | /* | 382 | /* |
383 | ** 16 port RTA note: | 383 | ** 16 port RTA note: |
384 | ** Command rup packets coming from the RTA will have pkt->data[1] (which | 384 | ** Command rup packets coming from the RTA will have pkt->data[1] (which |
385 | ** translates to PktCmdP->PhbNum) set to the host port number for the | 385 | ** translates to PktCmdP->PhbNum) set to the host port number for the |
386 | ** particular unit. To access the correct BaseSysPort for a 16 port RTA, | 386 | ** particular unit. To access the correct BaseSysPort for a 16 port RTA, |
387 | ** we can use PhbNum to get the rup number for the appropriate 8 port | 387 | ** we can use PhbNum to get the rup number for the appropriate 8 port |
388 | ** block (for the first block, this should be equal to 'Rup'). | 388 | ** block (for the first block, this should be equal to 'Rup'). |
389 | */ | 389 | */ |
390 | rup = readb(&PktCmdP->PhbNum) / (unsigned short) PORTS_PER_RTA; | 390 | rup = readb(&PktCmdP->PhbNum) / (unsigned short) PORTS_PER_RTA; |
391 | UnixRupP = &HostP->UnixRups[rup]; | 391 | UnixRupP = &HostP->UnixRups[rup]; |
392 | SysPort = UnixRupP->BaseSysPort + (readb(&PktCmdP->PhbNum) % (unsigned short) PORTS_PER_RTA); | 392 | SysPort = UnixRupP->BaseSysPort + (readb(&PktCmdP->PhbNum) % (unsigned short) PORTS_PER_RTA); |
393 | rio_dprintk(RIO_DEBUG_CMD, "Command on rup %d, port %d\n", rup, SysPort); | 393 | rio_dprintk(RIO_DEBUG_CMD, "Command on rup %d, port %d\n", rup, SysPort); |
394 | 394 | ||
395 | if (UnixRupP->BaseSysPort == NO_PORT) { | 395 | if (UnixRupP->BaseSysPort == NO_PORT) { |
396 | rio_dprintk(RIO_DEBUG_CMD, "OBSCURE ERROR!\n"); | 396 | rio_dprintk(RIO_DEBUG_CMD, "OBSCURE ERROR!\n"); |
397 | rio_dprintk(RIO_DEBUG_CMD, "Diagnostics follow. Please WRITE THESE DOWN and report them to Specialix Technical Support\n"); | 397 | rio_dprintk(RIO_DEBUG_CMD, "Diagnostics follow. Please WRITE THESE DOWN and report them to Specialix Technical Support\n"); |
398 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %Zd, name ``%s''\n", HostP - p->RIOHosts, HostP->Name); | 398 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %Zd, name ``%s''\n", HostP - p->RIOHosts, HostP->Name); |
399 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Rup number 0x%x\n", rup); | 399 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Rup number 0x%x\n", rup); |
400 | 400 | ||
401 | if (Rup < (unsigned short) MAX_RUP) { | 401 | if (Rup < (unsigned short) MAX_RUP) { |
402 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n", HostP->Mapping[Rup].Name); | 402 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n", HostP->Mapping[Rup].Name); |
403 | } else | 403 | } else |
404 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", ('A' + Rup - MAX_RUP), HostP->Name); | 404 | rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", ('A' + Rup - MAX_RUP), HostP->Name); |
405 | 405 | ||
406 | rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Destination 0x%x:0x%x\n", readb(&PacketP->dest_unit), readb(&PacketP->dest_port)); | 406 | rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Destination 0x%x:0x%x\n", readb(&PacketP->dest_unit), readb(&PacketP->dest_port)); |
407 | rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Source 0x%x:0x%x\n", readb(&PacketP->src_unit), readb(&PacketP->src_port)); | 407 | rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Source 0x%x:0x%x\n", readb(&PacketP->src_unit), readb(&PacketP->src_port)); |
408 | rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Length 0x%x (%d)\n", readb(&PacketP->len), readb(&PacketP->len)); | 408 | rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Length 0x%x (%d)\n", readb(&PacketP->len), readb(&PacketP->len)); |
409 | rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Control 0x%x (%d)\n", readb(&PacketP->control), readb(&PacketP->control)); | 409 | rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Control 0x%x (%d)\n", readb(&PacketP->control), readb(&PacketP->control)); |
410 | rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Check 0x%x (%d)\n", readw(&PacketP->csum), readw(&PacketP->csum)); | 410 | rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Check 0x%x (%d)\n", readw(&PacketP->csum), readw(&PacketP->csum)); |
411 | rio_dprintk(RIO_DEBUG_CMD, "COMMAND information: Host Port Number 0x%x, " "Command Code 0x%x\n", readb(&PktCmdP->PhbNum), readb(&PktCmdP->Command)); | 411 | rio_dprintk(RIO_DEBUG_CMD, "COMMAND information: Host Port Number 0x%x, " "Command Code 0x%x\n", readb(&PktCmdP->PhbNum), readb(&PktCmdP->Command)); |
412 | return 1; | 412 | return 1; |
413 | } | 413 | } |
414 | PortP = p->RIOPortp[SysPort]; | 414 | PortP = p->RIOPortp[SysPort]; |
415 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 415 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
416 | switch (readb(&PktCmdP->Command)) { | 416 | switch (readb(&PktCmdP->Command)) { |
417 | case RIOC_BREAK_RECEIVED: | 417 | case RIOC_BREAK_RECEIVED: |
418 | rio_dprintk(RIO_DEBUG_CMD, "Received a break!\n"); | 418 | rio_dprintk(RIO_DEBUG_CMD, "Received a break!\n"); |
419 | /* If the current line disc. is not multi-threading and | 419 | /* If the current line disc. is not multi-threading and |
420 | the current processor is not the default, reset rup_intr | 420 | the current processor is not the default, reset rup_intr |
421 | and return 0 to ensure that the command packet is | 421 | and return 0 to ensure that the command packet is |
422 | not freed. */ | 422 | not freed. */ |
423 | /* Call tmgr HANGUP HERE */ | 423 | /* Call tmgr HANGUP HERE */ |
424 | /* Fix this later when every thing works !!!! RAMRAJ */ | 424 | /* Fix this later when every thing works !!!! RAMRAJ */ |
425 | gs_got_break(&PortP->gs); | 425 | gs_got_break(&PortP->gs); |
426 | break; | 426 | break; |
427 | 427 | ||
428 | case RIOC_COMPLETE: | 428 | case RIOC_COMPLETE: |
429 | rio_dprintk(RIO_DEBUG_CMD, "Command complete on phb %d host %Zd\n", readb(&PktCmdP->PhbNum), HostP - p->RIOHosts); | 429 | rio_dprintk(RIO_DEBUG_CMD, "Command complete on phb %d host %Zd\n", readb(&PktCmdP->PhbNum), HostP - p->RIOHosts); |
430 | subCommand = 1; | 430 | subCommand = 1; |
431 | switch (readb(&PktCmdP->SubCommand)) { | 431 | switch (readb(&PktCmdP->SubCommand)) { |
432 | case RIOC_MEMDUMP: | 432 | case RIOC_MEMDUMP: |
433 | rio_dprintk(RIO_DEBUG_CMD, "Memory dump cmd (0x%x) from addr 0x%x\n", readb(&PktCmdP->SubCommand), readw(&PktCmdP->SubAddr)); | 433 | rio_dprintk(RIO_DEBUG_CMD, "Memory dump cmd (0x%x) from addr 0x%x\n", readb(&PktCmdP->SubCommand), readw(&PktCmdP->SubAddr)); |
434 | break; | 434 | break; |
435 | case RIOC_READ_REGISTER: | 435 | case RIOC_READ_REGISTER: |
436 | rio_dprintk(RIO_DEBUG_CMD, "Read register (0x%x)\n", readw(&PktCmdP->SubAddr)); | 436 | rio_dprintk(RIO_DEBUG_CMD, "Read register (0x%x)\n", readw(&PktCmdP->SubAddr)); |
437 | p->CdRegister = (readb(&PktCmdP->ModemStatus) & RIOC_MSVR1_HOST); | 437 | p->CdRegister = (readb(&PktCmdP->ModemStatus) & RIOC_MSVR1_HOST); |
438 | break; | 438 | break; |
439 | default: | 439 | default: |
440 | subCommand = 0; | 440 | subCommand = 0; |
441 | break; | 441 | break; |
442 | } | 442 | } |
443 | if (subCommand) | 443 | if (subCommand) |
444 | break; | 444 | break; |
445 | rio_dprintk(RIO_DEBUG_CMD, "New status is 0x%x was 0x%x\n", readb(&PktCmdP->PortStatus), PortP->PortState); | 445 | rio_dprintk(RIO_DEBUG_CMD, "New status is 0x%x was 0x%x\n", readb(&PktCmdP->PortStatus), PortP->PortState); |
446 | if (PortP->PortState != readb(&PktCmdP->PortStatus)) { | 446 | if (PortP->PortState != readb(&PktCmdP->PortStatus)) { |
447 | rio_dprintk(RIO_DEBUG_CMD, "Mark status & wakeup\n"); | 447 | rio_dprintk(RIO_DEBUG_CMD, "Mark status & wakeup\n"); |
448 | PortP->PortState = readb(&PktCmdP->PortStatus); | 448 | PortP->PortState = readb(&PktCmdP->PortStatus); |
449 | /* What should we do here ... | 449 | /* What should we do here ... |
450 | wakeup( &PortP->PortState ); | 450 | wakeup( &PortP->PortState ); |
451 | */ | 451 | */ |
452 | } else | 452 | } else |
453 | rio_dprintk(RIO_DEBUG_CMD, "No change\n"); | 453 | rio_dprintk(RIO_DEBUG_CMD, "No change\n"); |
454 | 454 | ||
455 | /* FALLTHROUGH */ | 455 | /* FALLTHROUGH */ |
456 | case RIOC_MODEM_STATUS: | 456 | case RIOC_MODEM_STATUS: |
457 | /* | 457 | /* |
458 | ** Knock out the tbusy and tstop bits, as these are not relevant | 458 | ** Knock out the tbusy and tstop bits, as these are not relevant |
459 | ** to the check for modem status change (they're just there because | 459 | ** to the check for modem status change (they're just there because |
460 | ** it's a convenient place to put them!). | 460 | ** it's a convenient place to put them!). |
461 | */ | 461 | */ |
462 | ReportedModemStatus = readb(&PktCmdP->ModemStatus); | 462 | ReportedModemStatus = readb(&PktCmdP->ModemStatus); |
463 | if ((PortP->ModemState & RIOC_MSVR1_HOST) == | 463 | if ((PortP->ModemState & RIOC_MSVR1_HOST) == |
464 | (ReportedModemStatus & RIOC_MSVR1_HOST)) { | 464 | (ReportedModemStatus & RIOC_MSVR1_HOST)) { |
465 | rio_dprintk(RIO_DEBUG_CMD, "Modem status unchanged 0x%x\n", PortP->ModemState); | 465 | rio_dprintk(RIO_DEBUG_CMD, "Modem status unchanged 0x%x\n", PortP->ModemState); |
466 | /* | 466 | /* |
467 | ** Update ModemState just in case tbusy or tstop states have | 467 | ** Update ModemState just in case tbusy or tstop states have |
468 | ** changed. | 468 | ** changed. |
469 | */ | 469 | */ |
470 | PortP->ModemState = ReportedModemStatus; | 470 | PortP->ModemState = ReportedModemStatus; |
471 | } else { | 471 | } else { |
472 | rio_dprintk(RIO_DEBUG_CMD, "Modem status change from 0x%x to 0x%x\n", PortP->ModemState, ReportedModemStatus); | 472 | rio_dprintk(RIO_DEBUG_CMD, "Modem status change from 0x%x to 0x%x\n", PortP->ModemState, ReportedModemStatus); |
473 | PortP->ModemState = ReportedModemStatus; | 473 | PortP->ModemState = ReportedModemStatus; |
474 | #ifdef MODEM_SUPPORT | 474 | #ifdef MODEM_SUPPORT |
475 | if (PortP->Mapped) { | 475 | if (PortP->Mapped) { |
476 | /***********************************************************\ | 476 | /***********************************************************\ |
477 | ************************************************************* | 477 | ************************************************************* |
478 | *** *** | 478 | *** *** |
479 | *** M O D E M S T A T E C H A N G E *** | 479 | *** M O D E M S T A T E C H A N G E *** |
480 | *** *** | 480 | *** *** |
481 | ************************************************************* | 481 | ************************************************************* |
482 | \***********************************************************/ | 482 | \***********************************************************/ |
483 | /* | 483 | /* |
484 | ** If the device is a modem, then check the modem | 484 | ** If the device is a modem, then check the modem |
485 | ** carrier. | 485 | ** carrier. |
486 | */ | 486 | */ |
487 | if (PortP->gs.tty == NULL) | 487 | if (PortP->gs.port.tty == NULL) |
488 | break; | 488 | break; |
489 | if (PortP->gs.tty->termios == NULL) | 489 | if (PortP->gs.port.tty->termios == NULL) |
490 | break; | 490 | break; |
491 | 491 | ||
492 | if (!(PortP->gs.tty->termios->c_cflag & CLOCAL) && ((PortP->State & (RIO_MOPEN | RIO_WOPEN)))) { | 492 | if (!(PortP->gs.port.tty->termios->c_cflag & CLOCAL) && ((PortP->State & (RIO_MOPEN | RIO_WOPEN)))) { |
493 | 493 | ||
494 | rio_dprintk(RIO_DEBUG_CMD, "Is there a Carrier?\n"); | 494 | rio_dprintk(RIO_DEBUG_CMD, "Is there a Carrier?\n"); |
495 | /* | 495 | /* |
496 | ** Is there a carrier? | 496 | ** Is there a carrier? |
497 | */ | 497 | */ |
498 | if (PortP->ModemState & RIOC_MSVR1_CD) { | 498 | if (PortP->ModemState & RIOC_MSVR1_CD) { |
499 | /* | 499 | /* |
500 | ** Has carrier just appeared? | 500 | ** Has carrier just appeared? |
501 | */ | 501 | */ |
502 | if (!(PortP->State & RIO_CARR_ON)) { | 502 | if (!(PortP->State & RIO_CARR_ON)) { |
503 | rio_dprintk(RIO_DEBUG_CMD, "Carrier just came up.\n"); | 503 | rio_dprintk(RIO_DEBUG_CMD, "Carrier just came up.\n"); |
504 | PortP->State |= RIO_CARR_ON; | 504 | PortP->State |= RIO_CARR_ON; |
505 | /* | 505 | /* |
506 | ** wakeup anyone in WOPEN | 506 | ** wakeup anyone in WOPEN |
507 | */ | 507 | */ |
508 | if (PortP->State & (PORT_ISOPEN | RIO_WOPEN)) | 508 | if (PortP->State & (PORT_ISOPEN | RIO_WOPEN)) |
509 | wake_up_interruptible(&PortP->gs.open_wait); | 509 | wake_up_interruptible(&PortP->gs.port.open_wait); |
510 | } | 510 | } |
511 | } else { | 511 | } else { |
512 | /* | 512 | /* |
513 | ** Has carrier just dropped? | 513 | ** Has carrier just dropped? |
514 | */ | 514 | */ |
515 | if (PortP->State & RIO_CARR_ON) { | 515 | if (PortP->State & RIO_CARR_ON) { |
516 | if (PortP->State & (PORT_ISOPEN | RIO_WOPEN | RIO_MOPEN)) | 516 | if (PortP->State & (PORT_ISOPEN | RIO_WOPEN | RIO_MOPEN)) |
517 | tty_hangup(PortP->gs.tty); | 517 | tty_hangup(PortP->gs.port.tty); |
518 | PortP->State &= ~RIO_CARR_ON; | 518 | PortP->State &= ~RIO_CARR_ON; |
519 | rio_dprintk(RIO_DEBUG_CMD, "Carrirer just went down\n"); | 519 | rio_dprintk(RIO_DEBUG_CMD, "Carrirer just went down\n"); |
520 | } | 520 | } |
521 | } | 521 | } |
522 | } | 522 | } |
523 | } | 523 | } |
524 | #endif | 524 | #endif |
525 | } | 525 | } |
526 | break; | 526 | break; |
527 | 527 | ||
528 | default: | 528 | default: |
529 | rio_dprintk(RIO_DEBUG_CMD, "Unknown command %d on CMD_RUP of host %Zd\n", readb(&PktCmdP->Command), HostP - p->RIOHosts); | 529 | rio_dprintk(RIO_DEBUG_CMD, "Unknown command %d on CMD_RUP of host %Zd\n", readb(&PktCmdP->Command), HostP - p->RIOHosts); |
530 | break; | 530 | break; |
531 | } | 531 | } |
532 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 532 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
533 | 533 | ||
534 | func_exit(); | 534 | func_exit(); |
535 | 535 | ||
536 | return 1; | 536 | return 1; |
537 | } | 537 | } |
538 | 538 | ||
539 | /* | 539 | /* |
540 | ** The command mechanism: | 540 | ** The command mechanism: |
541 | ** Each rup has a chain of commands associated with it. | 541 | ** Each rup has a chain of commands associated with it. |
542 | ** This chain is maintained by routines in this file. | 542 | ** This chain is maintained by routines in this file. |
543 | ** Periodically we are called and we run a quick check of all the | 543 | ** Periodically we are called and we run a quick check of all the |
544 | ** active chains to determine if there is a command to be executed, | 544 | ** active chains to determine if there is a command to be executed, |
545 | ** and if the rup is ready to accept it. | 545 | ** and if the rup is ready to accept it. |
546 | ** | 546 | ** |
547 | */ | 547 | */ |
548 | 548 | ||
549 | /* | 549 | /* |
550 | ** Allocate an empty command block. | 550 | ** Allocate an empty command block. |
551 | */ | 551 | */ |
552 | struct CmdBlk *RIOGetCmdBlk(void) | 552 | struct CmdBlk *RIOGetCmdBlk(void) |
553 | { | 553 | { |
554 | struct CmdBlk *CmdBlkP; | 554 | struct CmdBlk *CmdBlkP; |
555 | 555 | ||
556 | CmdBlkP = kzalloc(sizeof(struct CmdBlk), GFP_ATOMIC); | 556 | CmdBlkP = kzalloc(sizeof(struct CmdBlk), GFP_ATOMIC); |
557 | return CmdBlkP; | 557 | return CmdBlkP; |
558 | } | 558 | } |
559 | 559 | ||
560 | /* | 560 | /* |
561 | ** Return a block to the head of the free list. | 561 | ** Return a block to the head of the free list. |
562 | */ | 562 | */ |
563 | void RIOFreeCmdBlk(struct CmdBlk *CmdBlkP) | 563 | void RIOFreeCmdBlk(struct CmdBlk *CmdBlkP) |
564 | { | 564 | { |
565 | kfree(CmdBlkP); | 565 | kfree(CmdBlkP); |
566 | } | 566 | } |
567 | 567 | ||
568 | /* | 568 | /* |
569 | ** attach a command block to the list of commands to be performed for | 569 | ** attach a command block to the list of commands to be performed for |
570 | ** a given rup. | 570 | ** a given rup. |
571 | */ | 571 | */ |
572 | int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP) | 572 | int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP) |
573 | { | 573 | { |
574 | struct CmdBlk **Base; | 574 | struct CmdBlk **Base; |
575 | struct UnixRup *UnixRupP; | 575 | struct UnixRup *UnixRupP; |
576 | unsigned long flags; | 576 | unsigned long flags; |
577 | 577 | ||
578 | if (Rup >= (unsigned short) (MAX_RUP + LINKS_PER_UNIT)) { | 578 | if (Rup >= (unsigned short) (MAX_RUP + LINKS_PER_UNIT)) { |
579 | rio_dprintk(RIO_DEBUG_CMD, "Illegal rup number %d in RIOQueueCmdBlk\n", Rup); | 579 | rio_dprintk(RIO_DEBUG_CMD, "Illegal rup number %d in RIOQueueCmdBlk\n", Rup); |
580 | RIOFreeCmdBlk(CmdBlkP); | 580 | RIOFreeCmdBlk(CmdBlkP); |
581 | return RIO_FAIL; | 581 | return RIO_FAIL; |
582 | } | 582 | } |
583 | 583 | ||
584 | UnixRupP = &HostP->UnixRups[Rup]; | 584 | UnixRupP = &HostP->UnixRups[Rup]; |
585 | 585 | ||
586 | rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); | 586 | rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); |
587 | 587 | ||
588 | /* | 588 | /* |
589 | ** If the RUP is currently inactive, then put the request | 589 | ** If the RUP is currently inactive, then put the request |
590 | ** straight on the RUP.... | 590 | ** straight on the RUP.... |
591 | */ | 591 | */ |
592 | if ((UnixRupP->CmdsWaitingP == NULL) && (UnixRupP->CmdPendingP == NULL) && (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE) && (CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) | 592 | if ((UnixRupP->CmdsWaitingP == NULL) && (UnixRupP->CmdPendingP == NULL) && (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE) && (CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) |
593 | : 1)) { | 593 | : 1)) { |
594 | rio_dprintk(RIO_DEBUG_CMD, "RUP inactive-placing command straight on. Cmd byte is 0x%x\n", CmdBlkP->Packet.data[0]); | 594 | rio_dprintk(RIO_DEBUG_CMD, "RUP inactive-placing command straight on. Cmd byte is 0x%x\n", CmdBlkP->Packet.data[0]); |
595 | 595 | ||
596 | /* | 596 | /* |
597 | ** Whammy! blat that pack! | 597 | ** Whammy! blat that pack! |
598 | */ | 598 | */ |
599 | HostP->Copy(&CmdBlkP->Packet, RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->txpkt)), sizeof(struct PKT)); | 599 | HostP->Copy(&CmdBlkP->Packet, RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->txpkt)), sizeof(struct PKT)); |
600 | 600 | ||
601 | /* | 601 | /* |
602 | ** place command packet on the pending position. | 602 | ** place command packet on the pending position. |
603 | */ | 603 | */ |
604 | UnixRupP->CmdPendingP = CmdBlkP; | 604 | UnixRupP->CmdPendingP = CmdBlkP; |
605 | 605 | ||
606 | /* | 606 | /* |
607 | ** set the command register | 607 | ** set the command register |
608 | */ | 608 | */ |
609 | writew(TX_PACKET_READY, &UnixRupP->RupP->txcontrol); | 609 | writew(TX_PACKET_READY, &UnixRupP->RupP->txcontrol); |
610 | 610 | ||
611 | rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); | 611 | rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); |
612 | 612 | ||
613 | return 0; | 613 | return 0; |
614 | } | 614 | } |
615 | rio_dprintk(RIO_DEBUG_CMD, "RUP active - en-queing\n"); | 615 | rio_dprintk(RIO_DEBUG_CMD, "RUP active - en-queing\n"); |
616 | 616 | ||
617 | if (UnixRupP->CmdsWaitingP != NULL) | 617 | if (UnixRupP->CmdsWaitingP != NULL) |
618 | rio_dprintk(RIO_DEBUG_CMD, "Rup active - command waiting\n"); | 618 | rio_dprintk(RIO_DEBUG_CMD, "Rup active - command waiting\n"); |
619 | if (UnixRupP->CmdPendingP != NULL) | 619 | if (UnixRupP->CmdPendingP != NULL) |
620 | rio_dprintk(RIO_DEBUG_CMD, "Rup active - command pending\n"); | 620 | rio_dprintk(RIO_DEBUG_CMD, "Rup active - command pending\n"); |
621 | if (readw(&UnixRupP->RupP->txcontrol) != TX_RUP_INACTIVE) | 621 | if (readw(&UnixRupP->RupP->txcontrol) != TX_RUP_INACTIVE) |
622 | rio_dprintk(RIO_DEBUG_CMD, "Rup active - command rup not ready\n"); | 622 | rio_dprintk(RIO_DEBUG_CMD, "Rup active - command rup not ready\n"); |
623 | 623 | ||
624 | Base = &UnixRupP->CmdsWaitingP; | 624 | Base = &UnixRupP->CmdsWaitingP; |
625 | 625 | ||
626 | rio_dprintk(RIO_DEBUG_CMD, "First try to queue cmdblk %p at %p\n", CmdBlkP, Base); | 626 | rio_dprintk(RIO_DEBUG_CMD, "First try to queue cmdblk %p at %p\n", CmdBlkP, Base); |
627 | 627 | ||
628 | while (*Base) { | 628 | while (*Base) { |
629 | rio_dprintk(RIO_DEBUG_CMD, "Command cmdblk %p here\n", *Base); | 629 | rio_dprintk(RIO_DEBUG_CMD, "Command cmdblk %p here\n", *Base); |
630 | Base = &((*Base)->NextP); | 630 | Base = &((*Base)->NextP); |
631 | rio_dprintk(RIO_DEBUG_CMD, "Now try to queue cmd cmdblk %p at %p\n", CmdBlkP, Base); | 631 | rio_dprintk(RIO_DEBUG_CMD, "Now try to queue cmd cmdblk %p at %p\n", CmdBlkP, Base); |
632 | } | 632 | } |
633 | 633 | ||
634 | rio_dprintk(RIO_DEBUG_CMD, "Will queue cmdblk %p at %p\n", CmdBlkP, Base); | 634 | rio_dprintk(RIO_DEBUG_CMD, "Will queue cmdblk %p at %p\n", CmdBlkP, Base); |
635 | 635 | ||
636 | *Base = CmdBlkP; | 636 | *Base = CmdBlkP; |
637 | 637 | ||
638 | CmdBlkP->NextP = NULL; | 638 | CmdBlkP->NextP = NULL; |
639 | 639 | ||
640 | rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); | 640 | rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); |
641 | 641 | ||
642 | return 0; | 642 | return 0; |
643 | } | 643 | } |
644 | 644 | ||
645 | /* | 645 | /* |
646 | ** Here we go - if there is an empty rup, fill it! | 646 | ** Here we go - if there is an empty rup, fill it! |
647 | ** must be called at splrio() or higher. | 647 | ** must be called at splrio() or higher. |
648 | */ | 648 | */ |
649 | void RIOPollHostCommands(struct rio_info *p, struct Host *HostP) | 649 | void RIOPollHostCommands(struct rio_info *p, struct Host *HostP) |
650 | { | 650 | { |
651 | struct CmdBlk *CmdBlkP; | 651 | struct CmdBlk *CmdBlkP; |
652 | struct UnixRup *UnixRupP; | 652 | struct UnixRup *UnixRupP; |
653 | struct PKT __iomem *PacketP; | 653 | struct PKT __iomem *PacketP; |
654 | unsigned short Rup; | 654 | unsigned short Rup; |
655 | unsigned long flags; | 655 | unsigned long flags; |
656 | 656 | ||
657 | 657 | ||
658 | Rup = MAX_RUP + LINKS_PER_UNIT; | 658 | Rup = MAX_RUP + LINKS_PER_UNIT; |
659 | 659 | ||
660 | do { /* do this loop for each RUP */ | 660 | do { /* do this loop for each RUP */ |
661 | /* | 661 | /* |
662 | ** locate the rup we are processing & lock it | 662 | ** locate the rup we are processing & lock it |
663 | */ | 663 | */ |
664 | UnixRupP = &HostP->UnixRups[--Rup]; | 664 | UnixRupP = &HostP->UnixRups[--Rup]; |
665 | 665 | ||
666 | spin_lock_irqsave(&UnixRupP->RupLock, flags); | 666 | spin_lock_irqsave(&UnixRupP->RupLock, flags); |
667 | 667 | ||
668 | /* | 668 | /* |
669 | ** First check for incoming commands: | 669 | ** First check for incoming commands: |
670 | */ | 670 | */ |
671 | if (readw(&UnixRupP->RupP->rxcontrol) != RX_RUP_INACTIVE) { | 671 | if (readw(&UnixRupP->RupP->rxcontrol) != RX_RUP_INACTIVE) { |
672 | int FreeMe; | 672 | int FreeMe; |
673 | 673 | ||
674 | PacketP = (struct PKT __iomem *) RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->rxpkt)); | 674 | PacketP = (struct PKT __iomem *) RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->rxpkt)); |
675 | 675 | ||
676 | switch (readb(&PacketP->dest_port)) { | 676 | switch (readb(&PacketP->dest_port)) { |
677 | case BOOT_RUP: | 677 | case BOOT_RUP: |
678 | rio_dprintk(RIO_DEBUG_CMD, "Incoming Boot %s packet '%x'\n", readb(&PacketP->len) & 0x80 ? "Command" : "Data", readb(&PacketP->data[0])); | 678 | rio_dprintk(RIO_DEBUG_CMD, "Incoming Boot %s packet '%x'\n", readb(&PacketP->len) & 0x80 ? "Command" : "Data", readb(&PacketP->data[0])); |
679 | rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); | 679 | rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); |
680 | FreeMe = RIOBootRup(p, Rup, HostP, PacketP); | 680 | FreeMe = RIOBootRup(p, Rup, HostP, PacketP); |
681 | rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); | 681 | rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); |
682 | break; | 682 | break; |
683 | 683 | ||
684 | case COMMAND_RUP: | 684 | case COMMAND_RUP: |
685 | /* | 685 | /* |
686 | ** Free the RUP lock as loss of carrier causes a | 686 | ** Free the RUP lock as loss of carrier causes a |
687 | ** ttyflush which will (eventually) call another | 687 | ** ttyflush which will (eventually) call another |
688 | ** routine that uses the RUP lock. | 688 | ** routine that uses the RUP lock. |
689 | */ | 689 | */ |
690 | rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); | 690 | rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); |
691 | FreeMe = RIOCommandRup(p, Rup, HostP, PacketP); | 691 | FreeMe = RIOCommandRup(p, Rup, HostP, PacketP); |
692 | if (readb(&PacketP->data[5]) == RIOC_MEMDUMP) { | 692 | if (readb(&PacketP->data[5]) == RIOC_MEMDUMP) { |
693 | rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", readw(&(PacketP->data[6]))); | 693 | rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", readw(&(PacketP->data[6]))); |
694 | rio_memcpy_fromio(p->RIOMemDump, &(PacketP->data[8]), 32); | 694 | rio_memcpy_fromio(p->RIOMemDump, &(PacketP->data[8]), 32); |
695 | } | 695 | } |
696 | rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); | 696 | rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); |
697 | break; | 697 | break; |
698 | 698 | ||
699 | case ROUTE_RUP: | 699 | case ROUTE_RUP: |
700 | rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); | 700 | rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); |
701 | FreeMe = RIORouteRup(p, Rup, HostP, PacketP); | 701 | FreeMe = RIORouteRup(p, Rup, HostP, PacketP); |
702 | rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); | 702 | rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); |
703 | break; | 703 | break; |
704 | 704 | ||
705 | default: | 705 | default: |
706 | rio_dprintk(RIO_DEBUG_CMD, "Unknown RUP %d\n", readb(&PacketP->dest_port)); | 706 | rio_dprintk(RIO_DEBUG_CMD, "Unknown RUP %d\n", readb(&PacketP->dest_port)); |
707 | FreeMe = 1; | 707 | FreeMe = 1; |
708 | break; | 708 | break; |
709 | } | 709 | } |
710 | 710 | ||
711 | if (FreeMe) { | 711 | if (FreeMe) { |
712 | rio_dprintk(RIO_DEBUG_CMD, "Free processed incoming command packet\n"); | 712 | rio_dprintk(RIO_DEBUG_CMD, "Free processed incoming command packet\n"); |
713 | put_free_end(HostP, PacketP); | 713 | put_free_end(HostP, PacketP); |
714 | 714 | ||
715 | writew(RX_RUP_INACTIVE, &UnixRupP->RupP->rxcontrol); | 715 | writew(RX_RUP_INACTIVE, &UnixRupP->RupP->rxcontrol); |
716 | 716 | ||
717 | if (readw(&UnixRupP->RupP->handshake) == PHB_HANDSHAKE_SET) { | 717 | if (readw(&UnixRupP->RupP->handshake) == PHB_HANDSHAKE_SET) { |
718 | rio_dprintk(RIO_DEBUG_CMD, "Handshake rup %d\n", Rup); | 718 | rio_dprintk(RIO_DEBUG_CMD, "Handshake rup %d\n", Rup); |
719 | writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &UnixRupP->RupP->handshake); | 719 | writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &UnixRupP->RupP->handshake); |
720 | } | 720 | } |
721 | } | 721 | } |
722 | } | 722 | } |
723 | 723 | ||
724 | /* | 724 | /* |
725 | ** IF a command was running on the port, | 725 | ** IF a command was running on the port, |
726 | ** and it has completed, then tidy it up. | 726 | ** and it has completed, then tidy it up. |
727 | */ | 727 | */ |
728 | if ((CmdBlkP = UnixRupP->CmdPendingP) && /* ASSIGN! */ | 728 | if ((CmdBlkP = UnixRupP->CmdPendingP) && /* ASSIGN! */ |
729 | (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) { | 729 | (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) { |
730 | /* | 730 | /* |
731 | ** we are idle. | 731 | ** we are idle. |
732 | ** there is a command in pending. | 732 | ** there is a command in pending. |
733 | ** Therefore, this command has finished. | 733 | ** Therefore, this command has finished. |
734 | ** So, wakeup whoever is waiting for it (and tell them | 734 | ** So, wakeup whoever is waiting for it (and tell them |
735 | ** what happened). | 735 | ** what happened). |
736 | */ | 736 | */ |
737 | if (CmdBlkP->Packet.dest_port == BOOT_RUP) | 737 | if (CmdBlkP->Packet.dest_port == BOOT_RUP) |
738 | rio_dprintk(RIO_DEBUG_CMD, "Free Boot %s Command Block '%x'\n", CmdBlkP->Packet.len & 0x80 ? "Command" : "Data", CmdBlkP->Packet.data[0]); | 738 | rio_dprintk(RIO_DEBUG_CMD, "Free Boot %s Command Block '%x'\n", CmdBlkP->Packet.len & 0x80 ? "Command" : "Data", CmdBlkP->Packet.data[0]); |
739 | 739 | ||
740 | rio_dprintk(RIO_DEBUG_CMD, "Command %p completed\n", CmdBlkP); | 740 | rio_dprintk(RIO_DEBUG_CMD, "Command %p completed\n", CmdBlkP); |
741 | 741 | ||
742 | /* | 742 | /* |
743 | ** Clear the Rup lock to prevent mutual exclusion. | 743 | ** Clear the Rup lock to prevent mutual exclusion. |
744 | */ | 744 | */ |
745 | if (CmdBlkP->PostFuncP) { | 745 | if (CmdBlkP->PostFuncP) { |
746 | rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); | 746 | rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); |
747 | (*CmdBlkP->PostFuncP) (CmdBlkP->PostArg, CmdBlkP); | 747 | (*CmdBlkP->PostFuncP) (CmdBlkP->PostArg, CmdBlkP); |
748 | rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); | 748 | rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); |
749 | } | 749 | } |
750 | 750 | ||
751 | /* | 751 | /* |
752 | ** ....clear the pending flag.... | 752 | ** ....clear the pending flag.... |
753 | */ | 753 | */ |
754 | UnixRupP->CmdPendingP = NULL; | 754 | UnixRupP->CmdPendingP = NULL; |
755 | 755 | ||
756 | /* | 756 | /* |
757 | ** ....and return the command block to the freelist. | 757 | ** ....and return the command block to the freelist. |
758 | */ | 758 | */ |
759 | RIOFreeCmdBlk(CmdBlkP); | 759 | RIOFreeCmdBlk(CmdBlkP); |
760 | } | 760 | } |
761 | 761 | ||
762 | /* | 762 | /* |
763 | ** If there is a command for this rup, and the rup | 763 | ** If there is a command for this rup, and the rup |
764 | ** is idle, then process the command | 764 | ** is idle, then process the command |
765 | */ | 765 | */ |
766 | if ((CmdBlkP = UnixRupP->CmdsWaitingP) && /* ASSIGN! */ | 766 | if ((CmdBlkP = UnixRupP->CmdsWaitingP) && /* ASSIGN! */ |
767 | (UnixRupP->CmdPendingP == NULL) && (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) { | 767 | (UnixRupP->CmdPendingP == NULL) && (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) { |
768 | /* | 768 | /* |
769 | ** if the pre-function is non-zero, call it. | 769 | ** if the pre-function is non-zero, call it. |
770 | ** If it returns RIO_FAIL then don't | 770 | ** If it returns RIO_FAIL then don't |
771 | ** send this command yet! | 771 | ** send this command yet! |
772 | */ | 772 | */ |
773 | if (!(CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) : 1)) { | 773 | if (!(CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) : 1)) { |
774 | rio_dprintk(RIO_DEBUG_CMD, "Not ready to start command %p\n", CmdBlkP); | 774 | rio_dprintk(RIO_DEBUG_CMD, "Not ready to start command %p\n", CmdBlkP); |
775 | } else { | 775 | } else { |
776 | rio_dprintk(RIO_DEBUG_CMD, "Start new command %p Cmd byte is 0x%x\n", CmdBlkP, CmdBlkP->Packet.data[0]); | 776 | rio_dprintk(RIO_DEBUG_CMD, "Start new command %p Cmd byte is 0x%x\n", CmdBlkP, CmdBlkP->Packet.data[0]); |
777 | /* | 777 | /* |
778 | ** Whammy! blat that pack! | 778 | ** Whammy! blat that pack! |
779 | */ | 779 | */ |
780 | HostP->Copy(&CmdBlkP->Packet, RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->txpkt)), sizeof(struct PKT)); | 780 | HostP->Copy(&CmdBlkP->Packet, RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->txpkt)), sizeof(struct PKT)); |
781 | 781 | ||
782 | /* | 782 | /* |
783 | ** remove the command from the rup command queue... | 783 | ** remove the command from the rup command queue... |
784 | */ | 784 | */ |
785 | UnixRupP->CmdsWaitingP = CmdBlkP->NextP; | 785 | UnixRupP->CmdsWaitingP = CmdBlkP->NextP; |
786 | 786 | ||
787 | /* | 787 | /* |
788 | ** ...and place it on the pending position. | 788 | ** ...and place it on the pending position. |
789 | */ | 789 | */ |
790 | UnixRupP->CmdPendingP = CmdBlkP; | 790 | UnixRupP->CmdPendingP = CmdBlkP; |
791 | 791 | ||
792 | /* | 792 | /* |
793 | ** set the command register | 793 | ** set the command register |
794 | */ | 794 | */ |
795 | writew(TX_PACKET_READY, &UnixRupP->RupP->txcontrol); | 795 | writew(TX_PACKET_READY, &UnixRupP->RupP->txcontrol); |
796 | 796 | ||
797 | /* | 797 | /* |
798 | ** the command block will be freed | 798 | ** the command block will be freed |
799 | ** when the command has been processed. | 799 | ** when the command has been processed. |
800 | */ | 800 | */ |
801 | } | 801 | } |
802 | } | 802 | } |
803 | spin_unlock_irqrestore(&UnixRupP->RupLock, flags); | 803 | spin_unlock_irqrestore(&UnixRupP->RupLock, flags); |
804 | } while (Rup); | 804 | } while (Rup); |
805 | } | 805 | } |
806 | 806 | ||
807 | int RIOWFlushMark(unsigned long iPortP, struct CmdBlk *CmdBlkP) | 807 | int RIOWFlushMark(unsigned long iPortP, struct CmdBlk *CmdBlkP) |
808 | { | 808 | { |
809 | struct Port *PortP = (struct Port *) iPortP; | 809 | struct Port *PortP = (struct Port *) iPortP; |
810 | unsigned long flags; | 810 | unsigned long flags; |
811 | 811 | ||
812 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 812 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
813 | PortP->WflushFlag++; | 813 | PortP->WflushFlag++; |
814 | PortP->MagicFlags |= MAGIC_FLUSH; | 814 | PortP->MagicFlags |= MAGIC_FLUSH; |
815 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 815 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
816 | return RIOUnUse(iPortP, CmdBlkP); | 816 | return RIOUnUse(iPortP, CmdBlkP); |
817 | } | 817 | } |
818 | 818 | ||
819 | int RIORFlushEnable(unsigned long iPortP, struct CmdBlk *CmdBlkP) | 819 | int RIORFlushEnable(unsigned long iPortP, struct CmdBlk *CmdBlkP) |
820 | { | 820 | { |
821 | struct Port *PortP = (struct Port *) iPortP; | 821 | struct Port *PortP = (struct Port *) iPortP; |
822 | struct PKT __iomem *PacketP; | 822 | struct PKT __iomem *PacketP; |
823 | unsigned long flags; | 823 | unsigned long flags; |
824 | 824 | ||
825 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 825 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
826 | 826 | ||
827 | while (can_remove_receive(&PacketP, PortP)) { | 827 | while (can_remove_receive(&PacketP, PortP)) { |
828 | remove_receive(PortP); | 828 | remove_receive(PortP); |
829 | put_free_end(PortP->HostP, PacketP); | 829 | put_free_end(PortP->HostP, PacketP); |
830 | } | 830 | } |
831 | 831 | ||
832 | if (readw(&PortP->PhbP->handshake) == PHB_HANDSHAKE_SET) { | 832 | if (readw(&PortP->PhbP->handshake) == PHB_HANDSHAKE_SET) { |
833 | /* | 833 | /* |
834 | ** MAGIC! (Basically, handshake the RX buffer, so that | 834 | ** MAGIC! (Basically, handshake the RX buffer, so that |
835 | ** the RTAs upstream can be re-enabled.) | 835 | ** the RTAs upstream can be re-enabled.) |
836 | */ | 836 | */ |
837 | rio_dprintk(RIO_DEBUG_CMD, "Util: Set RX handshake bit\n"); | 837 | rio_dprintk(RIO_DEBUG_CMD, "Util: Set RX handshake bit\n"); |
838 | writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &PortP->PhbP->handshake); | 838 | writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &PortP->PhbP->handshake); |
839 | } | 839 | } |
840 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 840 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
841 | return RIOUnUse(iPortP, CmdBlkP); | 841 | return RIOUnUse(iPortP, CmdBlkP); |
842 | } | 842 | } |
843 | 843 | ||
844 | int RIOUnUse(unsigned long iPortP, struct CmdBlk *CmdBlkP) | 844 | int RIOUnUse(unsigned long iPortP, struct CmdBlk *CmdBlkP) |
845 | { | 845 | { |
846 | struct Port *PortP = (struct Port *) iPortP; | 846 | struct Port *PortP = (struct Port *) iPortP; |
847 | unsigned long flags; | 847 | unsigned long flags; |
848 | 848 | ||
849 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 849 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
850 | 850 | ||
851 | rio_dprintk(RIO_DEBUG_CMD, "Decrement in use count for port\n"); | 851 | rio_dprintk(RIO_DEBUG_CMD, "Decrement in use count for port\n"); |
852 | 852 | ||
853 | if (PortP->InUse) { | 853 | if (PortP->InUse) { |
854 | if (--PortP->InUse != NOT_INUSE) { | 854 | if (--PortP->InUse != NOT_INUSE) { |
855 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 855 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
856 | return 0; | 856 | return 0; |
857 | } | 857 | } |
858 | } | 858 | } |
859 | /* | 859 | /* |
860 | ** While PortP->InUse is set (i.e. a preemptive command has been sent to | 860 | ** While PortP->InUse is set (i.e. a preemptive command has been sent to |
861 | ** the RTA and is awaiting completion), any transmit data is prevented from | 861 | ** the RTA and is awaiting completion), any transmit data is prevented from |
862 | ** being transferred from the write queue into the transmit packets | 862 | ** being transferred from the write queue into the transmit packets |
863 | ** (add_transmit) and no furthur transmit interrupt will be sent for that | 863 | ** (add_transmit) and no furthur transmit interrupt will be sent for that |
864 | ** data. The next interrupt will occur up to 500ms later (RIOIntr is called | 864 | ** data. The next interrupt will occur up to 500ms later (RIOIntr is called |
865 | ** twice a second as a saftey measure). This was the case when kermit was | 865 | ** twice a second as a saftey measure). This was the case when kermit was |
866 | ** used to send data into a RIO port. After each packet was sent, TCFLSH | 866 | ** used to send data into a RIO port. After each packet was sent, TCFLSH |
867 | ** was called to flush the read queue preemptively. PortP->InUse was | 867 | ** was called to flush the read queue preemptively. PortP->InUse was |
868 | ** incremented, thereby blocking the 6 byte acknowledgement packet | 868 | ** incremented, thereby blocking the 6 byte acknowledgement packet |
869 | ** transmitted back. This acknowledgment hung around for 500ms before | 869 | ** transmitted back. This acknowledgment hung around for 500ms before |
870 | ** being sent, thus reducing input performance substantially!. | 870 | ** being sent, thus reducing input performance substantially!. |
871 | ** When PortP->InUse becomes NOT_INUSE, we must ensure that any data | 871 | ** When PortP->InUse becomes NOT_INUSE, we must ensure that any data |
872 | ** hanging around in the transmit buffer is sent immediately. | 872 | ** hanging around in the transmit buffer is sent immediately. |
873 | */ | 873 | */ |
874 | writew(1, &PortP->HostP->ParmMapP->tx_intr); | 874 | writew(1, &PortP->HostP->ParmMapP->tx_intr); |
875 | /* What to do here .. | 875 | /* What to do here .. |
876 | wakeup( (caddr_t)&(PortP->InUse) ); | 876 | wakeup( (caddr_t)&(PortP->InUse) ); |
877 | */ | 877 | */ |
878 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 878 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
879 | return 0; | 879 | return 0; |
880 | } | 880 | } |
881 | 881 | ||
882 | /* | 882 | /* |
883 | ** | 883 | ** |
884 | ** How to use this file: | 884 | ** How to use this file: |
885 | ** | 885 | ** |
886 | ** To send a command down a rup, you need to allocate a command block, fill | 886 | ** To send a command down a rup, you need to allocate a command block, fill |
887 | ** in the packet information, fill in the command number, fill in the pre- | 887 | ** in the packet information, fill in the command number, fill in the pre- |
888 | ** and post- functions and arguments, and then add the command block to the | 888 | ** and post- functions and arguments, and then add the command block to the |
889 | ** queue of command blocks for the port in question. When the port is idle, | 889 | ** queue of command blocks for the port in question. When the port is idle, |
890 | ** then the pre-function will be called. If this returns RIO_FAIL then the | 890 | ** then the pre-function will be called. If this returns RIO_FAIL then the |
891 | ** command will be re-queued and tried again at a later date (probably in one | 891 | ** command will be re-queued and tried again at a later date (probably in one |
892 | ** clock tick). If the pre-function returns NOT RIO_FAIL, then the command | 892 | ** clock tick). If the pre-function returns NOT RIO_FAIL, then the command |
893 | ** packet will be queued on the RUP, and the txcontrol field set to the | 893 | ** packet will be queued on the RUP, and the txcontrol field set to the |
894 | ** command number. When the txcontrol field has changed from being the | 894 | ** command number. When the txcontrol field has changed from being the |
895 | ** command number, then the post-function will be called, with the argument | 895 | ** command number, then the post-function will be called, with the argument |
896 | ** specified earlier, a pointer to the command block, and the value of | 896 | ** specified earlier, a pointer to the command block, and the value of |
897 | ** txcontrol. | 897 | ** txcontrol. |
898 | ** | 898 | ** |
899 | ** To allocate a command block, call RIOGetCmdBlk(). This returns a pointer | 899 | ** To allocate a command block, call RIOGetCmdBlk(). This returns a pointer |
900 | ** to the command block structure allocated, or NULL if there aren't any. | 900 | ** to the command block structure allocated, or NULL if there aren't any. |
901 | ** The block will have been zeroed for you. | 901 | ** The block will have been zeroed for you. |
902 | ** | 902 | ** |
903 | ** The structure has the following fields: | 903 | ** The structure has the following fields: |
904 | ** | 904 | ** |
905 | ** struct CmdBlk | 905 | ** struct CmdBlk |
906 | ** { | 906 | ** { |
907 | ** struct CmdBlk *NextP; ** Pointer to next command block ** | 907 | ** struct CmdBlk *NextP; ** Pointer to next command block ** |
908 | ** struct PKT Packet; ** A packet, to copy to the rup ** | 908 | ** struct PKT Packet; ** A packet, to copy to the rup ** |
909 | ** int (*PreFuncP)(); ** The func to call to check if OK ** | 909 | ** int (*PreFuncP)(); ** The func to call to check if OK ** |
910 | ** int PreArg; ** The arg for the func ** | 910 | ** int PreArg; ** The arg for the func ** |
911 | ** int (*PostFuncP)(); ** The func to call when completed ** | 911 | ** int (*PostFuncP)(); ** The func to call when completed ** |
912 | ** int PostArg; ** The arg for the func ** | 912 | ** int PostArg; ** The arg for the func ** |
913 | ** }; | 913 | ** }; |
914 | ** | 914 | ** |
915 | ** You need to fill in ALL fields EXCEPT NextP, which is used to link the | 915 | ** You need to fill in ALL fields EXCEPT NextP, which is used to link the |
916 | ** blocks together either on the free list or on the Rup list. | 916 | ** blocks together either on the free list or on the Rup list. |
917 | ** | 917 | ** |
918 | ** Packet is an actual packet structure to be filled in with the packet | 918 | ** Packet is an actual packet structure to be filled in with the packet |
919 | ** information associated with the command. You need to fill in everything, | 919 | ** information associated with the command. You need to fill in everything, |
920 | ** as the command processor doesn't process the command packet in any way. | 920 | ** as the command processor doesn't process the command packet in any way. |
921 | ** | 921 | ** |
922 | ** The PreFuncP is called before the packet is enqueued on the host rup. | 922 | ** The PreFuncP is called before the packet is enqueued on the host rup. |
923 | ** PreFuncP is called as (*PreFuncP)(PreArg, CmdBlkP);. PreFuncP must | 923 | ** PreFuncP is called as (*PreFuncP)(PreArg, CmdBlkP);. PreFuncP must |
924 | ** return !RIO_FAIL to have the packet queued on the rup, and RIO_FAIL | 924 | ** return !RIO_FAIL to have the packet queued on the rup, and RIO_FAIL |
925 | ** if the packet is NOT to be queued. | 925 | ** if the packet is NOT to be queued. |
926 | ** | 926 | ** |
927 | ** The PostFuncP is called when the command has completed. It is called | 927 | ** The PostFuncP is called when the command has completed. It is called |
928 | ** as (*PostFuncP)(PostArg, CmdBlkP, txcontrol);. PostFuncP is not expected | 928 | ** as (*PostFuncP)(PostArg, CmdBlkP, txcontrol);. PostFuncP is not expected |
929 | ** to return a value. PostFuncP does NOT need to free the command block, | 929 | ** to return a value. PostFuncP does NOT need to free the command block, |
930 | ** as this happens automatically after PostFuncP returns. | 930 | ** as this happens automatically after PostFuncP returns. |
931 | ** | 931 | ** |
932 | ** Once the command block has been filled in, it is attached to the correct | 932 | ** Once the command block has been filled in, it is attached to the correct |
933 | ** queue by calling RIOQueueCmdBlk( HostP, Rup, CmdBlkP ) where HostP is | 933 | ** queue by calling RIOQueueCmdBlk( HostP, Rup, CmdBlkP ) where HostP is |
934 | ** a pointer to the struct Host, Rup is the NUMBER of the rup (NOT a pointer | 934 | ** a pointer to the struct Host, Rup is the NUMBER of the rup (NOT a pointer |
935 | ** to it!), and CmdBlkP is the pointer to the command block allocated using | 935 | ** to it!), and CmdBlkP is the pointer to the command block allocated using |
936 | ** RIOGetCmdBlk(). | 936 | ** RIOGetCmdBlk(). |
937 | ** | 937 | ** |
938 | */ | 938 | */ |
939 | 939 |
drivers/char/rio/riointr.c
1 | /* | 1 | /* |
2 | ** ----------------------------------------------------------------------------- | 2 | ** ----------------------------------------------------------------------------- |
3 | ** | 3 | ** |
4 | ** Perle Specialix driver for Linux | 4 | ** Perle Specialix driver for Linux |
5 | ** Ported from existing RIO Driver for SCO sources. | 5 | ** Ported from existing RIO Driver for SCO sources. |
6 | * | 6 | * |
7 | * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK. | 7 | * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK. |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
11 | * the Free Software Foundation; either version 2 of the License, or | 11 | * the Free Software Foundation; either version 2 of the License, or |
12 | * (at your option) any later version. | 12 | * (at your option) any later version. |
13 | * | 13 | * |
14 | * This program is distributed in the hope that it will be useful, | 14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | * GNU General Public License for more details. | 17 | * GNU General Public License for more details. |
18 | * | 18 | * |
19 | * You should have received a copy of the GNU General Public License | 19 | * You should have received a copy of the GNU General Public License |
20 | * along with this program; if not, write to the Free Software | 20 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
22 | ** | 22 | ** |
23 | ** Module : riointr.c | 23 | ** Module : riointr.c |
24 | ** SID : 1.2 | 24 | ** SID : 1.2 |
25 | ** Last Modified : 11/6/98 10:33:44 | 25 | ** Last Modified : 11/6/98 10:33:44 |
26 | ** Retrieved : 11/6/98 10:33:49 | 26 | ** Retrieved : 11/6/98 10:33:49 |
27 | ** | 27 | ** |
28 | ** ident @(#)riointr.c 1.2 | 28 | ** ident @(#)riointr.c 1.2 |
29 | ** | 29 | ** |
30 | ** ----------------------------------------------------------------------------- | 30 | ** ----------------------------------------------------------------------------- |
31 | */ | 31 | */ |
32 | 32 | ||
33 | #include <linux/module.h> | 33 | #include <linux/module.h> |
34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
35 | #include <linux/errno.h> | 35 | #include <linux/errno.h> |
36 | #include <linux/tty.h> | 36 | #include <linux/tty.h> |
37 | #include <linux/tty_flip.h> | 37 | #include <linux/tty_flip.h> |
38 | #include <asm/io.h> | 38 | #include <asm/io.h> |
39 | #include <asm/system.h> | 39 | #include <asm/system.h> |
40 | #include <asm/string.h> | 40 | #include <asm/string.h> |
41 | #include <asm/uaccess.h> | 41 | #include <asm/uaccess.h> |
42 | 42 | ||
43 | #include <linux/termios.h> | 43 | #include <linux/termios.h> |
44 | #include <linux/serial.h> | 44 | #include <linux/serial.h> |
45 | 45 | ||
46 | #include <linux/generic_serial.h> | 46 | #include <linux/generic_serial.h> |
47 | 47 | ||
48 | #include <linux/delay.h> | 48 | #include <linux/delay.h> |
49 | 49 | ||
50 | #include "linux_compat.h" | 50 | #include "linux_compat.h" |
51 | #include "rio_linux.h" | 51 | #include "rio_linux.h" |
52 | #include "pkt.h" | 52 | #include "pkt.h" |
53 | #include "daemon.h" | 53 | #include "daemon.h" |
54 | #include "rio.h" | 54 | #include "rio.h" |
55 | #include "riospace.h" | 55 | #include "riospace.h" |
56 | #include "cmdpkt.h" | 56 | #include "cmdpkt.h" |
57 | #include "map.h" | 57 | #include "map.h" |
58 | #include "rup.h" | 58 | #include "rup.h" |
59 | #include "port.h" | 59 | #include "port.h" |
60 | #include "riodrvr.h" | 60 | #include "riodrvr.h" |
61 | #include "rioinfo.h" | 61 | #include "rioinfo.h" |
62 | #include "func.h" | 62 | #include "func.h" |
63 | #include "errors.h" | 63 | #include "errors.h" |
64 | #include "pci.h" | 64 | #include "pci.h" |
65 | 65 | ||
66 | #include "parmmap.h" | 66 | #include "parmmap.h" |
67 | #include "unixrup.h" | 67 | #include "unixrup.h" |
68 | #include "board.h" | 68 | #include "board.h" |
69 | #include "host.h" | 69 | #include "host.h" |
70 | #include "phb.h" | 70 | #include "phb.h" |
71 | #include "link.h" | 71 | #include "link.h" |
72 | #include "cmdblk.h" | 72 | #include "cmdblk.h" |
73 | #include "route.h" | 73 | #include "route.h" |
74 | #include "cirrus.h" | 74 | #include "cirrus.h" |
75 | #include "rioioctl.h" | 75 | #include "rioioctl.h" |
76 | 76 | ||
77 | 77 | ||
78 | static void RIOReceive(struct rio_info *, struct Port *); | 78 | static void RIOReceive(struct rio_info *, struct Port *); |
79 | 79 | ||
80 | 80 | ||
81 | static char *firstchars(char *p, int nch) | 81 | static char *firstchars(char *p, int nch) |
82 | { | 82 | { |
83 | static char buf[2][128]; | 83 | static char buf[2][128]; |
84 | static int t = 0; | 84 | static int t = 0; |
85 | t = !t; | 85 | t = !t; |
86 | memcpy(buf[t], p, nch); | 86 | memcpy(buf[t], p, nch); |
87 | buf[t][nch] = 0; | 87 | buf[t][nch] = 0; |
88 | return buf[t]; | 88 | return buf[t]; |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | #define INCR( P, I ) ((P) = (((P)+(I)) & p->RIOBufferMask)) | 92 | #define INCR( P, I ) ((P) = (((P)+(I)) & p->RIOBufferMask)) |
93 | /* Enable and start the transmission of packets */ | 93 | /* Enable and start the transmission of packets */ |
94 | void RIOTxEnable(char *en) | 94 | void RIOTxEnable(char *en) |
95 | { | 95 | { |
96 | struct Port *PortP; | 96 | struct Port *PortP; |
97 | struct rio_info *p; | 97 | struct rio_info *p; |
98 | struct tty_struct *tty; | 98 | struct tty_struct *tty; |
99 | int c; | 99 | int c; |
100 | struct PKT __iomem *PacketP; | 100 | struct PKT __iomem *PacketP; |
101 | unsigned long flags; | 101 | unsigned long flags; |
102 | 102 | ||
103 | PortP = (struct Port *) en; | 103 | PortP = (struct Port *) en; |
104 | p = (struct rio_info *) PortP->p; | 104 | p = (struct rio_info *) PortP->p; |
105 | tty = PortP->gs.tty; | 105 | tty = PortP->gs.port.tty; |
106 | 106 | ||
107 | 107 | ||
108 | rio_dprintk(RIO_DEBUG_INTR, "tx port %d: %d chars queued.\n", PortP->PortNum, PortP->gs.xmit_cnt); | 108 | rio_dprintk(RIO_DEBUG_INTR, "tx port %d: %d chars queued.\n", PortP->PortNum, PortP->gs.xmit_cnt); |
109 | 109 | ||
110 | if (!PortP->gs.xmit_cnt) | 110 | if (!PortP->gs.xmit_cnt) |
111 | return; | 111 | return; |
112 | 112 | ||
113 | 113 | ||
114 | /* This routine is an order of magnitude simpler than the specialix | 114 | /* This routine is an order of magnitude simpler than the specialix |
115 | version. One of the disadvantages is that this version will send | 115 | version. One of the disadvantages is that this version will send |
116 | an incomplete packet (usually 64 bytes instead of 72) once for | 116 | an incomplete packet (usually 64 bytes instead of 72) once for |
117 | every 4k worth of data. Let's just say that this won't influence | 117 | every 4k worth of data. Let's just say that this won't influence |
118 | performance significantly..... */ | 118 | performance significantly..... */ |
119 | 119 | ||
120 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 120 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
121 | 121 | ||
122 | while (can_add_transmit(&PacketP, PortP)) { | 122 | while (can_add_transmit(&PacketP, PortP)) { |
123 | c = PortP->gs.xmit_cnt; | 123 | c = PortP->gs.xmit_cnt; |
124 | if (c > PKT_MAX_DATA_LEN) | 124 | if (c > PKT_MAX_DATA_LEN) |
125 | c = PKT_MAX_DATA_LEN; | 125 | c = PKT_MAX_DATA_LEN; |
126 | 126 | ||
127 | /* Don't copy past the end of the source buffer */ | 127 | /* Don't copy past the end of the source buffer */ |
128 | if (c > SERIAL_XMIT_SIZE - PortP->gs.xmit_tail) | 128 | if (c > SERIAL_XMIT_SIZE - PortP->gs.xmit_tail) |
129 | c = SERIAL_XMIT_SIZE - PortP->gs.xmit_tail; | 129 | c = SERIAL_XMIT_SIZE - PortP->gs.xmit_tail; |
130 | 130 | ||
131 | { | 131 | { |
132 | int t; | 132 | int t; |
133 | t = (c > 10) ? 10 : c; | 133 | t = (c > 10) ? 10 : c; |
134 | 134 | ||
135 | rio_dprintk(RIO_DEBUG_INTR, "rio: tx port %d: copying %d chars: %s - %s\n", PortP->PortNum, c, firstchars(PortP->gs.xmit_buf + PortP->gs.xmit_tail, t), firstchars(PortP->gs.xmit_buf + PortP->gs.xmit_tail + c - t, t)); | 135 | rio_dprintk(RIO_DEBUG_INTR, "rio: tx port %d: copying %d chars: %s - %s\n", PortP->PortNum, c, firstchars(PortP->gs.xmit_buf + PortP->gs.xmit_tail, t), firstchars(PortP->gs.xmit_buf + PortP->gs.xmit_tail + c - t, t)); |
136 | } | 136 | } |
137 | /* If for one reason or another, we can't copy more data, | 137 | /* If for one reason or another, we can't copy more data, |
138 | we're done! */ | 138 | we're done! */ |
139 | if (c == 0) | 139 | if (c == 0) |
140 | break; | 140 | break; |
141 | 141 | ||
142 | rio_memcpy_toio(PortP->HostP->Caddr, PacketP->data, PortP->gs.xmit_buf + PortP->gs.xmit_tail, c); | 142 | rio_memcpy_toio(PortP->HostP->Caddr, PacketP->data, PortP->gs.xmit_buf + PortP->gs.xmit_tail, c); |
143 | /* udelay (1); */ | 143 | /* udelay (1); */ |
144 | 144 | ||
145 | writeb(c, &(PacketP->len)); | 145 | writeb(c, &(PacketP->len)); |
146 | if (!(PortP->State & RIO_DELETED)) { | 146 | if (!(PortP->State & RIO_DELETED)) { |
147 | add_transmit(PortP); | 147 | add_transmit(PortP); |
148 | /* | 148 | /* |
149 | ** Count chars tx'd for port statistics reporting | 149 | ** Count chars tx'd for port statistics reporting |
150 | */ | 150 | */ |
151 | if (PortP->statsGather) | 151 | if (PortP->statsGather) |
152 | PortP->txchars += c; | 152 | PortP->txchars += c; |
153 | } | 153 | } |
154 | PortP->gs.xmit_tail = (PortP->gs.xmit_tail + c) & (SERIAL_XMIT_SIZE - 1); | 154 | PortP->gs.xmit_tail = (PortP->gs.xmit_tail + c) & (SERIAL_XMIT_SIZE - 1); |
155 | PortP->gs.xmit_cnt -= c; | 155 | PortP->gs.xmit_cnt -= c; |
156 | } | 156 | } |
157 | 157 | ||
158 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 158 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
159 | 159 | ||
160 | if (PortP->gs.xmit_cnt <= (PortP->gs.wakeup_chars + 2 * PKT_MAX_DATA_LEN)) | 160 | if (PortP->gs.xmit_cnt <= (PortP->gs.wakeup_chars + 2 * PKT_MAX_DATA_LEN)) |
161 | tty_wakeup(PortP->gs.tty); | 161 | tty_wakeup(PortP->gs.port.tty); |
162 | 162 | ||
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
166 | /* | 166 | /* |
167 | ** RIO Host Service routine. Does all the work traditionally associated with an | 167 | ** RIO Host Service routine. Does all the work traditionally associated with an |
168 | ** interrupt. | 168 | ** interrupt. |
169 | */ | 169 | */ |
170 | static int RupIntr; | 170 | static int RupIntr; |
171 | static int RxIntr; | 171 | static int RxIntr; |
172 | static int TxIntr; | 172 | static int TxIntr; |
173 | 173 | ||
174 | void RIOServiceHost(struct rio_info *p, struct Host *HostP) | 174 | void RIOServiceHost(struct rio_info *p, struct Host *HostP) |
175 | { | 175 | { |
176 | rio_spin_lock(&HostP->HostLock); | 176 | rio_spin_lock(&HostP->HostLock); |
177 | if ((HostP->Flags & RUN_STATE) != RC_RUNNING) { | 177 | if ((HostP->Flags & RUN_STATE) != RC_RUNNING) { |
178 | static int t = 0; | 178 | static int t = 0; |
179 | rio_spin_unlock(&HostP->HostLock); | 179 | rio_spin_unlock(&HostP->HostLock); |
180 | if ((t++ % 200) == 0) | 180 | if ((t++ % 200) == 0) |
181 | rio_dprintk(RIO_DEBUG_INTR, "Interrupt but host not running. flags=%x.\n", (int) HostP->Flags); | 181 | rio_dprintk(RIO_DEBUG_INTR, "Interrupt but host not running. flags=%x.\n", (int) HostP->Flags); |
182 | return; | 182 | return; |
183 | } | 183 | } |
184 | rio_spin_unlock(&HostP->HostLock); | 184 | rio_spin_unlock(&HostP->HostLock); |
185 | 185 | ||
186 | if (readw(&HostP->ParmMapP->rup_intr)) { | 186 | if (readw(&HostP->ParmMapP->rup_intr)) { |
187 | writew(0, &HostP->ParmMapP->rup_intr); | 187 | writew(0, &HostP->ParmMapP->rup_intr); |
188 | p->RIORupCount++; | 188 | p->RIORupCount++; |
189 | RupIntr++; | 189 | RupIntr++; |
190 | rio_dprintk(RIO_DEBUG_INTR, "rio: RUP interrupt on host %Zd\n", HostP - p->RIOHosts); | 190 | rio_dprintk(RIO_DEBUG_INTR, "rio: RUP interrupt on host %Zd\n", HostP - p->RIOHosts); |
191 | RIOPollHostCommands(p, HostP); | 191 | RIOPollHostCommands(p, HostP); |
192 | } | 192 | } |
193 | 193 | ||
194 | if (readw(&HostP->ParmMapP->rx_intr)) { | 194 | if (readw(&HostP->ParmMapP->rx_intr)) { |
195 | int port; | 195 | int port; |
196 | 196 | ||
197 | writew(0, &HostP->ParmMapP->rx_intr); | 197 | writew(0, &HostP->ParmMapP->rx_intr); |
198 | p->RIORxCount++; | 198 | p->RIORxCount++; |
199 | RxIntr++; | 199 | RxIntr++; |
200 | 200 | ||
201 | rio_dprintk(RIO_DEBUG_INTR, "rio: RX interrupt on host %Zd\n", HostP - p->RIOHosts); | 201 | rio_dprintk(RIO_DEBUG_INTR, "rio: RX interrupt on host %Zd\n", HostP - p->RIOHosts); |
202 | /* | 202 | /* |
203 | ** Loop through every port. If the port is mapped into | 203 | ** Loop through every port. If the port is mapped into |
204 | ** the system ( i.e. has /dev/ttyXXXX associated ) then it is | 204 | ** the system ( i.e. has /dev/ttyXXXX associated ) then it is |
205 | ** worth checking. If the port isn't open, grab any packets | 205 | ** worth checking. If the port isn't open, grab any packets |
206 | ** hanging on its receive queue and stuff them on the free | 206 | ** hanging on its receive queue and stuff them on the free |
207 | ** list; check for commands on the way. | 207 | ** list; check for commands on the way. |
208 | */ | 208 | */ |
209 | for (port = p->RIOFirstPortsBooted; port < p->RIOLastPortsBooted + PORTS_PER_RTA; port++) { | 209 | for (port = p->RIOFirstPortsBooted; port < p->RIOLastPortsBooted + PORTS_PER_RTA; port++) { |
210 | struct Port *PortP = p->RIOPortp[port]; | 210 | struct Port *PortP = p->RIOPortp[port]; |
211 | struct tty_struct *ttyP; | 211 | struct tty_struct *ttyP; |
212 | struct PKT __iomem *PacketP; | 212 | struct PKT __iomem *PacketP; |
213 | 213 | ||
214 | /* | 214 | /* |
215 | ** not mapped in - most of the RIOPortp[] information | 215 | ** not mapped in - most of the RIOPortp[] information |
216 | ** has not been set up! | 216 | ** has not been set up! |
217 | ** Optimise: ports come in bundles of eight. | 217 | ** Optimise: ports come in bundles of eight. |
218 | */ | 218 | */ |
219 | if (!PortP->Mapped) { | 219 | if (!PortP->Mapped) { |
220 | port += 7; | 220 | port += 7; |
221 | continue; /* with the next port */ | 221 | continue; /* with the next port */ |
222 | } | 222 | } |
223 | 223 | ||
224 | /* | 224 | /* |
225 | ** If the host board isn't THIS host board, check the next one. | 225 | ** If the host board isn't THIS host board, check the next one. |
226 | ** optimise: ports come in bundles of eight. | 226 | ** optimise: ports come in bundles of eight. |
227 | */ | 227 | */ |
228 | if (PortP->HostP != HostP) { | 228 | if (PortP->HostP != HostP) { |
229 | port += 7; | 229 | port += 7; |
230 | continue; | 230 | continue; |
231 | } | 231 | } |
232 | 232 | ||
233 | /* | 233 | /* |
234 | ** Let us see - is the port open? If not, then don't service it. | 234 | ** Let us see - is the port open? If not, then don't service it. |
235 | */ | 235 | */ |
236 | if (!(PortP->PortState & PORT_ISOPEN)) { | 236 | if (!(PortP->PortState & PORT_ISOPEN)) { |
237 | continue; | 237 | continue; |
238 | } | 238 | } |
239 | 239 | ||
240 | /* | 240 | /* |
241 | ** find corresponding tty structure. The process of mapping | 241 | ** find corresponding tty structure. The process of mapping |
242 | ** the ports puts these here. | 242 | ** the ports puts these here. |
243 | */ | 243 | */ |
244 | ttyP = PortP->gs.tty; | 244 | ttyP = PortP->gs.port.tty; |
245 | 245 | ||
246 | /* | 246 | /* |
247 | ** Lock the port before we begin working on it. | 247 | ** Lock the port before we begin working on it. |
248 | */ | 248 | */ |
249 | rio_spin_lock(&PortP->portSem); | 249 | rio_spin_lock(&PortP->portSem); |
250 | 250 | ||
251 | /* | 251 | /* |
252 | ** Process received data if there is any. | 252 | ** Process received data if there is any. |
253 | */ | 253 | */ |
254 | if (can_remove_receive(&PacketP, PortP)) | 254 | if (can_remove_receive(&PacketP, PortP)) |
255 | RIOReceive(p, PortP); | 255 | RIOReceive(p, PortP); |
256 | 256 | ||
257 | /* | 257 | /* |
258 | ** If there is no data left to be read from the port, and | 258 | ** If there is no data left to be read from the port, and |
259 | ** it's handshake bit is set, then we must clear the handshake, | 259 | ** it's handshake bit is set, then we must clear the handshake, |
260 | ** so that that downstream RTA is re-enabled. | 260 | ** so that that downstream RTA is re-enabled. |
261 | */ | 261 | */ |
262 | if (!can_remove_receive(&PacketP, PortP) && (readw(&PortP->PhbP->handshake) == PHB_HANDSHAKE_SET)) { | 262 | if (!can_remove_receive(&PacketP, PortP) && (readw(&PortP->PhbP->handshake) == PHB_HANDSHAKE_SET)) { |
263 | /* | 263 | /* |
264 | ** MAGIC! ( Basically, handshake the RX buffer, so that | 264 | ** MAGIC! ( Basically, handshake the RX buffer, so that |
265 | ** the RTAs upstream can be re-enabled. ) | 265 | ** the RTAs upstream can be re-enabled. ) |
266 | */ | 266 | */ |
267 | rio_dprintk(RIO_DEBUG_INTR, "Set RX handshake bit\n"); | 267 | rio_dprintk(RIO_DEBUG_INTR, "Set RX handshake bit\n"); |
268 | writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &PortP->PhbP->handshake); | 268 | writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &PortP->PhbP->handshake); |
269 | } | 269 | } |
270 | rio_spin_unlock(&PortP->portSem); | 270 | rio_spin_unlock(&PortP->portSem); |
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||
274 | if (readw(&HostP->ParmMapP->tx_intr)) { | 274 | if (readw(&HostP->ParmMapP->tx_intr)) { |
275 | int port; | 275 | int port; |
276 | 276 | ||
277 | writew(0, &HostP->ParmMapP->tx_intr); | 277 | writew(0, &HostP->ParmMapP->tx_intr); |
278 | 278 | ||
279 | p->RIOTxCount++; | 279 | p->RIOTxCount++; |
280 | TxIntr++; | 280 | TxIntr++; |
281 | rio_dprintk(RIO_DEBUG_INTR, "rio: TX interrupt on host %Zd\n", HostP - p->RIOHosts); | 281 | rio_dprintk(RIO_DEBUG_INTR, "rio: TX interrupt on host %Zd\n", HostP - p->RIOHosts); |
282 | 282 | ||
283 | /* | 283 | /* |
284 | ** Loop through every port. | 284 | ** Loop through every port. |
285 | ** If the port is mapped into the system ( i.e. has /dev/ttyXXXX | 285 | ** If the port is mapped into the system ( i.e. has /dev/ttyXXXX |
286 | ** associated ) then it is worth checking. | 286 | ** associated ) then it is worth checking. |
287 | */ | 287 | */ |
288 | for (port = p->RIOFirstPortsBooted; port < p->RIOLastPortsBooted + PORTS_PER_RTA; port++) { | 288 | for (port = p->RIOFirstPortsBooted; port < p->RIOLastPortsBooted + PORTS_PER_RTA; port++) { |
289 | struct Port *PortP = p->RIOPortp[port]; | 289 | struct Port *PortP = p->RIOPortp[port]; |
290 | struct tty_struct *ttyP; | 290 | struct tty_struct *ttyP; |
291 | struct PKT __iomem *PacketP; | 291 | struct PKT __iomem *PacketP; |
292 | 292 | ||
293 | /* | 293 | /* |
294 | ** not mapped in - most of the RIOPortp[] information | 294 | ** not mapped in - most of the RIOPortp[] information |
295 | ** has not been set up! | 295 | ** has not been set up! |
296 | */ | 296 | */ |
297 | if (!PortP->Mapped) { | 297 | if (!PortP->Mapped) { |
298 | port += 7; | 298 | port += 7; |
299 | continue; /* with the next port */ | 299 | continue; /* with the next port */ |
300 | } | 300 | } |
301 | 301 | ||
302 | /* | 302 | /* |
303 | ** If the host board isn't running, then its data structures | 303 | ** If the host board isn't running, then its data structures |
304 | ** are no use to us - continue quietly. | 304 | ** are no use to us - continue quietly. |
305 | */ | 305 | */ |
306 | if (PortP->HostP != HostP) { | 306 | if (PortP->HostP != HostP) { |
307 | port += 7; | 307 | port += 7; |
308 | continue; /* with the next port */ | 308 | continue; /* with the next port */ |
309 | } | 309 | } |
310 | 310 | ||
311 | /* | 311 | /* |
312 | ** Let us see - is the port open? If not, then don't service it. | 312 | ** Let us see - is the port open? If not, then don't service it. |
313 | */ | 313 | */ |
314 | if (!(PortP->PortState & PORT_ISOPEN)) { | 314 | if (!(PortP->PortState & PORT_ISOPEN)) { |
315 | continue; | 315 | continue; |
316 | } | 316 | } |
317 | 317 | ||
318 | rio_dprintk(RIO_DEBUG_INTR, "rio: Looking into port %d.\n", port); | 318 | rio_dprintk(RIO_DEBUG_INTR, "rio: Looking into port %d.\n", port); |
319 | /* | 319 | /* |
320 | ** Lock the port before we begin working on it. | 320 | ** Lock the port before we begin working on it. |
321 | */ | 321 | */ |
322 | rio_spin_lock(&PortP->portSem); | 322 | rio_spin_lock(&PortP->portSem); |
323 | 323 | ||
324 | /* | 324 | /* |
325 | ** If we can't add anything to the transmit queue, then | 325 | ** If we can't add anything to the transmit queue, then |
326 | ** we need do none of this processing. | 326 | ** we need do none of this processing. |
327 | */ | 327 | */ |
328 | if (!can_add_transmit(&PacketP, PortP)) { | 328 | if (!can_add_transmit(&PacketP, PortP)) { |
329 | rio_dprintk(RIO_DEBUG_INTR, "Can't add to port, so skipping.\n"); | 329 | rio_dprintk(RIO_DEBUG_INTR, "Can't add to port, so skipping.\n"); |
330 | rio_spin_unlock(&PortP->portSem); | 330 | rio_spin_unlock(&PortP->portSem); |
331 | continue; | 331 | continue; |
332 | } | 332 | } |
333 | 333 | ||
334 | /* | 334 | /* |
335 | ** find corresponding tty structure. The process of mapping | 335 | ** find corresponding tty structure. The process of mapping |
336 | ** the ports puts these here. | 336 | ** the ports puts these here. |
337 | */ | 337 | */ |
338 | ttyP = PortP->gs.tty; | 338 | ttyP = PortP->gs.port.tty; |
339 | /* If ttyP is NULL, the port is getting closed. Forget about it. */ | 339 | /* If ttyP is NULL, the port is getting closed. Forget about it. */ |
340 | if (!ttyP) { | 340 | if (!ttyP) { |
341 | rio_dprintk(RIO_DEBUG_INTR, "no tty, so skipping.\n"); | 341 | rio_dprintk(RIO_DEBUG_INTR, "no tty, so skipping.\n"); |
342 | rio_spin_unlock(&PortP->portSem); | 342 | rio_spin_unlock(&PortP->portSem); |
343 | continue; | 343 | continue; |
344 | } | 344 | } |
345 | /* | 345 | /* |
346 | ** If there is more room available we start up the transmit | 346 | ** If there is more room available we start up the transmit |
347 | ** data process again. This can be direct I/O, if the cookmode | 347 | ** data process again. This can be direct I/O, if the cookmode |
348 | ** is set to COOK_RAW or COOK_MEDIUM, or will be a call to the | 348 | ** is set to COOK_RAW or COOK_MEDIUM, or will be a call to the |
349 | ** riotproc( T_OUTPUT ) if we are in COOK_WELL mode, to fetch | 349 | ** riotproc( T_OUTPUT ) if we are in COOK_WELL mode, to fetch |
350 | ** characters via the line discipline. We must always call | 350 | ** characters via the line discipline. We must always call |
351 | ** the line discipline, | 351 | ** the line discipline, |
352 | ** so that user input characters can be echoed correctly. | 352 | ** so that user input characters can be echoed correctly. |
353 | ** | 353 | ** |
354 | ** ++++ Update +++++ | 354 | ** ++++ Update +++++ |
355 | ** With the advent of double buffering, we now see if | 355 | ** With the advent of double buffering, we now see if |
356 | ** TxBufferOut-In is non-zero. If so, then we copy a packet | 356 | ** TxBufferOut-In is non-zero. If so, then we copy a packet |
357 | ** to the output place, and set it going. If this empties | 357 | ** to the output place, and set it going. If this empties |
358 | ** the buffer, then we must issue a wakeup( ) on OUT. | 358 | ** the buffer, then we must issue a wakeup( ) on OUT. |
359 | ** If it frees space in the buffer then we must issue | 359 | ** If it frees space in the buffer then we must issue |
360 | ** a wakeup( ) on IN. | 360 | ** a wakeup( ) on IN. |
361 | ** | 361 | ** |
362 | ** ++++ Extra! Extra! If PortP->WflushFlag is set, then we | 362 | ** ++++ Extra! Extra! If PortP->WflushFlag is set, then we |
363 | ** have to send a WFLUSH command down the PHB, to mark the | 363 | ** have to send a WFLUSH command down the PHB, to mark the |
364 | ** end point of a WFLUSH. We also need to clear out any | 364 | ** end point of a WFLUSH. We also need to clear out any |
365 | ** data from the double buffer! ( note that WflushFlag is a | 365 | ** data from the double buffer! ( note that WflushFlag is a |
366 | ** *count* of the number of WFLUSH commands outstanding! ) | 366 | ** *count* of the number of WFLUSH commands outstanding! ) |
367 | ** | 367 | ** |
368 | ** ++++ And there's more! | 368 | ** ++++ And there's more! |
369 | ** If an RTA is powered off, then on again, and rebooted, | 369 | ** If an RTA is powered off, then on again, and rebooted, |
370 | ** whilst it has ports open, then we need to re-open the ports. | 370 | ** whilst it has ports open, then we need to re-open the ports. |
371 | ** ( reasonable enough ). We can't do this when we spot the | 371 | ** ( reasonable enough ). We can't do this when we spot the |
372 | ** re-boot, in interrupt time, because the queue is probably | 372 | ** re-boot, in interrupt time, because the queue is probably |
373 | ** full. So, when we come in here, we need to test if any | 373 | ** full. So, when we come in here, we need to test if any |
374 | ** ports are in this condition, and re-open the port before | 374 | ** ports are in this condition, and re-open the port before |
375 | ** we try to send any more data to it. Now, the re-booted | 375 | ** we try to send any more data to it. Now, the re-booted |
376 | ** RTA will be discarding packets from the PHB until it | 376 | ** RTA will be discarding packets from the PHB until it |
377 | ** receives this open packet, but don't worry tooo much | 377 | ** receives this open packet, but don't worry tooo much |
378 | ** about that. The one thing that is interesting is the | 378 | ** about that. The one thing that is interesting is the |
379 | ** combination of this effect and the WFLUSH effect! | 379 | ** combination of this effect and the WFLUSH effect! |
380 | */ | 380 | */ |
381 | /* For now don't handle RTA reboots. -- REW. | 381 | /* For now don't handle RTA reboots. -- REW. |
382 | Reenabled. Otherwise RTA reboots didn't work. Duh. -- REW */ | 382 | Reenabled. Otherwise RTA reboots didn't work. Duh. -- REW */ |
383 | if (PortP->MagicFlags) { | 383 | if (PortP->MagicFlags) { |
384 | if (PortP->MagicFlags & MAGIC_REBOOT) { | 384 | if (PortP->MagicFlags & MAGIC_REBOOT) { |
385 | /* | 385 | /* |
386 | ** well, the RTA has been rebooted, and there is room | 386 | ** well, the RTA has been rebooted, and there is room |
387 | ** on its queue to add the open packet that is required. | 387 | ** on its queue to add the open packet that is required. |
388 | ** | 388 | ** |
389 | ** The messy part of this line is trying to decide if | 389 | ** The messy part of this line is trying to decide if |
390 | ** we need to call the Param function as a tty or as | 390 | ** we need to call the Param function as a tty or as |
391 | ** a modem. | 391 | ** a modem. |
392 | ** DONT USE CLOCAL AS A TEST FOR THIS! | 392 | ** DONT USE CLOCAL AS A TEST FOR THIS! |
393 | ** | 393 | ** |
394 | ** If we can't param the port, then move on to the | 394 | ** If we can't param the port, then move on to the |
395 | ** next port. | 395 | ** next port. |
396 | */ | 396 | */ |
397 | PortP->InUse = NOT_INUSE; | 397 | PortP->InUse = NOT_INUSE; |
398 | 398 | ||
399 | rio_spin_unlock(&PortP->portSem); | 399 | rio_spin_unlock(&PortP->portSem); |
400 | if (RIOParam(PortP, RIOC_OPEN, ((PortP->Cor2Copy & (RIOC_COR2_RTSFLOW | RIOC_COR2_CTSFLOW)) == (RIOC_COR2_RTSFLOW | RIOC_COR2_CTSFLOW)) ? 1 : 0, DONT_SLEEP) == RIO_FAIL) | 400 | if (RIOParam(PortP, RIOC_OPEN, ((PortP->Cor2Copy & (RIOC_COR2_RTSFLOW | RIOC_COR2_CTSFLOW)) == (RIOC_COR2_RTSFLOW | RIOC_COR2_CTSFLOW)) ? 1 : 0, DONT_SLEEP) == RIO_FAIL) |
401 | continue; /* with next port */ | 401 | continue; /* with next port */ |
402 | rio_spin_lock(&PortP->portSem); | 402 | rio_spin_lock(&PortP->portSem); |
403 | PortP->MagicFlags &= ~MAGIC_REBOOT; | 403 | PortP->MagicFlags &= ~MAGIC_REBOOT; |
404 | } | 404 | } |
405 | 405 | ||
406 | /* | 406 | /* |
407 | ** As mentioned above, this is a tacky hack to cope | 407 | ** As mentioned above, this is a tacky hack to cope |
408 | ** with WFLUSH | 408 | ** with WFLUSH |
409 | */ | 409 | */ |
410 | if (PortP->WflushFlag) { | 410 | if (PortP->WflushFlag) { |
411 | rio_dprintk(RIO_DEBUG_INTR, "Want to WFLUSH mark this port\n"); | 411 | rio_dprintk(RIO_DEBUG_INTR, "Want to WFLUSH mark this port\n"); |
412 | 412 | ||
413 | if (PortP->InUse) | 413 | if (PortP->InUse) |
414 | rio_dprintk(RIO_DEBUG_INTR, "FAILS - PORT IS IN USE\n"); | 414 | rio_dprintk(RIO_DEBUG_INTR, "FAILS - PORT IS IN USE\n"); |
415 | } | 415 | } |
416 | 416 | ||
417 | while (PortP->WflushFlag && can_add_transmit(&PacketP, PortP) && (PortP->InUse == NOT_INUSE)) { | 417 | while (PortP->WflushFlag && can_add_transmit(&PacketP, PortP) && (PortP->InUse == NOT_INUSE)) { |
418 | int p; | 418 | int p; |
419 | struct PktCmd __iomem *PktCmdP; | 419 | struct PktCmd __iomem *PktCmdP; |
420 | 420 | ||
421 | rio_dprintk(RIO_DEBUG_INTR, "Add WFLUSH marker to data queue\n"); | 421 | rio_dprintk(RIO_DEBUG_INTR, "Add WFLUSH marker to data queue\n"); |
422 | /* | 422 | /* |
423 | ** make it look just like a WFLUSH command | 423 | ** make it look just like a WFLUSH command |
424 | */ | 424 | */ |
425 | PktCmdP = (struct PktCmd __iomem *) &PacketP->data[0]; | 425 | PktCmdP = (struct PktCmd __iomem *) &PacketP->data[0]; |
426 | 426 | ||
427 | writeb(RIOC_WFLUSH, &PktCmdP->Command); | 427 | writeb(RIOC_WFLUSH, &PktCmdP->Command); |
428 | 428 | ||
429 | p = PortP->HostPort % (u16) PORTS_PER_RTA; | 429 | p = PortP->HostPort % (u16) PORTS_PER_RTA; |
430 | 430 | ||
431 | /* | 431 | /* |
432 | ** If second block of ports for 16 port RTA, add 8 | 432 | ** If second block of ports for 16 port RTA, add 8 |
433 | ** to index 8-15. | 433 | ** to index 8-15. |
434 | */ | 434 | */ |
435 | if (PortP->SecondBlock) | 435 | if (PortP->SecondBlock) |
436 | p += PORTS_PER_RTA; | 436 | p += PORTS_PER_RTA; |
437 | 437 | ||
438 | writeb(p, &PktCmdP->PhbNum); | 438 | writeb(p, &PktCmdP->PhbNum); |
439 | 439 | ||
440 | /* | 440 | /* |
441 | ** to make debuggery easier | 441 | ** to make debuggery easier |
442 | */ | 442 | */ |
443 | writeb('W', &PacketP->data[2]); | 443 | writeb('W', &PacketP->data[2]); |
444 | writeb('F', &PacketP->data[3]); | 444 | writeb('F', &PacketP->data[3]); |
445 | writeb('L', &PacketP->data[4]); | 445 | writeb('L', &PacketP->data[4]); |
446 | writeb('U', &PacketP->data[5]); | 446 | writeb('U', &PacketP->data[5]); |
447 | writeb('S', &PacketP->data[6]); | 447 | writeb('S', &PacketP->data[6]); |
448 | writeb('H', &PacketP->data[7]); | 448 | writeb('H', &PacketP->data[7]); |
449 | writeb(' ', &PacketP->data[8]); | 449 | writeb(' ', &PacketP->data[8]); |
450 | writeb('0' + PortP->WflushFlag, &PacketP->data[9]); | 450 | writeb('0' + PortP->WflushFlag, &PacketP->data[9]); |
451 | writeb(' ', &PacketP->data[10]); | 451 | writeb(' ', &PacketP->data[10]); |
452 | writeb(' ', &PacketP->data[11]); | 452 | writeb(' ', &PacketP->data[11]); |
453 | writeb('\0', &PacketP->data[12]); | 453 | writeb('\0', &PacketP->data[12]); |
454 | 454 | ||
455 | /* | 455 | /* |
456 | ** its two bytes long! | 456 | ** its two bytes long! |
457 | */ | 457 | */ |
458 | writeb(PKT_CMD_BIT | 2, &PacketP->len); | 458 | writeb(PKT_CMD_BIT | 2, &PacketP->len); |
459 | 459 | ||
460 | /* | 460 | /* |
461 | ** queue it! | 461 | ** queue it! |
462 | */ | 462 | */ |
463 | if (!(PortP->State & RIO_DELETED)) { | 463 | if (!(PortP->State & RIO_DELETED)) { |
464 | add_transmit(PortP); | 464 | add_transmit(PortP); |
465 | /* | 465 | /* |
466 | ** Count chars tx'd for port statistics reporting | 466 | ** Count chars tx'd for port statistics reporting |
467 | */ | 467 | */ |
468 | if (PortP->statsGather) | 468 | if (PortP->statsGather) |
469 | PortP->txchars += 2; | 469 | PortP->txchars += 2; |
470 | } | 470 | } |
471 | 471 | ||
472 | if (--(PortP->WflushFlag) == 0) { | 472 | if (--(PortP->WflushFlag) == 0) { |
473 | PortP->MagicFlags &= ~MAGIC_FLUSH; | 473 | PortP->MagicFlags &= ~MAGIC_FLUSH; |
474 | } | 474 | } |
475 | 475 | ||
476 | rio_dprintk(RIO_DEBUG_INTR, "Wflush count now stands at %d\n", PortP->WflushFlag); | 476 | rio_dprintk(RIO_DEBUG_INTR, "Wflush count now stands at %d\n", PortP->WflushFlag); |
477 | } | 477 | } |
478 | if (PortP->MagicFlags & MORE_OUTPUT_EYGOR) { | 478 | if (PortP->MagicFlags & MORE_OUTPUT_EYGOR) { |
479 | if (PortP->MagicFlags & MAGIC_FLUSH) { | 479 | if (PortP->MagicFlags & MAGIC_FLUSH) { |
480 | PortP->MagicFlags |= MORE_OUTPUT_EYGOR; | 480 | PortP->MagicFlags |= MORE_OUTPUT_EYGOR; |
481 | } else { | 481 | } else { |
482 | if (!can_add_transmit(&PacketP, PortP)) { | 482 | if (!can_add_transmit(&PacketP, PortP)) { |
483 | rio_spin_unlock(&PortP->portSem); | 483 | rio_spin_unlock(&PortP->portSem); |
484 | continue; | 484 | continue; |
485 | } | 485 | } |
486 | rio_spin_unlock(&PortP->portSem); | 486 | rio_spin_unlock(&PortP->portSem); |
487 | RIOTxEnable((char *) PortP); | 487 | RIOTxEnable((char *) PortP); |
488 | rio_spin_lock(&PortP->portSem); | 488 | rio_spin_lock(&PortP->portSem); |
489 | PortP->MagicFlags &= ~MORE_OUTPUT_EYGOR; | 489 | PortP->MagicFlags &= ~MORE_OUTPUT_EYGOR; |
490 | } | 490 | } |
491 | } | 491 | } |
492 | } | 492 | } |
493 | 493 | ||
494 | 494 | ||
495 | /* | 495 | /* |
496 | ** If we can't add anything to the transmit queue, then | 496 | ** If we can't add anything to the transmit queue, then |
497 | ** we need do none of the remaining processing. | 497 | ** we need do none of the remaining processing. |
498 | */ | 498 | */ |
499 | if (!can_add_transmit(&PacketP, PortP)) { | 499 | if (!can_add_transmit(&PacketP, PortP)) { |
500 | rio_spin_unlock(&PortP->portSem); | 500 | rio_spin_unlock(&PortP->portSem); |
501 | continue; | 501 | continue; |
502 | } | 502 | } |
503 | 503 | ||
504 | rio_spin_unlock(&PortP->portSem); | 504 | rio_spin_unlock(&PortP->portSem); |
505 | RIOTxEnable((char *) PortP); | 505 | RIOTxEnable((char *) PortP); |
506 | } | 506 | } |
507 | } | 507 | } |
508 | } | 508 | } |
509 | 509 | ||
510 | /* | 510 | /* |
511 | ** Routine for handling received data for tty drivers | 511 | ** Routine for handling received data for tty drivers |
512 | */ | 512 | */ |
513 | static void RIOReceive(struct rio_info *p, struct Port *PortP) | 513 | static void RIOReceive(struct rio_info *p, struct Port *PortP) |
514 | { | 514 | { |
515 | struct tty_struct *TtyP; | 515 | struct tty_struct *TtyP; |
516 | unsigned short transCount; | 516 | unsigned short transCount; |
517 | struct PKT __iomem *PacketP; | 517 | struct PKT __iomem *PacketP; |
518 | register unsigned int DataCnt; | 518 | register unsigned int DataCnt; |
519 | unsigned char __iomem *ptr; | 519 | unsigned char __iomem *ptr; |
520 | unsigned char *buf; | 520 | unsigned char *buf; |
521 | int copied = 0; | 521 | int copied = 0; |
522 | 522 | ||
523 | static int intCount, RxIntCnt; | 523 | static int intCount, RxIntCnt; |
524 | 524 | ||
525 | /* | 525 | /* |
526 | ** The receive data process is to remove packets from the | 526 | ** The receive data process is to remove packets from the |
527 | ** PHB until there aren't any more or the current cblock | 527 | ** PHB until there aren't any more or the current cblock |
528 | ** is full. When this occurs, there will be some left over | 528 | ** is full. When this occurs, there will be some left over |
529 | ** data in the packet, that we must do something with. | 529 | ** data in the packet, that we must do something with. |
530 | ** As we haven't unhooked the packet from the read list | 530 | ** As we haven't unhooked the packet from the read list |
531 | ** yet, we can just leave the packet there, having first | 531 | ** yet, we can just leave the packet there, having first |
532 | ** made a note of how far we got. This means that we need | 532 | ** made a note of how far we got. This means that we need |
533 | ** a pointer per port saying where we start taking the | 533 | ** a pointer per port saying where we start taking the |
534 | ** data from - this will normally be zero, but when we | 534 | ** data from - this will normally be zero, but when we |
535 | ** run out of space it will be set to the offset of the | 535 | ** run out of space it will be set to the offset of the |
536 | ** next byte to copy from the packet data area. The packet | 536 | ** next byte to copy from the packet data area. The packet |
537 | ** length field is decremented by the number of bytes that | 537 | ** length field is decremented by the number of bytes that |
538 | ** we successfully removed from the packet. When this reaches | 538 | ** we successfully removed from the packet. When this reaches |
539 | ** zero, we reset the offset pointer to be zero, and free | 539 | ** zero, we reset the offset pointer to be zero, and free |
540 | ** the packet from the front of the queue. | 540 | ** the packet from the front of the queue. |
541 | */ | 541 | */ |
542 | 542 | ||
543 | intCount++; | 543 | intCount++; |
544 | 544 | ||
545 | TtyP = PortP->gs.tty; | 545 | TtyP = PortP->gs.port.tty; |
546 | if (!TtyP) { | 546 | if (!TtyP) { |
547 | rio_dprintk(RIO_DEBUG_INTR, "RIOReceive: tty is null. \n"); | 547 | rio_dprintk(RIO_DEBUG_INTR, "RIOReceive: tty is null. \n"); |
548 | return; | 548 | return; |
549 | } | 549 | } |
550 | 550 | ||
551 | if (PortP->State & RIO_THROTTLE_RX) { | 551 | if (PortP->State & RIO_THROTTLE_RX) { |
552 | rio_dprintk(RIO_DEBUG_INTR, "RIOReceive: Throttled. Can't handle more input.\n"); | 552 | rio_dprintk(RIO_DEBUG_INTR, "RIOReceive: Throttled. Can't handle more input.\n"); |
553 | return; | 553 | return; |
554 | } | 554 | } |
555 | 555 | ||
556 | if (PortP->State & RIO_DELETED) { | 556 | if (PortP->State & RIO_DELETED) { |
557 | while (can_remove_receive(&PacketP, PortP)) { | 557 | while (can_remove_receive(&PacketP, PortP)) { |
558 | remove_receive(PortP); | 558 | remove_receive(PortP); |
559 | put_free_end(PortP->HostP, PacketP); | 559 | put_free_end(PortP->HostP, PacketP); |
560 | } | 560 | } |
561 | } else { | 561 | } else { |
562 | /* | 562 | /* |
563 | ** loop, just so long as: | 563 | ** loop, just so long as: |
564 | ** i ) there's some data ( i.e. can_remove_receive ) | 564 | ** i ) there's some data ( i.e. can_remove_receive ) |
565 | ** ii ) we haven't been blocked | 565 | ** ii ) we haven't been blocked |
566 | ** iii ) there's somewhere to put the data | 566 | ** iii ) there's somewhere to put the data |
567 | ** iv ) we haven't outstayed our welcome | 567 | ** iv ) we haven't outstayed our welcome |
568 | */ | 568 | */ |
569 | transCount = 1; | 569 | transCount = 1; |
570 | while (can_remove_receive(&PacketP, PortP) | 570 | while (can_remove_receive(&PacketP, PortP) |
571 | && transCount) { | 571 | && transCount) { |
572 | RxIntCnt++; | 572 | RxIntCnt++; |
573 | 573 | ||
574 | /* | 574 | /* |
575 | ** check that it is not a command! | 575 | ** check that it is not a command! |
576 | */ | 576 | */ |
577 | if (readb(&PacketP->len) & PKT_CMD_BIT) { | 577 | if (readb(&PacketP->len) & PKT_CMD_BIT) { |
578 | rio_dprintk(RIO_DEBUG_INTR, "RIO: unexpected command packet received on PHB\n"); | 578 | rio_dprintk(RIO_DEBUG_INTR, "RIO: unexpected command packet received on PHB\n"); |
579 | /* rio_dprint(RIO_DEBUG_INTR, (" sysport = %d\n", p->RIOPortp->PortNum)); */ | 579 | /* rio_dprint(RIO_DEBUG_INTR, (" sysport = %d\n", p->RIOPortp->PortNum)); */ |
580 | rio_dprintk(RIO_DEBUG_INTR, " dest_unit = %d\n", readb(&PacketP->dest_unit)); | 580 | rio_dprintk(RIO_DEBUG_INTR, " dest_unit = %d\n", readb(&PacketP->dest_unit)); |
581 | rio_dprintk(RIO_DEBUG_INTR, " dest_port = %d\n", readb(&PacketP->dest_port)); | 581 | rio_dprintk(RIO_DEBUG_INTR, " dest_port = %d\n", readb(&PacketP->dest_port)); |
582 | rio_dprintk(RIO_DEBUG_INTR, " src_unit = %d\n", readb(&PacketP->src_unit)); | 582 | rio_dprintk(RIO_DEBUG_INTR, " src_unit = %d\n", readb(&PacketP->src_unit)); |
583 | rio_dprintk(RIO_DEBUG_INTR, " src_port = %d\n", readb(&PacketP->src_port)); | 583 | rio_dprintk(RIO_DEBUG_INTR, " src_port = %d\n", readb(&PacketP->src_port)); |
584 | rio_dprintk(RIO_DEBUG_INTR, " len = %d\n", readb(&PacketP->len)); | 584 | rio_dprintk(RIO_DEBUG_INTR, " len = %d\n", readb(&PacketP->len)); |
585 | rio_dprintk(RIO_DEBUG_INTR, " control = %d\n", readb(&PacketP->control)); | 585 | rio_dprintk(RIO_DEBUG_INTR, " control = %d\n", readb(&PacketP->control)); |
586 | rio_dprintk(RIO_DEBUG_INTR, " csum = %d\n", readw(&PacketP->csum)); | 586 | rio_dprintk(RIO_DEBUG_INTR, " csum = %d\n", readw(&PacketP->csum)); |
587 | rio_dprintk(RIO_DEBUG_INTR, " data bytes: "); | 587 | rio_dprintk(RIO_DEBUG_INTR, " data bytes: "); |
588 | for (DataCnt = 0; DataCnt < PKT_MAX_DATA_LEN; DataCnt++) | 588 | for (DataCnt = 0; DataCnt < PKT_MAX_DATA_LEN; DataCnt++) |
589 | rio_dprintk(RIO_DEBUG_INTR, "%d\n", readb(&PacketP->data[DataCnt])); | 589 | rio_dprintk(RIO_DEBUG_INTR, "%d\n", readb(&PacketP->data[DataCnt])); |
590 | remove_receive(PortP); | 590 | remove_receive(PortP); |
591 | put_free_end(PortP->HostP, PacketP); | 591 | put_free_end(PortP->HostP, PacketP); |
592 | continue; /* with next packet */ | 592 | continue; /* with next packet */ |
593 | } | 593 | } |
594 | 594 | ||
595 | /* | 595 | /* |
596 | ** How many characters can we move 'upstream' ? | 596 | ** How many characters can we move 'upstream' ? |
597 | ** | 597 | ** |
598 | ** Determine the minimum of the amount of data | 598 | ** Determine the minimum of the amount of data |
599 | ** available and the amount of space in which to | 599 | ** available and the amount of space in which to |
600 | ** put it. | 600 | ** put it. |
601 | ** | 601 | ** |
602 | ** 1. Get the packet length by masking 'len' | 602 | ** 1. Get the packet length by masking 'len' |
603 | ** for only the length bits. | 603 | ** for only the length bits. |
604 | ** 2. Available space is [buffer size] - [space used] | 604 | ** 2. Available space is [buffer size] - [space used] |
605 | ** | 605 | ** |
606 | ** Transfer count is the minimum of packet length | 606 | ** Transfer count is the minimum of packet length |
607 | ** and available space. | 607 | ** and available space. |
608 | */ | 608 | */ |
609 | 609 | ||
610 | transCount = tty_buffer_request_room(TtyP, readb(&PacketP->len) & PKT_LEN_MASK); | 610 | transCount = tty_buffer_request_room(TtyP, readb(&PacketP->len) & PKT_LEN_MASK); |
611 | rio_dprintk(RIO_DEBUG_REC, "port %d: Copy %d bytes\n", PortP->PortNum, transCount); | 611 | rio_dprintk(RIO_DEBUG_REC, "port %d: Copy %d bytes\n", PortP->PortNum, transCount); |
612 | /* | 612 | /* |
613 | ** To use the following 'kkprintfs' for debugging - change the '#undef' | 613 | ** To use the following 'kkprintfs' for debugging - change the '#undef' |
614 | ** to '#define', (this is the only place ___DEBUG_IT___ occurs in the | 614 | ** to '#define', (this is the only place ___DEBUG_IT___ occurs in the |
615 | ** driver). | 615 | ** driver). |
616 | */ | 616 | */ |
617 | ptr = (unsigned char __iomem *) PacketP->data + PortP->RxDataStart; | 617 | ptr = (unsigned char __iomem *) PacketP->data + PortP->RxDataStart; |
618 | 618 | ||
619 | tty_prepare_flip_string(TtyP, &buf, transCount); | 619 | tty_prepare_flip_string(TtyP, &buf, transCount); |
620 | rio_memcpy_fromio(buf, ptr, transCount); | 620 | rio_memcpy_fromio(buf, ptr, transCount); |
621 | PortP->RxDataStart += transCount; | 621 | PortP->RxDataStart += transCount; |
622 | writeb(readb(&PacketP->len)-transCount, &PacketP->len); | 622 | writeb(readb(&PacketP->len)-transCount, &PacketP->len); |
623 | copied += transCount; | 623 | copied += transCount; |
624 | 624 | ||
625 | 625 | ||
626 | 626 | ||
627 | if (readb(&PacketP->len) == 0) { | 627 | if (readb(&PacketP->len) == 0) { |
628 | /* | 628 | /* |
629 | ** If we have emptied the packet, then we can | 629 | ** If we have emptied the packet, then we can |
630 | ** free it, and reset the start pointer for | 630 | ** free it, and reset the start pointer for |
631 | ** the next packet. | 631 | ** the next packet. |
632 | */ | 632 | */ |
633 | remove_receive(PortP); | 633 | remove_receive(PortP); |
634 | put_free_end(PortP->HostP, PacketP); | 634 | put_free_end(PortP->HostP, PacketP); |
635 | PortP->RxDataStart = 0; | 635 | PortP->RxDataStart = 0; |
636 | } | 636 | } |
637 | } | 637 | } |
638 | } | 638 | } |
639 | if (copied) { | 639 | if (copied) { |
640 | rio_dprintk(RIO_DEBUG_REC, "port %d: pushing tty flip buffer: %d total bytes copied.\n", PortP->PortNum, copied); | 640 | rio_dprintk(RIO_DEBUG_REC, "port %d: pushing tty flip buffer: %d total bytes copied.\n", PortP->PortNum, copied); |
641 | tty_flip_buffer_push(TtyP); | 641 | tty_flip_buffer_push(TtyP); |
642 | } | 642 | } |
643 | 643 | ||
644 | return; | 644 | return; |
645 | } | 645 | } |
646 | 646 | ||
647 | 647 |
drivers/char/rio/rioparam.c
1 | /* | 1 | /* |
2 | ** ----------------------------------------------------------------------------- | 2 | ** ----------------------------------------------------------------------------- |
3 | ** | 3 | ** |
4 | ** Perle Specialix driver for Linux | 4 | ** Perle Specialix driver for Linux |
5 | ** Ported from existing RIO Driver for SCO sources. | 5 | ** Ported from existing RIO Driver for SCO sources. |
6 | * | 6 | * |
7 | * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK. | 7 | * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK. |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
11 | * the Free Software Foundation; either version 2 of the License, or | 11 | * the Free Software Foundation; either version 2 of the License, or |
12 | * (at your option) any later version. | 12 | * (at your option) any later version. |
13 | * | 13 | * |
14 | * This program is distributed in the hope that it will be useful, | 14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | * GNU General Public License for more details. | 17 | * GNU General Public License for more details. |
18 | * | 18 | * |
19 | * You should have received a copy of the GNU General Public License | 19 | * You should have received a copy of the GNU General Public License |
20 | * along with this program; if not, write to the Free Software | 20 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
22 | ** | 22 | ** |
23 | ** Module : rioparam.c | 23 | ** Module : rioparam.c |
24 | ** SID : 1.3 | 24 | ** SID : 1.3 |
25 | ** Last Modified : 11/6/98 10:33:45 | 25 | ** Last Modified : 11/6/98 10:33:45 |
26 | ** Retrieved : 11/6/98 10:33:50 | 26 | ** Retrieved : 11/6/98 10:33:50 |
27 | ** | 27 | ** |
28 | ** ident @(#)rioparam.c 1.3 | 28 | ** ident @(#)rioparam.c 1.3 |
29 | ** | 29 | ** |
30 | ** ----------------------------------------------------------------------------- | 30 | ** ----------------------------------------------------------------------------- |
31 | */ | 31 | */ |
32 | 32 | ||
33 | #include <linux/module.h> | 33 | #include <linux/module.h> |
34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
35 | #include <linux/errno.h> | 35 | #include <linux/errno.h> |
36 | #include <linux/tty.h> | 36 | #include <linux/tty.h> |
37 | #include <asm/io.h> | 37 | #include <asm/io.h> |
38 | #include <asm/system.h> | 38 | #include <asm/system.h> |
39 | #include <asm/string.h> | 39 | #include <asm/string.h> |
40 | #include <asm/uaccess.h> | 40 | #include <asm/uaccess.h> |
41 | 41 | ||
42 | #include <linux/termios.h> | 42 | #include <linux/termios.h> |
43 | #include <linux/serial.h> | 43 | #include <linux/serial.h> |
44 | 44 | ||
45 | #include <linux/generic_serial.h> | 45 | #include <linux/generic_serial.h> |
46 | 46 | ||
47 | 47 | ||
48 | #include "linux_compat.h" | 48 | #include "linux_compat.h" |
49 | #include "rio_linux.h" | 49 | #include "rio_linux.h" |
50 | #include "pkt.h" | 50 | #include "pkt.h" |
51 | #include "daemon.h" | 51 | #include "daemon.h" |
52 | #include "rio.h" | 52 | #include "rio.h" |
53 | #include "riospace.h" | 53 | #include "riospace.h" |
54 | #include "cmdpkt.h" | 54 | #include "cmdpkt.h" |
55 | #include "map.h" | 55 | #include "map.h" |
56 | #include "rup.h" | 56 | #include "rup.h" |
57 | #include "port.h" | 57 | #include "port.h" |
58 | #include "riodrvr.h" | 58 | #include "riodrvr.h" |
59 | #include "rioinfo.h" | 59 | #include "rioinfo.h" |
60 | #include "func.h" | 60 | #include "func.h" |
61 | #include "errors.h" | 61 | #include "errors.h" |
62 | #include "pci.h" | 62 | #include "pci.h" |
63 | 63 | ||
64 | #include "parmmap.h" | 64 | #include "parmmap.h" |
65 | #include "unixrup.h" | 65 | #include "unixrup.h" |
66 | #include "board.h" | 66 | #include "board.h" |
67 | #include "host.h" | 67 | #include "host.h" |
68 | #include "phb.h" | 68 | #include "phb.h" |
69 | #include "link.h" | 69 | #include "link.h" |
70 | #include "cmdblk.h" | 70 | #include "cmdblk.h" |
71 | #include "route.h" | 71 | #include "route.h" |
72 | #include "cirrus.h" | 72 | #include "cirrus.h" |
73 | #include "rioioctl.h" | 73 | #include "rioioctl.h" |
74 | #include "param.h" | 74 | #include "param.h" |
75 | 75 | ||
76 | 76 | ||
77 | 77 | ||
78 | /* | 78 | /* |
79 | ** The Scam, based on email from jeremyr@bugs.specialix.co.uk.... | 79 | ** The Scam, based on email from jeremyr@bugs.specialix.co.uk.... |
80 | ** | 80 | ** |
81 | ** To send a command on a particular port, you put a packet with the | 81 | ** To send a command on a particular port, you put a packet with the |
82 | ** command bit set onto the port. The command bit is in the len field, | 82 | ** command bit set onto the port. The command bit is in the len field, |
83 | ** and gets ORed in with the actual byte count. | 83 | ** and gets ORed in with the actual byte count. |
84 | ** | 84 | ** |
85 | ** When you send a packet with the command bit set the first | 85 | ** When you send a packet with the command bit set the first |
86 | ** data byte (data[0]) is interpreted as the command to execute. | 86 | ** data byte (data[0]) is interpreted as the command to execute. |
87 | ** It also governs what data structure overlay should accompany the packet. | 87 | ** It also governs what data structure overlay should accompany the packet. |
88 | ** Commands are defined in cirrus/cirrus.h | 88 | ** Commands are defined in cirrus/cirrus.h |
89 | ** | 89 | ** |
90 | ** If you want the command to pre-emt data already on the queue for the | 90 | ** If you want the command to pre-emt data already on the queue for the |
91 | ** port, set the pre-emptive bit in conjunction with the command bit. | 91 | ** port, set the pre-emptive bit in conjunction with the command bit. |
92 | ** It is not defined what will happen if you set the preemptive bit | 92 | ** It is not defined what will happen if you set the preemptive bit |
93 | ** on a packet that is NOT a command. | 93 | ** on a packet that is NOT a command. |
94 | ** | 94 | ** |
95 | ** Pre-emptive commands should be queued at the head of the queue using | 95 | ** Pre-emptive commands should be queued at the head of the queue using |
96 | ** add_start(), whereas normal commands and data are enqueued using | 96 | ** add_start(), whereas normal commands and data are enqueued using |
97 | ** add_end(). | 97 | ** add_end(). |
98 | ** | 98 | ** |
99 | ** Most commands do not use the remaining bytes in the data array. The | 99 | ** Most commands do not use the remaining bytes in the data array. The |
100 | ** exceptions are OPEN MOPEN and CONFIG. (NB. As with the SI CONFIG and | 100 | ** exceptions are OPEN MOPEN and CONFIG. (NB. As with the SI CONFIG and |
101 | ** OPEN are currently analogous). With these three commands the following | 101 | ** OPEN are currently analogous). With these three commands the following |
102 | ** 11 data bytes are all used to pass config information such as baud rate etc. | 102 | ** 11 data bytes are all used to pass config information such as baud rate etc. |
103 | ** The fields are also defined in cirrus.h. Some contain straightforward | 103 | ** The fields are also defined in cirrus.h. Some contain straightforward |
104 | ** information such as the transmit XON character. Two contain the transmit and | 104 | ** information such as the transmit XON character. Two contain the transmit and |
105 | ** receive baud rates respectively. For most baud rates there is a direct | 105 | ** receive baud rates respectively. For most baud rates there is a direct |
106 | ** mapping between the rates defined in <sys/termio.h> and the byte in the | 106 | ** mapping between the rates defined in <sys/termio.h> and the byte in the |
107 | ** packet. There are additional (non UNIX-standard) rates defined in | 107 | ** packet. There are additional (non UNIX-standard) rates defined in |
108 | ** /u/dos/rio/cirrus/h/brates.h. | 108 | ** /u/dos/rio/cirrus/h/brates.h. |
109 | ** | 109 | ** |
110 | ** The rest of the data fields contain approximations to the Cirrus registers | 110 | ** The rest of the data fields contain approximations to the Cirrus registers |
111 | ** that are used to program number of bits etc. Each registers bit fields is | 111 | ** that are used to program number of bits etc. Each registers bit fields is |
112 | ** defined in cirrus.h. | 112 | ** defined in cirrus.h. |
113 | ** | 113 | ** |
114 | ** NB. Only use those bits that are defined as being driver specific | 114 | ** NB. Only use those bits that are defined as being driver specific |
115 | ** or common to the RTA and the driver. | 115 | ** or common to the RTA and the driver. |
116 | ** | 116 | ** |
117 | ** All commands going from RTA->Host will be dealt with by the Host code - you | 117 | ** All commands going from RTA->Host will be dealt with by the Host code - you |
118 | ** will never see them. As with the SI there will be three fields to look out | 118 | ** will never see them. As with the SI there will be three fields to look out |
119 | ** for in each phb (not yet defined - needs defining a.s.a.p). | 119 | ** for in each phb (not yet defined - needs defining a.s.a.p). |
120 | ** | 120 | ** |
121 | ** modem_status - current state of handshake pins. | 121 | ** modem_status - current state of handshake pins. |
122 | ** | 122 | ** |
123 | ** port_status - current port status - equivalent to hi_stat for SI, indicates | 123 | ** port_status - current port status - equivalent to hi_stat for SI, indicates |
124 | ** if port is IDLE_OPEN, IDLE_CLOSED etc. | 124 | ** if port is IDLE_OPEN, IDLE_CLOSED etc. |
125 | ** | 125 | ** |
126 | ** break_status - bit X set if break has been received. | 126 | ** break_status - bit X set if break has been received. |
127 | ** | 127 | ** |
128 | ** Happy hacking. | 128 | ** Happy hacking. |
129 | ** | 129 | ** |
130 | */ | 130 | */ |
131 | 131 | ||
132 | /* | 132 | /* |
133 | ** RIOParam is used to open or configure a port. You pass it a PortP, | 133 | ** RIOParam is used to open or configure a port. You pass it a PortP, |
134 | ** which will have a tty struct attached to it. You also pass a command, | 134 | ** which will have a tty struct attached to it. You also pass a command, |
135 | ** either OPEN or CONFIG. The port's setup is taken from the t_ fields | 135 | ** either OPEN or CONFIG. The port's setup is taken from the t_ fields |
136 | ** of the tty struct inside the PortP, and the port is either opened | 136 | ** of the tty struct inside the PortP, and the port is either opened |
137 | ** or re-configured. You must also tell RIOParam if the device is a modem | 137 | ** or re-configured. You must also tell RIOParam if the device is a modem |
138 | ** device or not (i.e. top bit of minor number set or clear - take special | 138 | ** device or not (i.e. top bit of minor number set or clear - take special |
139 | ** care when deciding on this!). | 139 | ** care when deciding on this!). |
140 | ** RIOParam neither flushes nor waits for drain, and is NOT preemptive. | 140 | ** RIOParam neither flushes nor waits for drain, and is NOT preemptive. |
141 | ** | 141 | ** |
142 | ** RIOParam assumes it will be called at splrio(), and also assumes | 142 | ** RIOParam assumes it will be called at splrio(), and also assumes |
143 | ** that CookMode is set correctly in the port structure. | 143 | ** that CookMode is set correctly in the port structure. |
144 | ** | 144 | ** |
145 | ** NB. for MPX | 145 | ** NB. for MPX |
146 | ** tty lock must NOT have been previously acquired. | 146 | ** tty lock must NOT have been previously acquired. |
147 | */ | 147 | */ |
148 | int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag) | 148 | int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag) |
149 | { | 149 | { |
150 | struct tty_struct *TtyP; | 150 | struct tty_struct *TtyP; |
151 | int retval; | 151 | int retval; |
152 | struct phb_param __iomem *phb_param_ptr; | 152 | struct phb_param __iomem *phb_param_ptr; |
153 | struct PKT __iomem *PacketP; | 153 | struct PKT __iomem *PacketP; |
154 | int res; | 154 | int res; |
155 | u8 Cor1 = 0, Cor2 = 0, Cor4 = 0, Cor5 = 0; | 155 | u8 Cor1 = 0, Cor2 = 0, Cor4 = 0, Cor5 = 0; |
156 | u8 TxXon = 0, TxXoff = 0, RxXon = 0, RxXoff = 0; | 156 | u8 TxXon = 0, TxXoff = 0, RxXon = 0, RxXoff = 0; |
157 | u8 LNext = 0, TxBaud = 0, RxBaud = 0; | 157 | u8 LNext = 0, TxBaud = 0, RxBaud = 0; |
158 | int retries = 0xff; | 158 | int retries = 0xff; |
159 | unsigned long flags; | 159 | unsigned long flags; |
160 | 160 | ||
161 | func_enter(); | 161 | func_enter(); |
162 | 162 | ||
163 | TtyP = PortP->gs.tty; | 163 | TtyP = PortP->gs.port.tty; |
164 | 164 | ||
165 | rio_dprintk(RIO_DEBUG_PARAM, "RIOParam: Port:%d cmd:%d Modem:%d SleepFlag:%d Mapped: %d, tty=%p\n", PortP->PortNum, cmd, Modem, SleepFlag, PortP->Mapped, TtyP); | 165 | rio_dprintk(RIO_DEBUG_PARAM, "RIOParam: Port:%d cmd:%d Modem:%d SleepFlag:%d Mapped: %d, tty=%p\n", PortP->PortNum, cmd, Modem, SleepFlag, PortP->Mapped, TtyP); |
166 | 166 | ||
167 | if (!TtyP) { | 167 | if (!TtyP) { |
168 | rio_dprintk(RIO_DEBUG_PARAM, "Can't call rioparam with null tty.\n"); | 168 | rio_dprintk(RIO_DEBUG_PARAM, "Can't call rioparam with null tty.\n"); |
169 | 169 | ||
170 | func_exit(); | 170 | func_exit(); |
171 | 171 | ||
172 | return RIO_FAIL; | 172 | return RIO_FAIL; |
173 | } | 173 | } |
174 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 174 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
175 | 175 | ||
176 | if (cmd == RIOC_OPEN) { | 176 | if (cmd == RIOC_OPEN) { |
177 | /* | 177 | /* |
178 | ** If the port is set to store or lock the parameters, and it is | 178 | ** If the port is set to store or lock the parameters, and it is |
179 | ** paramed with OPEN, we want to restore the saved port termio, but | 179 | ** paramed with OPEN, we want to restore the saved port termio, but |
180 | ** only if StoredTermio has been saved, i.e. NOT 1st open after reboot. | 180 | ** only if StoredTermio has been saved, i.e. NOT 1st open after reboot. |
181 | */ | 181 | */ |
182 | } | 182 | } |
183 | 183 | ||
184 | /* | 184 | /* |
185 | ** wait for space | 185 | ** wait for space |
186 | */ | 186 | */ |
187 | while (!(res = can_add_transmit(&PacketP, PortP)) || (PortP->InUse != NOT_INUSE)) { | 187 | while (!(res = can_add_transmit(&PacketP, PortP)) || (PortP->InUse != NOT_INUSE)) { |
188 | if (retries-- <= 0) { | 188 | if (retries-- <= 0) { |
189 | break; | 189 | break; |
190 | } | 190 | } |
191 | if (PortP->InUse != NOT_INUSE) { | 191 | if (PortP->InUse != NOT_INUSE) { |
192 | rio_dprintk(RIO_DEBUG_PARAM, "Port IN_USE for pre-emptive command\n"); | 192 | rio_dprintk(RIO_DEBUG_PARAM, "Port IN_USE for pre-emptive command\n"); |
193 | } | 193 | } |
194 | 194 | ||
195 | if (!res) { | 195 | if (!res) { |
196 | rio_dprintk(RIO_DEBUG_PARAM, "Port has no space on transmit queue\n"); | 196 | rio_dprintk(RIO_DEBUG_PARAM, "Port has no space on transmit queue\n"); |
197 | } | 197 | } |
198 | 198 | ||
199 | if (SleepFlag != OK_TO_SLEEP) { | 199 | if (SleepFlag != OK_TO_SLEEP) { |
200 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 200 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
201 | func_exit(); | 201 | func_exit(); |
202 | 202 | ||
203 | return RIO_FAIL; | 203 | return RIO_FAIL; |
204 | } | 204 | } |
205 | 205 | ||
206 | rio_dprintk(RIO_DEBUG_PARAM, "wait for can_add_transmit\n"); | 206 | rio_dprintk(RIO_DEBUG_PARAM, "wait for can_add_transmit\n"); |
207 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 207 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
208 | retval = RIODelay(PortP, HUNDRED_MS); | 208 | retval = RIODelay(PortP, HUNDRED_MS); |
209 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 209 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
210 | if (retval == RIO_FAIL) { | 210 | if (retval == RIO_FAIL) { |
211 | rio_dprintk(RIO_DEBUG_PARAM, "wait for can_add_transmit broken by signal\n"); | 211 | rio_dprintk(RIO_DEBUG_PARAM, "wait for can_add_transmit broken by signal\n"); |
212 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 212 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
213 | func_exit(); | 213 | func_exit(); |
214 | return -EINTR; | 214 | return -EINTR; |
215 | } | 215 | } |
216 | if (PortP->State & RIO_DELETED) { | 216 | if (PortP->State & RIO_DELETED) { |
217 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 217 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
218 | func_exit(); | 218 | func_exit(); |
219 | return 0; | 219 | return 0; |
220 | } | 220 | } |
221 | } | 221 | } |
222 | 222 | ||
223 | if (!res) { | 223 | if (!res) { |
224 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 224 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
225 | func_exit(); | 225 | func_exit(); |
226 | 226 | ||
227 | return RIO_FAIL; | 227 | return RIO_FAIL; |
228 | } | 228 | } |
229 | 229 | ||
230 | rio_dprintk(RIO_DEBUG_PARAM, "can_add_transmit() returns %x\n", res); | 230 | rio_dprintk(RIO_DEBUG_PARAM, "can_add_transmit() returns %x\n", res); |
231 | rio_dprintk(RIO_DEBUG_PARAM, "Packet is %p\n", PacketP); | 231 | rio_dprintk(RIO_DEBUG_PARAM, "Packet is %p\n", PacketP); |
232 | 232 | ||
233 | phb_param_ptr = (struct phb_param __iomem *) PacketP->data; | 233 | phb_param_ptr = (struct phb_param __iomem *) PacketP->data; |
234 | 234 | ||
235 | 235 | ||
236 | switch (TtyP->termios->c_cflag & CSIZE) { | 236 | switch (TtyP->termios->c_cflag & CSIZE) { |
237 | case CS5: | 237 | case CS5: |
238 | { | 238 | { |
239 | rio_dprintk(RIO_DEBUG_PARAM, "5 bit data\n"); | 239 | rio_dprintk(RIO_DEBUG_PARAM, "5 bit data\n"); |
240 | Cor1 |= RIOC_COR1_5BITS; | 240 | Cor1 |= RIOC_COR1_5BITS; |
241 | break; | 241 | break; |
242 | } | 242 | } |
243 | case CS6: | 243 | case CS6: |
244 | { | 244 | { |
245 | rio_dprintk(RIO_DEBUG_PARAM, "6 bit data\n"); | 245 | rio_dprintk(RIO_DEBUG_PARAM, "6 bit data\n"); |
246 | Cor1 |= RIOC_COR1_6BITS; | 246 | Cor1 |= RIOC_COR1_6BITS; |
247 | break; | 247 | break; |
248 | } | 248 | } |
249 | case CS7: | 249 | case CS7: |
250 | { | 250 | { |
251 | rio_dprintk(RIO_DEBUG_PARAM, "7 bit data\n"); | 251 | rio_dprintk(RIO_DEBUG_PARAM, "7 bit data\n"); |
252 | Cor1 |= RIOC_COR1_7BITS; | 252 | Cor1 |= RIOC_COR1_7BITS; |
253 | break; | 253 | break; |
254 | } | 254 | } |
255 | case CS8: | 255 | case CS8: |
256 | { | 256 | { |
257 | rio_dprintk(RIO_DEBUG_PARAM, "8 bit data\n"); | 257 | rio_dprintk(RIO_DEBUG_PARAM, "8 bit data\n"); |
258 | Cor1 |= RIOC_COR1_8BITS; | 258 | Cor1 |= RIOC_COR1_8BITS; |
259 | break; | 259 | break; |
260 | } | 260 | } |
261 | } | 261 | } |
262 | 262 | ||
263 | if (TtyP->termios->c_cflag & CSTOPB) { | 263 | if (TtyP->termios->c_cflag & CSTOPB) { |
264 | rio_dprintk(RIO_DEBUG_PARAM, "2 stop bits\n"); | 264 | rio_dprintk(RIO_DEBUG_PARAM, "2 stop bits\n"); |
265 | Cor1 |= RIOC_COR1_2STOP; | 265 | Cor1 |= RIOC_COR1_2STOP; |
266 | } else { | 266 | } else { |
267 | rio_dprintk(RIO_DEBUG_PARAM, "1 stop bit\n"); | 267 | rio_dprintk(RIO_DEBUG_PARAM, "1 stop bit\n"); |
268 | Cor1 |= RIOC_COR1_1STOP; | 268 | Cor1 |= RIOC_COR1_1STOP; |
269 | } | 269 | } |
270 | 270 | ||
271 | if (TtyP->termios->c_cflag & PARENB) { | 271 | if (TtyP->termios->c_cflag & PARENB) { |
272 | rio_dprintk(RIO_DEBUG_PARAM, "Enable parity\n"); | 272 | rio_dprintk(RIO_DEBUG_PARAM, "Enable parity\n"); |
273 | Cor1 |= RIOC_COR1_NORMAL; | 273 | Cor1 |= RIOC_COR1_NORMAL; |
274 | } else { | 274 | } else { |
275 | rio_dprintk(RIO_DEBUG_PARAM, "Disable parity\n"); | 275 | rio_dprintk(RIO_DEBUG_PARAM, "Disable parity\n"); |
276 | Cor1 |= RIOC_COR1_NOP; | 276 | Cor1 |= RIOC_COR1_NOP; |
277 | } | 277 | } |
278 | if (TtyP->termios->c_cflag & PARODD) { | 278 | if (TtyP->termios->c_cflag & PARODD) { |
279 | rio_dprintk(RIO_DEBUG_PARAM, "Odd parity\n"); | 279 | rio_dprintk(RIO_DEBUG_PARAM, "Odd parity\n"); |
280 | Cor1 |= RIOC_COR1_ODD; | 280 | Cor1 |= RIOC_COR1_ODD; |
281 | } else { | 281 | } else { |
282 | rio_dprintk(RIO_DEBUG_PARAM, "Even parity\n"); | 282 | rio_dprintk(RIO_DEBUG_PARAM, "Even parity\n"); |
283 | Cor1 |= RIOC_COR1_EVEN; | 283 | Cor1 |= RIOC_COR1_EVEN; |
284 | } | 284 | } |
285 | 285 | ||
286 | /* | 286 | /* |
287 | ** COR 2 | 287 | ** COR 2 |
288 | */ | 288 | */ |
289 | if (TtyP->termios->c_iflag & IXON) { | 289 | if (TtyP->termios->c_iflag & IXON) { |
290 | rio_dprintk(RIO_DEBUG_PARAM, "Enable start/stop output control\n"); | 290 | rio_dprintk(RIO_DEBUG_PARAM, "Enable start/stop output control\n"); |
291 | Cor2 |= RIOC_COR2_IXON; | 291 | Cor2 |= RIOC_COR2_IXON; |
292 | } else { | 292 | } else { |
293 | if (PortP->Config & RIO_IXON) { | 293 | if (PortP->Config & RIO_IXON) { |
294 | rio_dprintk(RIO_DEBUG_PARAM, "Force enable start/stop output control\n"); | 294 | rio_dprintk(RIO_DEBUG_PARAM, "Force enable start/stop output control\n"); |
295 | Cor2 |= RIOC_COR2_IXON; | 295 | Cor2 |= RIOC_COR2_IXON; |
296 | } else | 296 | } else |
297 | rio_dprintk(RIO_DEBUG_PARAM, "IXON has been disabled.\n"); | 297 | rio_dprintk(RIO_DEBUG_PARAM, "IXON has been disabled.\n"); |
298 | } | 298 | } |
299 | 299 | ||
300 | if (TtyP->termios->c_iflag & IXANY) { | 300 | if (TtyP->termios->c_iflag & IXANY) { |
301 | if (PortP->Config & RIO_IXANY) { | 301 | if (PortP->Config & RIO_IXANY) { |
302 | rio_dprintk(RIO_DEBUG_PARAM, "Enable any key to restart output\n"); | 302 | rio_dprintk(RIO_DEBUG_PARAM, "Enable any key to restart output\n"); |
303 | Cor2 |= RIOC_COR2_IXANY; | 303 | Cor2 |= RIOC_COR2_IXANY; |
304 | } else | 304 | } else |
305 | rio_dprintk(RIO_DEBUG_PARAM, "IXANY has been disabled due to sanity reasons.\n"); | 305 | rio_dprintk(RIO_DEBUG_PARAM, "IXANY has been disabled due to sanity reasons.\n"); |
306 | } | 306 | } |
307 | 307 | ||
308 | if (TtyP->termios->c_iflag & IXOFF) { | 308 | if (TtyP->termios->c_iflag & IXOFF) { |
309 | rio_dprintk(RIO_DEBUG_PARAM, "Enable start/stop input control 2\n"); | 309 | rio_dprintk(RIO_DEBUG_PARAM, "Enable start/stop input control 2\n"); |
310 | Cor2 |= RIOC_COR2_IXOFF; | 310 | Cor2 |= RIOC_COR2_IXOFF; |
311 | } | 311 | } |
312 | 312 | ||
313 | if (TtyP->termios->c_cflag & HUPCL) { | 313 | if (TtyP->termios->c_cflag & HUPCL) { |
314 | rio_dprintk(RIO_DEBUG_PARAM, "Hangup on last close\n"); | 314 | rio_dprintk(RIO_DEBUG_PARAM, "Hangup on last close\n"); |
315 | Cor2 |= RIOC_COR2_HUPCL; | 315 | Cor2 |= RIOC_COR2_HUPCL; |
316 | } | 316 | } |
317 | 317 | ||
318 | if (C_CRTSCTS(TtyP)) { | 318 | if (C_CRTSCTS(TtyP)) { |
319 | rio_dprintk(RIO_DEBUG_PARAM, "Rx hardware flow control enabled\n"); | 319 | rio_dprintk(RIO_DEBUG_PARAM, "Rx hardware flow control enabled\n"); |
320 | Cor2 |= RIOC_COR2_CTSFLOW; | 320 | Cor2 |= RIOC_COR2_CTSFLOW; |
321 | Cor2 |= RIOC_COR2_RTSFLOW; | 321 | Cor2 |= RIOC_COR2_RTSFLOW; |
322 | } else { | 322 | } else { |
323 | rio_dprintk(RIO_DEBUG_PARAM, "Rx hardware flow control disabled\n"); | 323 | rio_dprintk(RIO_DEBUG_PARAM, "Rx hardware flow control disabled\n"); |
324 | Cor2 &= ~RIOC_COR2_CTSFLOW; | 324 | Cor2 &= ~RIOC_COR2_CTSFLOW; |
325 | Cor2 &= ~RIOC_COR2_RTSFLOW; | 325 | Cor2 &= ~RIOC_COR2_RTSFLOW; |
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | if (TtyP->termios->c_cflag & CLOCAL) { | 329 | if (TtyP->termios->c_cflag & CLOCAL) { |
330 | rio_dprintk(RIO_DEBUG_PARAM, "Local line\n"); | 330 | rio_dprintk(RIO_DEBUG_PARAM, "Local line\n"); |
331 | } else { | 331 | } else { |
332 | rio_dprintk(RIO_DEBUG_PARAM, "Possible Modem line\n"); | 332 | rio_dprintk(RIO_DEBUG_PARAM, "Possible Modem line\n"); |
333 | } | 333 | } |
334 | 334 | ||
335 | /* | 335 | /* |
336 | ** COR 4 (there is no COR 3) | 336 | ** COR 4 (there is no COR 3) |
337 | */ | 337 | */ |
338 | if (TtyP->termios->c_iflag & IGNBRK) { | 338 | if (TtyP->termios->c_iflag & IGNBRK) { |
339 | rio_dprintk(RIO_DEBUG_PARAM, "Ignore break condition\n"); | 339 | rio_dprintk(RIO_DEBUG_PARAM, "Ignore break condition\n"); |
340 | Cor4 |= RIOC_COR4_IGNBRK; | 340 | Cor4 |= RIOC_COR4_IGNBRK; |
341 | } | 341 | } |
342 | if (!(TtyP->termios->c_iflag & BRKINT)) { | 342 | if (!(TtyP->termios->c_iflag & BRKINT)) { |
343 | rio_dprintk(RIO_DEBUG_PARAM, "Break generates NULL condition\n"); | 343 | rio_dprintk(RIO_DEBUG_PARAM, "Break generates NULL condition\n"); |
344 | Cor4 |= RIOC_COR4_NBRKINT; | 344 | Cor4 |= RIOC_COR4_NBRKINT; |
345 | } else { | 345 | } else { |
346 | rio_dprintk(RIO_DEBUG_PARAM, "Interrupt on break condition\n"); | 346 | rio_dprintk(RIO_DEBUG_PARAM, "Interrupt on break condition\n"); |
347 | } | 347 | } |
348 | 348 | ||
349 | if (TtyP->termios->c_iflag & INLCR) { | 349 | if (TtyP->termios->c_iflag & INLCR) { |
350 | rio_dprintk(RIO_DEBUG_PARAM, "Map newline to carriage return on input\n"); | 350 | rio_dprintk(RIO_DEBUG_PARAM, "Map newline to carriage return on input\n"); |
351 | Cor4 |= RIOC_COR4_INLCR; | 351 | Cor4 |= RIOC_COR4_INLCR; |
352 | } | 352 | } |
353 | 353 | ||
354 | if (TtyP->termios->c_iflag & IGNCR) { | 354 | if (TtyP->termios->c_iflag & IGNCR) { |
355 | rio_dprintk(RIO_DEBUG_PARAM, "Ignore carriage return on input\n"); | 355 | rio_dprintk(RIO_DEBUG_PARAM, "Ignore carriage return on input\n"); |
356 | Cor4 |= RIOC_COR4_IGNCR; | 356 | Cor4 |= RIOC_COR4_IGNCR; |
357 | } | 357 | } |
358 | 358 | ||
359 | if (TtyP->termios->c_iflag & ICRNL) { | 359 | if (TtyP->termios->c_iflag & ICRNL) { |
360 | rio_dprintk(RIO_DEBUG_PARAM, "Map carriage return to newline on input\n"); | 360 | rio_dprintk(RIO_DEBUG_PARAM, "Map carriage return to newline on input\n"); |
361 | Cor4 |= RIOC_COR4_ICRNL; | 361 | Cor4 |= RIOC_COR4_ICRNL; |
362 | } | 362 | } |
363 | if (TtyP->termios->c_iflag & IGNPAR) { | 363 | if (TtyP->termios->c_iflag & IGNPAR) { |
364 | rio_dprintk(RIO_DEBUG_PARAM, "Ignore characters with parity errors\n"); | 364 | rio_dprintk(RIO_DEBUG_PARAM, "Ignore characters with parity errors\n"); |
365 | Cor4 |= RIOC_COR4_IGNPAR; | 365 | Cor4 |= RIOC_COR4_IGNPAR; |
366 | } | 366 | } |
367 | if (TtyP->termios->c_iflag & PARMRK) { | 367 | if (TtyP->termios->c_iflag & PARMRK) { |
368 | rio_dprintk(RIO_DEBUG_PARAM, "Mark parity errors\n"); | 368 | rio_dprintk(RIO_DEBUG_PARAM, "Mark parity errors\n"); |
369 | Cor4 |= RIOC_COR4_PARMRK; | 369 | Cor4 |= RIOC_COR4_PARMRK; |
370 | } | 370 | } |
371 | 371 | ||
372 | /* | 372 | /* |
373 | ** Set the RAISEMOD flag to ensure that the modem lines are raised | 373 | ** Set the RAISEMOD flag to ensure that the modem lines are raised |
374 | ** on reception of a config packet. | 374 | ** on reception of a config packet. |
375 | ** The download code handles the zero baud condition. | 375 | ** The download code handles the zero baud condition. |
376 | */ | 376 | */ |
377 | Cor4 |= RIOC_COR4_RAISEMOD; | 377 | Cor4 |= RIOC_COR4_RAISEMOD; |
378 | 378 | ||
379 | /* | 379 | /* |
380 | ** COR 5 | 380 | ** COR 5 |
381 | */ | 381 | */ |
382 | 382 | ||
383 | Cor5 = RIOC_COR5_CMOE; | 383 | Cor5 = RIOC_COR5_CMOE; |
384 | 384 | ||
385 | /* | 385 | /* |
386 | ** Set to monitor tbusy/tstop (or not). | 386 | ** Set to monitor tbusy/tstop (or not). |
387 | */ | 387 | */ |
388 | 388 | ||
389 | if (PortP->MonitorTstate) | 389 | if (PortP->MonitorTstate) |
390 | Cor5 |= RIOC_COR5_TSTATE_ON; | 390 | Cor5 |= RIOC_COR5_TSTATE_ON; |
391 | else | 391 | else |
392 | Cor5 |= RIOC_COR5_TSTATE_OFF; | 392 | Cor5 |= RIOC_COR5_TSTATE_OFF; |
393 | 393 | ||
394 | /* | 394 | /* |
395 | ** Could set LNE here if you wanted LNext processing. SVR4 will use it. | 395 | ** Could set LNE here if you wanted LNext processing. SVR4 will use it. |
396 | */ | 396 | */ |
397 | if (TtyP->termios->c_iflag & ISTRIP) { | 397 | if (TtyP->termios->c_iflag & ISTRIP) { |
398 | rio_dprintk(RIO_DEBUG_PARAM, "Strip input characters\n"); | 398 | rio_dprintk(RIO_DEBUG_PARAM, "Strip input characters\n"); |
399 | if (!(PortP->State & RIO_TRIAD_MODE)) { | 399 | if (!(PortP->State & RIO_TRIAD_MODE)) { |
400 | Cor5 |= RIOC_COR5_ISTRIP; | 400 | Cor5 |= RIOC_COR5_ISTRIP; |
401 | } | 401 | } |
402 | } | 402 | } |
403 | 403 | ||
404 | if (TtyP->termios->c_oflag & ONLCR) { | 404 | if (TtyP->termios->c_oflag & ONLCR) { |
405 | rio_dprintk(RIO_DEBUG_PARAM, "Map newline to carriage-return, newline on output\n"); | 405 | rio_dprintk(RIO_DEBUG_PARAM, "Map newline to carriage-return, newline on output\n"); |
406 | if (PortP->CookMode == COOK_MEDIUM) | 406 | if (PortP->CookMode == COOK_MEDIUM) |
407 | Cor5 |= RIOC_COR5_ONLCR; | 407 | Cor5 |= RIOC_COR5_ONLCR; |
408 | } | 408 | } |
409 | if (TtyP->termios->c_oflag & OCRNL) { | 409 | if (TtyP->termios->c_oflag & OCRNL) { |
410 | rio_dprintk(RIO_DEBUG_PARAM, "Map carriage return to newline on output\n"); | 410 | rio_dprintk(RIO_DEBUG_PARAM, "Map carriage return to newline on output\n"); |
411 | if (PortP->CookMode == COOK_MEDIUM) | 411 | if (PortP->CookMode == COOK_MEDIUM) |
412 | Cor5 |= RIOC_COR5_OCRNL; | 412 | Cor5 |= RIOC_COR5_OCRNL; |
413 | } | 413 | } |
414 | if ((TtyP->termios->c_oflag & TABDLY) == TAB3) { | 414 | if ((TtyP->termios->c_oflag & TABDLY) == TAB3) { |
415 | rio_dprintk(RIO_DEBUG_PARAM, "Tab delay 3 set\n"); | 415 | rio_dprintk(RIO_DEBUG_PARAM, "Tab delay 3 set\n"); |
416 | if (PortP->CookMode == COOK_MEDIUM) | 416 | if (PortP->CookMode == COOK_MEDIUM) |
417 | Cor5 |= RIOC_COR5_TAB3; | 417 | Cor5 |= RIOC_COR5_TAB3; |
418 | } | 418 | } |
419 | 419 | ||
420 | /* | 420 | /* |
421 | ** Flow control bytes. | 421 | ** Flow control bytes. |
422 | */ | 422 | */ |
423 | TxXon = TtyP->termios->c_cc[VSTART]; | 423 | TxXon = TtyP->termios->c_cc[VSTART]; |
424 | TxXoff = TtyP->termios->c_cc[VSTOP]; | 424 | TxXoff = TtyP->termios->c_cc[VSTOP]; |
425 | RxXon = TtyP->termios->c_cc[VSTART]; | 425 | RxXon = TtyP->termios->c_cc[VSTART]; |
426 | RxXoff = TtyP->termios->c_cc[VSTOP]; | 426 | RxXoff = TtyP->termios->c_cc[VSTOP]; |
427 | /* | 427 | /* |
428 | ** LNEXT byte | 428 | ** LNEXT byte |
429 | */ | 429 | */ |
430 | LNext = 0; | 430 | LNext = 0; |
431 | 431 | ||
432 | /* | 432 | /* |
433 | ** Baud rate bytes | 433 | ** Baud rate bytes |
434 | */ | 434 | */ |
435 | rio_dprintk(RIO_DEBUG_PARAM, "Mapping of rx/tx baud %x (%x)\n", TtyP->termios->c_cflag, CBAUD); | 435 | rio_dprintk(RIO_DEBUG_PARAM, "Mapping of rx/tx baud %x (%x)\n", TtyP->termios->c_cflag, CBAUD); |
436 | 436 | ||
437 | switch (TtyP->termios->c_cflag & CBAUD) { | 437 | switch (TtyP->termios->c_cflag & CBAUD) { |
438 | #define e(b) case B ## b : RxBaud = TxBaud = RIO_B ## b ;break | 438 | #define e(b) case B ## b : RxBaud = TxBaud = RIO_B ## b ;break |
439 | e(50); | 439 | e(50); |
440 | e(75); | 440 | e(75); |
441 | e(110); | 441 | e(110); |
442 | e(134); | 442 | e(134); |
443 | e(150); | 443 | e(150); |
444 | e(200); | 444 | e(200); |
445 | e(300); | 445 | e(300); |
446 | e(600); | 446 | e(600); |
447 | e(1200); | 447 | e(1200); |
448 | e(1800); | 448 | e(1800); |
449 | e(2400); | 449 | e(2400); |
450 | e(4800); | 450 | e(4800); |
451 | e(9600); | 451 | e(9600); |
452 | e(19200); | 452 | e(19200); |
453 | e(38400); | 453 | e(38400); |
454 | e(57600); | 454 | e(57600); |
455 | e(115200); /* e(230400);e(460800); e(921600); */ | 455 | e(115200); /* e(230400);e(460800); e(921600); */ |
456 | } | 456 | } |
457 | 457 | ||
458 | rio_dprintk(RIO_DEBUG_PARAM, "tx baud 0x%x, rx baud 0x%x\n", TxBaud, RxBaud); | 458 | rio_dprintk(RIO_DEBUG_PARAM, "tx baud 0x%x, rx baud 0x%x\n", TxBaud, RxBaud); |
459 | 459 | ||
460 | 460 | ||
461 | /* | 461 | /* |
462 | ** Leftovers | 462 | ** Leftovers |
463 | */ | 463 | */ |
464 | if (TtyP->termios->c_cflag & CREAD) | 464 | if (TtyP->termios->c_cflag & CREAD) |
465 | rio_dprintk(RIO_DEBUG_PARAM, "Enable receiver\n"); | 465 | rio_dprintk(RIO_DEBUG_PARAM, "Enable receiver\n"); |
466 | #ifdef RCV1EN | 466 | #ifdef RCV1EN |
467 | if (TtyP->termios->c_cflag & RCV1EN) | 467 | if (TtyP->termios->c_cflag & RCV1EN) |
468 | rio_dprintk(RIO_DEBUG_PARAM, "RCV1EN (?)\n"); | 468 | rio_dprintk(RIO_DEBUG_PARAM, "RCV1EN (?)\n"); |
469 | #endif | 469 | #endif |
470 | #ifdef XMT1EN | 470 | #ifdef XMT1EN |
471 | if (TtyP->termios->c_cflag & XMT1EN) | 471 | if (TtyP->termios->c_cflag & XMT1EN) |
472 | rio_dprintk(RIO_DEBUG_PARAM, "XMT1EN (?)\n"); | 472 | rio_dprintk(RIO_DEBUG_PARAM, "XMT1EN (?)\n"); |
473 | #endif | 473 | #endif |
474 | if (TtyP->termios->c_lflag & ISIG) | 474 | if (TtyP->termios->c_lflag & ISIG) |
475 | rio_dprintk(RIO_DEBUG_PARAM, "Input character signal generating enabled\n"); | 475 | rio_dprintk(RIO_DEBUG_PARAM, "Input character signal generating enabled\n"); |
476 | if (TtyP->termios->c_lflag & ICANON) | 476 | if (TtyP->termios->c_lflag & ICANON) |
477 | rio_dprintk(RIO_DEBUG_PARAM, "Canonical input: erase and kill enabled\n"); | 477 | rio_dprintk(RIO_DEBUG_PARAM, "Canonical input: erase and kill enabled\n"); |
478 | if (TtyP->termios->c_lflag & XCASE) | 478 | if (TtyP->termios->c_lflag & XCASE) |
479 | rio_dprintk(RIO_DEBUG_PARAM, "Canonical upper/lower presentation\n"); | 479 | rio_dprintk(RIO_DEBUG_PARAM, "Canonical upper/lower presentation\n"); |
480 | if (TtyP->termios->c_lflag & ECHO) | 480 | if (TtyP->termios->c_lflag & ECHO) |
481 | rio_dprintk(RIO_DEBUG_PARAM, "Enable input echo\n"); | 481 | rio_dprintk(RIO_DEBUG_PARAM, "Enable input echo\n"); |
482 | if (TtyP->termios->c_lflag & ECHOE) | 482 | if (TtyP->termios->c_lflag & ECHOE) |
483 | rio_dprintk(RIO_DEBUG_PARAM, "Enable echo erase\n"); | 483 | rio_dprintk(RIO_DEBUG_PARAM, "Enable echo erase\n"); |
484 | if (TtyP->termios->c_lflag & ECHOK) | 484 | if (TtyP->termios->c_lflag & ECHOK) |
485 | rio_dprintk(RIO_DEBUG_PARAM, "Enable echo kill\n"); | 485 | rio_dprintk(RIO_DEBUG_PARAM, "Enable echo kill\n"); |
486 | if (TtyP->termios->c_lflag & ECHONL) | 486 | if (TtyP->termios->c_lflag & ECHONL) |
487 | rio_dprintk(RIO_DEBUG_PARAM, "Enable echo newline\n"); | 487 | rio_dprintk(RIO_DEBUG_PARAM, "Enable echo newline\n"); |
488 | if (TtyP->termios->c_lflag & NOFLSH) | 488 | if (TtyP->termios->c_lflag & NOFLSH) |
489 | rio_dprintk(RIO_DEBUG_PARAM, "Disable flush after interrupt or quit\n"); | 489 | rio_dprintk(RIO_DEBUG_PARAM, "Disable flush after interrupt or quit\n"); |
490 | #ifdef TOSTOP | 490 | #ifdef TOSTOP |
491 | if (TtyP->termios->c_lflag & TOSTOP) | 491 | if (TtyP->termios->c_lflag & TOSTOP) |
492 | rio_dprintk(RIO_DEBUG_PARAM, "Send SIGTTOU for background output\n"); | 492 | rio_dprintk(RIO_DEBUG_PARAM, "Send SIGTTOU for background output\n"); |
493 | #endif | 493 | #endif |
494 | #ifdef XCLUDE | 494 | #ifdef XCLUDE |
495 | if (TtyP->termios->c_lflag & XCLUDE) | 495 | if (TtyP->termios->c_lflag & XCLUDE) |
496 | rio_dprintk(RIO_DEBUG_PARAM, "Exclusive use of this line\n"); | 496 | rio_dprintk(RIO_DEBUG_PARAM, "Exclusive use of this line\n"); |
497 | #endif | 497 | #endif |
498 | if (TtyP->termios->c_iflag & IUCLC) | 498 | if (TtyP->termios->c_iflag & IUCLC) |
499 | rio_dprintk(RIO_DEBUG_PARAM, "Map uppercase to lowercase on input\n"); | 499 | rio_dprintk(RIO_DEBUG_PARAM, "Map uppercase to lowercase on input\n"); |
500 | if (TtyP->termios->c_oflag & OPOST) | 500 | if (TtyP->termios->c_oflag & OPOST) |
501 | rio_dprintk(RIO_DEBUG_PARAM, "Enable output post-processing\n"); | 501 | rio_dprintk(RIO_DEBUG_PARAM, "Enable output post-processing\n"); |
502 | if (TtyP->termios->c_oflag & OLCUC) | 502 | if (TtyP->termios->c_oflag & OLCUC) |
503 | rio_dprintk(RIO_DEBUG_PARAM, "Map lowercase to uppercase on output\n"); | 503 | rio_dprintk(RIO_DEBUG_PARAM, "Map lowercase to uppercase on output\n"); |
504 | if (TtyP->termios->c_oflag & ONOCR) | 504 | if (TtyP->termios->c_oflag & ONOCR) |
505 | rio_dprintk(RIO_DEBUG_PARAM, "No carriage return output at column 0\n"); | 505 | rio_dprintk(RIO_DEBUG_PARAM, "No carriage return output at column 0\n"); |
506 | if (TtyP->termios->c_oflag & ONLRET) | 506 | if (TtyP->termios->c_oflag & ONLRET) |
507 | rio_dprintk(RIO_DEBUG_PARAM, "Newline performs carriage return function\n"); | 507 | rio_dprintk(RIO_DEBUG_PARAM, "Newline performs carriage return function\n"); |
508 | if (TtyP->termios->c_oflag & OFILL) | 508 | if (TtyP->termios->c_oflag & OFILL) |
509 | rio_dprintk(RIO_DEBUG_PARAM, "Use fill characters for delay\n"); | 509 | rio_dprintk(RIO_DEBUG_PARAM, "Use fill characters for delay\n"); |
510 | if (TtyP->termios->c_oflag & OFDEL) | 510 | if (TtyP->termios->c_oflag & OFDEL) |
511 | rio_dprintk(RIO_DEBUG_PARAM, "Fill character is DEL\n"); | 511 | rio_dprintk(RIO_DEBUG_PARAM, "Fill character is DEL\n"); |
512 | if (TtyP->termios->c_oflag & NLDLY) | 512 | if (TtyP->termios->c_oflag & NLDLY) |
513 | rio_dprintk(RIO_DEBUG_PARAM, "Newline delay set\n"); | 513 | rio_dprintk(RIO_DEBUG_PARAM, "Newline delay set\n"); |
514 | if (TtyP->termios->c_oflag & CRDLY) | 514 | if (TtyP->termios->c_oflag & CRDLY) |
515 | rio_dprintk(RIO_DEBUG_PARAM, "Carriage return delay set\n"); | 515 | rio_dprintk(RIO_DEBUG_PARAM, "Carriage return delay set\n"); |
516 | if (TtyP->termios->c_oflag & TABDLY) | 516 | if (TtyP->termios->c_oflag & TABDLY) |
517 | rio_dprintk(RIO_DEBUG_PARAM, "Tab delay set\n"); | 517 | rio_dprintk(RIO_DEBUG_PARAM, "Tab delay set\n"); |
518 | /* | 518 | /* |
519 | ** These things are kind of useful in a later life! | 519 | ** These things are kind of useful in a later life! |
520 | */ | 520 | */ |
521 | PortP->Cor2Copy = Cor2; | 521 | PortP->Cor2Copy = Cor2; |
522 | 522 | ||
523 | if (PortP->State & RIO_DELETED) { | 523 | if (PortP->State & RIO_DELETED) { |
524 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 524 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
525 | func_exit(); | 525 | func_exit(); |
526 | 526 | ||
527 | return RIO_FAIL; | 527 | return RIO_FAIL; |
528 | } | 528 | } |
529 | 529 | ||
530 | /* | 530 | /* |
531 | ** Actually write the info into the packet to be sent | 531 | ** Actually write the info into the packet to be sent |
532 | */ | 532 | */ |
533 | writeb(cmd, &phb_param_ptr->Cmd); | 533 | writeb(cmd, &phb_param_ptr->Cmd); |
534 | writeb(Cor1, &phb_param_ptr->Cor1); | 534 | writeb(Cor1, &phb_param_ptr->Cor1); |
535 | writeb(Cor2, &phb_param_ptr->Cor2); | 535 | writeb(Cor2, &phb_param_ptr->Cor2); |
536 | writeb(Cor4, &phb_param_ptr->Cor4); | 536 | writeb(Cor4, &phb_param_ptr->Cor4); |
537 | writeb(Cor5, &phb_param_ptr->Cor5); | 537 | writeb(Cor5, &phb_param_ptr->Cor5); |
538 | writeb(TxXon, &phb_param_ptr->TxXon); | 538 | writeb(TxXon, &phb_param_ptr->TxXon); |
539 | writeb(RxXon, &phb_param_ptr->RxXon); | 539 | writeb(RxXon, &phb_param_ptr->RxXon); |
540 | writeb(TxXoff, &phb_param_ptr->TxXoff); | 540 | writeb(TxXoff, &phb_param_ptr->TxXoff); |
541 | writeb(RxXoff, &phb_param_ptr->RxXoff); | 541 | writeb(RxXoff, &phb_param_ptr->RxXoff); |
542 | writeb(LNext, &phb_param_ptr->LNext); | 542 | writeb(LNext, &phb_param_ptr->LNext); |
543 | writeb(TxBaud, &phb_param_ptr->TxBaud); | 543 | writeb(TxBaud, &phb_param_ptr->TxBaud); |
544 | writeb(RxBaud, &phb_param_ptr->RxBaud); | 544 | writeb(RxBaud, &phb_param_ptr->RxBaud); |
545 | 545 | ||
546 | /* | 546 | /* |
547 | ** Set the length/command field | 547 | ** Set the length/command field |
548 | */ | 548 | */ |
549 | writeb(12 | PKT_CMD_BIT, &PacketP->len); | 549 | writeb(12 | PKT_CMD_BIT, &PacketP->len); |
550 | 550 | ||
551 | /* | 551 | /* |
552 | ** The packet is formed - now, whack it off | 552 | ** The packet is formed - now, whack it off |
553 | ** to its final destination: | 553 | ** to its final destination: |
554 | */ | 554 | */ |
555 | add_transmit(PortP); | 555 | add_transmit(PortP); |
556 | /* | 556 | /* |
557 | ** Count characters transmitted for port statistics reporting | 557 | ** Count characters transmitted for port statistics reporting |
558 | */ | 558 | */ |
559 | if (PortP->statsGather) | 559 | if (PortP->statsGather) |
560 | PortP->txchars += 12; | 560 | PortP->txchars += 12; |
561 | 561 | ||
562 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 562 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
563 | 563 | ||
564 | rio_dprintk(RIO_DEBUG_PARAM, "add_transmit returned.\n"); | 564 | rio_dprintk(RIO_DEBUG_PARAM, "add_transmit returned.\n"); |
565 | /* | 565 | /* |
566 | ** job done. | 566 | ** job done. |
567 | */ | 567 | */ |
568 | func_exit(); | 568 | func_exit(); |
569 | 569 | ||
570 | return 0; | 570 | return 0; |
571 | } | 571 | } |
572 | 572 | ||
573 | 573 | ||
574 | /* | 574 | /* |
575 | ** We can add another packet to a transmit queue if the packet pointer pointed | 575 | ** We can add another packet to a transmit queue if the packet pointer pointed |
576 | ** to by the TxAdd pointer has PKT_IN_USE clear in its address. | 576 | ** to by the TxAdd pointer has PKT_IN_USE clear in its address. |
577 | */ | 577 | */ |
578 | int can_add_transmit(struct PKT __iomem **PktP, struct Port *PortP) | 578 | int can_add_transmit(struct PKT __iomem **PktP, struct Port *PortP) |
579 | { | 579 | { |
580 | struct PKT __iomem *tp; | 580 | struct PKT __iomem *tp; |
581 | 581 | ||
582 | *PktP = tp = (struct PKT __iomem *) RIO_PTR(PortP->Caddr, readw(PortP->TxAdd)); | 582 | *PktP = tp = (struct PKT __iomem *) RIO_PTR(PortP->Caddr, readw(PortP->TxAdd)); |
583 | 583 | ||
584 | return !((unsigned long) tp & PKT_IN_USE); | 584 | return !((unsigned long) tp & PKT_IN_USE); |
585 | } | 585 | } |
586 | 586 | ||
587 | /* | 587 | /* |
588 | ** To add a packet to the queue, you set the PKT_IN_USE bit in the address, | 588 | ** To add a packet to the queue, you set the PKT_IN_USE bit in the address, |
589 | ** and then move the TxAdd pointer along one position to point to the next | 589 | ** and then move the TxAdd pointer along one position to point to the next |
590 | ** packet pointer. You must wrap the pointer from the end back to the start. | 590 | ** packet pointer. You must wrap the pointer from the end back to the start. |
591 | */ | 591 | */ |
592 | void add_transmit(struct Port *PortP) | 592 | void add_transmit(struct Port *PortP) |
593 | { | 593 | { |
594 | if (readw(PortP->TxAdd) & PKT_IN_USE) { | 594 | if (readw(PortP->TxAdd) & PKT_IN_USE) { |
595 | rio_dprintk(RIO_DEBUG_PARAM, "add_transmit: Packet has been stolen!"); | 595 | rio_dprintk(RIO_DEBUG_PARAM, "add_transmit: Packet has been stolen!"); |
596 | } | 596 | } |
597 | writew(readw(PortP->TxAdd) | PKT_IN_USE, PortP->TxAdd); | 597 | writew(readw(PortP->TxAdd) | PKT_IN_USE, PortP->TxAdd); |
598 | PortP->TxAdd = (PortP->TxAdd == PortP->TxEnd) ? PortP->TxStart : PortP->TxAdd + 1; | 598 | PortP->TxAdd = (PortP->TxAdd == PortP->TxEnd) ? PortP->TxStart : PortP->TxAdd + 1; |
599 | writew(RIO_OFF(PortP->Caddr, PortP->TxAdd), &PortP->PhbP->tx_add); | 599 | writew(RIO_OFF(PortP->Caddr, PortP->TxAdd), &PortP->PhbP->tx_add); |
600 | } | 600 | } |
601 | 601 | ||
602 | /**************************************** | 602 | /**************************************** |
603 | * Put a packet onto the end of the | 603 | * Put a packet onto the end of the |
604 | * free list | 604 | * free list |
605 | ****************************************/ | 605 | ****************************************/ |
606 | void put_free_end(struct Host *HostP, struct PKT __iomem *PktP) | 606 | void put_free_end(struct Host *HostP, struct PKT __iomem *PktP) |
607 | { | 607 | { |
608 | struct rio_free_list __iomem *tmp_pointer; | 608 | struct rio_free_list __iomem *tmp_pointer; |
609 | unsigned short old_end, new_end; | 609 | unsigned short old_end, new_end; |
610 | unsigned long flags; | 610 | unsigned long flags; |
611 | 611 | ||
612 | rio_spin_lock_irqsave(&HostP->HostLock, flags); | 612 | rio_spin_lock_irqsave(&HostP->HostLock, flags); |
613 | 613 | ||
614 | /************************************************* | 614 | /************************************************* |
615 | * Put a packet back onto the back of the free list | 615 | * Put a packet back onto the back of the free list |
616 | * | 616 | * |
617 | ************************************************/ | 617 | ************************************************/ |
618 | 618 | ||
619 | rio_dprintk(RIO_DEBUG_PFE, "put_free_end(PktP=%p)\n", PktP); | 619 | rio_dprintk(RIO_DEBUG_PFE, "put_free_end(PktP=%p)\n", PktP); |
620 | 620 | ||
621 | if ((old_end = readw(&HostP->ParmMapP->free_list_end)) != TPNULL) { | 621 | if ((old_end = readw(&HostP->ParmMapP->free_list_end)) != TPNULL) { |
622 | new_end = RIO_OFF(HostP->Caddr, PktP); | 622 | new_end = RIO_OFF(HostP->Caddr, PktP); |
623 | tmp_pointer = (struct rio_free_list __iomem *) RIO_PTR(HostP->Caddr, old_end); | 623 | tmp_pointer = (struct rio_free_list __iomem *) RIO_PTR(HostP->Caddr, old_end); |
624 | writew(new_end, &tmp_pointer->next); | 624 | writew(new_end, &tmp_pointer->next); |
625 | writew(old_end, &((struct rio_free_list __iomem *) PktP)->prev); | 625 | writew(old_end, &((struct rio_free_list __iomem *) PktP)->prev); |
626 | writew(TPNULL, &((struct rio_free_list __iomem *) PktP)->next); | 626 | writew(TPNULL, &((struct rio_free_list __iomem *) PktP)->next); |
627 | writew(new_end, &HostP->ParmMapP->free_list_end); | 627 | writew(new_end, &HostP->ParmMapP->free_list_end); |
628 | } else { /* First packet on the free list this should never happen! */ | 628 | } else { /* First packet on the free list this should never happen! */ |
629 | rio_dprintk(RIO_DEBUG_PFE, "put_free_end(): This should never happen\n"); | 629 | rio_dprintk(RIO_DEBUG_PFE, "put_free_end(): This should never happen\n"); |
630 | writew(RIO_OFF(HostP->Caddr, PktP), &HostP->ParmMapP->free_list_end); | 630 | writew(RIO_OFF(HostP->Caddr, PktP), &HostP->ParmMapP->free_list_end); |
631 | tmp_pointer = (struct rio_free_list __iomem *) PktP; | 631 | tmp_pointer = (struct rio_free_list __iomem *) PktP; |
632 | writew(TPNULL, &tmp_pointer->prev); | 632 | writew(TPNULL, &tmp_pointer->prev); |
633 | writew(TPNULL, &tmp_pointer->next); | 633 | writew(TPNULL, &tmp_pointer->next); |
634 | } | 634 | } |
635 | rio_dprintk(RIO_DEBUG_CMD, "Before unlock: %p\n", &HostP->HostLock); | 635 | rio_dprintk(RIO_DEBUG_CMD, "Before unlock: %p\n", &HostP->HostLock); |
636 | rio_spin_unlock_irqrestore(&HostP->HostLock, flags); | 636 | rio_spin_unlock_irqrestore(&HostP->HostLock, flags); |
637 | } | 637 | } |
638 | 638 | ||
639 | /* | 639 | /* |
640 | ** can_remove_receive(PktP,P) returns non-zero if PKT_IN_USE is set | 640 | ** can_remove_receive(PktP,P) returns non-zero if PKT_IN_USE is set |
641 | ** for the next packet on the queue. It will also set PktP to point to the | 641 | ** for the next packet on the queue. It will also set PktP to point to the |
642 | ** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear, | 642 | ** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear, |
643 | ** then can_remove_receive() returns 0. | 643 | ** then can_remove_receive() returns 0. |
644 | */ | 644 | */ |
645 | int can_remove_receive(struct PKT __iomem **PktP, struct Port *PortP) | 645 | int can_remove_receive(struct PKT __iomem **PktP, struct Port *PortP) |
646 | { | 646 | { |
647 | if (readw(PortP->RxRemove) & PKT_IN_USE) { | 647 | if (readw(PortP->RxRemove) & PKT_IN_USE) { |
648 | *PktP = (struct PKT __iomem *) RIO_PTR(PortP->Caddr, readw(PortP->RxRemove) & ~PKT_IN_USE); | 648 | *PktP = (struct PKT __iomem *) RIO_PTR(PortP->Caddr, readw(PortP->RxRemove) & ~PKT_IN_USE); |
649 | return 1; | 649 | return 1; |
650 | } | 650 | } |
651 | return 0; | 651 | return 0; |
652 | } | 652 | } |
653 | 653 | ||
654 | /* | 654 | /* |
655 | ** To remove a packet from the receive queue you clear its PKT_IN_USE bit, | 655 | ** To remove a packet from the receive queue you clear its PKT_IN_USE bit, |
656 | ** and then bump the pointers. Once the pointers get to the end, they must | 656 | ** and then bump the pointers. Once the pointers get to the end, they must |
657 | ** be wrapped back to the start. | 657 | ** be wrapped back to the start. |
658 | */ | 658 | */ |
659 | void remove_receive(struct Port *PortP) | 659 | void remove_receive(struct Port *PortP) |
660 | { | 660 | { |
661 | writew(readw(PortP->RxRemove) & ~PKT_IN_USE, PortP->RxRemove); | 661 | writew(readw(PortP->RxRemove) & ~PKT_IN_USE, PortP->RxRemove); |
662 | PortP->RxRemove = (PortP->RxRemove == PortP->RxEnd) ? PortP->RxStart : PortP->RxRemove + 1; | 662 | PortP->RxRemove = (PortP->RxRemove == PortP->RxEnd) ? PortP->RxStart : PortP->RxRemove + 1; |
663 | writew(RIO_OFF(PortP->Caddr, PortP->RxRemove), &PortP->PhbP->rx_remove); | 663 | writew(RIO_OFF(PortP->Caddr, PortP->RxRemove), &PortP->PhbP->rx_remove); |
664 | } | 664 | } |
665 | 665 |
drivers/char/rio/riotty.c
1 | /* | 1 | /* |
2 | ** ----------------------------------------------------------------------------- | 2 | ** ----------------------------------------------------------------------------- |
3 | ** | 3 | ** |
4 | ** Perle Specialix driver for Linux | 4 | ** Perle Specialix driver for Linux |
5 | ** Ported from existing RIO Driver for SCO sources. | 5 | ** Ported from existing RIO Driver for SCO sources. |
6 | * | 6 | * |
7 | * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK. | 7 | * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK. |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
11 | * the Free Software Foundation; either version 2 of the License, or | 11 | * the Free Software Foundation; either version 2 of the License, or |
12 | * (at your option) any later version. | 12 | * (at your option) any later version. |
13 | * | 13 | * |
14 | * This program is distributed in the hope that it will be useful, | 14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | * GNU General Public License for more details. | 17 | * GNU General Public License for more details. |
18 | * | 18 | * |
19 | * You should have received a copy of the GNU General Public License | 19 | * You should have received a copy of the GNU General Public License |
20 | * along with this program; if not, write to the Free Software | 20 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
22 | ** | 22 | ** |
23 | ** Module : riotty.c | 23 | ** Module : riotty.c |
24 | ** SID : 1.3 | 24 | ** SID : 1.3 |
25 | ** Last Modified : 11/6/98 10:33:47 | 25 | ** Last Modified : 11/6/98 10:33:47 |
26 | ** Retrieved : 11/6/98 10:33:50 | 26 | ** Retrieved : 11/6/98 10:33:50 |
27 | ** | 27 | ** |
28 | ** ident @(#)riotty.c 1.3 | 28 | ** ident @(#)riotty.c 1.3 |
29 | ** | 29 | ** |
30 | ** ----------------------------------------------------------------------------- | 30 | ** ----------------------------------------------------------------------------- |
31 | */ | 31 | */ |
32 | 32 | ||
33 | #define __EXPLICIT_DEF_H__ | 33 | #define __EXPLICIT_DEF_H__ |
34 | 34 | ||
35 | #include <linux/module.h> | 35 | #include <linux/module.h> |
36 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
37 | #include <linux/errno.h> | 37 | #include <linux/errno.h> |
38 | #include <linux/tty.h> | 38 | #include <linux/tty.h> |
39 | #include <linux/string.h> | 39 | #include <linux/string.h> |
40 | #include <asm/io.h> | 40 | #include <asm/io.h> |
41 | #include <asm/system.h> | 41 | #include <asm/system.h> |
42 | #include <asm/string.h> | 42 | #include <asm/string.h> |
43 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
44 | 44 | ||
45 | #include <linux/termios.h> | 45 | #include <linux/termios.h> |
46 | 46 | ||
47 | #include <linux/serial.h> | 47 | #include <linux/serial.h> |
48 | 48 | ||
49 | #include <linux/generic_serial.h> | 49 | #include <linux/generic_serial.h> |
50 | 50 | ||
51 | 51 | ||
52 | #include "linux_compat.h" | 52 | #include "linux_compat.h" |
53 | #include "rio_linux.h" | 53 | #include "rio_linux.h" |
54 | #include "pkt.h" | 54 | #include "pkt.h" |
55 | #include "daemon.h" | 55 | #include "daemon.h" |
56 | #include "rio.h" | 56 | #include "rio.h" |
57 | #include "riospace.h" | 57 | #include "riospace.h" |
58 | #include "cmdpkt.h" | 58 | #include "cmdpkt.h" |
59 | #include "map.h" | 59 | #include "map.h" |
60 | #include "rup.h" | 60 | #include "rup.h" |
61 | #include "port.h" | 61 | #include "port.h" |
62 | #include "riodrvr.h" | 62 | #include "riodrvr.h" |
63 | #include "rioinfo.h" | 63 | #include "rioinfo.h" |
64 | #include "func.h" | 64 | #include "func.h" |
65 | #include "errors.h" | 65 | #include "errors.h" |
66 | #include "pci.h" | 66 | #include "pci.h" |
67 | 67 | ||
68 | #include "parmmap.h" | 68 | #include "parmmap.h" |
69 | #include "unixrup.h" | 69 | #include "unixrup.h" |
70 | #include "board.h" | 70 | #include "board.h" |
71 | #include "host.h" | 71 | #include "host.h" |
72 | #include "phb.h" | 72 | #include "phb.h" |
73 | #include "link.h" | 73 | #include "link.h" |
74 | #include "cmdblk.h" | 74 | #include "cmdblk.h" |
75 | #include "route.h" | 75 | #include "route.h" |
76 | #include "cirrus.h" | 76 | #include "cirrus.h" |
77 | #include "rioioctl.h" | 77 | #include "rioioctl.h" |
78 | #include "param.h" | 78 | #include "param.h" |
79 | 79 | ||
80 | static void RIOClearUp(struct Port *PortP); | 80 | static void RIOClearUp(struct Port *PortP); |
81 | 81 | ||
82 | /* Below belongs in func.h */ | 82 | /* Below belongs in func.h */ |
83 | int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg); | 83 | int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg); |
84 | 84 | ||
85 | 85 | ||
86 | extern struct rio_info *p; | 86 | extern struct rio_info *p; |
87 | 87 | ||
88 | 88 | ||
89 | int riotopen(struct tty_struct *tty, struct file *filp) | 89 | int riotopen(struct tty_struct *tty, struct file *filp) |
90 | { | 90 | { |
91 | unsigned int SysPort; | 91 | unsigned int SysPort; |
92 | int repeat_this = 250; | 92 | int repeat_this = 250; |
93 | struct Port *PortP; /* pointer to the port structure */ | 93 | struct Port *PortP; /* pointer to the port structure */ |
94 | unsigned long flags; | 94 | unsigned long flags; |
95 | int retval = 0; | 95 | int retval = 0; |
96 | 96 | ||
97 | func_enter(); | 97 | func_enter(); |
98 | 98 | ||
99 | /* Make sure driver_data is NULL in case the rio isn't booted jet. Else gs_close | 99 | /* Make sure driver_data is NULL in case the rio isn't booted jet. Else gs_close |
100 | is going to oops. | 100 | is going to oops. |
101 | */ | 101 | */ |
102 | tty->driver_data = NULL; | 102 | tty->driver_data = NULL; |
103 | 103 | ||
104 | SysPort = rio_minor(tty); | 104 | SysPort = rio_minor(tty); |
105 | 105 | ||
106 | if (p->RIOFailed) { | 106 | if (p->RIOFailed) { |
107 | rio_dprintk(RIO_DEBUG_TTY, "System initialisation failed\n"); | 107 | rio_dprintk(RIO_DEBUG_TTY, "System initialisation failed\n"); |
108 | func_exit(); | 108 | func_exit(); |
109 | return -ENXIO; | 109 | return -ENXIO; |
110 | } | 110 | } |
111 | 111 | ||
112 | rio_dprintk(RIO_DEBUG_TTY, "port open SysPort %d (mapped:%d)\n", SysPort, p->RIOPortp[SysPort]->Mapped); | 112 | rio_dprintk(RIO_DEBUG_TTY, "port open SysPort %d (mapped:%d)\n", SysPort, p->RIOPortp[SysPort]->Mapped); |
113 | 113 | ||
114 | /* | 114 | /* |
115 | ** Validate that we have received a legitimate request. | 115 | ** Validate that we have received a legitimate request. |
116 | ** Currently, just check that we are opening a port on | 116 | ** Currently, just check that we are opening a port on |
117 | ** a host card that actually exists, and that the port | 117 | ** a host card that actually exists, and that the port |
118 | ** has been mapped onto a host. | 118 | ** has been mapped onto a host. |
119 | */ | 119 | */ |
120 | if (SysPort >= RIO_PORTS) { /* out of range ? */ | 120 | if (SysPort >= RIO_PORTS) { /* out of range ? */ |
121 | rio_dprintk(RIO_DEBUG_TTY, "Illegal port number %d\n", SysPort); | 121 | rio_dprintk(RIO_DEBUG_TTY, "Illegal port number %d\n", SysPort); |
122 | func_exit(); | 122 | func_exit(); |
123 | return -ENXIO; | 123 | return -ENXIO; |
124 | } | 124 | } |
125 | 125 | ||
126 | /* | 126 | /* |
127 | ** Grab pointer to the port stucture | 127 | ** Grab pointer to the port stucture |
128 | */ | 128 | */ |
129 | PortP = p->RIOPortp[SysPort]; /* Get control struc */ | 129 | PortP = p->RIOPortp[SysPort]; /* Get control struc */ |
130 | rio_dprintk(RIO_DEBUG_TTY, "PortP: %p\n", PortP); | 130 | rio_dprintk(RIO_DEBUG_TTY, "PortP: %p\n", PortP); |
131 | if (!PortP->Mapped) { /* we aren't mapped yet! */ | 131 | if (!PortP->Mapped) { /* we aren't mapped yet! */ |
132 | /* | 132 | /* |
133 | ** The system doesn't know which RTA this port | 133 | ** The system doesn't know which RTA this port |
134 | ** corresponds to. | 134 | ** corresponds to. |
135 | */ | 135 | */ |
136 | rio_dprintk(RIO_DEBUG_TTY, "port not mapped into system\n"); | 136 | rio_dprintk(RIO_DEBUG_TTY, "port not mapped into system\n"); |
137 | func_exit(); | 137 | func_exit(); |
138 | return -ENXIO; | 138 | return -ENXIO; |
139 | } | 139 | } |
140 | 140 | ||
141 | tty->driver_data = PortP; | 141 | tty->driver_data = PortP; |
142 | 142 | ||
143 | PortP->gs.tty = tty; | 143 | PortP->gs.port.tty = tty; |
144 | PortP->gs.count++; | 144 | PortP->gs.port.count++; |
145 | 145 | ||
146 | rio_dprintk(RIO_DEBUG_TTY, "%d bytes in tx buffer\n", PortP->gs.xmit_cnt); | 146 | rio_dprintk(RIO_DEBUG_TTY, "%d bytes in tx buffer\n", PortP->gs.xmit_cnt); |
147 | 147 | ||
148 | retval = gs_init_port(&PortP->gs); | 148 | retval = gs_init_port(&PortP->gs); |
149 | if (retval) { | 149 | if (retval) { |
150 | PortP->gs.count--; | 150 | PortP->gs.port.count--; |
151 | return -ENXIO; | 151 | return -ENXIO; |
152 | } | 152 | } |
153 | /* | 153 | /* |
154 | ** If the host hasn't been booted yet, then | 154 | ** If the host hasn't been booted yet, then |
155 | ** fail | 155 | ** fail |
156 | */ | 156 | */ |
157 | if ((PortP->HostP->Flags & RUN_STATE) != RC_RUNNING) { | 157 | if ((PortP->HostP->Flags & RUN_STATE) != RC_RUNNING) { |
158 | rio_dprintk(RIO_DEBUG_TTY, "Host not running\n"); | 158 | rio_dprintk(RIO_DEBUG_TTY, "Host not running\n"); |
159 | func_exit(); | 159 | func_exit(); |
160 | return -ENXIO; | 160 | return -ENXIO; |
161 | } | 161 | } |
162 | 162 | ||
163 | /* | 163 | /* |
164 | ** If the RTA has not booted yet and the user has choosen to block | 164 | ** If the RTA has not booted yet and the user has choosen to block |
165 | ** until the RTA is present then we must spin here waiting for | 165 | ** until the RTA is present then we must spin here waiting for |
166 | ** the RTA to boot. | 166 | ** the RTA to boot. |
167 | */ | 167 | */ |
168 | /* I find the above code a bit hairy. I find the below code | 168 | /* I find the above code a bit hairy. I find the below code |
169 | easier to read and shorter. Now, if it works too that would | 169 | easier to read and shorter. Now, if it works too that would |
170 | be great... -- REW | 170 | be great... -- REW |
171 | */ | 171 | */ |
172 | rio_dprintk(RIO_DEBUG_TTY, "Checking if RTA has booted... \n"); | 172 | rio_dprintk(RIO_DEBUG_TTY, "Checking if RTA has booted... \n"); |
173 | while (!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED)) { | 173 | while (!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED)) { |
174 | if (!PortP->WaitUntilBooted) { | 174 | if (!PortP->WaitUntilBooted) { |
175 | rio_dprintk(RIO_DEBUG_TTY, "RTA never booted\n"); | 175 | rio_dprintk(RIO_DEBUG_TTY, "RTA never booted\n"); |
176 | func_exit(); | 176 | func_exit(); |
177 | return -ENXIO; | 177 | return -ENXIO; |
178 | } | 178 | } |
179 | 179 | ||
180 | /* Under Linux you'd normally use a wait instead of this | 180 | /* Under Linux you'd normally use a wait instead of this |
181 | busy-waiting. I'll stick with the old implementation for | 181 | busy-waiting. I'll stick with the old implementation for |
182 | now. --REW | 182 | now. --REW |
183 | */ | 183 | */ |
184 | if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { | 184 | if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { |
185 | rio_dprintk(RIO_DEBUG_TTY, "RTA_wait_for_boot: EINTR in delay \n"); | 185 | rio_dprintk(RIO_DEBUG_TTY, "RTA_wait_for_boot: EINTR in delay \n"); |
186 | func_exit(); | 186 | func_exit(); |
187 | return -EINTR; | 187 | return -EINTR; |
188 | } | 188 | } |
189 | if (repeat_this-- <= 0) { | 189 | if (repeat_this-- <= 0) { |
190 | rio_dprintk(RIO_DEBUG_TTY, "Waiting for RTA to boot timeout\n"); | 190 | rio_dprintk(RIO_DEBUG_TTY, "Waiting for RTA to boot timeout\n"); |
191 | func_exit(); | 191 | func_exit(); |
192 | return -EIO; | 192 | return -EIO; |
193 | } | 193 | } |
194 | } | 194 | } |
195 | rio_dprintk(RIO_DEBUG_TTY, "RTA has been booted\n"); | 195 | rio_dprintk(RIO_DEBUG_TTY, "RTA has been booted\n"); |
196 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 196 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
197 | if (p->RIOHalted) { | 197 | if (p->RIOHalted) { |
198 | goto bombout; | 198 | goto bombout; |
199 | } | 199 | } |
200 | 200 | ||
201 | /* | 201 | /* |
202 | ** If the port is in the final throws of being closed, | 202 | ** If the port is in the final throws of being closed, |
203 | ** we should wait here (politely), waiting | 203 | ** we should wait here (politely), waiting |
204 | ** for it to finish, so that it doesn't close us! | 204 | ** for it to finish, so that it doesn't close us! |
205 | */ | 205 | */ |
206 | while ((PortP->State & RIO_CLOSING) && !p->RIOHalted) { | 206 | while ((PortP->State & RIO_CLOSING) && !p->RIOHalted) { |
207 | rio_dprintk(RIO_DEBUG_TTY, "Waiting for RIO_CLOSING to go away\n"); | 207 | rio_dprintk(RIO_DEBUG_TTY, "Waiting for RIO_CLOSING to go away\n"); |
208 | if (repeat_this-- <= 0) { | 208 | if (repeat_this-- <= 0) { |
209 | rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n"); | 209 | rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n"); |
210 | RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE); | 210 | RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE); |
211 | retval = -EINTR; | 211 | retval = -EINTR; |
212 | goto bombout; | 212 | goto bombout; |
213 | } | 213 | } |
214 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 214 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
215 | if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { | 215 | if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { |
216 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 216 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
217 | retval = -EINTR; | 217 | retval = -EINTR; |
218 | goto bombout; | 218 | goto bombout; |
219 | } | 219 | } |
220 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 220 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
221 | } | 221 | } |
222 | 222 | ||
223 | if (!PortP->Mapped) { | 223 | if (!PortP->Mapped) { |
224 | rio_dprintk(RIO_DEBUG_TTY, "Port unmapped while closing!\n"); | 224 | rio_dprintk(RIO_DEBUG_TTY, "Port unmapped while closing!\n"); |
225 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 225 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
226 | retval = -ENXIO; | 226 | retval = -ENXIO; |
227 | func_exit(); | 227 | func_exit(); |
228 | return retval; | 228 | return retval; |
229 | } | 229 | } |
230 | 230 | ||
231 | if (p->RIOHalted) { | 231 | if (p->RIOHalted) { |
232 | goto bombout; | 232 | goto bombout; |
233 | } | 233 | } |
234 | 234 | ||
235 | /* | 235 | /* |
236 | ** 15.10.1998 ARG - ESIL 0761 part fix | 236 | ** 15.10.1998 ARG - ESIL 0761 part fix |
237 | ** RIO has it's own CTSFLOW and RTSFLOW flags in 'Config' in the port structure, | 237 | ** RIO has it's own CTSFLOW and RTSFLOW flags in 'Config' in the port structure, |
238 | ** we need to make sure that the flags are clear when the port is opened. | 238 | ** we need to make sure that the flags are clear when the port is opened. |
239 | */ | 239 | */ |
240 | /* Uh? Suppose I turn these on and then another process opens | 240 | /* Uh? Suppose I turn these on and then another process opens |
241 | the port again? The flags get cleared! Not good. -- REW */ | 241 | the port again? The flags get cleared! Not good. -- REW */ |
242 | if (!(PortP->State & (RIO_LOPEN | RIO_MOPEN))) { | 242 | if (!(PortP->State & (RIO_LOPEN | RIO_MOPEN))) { |
243 | PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW); | 243 | PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW); |
244 | } | 244 | } |
245 | 245 | ||
246 | if (!(PortP->firstOpen)) { /* First time ? */ | 246 | if (!(PortP->firstOpen)) { /* First time ? */ |
247 | rio_dprintk(RIO_DEBUG_TTY, "First open for this port\n"); | 247 | rio_dprintk(RIO_DEBUG_TTY, "First open for this port\n"); |
248 | 248 | ||
249 | 249 | ||
250 | PortP->firstOpen++; | 250 | PortP->firstOpen++; |
251 | PortP->CookMode = 0; /* XXX RIOCookMode(tp); */ | 251 | PortP->CookMode = 0; /* XXX RIOCookMode(tp); */ |
252 | PortP->InUse = NOT_INUSE; | 252 | PortP->InUse = NOT_INUSE; |
253 | 253 | ||
254 | /* Tentative fix for bug PR27. Didn't work. */ | 254 | /* Tentative fix for bug PR27. Didn't work. */ |
255 | /* PortP->gs.xmit_cnt = 0; */ | 255 | /* PortP->gs.xmit_cnt = 0; */ |
256 | 256 | ||
257 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 257 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
258 | 258 | ||
259 | /* Someone explain to me why this delay/config is | 259 | /* Someone explain to me why this delay/config is |
260 | here. If I read the docs correctly the "open" | 260 | here. If I read the docs correctly the "open" |
261 | command piggybacks the parameters immediately. | 261 | command piggybacks the parameters immediately. |
262 | -- REW */ | 262 | -- REW */ |
263 | RIOParam(PortP, RIOC_OPEN, 1, OK_TO_SLEEP); /* Open the port */ | 263 | RIOParam(PortP, RIOC_OPEN, 1, OK_TO_SLEEP); /* Open the port */ |
264 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 264 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
265 | 265 | ||
266 | /* | 266 | /* |
267 | ** wait for the port to be not closed. | 267 | ** wait for the port to be not closed. |
268 | */ | 268 | */ |
269 | while (!(PortP->PortState & PORT_ISOPEN) && !p->RIOHalted) { | 269 | while (!(PortP->PortState & PORT_ISOPEN) && !p->RIOHalted) { |
270 | rio_dprintk(RIO_DEBUG_TTY, "Waiting for PORT_ISOPEN-currently %x\n", PortP->PortState); | 270 | rio_dprintk(RIO_DEBUG_TTY, "Waiting for PORT_ISOPEN-currently %x\n", PortP->PortState); |
271 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 271 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
272 | if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { | 272 | if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { |
273 | rio_dprintk(RIO_DEBUG_TTY, "Waiting for open to finish broken by signal\n"); | 273 | rio_dprintk(RIO_DEBUG_TTY, "Waiting for open to finish broken by signal\n"); |
274 | RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE); | 274 | RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE); |
275 | func_exit(); | 275 | func_exit(); |
276 | return -EINTR; | 276 | return -EINTR; |
277 | } | 277 | } |
278 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 278 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
279 | } | 279 | } |
280 | 280 | ||
281 | if (p->RIOHalted) { | 281 | if (p->RIOHalted) { |
282 | retval = -EIO; | 282 | retval = -EIO; |
283 | bombout: | 283 | bombout: |
284 | /* RIOClearUp( PortP ); */ | 284 | /* RIOClearUp( PortP ); */ |
285 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 285 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
286 | return retval; | 286 | return retval; |
287 | } | 287 | } |
288 | rio_dprintk(RIO_DEBUG_TTY, "PORT_ISOPEN found\n"); | 288 | rio_dprintk(RIO_DEBUG_TTY, "PORT_ISOPEN found\n"); |
289 | } | 289 | } |
290 | rio_dprintk(RIO_DEBUG_TTY, "Modem - test for carrier\n"); | 290 | rio_dprintk(RIO_DEBUG_TTY, "Modem - test for carrier\n"); |
291 | /* | 291 | /* |
292 | ** ACTION | 292 | ** ACTION |
293 | ** insert test for carrier here. -- ??? | 293 | ** insert test for carrier here. -- ??? |
294 | ** I already see that test here. What's the deal? -- REW | 294 | ** I already see that test here. What's the deal? -- REW |
295 | */ | 295 | */ |
296 | if ((PortP->gs.tty->termios->c_cflag & CLOCAL) || | 296 | if ((PortP->gs.port.tty->termios->c_cflag & CLOCAL) || |
297 | (PortP->ModemState & RIOC_MSVR1_CD)) { | 297 | (PortP->ModemState & RIOC_MSVR1_CD)) { |
298 | rio_dprintk(RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort); | 298 | rio_dprintk(RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort); |
299 | /* | 299 | /* |
300 | tp->tm.c_state |= CARR_ON; | 300 | tp->tm.c_state |= CARR_ON; |
301 | wakeup((caddr_t) &tp->tm.c_canq); | 301 | wakeup((caddr_t) &tp->tm.c_canq); |
302 | */ | 302 | */ |
303 | PortP->State |= RIO_CARR_ON; | 303 | PortP->State |= RIO_CARR_ON; |
304 | wake_up_interruptible(&PortP->gs.open_wait); | 304 | wake_up_interruptible(&PortP->gs.port.open_wait); |
305 | } else { /* no carrier - wait for DCD */ | 305 | } else { /* no carrier - wait for DCD */ |
306 | /* | 306 | /* |
307 | while (!(PortP->gs.tty->termios->c_state & CARR_ON) && | 307 | while (!(PortP->gs.port.tty->termios->c_state & CARR_ON) && |
308 | !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted ) | 308 | !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted ) |
309 | */ | 309 | */ |
310 | while (!(PortP->State & RIO_CARR_ON) && !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted) { | 310 | while (!(PortP->State & RIO_CARR_ON) && !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted) { |
311 | rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n", SysPort); | 311 | rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n", SysPort); |
312 | /* | 312 | /* |
313 | PortP->gs.tty->termios->c_state |= WOPEN; | 313 | PortP->gs.port.tty->termios->c_state |= WOPEN; |
314 | */ | 314 | */ |
315 | PortP->State |= RIO_WOPEN; | 315 | PortP->State |= RIO_WOPEN; |
316 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 316 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
317 | if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { | 317 | if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { |
318 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 318 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
319 | /* | 319 | /* |
320 | ** ACTION: verify that this is a good thing | 320 | ** ACTION: verify that this is a good thing |
321 | ** to do here. -- ??? | 321 | ** to do here. -- ??? |
322 | ** I think it's OK. -- REW | 322 | ** I think it's OK. -- REW |
323 | */ | 323 | */ |
324 | rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n", SysPort); | 324 | rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n", SysPort); |
325 | RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE); | 325 | RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE); |
326 | /* | 326 | /* |
327 | tp->tm.c_state &= ~WOPEN; | 327 | tp->tm.c_state &= ~WOPEN; |
328 | */ | 328 | */ |
329 | PortP->State &= ~RIO_WOPEN; | 329 | PortP->State &= ~RIO_WOPEN; |
330 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 330 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
331 | func_exit(); | 331 | func_exit(); |
332 | return -EINTR; | 332 | return -EINTR; |
333 | } | 333 | } |
334 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 334 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
335 | } | 335 | } |
336 | PortP->State &= ~RIO_WOPEN; | 336 | PortP->State &= ~RIO_WOPEN; |
337 | } | 337 | } |
338 | if (p->RIOHalted) | 338 | if (p->RIOHalted) |
339 | goto bombout; | 339 | goto bombout; |
340 | rio_dprintk(RIO_DEBUG_TTY, "Setting RIO_MOPEN\n"); | 340 | rio_dprintk(RIO_DEBUG_TTY, "Setting RIO_MOPEN\n"); |
341 | PortP->State |= RIO_MOPEN; | 341 | PortP->State |= RIO_MOPEN; |
342 | 342 | ||
343 | if (p->RIOHalted) | 343 | if (p->RIOHalted) |
344 | goto bombout; | 344 | goto bombout; |
345 | 345 | ||
346 | rio_dprintk(RIO_DEBUG_TTY, "high level open done\n"); | 346 | rio_dprintk(RIO_DEBUG_TTY, "high level open done\n"); |
347 | 347 | ||
348 | /* | 348 | /* |
349 | ** Count opens for port statistics reporting | 349 | ** Count opens for port statistics reporting |
350 | */ | 350 | */ |
351 | if (PortP->statsGather) | 351 | if (PortP->statsGather) |
352 | PortP->opens++; | 352 | PortP->opens++; |
353 | 353 | ||
354 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 354 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
355 | rio_dprintk(RIO_DEBUG_TTY, "Returning from open\n"); | 355 | rio_dprintk(RIO_DEBUG_TTY, "Returning from open\n"); |
356 | func_exit(); | 356 | func_exit(); |
357 | return 0; | 357 | return 0; |
358 | } | 358 | } |
359 | 359 | ||
360 | /* | 360 | /* |
361 | ** RIOClose the port. | 361 | ** RIOClose the port. |
362 | ** The operating system thinks that this is last close for the device. | 362 | ** The operating system thinks that this is last close for the device. |
363 | ** As there are two interfaces to the port (Modem and tty), we need to | 363 | ** As there are two interfaces to the port (Modem and tty), we need to |
364 | ** check that both are closed before we close the device. | 364 | ** check that both are closed before we close the device. |
365 | */ | 365 | */ |
366 | int riotclose(void *ptr) | 366 | int riotclose(void *ptr) |
367 | { | 367 | { |
368 | struct Port *PortP = ptr; /* pointer to the port structure */ | 368 | struct Port *PortP = ptr; /* pointer to the port structure */ |
369 | int deleted = 0; | 369 | int deleted = 0; |
370 | int try = -1; /* Disable the timeouts by setting them to -1 */ | 370 | int try = -1; /* Disable the timeouts by setting them to -1 */ |
371 | int repeat_this = -1; /* Congrats to those having 15 years of | 371 | int repeat_this = -1; /* Congrats to those having 15 years of |
372 | uptime! (You get to break the driver.) */ | 372 | uptime! (You get to break the driver.) */ |
373 | unsigned long end_time; | 373 | unsigned long end_time; |
374 | struct tty_struct *tty; | 374 | struct tty_struct *tty; |
375 | unsigned long flags; | 375 | unsigned long flags; |
376 | int rv = 0; | 376 | int rv = 0; |
377 | 377 | ||
378 | rio_dprintk(RIO_DEBUG_TTY, "port close SysPort %d\n", PortP->PortNum); | 378 | rio_dprintk(RIO_DEBUG_TTY, "port close SysPort %d\n", PortP->PortNum); |
379 | 379 | ||
380 | /* PortP = p->RIOPortp[SysPort]; */ | 380 | /* PortP = p->RIOPortp[SysPort]; */ |
381 | rio_dprintk(RIO_DEBUG_TTY, "Port is at address %p\n", PortP); | 381 | rio_dprintk(RIO_DEBUG_TTY, "Port is at address %p\n", PortP); |
382 | /* tp = PortP->TtyP; *//* Get tty */ | 382 | /* tp = PortP->TtyP; *//* Get tty */ |
383 | tty = PortP->gs.tty; | 383 | tty = PortP->gs.port.tty; |
384 | rio_dprintk(RIO_DEBUG_TTY, "TTY is at address %p\n", tty); | 384 | rio_dprintk(RIO_DEBUG_TTY, "TTY is at address %p\n", tty); |
385 | 385 | ||
386 | if (PortP->gs.closing_wait) | 386 | if (PortP->gs.closing_wait) |
387 | end_time = jiffies + PortP->gs.closing_wait; | 387 | end_time = jiffies + PortP->gs.closing_wait; |
388 | else | 388 | else |
389 | end_time = jiffies + MAX_SCHEDULE_TIMEOUT; | 389 | end_time = jiffies + MAX_SCHEDULE_TIMEOUT; |
390 | 390 | ||
391 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 391 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
392 | 392 | ||
393 | /* | 393 | /* |
394 | ** Setting this flag will make any process trying to open | 394 | ** Setting this flag will make any process trying to open |
395 | ** this port block until we are complete closing it. | 395 | ** this port block until we are complete closing it. |
396 | */ | 396 | */ |
397 | PortP->State |= RIO_CLOSING; | 397 | PortP->State |= RIO_CLOSING; |
398 | 398 | ||
399 | if ((PortP->State & RIO_DELETED)) { | 399 | if ((PortP->State & RIO_DELETED)) { |
400 | rio_dprintk(RIO_DEBUG_TTY, "Close on deleted RTA\n"); | 400 | rio_dprintk(RIO_DEBUG_TTY, "Close on deleted RTA\n"); |
401 | deleted = 1; | 401 | deleted = 1; |
402 | } | 402 | } |
403 | 403 | ||
404 | if (p->RIOHalted) { | 404 | if (p->RIOHalted) { |
405 | RIOClearUp(PortP); | 405 | RIOClearUp(PortP); |
406 | rv = -EIO; | 406 | rv = -EIO; |
407 | goto close_end; | 407 | goto close_end; |
408 | } | 408 | } |
409 | 409 | ||
410 | rio_dprintk(RIO_DEBUG_TTY, "Clear bits\n"); | 410 | rio_dprintk(RIO_DEBUG_TTY, "Clear bits\n"); |
411 | /* | 411 | /* |
412 | ** clear the open bits for this device | 412 | ** clear the open bits for this device |
413 | */ | 413 | */ |
414 | PortP->State &= ~RIO_MOPEN; | 414 | PortP->State &= ~RIO_MOPEN; |
415 | PortP->State &= ~RIO_CARR_ON; | 415 | PortP->State &= ~RIO_CARR_ON; |
416 | PortP->ModemState &= ~RIOC_MSVR1_CD; | 416 | PortP->ModemState &= ~RIOC_MSVR1_CD; |
417 | /* | 417 | /* |
418 | ** If the device was open as both a Modem and a tty line | 418 | ** If the device was open as both a Modem and a tty line |
419 | ** then we need to wimp out here, as the port has not really | 419 | ** then we need to wimp out here, as the port has not really |
420 | ** been finally closed (gee, whizz!) The test here uses the | 420 | ** been finally closed (gee, whizz!) The test here uses the |
421 | ** bit for the OTHER mode of operation, to see if THAT is | 421 | ** bit for the OTHER mode of operation, to see if THAT is |
422 | ** still active! | 422 | ** still active! |
423 | */ | 423 | */ |
424 | if ((PortP->State & (RIO_LOPEN | RIO_MOPEN))) { | 424 | if ((PortP->State & (RIO_LOPEN | RIO_MOPEN))) { |
425 | /* | 425 | /* |
426 | ** The port is still open for the other task - | 426 | ** The port is still open for the other task - |
427 | ** return, pretending that we are still active. | 427 | ** return, pretending that we are still active. |
428 | */ | 428 | */ |
429 | rio_dprintk(RIO_DEBUG_TTY, "Channel %d still open !\n", PortP->PortNum); | 429 | rio_dprintk(RIO_DEBUG_TTY, "Channel %d still open !\n", PortP->PortNum); |
430 | PortP->State &= ~RIO_CLOSING; | 430 | PortP->State &= ~RIO_CLOSING; |
431 | if (PortP->firstOpen) | 431 | if (PortP->firstOpen) |
432 | PortP->firstOpen--; | 432 | PortP->firstOpen--; |
433 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 433 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
434 | return -EIO; | 434 | return -EIO; |
435 | } | 435 | } |
436 | 436 | ||
437 | rio_dprintk(RIO_DEBUG_TTY, "Closing down - everything must go!\n"); | 437 | rio_dprintk(RIO_DEBUG_TTY, "Closing down - everything must go!\n"); |
438 | 438 | ||
439 | PortP->State &= ~RIO_DYNOROD; | 439 | PortP->State &= ~RIO_DYNOROD; |
440 | 440 | ||
441 | /* | 441 | /* |
442 | ** This is where we wait for the port | 442 | ** This is where we wait for the port |
443 | ** to drain down before closing. Bye-bye.... | 443 | ** to drain down before closing. Bye-bye.... |
444 | ** (We never meant to do this) | 444 | ** (We never meant to do this) |
445 | */ | 445 | */ |
446 | rio_dprintk(RIO_DEBUG_TTY, "Timeout 1 starts\n"); | 446 | rio_dprintk(RIO_DEBUG_TTY, "Timeout 1 starts\n"); |
447 | 447 | ||
448 | if (!deleted) | 448 | if (!deleted) |
449 | while ((PortP->InUse != NOT_INUSE) && !p->RIOHalted && (PortP->TxBufferIn != PortP->TxBufferOut)) { | 449 | while ((PortP->InUse != NOT_INUSE) && !p->RIOHalted && (PortP->TxBufferIn != PortP->TxBufferOut)) { |
450 | if (repeat_this-- <= 0) { | 450 | if (repeat_this-- <= 0) { |
451 | rv = -EINTR; | 451 | rv = -EINTR; |
452 | rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n"); | 452 | rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n"); |
453 | RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE); | 453 | RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE); |
454 | goto close_end; | 454 | goto close_end; |
455 | } | 455 | } |
456 | rio_dprintk(RIO_DEBUG_TTY, "Calling timeout to flush in closing\n"); | 456 | rio_dprintk(RIO_DEBUG_TTY, "Calling timeout to flush in closing\n"); |
457 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 457 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
458 | if (RIODelay_ni(PortP, HUNDRED_MS * 10) == RIO_FAIL) { | 458 | if (RIODelay_ni(PortP, HUNDRED_MS * 10) == RIO_FAIL) { |
459 | rio_dprintk(RIO_DEBUG_TTY, "RTA EINTR in delay \n"); | 459 | rio_dprintk(RIO_DEBUG_TTY, "RTA EINTR in delay \n"); |
460 | rv = -EINTR; | 460 | rv = -EINTR; |
461 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 461 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
462 | goto close_end; | 462 | goto close_end; |
463 | } | 463 | } |
464 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 464 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
465 | } | 465 | } |
466 | 466 | ||
467 | PortP->TxBufferIn = PortP->TxBufferOut = 0; | 467 | PortP->TxBufferIn = PortP->TxBufferOut = 0; |
468 | repeat_this = 0xff; | 468 | repeat_this = 0xff; |
469 | 469 | ||
470 | PortP->InUse = 0; | 470 | PortP->InUse = 0; |
471 | if ((PortP->State & (RIO_LOPEN | RIO_MOPEN))) { | 471 | if ((PortP->State & (RIO_LOPEN | RIO_MOPEN))) { |
472 | /* | 472 | /* |
473 | ** The port has been re-opened for the other task - | 473 | ** The port has been re-opened for the other task - |
474 | ** return, pretending that we are still active. | 474 | ** return, pretending that we are still active. |
475 | */ | 475 | */ |
476 | rio_dprintk(RIO_DEBUG_TTY, "Channel %d re-open!\n", PortP->PortNum); | 476 | rio_dprintk(RIO_DEBUG_TTY, "Channel %d re-open!\n", PortP->PortNum); |
477 | PortP->State &= ~RIO_CLOSING; | 477 | PortP->State &= ~RIO_CLOSING; |
478 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 478 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
479 | if (PortP->firstOpen) | 479 | if (PortP->firstOpen) |
480 | PortP->firstOpen--; | 480 | PortP->firstOpen--; |
481 | return -EIO; | 481 | return -EIO; |
482 | } | 482 | } |
483 | 483 | ||
484 | if (p->RIOHalted) { | 484 | if (p->RIOHalted) { |
485 | RIOClearUp(PortP); | 485 | RIOClearUp(PortP); |
486 | goto close_end; | 486 | goto close_end; |
487 | } | 487 | } |
488 | 488 | ||
489 | /* Can't call RIOShortCommand with the port locked. */ | 489 | /* Can't call RIOShortCommand with the port locked. */ |
490 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 490 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
491 | 491 | ||
492 | if (RIOShortCommand(p, PortP, RIOC_CLOSE, 1, 0) == RIO_FAIL) { | 492 | if (RIOShortCommand(p, PortP, RIOC_CLOSE, 1, 0) == RIO_FAIL) { |
493 | RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE); | 493 | RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE); |
494 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 494 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
495 | goto close_end; | 495 | goto close_end; |
496 | } | 496 | } |
497 | 497 | ||
498 | if (!deleted) | 498 | if (!deleted) |
499 | while (try && (PortP->PortState & PORT_ISOPEN)) { | 499 | while (try && (PortP->PortState & PORT_ISOPEN)) { |
500 | try--; | 500 | try--; |
501 | if (time_after(jiffies, end_time)) { | 501 | if (time_after(jiffies, end_time)) { |
502 | rio_dprintk(RIO_DEBUG_TTY, "Run out of tries - force the bugger shut!\n"); | 502 | rio_dprintk(RIO_DEBUG_TTY, "Run out of tries - force the bugger shut!\n"); |
503 | RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE); | 503 | RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE); |
504 | break; | 504 | break; |
505 | } | 505 | } |
506 | rio_dprintk(RIO_DEBUG_TTY, "Close: PortState:ISOPEN is %d\n", PortP->PortState & PORT_ISOPEN); | 506 | rio_dprintk(RIO_DEBUG_TTY, "Close: PortState:ISOPEN is %d\n", PortP->PortState & PORT_ISOPEN); |
507 | 507 | ||
508 | if (p->RIOHalted) { | 508 | if (p->RIOHalted) { |
509 | RIOClearUp(PortP); | 509 | RIOClearUp(PortP); |
510 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 510 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
511 | goto close_end; | 511 | goto close_end; |
512 | } | 512 | } |
513 | if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { | 513 | if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { |
514 | rio_dprintk(RIO_DEBUG_TTY, "RTA EINTR in delay \n"); | 514 | rio_dprintk(RIO_DEBUG_TTY, "RTA EINTR in delay \n"); |
515 | RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE); | 515 | RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE); |
516 | break; | 516 | break; |
517 | } | 517 | } |
518 | } | 518 | } |
519 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 519 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
520 | rio_dprintk(RIO_DEBUG_TTY, "Close: try was %d on completion\n", try); | 520 | rio_dprintk(RIO_DEBUG_TTY, "Close: try was %d on completion\n", try); |
521 | 521 | ||
522 | /* RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE); */ | 522 | /* RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE); */ |
523 | 523 | ||
524 | /* | 524 | /* |
525 | ** 15.10.1998 ARG - ESIL 0761 part fix | 525 | ** 15.10.1998 ARG - ESIL 0761 part fix |
526 | ** RIO has it's own CTSFLOW and RTSFLOW flags in 'Config' in the port structure,** we need to make sure that the flags are clear when the port is opened. | 526 | ** RIO has it's own CTSFLOW and RTSFLOW flags in 'Config' in the port structure,** we need to make sure that the flags are clear when the port is opened. |
527 | */ | 527 | */ |
528 | PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW); | 528 | PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW); |
529 | 529 | ||
530 | /* | 530 | /* |
531 | ** Count opens for port statistics reporting | 531 | ** Count opens for port statistics reporting |
532 | */ | 532 | */ |
533 | if (PortP->statsGather) | 533 | if (PortP->statsGather) |
534 | PortP->closes++; | 534 | PortP->closes++; |
535 | 535 | ||
536 | close_end: | 536 | close_end: |
537 | /* XXX: Why would a "DELETED" flag be reset here? I'd have | 537 | /* XXX: Why would a "DELETED" flag be reset here? I'd have |
538 | thought that a "deleted" flag means that the port was | 538 | thought that a "deleted" flag means that the port was |
539 | permanently gone, but here we can make it reappear by it | 539 | permanently gone, but here we can make it reappear by it |
540 | being in close during the "deletion". | 540 | being in close during the "deletion". |
541 | */ | 541 | */ |
542 | PortP->State &= ~(RIO_CLOSING | RIO_DELETED); | 542 | PortP->State &= ~(RIO_CLOSING | RIO_DELETED); |
543 | if (PortP->firstOpen) | 543 | if (PortP->firstOpen) |
544 | PortP->firstOpen--; | 544 | PortP->firstOpen--; |
545 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 545 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
546 | rio_dprintk(RIO_DEBUG_TTY, "Return from close\n"); | 546 | rio_dprintk(RIO_DEBUG_TTY, "Return from close\n"); |
547 | return rv; | 547 | return rv; |
548 | } | 548 | } |
549 | 549 | ||
550 | 550 | ||
551 | 551 | ||
552 | static void RIOClearUp(struct Port *PortP) | 552 | static void RIOClearUp(struct Port *PortP) |
553 | { | 553 | { |
554 | rio_dprintk(RIO_DEBUG_TTY, "RIOHalted set\n"); | 554 | rio_dprintk(RIO_DEBUG_TTY, "RIOHalted set\n"); |
555 | PortP->Config = 0; /* Direct semaphore */ | 555 | PortP->Config = 0; /* Direct semaphore */ |
556 | PortP->PortState = 0; | 556 | PortP->PortState = 0; |
557 | PortP->firstOpen = 0; | 557 | PortP->firstOpen = 0; |
558 | PortP->FlushCmdBodge = 0; | 558 | PortP->FlushCmdBodge = 0; |
559 | PortP->ModemState = PortP->CookMode = 0; | 559 | PortP->ModemState = PortP->CookMode = 0; |
560 | PortP->Mapped = 0; | 560 | PortP->Mapped = 0; |
561 | PortP->WflushFlag = 0; | 561 | PortP->WflushFlag = 0; |
562 | PortP->MagicFlags = 0; | 562 | PortP->MagicFlags = 0; |
563 | PortP->RxDataStart = 0; | 563 | PortP->RxDataStart = 0; |
564 | PortP->TxBufferIn = 0; | 564 | PortP->TxBufferIn = 0; |
565 | PortP->TxBufferOut = 0; | 565 | PortP->TxBufferOut = 0; |
566 | } | 566 | } |
567 | 567 | ||
568 | /* | 568 | /* |
569 | ** Put a command onto a port. | 569 | ** Put a command onto a port. |
570 | ** The PortPointer, command, length and arg are passed. | 570 | ** The PortPointer, command, length and arg are passed. |
571 | ** The len is the length *inclusive* of the command byte, | 571 | ** The len is the length *inclusive* of the command byte, |
572 | ** and so for a command that takes no data, len==1. | 572 | ** and so for a command that takes no data, len==1. |
573 | ** The arg is a single byte, and is only used if len==2. | 573 | ** The arg is a single byte, and is only used if len==2. |
574 | ** Other values of len aren't allowed, and will cause | 574 | ** Other values of len aren't allowed, and will cause |
575 | ** a panic. | 575 | ** a panic. |
576 | */ | 576 | */ |
577 | int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg) | 577 | int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg) |
578 | { | 578 | { |
579 | struct PKT __iomem *PacketP; | 579 | struct PKT __iomem *PacketP; |
580 | int retries = 20; /* at 10 per second -> 2 seconds */ | 580 | int retries = 20; /* at 10 per second -> 2 seconds */ |
581 | unsigned long flags; | 581 | unsigned long flags; |
582 | 582 | ||
583 | rio_dprintk(RIO_DEBUG_TTY, "entering shortcommand.\n"); | 583 | rio_dprintk(RIO_DEBUG_TTY, "entering shortcommand.\n"); |
584 | 584 | ||
585 | if (PortP->State & RIO_DELETED) { | 585 | if (PortP->State & RIO_DELETED) { |
586 | rio_dprintk(RIO_DEBUG_TTY, "Short command to deleted RTA ignored\n"); | 586 | rio_dprintk(RIO_DEBUG_TTY, "Short command to deleted RTA ignored\n"); |
587 | return RIO_FAIL; | 587 | return RIO_FAIL; |
588 | } | 588 | } |
589 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 589 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
590 | 590 | ||
591 | /* | 591 | /* |
592 | ** If the port is in use for pre-emptive command, then wait for it to | 592 | ** If the port is in use for pre-emptive command, then wait for it to |
593 | ** be free again. | 593 | ** be free again. |
594 | */ | 594 | */ |
595 | while ((PortP->InUse != NOT_INUSE) && !p->RIOHalted) { | 595 | while ((PortP->InUse != NOT_INUSE) && !p->RIOHalted) { |
596 | rio_dprintk(RIO_DEBUG_TTY, "Waiting for not in use (%d)\n", retries); | 596 | rio_dprintk(RIO_DEBUG_TTY, "Waiting for not in use (%d)\n", retries); |
597 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 597 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
598 | if (retries-- <= 0) { | 598 | if (retries-- <= 0) { |
599 | return RIO_FAIL; | 599 | return RIO_FAIL; |
600 | } | 600 | } |
601 | if (RIODelay_ni(PortP, HUNDRED_MS) == RIO_FAIL) { | 601 | if (RIODelay_ni(PortP, HUNDRED_MS) == RIO_FAIL) { |
602 | return RIO_FAIL; | 602 | return RIO_FAIL; |
603 | } | 603 | } |
604 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 604 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
605 | } | 605 | } |
606 | if (PortP->State & RIO_DELETED) { | 606 | if (PortP->State & RIO_DELETED) { |
607 | rio_dprintk(RIO_DEBUG_TTY, "Short command to deleted RTA ignored\n"); | 607 | rio_dprintk(RIO_DEBUG_TTY, "Short command to deleted RTA ignored\n"); |
608 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 608 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
609 | return RIO_FAIL; | 609 | return RIO_FAIL; |
610 | } | 610 | } |
611 | 611 | ||
612 | while (!can_add_transmit(&PacketP, PortP) && !p->RIOHalted) { | 612 | while (!can_add_transmit(&PacketP, PortP) && !p->RIOHalted) { |
613 | rio_dprintk(RIO_DEBUG_TTY, "Waiting to add short command to queue (%d)\n", retries); | 613 | rio_dprintk(RIO_DEBUG_TTY, "Waiting to add short command to queue (%d)\n", retries); |
614 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 614 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
615 | if (retries-- <= 0) { | 615 | if (retries-- <= 0) { |
616 | rio_dprintk(RIO_DEBUG_TTY, "out of tries. Failing\n"); | 616 | rio_dprintk(RIO_DEBUG_TTY, "out of tries. Failing\n"); |
617 | return RIO_FAIL; | 617 | return RIO_FAIL; |
618 | } | 618 | } |
619 | if (RIODelay_ni(PortP, HUNDRED_MS) == RIO_FAIL) { | 619 | if (RIODelay_ni(PortP, HUNDRED_MS) == RIO_FAIL) { |
620 | return RIO_FAIL; | 620 | return RIO_FAIL; |
621 | } | 621 | } |
622 | rio_spin_lock_irqsave(&PortP->portSem, flags); | 622 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
623 | } | 623 | } |
624 | 624 | ||
625 | if (p->RIOHalted) { | 625 | if (p->RIOHalted) { |
626 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 626 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
627 | return RIO_FAIL; | 627 | return RIO_FAIL; |
628 | } | 628 | } |
629 | 629 | ||
630 | /* | 630 | /* |
631 | ** set the command byte and the argument byte | 631 | ** set the command byte and the argument byte |
632 | */ | 632 | */ |
633 | writeb(command, &PacketP->data[0]); | 633 | writeb(command, &PacketP->data[0]); |
634 | 634 | ||
635 | if (len == 2) | 635 | if (len == 2) |
636 | writeb(arg, &PacketP->data[1]); | 636 | writeb(arg, &PacketP->data[1]); |
637 | 637 | ||
638 | /* | 638 | /* |
639 | ** set the length of the packet and set the command bit. | 639 | ** set the length of the packet and set the command bit. |
640 | */ | 640 | */ |
641 | writeb(PKT_CMD_BIT | len, &PacketP->len); | 641 | writeb(PKT_CMD_BIT | len, &PacketP->len); |
642 | 642 | ||
643 | add_transmit(PortP); | 643 | add_transmit(PortP); |
644 | /* | 644 | /* |
645 | ** Count characters transmitted for port statistics reporting | 645 | ** Count characters transmitted for port statistics reporting |
646 | */ | 646 | */ |
647 | if (PortP->statsGather) | 647 | if (PortP->statsGather) |
648 | PortP->txchars += len; | 648 | PortP->txchars += len; |
649 | 649 | ||
650 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | 650 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
651 | return p->RIOHalted ? RIO_FAIL : ~RIO_FAIL; | 651 | return p->RIOHalted ? RIO_FAIL : ~RIO_FAIL; |
652 | } | 652 | } |
653 | 653 | ||
654 | 654 | ||
655 | 655 |
drivers/char/sx.c
1 | |||
2 | /* sx.c -- driver for the Specialix SX series cards. | 1 | /* sx.c -- driver for the Specialix SX series cards. |
3 | * | 2 | * |
4 | * This driver will also support the older SI, and XIO cards. | 3 | * This driver will also support the older SI, and XIO cards. |
5 | * | 4 | * |
6 | * | 5 | * |
7 | * (C) 1998 - 2004 R.E.Wolff@BitWizard.nl | 6 | * (C) 1998 - 2004 R.E.Wolff@BitWizard.nl |
8 | * | 7 | * |
9 | * Simon Allen (simonallen@cix.compulink.co.uk) wrote a previous | 8 | * Simon Allen (simonallen@cix.compulink.co.uk) wrote a previous |
10 | * version of this driver. Some fragments may have been copied. (none | 9 | * version of this driver. Some fragments may have been copied. (none |
11 | * yet :-) | 10 | * yet :-) |
12 | * | 11 | * |
13 | * Specialix pays for the development and support of this driver. | 12 | * Specialix pays for the development and support of this driver. |
14 | * Please DO contact support@specialix.co.uk if you require | 13 | * Please DO contact support@specialix.co.uk if you require |
15 | * support. But please read the documentation (sx.txt) first. | 14 | * support. But please read the documentation (sx.txt) first. |
16 | * | 15 | * |
17 | * | 16 | * |
18 | * | 17 | * |
19 | * This program is free software; you can redistribute it and/or | 18 | * This program is free software; you can redistribute it and/or |
20 | * modify it under the terms of the GNU General Public License as | 19 | * modify it under the terms of the GNU General Public License as |
21 | * published by the Free Software Foundation; either version 2 of | 20 | * published by the Free Software Foundation; either version 2 of |
22 | * the License, or (at your option) any later version. | 21 | * the License, or (at your option) any later version. |
23 | * | 22 | * |
24 | * This program is distributed in the hope that it will be | 23 | * This program is distributed in the hope that it will be |
25 | * useful, but WITHOUT ANY WARRANTY; without even the implied | 24 | * useful, but WITHOUT ANY WARRANTY; without even the implied |
26 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | 25 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
27 | * PURPOSE. See the GNU General Public License for more details. | 26 | * PURPOSE. See the GNU General Public License for more details. |
28 | * | 27 | * |
29 | * You should have received a copy of the GNU General Public | 28 | * You should have received a copy of the GNU General Public |
30 | * License along with this program; if not, write to the Free | 29 | * License along with this program; if not, write to the Free |
31 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, | 30 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, |
32 | * USA. | 31 | * USA. |
33 | * | 32 | * |
34 | * Revision history: | 33 | * Revision history: |
35 | * Revision 1.33 2000/03/09 10:00:00 pvdl,wolff | 34 | * Revision 1.33 2000/03/09 10:00:00 pvdl,wolff |
36 | * - Fixed module and port counting | 35 | * - Fixed module and port counting |
37 | * - Fixed signal handling | 36 | * - Fixed signal handling |
38 | * - Fixed an Ooops | 37 | * - Fixed an Ooops |
39 | * | 38 | * |
40 | * Revision 1.32 2000/03/07 09:00:00 wolff,pvdl | 39 | * Revision 1.32 2000/03/07 09:00:00 wolff,pvdl |
41 | * - Fixed some sx_dprintk typos | 40 | * - Fixed some sx_dprintk typos |
42 | * - added detection for an invalid board/module configuration | 41 | * - added detection for an invalid board/module configuration |
43 | * | 42 | * |
44 | * Revision 1.31 2000/03/06 12:00:00 wolff,pvdl | 43 | * Revision 1.31 2000/03/06 12:00:00 wolff,pvdl |
45 | * - Added support for EISA | 44 | * - Added support for EISA |
46 | * | 45 | * |
47 | * Revision 1.30 2000/01/21 17:43:06 wolff | 46 | * Revision 1.30 2000/01/21 17:43:06 wolff |
48 | * - Added support for SX+ | 47 | * - Added support for SX+ |
49 | * | 48 | * |
50 | * Revision 1.26 1999/08/05 15:22:14 wolff | 49 | * Revision 1.26 1999/08/05 15:22:14 wolff |
51 | * - Port to 2.3.x | 50 | * - Port to 2.3.x |
52 | * - Reformatted to Linus' liking. | 51 | * - Reformatted to Linus' liking. |
53 | * | 52 | * |
54 | * Revision 1.25 1999/07/30 14:24:08 wolff | 53 | * Revision 1.25 1999/07/30 14:24:08 wolff |
55 | * Had accidentally left "gs_debug" set to "-1" instead of "off" (=0). | 54 | * Had accidentally left "gs_debug" set to "-1" instead of "off" (=0). |
56 | * | 55 | * |
57 | * Revision 1.24 1999/07/28 09:41:52 wolff | 56 | * Revision 1.24 1999/07/28 09:41:52 wolff |
58 | * - I noticed the remark about use-count straying in sx.txt. I checked | 57 | * - I noticed the remark about use-count straying in sx.txt. I checked |
59 | * sx_open, and found a few places where that could happen. I hope it's | 58 | * sx_open, and found a few places where that could happen. I hope it's |
60 | * fixed now. | 59 | * fixed now. |
61 | * | 60 | * |
62 | * Revision 1.23 1999/07/28 08:56:06 wolff | 61 | * Revision 1.23 1999/07/28 08:56:06 wolff |
63 | * - Fixed crash when sx_firmware run twice. | 62 | * - Fixed crash when sx_firmware run twice. |
64 | * - Added sx_slowpoll as a module parameter (I guess nobody really wanted | 63 | * - Added sx_slowpoll as a module parameter (I guess nobody really wanted |
65 | * to change it from the default... ) | 64 | * to change it from the default... ) |
66 | * - Fixed a stupid editing problem I introduced in 1.22. | 65 | * - Fixed a stupid editing problem I introduced in 1.22. |
67 | * - Fixed dropping characters on a termios change. | 66 | * - Fixed dropping characters on a termios change. |
68 | * | 67 | * |
69 | * Revision 1.22 1999/07/26 21:01:43 wolff | 68 | * Revision 1.22 1999/07/26 21:01:43 wolff |
70 | * Russell Brown noticed that I had overlooked 4 out of six modem control | 69 | * Russell Brown noticed that I had overlooked 4 out of six modem control |
71 | * signals in sx_getsignals. Ooops. | 70 | * signals in sx_getsignals. Ooops. |
72 | * | 71 | * |
73 | * Revision 1.21 1999/07/23 09:11:33 wolff | 72 | * Revision 1.21 1999/07/23 09:11:33 wolff |
74 | * I forgot to free dynamically allocated memory when the driver is unloaded. | 73 | * I forgot to free dynamically allocated memory when the driver is unloaded. |
75 | * | 74 | * |
76 | * Revision 1.20 1999/07/20 06:25:26 wolff | 75 | * Revision 1.20 1999/07/20 06:25:26 wolff |
77 | * The "closing wait" wasn't honoured. Thanks to James Griffiths for | 76 | * The "closing wait" wasn't honoured. Thanks to James Griffiths for |
78 | * reporting this. | 77 | * reporting this. |
79 | * | 78 | * |
80 | * Revision 1.19 1999/07/11 08:59:59 wolff | 79 | * Revision 1.19 1999/07/11 08:59:59 wolff |
81 | * Fixed an oops in close, when an open was pending. Changed the memtest | 80 | * Fixed an oops in close, when an open was pending. Changed the memtest |
82 | * a bit. Should also test the board in word-mode, however my card fails the | 81 | * a bit. Should also test the board in word-mode, however my card fails the |
83 | * memtest then. I still have to figure out what is wrong... | 82 | * memtest then. I still have to figure out what is wrong... |
84 | * | 83 | * |
85 | * Revision 1.18 1999/06/10 09:38:42 wolff | 84 | * Revision 1.18 1999/06/10 09:38:42 wolff |
86 | * Changed the format of the firmware revision from %04x to %x.%02x . | 85 | * Changed the format of the firmware revision from %04x to %x.%02x . |
87 | * | 86 | * |
88 | * Revision 1.17 1999/06/04 09:44:35 wolff | 87 | * Revision 1.17 1999/06/04 09:44:35 wolff |
89 | * fixed problem: reference to pci stuff when config_pci was off... | 88 | * fixed problem: reference to pci stuff when config_pci was off... |
90 | * Thanks to Jorge Novo for noticing this. | 89 | * Thanks to Jorge Novo for noticing this. |
91 | * | 90 | * |
92 | * Revision 1.16 1999/06/02 08:30:15 wolff | 91 | * Revision 1.16 1999/06/02 08:30:15 wolff |
93 | * added/removed the workaround for the DCD bug in the Firmware. | 92 | * added/removed the workaround for the DCD bug in the Firmware. |
94 | * A bit more debugging code to locate that... | 93 | * A bit more debugging code to locate that... |
95 | * | 94 | * |
96 | * Revision 1.15 1999/06/01 11:35:30 wolff | 95 | * Revision 1.15 1999/06/01 11:35:30 wolff |
97 | * when DCD is left low (floating?), on TA's the firmware first tells us | 96 | * when DCD is left low (floating?), on TA's the firmware first tells us |
98 | * that DCD is high, but after a short while suddenly comes to the | 97 | * that DCD is high, but after a short while suddenly comes to the |
99 | * conclusion that it is low. All this would be fine, if it weren't that | 98 | * conclusion that it is low. All this would be fine, if it weren't that |
100 | * Unix requires us to send a "hangup" signal in that case. This usually | 99 | * Unix requires us to send a "hangup" signal in that case. This usually |
101 | * all happens BEFORE the program has had a chance to ioctl the device | 100 | * all happens BEFORE the program has had a chance to ioctl the device |
102 | * into clocal mode.. | 101 | * into clocal mode.. |
103 | * | 102 | * |
104 | * Revision 1.14 1999/05/25 11:18:59 wolff | 103 | * Revision 1.14 1999/05/25 11:18:59 wolff |
105 | * Added PCI-fix. | 104 | * Added PCI-fix. |
106 | * Added checks for return code of sx_sendcommand. | 105 | * Added checks for return code of sx_sendcommand. |
107 | * Don't issue "reconfig" if port isn't open yet. (bit us on TA modules...) | 106 | * Don't issue "reconfig" if port isn't open yet. (bit us on TA modules...) |
108 | * | 107 | * |
109 | * Revision 1.13 1999/04/29 15:18:01 wolff | 108 | * Revision 1.13 1999/04/29 15:18:01 wolff |
110 | * Fixed an "oops" that showed on SuSE 6.0 systems. | 109 | * Fixed an "oops" that showed on SuSE 6.0 systems. |
111 | * Activate DTR again after stty 0. | 110 | * Activate DTR again after stty 0. |
112 | * | 111 | * |
113 | * Revision 1.12 1999/04/29 07:49:52 wolff | 112 | * Revision 1.12 1999/04/29 07:49:52 wolff |
114 | * Improved "stty 0" handling a bit. (used to change baud to 9600 assuming | 113 | * Improved "stty 0" handling a bit. (used to change baud to 9600 assuming |
115 | * the connection would be dropped anyway. That is not always the case, | 114 | * the connection would be dropped anyway. That is not always the case, |
116 | * and confuses people). | 115 | * and confuses people). |
117 | * Told the card to always monitor the modem signals. | 116 | * Told the card to always monitor the modem signals. |
118 | * Added support for dynamic gs_debug adjustments. | 117 | * Added support for dynamic gs_debug adjustments. |
119 | * Now tells the rest of the system the number of ports. | 118 | * Now tells the rest of the system the number of ports. |
120 | * | 119 | * |
121 | * Revision 1.11 1999/04/24 11:11:30 wolff | 120 | * Revision 1.11 1999/04/24 11:11:30 wolff |
122 | * Fixed two stupid typos in the memory test. | 121 | * Fixed two stupid typos in the memory test. |
123 | * | 122 | * |
124 | * Revision 1.10 1999/04/24 10:53:39 wolff | 123 | * Revision 1.10 1999/04/24 10:53:39 wolff |
125 | * Added some of Christian's suggestions. | 124 | * Added some of Christian's suggestions. |
126 | * Fixed an HW_COOK_IN bug (ISIG was not in I_OTHER. We used to trust the | 125 | * Fixed an HW_COOK_IN bug (ISIG was not in I_OTHER. We used to trust the |
127 | * card to send the signal to the process.....) | 126 | * card to send the signal to the process.....) |
128 | * | 127 | * |
129 | * Revision 1.9 1999/04/23 07:26:38 wolff | 128 | * Revision 1.9 1999/04/23 07:26:38 wolff |
130 | * Included Christian Lademann's 2.0 compile-warning fixes and interrupt | 129 | * Included Christian Lademann's 2.0 compile-warning fixes and interrupt |
131 | * assignment redesign. | 130 | * assignment redesign. |
132 | * Cleanup of some other stuff. | 131 | * Cleanup of some other stuff. |
133 | * | 132 | * |
134 | * Revision 1.8 1999/04/16 13:05:30 wolff | 133 | * Revision 1.8 1999/04/16 13:05:30 wolff |
135 | * fixed a DCD change unnoticed bug. | 134 | * fixed a DCD change unnoticed bug. |
136 | * | 135 | * |
137 | * Revision 1.7 1999/04/14 22:19:51 wolff | 136 | * Revision 1.7 1999/04/14 22:19:51 wolff |
138 | * Fixed typo that showed up in 2.0.x builds (get_user instead of Get_user!) | 137 | * Fixed typo that showed up in 2.0.x builds (get_user instead of Get_user!) |
139 | * | 138 | * |
140 | * Revision 1.6 1999/04/13 18:40:20 wolff | 139 | * Revision 1.6 1999/04/13 18:40:20 wolff |
141 | * changed misc-minor to 161, as assigned by HPA. | 140 | * changed misc-minor to 161, as assigned by HPA. |
142 | * | 141 | * |
143 | * Revision 1.5 1999/04/13 15:12:25 wolff | 142 | * Revision 1.5 1999/04/13 15:12:25 wolff |
144 | * Fixed use-count leak when "hangup" occurred. | 143 | * Fixed use-count leak when "hangup" occurred. |
145 | * Added workaround for a stupid-PCIBIOS bug. | 144 | * Added workaround for a stupid-PCIBIOS bug. |
146 | * | 145 | * |
147 | * | 146 | * |
148 | * Revision 1.4 1999/04/01 22:47:40 wolff | 147 | * Revision 1.4 1999/04/01 22:47:40 wolff |
149 | * Fixed < 1M linux-2.0 problem. | 148 | * Fixed < 1M linux-2.0 problem. |
150 | * (vremap isn't compatible with ioremap in that case) | 149 | * (vremap isn't compatible with ioremap in that case) |
151 | * | 150 | * |
152 | * Revision 1.3 1999/03/31 13:45:45 wolff | 151 | * Revision 1.3 1999/03/31 13:45:45 wolff |
153 | * Firmware loading is now done through a separate IOCTL. | 152 | * Firmware loading is now done through a separate IOCTL. |
154 | * | 153 | * |
155 | * Revision 1.2 1999/03/28 12:22:29 wolff | 154 | * Revision 1.2 1999/03/28 12:22:29 wolff |
156 | * rcs cleanup | 155 | * rcs cleanup |
157 | * | 156 | * |
158 | * Revision 1.1 1999/03/28 12:10:34 wolff | 157 | * Revision 1.1 1999/03/28 12:10:34 wolff |
159 | * Readying for release on 2.0.x (sorry David, 1.01 becomes 1.1 for RCS). | 158 | * Readying for release on 2.0.x (sorry David, 1.01 becomes 1.1 for RCS). |
160 | * | 159 | * |
161 | * Revision 0.12 1999/03/28 09:20:10 wolff | 160 | * Revision 0.12 1999/03/28 09:20:10 wolff |
162 | * Fixed problem in 0.11, continueing cleanup. | 161 | * Fixed problem in 0.11, continueing cleanup. |
163 | * | 162 | * |
164 | * Revision 0.11 1999/03/28 08:46:44 wolff | 163 | * Revision 0.11 1999/03/28 08:46:44 wolff |
165 | * cleanup. Not good. | 164 | * cleanup. Not good. |
166 | * | 165 | * |
167 | * Revision 0.10 1999/03/28 08:09:43 wolff | 166 | * Revision 0.10 1999/03/28 08:09:43 wolff |
168 | * Fixed loosing characters on close. | 167 | * Fixed loosing characters on close. |
169 | * | 168 | * |
170 | * Revision 0.9 1999/03/21 22:52:01 wolff | 169 | * Revision 0.9 1999/03/21 22:52:01 wolff |
171 | * Ported back to 2.2.... (minor things) | 170 | * Ported back to 2.2.... (minor things) |
172 | * | 171 | * |
173 | * Revision 0.8 1999/03/21 22:40:33 wolff | 172 | * Revision 0.8 1999/03/21 22:40:33 wolff |
174 | * Port to 2.0 | 173 | * Port to 2.0 |
175 | * | 174 | * |
176 | * Revision 0.7 1999/03/21 19:06:34 wolff | 175 | * Revision 0.7 1999/03/21 19:06:34 wolff |
177 | * Fixed hangup processing. | 176 | * Fixed hangup processing. |
178 | * | 177 | * |
179 | * Revision 0.6 1999/02/05 08:45:14 wolff | 178 | * Revision 0.6 1999/02/05 08:45:14 wolff |
180 | * fixed real_raw problems. Inclusion into kernel imminent. | 179 | * fixed real_raw problems. Inclusion into kernel imminent. |
181 | * | 180 | * |
182 | * Revision 0.5 1998/12/21 23:51:06 wolff | 181 | * Revision 0.5 1998/12/21 23:51:06 wolff |
183 | * Snatched a nasty bug: sx_transmit_chars was getting re-entered, and it | 182 | * Snatched a nasty bug: sx_transmit_chars was getting re-entered, and it |
184 | * shouldn't have. THATs why I want to have transmit interrupts even when | 183 | * shouldn't have. THATs why I want to have transmit interrupts even when |
185 | * the buffer is empty. | 184 | * the buffer is empty. |
186 | * | 185 | * |
187 | * Revision 0.4 1998/12/17 09:34:46 wolff | 186 | * Revision 0.4 1998/12/17 09:34:46 wolff |
188 | * PPP works. ioctl works. Basically works! | 187 | * PPP works. ioctl works. Basically works! |
189 | * | 188 | * |
190 | * Revision 0.3 1998/12/15 13:05:18 wolff | 189 | * Revision 0.3 1998/12/15 13:05:18 wolff |
191 | * It works! Wow! Gotta start implementing IOCTL and stuff.... | 190 | * It works! Wow! Gotta start implementing IOCTL and stuff.... |
192 | * | 191 | * |
193 | * Revision 0.2 1998/12/01 08:33:53 wolff | 192 | * Revision 0.2 1998/12/01 08:33:53 wolff |
194 | * moved over to 2.1.130 | 193 | * moved over to 2.1.130 |
195 | * | 194 | * |
196 | * Revision 0.1 1998/11/03 21:23:51 wolff | 195 | * Revision 0.1 1998/11/03 21:23:51 wolff |
197 | * Initial revision. Detects SX card. | 196 | * Initial revision. Detects SX card. |
198 | * | 197 | * |
199 | * */ | 198 | * */ |
200 | 199 | ||
201 | #define SX_VERSION 1.33 | 200 | #define SX_VERSION 1.33 |
202 | 201 | ||
203 | #include <linux/module.h> | 202 | #include <linux/module.h> |
204 | #include <linux/kdev_t.h> | 203 | #include <linux/kdev_t.h> |
205 | #include <linux/kernel.h> | 204 | #include <linux/kernel.h> |
206 | #include <linux/sched.h> | 205 | #include <linux/sched.h> |
207 | #include <linux/ioport.h> | 206 | #include <linux/ioport.h> |
208 | #include <linux/interrupt.h> | 207 | #include <linux/interrupt.h> |
209 | #include <linux/errno.h> | 208 | #include <linux/errno.h> |
210 | #include <linux/tty.h> | 209 | #include <linux/tty.h> |
211 | #include <linux/tty_flip.h> | 210 | #include <linux/tty_flip.h> |
212 | #include <linux/mm.h> | 211 | #include <linux/mm.h> |
213 | #include <linux/serial.h> | 212 | #include <linux/serial.h> |
214 | #include <linux/fcntl.h> | 213 | #include <linux/fcntl.h> |
215 | #include <linux/major.h> | 214 | #include <linux/major.h> |
216 | #include <linux/delay.h> | 215 | #include <linux/delay.h> |
217 | #include <linux/eisa.h> | 216 | #include <linux/eisa.h> |
218 | #include <linux/pci.h> | 217 | #include <linux/pci.h> |
219 | #include <linux/slab.h> | 218 | #include <linux/slab.h> |
220 | #include <linux/init.h> | 219 | #include <linux/init.h> |
221 | #include <linux/miscdevice.h> | 220 | #include <linux/miscdevice.h> |
222 | #include <linux/bitops.h> | 221 | #include <linux/bitops.h> |
223 | 222 | ||
224 | #include <asm/io.h> | 223 | #include <asm/io.h> |
225 | #include <asm/uaccess.h> | 224 | #include <asm/uaccess.h> |
226 | 225 | ||
227 | /* The 3.0.0 version of sxboards/sxwindow.h uses BYTE and WORD.... */ | 226 | /* The 3.0.0 version of sxboards/sxwindow.h uses BYTE and WORD.... */ |
228 | #define BYTE u8 | 227 | #define BYTE u8 |
229 | #define WORD u16 | 228 | #define WORD u16 |
230 | 229 | ||
231 | /* .... but the 3.0.4 version uses _u8 and _u16. */ | 230 | /* .... but the 3.0.4 version uses _u8 and _u16. */ |
232 | #define _u8 u8 | 231 | #define _u8 u8 |
233 | #define _u16 u16 | 232 | #define _u16 u16 |
234 | 233 | ||
235 | #include "sxboards.h" | 234 | #include "sxboards.h" |
236 | #include "sxwindow.h" | 235 | #include "sxwindow.h" |
237 | 236 | ||
238 | #include <linux/generic_serial.h> | 237 | #include <linux/generic_serial.h> |
239 | #include "sx.h" | 238 | #include "sx.h" |
240 | 239 | ||
241 | /* I don't think that this driver can handle more than 256 ports on | 240 | /* I don't think that this driver can handle more than 256 ports on |
242 | one machine. You'll have to increase the number of boards in sx.h | 241 | one machine. You'll have to increase the number of boards in sx.h |
243 | if you want more than 4 boards. */ | 242 | if you want more than 4 boards. */ |
244 | 243 | ||
245 | #ifndef PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8 | 244 | #ifndef PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8 |
246 | #define PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8 0x2000 | 245 | #define PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8 0x2000 |
247 | #endif | 246 | #endif |
248 | 247 | ||
249 | /* Configurable options: | 248 | /* Configurable options: |
250 | (Don't be too sure that it'll work if you toggle them) */ | 249 | (Don't be too sure that it'll work if you toggle them) */ |
251 | 250 | ||
252 | /* Am I paranoid or not ? ;-) */ | 251 | /* Am I paranoid or not ? ;-) */ |
253 | #undef SX_PARANOIA_CHECK | 252 | #undef SX_PARANOIA_CHECK |
254 | 253 | ||
255 | /* 20 -> 2000 per second. The card should rate-limit interrupts at 100 | 254 | /* 20 -> 2000 per second. The card should rate-limit interrupts at 100 |
256 | Hz, but it is user configurable. I don't recommend going above 1000 | 255 | Hz, but it is user configurable. I don't recommend going above 1000 |
257 | Hz. The interrupt ratelimit might trigger if the interrupt is | 256 | Hz. The interrupt ratelimit might trigger if the interrupt is |
258 | shared with a very active other device. */ | 257 | shared with a very active other device. */ |
259 | #define IRQ_RATE_LIMIT 20 | 258 | #define IRQ_RATE_LIMIT 20 |
260 | 259 | ||
261 | /* Sharing interrupts is possible now. If the other device wants more | 260 | /* Sharing interrupts is possible now. If the other device wants more |
262 | than 2000 interrupts per second, we'd gracefully decline further | 261 | than 2000 interrupts per second, we'd gracefully decline further |
263 | interrupts. That's not what we want. On the other hand, if the | 262 | interrupts. That's not what we want. On the other hand, if the |
264 | other device interrupts 2000 times a second, don't use the SX | 263 | other device interrupts 2000 times a second, don't use the SX |
265 | interrupt. Use polling. */ | 264 | interrupt. Use polling. */ |
266 | #undef IRQ_RATE_LIMIT | 265 | #undef IRQ_RATE_LIMIT |
267 | 266 | ||
268 | #if 0 | 267 | #if 0 |
269 | /* Not implemented */ | 268 | /* Not implemented */ |
270 | /* | 269 | /* |
271 | * The following defines are mostly for testing purposes. But if you need | 270 | * The following defines are mostly for testing purposes. But if you need |
272 | * some nice reporting in your syslog, you can define them also. | 271 | * some nice reporting in your syslog, you can define them also. |
273 | */ | 272 | */ |
274 | #define SX_REPORT_FIFO | 273 | #define SX_REPORT_FIFO |
275 | #define SX_REPORT_OVERRUN | 274 | #define SX_REPORT_OVERRUN |
276 | #endif | 275 | #endif |
277 | 276 | ||
278 | /* Function prototypes */ | 277 | /* Function prototypes */ |
279 | static void sx_disable_tx_interrupts(void *ptr); | 278 | static void sx_disable_tx_interrupts(void *ptr); |
280 | static void sx_enable_tx_interrupts(void *ptr); | 279 | static void sx_enable_tx_interrupts(void *ptr); |
281 | static void sx_disable_rx_interrupts(void *ptr); | 280 | static void sx_disable_rx_interrupts(void *ptr); |
282 | static void sx_enable_rx_interrupts(void *ptr); | 281 | static void sx_enable_rx_interrupts(void *ptr); |
283 | static int sx_get_CD(void *ptr); | 282 | static int sx_get_CD(void *ptr); |
284 | static void sx_shutdown_port(void *ptr); | 283 | static void sx_shutdown_port(void *ptr); |
285 | static int sx_set_real_termios(void *ptr); | 284 | static int sx_set_real_termios(void *ptr); |
286 | static void sx_close(void *ptr); | 285 | static void sx_close(void *ptr); |
287 | static int sx_chars_in_buffer(void *ptr); | 286 | static int sx_chars_in_buffer(void *ptr); |
288 | static int sx_init_board(struct sx_board *board); | 287 | static int sx_init_board(struct sx_board *board); |
289 | static int sx_init_portstructs(int nboards, int nports); | 288 | static int sx_init_portstructs(int nboards, int nports); |
290 | static int sx_fw_ioctl(struct inode *inode, struct file *filp, | 289 | static int sx_fw_ioctl(struct inode *inode, struct file *filp, |
291 | unsigned int cmd, unsigned long arg); | 290 | unsigned int cmd, unsigned long arg); |
292 | static int sx_init_drivers(void); | 291 | static int sx_init_drivers(void); |
293 | 292 | ||
294 | static struct tty_driver *sx_driver; | 293 | static struct tty_driver *sx_driver; |
295 | 294 | ||
296 | static DEFINE_MUTEX(sx_boards_lock); | 295 | static DEFINE_MUTEX(sx_boards_lock); |
297 | static struct sx_board boards[SX_NBOARDS]; | 296 | static struct sx_board boards[SX_NBOARDS]; |
298 | static struct sx_port *sx_ports; | 297 | static struct sx_port *sx_ports; |
299 | static int sx_initialized; | 298 | static int sx_initialized; |
300 | static int sx_nports; | 299 | static int sx_nports; |
301 | static int sx_debug; | 300 | static int sx_debug; |
302 | 301 | ||
303 | /* You can have the driver poll your card. | 302 | /* You can have the driver poll your card. |
304 | - Set sx_poll to 1 to poll every timer tick (10ms on Intel). | 303 | - Set sx_poll to 1 to poll every timer tick (10ms on Intel). |
305 | This is used when the card cannot use an interrupt for some reason. | 304 | This is used when the card cannot use an interrupt for some reason. |
306 | 305 | ||
307 | - set sx_slowpoll to 100 to do an extra poll once a second (on Intel). If | 306 | - set sx_slowpoll to 100 to do an extra poll once a second (on Intel). If |
308 | the driver misses an interrupt (report this if it DOES happen to you!) | 307 | the driver misses an interrupt (report this if it DOES happen to you!) |
309 | everything will continue to work.... | 308 | everything will continue to work.... |
310 | */ | 309 | */ |
311 | static int sx_poll = 1; | 310 | static int sx_poll = 1; |
312 | static int sx_slowpoll; | 311 | static int sx_slowpoll; |
313 | 312 | ||
314 | /* The card limits the number of interrupts per second. | 313 | /* The card limits the number of interrupts per second. |
315 | At 115k2 "100" should be sufficient. | 314 | At 115k2 "100" should be sufficient. |
316 | If you're using higher baudrates, you can increase this... | 315 | If you're using higher baudrates, you can increase this... |
317 | */ | 316 | */ |
318 | 317 | ||
319 | static int sx_maxints = 100; | 318 | static int sx_maxints = 100; |
320 | 319 | ||
321 | #ifdef CONFIG_ISA | 320 | #ifdef CONFIG_ISA |
322 | 321 | ||
323 | /* These are the only open spaces in my computer. Yours may have more | 322 | /* These are the only open spaces in my computer. Yours may have more |
324 | or less.... -- REW | 323 | or less.... -- REW |
325 | duh: Card at 0xa0000 is possible on HP Netserver?? -- pvdl | 324 | duh: Card at 0xa0000 is possible on HP Netserver?? -- pvdl |
326 | */ | 325 | */ |
327 | static int sx_probe_addrs[] = { | 326 | static int sx_probe_addrs[] = { |
328 | 0xc0000, 0xd0000, 0xe0000, | 327 | 0xc0000, 0xd0000, 0xe0000, |
329 | 0xc8000, 0xd8000, 0xe8000 | 328 | 0xc8000, 0xd8000, 0xe8000 |
330 | }; | 329 | }; |
331 | static int si_probe_addrs[] = { | 330 | static int si_probe_addrs[] = { |
332 | 0xc0000, 0xd0000, 0xe0000, | 331 | 0xc0000, 0xd0000, 0xe0000, |
333 | 0xc8000, 0xd8000, 0xe8000, 0xa0000 | 332 | 0xc8000, 0xd8000, 0xe8000, 0xa0000 |
334 | }; | 333 | }; |
335 | static int si1_probe_addrs[] = { | 334 | static int si1_probe_addrs[] = { |
336 | 0xd0000 | 335 | 0xd0000 |
337 | }; | 336 | }; |
338 | 337 | ||
339 | #define NR_SX_ADDRS ARRAY_SIZE(sx_probe_addrs) | 338 | #define NR_SX_ADDRS ARRAY_SIZE(sx_probe_addrs) |
340 | #define NR_SI_ADDRS ARRAY_SIZE(si_probe_addrs) | 339 | #define NR_SI_ADDRS ARRAY_SIZE(si_probe_addrs) |
341 | #define NR_SI1_ADDRS ARRAY_SIZE(si1_probe_addrs) | 340 | #define NR_SI1_ADDRS ARRAY_SIZE(si1_probe_addrs) |
342 | 341 | ||
343 | module_param_array(sx_probe_addrs, int, NULL, 0); | 342 | module_param_array(sx_probe_addrs, int, NULL, 0); |
344 | module_param_array(si_probe_addrs, int, NULL, 0); | 343 | module_param_array(si_probe_addrs, int, NULL, 0); |
345 | #endif | 344 | #endif |
346 | 345 | ||
347 | /* Set the mask to all-ones. This alas, only supports 32 interrupts. | 346 | /* Set the mask to all-ones. This alas, only supports 32 interrupts. |
348 | Some architectures may need more. */ | 347 | Some architectures may need more. */ |
349 | static int sx_irqmask = -1; | 348 | static int sx_irqmask = -1; |
350 | 349 | ||
351 | module_param(sx_poll, int, 0); | 350 | module_param(sx_poll, int, 0); |
352 | module_param(sx_slowpoll, int, 0); | 351 | module_param(sx_slowpoll, int, 0); |
353 | module_param(sx_maxints, int, 0); | 352 | module_param(sx_maxints, int, 0); |
354 | module_param(sx_debug, int, 0); | 353 | module_param(sx_debug, int, 0); |
355 | module_param(sx_irqmask, int, 0); | 354 | module_param(sx_irqmask, int, 0); |
356 | 355 | ||
357 | MODULE_LICENSE("GPL"); | 356 | MODULE_LICENSE("GPL"); |
358 | 357 | ||
359 | static struct real_driver sx_real_driver = { | 358 | static struct real_driver sx_real_driver = { |
360 | sx_disable_tx_interrupts, | 359 | sx_disable_tx_interrupts, |
361 | sx_enable_tx_interrupts, | 360 | sx_enable_tx_interrupts, |
362 | sx_disable_rx_interrupts, | 361 | sx_disable_rx_interrupts, |
363 | sx_enable_rx_interrupts, | 362 | sx_enable_rx_interrupts, |
364 | sx_get_CD, | 363 | sx_get_CD, |
365 | sx_shutdown_port, | 364 | sx_shutdown_port, |
366 | sx_set_real_termios, | 365 | sx_set_real_termios, |
367 | sx_chars_in_buffer, | 366 | sx_chars_in_buffer, |
368 | sx_close, | 367 | sx_close, |
369 | }; | 368 | }; |
370 | 369 | ||
371 | /* | 370 | /* |
372 | This driver can spew a whole lot of debugging output at you. If you | 371 | This driver can spew a whole lot of debugging output at you. If you |
373 | need maximum performance, you should disable the DEBUG define. To | 372 | need maximum performance, you should disable the DEBUG define. To |
374 | aid in debugging in the field, I'm leaving the compile-time debug | 373 | aid in debugging in the field, I'm leaving the compile-time debug |
375 | features enabled, and disable them "runtime". That allows me to | 374 | features enabled, and disable them "runtime". That allows me to |
376 | instruct people with problems to enable debugging without requiring | 375 | instruct people with problems to enable debugging without requiring |
377 | them to recompile... | 376 | them to recompile... |
378 | */ | 377 | */ |
379 | #define DEBUG | 378 | #define DEBUG |
380 | 379 | ||
381 | #ifdef DEBUG | 380 | #ifdef DEBUG |
382 | #define sx_dprintk(f, str...) if (sx_debug & f) printk (str) | 381 | #define sx_dprintk(f, str...) if (sx_debug & f) printk (str) |
383 | #else | 382 | #else |
384 | #define sx_dprintk(f, str...) /* nothing */ | 383 | #define sx_dprintk(f, str...) /* nothing */ |
385 | #endif | 384 | #endif |
386 | 385 | ||
387 | #define func_enter() sx_dprintk(SX_DEBUG_FLOW, "sx: enter %s\n",__func__) | 386 | #define func_enter() sx_dprintk(SX_DEBUG_FLOW, "sx: enter %s\n",__func__) |
388 | #define func_exit() sx_dprintk(SX_DEBUG_FLOW, "sx: exit %s\n",__func__) | 387 | #define func_exit() sx_dprintk(SX_DEBUG_FLOW, "sx: exit %s\n",__func__) |
389 | 388 | ||
390 | #define func_enter2() sx_dprintk(SX_DEBUG_FLOW, "sx: enter %s (port %d)\n", \ | 389 | #define func_enter2() sx_dprintk(SX_DEBUG_FLOW, "sx: enter %s (port %d)\n", \ |
391 | __func__, port->line) | 390 | __func__, port->line) |
392 | 391 | ||
393 | /* | 392 | /* |
394 | * Firmware loader driver specific routines | 393 | * Firmware loader driver specific routines |
395 | * | 394 | * |
396 | */ | 395 | */ |
397 | 396 | ||
398 | static const struct file_operations sx_fw_fops = { | 397 | static const struct file_operations sx_fw_fops = { |
399 | .owner = THIS_MODULE, | 398 | .owner = THIS_MODULE, |
400 | .ioctl = sx_fw_ioctl, | 399 | .ioctl = sx_fw_ioctl, |
401 | }; | 400 | }; |
402 | 401 | ||
403 | static struct miscdevice sx_fw_device = { | 402 | static struct miscdevice sx_fw_device = { |
404 | SXCTL_MISC_MINOR, "sxctl", &sx_fw_fops | 403 | SXCTL_MISC_MINOR, "sxctl", &sx_fw_fops |
405 | }; | 404 | }; |
406 | 405 | ||
407 | #ifdef SX_PARANOIA_CHECK | 406 | #ifdef SX_PARANOIA_CHECK |
408 | 407 | ||
409 | /* This doesn't work. Who's paranoid around here? Not me! */ | 408 | /* This doesn't work. Who's paranoid around here? Not me! */ |
410 | 409 | ||
411 | static inline int sx_paranoia_check(struct sx_port const *port, | 410 | static inline int sx_paranoia_check(struct sx_port const *port, |
412 | char *name, const char *routine) | 411 | char *name, const char *routine) |
413 | { | 412 | { |
414 | static const char *badmagic = KERN_ERR "sx: Warning: bad sx port magic " | 413 | static const char *badmagic = KERN_ERR "sx: Warning: bad sx port magic " |
415 | "number for device %s in %s\n"; | 414 | "number for device %s in %s\n"; |
416 | static const char *badinfo = KERN_ERR "sx: Warning: null sx port for " | 415 | static const char *badinfo = KERN_ERR "sx: Warning: null sx port for " |
417 | "device %s in %s\n"; | 416 | "device %s in %s\n"; |
418 | 417 | ||
419 | if (!port) { | 418 | if (!port) { |
420 | printk(badinfo, name, routine); | 419 | printk(badinfo, name, routine); |
421 | return 1; | 420 | return 1; |
422 | } | 421 | } |
423 | if (port->magic != SX_MAGIC) { | 422 | if (port->magic != SX_MAGIC) { |
424 | printk(badmagic, name, routine); | 423 | printk(badmagic, name, routine); |
425 | return 1; | 424 | return 1; |
426 | } | 425 | } |
427 | 426 | ||
428 | return 0; | 427 | return 0; |
429 | } | 428 | } |
430 | #else | 429 | #else |
431 | #define sx_paranoia_check(a,b,c) 0 | 430 | #define sx_paranoia_check(a,b,c) 0 |
432 | #endif | 431 | #endif |
433 | 432 | ||
434 | /* The timeouts. First try 30 times as fast as possible. Then give | 433 | /* The timeouts. First try 30 times as fast as possible. Then give |
435 | the card some time to breathe between accesses. (Otherwise the | 434 | the card some time to breathe between accesses. (Otherwise the |
436 | processor on the card might not be able to access its OWN bus... */ | 435 | processor on the card might not be able to access its OWN bus... */ |
437 | 436 | ||
438 | #define TIMEOUT_1 30 | 437 | #define TIMEOUT_1 30 |
439 | #define TIMEOUT_2 1000000 | 438 | #define TIMEOUT_2 1000000 |
440 | 439 | ||
441 | #ifdef DEBUG | 440 | #ifdef DEBUG |
442 | static void my_hd_io(void __iomem *p, int len) | 441 | static void my_hd_io(void __iomem *p, int len) |
443 | { | 442 | { |
444 | int i, j, ch; | 443 | int i, j, ch; |
445 | unsigned char __iomem *addr = p; | 444 | unsigned char __iomem *addr = p; |
446 | 445 | ||
447 | for (i = 0; i < len; i += 16) { | 446 | for (i = 0; i < len; i += 16) { |
448 | printk("%p ", addr + i); | 447 | printk("%p ", addr + i); |
449 | for (j = 0; j < 16; j++) { | 448 | for (j = 0; j < 16; j++) { |
450 | printk("%02x %s", readb(addr + j + i), | 449 | printk("%02x %s", readb(addr + j + i), |
451 | (j == 7) ? " " : ""); | 450 | (j == 7) ? " " : ""); |
452 | } | 451 | } |
453 | for (j = 0; j < 16; j++) { | 452 | for (j = 0; j < 16; j++) { |
454 | ch = readb(addr + j + i); | 453 | ch = readb(addr + j + i); |
455 | printk("%c", (ch < 0x20) ? '.' : | 454 | printk("%c", (ch < 0x20) ? '.' : |
456 | ((ch > 0x7f) ? '.' : ch)); | 455 | ((ch > 0x7f) ? '.' : ch)); |
457 | } | 456 | } |
458 | printk("\n"); | 457 | printk("\n"); |
459 | } | 458 | } |
460 | } | 459 | } |
461 | static void my_hd(void *p, int len) | 460 | static void my_hd(void *p, int len) |
462 | { | 461 | { |
463 | int i, j, ch; | 462 | int i, j, ch; |
464 | unsigned char *addr = p; | 463 | unsigned char *addr = p; |
465 | 464 | ||
466 | for (i = 0; i < len; i += 16) { | 465 | for (i = 0; i < len; i += 16) { |
467 | printk("%p ", addr + i); | 466 | printk("%p ", addr + i); |
468 | for (j = 0; j < 16; j++) { | 467 | for (j = 0; j < 16; j++) { |
469 | printk("%02x %s", addr[j + i], (j == 7) ? " " : ""); | 468 | printk("%02x %s", addr[j + i], (j == 7) ? " " : ""); |
470 | } | 469 | } |
471 | for (j = 0; j < 16; j++) { | 470 | for (j = 0; j < 16; j++) { |
472 | ch = addr[j + i]; | 471 | ch = addr[j + i]; |
473 | printk("%c", (ch < 0x20) ? '.' : | 472 | printk("%c", (ch < 0x20) ? '.' : |
474 | ((ch > 0x7f) ? '.' : ch)); | 473 | ((ch > 0x7f) ? '.' : ch)); |
475 | } | 474 | } |
476 | printk("\n"); | 475 | printk("\n"); |
477 | } | 476 | } |
478 | } | 477 | } |
479 | #endif | 478 | #endif |
480 | 479 | ||
481 | /* This needs redoing for Alpha -- REW -- Done. */ | 480 | /* This needs redoing for Alpha -- REW -- Done. */ |
482 | 481 | ||
483 | static inline void write_sx_byte(struct sx_board *board, int offset, u8 byte) | 482 | static inline void write_sx_byte(struct sx_board *board, int offset, u8 byte) |
484 | { | 483 | { |
485 | writeb(byte, board->base + offset); | 484 | writeb(byte, board->base + offset); |
486 | } | 485 | } |
487 | 486 | ||
488 | static inline u8 read_sx_byte(struct sx_board *board, int offset) | 487 | static inline u8 read_sx_byte(struct sx_board *board, int offset) |
489 | { | 488 | { |
490 | return readb(board->base + offset); | 489 | return readb(board->base + offset); |
491 | } | 490 | } |
492 | 491 | ||
493 | static inline void write_sx_word(struct sx_board *board, int offset, u16 word) | 492 | static inline void write_sx_word(struct sx_board *board, int offset, u16 word) |
494 | { | 493 | { |
495 | writew(word, board->base + offset); | 494 | writew(word, board->base + offset); |
496 | } | 495 | } |
497 | 496 | ||
498 | static inline u16 read_sx_word(struct sx_board *board, int offset) | 497 | static inline u16 read_sx_word(struct sx_board *board, int offset) |
499 | { | 498 | { |
500 | return readw(board->base + offset); | 499 | return readw(board->base + offset); |
501 | } | 500 | } |
502 | 501 | ||
503 | static int sx_busy_wait_eq(struct sx_board *board, | 502 | static int sx_busy_wait_eq(struct sx_board *board, |
504 | int offset, int mask, int correctval) | 503 | int offset, int mask, int correctval) |
505 | { | 504 | { |
506 | int i; | 505 | int i; |
507 | 506 | ||
508 | func_enter(); | 507 | func_enter(); |
509 | 508 | ||
510 | for (i = 0; i < TIMEOUT_1; i++) | 509 | for (i = 0; i < TIMEOUT_1; i++) |
511 | if ((read_sx_byte(board, offset) & mask) == correctval) { | 510 | if ((read_sx_byte(board, offset) & mask) == correctval) { |
512 | func_exit(); | 511 | func_exit(); |
513 | return 1; | 512 | return 1; |
514 | } | 513 | } |
515 | 514 | ||
516 | for (i = 0; i < TIMEOUT_2; i++) { | 515 | for (i = 0; i < TIMEOUT_2; i++) { |
517 | if ((read_sx_byte(board, offset) & mask) == correctval) { | 516 | if ((read_sx_byte(board, offset) & mask) == correctval) { |
518 | func_exit(); | 517 | func_exit(); |
519 | return 1; | 518 | return 1; |
520 | } | 519 | } |
521 | udelay(1); | 520 | udelay(1); |
522 | } | 521 | } |
523 | 522 | ||
524 | func_exit(); | 523 | func_exit(); |
525 | return 0; | 524 | return 0; |
526 | } | 525 | } |
527 | 526 | ||
528 | static int sx_busy_wait_neq(struct sx_board *board, | 527 | static int sx_busy_wait_neq(struct sx_board *board, |
529 | int offset, int mask, int badval) | 528 | int offset, int mask, int badval) |
530 | { | 529 | { |
531 | int i; | 530 | int i; |
532 | 531 | ||
533 | func_enter(); | 532 | func_enter(); |
534 | 533 | ||
535 | for (i = 0; i < TIMEOUT_1; i++) | 534 | for (i = 0; i < TIMEOUT_1; i++) |
536 | if ((read_sx_byte(board, offset) & mask) != badval) { | 535 | if ((read_sx_byte(board, offset) & mask) != badval) { |
537 | func_exit(); | 536 | func_exit(); |
538 | return 1; | 537 | return 1; |
539 | } | 538 | } |
540 | 539 | ||
541 | for (i = 0; i < TIMEOUT_2; i++) { | 540 | for (i = 0; i < TIMEOUT_2; i++) { |
542 | if ((read_sx_byte(board, offset) & mask) != badval) { | 541 | if ((read_sx_byte(board, offset) & mask) != badval) { |
543 | func_exit(); | 542 | func_exit(); |
544 | return 1; | 543 | return 1; |
545 | } | 544 | } |
546 | udelay(1); | 545 | udelay(1); |
547 | } | 546 | } |
548 | 547 | ||
549 | func_exit(); | 548 | func_exit(); |
550 | return 0; | 549 | return 0; |
551 | } | 550 | } |
552 | 551 | ||
553 | /* 5.6.4 of 6210028 r2.3 */ | 552 | /* 5.6.4 of 6210028 r2.3 */ |
554 | static int sx_reset(struct sx_board *board) | 553 | static int sx_reset(struct sx_board *board) |
555 | { | 554 | { |
556 | func_enter(); | 555 | func_enter(); |
557 | 556 | ||
558 | if (IS_SX_BOARD(board)) { | 557 | if (IS_SX_BOARD(board)) { |
559 | 558 | ||
560 | write_sx_byte(board, SX_CONFIG, 0); | 559 | write_sx_byte(board, SX_CONFIG, 0); |
561 | write_sx_byte(board, SX_RESET, 1); /* Value doesn't matter */ | 560 | write_sx_byte(board, SX_RESET, 1); /* Value doesn't matter */ |
562 | 561 | ||
563 | if (!sx_busy_wait_eq(board, SX_RESET_STATUS, 1, 0)) { | 562 | if (!sx_busy_wait_eq(board, SX_RESET_STATUS, 1, 0)) { |
564 | printk(KERN_INFO "sx: Card doesn't respond to " | 563 | printk(KERN_INFO "sx: Card doesn't respond to " |
565 | "reset...\n"); | 564 | "reset...\n"); |
566 | return 0; | 565 | return 0; |
567 | } | 566 | } |
568 | } else if (IS_EISA_BOARD(board)) { | 567 | } else if (IS_EISA_BOARD(board)) { |
569 | outb(board->irq << 4, board->eisa_base + 0xc02); | 568 | outb(board->irq << 4, board->eisa_base + 0xc02); |
570 | } else if (IS_SI1_BOARD(board)) { | 569 | } else if (IS_SI1_BOARD(board)) { |
571 | write_sx_byte(board, SI1_ISA_RESET, 0); /*value doesn't matter*/ | 570 | write_sx_byte(board, SI1_ISA_RESET, 0); /*value doesn't matter*/ |
572 | } else { | 571 | } else { |
573 | /* Gory details of the SI/ISA board */ | 572 | /* Gory details of the SI/ISA board */ |
574 | write_sx_byte(board, SI2_ISA_RESET, SI2_ISA_RESET_SET); | 573 | write_sx_byte(board, SI2_ISA_RESET, SI2_ISA_RESET_SET); |
575 | write_sx_byte(board, SI2_ISA_IRQ11, SI2_ISA_IRQ11_CLEAR); | 574 | write_sx_byte(board, SI2_ISA_IRQ11, SI2_ISA_IRQ11_CLEAR); |
576 | write_sx_byte(board, SI2_ISA_IRQ12, SI2_ISA_IRQ12_CLEAR); | 575 | write_sx_byte(board, SI2_ISA_IRQ12, SI2_ISA_IRQ12_CLEAR); |
577 | write_sx_byte(board, SI2_ISA_IRQ15, SI2_ISA_IRQ15_CLEAR); | 576 | write_sx_byte(board, SI2_ISA_IRQ15, SI2_ISA_IRQ15_CLEAR); |
578 | write_sx_byte(board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_CLEAR); | 577 | write_sx_byte(board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_CLEAR); |
579 | write_sx_byte(board, SI2_ISA_IRQSET, SI2_ISA_IRQSET_CLEAR); | 578 | write_sx_byte(board, SI2_ISA_IRQSET, SI2_ISA_IRQSET_CLEAR); |
580 | } | 579 | } |
581 | 580 | ||
582 | func_exit(); | 581 | func_exit(); |
583 | return 1; | 582 | return 1; |
584 | } | 583 | } |
585 | 584 | ||
586 | /* This doesn't work on machines where "NULL" isn't 0 */ | 585 | /* This doesn't work on machines where "NULL" isn't 0 */ |
587 | /* If you have one of those, someone will need to write | 586 | /* If you have one of those, someone will need to write |
588 | the equivalent of this, which will amount to about 3 lines. I don't | 587 | the equivalent of this, which will amount to about 3 lines. I don't |
589 | want to complicate this right now. -- REW | 588 | want to complicate this right now. -- REW |
590 | (See, I do write comments every now and then :-) */ | 589 | (See, I do write comments every now and then :-) */ |
591 | #define OFFSETOF(strct, elem) ((long)&(((struct strct *)NULL)->elem)) | 590 | #define OFFSETOF(strct, elem) ((long)&(((struct strct *)NULL)->elem)) |
592 | 591 | ||
593 | #define CHAN_OFFSET(port,elem) (port->ch_base + OFFSETOF (_SXCHANNEL, elem)) | 592 | #define CHAN_OFFSET(port,elem) (port->ch_base + OFFSETOF (_SXCHANNEL, elem)) |
594 | #define MODU_OFFSET(board,addr,elem) (addr + OFFSETOF (_SXMODULE, elem)) | 593 | #define MODU_OFFSET(board,addr,elem) (addr + OFFSETOF (_SXMODULE, elem)) |
595 | #define BRD_OFFSET(board,elem) (OFFSETOF (_SXCARD, elem)) | 594 | #define BRD_OFFSET(board,elem) (OFFSETOF (_SXCARD, elem)) |
596 | 595 | ||
597 | #define sx_write_channel_byte(port, elem, val) \ | 596 | #define sx_write_channel_byte(port, elem, val) \ |
598 | write_sx_byte (port->board, CHAN_OFFSET (port, elem), val) | 597 | write_sx_byte (port->board, CHAN_OFFSET (port, elem), val) |
599 | 598 | ||
600 | #define sx_read_channel_byte(port, elem) \ | 599 | #define sx_read_channel_byte(port, elem) \ |
601 | read_sx_byte (port->board, CHAN_OFFSET (port, elem)) | 600 | read_sx_byte (port->board, CHAN_OFFSET (port, elem)) |
602 | 601 | ||
603 | #define sx_write_channel_word(port, elem, val) \ | 602 | #define sx_write_channel_word(port, elem, val) \ |
604 | write_sx_word (port->board, CHAN_OFFSET (port, elem), val) | 603 | write_sx_word (port->board, CHAN_OFFSET (port, elem), val) |
605 | 604 | ||
606 | #define sx_read_channel_word(port, elem) \ | 605 | #define sx_read_channel_word(port, elem) \ |
607 | read_sx_word (port->board, CHAN_OFFSET (port, elem)) | 606 | read_sx_word (port->board, CHAN_OFFSET (port, elem)) |
608 | 607 | ||
609 | #define sx_write_module_byte(board, addr, elem, val) \ | 608 | #define sx_write_module_byte(board, addr, elem, val) \ |
610 | write_sx_byte (board, MODU_OFFSET (board, addr, elem), val) | 609 | write_sx_byte (board, MODU_OFFSET (board, addr, elem), val) |
611 | 610 | ||
612 | #define sx_read_module_byte(board, addr, elem) \ | 611 | #define sx_read_module_byte(board, addr, elem) \ |
613 | read_sx_byte (board, MODU_OFFSET (board, addr, elem)) | 612 | read_sx_byte (board, MODU_OFFSET (board, addr, elem)) |
614 | 613 | ||
615 | #define sx_write_module_word(board, addr, elem, val) \ | 614 | #define sx_write_module_word(board, addr, elem, val) \ |
616 | write_sx_word (board, MODU_OFFSET (board, addr, elem), val) | 615 | write_sx_word (board, MODU_OFFSET (board, addr, elem), val) |
617 | 616 | ||
618 | #define sx_read_module_word(board, addr, elem) \ | 617 | #define sx_read_module_word(board, addr, elem) \ |
619 | read_sx_word (board, MODU_OFFSET (board, addr, elem)) | 618 | read_sx_word (board, MODU_OFFSET (board, addr, elem)) |
620 | 619 | ||
621 | #define sx_write_board_byte(board, elem, val) \ | 620 | #define sx_write_board_byte(board, elem, val) \ |
622 | write_sx_byte (board, BRD_OFFSET (board, elem), val) | 621 | write_sx_byte (board, BRD_OFFSET (board, elem), val) |
623 | 622 | ||
624 | #define sx_read_board_byte(board, elem) \ | 623 | #define sx_read_board_byte(board, elem) \ |
625 | read_sx_byte (board, BRD_OFFSET (board, elem)) | 624 | read_sx_byte (board, BRD_OFFSET (board, elem)) |
626 | 625 | ||
627 | #define sx_write_board_word(board, elem, val) \ | 626 | #define sx_write_board_word(board, elem, val) \ |
628 | write_sx_word (board, BRD_OFFSET (board, elem), val) | 627 | write_sx_word (board, BRD_OFFSET (board, elem), val) |
629 | 628 | ||
630 | #define sx_read_board_word(board, elem) \ | 629 | #define sx_read_board_word(board, elem) \ |
631 | read_sx_word (board, BRD_OFFSET (board, elem)) | 630 | read_sx_word (board, BRD_OFFSET (board, elem)) |
632 | 631 | ||
633 | static int sx_start_board(struct sx_board *board) | 632 | static int sx_start_board(struct sx_board *board) |
634 | { | 633 | { |
635 | if (IS_SX_BOARD(board)) { | 634 | if (IS_SX_BOARD(board)) { |
636 | write_sx_byte(board, SX_CONFIG, SX_CONF_BUSEN); | 635 | write_sx_byte(board, SX_CONFIG, SX_CONF_BUSEN); |
637 | } else if (IS_EISA_BOARD(board)) { | 636 | } else if (IS_EISA_BOARD(board)) { |
638 | write_sx_byte(board, SI2_EISA_OFF, SI2_EISA_VAL); | 637 | write_sx_byte(board, SI2_EISA_OFF, SI2_EISA_VAL); |
639 | outb((board->irq << 4) | 4, board->eisa_base + 0xc02); | 638 | outb((board->irq << 4) | 4, board->eisa_base + 0xc02); |
640 | } else if (IS_SI1_BOARD(board)) { | 639 | } else if (IS_SI1_BOARD(board)) { |
641 | write_sx_byte(board, SI1_ISA_RESET_CLEAR, 0); | 640 | write_sx_byte(board, SI1_ISA_RESET_CLEAR, 0); |
642 | write_sx_byte(board, SI1_ISA_INTCL, 0); | 641 | write_sx_byte(board, SI1_ISA_INTCL, 0); |
643 | } else { | 642 | } else { |
644 | /* Don't bug me about the clear_set. | 643 | /* Don't bug me about the clear_set. |
645 | I haven't the foggiest idea what it's about -- REW */ | 644 | I haven't the foggiest idea what it's about -- REW */ |
646 | write_sx_byte(board, SI2_ISA_RESET, SI2_ISA_RESET_CLEAR); | 645 | write_sx_byte(board, SI2_ISA_RESET, SI2_ISA_RESET_CLEAR); |
647 | write_sx_byte(board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_SET); | 646 | write_sx_byte(board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_SET); |
648 | } | 647 | } |
649 | return 1; | 648 | return 1; |
650 | } | 649 | } |
651 | 650 | ||
652 | #define SX_IRQ_REG_VAL(board) \ | 651 | #define SX_IRQ_REG_VAL(board) \ |
653 | ((board->flags & SX_ISA_BOARD) ? (board->irq << 4) : 0) | 652 | ((board->flags & SX_ISA_BOARD) ? (board->irq << 4) : 0) |
654 | 653 | ||
655 | /* Note. The SX register is write-only. Therefore, we have to enable the | 654 | /* Note. The SX register is write-only. Therefore, we have to enable the |
656 | bus too. This is a no-op, if you don't mess with this driver... */ | 655 | bus too. This is a no-op, if you don't mess with this driver... */ |
657 | static int sx_start_interrupts(struct sx_board *board) | 656 | static int sx_start_interrupts(struct sx_board *board) |
658 | { | 657 | { |
659 | 658 | ||
660 | /* Don't call this with board->irq == 0 */ | 659 | /* Don't call this with board->irq == 0 */ |
661 | 660 | ||
662 | if (IS_SX_BOARD(board)) { | 661 | if (IS_SX_BOARD(board)) { |
663 | write_sx_byte(board, SX_CONFIG, SX_IRQ_REG_VAL(board) | | 662 | write_sx_byte(board, SX_CONFIG, SX_IRQ_REG_VAL(board) | |
664 | SX_CONF_BUSEN | SX_CONF_HOSTIRQ); | 663 | SX_CONF_BUSEN | SX_CONF_HOSTIRQ); |
665 | } else if (IS_EISA_BOARD(board)) { | 664 | } else if (IS_EISA_BOARD(board)) { |
666 | inb(board->eisa_base + 0xc03); | 665 | inb(board->eisa_base + 0xc03); |
667 | } else if (IS_SI1_BOARD(board)) { | 666 | } else if (IS_SI1_BOARD(board)) { |
668 | write_sx_byte(board, SI1_ISA_INTCL, 0); | 667 | write_sx_byte(board, SI1_ISA_INTCL, 0); |
669 | write_sx_byte(board, SI1_ISA_INTCL_CLEAR, 0); | 668 | write_sx_byte(board, SI1_ISA_INTCL_CLEAR, 0); |
670 | } else { | 669 | } else { |
671 | switch (board->irq) { | 670 | switch (board->irq) { |
672 | case 11: | 671 | case 11: |
673 | write_sx_byte(board, SI2_ISA_IRQ11, SI2_ISA_IRQ11_SET); | 672 | write_sx_byte(board, SI2_ISA_IRQ11, SI2_ISA_IRQ11_SET); |
674 | break; | 673 | break; |
675 | case 12: | 674 | case 12: |
676 | write_sx_byte(board, SI2_ISA_IRQ12, SI2_ISA_IRQ12_SET); | 675 | write_sx_byte(board, SI2_ISA_IRQ12, SI2_ISA_IRQ12_SET); |
677 | break; | 676 | break; |
678 | case 15: | 677 | case 15: |
679 | write_sx_byte(board, SI2_ISA_IRQ15, SI2_ISA_IRQ15_SET); | 678 | write_sx_byte(board, SI2_ISA_IRQ15, SI2_ISA_IRQ15_SET); |
680 | break; | 679 | break; |
681 | default: | 680 | default: |
682 | printk(KERN_INFO "sx: SI/XIO card doesn't support " | 681 | printk(KERN_INFO "sx: SI/XIO card doesn't support " |
683 | "interrupt %d.\n", board->irq); | 682 | "interrupt %d.\n", board->irq); |
684 | return 0; | 683 | return 0; |
685 | } | 684 | } |
686 | write_sx_byte(board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_SET); | 685 | write_sx_byte(board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_SET); |
687 | } | 686 | } |
688 | 687 | ||
689 | return 1; | 688 | return 1; |
690 | } | 689 | } |
691 | 690 | ||
692 | static int sx_send_command(struct sx_port *port, | 691 | static int sx_send_command(struct sx_port *port, |
693 | int command, int mask, int newstat) | 692 | int command, int mask, int newstat) |
694 | { | 693 | { |
695 | func_enter2(); | 694 | func_enter2(); |
696 | write_sx_byte(port->board, CHAN_OFFSET(port, hi_hstat), command); | 695 | write_sx_byte(port->board, CHAN_OFFSET(port, hi_hstat), command); |
697 | func_exit(); | 696 | func_exit(); |
698 | return sx_busy_wait_eq(port->board, CHAN_OFFSET(port, hi_hstat), mask, | 697 | return sx_busy_wait_eq(port->board, CHAN_OFFSET(port, hi_hstat), mask, |
699 | newstat); | 698 | newstat); |
700 | } | 699 | } |
701 | 700 | ||
702 | static char *mod_type_s(int module_type) | 701 | static char *mod_type_s(int module_type) |
703 | { | 702 | { |
704 | switch (module_type) { | 703 | switch (module_type) { |
705 | case TA4: | 704 | case TA4: |
706 | return "TA4"; | 705 | return "TA4"; |
707 | case TA8: | 706 | case TA8: |
708 | return "TA8"; | 707 | return "TA8"; |
709 | case TA4_ASIC: | 708 | case TA4_ASIC: |
710 | return "TA4_ASIC"; | 709 | return "TA4_ASIC"; |
711 | case TA8_ASIC: | 710 | case TA8_ASIC: |
712 | return "TA8_ASIC"; | 711 | return "TA8_ASIC"; |
713 | case MTA_CD1400: | 712 | case MTA_CD1400: |
714 | return "MTA_CD1400"; | 713 | return "MTA_CD1400"; |
715 | case SXDC: | 714 | case SXDC: |
716 | return "SXDC"; | 715 | return "SXDC"; |
717 | default: | 716 | default: |
718 | return "Unknown/invalid"; | 717 | return "Unknown/invalid"; |
719 | } | 718 | } |
720 | } | 719 | } |
721 | 720 | ||
722 | static char *pan_type_s(int pan_type) | 721 | static char *pan_type_s(int pan_type) |
723 | { | 722 | { |
724 | switch (pan_type) { | 723 | switch (pan_type) { |
725 | case MOD_RS232DB25: | 724 | case MOD_RS232DB25: |
726 | return "MOD_RS232DB25"; | 725 | return "MOD_RS232DB25"; |
727 | case MOD_RS232RJ45: | 726 | case MOD_RS232RJ45: |
728 | return "MOD_RS232RJ45"; | 727 | return "MOD_RS232RJ45"; |
729 | case MOD_RS422DB25: | 728 | case MOD_RS422DB25: |
730 | return "MOD_RS422DB25"; | 729 | return "MOD_RS422DB25"; |
731 | case MOD_PARALLEL: | 730 | case MOD_PARALLEL: |
732 | return "MOD_PARALLEL"; | 731 | return "MOD_PARALLEL"; |
733 | case MOD_2_RS232DB25: | 732 | case MOD_2_RS232DB25: |
734 | return "MOD_2_RS232DB25"; | 733 | return "MOD_2_RS232DB25"; |
735 | case MOD_2_RS232RJ45: | 734 | case MOD_2_RS232RJ45: |
736 | return "MOD_2_RS232RJ45"; | 735 | return "MOD_2_RS232RJ45"; |
737 | case MOD_2_RS422DB25: | 736 | case MOD_2_RS422DB25: |
738 | return "MOD_2_RS422DB25"; | 737 | return "MOD_2_RS422DB25"; |
739 | case MOD_RS232DB25MALE: | 738 | case MOD_RS232DB25MALE: |
740 | return "MOD_RS232DB25MALE"; | 739 | return "MOD_RS232DB25MALE"; |
741 | case MOD_2_PARALLEL: | 740 | case MOD_2_PARALLEL: |
742 | return "MOD_2_PARALLEL"; | 741 | return "MOD_2_PARALLEL"; |
743 | case MOD_BLANK: | 742 | case MOD_BLANK: |
744 | return "empty"; | 743 | return "empty"; |
745 | default: | 744 | default: |
746 | return "invalid"; | 745 | return "invalid"; |
747 | } | 746 | } |
748 | } | 747 | } |
749 | 748 | ||
750 | static int mod_compat_type(int module_type) | 749 | static int mod_compat_type(int module_type) |
751 | { | 750 | { |
752 | return module_type >> 4; | 751 | return module_type >> 4; |
753 | } | 752 | } |
754 | 753 | ||
755 | static void sx_reconfigure_port(struct sx_port *port) | 754 | static void sx_reconfigure_port(struct sx_port *port) |
756 | { | 755 | { |
757 | if (sx_read_channel_byte(port, hi_hstat) == HS_IDLE_OPEN) { | 756 | if (sx_read_channel_byte(port, hi_hstat) == HS_IDLE_OPEN) { |
758 | if (sx_send_command(port, HS_CONFIG, -1, HS_IDLE_OPEN) != 1) { | 757 | if (sx_send_command(port, HS_CONFIG, -1, HS_IDLE_OPEN) != 1) { |
759 | printk(KERN_WARNING "sx: Sent reconfigure command, but " | 758 | printk(KERN_WARNING "sx: Sent reconfigure command, but " |
760 | "card didn't react.\n"); | 759 | "card didn't react.\n"); |
761 | } | 760 | } |
762 | } else { | 761 | } else { |
763 | sx_dprintk(SX_DEBUG_TERMIOS, "sx: Not sending reconfigure: " | 762 | sx_dprintk(SX_DEBUG_TERMIOS, "sx: Not sending reconfigure: " |
764 | "port isn't open (%02x).\n", | 763 | "port isn't open (%02x).\n", |
765 | sx_read_channel_byte(port, hi_hstat)); | 764 | sx_read_channel_byte(port, hi_hstat)); |
766 | } | 765 | } |
767 | } | 766 | } |
768 | 767 | ||
769 | static void sx_setsignals(struct sx_port *port, int dtr, int rts) | 768 | static void sx_setsignals(struct sx_port *port, int dtr, int rts) |
770 | { | 769 | { |
771 | int t; | 770 | int t; |
772 | func_enter2(); | 771 | func_enter2(); |
773 | 772 | ||
774 | t = sx_read_channel_byte(port, hi_op); | 773 | t = sx_read_channel_byte(port, hi_op); |
775 | if (dtr >= 0) | 774 | if (dtr >= 0) |
776 | t = dtr ? (t | OP_DTR) : (t & ~OP_DTR); | 775 | t = dtr ? (t | OP_DTR) : (t & ~OP_DTR); |
777 | if (rts >= 0) | 776 | if (rts >= 0) |
778 | t = rts ? (t | OP_RTS) : (t & ~OP_RTS); | 777 | t = rts ? (t | OP_RTS) : (t & ~OP_RTS); |
779 | sx_write_channel_byte(port, hi_op, t); | 778 | sx_write_channel_byte(port, hi_op, t); |
780 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "setsignals: %d/%d\n", dtr, rts); | 779 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "setsignals: %d/%d\n", dtr, rts); |
781 | 780 | ||
782 | func_exit(); | 781 | func_exit(); |
783 | } | 782 | } |
784 | 783 | ||
785 | static int sx_getsignals(struct sx_port *port) | 784 | static int sx_getsignals(struct sx_port *port) |
786 | { | 785 | { |
787 | int i_stat, o_stat; | 786 | int i_stat, o_stat; |
788 | 787 | ||
789 | o_stat = sx_read_channel_byte(port, hi_op); | 788 | o_stat = sx_read_channel_byte(port, hi_op); |
790 | i_stat = sx_read_channel_byte(port, hi_ip); | 789 | i_stat = sx_read_channel_byte(port, hi_ip); |
791 | 790 | ||
792 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "getsignals: %d/%d (%d/%d) " | 791 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "getsignals: %d/%d (%d/%d) " |
793 | "%02x/%02x\n", | 792 | "%02x/%02x\n", |
794 | (o_stat & OP_DTR) != 0, (o_stat & OP_RTS) != 0, | 793 | (o_stat & OP_DTR) != 0, (o_stat & OP_RTS) != 0, |
795 | port->c_dcd, sx_get_CD(port), | 794 | port->c_dcd, sx_get_CD(port), |
796 | sx_read_channel_byte(port, hi_ip), | 795 | sx_read_channel_byte(port, hi_ip), |
797 | sx_read_channel_byte(port, hi_state)); | 796 | sx_read_channel_byte(port, hi_state)); |
798 | 797 | ||
799 | return (((o_stat & OP_DTR) ? TIOCM_DTR : 0) | | 798 | return (((o_stat & OP_DTR) ? TIOCM_DTR : 0) | |
800 | ((o_stat & OP_RTS) ? TIOCM_RTS : 0) | | 799 | ((o_stat & OP_RTS) ? TIOCM_RTS : 0) | |
801 | ((i_stat & IP_CTS) ? TIOCM_CTS : 0) | | 800 | ((i_stat & IP_CTS) ? TIOCM_CTS : 0) | |
802 | ((i_stat & IP_DCD) ? TIOCM_CAR : 0) | | 801 | ((i_stat & IP_DCD) ? TIOCM_CAR : 0) | |
803 | ((i_stat & IP_DSR) ? TIOCM_DSR : 0) | | 802 | ((i_stat & IP_DSR) ? TIOCM_DSR : 0) | |
804 | ((i_stat & IP_RI) ? TIOCM_RNG : 0)); | 803 | ((i_stat & IP_RI) ? TIOCM_RNG : 0)); |
805 | } | 804 | } |
806 | 805 | ||
807 | static void sx_set_baud(struct sx_port *port) | 806 | static void sx_set_baud(struct sx_port *port) |
808 | { | 807 | { |
809 | int t; | 808 | int t; |
810 | 809 | ||
811 | if (port->board->ta_type == MOD_SXDC) { | 810 | if (port->board->ta_type == MOD_SXDC) { |
812 | switch (port->gs.baud) { | 811 | switch (port->gs.baud) { |
813 | /* Save some typing work... */ | 812 | /* Save some typing work... */ |
814 | #define e(x) case x: t = BAUD_ ## x; break | 813 | #define e(x) case x: t = BAUD_ ## x; break |
815 | e(50); | 814 | e(50); |
816 | e(75); | 815 | e(75); |
817 | e(110); | 816 | e(110); |
818 | e(150); | 817 | e(150); |
819 | e(200); | 818 | e(200); |
820 | e(300); | 819 | e(300); |
821 | e(600); | 820 | e(600); |
822 | e(1200); | 821 | e(1200); |
823 | e(1800); | 822 | e(1800); |
824 | e(2000); | 823 | e(2000); |
825 | e(2400); | 824 | e(2400); |
826 | e(4800); | 825 | e(4800); |
827 | e(7200); | 826 | e(7200); |
828 | e(9600); | 827 | e(9600); |
829 | e(14400); | 828 | e(14400); |
830 | e(19200); | 829 | e(19200); |
831 | e(28800); | 830 | e(28800); |
832 | e(38400); | 831 | e(38400); |
833 | e(56000); | 832 | e(56000); |
834 | e(57600); | 833 | e(57600); |
835 | e(64000); | 834 | e(64000); |
836 | e(76800); | 835 | e(76800); |
837 | e(115200); | 836 | e(115200); |
838 | e(128000); | 837 | e(128000); |
839 | e(150000); | 838 | e(150000); |
840 | e(230400); | 839 | e(230400); |
841 | e(256000); | 840 | e(256000); |
842 | e(460800); | 841 | e(460800); |
843 | e(921600); | 842 | e(921600); |
844 | case 134: | 843 | case 134: |
845 | t = BAUD_134_5; | 844 | t = BAUD_134_5; |
846 | break; | 845 | break; |
847 | case 0: | 846 | case 0: |
848 | t = -1; | 847 | t = -1; |
849 | break; | 848 | break; |
850 | default: | 849 | default: |
851 | /* Can I return "invalid"? */ | 850 | /* Can I return "invalid"? */ |
852 | t = BAUD_9600; | 851 | t = BAUD_9600; |
853 | printk(KERN_INFO "sx: unsupported baud rate: %d.\n", | 852 | printk(KERN_INFO "sx: unsupported baud rate: %d.\n", |
854 | port->gs.baud); | 853 | port->gs.baud); |
855 | break; | 854 | break; |
856 | } | 855 | } |
857 | #undef e | 856 | #undef e |
858 | if (t > 0) { | 857 | if (t > 0) { |
859 | /* The baud rate is not set to 0, so we're enabeling DTR... -- REW */ | 858 | /* The baud rate is not set to 0, so we're enabeling DTR... -- REW */ |
860 | sx_setsignals(port, 1, -1); | 859 | sx_setsignals(port, 1, -1); |
861 | /* XXX This is not TA & MTA compatible */ | 860 | /* XXX This is not TA & MTA compatible */ |
862 | sx_write_channel_byte(port, hi_csr, 0xff); | 861 | sx_write_channel_byte(port, hi_csr, 0xff); |
863 | 862 | ||
864 | sx_write_channel_byte(port, hi_txbaud, t); | 863 | sx_write_channel_byte(port, hi_txbaud, t); |
865 | sx_write_channel_byte(port, hi_rxbaud, t); | 864 | sx_write_channel_byte(port, hi_rxbaud, t); |
866 | } else { | 865 | } else { |
867 | sx_setsignals(port, 0, -1); | 866 | sx_setsignals(port, 0, -1); |
868 | } | 867 | } |
869 | } else { | 868 | } else { |
870 | switch (port->gs.baud) { | 869 | switch (port->gs.baud) { |
871 | #define e(x) case x: t = CSR_ ## x; break | 870 | #define e(x) case x: t = CSR_ ## x; break |
872 | e(75); | 871 | e(75); |
873 | e(150); | 872 | e(150); |
874 | e(300); | 873 | e(300); |
875 | e(600); | 874 | e(600); |
876 | e(1200); | 875 | e(1200); |
877 | e(2400); | 876 | e(2400); |
878 | e(4800); | 877 | e(4800); |
879 | e(1800); | 878 | e(1800); |
880 | e(9600); | 879 | e(9600); |
881 | e(19200); | 880 | e(19200); |
882 | e(57600); | 881 | e(57600); |
883 | e(38400); | 882 | e(38400); |
884 | /* TA supports 110, but not 115200, MTA supports 115200, but not 110 */ | 883 | /* TA supports 110, but not 115200, MTA supports 115200, but not 110 */ |
885 | case 110: | 884 | case 110: |
886 | if (port->board->ta_type == MOD_TA) { | 885 | if (port->board->ta_type == MOD_TA) { |
887 | t = CSR_110; | 886 | t = CSR_110; |
888 | break; | 887 | break; |
889 | } else { | 888 | } else { |
890 | t = CSR_9600; | 889 | t = CSR_9600; |
891 | printk(KERN_INFO "sx: Unsupported baud rate: " | 890 | printk(KERN_INFO "sx: Unsupported baud rate: " |
892 | "%d.\n", port->gs.baud); | 891 | "%d.\n", port->gs.baud); |
893 | break; | 892 | break; |
894 | } | 893 | } |
895 | case 115200: | 894 | case 115200: |
896 | if (port->board->ta_type == MOD_TA) { | 895 | if (port->board->ta_type == MOD_TA) { |
897 | t = CSR_9600; | 896 | t = CSR_9600; |
898 | printk(KERN_INFO "sx: Unsupported baud rate: " | 897 | printk(KERN_INFO "sx: Unsupported baud rate: " |
899 | "%d.\n", port->gs.baud); | 898 | "%d.\n", port->gs.baud); |
900 | break; | 899 | break; |
901 | } else { | 900 | } else { |
902 | t = CSR_110; | 901 | t = CSR_110; |
903 | break; | 902 | break; |
904 | } | 903 | } |
905 | case 0: | 904 | case 0: |
906 | t = -1; | 905 | t = -1; |
907 | break; | 906 | break; |
908 | default: | 907 | default: |
909 | t = CSR_9600; | 908 | t = CSR_9600; |
910 | printk(KERN_INFO "sx: Unsupported baud rate: %d.\n", | 909 | printk(KERN_INFO "sx: Unsupported baud rate: %d.\n", |
911 | port->gs.baud); | 910 | port->gs.baud); |
912 | break; | 911 | break; |
913 | } | 912 | } |
914 | #undef e | 913 | #undef e |
915 | if (t >= 0) { | 914 | if (t >= 0) { |
916 | sx_setsignals(port, 1, -1); | 915 | sx_setsignals(port, 1, -1); |
917 | sx_write_channel_byte(port, hi_csr, t * 0x11); | 916 | sx_write_channel_byte(port, hi_csr, t * 0x11); |
918 | } else { | 917 | } else { |
919 | sx_setsignals(port, 0, -1); | 918 | sx_setsignals(port, 0, -1); |
920 | } | 919 | } |
921 | } | 920 | } |
922 | } | 921 | } |
923 | 922 | ||
924 | /* Simon Allen's version of this routine was 225 lines long. 85 is a lot | 923 | /* Simon Allen's version of this routine was 225 lines long. 85 is a lot |
925 | better. -- REW */ | 924 | better. -- REW */ |
926 | 925 | ||
927 | static int sx_set_real_termios(void *ptr) | 926 | static int sx_set_real_termios(void *ptr) |
928 | { | 927 | { |
929 | struct sx_port *port = ptr; | 928 | struct sx_port *port = ptr; |
930 | 929 | ||
931 | func_enter2(); | 930 | func_enter2(); |
932 | 931 | ||
933 | if (!port->gs.tty) | 932 | if (!port->gs.port.tty) |
934 | return 0; | 933 | return 0; |
935 | 934 | ||
936 | /* What is this doing here? -- REW | 935 | /* What is this doing here? -- REW |
937 | Ha! figured it out. It is to allow you to get DTR active again | 936 | Ha! figured it out. It is to allow you to get DTR active again |
938 | if you've dropped it with stty 0. Moved to set_baud, where it | 937 | if you've dropped it with stty 0. Moved to set_baud, where it |
939 | belongs (next to the drop dtr if baud == 0) -- REW */ | 938 | belongs (next to the drop dtr if baud == 0) -- REW */ |
940 | /* sx_setsignals (port, 1, -1); */ | 939 | /* sx_setsignals (port, 1, -1); */ |
941 | 940 | ||
942 | sx_set_baud(port); | 941 | sx_set_baud(port); |
943 | 942 | ||
944 | #define CFLAG port->gs.tty->termios->c_cflag | 943 | #define CFLAG port->gs.port.tty->termios->c_cflag |
945 | sx_write_channel_byte(port, hi_mr1, | 944 | sx_write_channel_byte(port, hi_mr1, |
946 | (C_PARENB(port->gs.tty) ? MR1_WITH : MR1_NONE) | | 945 | (C_PARENB(port->gs.port.tty) ? MR1_WITH : MR1_NONE) | |
947 | (C_PARODD(port->gs.tty) ? MR1_ODD : MR1_EVEN) | | 946 | (C_PARODD(port->gs.port.tty) ? MR1_ODD : MR1_EVEN) | |
948 | (C_CRTSCTS(port->gs.tty) ? MR1_RTS_RXFLOW : 0) | | 947 | (C_CRTSCTS(port->gs.port.tty) ? MR1_RTS_RXFLOW : 0) | |
949 | (((CFLAG & CSIZE) == CS8) ? MR1_8_BITS : 0) | | 948 | (((CFLAG & CSIZE) == CS8) ? MR1_8_BITS : 0) | |
950 | (((CFLAG & CSIZE) == CS7) ? MR1_7_BITS : 0) | | 949 | (((CFLAG & CSIZE) == CS7) ? MR1_7_BITS : 0) | |
951 | (((CFLAG & CSIZE) == CS6) ? MR1_6_BITS : 0) | | 950 | (((CFLAG & CSIZE) == CS6) ? MR1_6_BITS : 0) | |
952 | (((CFLAG & CSIZE) == CS5) ? MR1_5_BITS : 0)); | 951 | (((CFLAG & CSIZE) == CS5) ? MR1_5_BITS : 0)); |
953 | 952 | ||
954 | sx_write_channel_byte(port, hi_mr2, | 953 | sx_write_channel_byte(port, hi_mr2, |
955 | (C_CRTSCTS(port->gs.tty) ? MR2_CTS_TXFLOW : 0) | | 954 | (C_CRTSCTS(port->gs.port.tty) ? MR2_CTS_TXFLOW : 0) | |
956 | (C_CSTOPB(port->gs.tty) ? MR2_2_STOP : | 955 | (C_CSTOPB(port->gs.port.tty) ? MR2_2_STOP : |
957 | MR2_1_STOP)); | 956 | MR2_1_STOP)); |
958 | 957 | ||
959 | switch (CFLAG & CSIZE) { | 958 | switch (CFLAG & CSIZE) { |
960 | case CS8: | 959 | case CS8: |
961 | sx_write_channel_byte(port, hi_mask, 0xff); | 960 | sx_write_channel_byte(port, hi_mask, 0xff); |
962 | break; | 961 | break; |
963 | case CS7: | 962 | case CS7: |
964 | sx_write_channel_byte(port, hi_mask, 0x7f); | 963 | sx_write_channel_byte(port, hi_mask, 0x7f); |
965 | break; | 964 | break; |
966 | case CS6: | 965 | case CS6: |
967 | sx_write_channel_byte(port, hi_mask, 0x3f); | 966 | sx_write_channel_byte(port, hi_mask, 0x3f); |
968 | break; | 967 | break; |
969 | case CS5: | 968 | case CS5: |
970 | sx_write_channel_byte(port, hi_mask, 0x1f); | 969 | sx_write_channel_byte(port, hi_mask, 0x1f); |
971 | break; | 970 | break; |
972 | default: | 971 | default: |
973 | printk(KERN_INFO "sx: Invalid wordsize: %u\n", | 972 | printk(KERN_INFO "sx: Invalid wordsize: %u\n", |
974 | (unsigned int)CFLAG & CSIZE); | 973 | (unsigned int)CFLAG & CSIZE); |
975 | break; | 974 | break; |
976 | } | 975 | } |
977 | 976 | ||
978 | sx_write_channel_byte(port, hi_prtcl, | 977 | sx_write_channel_byte(port, hi_prtcl, |
979 | (I_IXON(port->gs.tty) ? SP_TXEN : 0) | | 978 | (I_IXON(port->gs.port.tty) ? SP_TXEN : 0) | |
980 | (I_IXOFF(port->gs.tty) ? SP_RXEN : 0) | | 979 | (I_IXOFF(port->gs.port.tty) ? SP_RXEN : 0) | |
981 | (I_IXANY(port->gs.tty) ? SP_TANY : 0) | SP_DCEN); | 980 | (I_IXANY(port->gs.port.tty) ? SP_TANY : 0) | SP_DCEN); |
982 | 981 | ||
983 | sx_write_channel_byte(port, hi_break, | 982 | sx_write_channel_byte(port, hi_break, |
984 | (I_IGNBRK(port->gs.tty) ? BR_IGN : 0 | | 983 | (I_IGNBRK(port->gs.port.tty) ? BR_IGN : 0 | |
985 | I_BRKINT(port->gs.tty) ? BR_INT : 0)); | 984 | I_BRKINT(port->gs.port.tty) ? BR_INT : 0)); |
986 | 985 | ||
987 | sx_write_channel_byte(port, hi_txon, START_CHAR(port->gs.tty)); | 986 | sx_write_channel_byte(port, hi_txon, START_CHAR(port->gs.port.tty)); |
988 | sx_write_channel_byte(port, hi_rxon, START_CHAR(port->gs.tty)); | 987 | sx_write_channel_byte(port, hi_rxon, START_CHAR(port->gs.port.tty)); |
989 | sx_write_channel_byte(port, hi_txoff, STOP_CHAR(port->gs.tty)); | 988 | sx_write_channel_byte(port, hi_txoff, STOP_CHAR(port->gs.port.tty)); |
990 | sx_write_channel_byte(port, hi_rxoff, STOP_CHAR(port->gs.tty)); | 989 | sx_write_channel_byte(port, hi_rxoff, STOP_CHAR(port->gs.port.tty)); |
991 | 990 | ||
992 | sx_reconfigure_port(port); | 991 | sx_reconfigure_port(port); |
993 | 992 | ||
994 | /* Tell line discipline whether we will do input cooking */ | 993 | /* Tell line discipline whether we will do input cooking */ |
995 | if (I_OTHER(port->gs.tty)) { | 994 | if (I_OTHER(port->gs.port.tty)) { |
996 | clear_bit(TTY_HW_COOK_IN, &port->gs.tty->flags); | 995 | clear_bit(TTY_HW_COOK_IN, &port->gs.port.tty->flags); |
997 | } else { | 996 | } else { |
998 | set_bit(TTY_HW_COOK_IN, &port->gs.tty->flags); | 997 | set_bit(TTY_HW_COOK_IN, &port->gs.port.tty->flags); |
999 | } | 998 | } |
1000 | sx_dprintk(SX_DEBUG_TERMIOS, "iflags: %x(%d) ", | 999 | sx_dprintk(SX_DEBUG_TERMIOS, "iflags: %x(%d) ", |
1001 | (unsigned int)port->gs.tty->termios->c_iflag, | 1000 | (unsigned int)port->gs.port.tty->termios->c_iflag, |
1002 | I_OTHER(port->gs.tty)); | 1001 | I_OTHER(port->gs.port.tty)); |
1003 | 1002 | ||
1004 | /* Tell line discipline whether we will do output cooking. | 1003 | /* Tell line discipline whether we will do output cooking. |
1005 | * If OPOST is set and no other output flags are set then we can do output | 1004 | * If OPOST is set and no other output flags are set then we can do output |
1006 | * processing. Even if only *one* other flag in the O_OTHER group is set | 1005 | * processing. Even if only *one* other flag in the O_OTHER group is set |
1007 | * we do cooking in software. | 1006 | * we do cooking in software. |
1008 | */ | 1007 | */ |
1009 | if (O_OPOST(port->gs.tty) && !O_OTHER(port->gs.tty)) { | 1008 | if (O_OPOST(port->gs.port.tty) && !O_OTHER(port->gs.port.tty)) { |
1010 | set_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags); | 1009 | set_bit(TTY_HW_COOK_OUT, &port->gs.port.tty->flags); |
1011 | } else { | 1010 | } else { |
1012 | clear_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags); | 1011 | clear_bit(TTY_HW_COOK_OUT, &port->gs.port.tty->flags); |
1013 | } | 1012 | } |
1014 | sx_dprintk(SX_DEBUG_TERMIOS, "oflags: %x(%d)\n", | 1013 | sx_dprintk(SX_DEBUG_TERMIOS, "oflags: %x(%d)\n", |
1015 | (unsigned int)port->gs.tty->termios->c_oflag, | 1014 | (unsigned int)port->gs.port.tty->termios->c_oflag, |
1016 | O_OTHER(port->gs.tty)); | 1015 | O_OTHER(port->gs.port.tty)); |
1017 | /* port->c_dcd = sx_get_CD (port); */ | 1016 | /* port->c_dcd = sx_get_CD (port); */ |
1018 | func_exit(); | 1017 | func_exit(); |
1019 | return 0; | 1018 | return 0; |
1020 | } | 1019 | } |
1021 | 1020 | ||
1022 | /* ********************************************************************** * | 1021 | /* ********************************************************************** * |
1023 | * the interrupt related routines * | 1022 | * the interrupt related routines * |
1024 | * ********************************************************************** */ | 1023 | * ********************************************************************** */ |
1025 | 1024 | ||
1026 | /* Note: | 1025 | /* Note: |
1027 | Other drivers use the macro "MIN" to calculate how much to copy. | 1026 | Other drivers use the macro "MIN" to calculate how much to copy. |
1028 | This has the disadvantage that it will evaluate parts twice. That's | 1027 | This has the disadvantage that it will evaluate parts twice. That's |
1029 | expensive when it's IO (and the compiler cannot optimize those away!). | 1028 | expensive when it's IO (and the compiler cannot optimize those away!). |
1030 | Moreover, I'm not sure that you're race-free. | 1029 | Moreover, I'm not sure that you're race-free. |
1031 | 1030 | ||
1032 | I assign a value, and then only allow the value to decrease. This | 1031 | I assign a value, and then only allow the value to decrease. This |
1033 | is always safe. This makes the code a few lines longer, and you | 1032 | is always safe. This makes the code a few lines longer, and you |
1034 | know I'm dead against that, but I think it is required in this | 1033 | know I'm dead against that, but I think it is required in this |
1035 | case. */ | 1034 | case. */ |
1036 | 1035 | ||
1037 | static void sx_transmit_chars(struct sx_port *port) | 1036 | static void sx_transmit_chars(struct sx_port *port) |
1038 | { | 1037 | { |
1039 | int c; | 1038 | int c; |
1040 | int tx_ip; | 1039 | int tx_ip; |
1041 | int txroom; | 1040 | int txroom; |
1042 | 1041 | ||
1043 | func_enter2(); | 1042 | func_enter2(); |
1044 | sx_dprintk(SX_DEBUG_TRANSMIT, "Port %p: transmit %d chars\n", | 1043 | sx_dprintk(SX_DEBUG_TRANSMIT, "Port %p: transmit %d chars\n", |
1045 | port, port->gs.xmit_cnt); | 1044 | port, port->gs.xmit_cnt); |
1046 | 1045 | ||
1047 | if (test_and_set_bit(SX_PORT_TRANSMIT_LOCK, &port->locks)) { | 1046 | if (test_and_set_bit(SX_PORT_TRANSMIT_LOCK, &port->locks)) { |
1048 | return; | 1047 | return; |
1049 | } | 1048 | } |
1050 | 1049 | ||
1051 | while (1) { | 1050 | while (1) { |
1052 | c = port->gs.xmit_cnt; | 1051 | c = port->gs.xmit_cnt; |
1053 | 1052 | ||
1054 | sx_dprintk(SX_DEBUG_TRANSMIT, "Copying %d ", c); | 1053 | sx_dprintk(SX_DEBUG_TRANSMIT, "Copying %d ", c); |
1055 | tx_ip = sx_read_channel_byte(port, hi_txipos); | 1054 | tx_ip = sx_read_channel_byte(port, hi_txipos); |
1056 | 1055 | ||
1057 | /* Took me 5 minutes to deduce this formula. | 1056 | /* Took me 5 minutes to deduce this formula. |
1058 | Luckily it is literally in the manual in section 6.5.4.3.5 */ | 1057 | Luckily it is literally in the manual in section 6.5.4.3.5 */ |
1059 | txroom = (sx_read_channel_byte(port, hi_txopos) - tx_ip - 1) & | 1058 | txroom = (sx_read_channel_byte(port, hi_txopos) - tx_ip - 1) & |
1060 | 0xff; | 1059 | 0xff; |
1061 | 1060 | ||
1062 | /* Don't copy more bytes than there is room for in the buffer */ | 1061 | /* Don't copy more bytes than there is room for in the buffer */ |
1063 | if (c > txroom) | 1062 | if (c > txroom) |
1064 | c = txroom; | 1063 | c = txroom; |
1065 | sx_dprintk(SX_DEBUG_TRANSMIT, " %d(%d) ", c, txroom); | 1064 | sx_dprintk(SX_DEBUG_TRANSMIT, " %d(%d) ", c, txroom); |
1066 | 1065 | ||
1067 | /* Don't copy past the end of the hardware transmit buffer */ | 1066 | /* Don't copy past the end of the hardware transmit buffer */ |
1068 | if (c > 0x100 - tx_ip) | 1067 | if (c > 0x100 - tx_ip) |
1069 | c = 0x100 - tx_ip; | 1068 | c = 0x100 - tx_ip; |
1070 | 1069 | ||
1071 | sx_dprintk(SX_DEBUG_TRANSMIT, " %d(%d) ", c, 0x100 - tx_ip); | 1070 | sx_dprintk(SX_DEBUG_TRANSMIT, " %d(%d) ", c, 0x100 - tx_ip); |
1072 | 1071 | ||
1073 | /* Don't copy pas the end of the source buffer */ | 1072 | /* Don't copy pas the end of the source buffer */ |
1074 | if (c > SERIAL_XMIT_SIZE - port->gs.xmit_tail) | 1073 | if (c > SERIAL_XMIT_SIZE - port->gs.xmit_tail) |
1075 | c = SERIAL_XMIT_SIZE - port->gs.xmit_tail; | 1074 | c = SERIAL_XMIT_SIZE - port->gs.xmit_tail; |
1076 | 1075 | ||
1077 | sx_dprintk(SX_DEBUG_TRANSMIT, " %d(%ld) \n", | 1076 | sx_dprintk(SX_DEBUG_TRANSMIT, " %d(%ld) \n", |
1078 | c, SERIAL_XMIT_SIZE - port->gs.xmit_tail); | 1077 | c, SERIAL_XMIT_SIZE - port->gs.xmit_tail); |
1079 | 1078 | ||
1080 | /* If for one reason or another, we can't copy more data, we're | 1079 | /* If for one reason or another, we can't copy more data, we're |
1081 | done! */ | 1080 | done! */ |
1082 | if (c == 0) | 1081 | if (c == 0) |
1083 | break; | 1082 | break; |
1084 | 1083 | ||
1085 | memcpy_toio(port->board->base + CHAN_OFFSET(port, hi_txbuf) + | 1084 | memcpy_toio(port->board->base + CHAN_OFFSET(port, hi_txbuf) + |
1086 | tx_ip, port->gs.xmit_buf + port->gs.xmit_tail, c); | 1085 | tx_ip, port->gs.xmit_buf + port->gs.xmit_tail, c); |
1087 | 1086 | ||
1088 | /* Update the pointer in the card */ | 1087 | /* Update the pointer in the card */ |
1089 | sx_write_channel_byte(port, hi_txipos, (tx_ip + c) & 0xff); | 1088 | sx_write_channel_byte(port, hi_txipos, (tx_ip + c) & 0xff); |
1090 | 1089 | ||
1091 | /* Update the kernel buffer end */ | 1090 | /* Update the kernel buffer end */ |
1092 | port->gs.xmit_tail = (port->gs.xmit_tail + c) & | 1091 | port->gs.xmit_tail = (port->gs.xmit_tail + c) & |
1093 | (SERIAL_XMIT_SIZE - 1); | 1092 | (SERIAL_XMIT_SIZE - 1); |
1094 | 1093 | ||
1095 | /* This one last. (this is essential) | 1094 | /* This one last. (this is essential) |
1096 | It would allow others to start putting more data into the | 1095 | It would allow others to start putting more data into the |
1097 | buffer! */ | 1096 | buffer! */ |
1098 | port->gs.xmit_cnt -= c; | 1097 | port->gs.xmit_cnt -= c; |
1099 | } | 1098 | } |
1100 | 1099 | ||
1101 | if (port->gs.xmit_cnt == 0) { | 1100 | if (port->gs.xmit_cnt == 0) { |
1102 | sx_disable_tx_interrupts(port); | 1101 | sx_disable_tx_interrupts(port); |
1103 | } | 1102 | } |
1104 | 1103 | ||
1105 | if ((port->gs.xmit_cnt <= port->gs.wakeup_chars) && port->gs.tty) { | 1104 | if ((port->gs.xmit_cnt <= port->gs.wakeup_chars) && port->gs.port.tty) { |
1106 | tty_wakeup(port->gs.tty); | 1105 | tty_wakeup(port->gs.port.tty); |
1107 | sx_dprintk(SX_DEBUG_TRANSMIT, "Waking up.... ldisc (%d)....\n", | 1106 | sx_dprintk(SX_DEBUG_TRANSMIT, "Waking up.... ldisc (%d)....\n", |
1108 | port->gs.wakeup_chars); | 1107 | port->gs.wakeup_chars); |
1109 | } | 1108 | } |
1110 | 1109 | ||
1111 | clear_bit(SX_PORT_TRANSMIT_LOCK, &port->locks); | 1110 | clear_bit(SX_PORT_TRANSMIT_LOCK, &port->locks); |
1112 | func_exit(); | 1111 | func_exit(); |
1113 | } | 1112 | } |
1114 | 1113 | ||
1115 | /* Note the symmetry between receiving chars and transmitting them! | 1114 | /* Note the symmetry between receiving chars and transmitting them! |
1116 | Note: The kernel should have implemented both a receive buffer and | 1115 | Note: The kernel should have implemented both a receive buffer and |
1117 | a transmit buffer. */ | 1116 | a transmit buffer. */ |
1118 | 1117 | ||
1119 | /* Inlined: Called only once. Remove the inline when you add another call */ | 1118 | /* Inlined: Called only once. Remove the inline when you add another call */ |
1120 | static inline void sx_receive_chars(struct sx_port *port) | 1119 | static inline void sx_receive_chars(struct sx_port *port) |
1121 | { | 1120 | { |
1122 | int c; | 1121 | int c; |
1123 | int rx_op; | 1122 | int rx_op; |
1124 | struct tty_struct *tty; | 1123 | struct tty_struct *tty; |
1125 | int copied = 0; | 1124 | int copied = 0; |
1126 | unsigned char *rp; | 1125 | unsigned char *rp; |
1127 | 1126 | ||
1128 | func_enter2(); | 1127 | func_enter2(); |
1129 | tty = port->gs.tty; | 1128 | tty = port->gs.port.tty; |
1130 | while (1) { | 1129 | while (1) { |
1131 | rx_op = sx_read_channel_byte(port, hi_rxopos); | 1130 | rx_op = sx_read_channel_byte(port, hi_rxopos); |
1132 | c = (sx_read_channel_byte(port, hi_rxipos) - rx_op) & 0xff; | 1131 | c = (sx_read_channel_byte(port, hi_rxipos) - rx_op) & 0xff; |
1133 | 1132 | ||
1134 | sx_dprintk(SX_DEBUG_RECEIVE, "rxop=%d, c = %d.\n", rx_op, c); | 1133 | sx_dprintk(SX_DEBUG_RECEIVE, "rxop=%d, c = %d.\n", rx_op, c); |
1135 | 1134 | ||
1136 | /* Don't copy past the end of the hardware receive buffer */ | 1135 | /* Don't copy past the end of the hardware receive buffer */ |
1137 | if (rx_op + c > 0x100) | 1136 | if (rx_op + c > 0x100) |
1138 | c = 0x100 - rx_op; | 1137 | c = 0x100 - rx_op; |
1139 | 1138 | ||
1140 | sx_dprintk(SX_DEBUG_RECEIVE, "c = %d.\n", c); | 1139 | sx_dprintk(SX_DEBUG_RECEIVE, "c = %d.\n", c); |
1141 | 1140 | ||
1142 | /* Don't copy more bytes than there is room for in the buffer */ | 1141 | /* Don't copy more bytes than there is room for in the buffer */ |
1143 | 1142 | ||
1144 | c = tty_prepare_flip_string(tty, &rp, c); | 1143 | c = tty_prepare_flip_string(tty, &rp, c); |
1145 | 1144 | ||
1146 | sx_dprintk(SX_DEBUG_RECEIVE, "c = %d.\n", c); | 1145 | sx_dprintk(SX_DEBUG_RECEIVE, "c = %d.\n", c); |
1147 | 1146 | ||
1148 | /* If for one reason or another, we can't copy more data, we're done! */ | 1147 | /* If for one reason or another, we can't copy more data, we're done! */ |
1149 | if (c == 0) | 1148 | if (c == 0) |
1150 | break; | 1149 | break; |
1151 | 1150 | ||
1152 | sx_dprintk(SX_DEBUG_RECEIVE, "Copying over %d chars. First is " | 1151 | sx_dprintk(SX_DEBUG_RECEIVE, "Copying over %d chars. First is " |
1153 | "%d at %lx\n", c, read_sx_byte(port->board, | 1152 | "%d at %lx\n", c, read_sx_byte(port->board, |
1154 | CHAN_OFFSET(port, hi_rxbuf) + rx_op), | 1153 | CHAN_OFFSET(port, hi_rxbuf) + rx_op), |
1155 | CHAN_OFFSET(port, hi_rxbuf)); | 1154 | CHAN_OFFSET(port, hi_rxbuf)); |
1156 | memcpy_fromio(rp, port->board->base + | 1155 | memcpy_fromio(rp, port->board->base + |
1157 | CHAN_OFFSET(port, hi_rxbuf) + rx_op, c); | 1156 | CHAN_OFFSET(port, hi_rxbuf) + rx_op, c); |
1158 | 1157 | ||
1159 | /* This one last. ( Not essential.) | 1158 | /* This one last. ( Not essential.) |
1160 | It allows the card to start putting more data into the | 1159 | It allows the card to start putting more data into the |
1161 | buffer! | 1160 | buffer! |
1162 | Update the pointer in the card */ | 1161 | Update the pointer in the card */ |
1163 | sx_write_channel_byte(port, hi_rxopos, (rx_op + c) & 0xff); | 1162 | sx_write_channel_byte(port, hi_rxopos, (rx_op + c) & 0xff); |
1164 | 1163 | ||
1165 | copied += c; | 1164 | copied += c; |
1166 | } | 1165 | } |
1167 | if (copied) { | 1166 | if (copied) { |
1168 | struct timeval tv; | 1167 | struct timeval tv; |
1169 | 1168 | ||
1170 | do_gettimeofday(&tv); | 1169 | do_gettimeofday(&tv); |
1171 | sx_dprintk(SX_DEBUG_RECEIVE, "pushing flipq port %d (%3d " | 1170 | sx_dprintk(SX_DEBUG_RECEIVE, "pushing flipq port %d (%3d " |
1172 | "chars): %d.%06d (%d/%d)\n", port->line, | 1171 | "chars): %d.%06d (%d/%d)\n", port->line, |
1173 | copied, (int)(tv.tv_sec % 60), (int)tv.tv_usec, | 1172 | copied, (int)(tv.tv_sec % 60), (int)tv.tv_usec, |
1174 | tty->raw, tty->real_raw); | 1173 | tty->raw, tty->real_raw); |
1175 | 1174 | ||
1176 | /* Tell the rest of the system the news. Great news. New | 1175 | /* Tell the rest of the system the news. Great news. New |
1177 | characters! */ | 1176 | characters! */ |
1178 | tty_flip_buffer_push(tty); | 1177 | tty_flip_buffer_push(tty); |
1179 | /* tty_schedule_flip (tty); */ | 1178 | /* tty_schedule_flip (tty); */ |
1180 | } | 1179 | } |
1181 | 1180 | ||
1182 | func_exit(); | 1181 | func_exit(); |
1183 | } | 1182 | } |
1184 | 1183 | ||
1185 | /* Inlined: it is called only once. Remove the inline if you add another | 1184 | /* Inlined: it is called only once. Remove the inline if you add another |
1186 | call */ | 1185 | call */ |
1187 | static inline void sx_check_modem_signals(struct sx_port *port) | 1186 | static inline void sx_check_modem_signals(struct sx_port *port) |
1188 | { | 1187 | { |
1189 | int hi_state; | 1188 | int hi_state; |
1190 | int c_dcd; | 1189 | int c_dcd; |
1191 | 1190 | ||
1192 | hi_state = sx_read_channel_byte(port, hi_state); | 1191 | hi_state = sx_read_channel_byte(port, hi_state); |
1193 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "Checking modem signals (%d/%d)\n", | 1192 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "Checking modem signals (%d/%d)\n", |
1194 | port->c_dcd, sx_get_CD(port)); | 1193 | port->c_dcd, sx_get_CD(port)); |
1195 | 1194 | ||
1196 | if (hi_state & ST_BREAK) { | 1195 | if (hi_state & ST_BREAK) { |
1197 | hi_state &= ~ST_BREAK; | 1196 | hi_state &= ~ST_BREAK; |
1198 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "got a break.\n"); | 1197 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "got a break.\n"); |
1199 | sx_write_channel_byte(port, hi_state, hi_state); | 1198 | sx_write_channel_byte(port, hi_state, hi_state); |
1200 | gs_got_break(&port->gs); | 1199 | gs_got_break(&port->gs); |
1201 | } | 1200 | } |
1202 | if (hi_state & ST_DCD) { | 1201 | if (hi_state & ST_DCD) { |
1203 | hi_state &= ~ST_DCD; | 1202 | hi_state &= ~ST_DCD; |
1204 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "got a DCD change.\n"); | 1203 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "got a DCD change.\n"); |
1205 | sx_write_channel_byte(port, hi_state, hi_state); | 1204 | sx_write_channel_byte(port, hi_state, hi_state); |
1206 | c_dcd = sx_get_CD(port); | 1205 | c_dcd = sx_get_CD(port); |
1207 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD is now %d\n", c_dcd); | 1206 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD is now %d\n", c_dcd); |
1208 | if (c_dcd != port->c_dcd) { | 1207 | if (c_dcd != port->c_dcd) { |
1209 | port->c_dcd = c_dcd; | 1208 | port->c_dcd = c_dcd; |
1210 | if (sx_get_CD(port)) { | 1209 | if (sx_get_CD(port)) { |
1211 | /* DCD went UP */ | 1210 | /* DCD went UP */ |
1212 | if ((sx_read_channel_byte(port, hi_hstat) != | 1211 | if ((sx_read_channel_byte(port, hi_hstat) != |
1213 | HS_IDLE_CLOSED) && | 1212 | HS_IDLE_CLOSED) && |
1214 | !(port->gs.tty->termios-> | 1213 | !(port->gs.port.tty->termios-> |
1215 | c_cflag & CLOCAL)) { | 1214 | c_cflag & CLOCAL)) { |
1216 | /* Are we blocking in open? */ | 1215 | /* Are we blocking in open? */ |
1217 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD " | 1216 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD " |
1218 | "active, unblocking open\n"); | 1217 | "active, unblocking open\n"); |
1219 | wake_up_interruptible(&port->gs. | 1218 | wake_up_interruptible(&port->gs.port. |
1220 | open_wait); | 1219 | open_wait); |
1221 | } else { | 1220 | } else { |
1222 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD " | 1221 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD " |
1223 | "raised. Ignoring.\n"); | 1222 | "raised. Ignoring.\n"); |
1224 | } | 1223 | } |
1225 | } else { | 1224 | } else { |
1226 | /* DCD went down! */ | 1225 | /* DCD went down! */ |
1227 | if (!(port->gs.tty->termios->c_cflag & CLOCAL)){ | 1226 | if (!(port->gs.port.tty->termios->c_cflag & CLOCAL)){ |
1228 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD " | 1227 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD " |
1229 | "dropped. hanging up....\n"); | 1228 | "dropped. hanging up....\n"); |
1230 | tty_hangup(port->gs.tty); | 1229 | tty_hangup(port->gs.port.tty); |
1231 | } else { | 1230 | } else { |
1232 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD " | 1231 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD " |
1233 | "dropped. ignoring.\n"); | 1232 | "dropped. ignoring.\n"); |
1234 | } | 1233 | } |
1235 | } | 1234 | } |
1236 | } else { | 1235 | } else { |
1237 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "Hmmm. card told us " | 1236 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "Hmmm. card told us " |
1238 | "DCD changed, but it didn't.\n"); | 1237 | "DCD changed, but it didn't.\n"); |
1239 | } | 1238 | } |
1240 | } | 1239 | } |
1241 | } | 1240 | } |
1242 | 1241 | ||
1243 | /* This is what an interrupt routine should look like. | 1242 | /* This is what an interrupt routine should look like. |
1244 | * Small, elegant, clear. | 1243 | * Small, elegant, clear. |
1245 | */ | 1244 | */ |
1246 | 1245 | ||
1247 | static irqreturn_t sx_interrupt(int irq, void *ptr) | 1246 | static irqreturn_t sx_interrupt(int irq, void *ptr) |
1248 | { | 1247 | { |
1249 | struct sx_board *board = ptr; | 1248 | struct sx_board *board = ptr; |
1250 | struct sx_port *port; | 1249 | struct sx_port *port; |
1251 | int i; | 1250 | int i; |
1252 | 1251 | ||
1253 | func_enter(); | 1252 | func_enter(); |
1254 | sx_dprintk(SX_DEBUG_FLOW, "sx: enter sx_interrupt (%d/%d)\n", irq, | 1253 | sx_dprintk(SX_DEBUG_FLOW, "sx: enter sx_interrupt (%d/%d)\n", irq, |
1255 | board->irq); | 1254 | board->irq); |
1256 | 1255 | ||
1257 | /* AAargh! The order in which to do these things is essential and | 1256 | /* AAargh! The order in which to do these things is essential and |
1258 | not trivial. | 1257 | not trivial. |
1259 | 1258 | ||
1260 | - Rate limit goes before "recursive". Otherwise a series of | 1259 | - Rate limit goes before "recursive". Otherwise a series of |
1261 | recursive calls will hang the machine in the interrupt routine. | 1260 | recursive calls will hang the machine in the interrupt routine. |
1262 | 1261 | ||
1263 | - hardware twiddling goes before "recursive". Otherwise when we | 1262 | - hardware twiddling goes before "recursive". Otherwise when we |
1264 | poll the card, and a recursive interrupt happens, we won't | 1263 | poll the card, and a recursive interrupt happens, we won't |
1265 | ack the card, so it might keep on interrupting us. (especially | 1264 | ack the card, so it might keep on interrupting us. (especially |
1266 | level sensitive interrupt systems like PCI). | 1265 | level sensitive interrupt systems like PCI). |
1267 | 1266 | ||
1268 | - Rate limit goes before hardware twiddling. Otherwise we won't | 1267 | - Rate limit goes before hardware twiddling. Otherwise we won't |
1269 | catch a card that has gone bonkers. | 1268 | catch a card that has gone bonkers. |
1270 | 1269 | ||
1271 | - The "initialized" test goes after the hardware twiddling. Otherwise | 1270 | - The "initialized" test goes after the hardware twiddling. Otherwise |
1272 | the card will stick us in the interrupt routine again. | 1271 | the card will stick us in the interrupt routine again. |
1273 | 1272 | ||
1274 | - The initialized test goes before recursive. | 1273 | - The initialized test goes before recursive. |
1275 | */ | 1274 | */ |
1276 | 1275 | ||
1277 | #ifdef IRQ_RATE_LIMIT | 1276 | #ifdef IRQ_RATE_LIMIT |
1278 | /* Aaargh! I'm ashamed. This costs more lines-of-code than the | 1277 | /* Aaargh! I'm ashamed. This costs more lines-of-code than the |
1279 | actual interrupt routine!. (Well, used to when I wrote that | 1278 | actual interrupt routine!. (Well, used to when I wrote that |
1280 | comment) */ | 1279 | comment) */ |
1281 | { | 1280 | { |
1282 | static int lastjif; | 1281 | static int lastjif; |
1283 | static int nintr = 0; | 1282 | static int nintr = 0; |
1284 | 1283 | ||
1285 | if (lastjif == jiffies) { | 1284 | if (lastjif == jiffies) { |
1286 | if (++nintr > IRQ_RATE_LIMIT) { | 1285 | if (++nintr > IRQ_RATE_LIMIT) { |
1287 | free_irq(board->irq, board); | 1286 | free_irq(board->irq, board); |
1288 | printk(KERN_ERR "sx: Too many interrupts. " | 1287 | printk(KERN_ERR "sx: Too many interrupts. " |
1289 | "Turning off interrupt %d.\n", | 1288 | "Turning off interrupt %d.\n", |
1290 | board->irq); | 1289 | board->irq); |
1291 | } | 1290 | } |
1292 | } else { | 1291 | } else { |
1293 | lastjif = jiffies; | 1292 | lastjif = jiffies; |
1294 | nintr = 0; | 1293 | nintr = 0; |
1295 | } | 1294 | } |
1296 | } | 1295 | } |
1297 | #endif | 1296 | #endif |
1298 | 1297 | ||
1299 | if (board->irq == irq) { | 1298 | if (board->irq == irq) { |
1300 | /* Tell the card we've noticed the interrupt. */ | 1299 | /* Tell the card we've noticed the interrupt. */ |
1301 | 1300 | ||
1302 | sx_write_board_word(board, cc_int_pending, 0); | 1301 | sx_write_board_word(board, cc_int_pending, 0); |
1303 | if (IS_SX_BOARD(board)) { | 1302 | if (IS_SX_BOARD(board)) { |
1304 | write_sx_byte(board, SX_RESET_IRQ, 1); | 1303 | write_sx_byte(board, SX_RESET_IRQ, 1); |
1305 | } else if (IS_EISA_BOARD(board)) { | 1304 | } else if (IS_EISA_BOARD(board)) { |
1306 | inb(board->eisa_base + 0xc03); | 1305 | inb(board->eisa_base + 0xc03); |
1307 | write_sx_word(board, 8, 0); | 1306 | write_sx_word(board, 8, 0); |
1308 | } else { | 1307 | } else { |
1309 | write_sx_byte(board, SI2_ISA_INTCLEAR, | 1308 | write_sx_byte(board, SI2_ISA_INTCLEAR, |
1310 | SI2_ISA_INTCLEAR_CLEAR); | 1309 | SI2_ISA_INTCLEAR_CLEAR); |
1311 | write_sx_byte(board, SI2_ISA_INTCLEAR, | 1310 | write_sx_byte(board, SI2_ISA_INTCLEAR, |
1312 | SI2_ISA_INTCLEAR_SET); | 1311 | SI2_ISA_INTCLEAR_SET); |
1313 | } | 1312 | } |
1314 | } | 1313 | } |
1315 | 1314 | ||
1316 | if (!sx_initialized) | 1315 | if (!sx_initialized) |
1317 | return IRQ_HANDLED; | 1316 | return IRQ_HANDLED; |
1318 | if (!(board->flags & SX_BOARD_INITIALIZED)) | 1317 | if (!(board->flags & SX_BOARD_INITIALIZED)) |
1319 | return IRQ_HANDLED; | 1318 | return IRQ_HANDLED; |
1320 | 1319 | ||
1321 | if (test_and_set_bit(SX_BOARD_INTR_LOCK, &board->locks)) { | 1320 | if (test_and_set_bit(SX_BOARD_INTR_LOCK, &board->locks)) { |
1322 | printk(KERN_ERR "Recursive interrupt! (%d)\n", board->irq); | 1321 | printk(KERN_ERR "Recursive interrupt! (%d)\n", board->irq); |
1323 | return IRQ_HANDLED; | 1322 | return IRQ_HANDLED; |
1324 | } | 1323 | } |
1325 | 1324 | ||
1326 | for (i = 0; i < board->nports; i++) { | 1325 | for (i = 0; i < board->nports; i++) { |
1327 | port = &board->ports[i]; | 1326 | port = &board->ports[i]; |
1328 | if (port->gs.flags & GS_ACTIVE) { | 1327 | if (port->gs.port.flags & GS_ACTIVE) { |
1329 | if (sx_read_channel_byte(port, hi_state)) { | 1328 | if (sx_read_channel_byte(port, hi_state)) { |
1330 | sx_dprintk(SX_DEBUG_INTERRUPTS, "Port %d: " | 1329 | sx_dprintk(SX_DEBUG_INTERRUPTS, "Port %d: " |
1331 | "modem signal change?... \n",i); | 1330 | "modem signal change?... \n",i); |
1332 | sx_check_modem_signals(port); | 1331 | sx_check_modem_signals(port); |
1333 | } | 1332 | } |
1334 | if (port->gs.xmit_cnt) { | 1333 | if (port->gs.xmit_cnt) { |
1335 | sx_transmit_chars(port); | 1334 | sx_transmit_chars(port); |
1336 | } | 1335 | } |
1337 | if (!(port->gs.flags & SX_RX_THROTTLE)) { | 1336 | if (!(port->gs.port.flags & SX_RX_THROTTLE)) { |
1338 | sx_receive_chars(port); | 1337 | sx_receive_chars(port); |
1339 | } | 1338 | } |
1340 | } | 1339 | } |
1341 | } | 1340 | } |
1342 | 1341 | ||
1343 | clear_bit(SX_BOARD_INTR_LOCK, &board->locks); | 1342 | clear_bit(SX_BOARD_INTR_LOCK, &board->locks); |
1344 | 1343 | ||
1345 | sx_dprintk(SX_DEBUG_FLOW, "sx: exit sx_interrupt (%d/%d)\n", irq, | 1344 | sx_dprintk(SX_DEBUG_FLOW, "sx: exit sx_interrupt (%d/%d)\n", irq, |
1346 | board->irq); | 1345 | board->irq); |
1347 | func_exit(); | 1346 | func_exit(); |
1348 | return IRQ_HANDLED; | 1347 | return IRQ_HANDLED; |
1349 | } | 1348 | } |
1350 | 1349 | ||
1351 | static void sx_pollfunc(unsigned long data) | 1350 | static void sx_pollfunc(unsigned long data) |
1352 | { | 1351 | { |
1353 | struct sx_board *board = (struct sx_board *)data; | 1352 | struct sx_board *board = (struct sx_board *)data; |
1354 | 1353 | ||
1355 | func_enter(); | 1354 | func_enter(); |
1356 | 1355 | ||
1357 | sx_interrupt(0, board); | 1356 | sx_interrupt(0, board); |
1358 | 1357 | ||
1359 | mod_timer(&board->timer, jiffies + sx_poll); | 1358 | mod_timer(&board->timer, jiffies + sx_poll); |
1360 | func_exit(); | 1359 | func_exit(); |
1361 | } | 1360 | } |
1362 | 1361 | ||
1363 | /* ********************************************************************** * | 1362 | /* ********************************************************************** * |
1364 | * Here are the routines that actually * | 1363 | * Here are the routines that actually * |
1365 | * interface with the generic_serial driver * | 1364 | * interface with the generic_serial driver * |
1366 | * ********************************************************************** */ | 1365 | * ********************************************************************** */ |
1367 | 1366 | ||
1368 | /* Ehhm. I don't know how to fiddle with interrupts on the SX card. --REW */ | 1367 | /* Ehhm. I don't know how to fiddle with interrupts on the SX card. --REW */ |
1369 | /* Hmm. Ok I figured it out. You don't. */ | 1368 | /* Hmm. Ok I figured it out. You don't. */ |
1370 | 1369 | ||
1371 | static void sx_disable_tx_interrupts(void *ptr) | 1370 | static void sx_disable_tx_interrupts(void *ptr) |
1372 | { | 1371 | { |
1373 | struct sx_port *port = ptr; | 1372 | struct sx_port *port = ptr; |
1374 | func_enter2(); | 1373 | func_enter2(); |
1375 | 1374 | ||
1376 | port->gs.flags &= ~GS_TX_INTEN; | 1375 | port->gs.port.flags &= ~GS_TX_INTEN; |
1377 | 1376 | ||
1378 | func_exit(); | 1377 | func_exit(); |
1379 | } | 1378 | } |
1380 | 1379 | ||
1381 | static void sx_enable_tx_interrupts(void *ptr) | 1380 | static void sx_enable_tx_interrupts(void *ptr) |
1382 | { | 1381 | { |
1383 | struct sx_port *port = ptr; | 1382 | struct sx_port *port = ptr; |
1384 | int data_in_buffer; | 1383 | int data_in_buffer; |
1385 | func_enter2(); | 1384 | func_enter2(); |
1386 | 1385 | ||
1387 | /* First transmit the characters that we're supposed to */ | 1386 | /* First transmit the characters that we're supposed to */ |
1388 | sx_transmit_chars(port); | 1387 | sx_transmit_chars(port); |
1389 | 1388 | ||
1390 | /* The sx card will never interrupt us if we don't fill the buffer | 1389 | /* The sx card will never interrupt us if we don't fill the buffer |
1391 | past 25%. So we keep considering interrupts off if that's the case. */ | 1390 | past 25%. So we keep considering interrupts off if that's the case. */ |
1392 | data_in_buffer = (sx_read_channel_byte(port, hi_txipos) - | 1391 | data_in_buffer = (sx_read_channel_byte(port, hi_txipos) - |
1393 | sx_read_channel_byte(port, hi_txopos)) & 0xff; | 1392 | sx_read_channel_byte(port, hi_txopos)) & 0xff; |
1394 | 1393 | ||
1395 | /* XXX Must be "HIGH_WATER" for SI card according to doc. */ | 1394 | /* XXX Must be "HIGH_WATER" for SI card according to doc. */ |
1396 | if (data_in_buffer < LOW_WATER) | 1395 | if (data_in_buffer < LOW_WATER) |
1397 | port->gs.flags &= ~GS_TX_INTEN; | 1396 | port->gs.port.flags &= ~GS_TX_INTEN; |
1398 | 1397 | ||
1399 | func_exit(); | 1398 | func_exit(); |
1400 | } | 1399 | } |
1401 | 1400 | ||
1402 | static void sx_disable_rx_interrupts(void *ptr) | 1401 | static void sx_disable_rx_interrupts(void *ptr) |
1403 | { | 1402 | { |
1404 | /* struct sx_port *port = ptr; */ | 1403 | /* struct sx_port *port = ptr; */ |
1405 | func_enter(); | 1404 | func_enter(); |
1406 | 1405 | ||
1407 | func_exit(); | 1406 | func_exit(); |
1408 | } | 1407 | } |
1409 | 1408 | ||
1410 | static void sx_enable_rx_interrupts(void *ptr) | 1409 | static void sx_enable_rx_interrupts(void *ptr) |
1411 | { | 1410 | { |
1412 | /* struct sx_port *port = ptr; */ | 1411 | /* struct sx_port *port = ptr; */ |
1413 | func_enter(); | 1412 | func_enter(); |
1414 | 1413 | ||
1415 | func_exit(); | 1414 | func_exit(); |
1416 | } | 1415 | } |
1417 | 1416 | ||
1418 | /* Jeez. Isn't this simple? */ | 1417 | /* Jeez. Isn't this simple? */ |
1419 | static int sx_get_CD(void *ptr) | 1418 | static int sx_get_CD(void *ptr) |
1420 | { | 1419 | { |
1421 | struct sx_port *port = ptr; | 1420 | struct sx_port *port = ptr; |
1422 | func_enter2(); | 1421 | func_enter2(); |
1423 | 1422 | ||
1424 | func_exit(); | 1423 | func_exit(); |
1425 | return ((sx_read_channel_byte(port, hi_ip) & IP_DCD) != 0); | 1424 | return ((sx_read_channel_byte(port, hi_ip) & IP_DCD) != 0); |
1426 | } | 1425 | } |
1427 | 1426 | ||
1428 | /* Jeez. Isn't this simple? */ | 1427 | /* Jeez. Isn't this simple? */ |
1429 | static int sx_chars_in_buffer(void *ptr) | 1428 | static int sx_chars_in_buffer(void *ptr) |
1430 | { | 1429 | { |
1431 | struct sx_port *port = ptr; | 1430 | struct sx_port *port = ptr; |
1432 | func_enter2(); | 1431 | func_enter2(); |
1433 | 1432 | ||
1434 | func_exit(); | 1433 | func_exit(); |
1435 | return ((sx_read_channel_byte(port, hi_txipos) - | 1434 | return ((sx_read_channel_byte(port, hi_txipos) - |
1436 | sx_read_channel_byte(port, hi_txopos)) & 0xff); | 1435 | sx_read_channel_byte(port, hi_txopos)) & 0xff); |
1437 | } | 1436 | } |
1438 | 1437 | ||
1439 | static void sx_shutdown_port(void *ptr) | 1438 | static void sx_shutdown_port(void *ptr) |
1440 | { | 1439 | { |
1441 | struct sx_port *port = ptr; | 1440 | struct sx_port *port = ptr; |
1442 | 1441 | ||
1443 | func_enter(); | 1442 | func_enter(); |
1444 | 1443 | ||
1445 | port->gs.flags &= ~GS_ACTIVE; | 1444 | port->gs.port.flags &= ~GS_ACTIVE; |
1446 | if (port->gs.tty && (port->gs.tty->termios->c_cflag & HUPCL)) { | 1445 | if (port->gs.port.tty && (port->gs.port.tty->termios->c_cflag & HUPCL)) { |
1447 | sx_setsignals(port, 0, 0); | 1446 | sx_setsignals(port, 0, 0); |
1448 | sx_reconfigure_port(port); | 1447 | sx_reconfigure_port(port); |
1449 | } | 1448 | } |
1450 | 1449 | ||
1451 | func_exit(); | 1450 | func_exit(); |
1452 | } | 1451 | } |
1453 | 1452 | ||
1454 | /* ********************************************************************** * | 1453 | /* ********************************************************************** * |
1455 | * Here are the routines that actually * | 1454 | * Here are the routines that actually * |
1456 | * interface with the rest of the system * | 1455 | * interface with the rest of the system * |
1457 | * ********************************************************************** */ | 1456 | * ********************************************************************** */ |
1458 | 1457 | ||
1459 | static int sx_open(struct tty_struct *tty, struct file *filp) | 1458 | static int sx_open(struct tty_struct *tty, struct file *filp) |
1460 | { | 1459 | { |
1461 | struct sx_port *port; | 1460 | struct sx_port *port; |
1462 | int retval, line; | 1461 | int retval, line; |
1463 | unsigned long flags; | 1462 | unsigned long flags; |
1464 | 1463 | ||
1465 | func_enter(); | 1464 | func_enter(); |
1466 | 1465 | ||
1467 | if (!sx_initialized) { | 1466 | if (!sx_initialized) { |
1468 | return -EIO; | 1467 | return -EIO; |
1469 | } | 1468 | } |
1470 | 1469 | ||
1471 | line = tty->index; | 1470 | line = tty->index; |
1472 | sx_dprintk(SX_DEBUG_OPEN, "%d: opening line %d. tty=%p ctty=%p, " | 1471 | sx_dprintk(SX_DEBUG_OPEN, "%d: opening line %d. tty=%p ctty=%p, " |
1473 | "np=%d)\n", task_pid_nr(current), line, tty, | 1472 | "np=%d)\n", task_pid_nr(current), line, tty, |
1474 | current->signal->tty, sx_nports); | 1473 | current->signal->tty, sx_nports); |
1475 | 1474 | ||
1476 | if ((line < 0) || (line >= SX_NPORTS) || (line >= sx_nports)) | 1475 | if ((line < 0) || (line >= SX_NPORTS) || (line >= sx_nports)) |
1477 | return -ENODEV; | 1476 | return -ENODEV; |
1478 | 1477 | ||
1479 | port = &sx_ports[line]; | 1478 | port = &sx_ports[line]; |
1480 | port->c_dcd = 0; /* Make sure that the first interrupt doesn't detect a | 1479 | port->c_dcd = 0; /* Make sure that the first interrupt doesn't detect a |
1481 | 1 -> 0 transition. */ | 1480 | 1 -> 0 transition. */ |
1482 | 1481 | ||
1483 | sx_dprintk(SX_DEBUG_OPEN, "port = %p c_dcd = %d\n", port, port->c_dcd); | 1482 | sx_dprintk(SX_DEBUG_OPEN, "port = %p c_dcd = %d\n", port, port->c_dcd); |
1484 | 1483 | ||
1485 | spin_lock_irqsave(&port->gs.driver_lock, flags); | 1484 | spin_lock_irqsave(&port->gs.driver_lock, flags); |
1486 | 1485 | ||
1487 | tty->driver_data = port; | 1486 | tty->driver_data = port; |
1488 | port->gs.tty = tty; | 1487 | port->gs.port.tty = tty; |
1489 | port->gs.count++; | 1488 | port->gs.port.count++; |
1490 | spin_unlock_irqrestore(&port->gs.driver_lock, flags); | 1489 | spin_unlock_irqrestore(&port->gs.driver_lock, flags); |
1491 | 1490 | ||
1492 | sx_dprintk(SX_DEBUG_OPEN, "starting port\n"); | 1491 | sx_dprintk(SX_DEBUG_OPEN, "starting port\n"); |
1493 | 1492 | ||
1494 | /* | 1493 | /* |
1495 | * Start up serial port | 1494 | * Start up serial port |
1496 | */ | 1495 | */ |
1497 | retval = gs_init_port(&port->gs); | 1496 | retval = gs_init_port(&port->gs); |
1498 | sx_dprintk(SX_DEBUG_OPEN, "done gs_init\n"); | 1497 | sx_dprintk(SX_DEBUG_OPEN, "done gs_init\n"); |
1499 | if (retval) { | 1498 | if (retval) { |
1500 | port->gs.count--; | 1499 | port->gs.port.count--; |
1501 | return retval; | 1500 | return retval; |
1502 | } | 1501 | } |
1503 | 1502 | ||
1504 | port->gs.flags |= GS_ACTIVE; | 1503 | port->gs.port.flags |= GS_ACTIVE; |
1505 | if (port->gs.count <= 1) | 1504 | if (port->gs.port.count <= 1) |
1506 | sx_setsignals(port, 1, 1); | 1505 | sx_setsignals(port, 1, 1); |
1507 | 1506 | ||
1508 | #if 0 | 1507 | #if 0 |
1509 | if (sx_debug & SX_DEBUG_OPEN) | 1508 | if (sx_debug & SX_DEBUG_OPEN) |
1510 | my_hd(port, sizeof(*port)); | 1509 | my_hd(port, sizeof(*port)); |
1511 | #else | 1510 | #else |
1512 | if (sx_debug & SX_DEBUG_OPEN) | 1511 | if (sx_debug & SX_DEBUG_OPEN) |
1513 | my_hd_io(port->board->base + port->ch_base, sizeof(*port)); | 1512 | my_hd_io(port->board->base + port->ch_base, sizeof(*port)); |
1514 | #endif | 1513 | #endif |
1515 | 1514 | ||
1516 | if (port->gs.count <= 1) { | 1515 | if (port->gs.port.count <= 1) { |
1517 | if (sx_send_command(port, HS_LOPEN, -1, HS_IDLE_OPEN) != 1) { | 1516 | if (sx_send_command(port, HS_LOPEN, -1, HS_IDLE_OPEN) != 1) { |
1518 | printk(KERN_ERR "sx: Card didn't respond to LOPEN " | 1517 | printk(KERN_ERR "sx: Card didn't respond to LOPEN " |
1519 | "command.\n"); | 1518 | "command.\n"); |
1520 | spin_lock_irqsave(&port->gs.driver_lock, flags); | 1519 | spin_lock_irqsave(&port->gs.driver_lock, flags); |
1521 | port->gs.count--; | 1520 | port->gs.port.count--; |
1522 | spin_unlock_irqrestore(&port->gs.driver_lock, flags); | 1521 | spin_unlock_irqrestore(&port->gs.driver_lock, flags); |
1523 | return -EIO; | 1522 | return -EIO; |
1524 | } | 1523 | } |
1525 | } | 1524 | } |
1526 | 1525 | ||
1527 | retval = gs_block_til_ready(port, filp); | 1526 | retval = gs_block_til_ready(port, filp); |
1528 | sx_dprintk(SX_DEBUG_OPEN, "Block til ready returned %d. Count=%d\n", | 1527 | sx_dprintk(SX_DEBUG_OPEN, "Block til ready returned %d. Count=%d\n", |
1529 | retval, port->gs.count); | 1528 | retval, port->gs.port.count); |
1530 | 1529 | ||
1531 | if (retval) { | 1530 | if (retval) { |
1532 | /* | 1531 | /* |
1533 | * Don't lower gs.count here because sx_close() will be called later | 1532 | * Don't lower gs.port.count here because sx_close() will be called later |
1534 | */ | 1533 | */ |
1535 | 1534 | ||
1536 | return retval; | 1535 | return retval; |
1537 | } | 1536 | } |
1538 | /* tty->low_latency = 1; */ | 1537 | /* tty->low_latency = 1; */ |
1539 | 1538 | ||
1540 | port->c_dcd = sx_get_CD(port); | 1539 | port->c_dcd = sx_get_CD(port); |
1541 | sx_dprintk(SX_DEBUG_OPEN, "at open: cd=%d\n", port->c_dcd); | 1540 | sx_dprintk(SX_DEBUG_OPEN, "at open: cd=%d\n", port->c_dcd); |
1542 | 1541 | ||
1543 | func_exit(); | 1542 | func_exit(); |
1544 | return 0; | 1543 | return 0; |
1545 | 1544 | ||
1546 | } | 1545 | } |
1547 | 1546 | ||
1548 | static void sx_close(void *ptr) | 1547 | static void sx_close(void *ptr) |
1549 | { | 1548 | { |
1550 | struct sx_port *port = ptr; | 1549 | struct sx_port *port = ptr; |
1551 | /* Give the port 5 seconds to close down. */ | 1550 | /* Give the port 5 seconds to close down. */ |
1552 | int to = 5 * HZ; | 1551 | int to = 5 * HZ; |
1553 | 1552 | ||
1554 | func_enter(); | 1553 | func_enter(); |
1555 | 1554 | ||
1556 | sx_setsignals(port, 0, 0); | 1555 | sx_setsignals(port, 0, 0); |
1557 | sx_reconfigure_port(port); | 1556 | sx_reconfigure_port(port); |
1558 | sx_send_command(port, HS_CLOSE, 0, 0); | 1557 | sx_send_command(port, HS_CLOSE, 0, 0); |
1559 | 1558 | ||
1560 | while (to-- && (sx_read_channel_byte(port, hi_hstat) != HS_IDLE_CLOSED)) | 1559 | while (to-- && (sx_read_channel_byte(port, hi_hstat) != HS_IDLE_CLOSED)) |
1561 | if (msleep_interruptible(10)) | 1560 | if (msleep_interruptible(10)) |
1562 | break; | 1561 | break; |
1563 | if (sx_read_channel_byte(port, hi_hstat) != HS_IDLE_CLOSED) { | 1562 | if (sx_read_channel_byte(port, hi_hstat) != HS_IDLE_CLOSED) { |
1564 | if (sx_send_command(port, HS_FORCE_CLOSED, -1, HS_IDLE_CLOSED) | 1563 | if (sx_send_command(port, HS_FORCE_CLOSED, -1, HS_IDLE_CLOSED) |
1565 | != 1) { | 1564 | != 1) { |
1566 | printk(KERN_ERR "sx: sent the force_close command, but " | 1565 | printk(KERN_ERR "sx: sent the force_close command, but " |
1567 | "card didn't react\n"); | 1566 | "card didn't react\n"); |
1568 | } else | 1567 | } else |
1569 | sx_dprintk(SX_DEBUG_CLOSE, "sent the force_close " | 1568 | sx_dprintk(SX_DEBUG_CLOSE, "sent the force_close " |
1570 | "command.\n"); | 1569 | "command.\n"); |
1571 | } | 1570 | } |
1572 | 1571 | ||
1573 | sx_dprintk(SX_DEBUG_CLOSE, "waited %d jiffies for close. count=%d\n", | 1572 | sx_dprintk(SX_DEBUG_CLOSE, "waited %d jiffies for close. count=%d\n", |
1574 | 5 * HZ - to - 1, port->gs.count); | 1573 | 5 * HZ - to - 1, port->gs.port.count); |
1575 | 1574 | ||
1576 | if (port->gs.count) { | 1575 | if (port->gs.port.count) { |
1577 | sx_dprintk(SX_DEBUG_CLOSE, "WARNING port count:%d\n", | 1576 | sx_dprintk(SX_DEBUG_CLOSE, "WARNING port count:%d\n", |
1578 | port->gs.count); | 1577 | port->gs.port.count); |
1579 | /*printk("%s SETTING port count to zero: %p count: %d\n", | 1578 | /*printk("%s SETTING port count to zero: %p count: %d\n", |
1580 | __func__, port, port->gs.count); | 1579 | __func__, port, port->gs.port.count); |
1581 | port->gs.count = 0;*/ | 1580 | port->gs.port.count = 0;*/ |
1582 | } | 1581 | } |
1583 | 1582 | ||
1584 | func_exit(); | 1583 | func_exit(); |
1585 | } | 1584 | } |
1586 | 1585 | ||
1587 | /* This is relatively thorough. But then again it is only 20 lines. */ | 1586 | /* This is relatively thorough. But then again it is only 20 lines. */ |
1588 | #define MARCHUP for (i = min; i < max; i++) | 1587 | #define MARCHUP for (i = min; i < max; i++) |
1589 | #define MARCHDOWN for (i = max - 1; i >= min; i--) | 1588 | #define MARCHDOWN for (i = max - 1; i >= min; i--) |
1590 | #define W0 write_sx_byte(board, i, 0x55) | 1589 | #define W0 write_sx_byte(board, i, 0x55) |
1591 | #define W1 write_sx_byte(board, i, 0xaa) | 1590 | #define W1 write_sx_byte(board, i, 0xaa) |
1592 | #define R0 if (read_sx_byte(board, i) != 0x55) return 1 | 1591 | #define R0 if (read_sx_byte(board, i) != 0x55) return 1 |
1593 | #define R1 if (read_sx_byte(board, i) != 0xaa) return 1 | 1592 | #define R1 if (read_sx_byte(board, i) != 0xaa) return 1 |
1594 | 1593 | ||
1595 | /* This memtest takes a human-noticable time. You normally only do it | 1594 | /* This memtest takes a human-noticable time. You normally only do it |
1596 | once a boot, so I guess that it is worth it. */ | 1595 | once a boot, so I guess that it is worth it. */ |
1597 | static int do_memtest(struct sx_board *board, int min, int max) | 1596 | static int do_memtest(struct sx_board *board, int min, int max) |
1598 | { | 1597 | { |
1599 | int i; | 1598 | int i; |
1600 | 1599 | ||
1601 | /* This is a marchb. Theoretically, marchb catches much more than | 1600 | /* This is a marchb. Theoretically, marchb catches much more than |
1602 | simpler tests. In practise, the longer test just catches more | 1601 | simpler tests. In practise, the longer test just catches more |
1603 | intermittent errors. -- REW | 1602 | intermittent errors. -- REW |
1604 | (For the theory behind memory testing see: | 1603 | (For the theory behind memory testing see: |
1605 | Testing Semiconductor Memories by A.J. van de Goor.) */ | 1604 | Testing Semiconductor Memories by A.J. van de Goor.) */ |
1606 | MARCHUP { | 1605 | MARCHUP { |
1607 | W0; | 1606 | W0; |
1608 | } | 1607 | } |
1609 | MARCHUP { | 1608 | MARCHUP { |
1610 | R0; | 1609 | R0; |
1611 | W1; | 1610 | W1; |
1612 | R1; | 1611 | R1; |
1613 | W0; | 1612 | W0; |
1614 | R0; | 1613 | R0; |
1615 | W1; | 1614 | W1; |
1616 | } | 1615 | } |
1617 | MARCHUP { | 1616 | MARCHUP { |
1618 | R1; | 1617 | R1; |
1619 | W0; | 1618 | W0; |
1620 | W1; | 1619 | W1; |
1621 | } | 1620 | } |
1622 | MARCHDOWN { | 1621 | MARCHDOWN { |
1623 | R1; | 1622 | R1; |
1624 | W0; | 1623 | W0; |
1625 | W1; | 1624 | W1; |
1626 | W0; | 1625 | W0; |
1627 | } | 1626 | } |
1628 | MARCHDOWN { | 1627 | MARCHDOWN { |
1629 | R0; | 1628 | R0; |
1630 | W1; | 1629 | W1; |
1631 | W0; | 1630 | W0; |
1632 | } | 1631 | } |
1633 | 1632 | ||
1634 | return 0; | 1633 | return 0; |
1635 | } | 1634 | } |
1636 | 1635 | ||
1637 | #undef MARCHUP | 1636 | #undef MARCHUP |
1638 | #undef MARCHDOWN | 1637 | #undef MARCHDOWN |
1639 | #undef W0 | 1638 | #undef W0 |
1640 | #undef W1 | 1639 | #undef W1 |
1641 | #undef R0 | 1640 | #undef R0 |
1642 | #undef R1 | 1641 | #undef R1 |
1643 | 1642 | ||
1644 | #define MARCHUP for (i = min; i < max; i += 2) | 1643 | #define MARCHUP for (i = min; i < max; i += 2) |
1645 | #define MARCHDOWN for (i = max - 1; i >= min; i -= 2) | 1644 | #define MARCHDOWN for (i = max - 1; i >= min; i -= 2) |
1646 | #define W0 write_sx_word(board, i, 0x55aa) | 1645 | #define W0 write_sx_word(board, i, 0x55aa) |
1647 | #define W1 write_sx_word(board, i, 0xaa55) | 1646 | #define W1 write_sx_word(board, i, 0xaa55) |
1648 | #define R0 if (read_sx_word(board, i) != 0x55aa) return 1 | 1647 | #define R0 if (read_sx_word(board, i) != 0x55aa) return 1 |
1649 | #define R1 if (read_sx_word(board, i) != 0xaa55) return 1 | 1648 | #define R1 if (read_sx_word(board, i) != 0xaa55) return 1 |
1650 | 1649 | ||
1651 | #if 0 | 1650 | #if 0 |
1652 | /* This memtest takes a human-noticable time. You normally only do it | 1651 | /* This memtest takes a human-noticable time. You normally only do it |
1653 | once a boot, so I guess that it is worth it. */ | 1652 | once a boot, so I guess that it is worth it. */ |
1654 | static int do_memtest_w(struct sx_board *board, int min, int max) | 1653 | static int do_memtest_w(struct sx_board *board, int min, int max) |
1655 | { | 1654 | { |
1656 | int i; | 1655 | int i; |
1657 | 1656 | ||
1658 | MARCHUP { | 1657 | MARCHUP { |
1659 | W0; | 1658 | W0; |
1660 | } | 1659 | } |
1661 | MARCHUP { | 1660 | MARCHUP { |
1662 | R0; | 1661 | R0; |
1663 | W1; | 1662 | W1; |
1664 | R1; | 1663 | R1; |
1665 | W0; | 1664 | W0; |
1666 | R0; | 1665 | R0; |
1667 | W1; | 1666 | W1; |
1668 | } | 1667 | } |
1669 | MARCHUP { | 1668 | MARCHUP { |
1670 | R1; | 1669 | R1; |
1671 | W0; | 1670 | W0; |
1672 | W1; | 1671 | W1; |
1673 | } | 1672 | } |
1674 | MARCHDOWN { | 1673 | MARCHDOWN { |
1675 | R1; | 1674 | R1; |
1676 | W0; | 1675 | W0; |
1677 | W1; | 1676 | W1; |
1678 | W0; | 1677 | W0; |
1679 | } | 1678 | } |
1680 | MARCHDOWN { | 1679 | MARCHDOWN { |
1681 | R0; | 1680 | R0; |
1682 | W1; | 1681 | W1; |
1683 | W0; | 1682 | W0; |
1684 | } | 1683 | } |
1685 | 1684 | ||
1686 | return 0; | 1685 | return 0; |
1687 | } | 1686 | } |
1688 | #endif | 1687 | #endif |
1689 | 1688 | ||
1690 | static int sx_fw_ioctl(struct inode *inode, struct file *filp, | 1689 | static int sx_fw_ioctl(struct inode *inode, struct file *filp, |
1691 | unsigned int cmd, unsigned long arg) | 1690 | unsigned int cmd, unsigned long arg) |
1692 | { | 1691 | { |
1693 | int rc = 0; | 1692 | int rc = 0; |
1694 | int __user *descr = (int __user *)arg; | 1693 | int __user *descr = (int __user *)arg; |
1695 | int i; | 1694 | int i; |
1696 | static struct sx_board *board = NULL; | 1695 | static struct sx_board *board = NULL; |
1697 | int nbytes, offset; | 1696 | int nbytes, offset; |
1698 | unsigned long data; | 1697 | unsigned long data; |
1699 | char *tmp; | 1698 | char *tmp; |
1700 | 1699 | ||
1701 | func_enter(); | 1700 | func_enter(); |
1702 | 1701 | ||
1703 | #if 0 | 1702 | #if 0 |
1704 | /* Removed superuser check: Sysops can use the permissions on the device | 1703 | /* Removed superuser check: Sysops can use the permissions on the device |
1705 | file to restrict access. Recommendation: Root only. (root.root 600) */ | 1704 | file to restrict access. Recommendation: Root only. (root.root 600) */ |
1706 | if (!capable(CAP_SYS_ADMIN)) { | 1705 | if (!capable(CAP_SYS_ADMIN)) { |
1707 | return -EPERM; | 1706 | return -EPERM; |
1708 | } | 1707 | } |
1709 | #endif | 1708 | #endif |
1710 | 1709 | ||
1711 | sx_dprintk(SX_DEBUG_FIRMWARE, "IOCTL %x: %lx\n", cmd, arg); | 1710 | sx_dprintk(SX_DEBUG_FIRMWARE, "IOCTL %x: %lx\n", cmd, arg); |
1712 | 1711 | ||
1713 | if (!board) | 1712 | if (!board) |
1714 | board = &boards[0]; | 1713 | board = &boards[0]; |
1715 | if (board->flags & SX_BOARD_PRESENT) { | 1714 | if (board->flags & SX_BOARD_PRESENT) { |
1716 | sx_dprintk(SX_DEBUG_FIRMWARE, "Board present! (%x)\n", | 1715 | sx_dprintk(SX_DEBUG_FIRMWARE, "Board present! (%x)\n", |
1717 | board->flags); | 1716 | board->flags); |
1718 | } else { | 1717 | } else { |
1719 | sx_dprintk(SX_DEBUG_FIRMWARE, "Board not present! (%x) all:", | 1718 | sx_dprintk(SX_DEBUG_FIRMWARE, "Board not present! (%x) all:", |
1720 | board->flags); | 1719 | board->flags); |
1721 | for (i = 0; i < SX_NBOARDS; i++) | 1720 | for (i = 0; i < SX_NBOARDS; i++) |
1722 | sx_dprintk(SX_DEBUG_FIRMWARE, "<%x> ", boards[i].flags); | 1721 | sx_dprintk(SX_DEBUG_FIRMWARE, "<%x> ", boards[i].flags); |
1723 | sx_dprintk(SX_DEBUG_FIRMWARE, "\n"); | 1722 | sx_dprintk(SX_DEBUG_FIRMWARE, "\n"); |
1724 | return -EIO; | 1723 | return -EIO; |
1725 | } | 1724 | } |
1726 | 1725 | ||
1727 | switch (cmd) { | 1726 | switch (cmd) { |
1728 | case SXIO_SET_BOARD: | 1727 | case SXIO_SET_BOARD: |
1729 | sx_dprintk(SX_DEBUG_FIRMWARE, "set board to %ld\n", arg); | 1728 | sx_dprintk(SX_DEBUG_FIRMWARE, "set board to %ld\n", arg); |
1730 | if (arg >= SX_NBOARDS) | 1729 | if (arg >= SX_NBOARDS) |
1731 | return -EIO; | 1730 | return -EIO; |
1732 | sx_dprintk(SX_DEBUG_FIRMWARE, "not out of range\n"); | 1731 | sx_dprintk(SX_DEBUG_FIRMWARE, "not out of range\n"); |
1733 | if (!(boards[arg].flags & SX_BOARD_PRESENT)) | 1732 | if (!(boards[arg].flags & SX_BOARD_PRESENT)) |
1734 | return -EIO; | 1733 | return -EIO; |
1735 | sx_dprintk(SX_DEBUG_FIRMWARE, ".. and present!\n"); | 1734 | sx_dprintk(SX_DEBUG_FIRMWARE, ".. and present!\n"); |
1736 | board = &boards[arg]; | 1735 | board = &boards[arg]; |
1737 | break; | 1736 | break; |
1738 | case SXIO_GET_TYPE: | 1737 | case SXIO_GET_TYPE: |
1739 | rc = -ENOENT; /* If we manage to miss one, return error. */ | 1738 | rc = -ENOENT; /* If we manage to miss one, return error. */ |
1740 | if (IS_SX_BOARD(board)) | 1739 | if (IS_SX_BOARD(board)) |
1741 | rc = SX_TYPE_SX; | 1740 | rc = SX_TYPE_SX; |
1742 | if (IS_CF_BOARD(board)) | 1741 | if (IS_CF_BOARD(board)) |
1743 | rc = SX_TYPE_CF; | 1742 | rc = SX_TYPE_CF; |
1744 | if (IS_SI_BOARD(board)) | 1743 | if (IS_SI_BOARD(board)) |
1745 | rc = SX_TYPE_SI; | 1744 | rc = SX_TYPE_SI; |
1746 | if (IS_SI1_BOARD(board)) | 1745 | if (IS_SI1_BOARD(board)) |
1747 | rc = SX_TYPE_SI; | 1746 | rc = SX_TYPE_SI; |
1748 | if (IS_EISA_BOARD(board)) | 1747 | if (IS_EISA_BOARD(board)) |
1749 | rc = SX_TYPE_SI; | 1748 | rc = SX_TYPE_SI; |
1750 | sx_dprintk(SX_DEBUG_FIRMWARE, "returning type= %d\n", rc); | 1749 | sx_dprintk(SX_DEBUG_FIRMWARE, "returning type= %d\n", rc); |
1751 | break; | 1750 | break; |
1752 | case SXIO_DO_RAMTEST: | 1751 | case SXIO_DO_RAMTEST: |
1753 | if (sx_initialized) /* Already initialized: better not ramtest the board. */ | 1752 | if (sx_initialized) /* Already initialized: better not ramtest the board. */ |
1754 | return -EPERM; | 1753 | return -EPERM; |
1755 | if (IS_SX_BOARD(board)) { | 1754 | if (IS_SX_BOARD(board)) { |
1756 | rc = do_memtest(board, 0, 0x7000); | 1755 | rc = do_memtest(board, 0, 0x7000); |
1757 | if (!rc) | 1756 | if (!rc) |
1758 | rc = do_memtest(board, 0, 0x7000); | 1757 | rc = do_memtest(board, 0, 0x7000); |
1759 | /*if (!rc) rc = do_memtest_w (board, 0, 0x7000); */ | 1758 | /*if (!rc) rc = do_memtest_w (board, 0, 0x7000); */ |
1760 | } else { | 1759 | } else { |
1761 | rc = do_memtest(board, 0, 0x7ff8); | 1760 | rc = do_memtest(board, 0, 0x7ff8); |
1762 | /* if (!rc) rc = do_memtest_w (board, 0, 0x7ff8); */ | 1761 | /* if (!rc) rc = do_memtest_w (board, 0, 0x7ff8); */ |
1763 | } | 1762 | } |
1764 | sx_dprintk(SX_DEBUG_FIRMWARE, "returning memtest result= %d\n", | 1763 | sx_dprintk(SX_DEBUG_FIRMWARE, "returning memtest result= %d\n", |
1765 | rc); | 1764 | rc); |
1766 | break; | 1765 | break; |
1767 | case SXIO_DOWNLOAD: | 1766 | case SXIO_DOWNLOAD: |
1768 | if (sx_initialized) /* Already initialized */ | 1767 | if (sx_initialized) /* Already initialized */ |
1769 | return -EEXIST; | 1768 | return -EEXIST; |
1770 | if (!sx_reset(board)) | 1769 | if (!sx_reset(board)) |
1771 | return -EIO; | 1770 | return -EIO; |
1772 | sx_dprintk(SX_DEBUG_INIT, "reset the board...\n"); | 1771 | sx_dprintk(SX_DEBUG_INIT, "reset the board...\n"); |
1773 | 1772 | ||
1774 | tmp = kmalloc(SX_CHUNK_SIZE, GFP_USER); | 1773 | tmp = kmalloc(SX_CHUNK_SIZE, GFP_USER); |
1775 | if (!tmp) | 1774 | if (!tmp) |
1776 | return -ENOMEM; | 1775 | return -ENOMEM; |
1777 | get_user(nbytes, descr++); | 1776 | get_user(nbytes, descr++); |
1778 | get_user(offset, descr++); | 1777 | get_user(offset, descr++); |
1779 | get_user(data, descr++); | 1778 | get_user(data, descr++); |
1780 | while (nbytes && data) { | 1779 | while (nbytes && data) { |
1781 | for (i = 0; i < nbytes; i += SX_CHUNK_SIZE) { | 1780 | for (i = 0; i < nbytes; i += SX_CHUNK_SIZE) { |
1782 | if (copy_from_user(tmp, (char __user *)data + i, | 1781 | if (copy_from_user(tmp, (char __user *)data + i, |
1783 | (i + SX_CHUNK_SIZE > nbytes) ? | 1782 | (i + SX_CHUNK_SIZE > nbytes) ? |
1784 | nbytes - i : SX_CHUNK_SIZE)) { | 1783 | nbytes - i : SX_CHUNK_SIZE)) { |
1785 | kfree(tmp); | 1784 | kfree(tmp); |
1786 | return -EFAULT; | 1785 | return -EFAULT; |
1787 | } | 1786 | } |
1788 | memcpy_toio(board->base2 + offset + i, tmp, | 1787 | memcpy_toio(board->base2 + offset + i, tmp, |
1789 | (i + SX_CHUNK_SIZE > nbytes) ? | 1788 | (i + SX_CHUNK_SIZE > nbytes) ? |
1790 | nbytes - i : SX_CHUNK_SIZE); | 1789 | nbytes - i : SX_CHUNK_SIZE); |
1791 | } | 1790 | } |
1792 | 1791 | ||
1793 | get_user(nbytes, descr++); | 1792 | get_user(nbytes, descr++); |
1794 | get_user(offset, descr++); | 1793 | get_user(offset, descr++); |
1795 | get_user(data, descr++); | 1794 | get_user(data, descr++); |
1796 | } | 1795 | } |
1797 | kfree(tmp); | 1796 | kfree(tmp); |
1798 | sx_nports += sx_init_board(board); | 1797 | sx_nports += sx_init_board(board); |
1799 | rc = sx_nports; | 1798 | rc = sx_nports; |
1800 | break; | 1799 | break; |
1801 | case SXIO_INIT: | 1800 | case SXIO_INIT: |
1802 | if (sx_initialized) /* Already initialized */ | 1801 | if (sx_initialized) /* Already initialized */ |
1803 | return -EEXIST; | 1802 | return -EEXIST; |
1804 | /* This is not allowed until all boards are initialized... */ | 1803 | /* This is not allowed until all boards are initialized... */ |
1805 | for (i = 0; i < SX_NBOARDS; i++) { | 1804 | for (i = 0; i < SX_NBOARDS; i++) { |
1806 | if ((boards[i].flags & SX_BOARD_PRESENT) && | 1805 | if ((boards[i].flags & SX_BOARD_PRESENT) && |
1807 | !(boards[i].flags & SX_BOARD_INITIALIZED)) | 1806 | !(boards[i].flags & SX_BOARD_INITIALIZED)) |
1808 | return -EIO; | 1807 | return -EIO; |
1809 | } | 1808 | } |
1810 | for (i = 0; i < SX_NBOARDS; i++) | 1809 | for (i = 0; i < SX_NBOARDS; i++) |
1811 | if (!(boards[i].flags & SX_BOARD_PRESENT)) | 1810 | if (!(boards[i].flags & SX_BOARD_PRESENT)) |
1812 | break; | 1811 | break; |
1813 | 1812 | ||
1814 | sx_dprintk(SX_DEBUG_FIRMWARE, "initing portstructs, %d boards, " | 1813 | sx_dprintk(SX_DEBUG_FIRMWARE, "initing portstructs, %d boards, " |
1815 | "%d channels, first board: %d ports\n", | 1814 | "%d channels, first board: %d ports\n", |
1816 | i, sx_nports, boards[0].nports); | 1815 | i, sx_nports, boards[0].nports); |
1817 | rc = sx_init_portstructs(i, sx_nports); | 1816 | rc = sx_init_portstructs(i, sx_nports); |
1818 | sx_init_drivers(); | 1817 | sx_init_drivers(); |
1819 | if (rc >= 0) | 1818 | if (rc >= 0) |
1820 | sx_initialized++; | 1819 | sx_initialized++; |
1821 | break; | 1820 | break; |
1822 | case SXIO_SETDEBUG: | 1821 | case SXIO_SETDEBUG: |
1823 | sx_debug = arg; | 1822 | sx_debug = arg; |
1824 | break; | 1823 | break; |
1825 | case SXIO_GETDEBUG: | 1824 | case SXIO_GETDEBUG: |
1826 | rc = sx_debug; | 1825 | rc = sx_debug; |
1827 | break; | 1826 | break; |
1828 | case SXIO_GETGSDEBUG: | 1827 | case SXIO_GETGSDEBUG: |
1829 | case SXIO_SETGSDEBUG: | 1828 | case SXIO_SETGSDEBUG: |
1830 | rc = -EINVAL; | 1829 | rc = -EINVAL; |
1831 | break; | 1830 | break; |
1832 | case SXIO_GETNPORTS: | 1831 | case SXIO_GETNPORTS: |
1833 | rc = sx_nports; | 1832 | rc = sx_nports; |
1834 | break; | 1833 | break; |
1835 | default: | 1834 | default: |
1836 | printk(KERN_WARNING "Unknown ioctl on firmware device (%x).\n", | 1835 | printk(KERN_WARNING "Unknown ioctl on firmware device (%x).\n", |
1837 | cmd); | 1836 | cmd); |
1838 | break; | 1837 | break; |
1839 | } | 1838 | } |
1840 | func_exit(); | 1839 | func_exit(); |
1841 | return rc; | 1840 | return rc; |
1842 | } | 1841 | } |
1843 | 1842 | ||
1844 | static void sx_break(struct tty_struct *tty, int flag) | 1843 | static void sx_break(struct tty_struct *tty, int flag) |
1845 | { | 1844 | { |
1846 | struct sx_port *port = tty->driver_data; | 1845 | struct sx_port *port = tty->driver_data; |
1847 | int rv; | 1846 | int rv; |
1848 | 1847 | ||
1849 | func_enter(); | 1848 | func_enter(); |
1850 | lock_kernel(); | 1849 | lock_kernel(); |
1851 | 1850 | ||
1852 | if (flag) | 1851 | if (flag) |
1853 | rv = sx_send_command(port, HS_START, -1, HS_IDLE_BREAK); | 1852 | rv = sx_send_command(port, HS_START, -1, HS_IDLE_BREAK); |
1854 | else | 1853 | else |
1855 | rv = sx_send_command(port, HS_STOP, -1, HS_IDLE_OPEN); | 1854 | rv = sx_send_command(port, HS_STOP, -1, HS_IDLE_OPEN); |
1856 | if (rv != 1) | 1855 | if (rv != 1) |
1857 | printk(KERN_ERR "sx: couldn't send break (%x).\n", | 1856 | printk(KERN_ERR "sx: couldn't send break (%x).\n", |
1858 | read_sx_byte(port->board, CHAN_OFFSET(port, hi_hstat))); | 1857 | read_sx_byte(port->board, CHAN_OFFSET(port, hi_hstat))); |
1859 | unlock_kernel(); | 1858 | unlock_kernel(); |
1860 | func_exit(); | 1859 | func_exit(); |
1861 | } | 1860 | } |
1862 | 1861 | ||
1863 | static int sx_tiocmget(struct tty_struct *tty, struct file *file) | 1862 | static int sx_tiocmget(struct tty_struct *tty, struct file *file) |
1864 | { | 1863 | { |
1865 | struct sx_port *port = tty->driver_data; | 1864 | struct sx_port *port = tty->driver_data; |
1866 | return sx_getsignals(port); | 1865 | return sx_getsignals(port); |
1867 | } | 1866 | } |
1868 | 1867 | ||
1869 | static int sx_tiocmset(struct tty_struct *tty, struct file *file, | 1868 | static int sx_tiocmset(struct tty_struct *tty, struct file *file, |
1870 | unsigned int set, unsigned int clear) | 1869 | unsigned int set, unsigned int clear) |
1871 | { | 1870 | { |
1872 | struct sx_port *port = tty->driver_data; | 1871 | struct sx_port *port = tty->driver_data; |
1873 | int rts = -1, dtr = -1; | 1872 | int rts = -1, dtr = -1; |
1874 | 1873 | ||
1875 | if (set & TIOCM_RTS) | 1874 | if (set & TIOCM_RTS) |
1876 | rts = 1; | 1875 | rts = 1; |
1877 | if (set & TIOCM_DTR) | 1876 | if (set & TIOCM_DTR) |
1878 | dtr = 1; | 1877 | dtr = 1; |
1879 | if (clear & TIOCM_RTS) | 1878 | if (clear & TIOCM_RTS) |
1880 | rts = 0; | 1879 | rts = 0; |
1881 | if (clear & TIOCM_DTR) | 1880 | if (clear & TIOCM_DTR) |
1882 | dtr = 0; | 1881 | dtr = 0; |
1883 | 1882 | ||
1884 | sx_setsignals(port, dtr, rts); | 1883 | sx_setsignals(port, dtr, rts); |
1885 | sx_reconfigure_port(port); | 1884 | sx_reconfigure_port(port); |
1886 | return 0; | 1885 | return 0; |
1887 | } | 1886 | } |
1888 | 1887 | ||
1889 | static int sx_ioctl(struct tty_struct *tty, struct file *filp, | 1888 | static int sx_ioctl(struct tty_struct *tty, struct file *filp, |
1890 | unsigned int cmd, unsigned long arg) | 1889 | unsigned int cmd, unsigned long arg) |
1891 | { | 1890 | { |
1892 | int rc; | 1891 | int rc; |
1893 | struct sx_port *port = tty->driver_data; | 1892 | struct sx_port *port = tty->driver_data; |
1894 | void __user *argp = (void __user *)arg; | 1893 | void __user *argp = (void __user *)arg; |
1895 | 1894 | ||
1896 | /* func_enter2(); */ | 1895 | /* func_enter2(); */ |
1897 | 1896 | ||
1898 | rc = 0; | 1897 | rc = 0; |
1899 | lock_kernel(); | 1898 | lock_kernel(); |
1900 | switch (cmd) { | 1899 | switch (cmd) { |
1901 | case TIOCGSERIAL: | 1900 | case TIOCGSERIAL: |
1902 | rc = gs_getserial(&port->gs, argp); | 1901 | rc = gs_getserial(&port->gs, argp); |
1903 | break; | 1902 | break; |
1904 | case TIOCSSERIAL: | 1903 | case TIOCSSERIAL: |
1905 | rc = gs_setserial(&port->gs, argp); | 1904 | rc = gs_setserial(&port->gs, argp); |
1906 | break; | 1905 | break; |
1907 | default: | 1906 | default: |
1908 | rc = -ENOIOCTLCMD; | 1907 | rc = -ENOIOCTLCMD; |
1909 | break; | 1908 | break; |
1910 | } | 1909 | } |
1911 | unlock_kernel(); | 1910 | unlock_kernel(); |
1912 | 1911 | ||
1913 | /* func_exit(); */ | 1912 | /* func_exit(); */ |
1914 | return rc; | 1913 | return rc; |
1915 | } | 1914 | } |
1916 | 1915 | ||
1917 | /* The throttle/unthrottle scheme for the Specialix card is different | 1916 | /* The throttle/unthrottle scheme for the Specialix card is different |
1918 | * from other drivers and deserves some explanation. | 1917 | * from other drivers and deserves some explanation. |
1919 | * The Specialix hardware takes care of XON/XOFF | 1918 | * The Specialix hardware takes care of XON/XOFF |
1920 | * and CTS/RTS flow control itself. This means that all we have to | 1919 | * and CTS/RTS flow control itself. This means that all we have to |
1921 | * do when signalled by the upper tty layer to throttle/unthrottle is | 1920 | * do when signalled by the upper tty layer to throttle/unthrottle is |
1922 | * to make a note of it here. When we come to read characters from the | 1921 | * to make a note of it here. When we come to read characters from the |
1923 | * rx buffers on the card (sx_receive_chars()) we look to see if the | 1922 | * rx buffers on the card (sx_receive_chars()) we look to see if the |
1924 | * upper layer can accept more (as noted here in sx_rx_throt[]). | 1923 | * upper layer can accept more (as noted here in sx_rx_throt[]). |
1925 | * If it can't we simply don't remove chars from the cards buffer. | 1924 | * If it can't we simply don't remove chars from the cards buffer. |
1926 | * When the tty layer can accept chars, we again note that here and when | 1925 | * When the tty layer can accept chars, we again note that here and when |
1927 | * sx_receive_chars() is called it will remove them from the cards buffer. | 1926 | * sx_receive_chars() is called it will remove them from the cards buffer. |
1928 | * The card will notice that a ports buffer has drained below some low | 1927 | * The card will notice that a ports buffer has drained below some low |
1929 | * water mark and will unflow control the line itself, using whatever | 1928 | * water mark and will unflow control the line itself, using whatever |
1930 | * flow control scheme is in use for that port. -- Simon Allen | 1929 | * flow control scheme is in use for that port. -- Simon Allen |
1931 | */ | 1930 | */ |
1932 | 1931 | ||
1933 | static void sx_throttle(struct tty_struct *tty) | 1932 | static void sx_throttle(struct tty_struct *tty) |
1934 | { | 1933 | { |
1935 | struct sx_port *port = (struct sx_port *)tty->driver_data; | 1934 | struct sx_port *port = (struct sx_port *)tty->driver_data; |
1936 | 1935 | ||
1937 | func_enter2(); | 1936 | func_enter2(); |
1938 | /* If the port is using any type of input flow | 1937 | /* If the port is using any type of input flow |
1939 | * control then throttle the port. | 1938 | * control then throttle the port. |
1940 | */ | 1939 | */ |
1941 | if ((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty))) { | 1940 | if ((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty))) { |
1942 | port->gs.flags |= SX_RX_THROTTLE; | 1941 | port->gs.port.flags |= SX_RX_THROTTLE; |
1943 | } | 1942 | } |
1944 | func_exit(); | 1943 | func_exit(); |
1945 | } | 1944 | } |
1946 | 1945 | ||
1947 | static void sx_unthrottle(struct tty_struct *tty) | 1946 | static void sx_unthrottle(struct tty_struct *tty) |
1948 | { | 1947 | { |
1949 | struct sx_port *port = (struct sx_port *)tty->driver_data; | 1948 | struct sx_port *port = (struct sx_port *)tty->driver_data; |
1950 | 1949 | ||
1951 | func_enter2(); | 1950 | func_enter2(); |
1952 | /* Always unthrottle even if flow control is not enabled on | 1951 | /* Always unthrottle even if flow control is not enabled on |
1953 | * this port in case we disabled flow control while the port | 1952 | * this port in case we disabled flow control while the port |
1954 | * was throttled | 1953 | * was throttled |
1955 | */ | 1954 | */ |
1956 | port->gs.flags &= ~SX_RX_THROTTLE; | 1955 | port->gs.port.flags &= ~SX_RX_THROTTLE; |
1957 | func_exit(); | 1956 | func_exit(); |
1958 | return; | 1957 | return; |
1959 | } | 1958 | } |
1960 | 1959 | ||
1961 | /* ********************************************************************** * | 1960 | /* ********************************************************************** * |
1962 | * Here are the initialization routines. * | 1961 | * Here are the initialization routines. * |
1963 | * ********************************************************************** */ | 1962 | * ********************************************************************** */ |
1964 | 1963 | ||
1965 | static int sx_init_board(struct sx_board *board) | 1964 | static int sx_init_board(struct sx_board *board) |
1966 | { | 1965 | { |
1967 | int addr; | 1966 | int addr; |
1968 | int chans; | 1967 | int chans; |
1969 | int type; | 1968 | int type; |
1970 | 1969 | ||
1971 | func_enter(); | 1970 | func_enter(); |
1972 | 1971 | ||
1973 | /* This is preceded by downloading the download code. */ | 1972 | /* This is preceded by downloading the download code. */ |
1974 | 1973 | ||
1975 | board->flags |= SX_BOARD_INITIALIZED; | 1974 | board->flags |= SX_BOARD_INITIALIZED; |
1976 | 1975 | ||
1977 | if (read_sx_byte(board, 0)) | 1976 | if (read_sx_byte(board, 0)) |
1978 | /* CF boards may need this. */ | 1977 | /* CF boards may need this. */ |
1979 | write_sx_byte(board, 0, 0); | 1978 | write_sx_byte(board, 0, 0); |
1980 | 1979 | ||
1981 | /* This resets the processor again, to make sure it didn't do any | 1980 | /* This resets the processor again, to make sure it didn't do any |
1982 | foolish things while we were downloading the image */ | 1981 | foolish things while we were downloading the image */ |
1983 | if (!sx_reset(board)) | 1982 | if (!sx_reset(board)) |
1984 | return 0; | 1983 | return 0; |
1985 | 1984 | ||
1986 | sx_start_board(board); | 1985 | sx_start_board(board); |
1987 | udelay(10); | 1986 | udelay(10); |
1988 | if (!sx_busy_wait_neq(board, 0, 0xff, 0)) { | 1987 | if (!sx_busy_wait_neq(board, 0, 0xff, 0)) { |
1989 | printk(KERN_ERR "sx: Ooops. Board won't initialize.\n"); | 1988 | printk(KERN_ERR "sx: Ooops. Board won't initialize.\n"); |
1990 | return 0; | 1989 | return 0; |
1991 | } | 1990 | } |
1992 | 1991 | ||
1993 | /* Ok. So now the processor on the card is running. It gathered | 1992 | /* Ok. So now the processor on the card is running. It gathered |
1994 | some info for us... */ | 1993 | some info for us... */ |
1995 | sx_dprintk(SX_DEBUG_INIT, "The sxcard structure:\n"); | 1994 | sx_dprintk(SX_DEBUG_INIT, "The sxcard structure:\n"); |
1996 | if (sx_debug & SX_DEBUG_INIT) | 1995 | if (sx_debug & SX_DEBUG_INIT) |
1997 | my_hd_io(board->base, 0x10); | 1996 | my_hd_io(board->base, 0x10); |
1998 | sx_dprintk(SX_DEBUG_INIT, "the first sx_module structure:\n"); | 1997 | sx_dprintk(SX_DEBUG_INIT, "the first sx_module structure:\n"); |
1999 | if (sx_debug & SX_DEBUG_INIT) | 1998 | if (sx_debug & SX_DEBUG_INIT) |
2000 | my_hd_io(board->base + 0x80, 0x30); | 1999 | my_hd_io(board->base + 0x80, 0x30); |
2001 | 2000 | ||
2002 | sx_dprintk(SX_DEBUG_INIT, "init_status: %x, %dk memory, firmware " | 2001 | sx_dprintk(SX_DEBUG_INIT, "init_status: %x, %dk memory, firmware " |
2003 | "V%x.%02x,\n", | 2002 | "V%x.%02x,\n", |
2004 | read_sx_byte(board, 0), read_sx_byte(board, 1), | 2003 | read_sx_byte(board, 0), read_sx_byte(board, 1), |
2005 | read_sx_byte(board, 5), read_sx_byte(board, 4)); | 2004 | read_sx_byte(board, 5), read_sx_byte(board, 4)); |
2006 | 2005 | ||
2007 | if (read_sx_byte(board, 0) == 0xff) { | 2006 | if (read_sx_byte(board, 0) == 0xff) { |
2008 | printk(KERN_INFO "sx: No modules found. Sorry.\n"); | 2007 | printk(KERN_INFO "sx: No modules found. Sorry.\n"); |
2009 | board->nports = 0; | 2008 | board->nports = 0; |
2010 | return 0; | 2009 | return 0; |
2011 | } | 2010 | } |
2012 | 2011 | ||
2013 | chans = 0; | 2012 | chans = 0; |
2014 | 2013 | ||
2015 | if (IS_SX_BOARD(board)) { | 2014 | if (IS_SX_BOARD(board)) { |
2016 | sx_write_board_word(board, cc_int_count, sx_maxints); | 2015 | sx_write_board_word(board, cc_int_count, sx_maxints); |
2017 | } else { | 2016 | } else { |
2018 | if (sx_maxints) | 2017 | if (sx_maxints) |
2019 | sx_write_board_word(board, cc_int_count, | 2018 | sx_write_board_word(board, cc_int_count, |
2020 | SI_PROCESSOR_CLOCK / 8 / sx_maxints); | 2019 | SI_PROCESSOR_CLOCK / 8 / sx_maxints); |
2021 | } | 2020 | } |
2022 | 2021 | ||
2023 | /* grab the first module type... */ | 2022 | /* grab the first module type... */ |
2024 | /* board->ta_type = mod_compat_type (read_sx_byte (board, 0x80 + 0x08)); */ | 2023 | /* board->ta_type = mod_compat_type (read_sx_byte (board, 0x80 + 0x08)); */ |
2025 | board->ta_type = mod_compat_type(sx_read_module_byte(board, 0x80, | 2024 | board->ta_type = mod_compat_type(sx_read_module_byte(board, 0x80, |
2026 | mc_chip)); | 2025 | mc_chip)); |
2027 | 2026 | ||
2028 | /* XXX byteorder */ | 2027 | /* XXX byteorder */ |
2029 | for (addr = 0x80; addr != 0; addr = read_sx_word(board, addr) & 0x7fff){ | 2028 | for (addr = 0x80; addr != 0; addr = read_sx_word(board, addr) & 0x7fff){ |
2030 | type = sx_read_module_byte(board, addr, mc_chip); | 2029 | type = sx_read_module_byte(board, addr, mc_chip); |
2031 | sx_dprintk(SX_DEBUG_INIT, "Module at %x: %d channels\n", | 2030 | sx_dprintk(SX_DEBUG_INIT, "Module at %x: %d channels\n", |
2032 | addr, read_sx_byte(board, addr + 2)); | 2031 | addr, read_sx_byte(board, addr + 2)); |
2033 | 2032 | ||
2034 | chans += sx_read_module_byte(board, addr, mc_type); | 2033 | chans += sx_read_module_byte(board, addr, mc_type); |
2035 | 2034 | ||
2036 | sx_dprintk(SX_DEBUG_INIT, "module is an %s, which has %s/%s " | 2035 | sx_dprintk(SX_DEBUG_INIT, "module is an %s, which has %s/%s " |
2037 | "panels\n", | 2036 | "panels\n", |
2038 | mod_type_s(type), | 2037 | mod_type_s(type), |
2039 | pan_type_s(sx_read_module_byte(board, addr, | 2038 | pan_type_s(sx_read_module_byte(board, addr, |
2040 | mc_mods) & 0xf), | 2039 | mc_mods) & 0xf), |
2041 | pan_type_s(sx_read_module_byte(board, addr, | 2040 | pan_type_s(sx_read_module_byte(board, addr, |
2042 | mc_mods) >> 4)); | 2041 | mc_mods) >> 4)); |
2043 | 2042 | ||
2044 | sx_dprintk(SX_DEBUG_INIT, "CD1400 versions: %x/%x, ASIC " | 2043 | sx_dprintk(SX_DEBUG_INIT, "CD1400 versions: %x/%x, ASIC " |
2045 | "version: %x\n", | 2044 | "version: %x\n", |
2046 | sx_read_module_byte(board, addr, mc_rev1), | 2045 | sx_read_module_byte(board, addr, mc_rev1), |
2047 | sx_read_module_byte(board, addr, mc_rev2), | 2046 | sx_read_module_byte(board, addr, mc_rev2), |
2048 | sx_read_module_byte(board, addr, mc_mtaasic_rev)); | 2047 | sx_read_module_byte(board, addr, mc_mtaasic_rev)); |
2049 | 2048 | ||
2050 | /* The following combinations are illegal: It should theoretically | 2049 | /* The following combinations are illegal: It should theoretically |
2051 | work, but timing problems make the bus HANG. */ | 2050 | work, but timing problems make the bus HANG. */ |
2052 | 2051 | ||
2053 | if (mod_compat_type(type) != board->ta_type) { | 2052 | if (mod_compat_type(type) != board->ta_type) { |
2054 | printk(KERN_ERR "sx: This is an invalid " | 2053 | printk(KERN_ERR "sx: This is an invalid " |
2055 | "configuration.\nDon't mix TA/MTA/SXDC on the " | 2054 | "configuration.\nDon't mix TA/MTA/SXDC on the " |
2056 | "same hostadapter.\n"); | 2055 | "same hostadapter.\n"); |
2057 | chans = 0; | 2056 | chans = 0; |
2058 | break; | 2057 | break; |
2059 | } | 2058 | } |
2060 | if ((IS_EISA_BOARD(board) || | 2059 | if ((IS_EISA_BOARD(board) || |
2061 | IS_SI_BOARD(board)) && | 2060 | IS_SI_BOARD(board)) && |
2062 | (mod_compat_type(type) == 4)) { | 2061 | (mod_compat_type(type) == 4)) { |
2063 | printk(KERN_ERR "sx: This is an invalid " | 2062 | printk(KERN_ERR "sx: This is an invalid " |
2064 | "configuration.\nDon't use SXDCs on an SI/XIO " | 2063 | "configuration.\nDon't use SXDCs on an SI/XIO " |
2065 | "adapter.\n"); | 2064 | "adapter.\n"); |
2066 | chans = 0; | 2065 | chans = 0; |
2067 | break; | 2066 | break; |
2068 | } | 2067 | } |
2069 | #if 0 /* Problem fixed: firmware 3.05 */ | 2068 | #if 0 /* Problem fixed: firmware 3.05 */ |
2070 | if (IS_SX_BOARD(board) && (type == TA8)) { | 2069 | if (IS_SX_BOARD(board) && (type == TA8)) { |
2071 | /* There are some issues with the firmware and the DCD/RTS | 2070 | /* There are some issues with the firmware and the DCD/RTS |
2072 | lines. It might work if you tie them together or something. | 2071 | lines. It might work if you tie them together or something. |
2073 | It might also work if you get a newer sx_firmware. Therefore | 2072 | It might also work if you get a newer sx_firmware. Therefore |
2074 | this is just a warning. */ | 2073 | this is just a warning. */ |
2075 | printk(KERN_WARNING | 2074 | printk(KERN_WARNING |
2076 | "sx: The SX host doesn't work too well " | 2075 | "sx: The SX host doesn't work too well " |
2077 | "with the TA8 adapters.\nSpecialix is working on it.\n"); | 2076 | "with the TA8 adapters.\nSpecialix is working on it.\n"); |
2078 | } | 2077 | } |
2079 | #endif | 2078 | #endif |
2080 | } | 2079 | } |
2081 | 2080 | ||
2082 | if (chans) { | 2081 | if (chans) { |
2083 | if (board->irq > 0) { | 2082 | if (board->irq > 0) { |
2084 | /* fixed irq, probably PCI */ | 2083 | /* fixed irq, probably PCI */ |
2085 | if (sx_irqmask & (1 << board->irq)) { /* may we use this irq? */ | 2084 | if (sx_irqmask & (1 << board->irq)) { /* may we use this irq? */ |
2086 | if (request_irq(board->irq, sx_interrupt, | 2085 | if (request_irq(board->irq, sx_interrupt, |
2087 | IRQF_SHARED | IRQF_DISABLED, | 2086 | IRQF_SHARED | IRQF_DISABLED, |
2088 | "sx", board)) { | 2087 | "sx", board)) { |
2089 | printk(KERN_ERR "sx: Cannot allocate " | 2088 | printk(KERN_ERR "sx: Cannot allocate " |
2090 | "irq %d.\n", board->irq); | 2089 | "irq %d.\n", board->irq); |
2091 | board->irq = 0; | 2090 | board->irq = 0; |
2092 | } | 2091 | } |
2093 | } else | 2092 | } else |
2094 | board->irq = 0; | 2093 | board->irq = 0; |
2095 | } else if (board->irq < 0 && sx_irqmask) { | 2094 | } else if (board->irq < 0 && sx_irqmask) { |
2096 | /* auto-allocate irq */ | 2095 | /* auto-allocate irq */ |
2097 | int irqnr; | 2096 | int irqnr; |
2098 | int irqmask = sx_irqmask & (IS_SX_BOARD(board) ? | 2097 | int irqmask = sx_irqmask & (IS_SX_BOARD(board) ? |
2099 | SX_ISA_IRQ_MASK : SI2_ISA_IRQ_MASK); | 2098 | SX_ISA_IRQ_MASK : SI2_ISA_IRQ_MASK); |
2100 | for (irqnr = 15; irqnr > 0; irqnr--) | 2099 | for (irqnr = 15; irqnr > 0; irqnr--) |
2101 | if (irqmask & (1 << irqnr)) | 2100 | if (irqmask & (1 << irqnr)) |
2102 | if (!request_irq(irqnr, sx_interrupt, | 2101 | if (!request_irq(irqnr, sx_interrupt, |
2103 | IRQF_SHARED | IRQF_DISABLED, | 2102 | IRQF_SHARED | IRQF_DISABLED, |
2104 | "sx", board)) | 2103 | "sx", board)) |
2105 | break; | 2104 | break; |
2106 | if (!irqnr) | 2105 | if (!irqnr) |
2107 | printk(KERN_ERR "sx: Cannot allocate IRQ.\n"); | 2106 | printk(KERN_ERR "sx: Cannot allocate IRQ.\n"); |
2108 | board->irq = irqnr; | 2107 | board->irq = irqnr; |
2109 | } else | 2108 | } else |
2110 | board->irq = 0; | 2109 | board->irq = 0; |
2111 | 2110 | ||
2112 | if (board->irq) { | 2111 | if (board->irq) { |
2113 | /* Found a valid interrupt, start up interrupts! */ | 2112 | /* Found a valid interrupt, start up interrupts! */ |
2114 | sx_dprintk(SX_DEBUG_INIT, "Using irq %d.\n", | 2113 | sx_dprintk(SX_DEBUG_INIT, "Using irq %d.\n", |
2115 | board->irq); | 2114 | board->irq); |
2116 | sx_start_interrupts(board); | 2115 | sx_start_interrupts(board); |
2117 | board->poll = sx_slowpoll; | 2116 | board->poll = sx_slowpoll; |
2118 | board->flags |= SX_IRQ_ALLOCATED; | 2117 | board->flags |= SX_IRQ_ALLOCATED; |
2119 | } else { | 2118 | } else { |
2120 | /* no irq: setup board for polled operation */ | 2119 | /* no irq: setup board for polled operation */ |
2121 | board->poll = sx_poll; | 2120 | board->poll = sx_poll; |
2122 | sx_dprintk(SX_DEBUG_INIT, "Using poll-interval %d.\n", | 2121 | sx_dprintk(SX_DEBUG_INIT, "Using poll-interval %d.\n", |
2123 | board->poll); | 2122 | board->poll); |
2124 | } | 2123 | } |
2125 | 2124 | ||
2126 | /* The timer should be initialized anyway: That way we can | 2125 | /* The timer should be initialized anyway: That way we can |
2127 | safely del_timer it when the module is unloaded. */ | 2126 | safely del_timer it when the module is unloaded. */ |
2128 | setup_timer(&board->timer, sx_pollfunc, (unsigned long)board); | 2127 | setup_timer(&board->timer, sx_pollfunc, (unsigned long)board); |
2129 | 2128 | ||
2130 | if (board->poll) | 2129 | if (board->poll) |
2131 | mod_timer(&board->timer, jiffies + board->poll); | 2130 | mod_timer(&board->timer, jiffies + board->poll); |
2132 | } else { | 2131 | } else { |
2133 | board->irq = 0; | 2132 | board->irq = 0; |
2134 | } | 2133 | } |
2135 | 2134 | ||
2136 | board->nports = chans; | 2135 | board->nports = chans; |
2137 | sx_dprintk(SX_DEBUG_INIT, "returning %d ports.", board->nports); | 2136 | sx_dprintk(SX_DEBUG_INIT, "returning %d ports.", board->nports); |
2138 | 2137 | ||
2139 | func_exit(); | 2138 | func_exit(); |
2140 | return chans; | 2139 | return chans; |
2141 | } | 2140 | } |
2142 | 2141 | ||
2143 | static void __devinit printheader(void) | 2142 | static void __devinit printheader(void) |
2144 | { | 2143 | { |
2145 | static int header_printed; | 2144 | static int header_printed; |
2146 | 2145 | ||
2147 | if (!header_printed) { | 2146 | if (!header_printed) { |
2148 | printk(KERN_INFO "Specialix SX driver " | 2147 | printk(KERN_INFO "Specialix SX driver " |
2149 | "(C) 1998/1999 R.E.Wolff@BitWizard.nl\n"); | 2148 | "(C) 1998/1999 R.E.Wolff@BitWizard.nl\n"); |
2150 | printk(KERN_INFO "sx: version " __stringify(SX_VERSION) "\n"); | 2149 | printk(KERN_INFO "sx: version " __stringify(SX_VERSION) "\n"); |
2151 | header_printed = 1; | 2150 | header_printed = 1; |
2152 | } | 2151 | } |
2153 | } | 2152 | } |
2154 | 2153 | ||
2155 | static int __devinit probe_sx(struct sx_board *board) | 2154 | static int __devinit probe_sx(struct sx_board *board) |
2156 | { | 2155 | { |
2157 | struct vpd_prom vpdp; | 2156 | struct vpd_prom vpdp; |
2158 | char *p; | 2157 | char *p; |
2159 | int i; | 2158 | int i; |
2160 | 2159 | ||
2161 | func_enter(); | 2160 | func_enter(); |
2162 | 2161 | ||
2163 | if (!IS_CF_BOARD(board)) { | 2162 | if (!IS_CF_BOARD(board)) { |
2164 | sx_dprintk(SX_DEBUG_PROBE, "Going to verify vpd prom at %p.\n", | 2163 | sx_dprintk(SX_DEBUG_PROBE, "Going to verify vpd prom at %p.\n", |
2165 | board->base + SX_VPD_ROM); | 2164 | board->base + SX_VPD_ROM); |
2166 | 2165 | ||
2167 | if (sx_debug & SX_DEBUG_PROBE) | 2166 | if (sx_debug & SX_DEBUG_PROBE) |
2168 | my_hd_io(board->base + SX_VPD_ROM, 0x40); | 2167 | my_hd_io(board->base + SX_VPD_ROM, 0x40); |
2169 | 2168 | ||
2170 | p = (char *)&vpdp; | 2169 | p = (char *)&vpdp; |
2171 | for (i = 0; i < sizeof(struct vpd_prom); i++) | 2170 | for (i = 0; i < sizeof(struct vpd_prom); i++) |
2172 | *p++ = read_sx_byte(board, SX_VPD_ROM + i * 2); | 2171 | *p++ = read_sx_byte(board, SX_VPD_ROM + i * 2); |
2173 | 2172 | ||
2174 | if (sx_debug & SX_DEBUG_PROBE) | 2173 | if (sx_debug & SX_DEBUG_PROBE) |
2175 | my_hd(&vpdp, 0x20); | 2174 | my_hd(&vpdp, 0x20); |
2176 | 2175 | ||
2177 | sx_dprintk(SX_DEBUG_PROBE, "checking identifier...\n"); | 2176 | sx_dprintk(SX_DEBUG_PROBE, "checking identifier...\n"); |
2178 | 2177 | ||
2179 | if (strncmp(vpdp.identifier, SX_VPD_IDENT_STRING, 16) != 0) { | 2178 | if (strncmp(vpdp.identifier, SX_VPD_IDENT_STRING, 16) != 0) { |
2180 | sx_dprintk(SX_DEBUG_PROBE, "Got non-SX identifier: " | 2179 | sx_dprintk(SX_DEBUG_PROBE, "Got non-SX identifier: " |
2181 | "'%s'\n", vpdp.identifier); | 2180 | "'%s'\n", vpdp.identifier); |
2182 | return 0; | 2181 | return 0; |
2183 | } | 2182 | } |
2184 | } | 2183 | } |
2185 | 2184 | ||
2186 | printheader(); | 2185 | printheader(); |
2187 | 2186 | ||
2188 | if (!IS_CF_BOARD(board)) { | 2187 | if (!IS_CF_BOARD(board)) { |
2189 | printk(KERN_DEBUG "sx: Found an SX board at %lx\n", | 2188 | printk(KERN_DEBUG "sx: Found an SX board at %lx\n", |
2190 | board->hw_base); | 2189 | board->hw_base); |
2191 | printk(KERN_DEBUG "sx: hw_rev: %d, assembly level: %d, " | 2190 | printk(KERN_DEBUG "sx: hw_rev: %d, assembly level: %d, " |
2192 | "uniq ID:%08x, ", | 2191 | "uniq ID:%08x, ", |
2193 | vpdp.hwrev, vpdp.hwass, vpdp.uniqid); | 2192 | vpdp.hwrev, vpdp.hwass, vpdp.uniqid); |
2194 | printk("Manufactured: %d/%d\n", 1970 + vpdp.myear, vpdp.mweek); | 2193 | printk("Manufactured: %d/%d\n", 1970 + vpdp.myear, vpdp.mweek); |
2195 | 2194 | ||
2196 | if ((((vpdp.uniqid >> 24) & SX_UNIQUEID_MASK) != | 2195 | if ((((vpdp.uniqid >> 24) & SX_UNIQUEID_MASK) != |
2197 | SX_PCI_UNIQUEID1) && (((vpdp.uniqid >> 24) & | 2196 | SX_PCI_UNIQUEID1) && (((vpdp.uniqid >> 24) & |
2198 | SX_UNIQUEID_MASK) != SX_ISA_UNIQUEID1)) { | 2197 | SX_UNIQUEID_MASK) != SX_ISA_UNIQUEID1)) { |
2199 | /* This might be a bit harsh. This was the primary | 2198 | /* This might be a bit harsh. This was the primary |
2200 | reason the SX/ISA card didn't work at first... */ | 2199 | reason the SX/ISA card didn't work at first... */ |
2201 | printk(KERN_ERR "sx: Hmm. Not an SX/PCI or SX/ISA " | 2200 | printk(KERN_ERR "sx: Hmm. Not an SX/PCI or SX/ISA " |
2202 | "card. Sorry: giving up.\n"); | 2201 | "card. Sorry: giving up.\n"); |
2203 | return (0); | 2202 | return (0); |
2204 | } | 2203 | } |
2205 | 2204 | ||
2206 | if (((vpdp.uniqid >> 24) & SX_UNIQUEID_MASK) == | 2205 | if (((vpdp.uniqid >> 24) & SX_UNIQUEID_MASK) == |
2207 | SX_ISA_UNIQUEID1) { | 2206 | SX_ISA_UNIQUEID1) { |
2208 | if (((unsigned long)board->hw_base) & 0x8000) { | 2207 | if (((unsigned long)board->hw_base) & 0x8000) { |
2209 | printk(KERN_WARNING "sx: Warning: There may be " | 2208 | printk(KERN_WARNING "sx: Warning: There may be " |
2210 | "hardware problems with the card at " | 2209 | "hardware problems with the card at " |
2211 | "%lx.\n", board->hw_base); | 2210 | "%lx.\n", board->hw_base); |
2212 | printk(KERN_WARNING "sx: Read sx.txt for more " | 2211 | printk(KERN_WARNING "sx: Read sx.txt for more " |
2213 | "info.\n"); | 2212 | "info.\n"); |
2214 | } | 2213 | } |
2215 | } | 2214 | } |
2216 | } | 2215 | } |
2217 | 2216 | ||
2218 | board->nports = -1; | 2217 | board->nports = -1; |
2219 | 2218 | ||
2220 | /* This resets the processor, and keeps it off the bus. */ | 2219 | /* This resets the processor, and keeps it off the bus. */ |
2221 | if (!sx_reset(board)) | 2220 | if (!sx_reset(board)) |
2222 | return 0; | 2221 | return 0; |
2223 | sx_dprintk(SX_DEBUG_INIT, "reset the board...\n"); | 2222 | sx_dprintk(SX_DEBUG_INIT, "reset the board...\n"); |
2224 | 2223 | ||
2225 | func_exit(); | 2224 | func_exit(); |
2226 | return 1; | 2225 | return 1; |
2227 | } | 2226 | } |
2228 | 2227 | ||
2229 | #if defined(CONFIG_ISA) || defined(CONFIG_EISA) | 2228 | #if defined(CONFIG_ISA) || defined(CONFIG_EISA) |
2230 | 2229 | ||
2231 | /* Specialix probes for this card at 32k increments from 640k to 16M. | 2230 | /* Specialix probes for this card at 32k increments from 640k to 16M. |
2232 | I consider machines with less than 16M unlikely nowadays, so I'm | 2231 | I consider machines with less than 16M unlikely nowadays, so I'm |
2233 | not probing above 1Mb. Also, 0xa0000, 0xb0000, are taken by the VGA | 2232 | not probing above 1Mb. Also, 0xa0000, 0xb0000, are taken by the VGA |
2234 | card. 0xe0000 and 0xf0000 are taken by the BIOS. That only leaves | 2233 | card. 0xe0000 and 0xf0000 are taken by the BIOS. That only leaves |
2235 | 0xc0000, 0xc8000, 0xd0000 and 0xd8000 . */ | 2234 | 0xc0000, 0xc8000, 0xd0000 and 0xd8000 . */ |
2236 | 2235 | ||
2237 | static int __devinit probe_si(struct sx_board *board) | 2236 | static int __devinit probe_si(struct sx_board *board) |
2238 | { | 2237 | { |
2239 | int i; | 2238 | int i; |
2240 | 2239 | ||
2241 | func_enter(); | 2240 | func_enter(); |
2242 | sx_dprintk(SX_DEBUG_PROBE, "Going to verify SI signature hw %lx at " | 2241 | sx_dprintk(SX_DEBUG_PROBE, "Going to verify SI signature hw %lx at " |
2243 | "%p.\n", board->hw_base, board->base + SI2_ISA_ID_BASE); | 2242 | "%p.\n", board->hw_base, board->base + SI2_ISA_ID_BASE); |
2244 | 2243 | ||
2245 | if (sx_debug & SX_DEBUG_PROBE) | 2244 | if (sx_debug & SX_DEBUG_PROBE) |
2246 | my_hd_io(board->base + SI2_ISA_ID_BASE, 0x8); | 2245 | my_hd_io(board->base + SI2_ISA_ID_BASE, 0x8); |
2247 | 2246 | ||
2248 | if (!IS_EISA_BOARD(board)) { | 2247 | if (!IS_EISA_BOARD(board)) { |
2249 | if (IS_SI1_BOARD(board)) { | 2248 | if (IS_SI1_BOARD(board)) { |
2250 | for (i = 0; i < 8; i++) { | 2249 | for (i = 0; i < 8; i++) { |
2251 | write_sx_byte(board, SI2_ISA_ID_BASE + 7 - i,i); | 2250 | write_sx_byte(board, SI2_ISA_ID_BASE + 7 - i,i); |
2252 | } | 2251 | } |
2253 | } | 2252 | } |
2254 | for (i = 0; i < 8; i++) { | 2253 | for (i = 0; i < 8; i++) { |
2255 | if ((read_sx_byte(board, SI2_ISA_ID_BASE + 7 - i) & 7) | 2254 | if ((read_sx_byte(board, SI2_ISA_ID_BASE + 7 - i) & 7) |
2256 | != i) { | 2255 | != i) { |
2257 | func_exit(); | 2256 | func_exit(); |
2258 | return 0; | 2257 | return 0; |
2259 | } | 2258 | } |
2260 | } | 2259 | } |
2261 | } | 2260 | } |
2262 | 2261 | ||
2263 | /* Now we're pretty much convinced that there is an SI board here, | 2262 | /* Now we're pretty much convinced that there is an SI board here, |
2264 | but to prevent trouble, we'd better double check that we don't | 2263 | but to prevent trouble, we'd better double check that we don't |
2265 | have an SI1 board when we're probing for an SI2 board.... */ | 2264 | have an SI1 board when we're probing for an SI2 board.... */ |
2266 | 2265 | ||
2267 | write_sx_byte(board, SI2_ISA_ID_BASE, 0x10); | 2266 | write_sx_byte(board, SI2_ISA_ID_BASE, 0x10); |
2268 | if (IS_SI1_BOARD(board)) { | 2267 | if (IS_SI1_BOARD(board)) { |
2269 | /* This should be an SI1 board, which has this | 2268 | /* This should be an SI1 board, which has this |
2270 | location writable... */ | 2269 | location writable... */ |
2271 | if (read_sx_byte(board, SI2_ISA_ID_BASE) != 0x10) { | 2270 | if (read_sx_byte(board, SI2_ISA_ID_BASE) != 0x10) { |
2272 | func_exit(); | 2271 | func_exit(); |
2273 | return 0; | 2272 | return 0; |
2274 | } | 2273 | } |
2275 | } else { | 2274 | } else { |
2276 | /* This should be an SI2 board, which has the bottom | 2275 | /* This should be an SI2 board, which has the bottom |
2277 | 3 bits non-writable... */ | 2276 | 3 bits non-writable... */ |
2278 | if (read_sx_byte(board, SI2_ISA_ID_BASE) == 0x10) { | 2277 | if (read_sx_byte(board, SI2_ISA_ID_BASE) == 0x10) { |
2279 | func_exit(); | 2278 | func_exit(); |
2280 | return 0; | 2279 | return 0; |
2281 | } | 2280 | } |
2282 | } | 2281 | } |
2283 | 2282 | ||
2284 | /* Now we're pretty much convinced that there is an SI board here, | 2283 | /* Now we're pretty much convinced that there is an SI board here, |
2285 | but to prevent trouble, we'd better double check that we don't | 2284 | but to prevent trouble, we'd better double check that we don't |
2286 | have an SI1 board when we're probing for an SI2 board.... */ | 2285 | have an SI1 board when we're probing for an SI2 board.... */ |
2287 | 2286 | ||
2288 | write_sx_byte(board, SI2_ISA_ID_BASE, 0x10); | 2287 | write_sx_byte(board, SI2_ISA_ID_BASE, 0x10); |
2289 | if (IS_SI1_BOARD(board)) { | 2288 | if (IS_SI1_BOARD(board)) { |
2290 | /* This should be an SI1 board, which has this | 2289 | /* This should be an SI1 board, which has this |
2291 | location writable... */ | 2290 | location writable... */ |
2292 | if (read_sx_byte(board, SI2_ISA_ID_BASE) != 0x10) { | 2291 | if (read_sx_byte(board, SI2_ISA_ID_BASE) != 0x10) { |
2293 | func_exit(); | 2292 | func_exit(); |
2294 | return 0; | 2293 | return 0; |
2295 | } | 2294 | } |
2296 | } else { | 2295 | } else { |
2297 | /* This should be an SI2 board, which has the bottom | 2296 | /* This should be an SI2 board, which has the bottom |
2298 | 3 bits non-writable... */ | 2297 | 3 bits non-writable... */ |
2299 | if (read_sx_byte(board, SI2_ISA_ID_BASE) == 0x10) { | 2298 | if (read_sx_byte(board, SI2_ISA_ID_BASE) == 0x10) { |
2300 | func_exit(); | 2299 | func_exit(); |
2301 | return 0; | 2300 | return 0; |
2302 | } | 2301 | } |
2303 | } | 2302 | } |
2304 | 2303 | ||
2305 | printheader(); | 2304 | printheader(); |
2306 | 2305 | ||
2307 | printk(KERN_DEBUG "sx: Found an SI board at %lx\n", board->hw_base); | 2306 | printk(KERN_DEBUG "sx: Found an SI board at %lx\n", board->hw_base); |
2308 | /* Compared to the SX boards, it is a complete guess as to what | 2307 | /* Compared to the SX boards, it is a complete guess as to what |
2309 | this card is up to... */ | 2308 | this card is up to... */ |
2310 | 2309 | ||
2311 | board->nports = -1; | 2310 | board->nports = -1; |
2312 | 2311 | ||
2313 | /* This resets the processor, and keeps it off the bus. */ | 2312 | /* This resets the processor, and keeps it off the bus. */ |
2314 | if (!sx_reset(board)) | 2313 | if (!sx_reset(board)) |
2315 | return 0; | 2314 | return 0; |
2316 | sx_dprintk(SX_DEBUG_INIT, "reset the board...\n"); | 2315 | sx_dprintk(SX_DEBUG_INIT, "reset the board...\n"); |
2317 | 2316 | ||
2318 | func_exit(); | 2317 | func_exit(); |
2319 | return 1; | 2318 | return 1; |
2320 | } | 2319 | } |
2321 | #endif | 2320 | #endif |
2322 | 2321 | ||
2323 | static const struct tty_operations sx_ops = { | 2322 | static const struct tty_operations sx_ops = { |
2324 | .break_ctl = sx_break, | 2323 | .break_ctl = sx_break, |
2325 | .open = sx_open, | 2324 | .open = sx_open, |
2326 | .close = gs_close, | 2325 | .close = gs_close, |
2327 | .write = gs_write, | 2326 | .write = gs_write, |
2328 | .put_char = gs_put_char, | 2327 | .put_char = gs_put_char, |
2329 | .flush_chars = gs_flush_chars, | 2328 | .flush_chars = gs_flush_chars, |
2330 | .write_room = gs_write_room, | 2329 | .write_room = gs_write_room, |
2331 | .chars_in_buffer = gs_chars_in_buffer, | 2330 | .chars_in_buffer = gs_chars_in_buffer, |
2332 | .flush_buffer = gs_flush_buffer, | 2331 | .flush_buffer = gs_flush_buffer, |
2333 | .ioctl = sx_ioctl, | 2332 | .ioctl = sx_ioctl, |
2334 | .throttle = sx_throttle, | 2333 | .throttle = sx_throttle, |
2335 | .unthrottle = sx_unthrottle, | 2334 | .unthrottle = sx_unthrottle, |
2336 | .set_termios = gs_set_termios, | 2335 | .set_termios = gs_set_termios, |
2337 | .stop = gs_stop, | 2336 | .stop = gs_stop, |
2338 | .start = gs_start, | 2337 | .start = gs_start, |
2339 | .hangup = gs_hangup, | 2338 | .hangup = gs_hangup, |
2340 | .tiocmget = sx_tiocmget, | 2339 | .tiocmget = sx_tiocmget, |
2341 | .tiocmset = sx_tiocmset, | 2340 | .tiocmset = sx_tiocmset, |
2342 | }; | 2341 | }; |
2343 | 2342 | ||
2344 | static int sx_init_drivers(void) | 2343 | static int sx_init_drivers(void) |
2345 | { | 2344 | { |
2346 | int error; | 2345 | int error; |
2347 | 2346 | ||
2348 | func_enter(); | 2347 | func_enter(); |
2349 | 2348 | ||
2350 | sx_driver = alloc_tty_driver(sx_nports); | 2349 | sx_driver = alloc_tty_driver(sx_nports); |
2351 | if (!sx_driver) | 2350 | if (!sx_driver) |
2352 | return 1; | 2351 | return 1; |
2353 | sx_driver->owner = THIS_MODULE; | 2352 | sx_driver->owner = THIS_MODULE; |
2354 | sx_driver->driver_name = "specialix_sx"; | 2353 | sx_driver->driver_name = "specialix_sx"; |
2355 | sx_driver->name = "ttyX"; | 2354 | sx_driver->name = "ttyX"; |
2356 | sx_driver->major = SX_NORMAL_MAJOR; | 2355 | sx_driver->major = SX_NORMAL_MAJOR; |
2357 | sx_driver->type = TTY_DRIVER_TYPE_SERIAL; | 2356 | sx_driver->type = TTY_DRIVER_TYPE_SERIAL; |
2358 | sx_driver->subtype = SERIAL_TYPE_NORMAL; | 2357 | sx_driver->subtype = SERIAL_TYPE_NORMAL; |
2359 | sx_driver->init_termios = tty_std_termios; | 2358 | sx_driver->init_termios = tty_std_termios; |
2360 | sx_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; | 2359 | sx_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; |
2361 | sx_driver->init_termios.c_ispeed = 9600; | 2360 | sx_driver->init_termios.c_ispeed = 9600; |
2362 | sx_driver->init_termios.c_ospeed = 9600; | 2361 | sx_driver->init_termios.c_ospeed = 9600; |
2363 | sx_driver->flags = TTY_DRIVER_REAL_RAW; | 2362 | sx_driver->flags = TTY_DRIVER_REAL_RAW; |
2364 | tty_set_operations(sx_driver, &sx_ops); | 2363 | tty_set_operations(sx_driver, &sx_ops); |
2365 | 2364 | ||
2366 | if ((error = tty_register_driver(sx_driver))) { | 2365 | if ((error = tty_register_driver(sx_driver))) { |
2367 | put_tty_driver(sx_driver); | 2366 | put_tty_driver(sx_driver); |
2368 | printk(KERN_ERR "sx: Couldn't register sx driver, error = %d\n", | 2367 | printk(KERN_ERR "sx: Couldn't register sx driver, error = %d\n", |
2369 | error); | 2368 | error); |
2370 | return 1; | 2369 | return 1; |
2371 | } | 2370 | } |
2372 | func_exit(); | 2371 | func_exit(); |
2373 | return 0; | 2372 | return 0; |
2374 | } | 2373 | } |
2375 | 2374 | ||
2376 | static int sx_init_portstructs(int nboards, int nports) | 2375 | static int sx_init_portstructs(int nboards, int nports) |
2377 | { | 2376 | { |
2378 | struct sx_board *board; | 2377 | struct sx_board *board; |
2379 | struct sx_port *port; | 2378 | struct sx_port *port; |
2380 | int i, j; | 2379 | int i, j; |
2381 | int addr, chans; | 2380 | int addr, chans; |
2382 | int portno; | 2381 | int portno; |
2383 | 2382 | ||
2384 | func_enter(); | 2383 | func_enter(); |
2385 | 2384 | ||
2386 | /* Many drivers statically allocate the maximum number of ports | 2385 | /* Many drivers statically allocate the maximum number of ports |
2387 | There is no reason not to allocate them dynamically. | 2386 | There is no reason not to allocate them dynamically. |
2388 | Is there? -- REW */ | 2387 | Is there? -- REW */ |
2389 | sx_ports = kcalloc(nports, sizeof(struct sx_port), GFP_KERNEL); | 2388 | sx_ports = kcalloc(nports, sizeof(struct sx_port), GFP_KERNEL); |
2390 | if (!sx_ports) | 2389 | if (!sx_ports) |
2391 | return -ENOMEM; | 2390 | return -ENOMEM; |
2392 | 2391 | ||
2393 | port = sx_ports; | 2392 | port = sx_ports; |
2394 | for (i = 0; i < nboards; i++) { | 2393 | for (i = 0; i < nboards; i++) { |
2395 | board = &boards[i]; | 2394 | board = &boards[i]; |
2396 | board->ports = port; | 2395 | board->ports = port; |
2397 | for (j = 0; j < boards[i].nports; j++) { | 2396 | for (j = 0; j < boards[i].nports; j++) { |
2398 | sx_dprintk(SX_DEBUG_INIT, "initing port %d\n", j); | 2397 | sx_dprintk(SX_DEBUG_INIT, "initing port %d\n", j); |
2399 | port->gs.magic = SX_MAGIC; | 2398 | port->gs.magic = SX_MAGIC; |
2400 | port->gs.close_delay = HZ / 2; | 2399 | port->gs.close_delay = HZ / 2; |
2401 | port->gs.closing_wait = 30 * HZ; | 2400 | port->gs.closing_wait = 30 * HZ; |
2402 | port->board = board; | 2401 | port->board = board; |
2403 | port->gs.rd = &sx_real_driver; | 2402 | port->gs.rd = &sx_real_driver; |
2404 | #ifdef NEW_WRITE_LOCKING | 2403 | #ifdef NEW_WRITE_LOCKING |
2405 | port->gs.port_write_mutex = MUTEX; | 2404 | port->gs.port_write_mutex = MUTEX; |
2406 | #endif | 2405 | #endif |
2407 | spin_lock_init(&port->gs.driver_lock); | 2406 | spin_lock_init(&port->gs.driver_lock); |
2408 | /* | 2407 | /* |
2409 | * Initializing wait queue | 2408 | * Initializing wait queue |
2410 | */ | 2409 | */ |
2411 | init_waitqueue_head(&port->gs.open_wait); | 2410 | tty_port_init(&port->gs.port); |
2412 | init_waitqueue_head(&port->gs.close_wait); | ||
2413 | |||
2414 | port++; | 2411 | port++; |
2415 | } | 2412 | } |
2416 | } | 2413 | } |
2417 | 2414 | ||
2418 | port = sx_ports; | 2415 | port = sx_ports; |
2419 | portno = 0; | 2416 | portno = 0; |
2420 | for (i = 0; i < nboards; i++) { | 2417 | for (i = 0; i < nboards; i++) { |
2421 | board = &boards[i]; | 2418 | board = &boards[i]; |
2422 | board->port_base = portno; | 2419 | board->port_base = portno; |
2423 | /* Possibly the configuration was rejected. */ | 2420 | /* Possibly the configuration was rejected. */ |
2424 | sx_dprintk(SX_DEBUG_PROBE, "Board has %d channels\n", | 2421 | sx_dprintk(SX_DEBUG_PROBE, "Board has %d channels\n", |
2425 | board->nports); | 2422 | board->nports); |
2426 | if (board->nports <= 0) | 2423 | if (board->nports <= 0) |
2427 | continue; | 2424 | continue; |
2428 | /* XXX byteorder ?? */ | 2425 | /* XXX byteorder ?? */ |
2429 | for (addr = 0x80; addr != 0; | 2426 | for (addr = 0x80; addr != 0; |
2430 | addr = read_sx_word(board, addr) & 0x7fff) { | 2427 | addr = read_sx_word(board, addr) & 0x7fff) { |
2431 | chans = sx_read_module_byte(board, addr, mc_type); | 2428 | chans = sx_read_module_byte(board, addr, mc_type); |
2432 | sx_dprintk(SX_DEBUG_PROBE, "Module at %x: %d " | 2429 | sx_dprintk(SX_DEBUG_PROBE, "Module at %x: %d " |
2433 | "channels\n", addr, chans); | 2430 | "channels\n", addr, chans); |
2434 | sx_dprintk(SX_DEBUG_PROBE, "Port at"); | 2431 | sx_dprintk(SX_DEBUG_PROBE, "Port at"); |
2435 | for (j = 0; j < chans; j++) { | 2432 | for (j = 0; j < chans; j++) { |
2436 | /* The "sx-way" is the way it SHOULD be done. | 2433 | /* The "sx-way" is the way it SHOULD be done. |
2437 | That way in the future, the firmware may for | 2434 | That way in the future, the firmware may for |
2438 | example pack the structures a bit more | 2435 | example pack the structures a bit more |
2439 | efficient. Neil tells me it isn't going to | 2436 | efficient. Neil tells me it isn't going to |
2440 | happen anytime soon though. */ | 2437 | happen anytime soon though. */ |
2441 | if (IS_SX_BOARD(board)) | 2438 | if (IS_SX_BOARD(board)) |
2442 | port->ch_base = sx_read_module_word( | 2439 | port->ch_base = sx_read_module_word( |
2443 | board, addr + j * 2, | 2440 | board, addr + j * 2, |
2444 | mc_chan_pointer); | 2441 | mc_chan_pointer); |
2445 | else | 2442 | else |
2446 | port->ch_base = addr + 0x100 + 0x300 *j; | 2443 | port->ch_base = addr + 0x100 + 0x300 *j; |
2447 | 2444 | ||
2448 | sx_dprintk(SX_DEBUG_PROBE, " %x", | 2445 | sx_dprintk(SX_DEBUG_PROBE, " %x", |
2449 | port->ch_base); | 2446 | port->ch_base); |
2450 | port->line = portno++; | 2447 | port->line = portno++; |
2451 | port++; | 2448 | port++; |
2452 | } | 2449 | } |
2453 | sx_dprintk(SX_DEBUG_PROBE, "\n"); | 2450 | sx_dprintk(SX_DEBUG_PROBE, "\n"); |
2454 | } | 2451 | } |
2455 | /* This has to be done earlier. */ | 2452 | /* This has to be done earlier. */ |
2456 | /* board->flags |= SX_BOARD_INITIALIZED; */ | 2453 | /* board->flags |= SX_BOARD_INITIALIZED; */ |
2457 | } | 2454 | } |
2458 | 2455 | ||
2459 | func_exit(); | 2456 | func_exit(); |
2460 | return 0; | 2457 | return 0; |
2461 | } | 2458 | } |
2462 | 2459 | ||
2463 | static unsigned int sx_find_free_board(void) | 2460 | static unsigned int sx_find_free_board(void) |
2464 | { | 2461 | { |
2465 | unsigned int i; | 2462 | unsigned int i; |
2466 | 2463 | ||
2467 | for (i = 0; i < SX_NBOARDS; i++) | 2464 | for (i = 0; i < SX_NBOARDS; i++) |
2468 | if (!(boards[i].flags & SX_BOARD_PRESENT)) | 2465 | if (!(boards[i].flags & SX_BOARD_PRESENT)) |
2469 | break; | 2466 | break; |
2470 | 2467 | ||
2471 | return i; | 2468 | return i; |
2472 | } | 2469 | } |
2473 | 2470 | ||
2474 | static void __exit sx_release_drivers(void) | 2471 | static void __exit sx_release_drivers(void) |
2475 | { | 2472 | { |
2476 | func_enter(); | 2473 | func_enter(); |
2477 | tty_unregister_driver(sx_driver); | 2474 | tty_unregister_driver(sx_driver); |
2478 | put_tty_driver(sx_driver); | 2475 | put_tty_driver(sx_driver); |
2479 | func_exit(); | 2476 | func_exit(); |
2480 | } | 2477 | } |
2481 | 2478 | ||
2482 | static void __devexit sx_remove_card(struct sx_board *board, | 2479 | static void __devexit sx_remove_card(struct sx_board *board, |
2483 | struct pci_dev *pdev) | 2480 | struct pci_dev *pdev) |
2484 | { | 2481 | { |
2485 | if (board->flags & SX_BOARD_INITIALIZED) { | 2482 | if (board->flags & SX_BOARD_INITIALIZED) { |
2486 | /* The board should stop messing with us. (actually I mean the | 2483 | /* The board should stop messing with us. (actually I mean the |
2487 | interrupt) */ | 2484 | interrupt) */ |
2488 | sx_reset(board); | 2485 | sx_reset(board); |
2489 | if ((board->irq) && (board->flags & SX_IRQ_ALLOCATED)) | 2486 | if ((board->irq) && (board->flags & SX_IRQ_ALLOCATED)) |
2490 | free_irq(board->irq, board); | 2487 | free_irq(board->irq, board); |
2491 | 2488 | ||
2492 | /* It is safe/allowed to del_timer a non-active timer */ | 2489 | /* It is safe/allowed to del_timer a non-active timer */ |
2493 | del_timer(&board->timer); | 2490 | del_timer(&board->timer); |
2494 | if (pdev) { | 2491 | if (pdev) { |
2495 | #ifdef CONFIG_PCI | 2492 | #ifdef CONFIG_PCI |
2496 | pci_iounmap(pdev, board->base); | 2493 | pci_iounmap(pdev, board->base); |
2497 | pci_release_region(pdev, IS_CF_BOARD(board) ? 3 : 2); | 2494 | pci_release_region(pdev, IS_CF_BOARD(board) ? 3 : 2); |
2498 | #endif | 2495 | #endif |
2499 | } else { | 2496 | } else { |
2500 | iounmap(board->base); | 2497 | iounmap(board->base); |
2501 | release_region(board->hw_base, board->hw_len); | 2498 | release_region(board->hw_base, board->hw_len); |
2502 | } | 2499 | } |
2503 | 2500 | ||
2504 | board->flags &= ~(SX_BOARD_INITIALIZED | SX_BOARD_PRESENT); | 2501 | board->flags &= ~(SX_BOARD_INITIALIZED | SX_BOARD_PRESENT); |
2505 | } | 2502 | } |
2506 | } | 2503 | } |
2507 | 2504 | ||
2508 | #ifdef CONFIG_EISA | 2505 | #ifdef CONFIG_EISA |
2509 | 2506 | ||
2510 | static int __devinit sx_eisa_probe(struct device *dev) | 2507 | static int __devinit sx_eisa_probe(struct device *dev) |
2511 | { | 2508 | { |
2512 | struct eisa_device *edev = to_eisa_device(dev); | 2509 | struct eisa_device *edev = to_eisa_device(dev); |
2513 | struct sx_board *board; | 2510 | struct sx_board *board; |
2514 | unsigned long eisa_slot = edev->base_addr; | 2511 | unsigned long eisa_slot = edev->base_addr; |
2515 | unsigned int i; | 2512 | unsigned int i; |
2516 | int retval = -EIO; | 2513 | int retval = -EIO; |
2517 | 2514 | ||
2518 | mutex_lock(&sx_boards_lock); | 2515 | mutex_lock(&sx_boards_lock); |
2519 | i = sx_find_free_board(); | 2516 | i = sx_find_free_board(); |
2520 | if (i == SX_NBOARDS) { | 2517 | if (i == SX_NBOARDS) { |
2521 | mutex_unlock(&sx_boards_lock); | 2518 | mutex_unlock(&sx_boards_lock); |
2522 | goto err; | 2519 | goto err; |
2523 | } | 2520 | } |
2524 | board = &boards[i]; | 2521 | board = &boards[i]; |
2525 | board->flags |= SX_BOARD_PRESENT; | 2522 | board->flags |= SX_BOARD_PRESENT; |
2526 | mutex_unlock(&sx_boards_lock); | 2523 | mutex_unlock(&sx_boards_lock); |
2527 | 2524 | ||
2528 | dev_info(dev, "XIO : Signature found in EISA slot %lu, " | 2525 | dev_info(dev, "XIO : Signature found in EISA slot %lu, " |
2529 | "Product %d Rev %d (REPORT THIS TO LKLM)\n", | 2526 | "Product %d Rev %d (REPORT THIS TO LKLM)\n", |
2530 | eisa_slot >> 12, | 2527 | eisa_slot >> 12, |
2531 | inb(eisa_slot + EISA_VENDOR_ID_OFFSET + 2), | 2528 | inb(eisa_slot + EISA_VENDOR_ID_OFFSET + 2), |
2532 | inb(eisa_slot + EISA_VENDOR_ID_OFFSET + 3)); | 2529 | inb(eisa_slot + EISA_VENDOR_ID_OFFSET + 3)); |
2533 | 2530 | ||
2534 | board->eisa_base = eisa_slot; | 2531 | board->eisa_base = eisa_slot; |
2535 | board->flags &= ~SX_BOARD_TYPE; | 2532 | board->flags &= ~SX_BOARD_TYPE; |
2536 | board->flags |= SI_EISA_BOARD; | 2533 | board->flags |= SI_EISA_BOARD; |
2537 | 2534 | ||
2538 | board->hw_base = ((inb(eisa_slot + 0xc01) << 8) + | 2535 | board->hw_base = ((inb(eisa_slot + 0xc01) << 8) + |
2539 | inb(eisa_slot + 0xc00)) << 16; | 2536 | inb(eisa_slot + 0xc00)) << 16; |
2540 | board->hw_len = SI2_EISA_WINDOW_LEN; | 2537 | board->hw_len = SI2_EISA_WINDOW_LEN; |
2541 | if (!request_region(board->hw_base, board->hw_len, "sx")) { | 2538 | if (!request_region(board->hw_base, board->hw_len, "sx")) { |
2542 | dev_err(dev, "can't request region\n"); | 2539 | dev_err(dev, "can't request region\n"); |
2543 | goto err_flag; | 2540 | goto err_flag; |
2544 | } | 2541 | } |
2545 | board->base2 = | 2542 | board->base2 = |
2546 | board->base = ioremap_nocache(board->hw_base, SI2_EISA_WINDOW_LEN); | 2543 | board->base = ioremap_nocache(board->hw_base, SI2_EISA_WINDOW_LEN); |
2547 | if (!board->base) { | 2544 | if (!board->base) { |
2548 | dev_err(dev, "can't remap memory\n"); | 2545 | dev_err(dev, "can't remap memory\n"); |
2549 | goto err_reg; | 2546 | goto err_reg; |
2550 | } | 2547 | } |
2551 | 2548 | ||
2552 | sx_dprintk(SX_DEBUG_PROBE, "IO hw_base address: %lx\n", board->hw_base); | 2549 | sx_dprintk(SX_DEBUG_PROBE, "IO hw_base address: %lx\n", board->hw_base); |
2553 | sx_dprintk(SX_DEBUG_PROBE, "base: %p\n", board->base); | 2550 | sx_dprintk(SX_DEBUG_PROBE, "base: %p\n", board->base); |
2554 | board->irq = inb(eisa_slot + 0xc02) >> 4; | 2551 | board->irq = inb(eisa_slot + 0xc02) >> 4; |
2555 | sx_dprintk(SX_DEBUG_PROBE, "IRQ: %d\n", board->irq); | 2552 | sx_dprintk(SX_DEBUG_PROBE, "IRQ: %d\n", board->irq); |
2556 | 2553 | ||
2557 | if (!probe_si(board)) | 2554 | if (!probe_si(board)) |
2558 | goto err_unmap; | 2555 | goto err_unmap; |
2559 | 2556 | ||
2560 | dev_set_drvdata(dev, board); | 2557 | dev_set_drvdata(dev, board); |
2561 | 2558 | ||
2562 | return 0; | 2559 | return 0; |
2563 | err_unmap: | 2560 | err_unmap: |
2564 | iounmap(board->base); | 2561 | iounmap(board->base); |
2565 | err_reg: | 2562 | err_reg: |
2566 | release_region(board->hw_base, board->hw_len); | 2563 | release_region(board->hw_base, board->hw_len); |
2567 | err_flag: | 2564 | err_flag: |
2568 | board->flags &= ~SX_BOARD_PRESENT; | 2565 | board->flags &= ~SX_BOARD_PRESENT; |
2569 | err: | 2566 | err: |
2570 | return retval; | 2567 | return retval; |
2571 | } | 2568 | } |
2572 | 2569 | ||
2573 | static int __devexit sx_eisa_remove(struct device *dev) | 2570 | static int __devexit sx_eisa_remove(struct device *dev) |
2574 | { | 2571 | { |
2575 | struct sx_board *board = dev_get_drvdata(dev); | 2572 | struct sx_board *board = dev_get_drvdata(dev); |
2576 | 2573 | ||
2577 | sx_remove_card(board, NULL); | 2574 | sx_remove_card(board, NULL); |
2578 | 2575 | ||
2579 | return 0; | 2576 | return 0; |
2580 | } | 2577 | } |
2581 | 2578 | ||
2582 | static struct eisa_device_id sx_eisa_tbl[] = { | 2579 | static struct eisa_device_id sx_eisa_tbl[] = { |
2583 | { "SLX" }, | 2580 | { "SLX" }, |
2584 | { "" } | 2581 | { "" } |
2585 | }; | 2582 | }; |
2586 | 2583 | ||
2587 | MODULE_DEVICE_TABLE(eisa, sx_eisa_tbl); | 2584 | MODULE_DEVICE_TABLE(eisa, sx_eisa_tbl); |
2588 | 2585 | ||
2589 | static struct eisa_driver sx_eisadriver = { | 2586 | static struct eisa_driver sx_eisadriver = { |
2590 | .id_table = sx_eisa_tbl, | 2587 | .id_table = sx_eisa_tbl, |
2591 | .driver = { | 2588 | .driver = { |
2592 | .name = "sx", | 2589 | .name = "sx", |
2593 | .probe = sx_eisa_probe, | 2590 | .probe = sx_eisa_probe, |
2594 | .remove = __devexit_p(sx_eisa_remove), | 2591 | .remove = __devexit_p(sx_eisa_remove), |
2595 | } | 2592 | } |
2596 | }; | 2593 | }; |
2597 | 2594 | ||
2598 | #endif | 2595 | #endif |
2599 | 2596 | ||
2600 | #ifdef CONFIG_PCI | 2597 | #ifdef CONFIG_PCI |
2601 | /******************************************************** | 2598 | /******************************************************** |
2602 | * Setting bit 17 in the CNTRL register of the PLX 9050 * | 2599 | * Setting bit 17 in the CNTRL register of the PLX 9050 * |
2603 | * chip forces a retry on writes while a read is pending.* | 2600 | * chip forces a retry on writes while a read is pending.* |
2604 | * This is to prevent the card locking up on Intel Xeon * | 2601 | * This is to prevent the card locking up on Intel Xeon * |
2605 | * multiprocessor systems with the NX chipset. -- NV * | 2602 | * multiprocessor systems with the NX chipset. -- NV * |
2606 | ********************************************************/ | 2603 | ********************************************************/ |
2607 | 2604 | ||
2608 | /* Newer cards are produced with this bit set from the configuration | 2605 | /* Newer cards are produced with this bit set from the configuration |
2609 | EEprom. As the bit is read/write for the CPU, we can fix it here, | 2606 | EEprom. As the bit is read/write for the CPU, we can fix it here, |
2610 | if we detect that it isn't set correctly. -- REW */ | 2607 | if we detect that it isn't set correctly. -- REW */ |
2611 | 2608 | ||
2612 | static void __devinit fix_sx_pci(struct pci_dev *pdev, struct sx_board *board) | 2609 | static void __devinit fix_sx_pci(struct pci_dev *pdev, struct sx_board *board) |
2613 | { | 2610 | { |
2614 | unsigned int hwbase; | 2611 | unsigned int hwbase; |
2615 | void __iomem *rebase; | 2612 | void __iomem *rebase; |
2616 | unsigned int t; | 2613 | unsigned int t; |
2617 | 2614 | ||
2618 | #define CNTRL_REG_OFFSET 0x50 | 2615 | #define CNTRL_REG_OFFSET 0x50 |
2619 | #define CNTRL_REG_GOODVALUE 0x18260000 | 2616 | #define CNTRL_REG_GOODVALUE 0x18260000 |
2620 | 2617 | ||
2621 | pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase); | 2618 | pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase); |
2622 | hwbase &= PCI_BASE_ADDRESS_MEM_MASK; | 2619 | hwbase &= PCI_BASE_ADDRESS_MEM_MASK; |
2623 | rebase = ioremap_nocache(hwbase, 0x80); | 2620 | rebase = ioremap_nocache(hwbase, 0x80); |
2624 | t = readl(rebase + CNTRL_REG_OFFSET); | 2621 | t = readl(rebase + CNTRL_REG_OFFSET); |
2625 | if (t != CNTRL_REG_GOODVALUE) { | 2622 | if (t != CNTRL_REG_GOODVALUE) { |
2626 | printk(KERN_DEBUG "sx: performing cntrl reg fix: %08x -> " | 2623 | printk(KERN_DEBUG "sx: performing cntrl reg fix: %08x -> " |
2627 | "%08x\n", t, CNTRL_REG_GOODVALUE); | 2624 | "%08x\n", t, CNTRL_REG_GOODVALUE); |
2628 | writel(CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET); | 2625 | writel(CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET); |
2629 | } | 2626 | } |
2630 | iounmap(rebase); | 2627 | iounmap(rebase); |
2631 | } | 2628 | } |
2632 | #endif | 2629 | #endif |
2633 | 2630 | ||
2634 | static int __devinit sx_pci_probe(struct pci_dev *pdev, | 2631 | static int __devinit sx_pci_probe(struct pci_dev *pdev, |
2635 | const struct pci_device_id *ent) | 2632 | const struct pci_device_id *ent) |
2636 | { | 2633 | { |
2637 | #ifdef CONFIG_PCI | 2634 | #ifdef CONFIG_PCI |
2638 | struct sx_board *board; | 2635 | struct sx_board *board; |
2639 | unsigned int i, reg; | 2636 | unsigned int i, reg; |
2640 | int retval = -EIO; | 2637 | int retval = -EIO; |
2641 | 2638 | ||
2642 | mutex_lock(&sx_boards_lock); | 2639 | mutex_lock(&sx_boards_lock); |
2643 | i = sx_find_free_board(); | 2640 | i = sx_find_free_board(); |
2644 | if (i == SX_NBOARDS) { | 2641 | if (i == SX_NBOARDS) { |
2645 | mutex_unlock(&sx_boards_lock); | 2642 | mutex_unlock(&sx_boards_lock); |
2646 | goto err; | 2643 | goto err; |
2647 | } | 2644 | } |
2648 | board = &boards[i]; | 2645 | board = &boards[i]; |
2649 | board->flags |= SX_BOARD_PRESENT; | 2646 | board->flags |= SX_BOARD_PRESENT; |
2650 | mutex_unlock(&sx_boards_lock); | 2647 | mutex_unlock(&sx_boards_lock); |
2651 | 2648 | ||
2652 | retval = pci_enable_device(pdev); | 2649 | retval = pci_enable_device(pdev); |
2653 | if (retval) | 2650 | if (retval) |
2654 | goto err_flag; | 2651 | goto err_flag; |
2655 | 2652 | ||
2656 | board->flags &= ~SX_BOARD_TYPE; | 2653 | board->flags &= ~SX_BOARD_TYPE; |
2657 | board->flags |= (pdev->subsystem_vendor == 0x200) ? SX_PCI_BOARD : | 2654 | board->flags |= (pdev->subsystem_vendor == 0x200) ? SX_PCI_BOARD : |
2658 | SX_CFPCI_BOARD; | 2655 | SX_CFPCI_BOARD; |
2659 | 2656 | ||
2660 | /* CF boards use base address 3.... */ | 2657 | /* CF boards use base address 3.... */ |
2661 | reg = IS_CF_BOARD(board) ? 3 : 2; | 2658 | reg = IS_CF_BOARD(board) ? 3 : 2; |
2662 | retval = pci_request_region(pdev, reg, "sx"); | 2659 | retval = pci_request_region(pdev, reg, "sx"); |
2663 | if (retval) { | 2660 | if (retval) { |
2664 | dev_err(&pdev->dev, "can't request region\n"); | 2661 | dev_err(&pdev->dev, "can't request region\n"); |
2665 | goto err_flag; | 2662 | goto err_flag; |
2666 | } | 2663 | } |
2667 | board->hw_base = pci_resource_start(pdev, reg); | 2664 | board->hw_base = pci_resource_start(pdev, reg); |
2668 | board->base2 = | 2665 | board->base2 = |
2669 | board->base = pci_iomap(pdev, reg, WINDOW_LEN(board)); | 2666 | board->base = pci_iomap(pdev, reg, WINDOW_LEN(board)); |
2670 | if (!board->base) { | 2667 | if (!board->base) { |
2671 | dev_err(&pdev->dev, "ioremap failed\n"); | 2668 | dev_err(&pdev->dev, "ioremap failed\n"); |
2672 | goto err_reg; | 2669 | goto err_reg; |
2673 | } | 2670 | } |
2674 | 2671 | ||
2675 | /* Most of the stuff on the CF board is offset by 0x18000 .... */ | 2672 | /* Most of the stuff on the CF board is offset by 0x18000 .... */ |
2676 | if (IS_CF_BOARD(board)) | 2673 | if (IS_CF_BOARD(board)) |
2677 | board->base += 0x18000; | 2674 | board->base += 0x18000; |
2678 | 2675 | ||
2679 | board->irq = pdev->irq; | 2676 | board->irq = pdev->irq; |
2680 | 2677 | ||
2681 | dev_info(&pdev->dev, "Got a specialix card: %p(%d) %x.\n", board->base, | 2678 | dev_info(&pdev->dev, "Got a specialix card: %p(%d) %x.\n", board->base, |
2682 | board->irq, board->flags); | 2679 | board->irq, board->flags); |
2683 | 2680 | ||
2684 | if (!probe_sx(board)) { | 2681 | if (!probe_sx(board)) { |
2685 | retval = -EIO; | 2682 | retval = -EIO; |
2686 | goto err_unmap; | 2683 | goto err_unmap; |
2687 | } | 2684 | } |
2688 | 2685 | ||
2689 | fix_sx_pci(pdev, board); | 2686 | fix_sx_pci(pdev, board); |
2690 | 2687 | ||
2691 | pci_set_drvdata(pdev, board); | 2688 | pci_set_drvdata(pdev, board); |
2692 | 2689 | ||
2693 | return 0; | 2690 | return 0; |
2694 | err_unmap: | 2691 | err_unmap: |
2695 | pci_iounmap(pdev, board->base); | 2692 | pci_iounmap(pdev, board->base); |
2696 | err_reg: | 2693 | err_reg: |
2697 | pci_release_region(pdev, reg); | 2694 | pci_release_region(pdev, reg); |
2698 | err_flag: | 2695 | err_flag: |
2699 | board->flags &= ~SX_BOARD_PRESENT; | 2696 | board->flags &= ~SX_BOARD_PRESENT; |
2700 | err: | 2697 | err: |
2701 | return retval; | 2698 | return retval; |
2702 | #else | 2699 | #else |
2703 | return -ENODEV; | 2700 | return -ENODEV; |
2704 | #endif | 2701 | #endif |
2705 | } | 2702 | } |
2706 | 2703 | ||
2707 | static void __devexit sx_pci_remove(struct pci_dev *pdev) | 2704 | static void __devexit sx_pci_remove(struct pci_dev *pdev) |
2708 | { | 2705 | { |
2709 | struct sx_board *board = pci_get_drvdata(pdev); | 2706 | struct sx_board *board = pci_get_drvdata(pdev); |
2710 | 2707 | ||
2711 | sx_remove_card(board, pdev); | 2708 | sx_remove_card(board, pdev); |
2712 | } | 2709 | } |
2713 | 2710 | ||
2714 | /* Specialix has a whole bunch of cards with 0x2000 as the device ID. They say | 2711 | /* Specialix has a whole bunch of cards with 0x2000 as the device ID. They say |
2715 | its because the standard requires it. So check for SUBVENDOR_ID. */ | 2712 | its because the standard requires it. So check for SUBVENDOR_ID. */ |
2716 | static struct pci_device_id sx_pci_tbl[] = { | 2713 | static struct pci_device_id sx_pci_tbl[] = { |
2717 | { PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, | 2714 | { PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, |
2718 | .subvendor = PCI_ANY_ID, .subdevice = 0x0200 }, | 2715 | .subvendor = PCI_ANY_ID, .subdevice = 0x0200 }, |
2719 | { PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, | 2716 | { PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, |
2720 | .subvendor = PCI_ANY_ID, .subdevice = 0x0300 }, | 2717 | .subvendor = PCI_ANY_ID, .subdevice = 0x0300 }, |
2721 | { 0 } | 2718 | { 0 } |
2722 | }; | 2719 | }; |
2723 | 2720 | ||
2724 | MODULE_DEVICE_TABLE(pci, sx_pci_tbl); | 2721 | MODULE_DEVICE_TABLE(pci, sx_pci_tbl); |
2725 | 2722 | ||
2726 | static struct pci_driver sx_pcidriver = { | 2723 | static struct pci_driver sx_pcidriver = { |
2727 | .name = "sx", | 2724 | .name = "sx", |
2728 | .id_table = sx_pci_tbl, | 2725 | .id_table = sx_pci_tbl, |
2729 | .probe = sx_pci_probe, | 2726 | .probe = sx_pci_probe, |
2730 | .remove = __devexit_p(sx_pci_remove) | 2727 | .remove = __devexit_p(sx_pci_remove) |
2731 | }; | 2728 | }; |
2732 | 2729 | ||
2733 | static int __init sx_init(void) | 2730 | static int __init sx_init(void) |
2734 | { | 2731 | { |
2735 | #ifdef CONFIG_EISA | 2732 | #ifdef CONFIG_EISA |
2736 | int retval1; | 2733 | int retval1; |
2737 | #endif | 2734 | #endif |
2738 | #ifdef CONFIG_ISA | 2735 | #ifdef CONFIG_ISA |
2739 | struct sx_board *board; | 2736 | struct sx_board *board; |
2740 | unsigned int i; | 2737 | unsigned int i; |
2741 | #endif | 2738 | #endif |
2742 | unsigned int found = 0; | 2739 | unsigned int found = 0; |
2743 | int retval; | 2740 | int retval; |
2744 | 2741 | ||
2745 | func_enter(); | 2742 | func_enter(); |
2746 | sx_dprintk(SX_DEBUG_INIT, "Initing sx module... (sx_debug=%d)\n", | 2743 | sx_dprintk(SX_DEBUG_INIT, "Initing sx module... (sx_debug=%d)\n", |
2747 | sx_debug); | 2744 | sx_debug); |
2748 | if (abs((long)(&sx_debug) - sx_debug) < 0x10000) { | 2745 | if (abs((long)(&sx_debug) - sx_debug) < 0x10000) { |
2749 | printk(KERN_WARNING "sx: sx_debug is an address, instead of a " | 2746 | printk(KERN_WARNING "sx: sx_debug is an address, instead of a " |
2750 | "value. Assuming -1.\n(%p)\n", &sx_debug); | 2747 | "value. Assuming -1.\n(%p)\n", &sx_debug); |
2751 | sx_debug = -1; | 2748 | sx_debug = -1; |
2752 | } | 2749 | } |
2753 | 2750 | ||
2754 | if (misc_register(&sx_fw_device) < 0) { | 2751 | if (misc_register(&sx_fw_device) < 0) { |
2755 | printk(KERN_ERR "SX: Unable to register firmware loader " | 2752 | printk(KERN_ERR "SX: Unable to register firmware loader " |
2756 | "driver.\n"); | 2753 | "driver.\n"); |
2757 | return -EIO; | 2754 | return -EIO; |
2758 | } | 2755 | } |
2759 | #ifdef CONFIG_ISA | 2756 | #ifdef CONFIG_ISA |
2760 | for (i = 0; i < NR_SX_ADDRS; i++) { | 2757 | for (i = 0; i < NR_SX_ADDRS; i++) { |
2761 | board = &boards[found]; | 2758 | board = &boards[found]; |
2762 | board->hw_base = sx_probe_addrs[i]; | 2759 | board->hw_base = sx_probe_addrs[i]; |
2763 | board->hw_len = SX_WINDOW_LEN; | 2760 | board->hw_len = SX_WINDOW_LEN; |
2764 | if (!request_region(board->hw_base, board->hw_len, "sx")) | 2761 | if (!request_region(board->hw_base, board->hw_len, "sx")) |
2765 | continue; | 2762 | continue; |
2766 | board->base2 = | 2763 | board->base2 = |
2767 | board->base = ioremap_nocache(board->hw_base, board->hw_len); | 2764 | board->base = ioremap_nocache(board->hw_base, board->hw_len); |
2768 | if (!board->base) | 2765 | if (!board->base) |
2769 | goto err_sx_reg; | 2766 | goto err_sx_reg; |
2770 | board->flags &= ~SX_BOARD_TYPE; | 2767 | board->flags &= ~SX_BOARD_TYPE; |
2771 | board->flags |= SX_ISA_BOARD; | 2768 | board->flags |= SX_ISA_BOARD; |
2772 | board->irq = sx_irqmask ? -1 : 0; | 2769 | board->irq = sx_irqmask ? -1 : 0; |
2773 | 2770 | ||
2774 | if (probe_sx(board)) { | 2771 | if (probe_sx(board)) { |
2775 | board->flags |= SX_BOARD_PRESENT; | 2772 | board->flags |= SX_BOARD_PRESENT; |
2776 | found++; | 2773 | found++; |
2777 | } else { | 2774 | } else { |
2778 | iounmap(board->base); | 2775 | iounmap(board->base); |
2779 | err_sx_reg: | 2776 | err_sx_reg: |
2780 | release_region(board->hw_base, board->hw_len); | 2777 | release_region(board->hw_base, board->hw_len); |
2781 | } | 2778 | } |
2782 | } | 2779 | } |
2783 | 2780 | ||
2784 | for (i = 0; i < NR_SI_ADDRS; i++) { | 2781 | for (i = 0; i < NR_SI_ADDRS; i++) { |
2785 | board = &boards[found]; | 2782 | board = &boards[found]; |
2786 | board->hw_base = si_probe_addrs[i]; | 2783 | board->hw_base = si_probe_addrs[i]; |
2787 | board->hw_len = SI2_ISA_WINDOW_LEN; | 2784 | board->hw_len = SI2_ISA_WINDOW_LEN; |
2788 | if (!request_region(board->hw_base, board->hw_len, "sx")) | 2785 | if (!request_region(board->hw_base, board->hw_len, "sx")) |
2789 | continue; | 2786 | continue; |
2790 | board->base2 = | 2787 | board->base2 = |
2791 | board->base = ioremap_nocache(board->hw_base, board->hw_len); | 2788 | board->base = ioremap_nocache(board->hw_base, board->hw_len); |
2792 | if (!board->base) | 2789 | if (!board->base) |
2793 | goto err_si_reg; | 2790 | goto err_si_reg; |
2794 | board->flags &= ~SX_BOARD_TYPE; | 2791 | board->flags &= ~SX_BOARD_TYPE; |
2795 | board->flags |= SI_ISA_BOARD; | 2792 | board->flags |= SI_ISA_BOARD; |
2796 | board->irq = sx_irqmask ? -1 : 0; | 2793 | board->irq = sx_irqmask ? -1 : 0; |
2797 | 2794 | ||
2798 | if (probe_si(board)) { | 2795 | if (probe_si(board)) { |
2799 | board->flags |= SX_BOARD_PRESENT; | 2796 | board->flags |= SX_BOARD_PRESENT; |
2800 | found++; | 2797 | found++; |
2801 | } else { | 2798 | } else { |
2802 | iounmap(board->base); | 2799 | iounmap(board->base); |
2803 | err_si_reg: | 2800 | err_si_reg: |
2804 | release_region(board->hw_base, board->hw_len); | 2801 | release_region(board->hw_base, board->hw_len); |
2805 | } | 2802 | } |
2806 | } | 2803 | } |
2807 | for (i = 0; i < NR_SI1_ADDRS; i++) { | 2804 | for (i = 0; i < NR_SI1_ADDRS; i++) { |
2808 | board = &boards[found]; | 2805 | board = &boards[found]; |
2809 | board->hw_base = si1_probe_addrs[i]; | 2806 | board->hw_base = si1_probe_addrs[i]; |
2810 | board->hw_len = SI1_ISA_WINDOW_LEN; | 2807 | board->hw_len = SI1_ISA_WINDOW_LEN; |
2811 | if (!request_region(board->hw_base, board->hw_len, "sx")) | 2808 | if (!request_region(board->hw_base, board->hw_len, "sx")) |
2812 | continue; | 2809 | continue; |
2813 | board->base2 = | 2810 | board->base2 = |
2814 | board->base = ioremap_nocache(board->hw_base, board->hw_len); | 2811 | board->base = ioremap_nocache(board->hw_base, board->hw_len); |
2815 | if (!board->base) | 2812 | if (!board->base) |
2816 | goto err_si1_reg; | 2813 | goto err_si1_reg; |
2817 | board->flags &= ~SX_BOARD_TYPE; | 2814 | board->flags &= ~SX_BOARD_TYPE; |
2818 | board->flags |= SI1_ISA_BOARD; | 2815 | board->flags |= SI1_ISA_BOARD; |
2819 | board->irq = sx_irqmask ? -1 : 0; | 2816 | board->irq = sx_irqmask ? -1 : 0; |
2820 | 2817 | ||
2821 | if (probe_si(board)) { | 2818 | if (probe_si(board)) { |
2822 | board->flags |= SX_BOARD_PRESENT; | 2819 | board->flags |= SX_BOARD_PRESENT; |
2823 | found++; | 2820 | found++; |
2824 | } else { | 2821 | } else { |
2825 | iounmap(board->base); | 2822 | iounmap(board->base); |
2826 | err_si1_reg: | 2823 | err_si1_reg: |
2827 | release_region(board->hw_base, board->hw_len); | 2824 | release_region(board->hw_base, board->hw_len); |
2828 | } | 2825 | } |
2829 | } | 2826 | } |
2830 | #endif | 2827 | #endif |
2831 | #ifdef CONFIG_EISA | 2828 | #ifdef CONFIG_EISA |
2832 | retval1 = eisa_driver_register(&sx_eisadriver); | 2829 | retval1 = eisa_driver_register(&sx_eisadriver); |
2833 | #endif | 2830 | #endif |
2834 | retval = pci_register_driver(&sx_pcidriver); | 2831 | retval = pci_register_driver(&sx_pcidriver); |
2835 | 2832 | ||
2836 | if (found) { | 2833 | if (found) { |
2837 | printk(KERN_INFO "sx: total of %d boards detected.\n", found); | 2834 | printk(KERN_INFO "sx: total of %d boards detected.\n", found); |
2838 | retval = 0; | 2835 | retval = 0; |
2839 | } else if (retval) { | 2836 | } else if (retval) { |
2840 | #ifdef CONFIG_EISA | 2837 | #ifdef CONFIG_EISA |
2841 | retval = retval1; | 2838 | retval = retval1; |
2842 | if (retval1) | 2839 | if (retval1) |
2843 | #endif | 2840 | #endif |
2844 | misc_deregister(&sx_fw_device); | 2841 | misc_deregister(&sx_fw_device); |
2845 | } | 2842 | } |
2846 | 2843 | ||
2847 | func_exit(); | 2844 | func_exit(); |
2848 | return retval; | 2845 | return retval; |
2849 | } | 2846 | } |
2850 | 2847 | ||
2851 | static void __exit sx_exit(void) | 2848 | static void __exit sx_exit(void) |
2852 | { | 2849 | { |
2853 | int i; | 2850 | int i; |
2854 | 2851 | ||
2855 | func_enter(); | 2852 | func_enter(); |
2856 | #ifdef CONFIG_EISA | 2853 | #ifdef CONFIG_EISA |
2857 | eisa_driver_unregister(&sx_eisadriver); | 2854 | eisa_driver_unregister(&sx_eisadriver); |
2858 | #endif | 2855 | #endif |
2859 | pci_unregister_driver(&sx_pcidriver); | 2856 | pci_unregister_driver(&sx_pcidriver); |
2860 | 2857 | ||
2861 | for (i = 0; i < SX_NBOARDS; i++) | 2858 | for (i = 0; i < SX_NBOARDS; i++) |
2862 | sx_remove_card(&boards[i], NULL); | 2859 | sx_remove_card(&boards[i], NULL); |
2863 | 2860 | ||
2864 | if (misc_deregister(&sx_fw_device) < 0) { | 2861 | if (misc_deregister(&sx_fw_device) < 0) { |
2865 | printk(KERN_INFO "sx: couldn't deregister firmware loader " | 2862 | printk(KERN_INFO "sx: couldn't deregister firmware loader " |
2866 | "device\n"); | 2863 | "device\n"); |
2867 | } | 2864 | } |
2868 | sx_dprintk(SX_DEBUG_CLEANUP, "Cleaning up drivers (%d)\n", | 2865 | sx_dprintk(SX_DEBUG_CLEANUP, "Cleaning up drivers (%d)\n", |
2869 | sx_initialized); | 2866 | sx_initialized); |
2870 | if (sx_initialized) | 2867 | if (sx_initialized) |
2871 | sx_release_drivers(); | 2868 | sx_release_drivers(); |
2872 | 2869 | ||
2873 | kfree(sx_ports); | 2870 | kfree(sx_ports); |
2874 | func_exit(); | 2871 | func_exit(); |
2875 | } | 2872 | } |
2876 | 2873 | ||
2877 | module_init(sx_init); | 2874 | module_init(sx_init); |
2878 | module_exit(sx_exit); | 2875 | module_exit(sx_exit); |
2879 | 2876 |
include/linux/generic_serial.h
1 | /* | 1 | /* |
2 | * generic_serial.h | 2 | * generic_serial.h |
3 | * | 3 | * |
4 | * Copyright (C) 1998 R.E.Wolff@BitWizard.nl | 4 | * Copyright (C) 1998 R.E.Wolff@BitWizard.nl |
5 | * | 5 | * |
6 | * written for the SX serial driver. | 6 | * written for the SX serial driver. |
7 | * Contains the code that should be shared over all the serial drivers. | 7 | * Contains the code that should be shared over all the serial drivers. |
8 | * | 8 | * |
9 | * Version 0.1 -- December, 1998. | 9 | * Version 0.1 -- December, 1998. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #ifndef GENERIC_SERIAL_H | 12 | #ifndef GENERIC_SERIAL_H |
13 | #define GENERIC_SERIAL_H | 13 | #define GENERIC_SERIAL_H |
14 | 14 | ||
15 | #ifdef __KERNEL__ | 15 | #ifdef __KERNEL__ |
16 | #include <linux/mutex.h> | 16 | #include <linux/mutex.h> |
17 | #include <linux/tty.h> | ||
17 | 18 | ||
18 | struct real_driver { | 19 | struct real_driver { |
19 | void (*disable_tx_interrupts) (void *); | 20 | void (*disable_tx_interrupts) (void *); |
20 | void (*enable_tx_interrupts) (void *); | 21 | void (*enable_tx_interrupts) (void *); |
21 | void (*disable_rx_interrupts) (void *); | 22 | void (*disable_rx_interrupts) (void *); |
22 | void (*enable_rx_interrupts) (void *); | 23 | void (*enable_rx_interrupts) (void *); |
23 | int (*get_CD) (void *); | 24 | int (*get_CD) (void *); |
24 | void (*shutdown_port) (void*); | 25 | void (*shutdown_port) (void*); |
25 | int (*set_real_termios) (void*); | 26 | int (*set_real_termios) (void*); |
26 | int (*chars_in_buffer) (void*); | 27 | int (*chars_in_buffer) (void*); |
27 | void (*close) (void*); | 28 | void (*close) (void*); |
28 | void (*hungup) (void*); | 29 | void (*hungup) (void*); |
29 | void (*getserial) (void*, struct serial_struct *sp); | 30 | void (*getserial) (void*, struct serial_struct *sp); |
30 | }; | 31 | }; |
31 | 32 | ||
32 | 33 | ||
33 | 34 | ||
34 | struct gs_port { | 35 | struct gs_port { |
35 | int magic; | 36 | int magic; |
37 | struct tty_port port; | ||
36 | unsigned char *xmit_buf; | 38 | unsigned char *xmit_buf; |
37 | int xmit_head; | 39 | int xmit_head; |
38 | int xmit_tail; | 40 | int xmit_tail; |
39 | int xmit_cnt; | 41 | int xmit_cnt; |
40 | struct mutex port_write_mutex; | 42 | struct mutex port_write_mutex; |
41 | int flags; | ||
42 | wait_queue_head_t open_wait; | ||
43 | wait_queue_head_t close_wait; | ||
44 | int count; | ||
45 | int blocked_open; | ||
46 | struct tty_struct *tty; | ||
47 | unsigned long event; | 43 | unsigned long event; |
48 | unsigned short closing_wait; | 44 | unsigned short closing_wait; |
49 | int close_delay; | 45 | int close_delay; |
50 | struct real_driver *rd; | 46 | struct real_driver *rd; |
51 | int wakeup_chars; | 47 | int wakeup_chars; |
52 | int baud_base; | 48 | int baud_base; |
53 | int baud; | 49 | int baud; |
54 | int custom_divisor; | 50 | int custom_divisor; |
55 | spinlock_t driver_lock; | 51 | spinlock_t driver_lock; |
56 | }; | 52 | }; |
57 | 53 | ||
58 | #endif /* __KERNEL__ */ | 54 | #endif /* __KERNEL__ */ |
59 | 55 | ||
60 | /* Flags */ | 56 | /* Flags */ |
61 | /* Warning: serial.h defines some ASYNC_ flags, they say they are "only" | 57 | /* Warning: serial.h defines some ASYNC_ flags, they say they are "only" |
62 | used in serial.c, but they are also used in all other serial drivers. | 58 | used in serial.c, but they are also used in all other serial drivers. |
63 | Make sure they don't clash with these here... */ | 59 | Make sure they don't clash with these here... */ |
64 | #define GS_TX_INTEN 0x00800000 | 60 | #define GS_TX_INTEN 0x00800000 |
65 | #define GS_RX_INTEN 0x00400000 | 61 | #define GS_RX_INTEN 0x00400000 |
66 | #define GS_ACTIVE 0x00200000 | 62 | #define GS_ACTIVE 0x00200000 |
67 | 63 | ||
68 | 64 | ||
69 | 65 | ||
70 | #define GS_TYPE_NORMAL 1 | 66 | #define GS_TYPE_NORMAL 1 |
71 | 67 | ||
72 | #define GS_DEBUG_FLUSH 0x00000001 | 68 | #define GS_DEBUG_FLUSH 0x00000001 |
73 | #define GS_DEBUG_BTR 0x00000002 | 69 | #define GS_DEBUG_BTR 0x00000002 |
74 | #define GS_DEBUG_TERMIOS 0x00000004 | 70 | #define GS_DEBUG_TERMIOS 0x00000004 |
75 | #define GS_DEBUG_STUFF 0x00000008 | 71 | #define GS_DEBUG_STUFF 0x00000008 |
76 | #define GS_DEBUG_CLOSE 0x00000010 | 72 | #define GS_DEBUG_CLOSE 0x00000010 |
77 | #define GS_DEBUG_FLOW 0x00000020 | 73 | #define GS_DEBUG_FLOW 0x00000020 |
78 | #define GS_DEBUG_WRITE 0x00000040 | 74 | #define GS_DEBUG_WRITE 0x00000040 |
79 | 75 | ||
80 | #ifdef __KERNEL__ | 76 | #ifdef __KERNEL__ |
81 | int gs_put_char(struct tty_struct *tty, unsigned char ch); | 77 | int gs_put_char(struct tty_struct *tty, unsigned char ch); |
82 | int gs_write(struct tty_struct *tty, | 78 | int gs_write(struct tty_struct *tty, |
83 | const unsigned char *buf, int count); | 79 | const unsigned char *buf, int count); |
84 | int gs_write_room(struct tty_struct *tty); | 80 | int gs_write_room(struct tty_struct *tty); |
85 | int gs_chars_in_buffer(struct tty_struct *tty); | 81 | int gs_chars_in_buffer(struct tty_struct *tty); |
86 | void gs_flush_buffer(struct tty_struct *tty); | 82 | void gs_flush_buffer(struct tty_struct *tty); |
87 | void gs_flush_chars(struct tty_struct *tty); | 83 | void gs_flush_chars(struct tty_struct *tty); |
88 | void gs_stop(struct tty_struct *tty); | 84 | void gs_stop(struct tty_struct *tty); |
89 | void gs_start(struct tty_struct *tty); | 85 | void gs_start(struct tty_struct *tty); |
90 | void gs_hangup(struct tty_struct *tty); | 86 | void gs_hangup(struct tty_struct *tty); |
91 | int gs_block_til_ready(void *port, struct file *filp); | 87 | int gs_block_til_ready(void *port, struct file *filp); |
92 | void gs_close(struct tty_struct *tty, struct file *filp); | 88 | void gs_close(struct tty_struct *tty, struct file *filp); |
93 | void gs_set_termios (struct tty_struct * tty, | 89 | void gs_set_termios (struct tty_struct * tty, |
94 | struct ktermios * old_termios); | 90 | struct ktermios * old_termios); |
95 | int gs_init_port(struct gs_port *port); | 91 | int gs_init_port(struct gs_port *port); |
96 | int gs_setserial(struct gs_port *port, struct serial_struct __user *sp); | 92 | int gs_setserial(struct gs_port *port, struct serial_struct __user *sp); |
97 | int gs_getserial(struct gs_port *port, struct serial_struct __user *sp); | 93 | int gs_getserial(struct gs_port *port, struct serial_struct __user *sp); |
98 | void gs_got_break(struct gs_port *port); | 94 | void gs_got_break(struct gs_port *port); |
99 | #endif /* __KERNEL__ */ | 95 | #endif /* __KERNEL__ */ |