Diff markup
1 /* 1 /*
2 * linux/drivers/char/serial167.c 2 * linux/drivers/char/serial167.c
3 * 3 *
4 * Driver for MVME166/7 board serial ports, wh 4 * Driver for MVME166/7 board serial ports, which are via a CD2401.
5 * Based very much on cyclades.c. 5 * Based very much on cyclades.c.
6 * 6 *
7 * MVME166/7 work by Richard Hirst [richard@sl 7 * MVME166/7 work by Richard Hirst [richard@sleepie.demon.co.uk]
8 * 8 *
9 * =========================================== 9 * ==============================================================
10 * 10 *
11 * static char rcsid[] = 11 * static char rcsid[] =
12 * "$Revision: 1.36.1.4 $$Date: 1995/03/29 06: 12 * "$Revision: 1.36.1.4 $$Date: 1995/03/29 06:14:14 $";
13 * 13 *
14 * linux/kernel/cyclades.c 14 * linux/kernel/cyclades.c
15 * 15 *
16 * Maintained by Marcio Saito (cyclades@netcom 16 * Maintained by Marcio Saito (cyclades@netcom.com) and
17 * Randolph Bentson (bentson@grieg.seaslug.org 17 * Randolph Bentson (bentson@grieg.seaslug.org)
18 * 18 *
19 * Much of the design and some of the code cam 19 * Much of the design and some of the code came from serial.c
20 * which was copyright (C) 1991, 1992 Linus T 20 * which was copyright (C) 1991, 1992 Linus Torvalds. It was
21 * extensively rewritten by Theodore Ts'o, 8/1 21 * extensively rewritten by Theodore Ts'o, 8/16/92 -- 9/14/92,
22 * and then fixed as suggested by Michael K. J 22 * and then fixed as suggested by Michael K. Johnson 12/12/92.
23 * 23 *
24 * This version does not support shared irq's. 24 * This version does not support shared irq's.
25 * 25 *
26 * $Log: cyclades.c,v $ 26 * $Log: cyclades.c,v $
27 * Revision 1.36.1.4 1995/03/29 06:14:14 be 27 * Revision 1.36.1.4 1995/03/29 06:14:14 bentson
28 * disambiguate between Cyclom-16Y and Cyclom- 28 * disambiguate between Cyclom-16Y and Cyclom-32Ye;
29 * 29 *
30 * Changes: 30 * Changes:
31 * 31 *
32 * 200 lines of changes record removed - RGH 1 32 * 200 lines of changes record removed - RGH 11-10-95, starting work on
33 * converting this to drive serial ports on mv 33 * converting this to drive serial ports on mvme166 (cd2401).
34 * 34 *
35 * Arnaldo Carvalho de Melo <acme@conectiva.co 35 * Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 2000/08/25
36 * - get rid of verify_area 36 * - get rid of verify_area
37 * - use get_user to access memory from usersp 37 * - use get_user to access memory from userspace in set_threshold,
38 * set_default_threshold and set_timeout 38 * set_default_threshold and set_timeout
39 * - don't use the panic function in serial167 39 * - don't use the panic function in serial167_init
40 * - do resource release on failure on serial1 40 * - do resource release on failure on serial167_init
41 * - include missing restore_flags in mvme167_ 41 * - include missing restore_flags in mvme167_serial_console_setup
42 * 42 *
43 * Kars de Jong <jongk@linux-m68k.org> - 2004/ 43 * Kars de Jong <jongk@linux-m68k.org> - 2004/09/06
44 * - replace bottom half handler with task que 44 * - replace bottom half handler with task queue handler
45 */ 45 */
46 46
>> 47 #include <linux/config.h>
47 #include <linux/errno.h> 48 #include <linux/errno.h>
48 #include <linux/signal.h> 49 #include <linux/signal.h>
49 #include <linux/sched.h> 50 #include <linux/sched.h>
50 #include <linux/timer.h> 51 #include <linux/timer.h>
51 #include <linux/tty.h> 52 #include <linux/tty.h>
52 #include <linux/interrupt.h> 53 #include <linux/interrupt.h>
53 #include <linux/serial.h> 54 #include <linux/serial.h>
54 #include <linux/serialP.h> 55 #include <linux/serialP.h>
55 #include <linux/string.h> 56 #include <linux/string.h>
56 #include <linux/fcntl.h> 57 #include <linux/fcntl.h>
57 #include <linux/ptrace.h> 58 #include <linux/ptrace.h>
58 #include <linux/serial167.h> 59 #include <linux/serial167.h>
59 #include <linux/delay.h> 60 #include <linux/delay.h>
60 #include <linux/major.h> 61 #include <linux/major.h>
61 #include <linux/mm.h> 62 #include <linux/mm.h>
62 #include <linux/console.h> 63 #include <linux/console.h>
63 #include <linux/module.h> 64 #include <linux/module.h>
64 #include <linux/bitops.h> 65 #include <linux/bitops.h>
65 #include <linux/tty_flip.h> <<
66 66
67 #include <asm/system.h> 67 #include <asm/system.h>
68 #include <asm/io.h> 68 #include <asm/io.h>
69 #include <asm/mvme16xhw.h> 69 #include <asm/mvme16xhw.h>
70 #include <asm/bootinfo.h> 70 #include <asm/bootinfo.h>
71 #include <asm/setup.h> 71 #include <asm/setup.h>
72 72
73 #include <linux/types.h> 73 #include <linux/types.h>
74 #include <linux/kernel.h> 74 #include <linux/kernel.h>
75 75
76 #include <asm/uaccess.h> 76 #include <asm/uaccess.h>
77 #include <linux/init.h> 77 #include <linux/init.h>
78 78
79 #define SERIAL_PARANOIA_CHECK 79 #define SERIAL_PARANOIA_CHECK
80 #undef SERIAL_DEBUG_OPEN 80 #undef SERIAL_DEBUG_OPEN
81 #undef SERIAL_DEBUG_THROTTLE 81 #undef SERIAL_DEBUG_THROTTLE
82 #undef SERIAL_DEBUG_OTHER 82 #undef SERIAL_DEBUG_OTHER
83 #undef SERIAL_DEBUG_IO 83 #undef SERIAL_DEBUG_IO
84 #undef SERIAL_DEBUG_COUNT 84 #undef SERIAL_DEBUG_COUNT
85 #undef SERIAL_DEBUG_DTR 85 #undef SERIAL_DEBUG_DTR
86 #undef CYCLOM_16Y_HACK 86 #undef CYCLOM_16Y_HACK
87 #define CYCLOM_ENABLE_MONITORING 87 #define CYCLOM_ENABLE_MONITORING
88 88
89 #define WAKEUP_CHARS 256 89 #define WAKEUP_CHARS 256
90 90
91 #define STD_COM_FLAGS (0) 91 #define STD_COM_FLAGS (0)
92 92
>> 93 #define SERIAL_TYPE_NORMAL 1
>> 94
93 static struct tty_driver *cy_serial_driver; 95 static struct tty_driver *cy_serial_driver;
94 extern int serial_console; 96 extern int serial_console;
95 static struct cyclades_port *serial_console_in 97 static struct cyclades_port *serial_console_info = NULL;
96 static unsigned int serial_console_cflag = 0; 98 static unsigned int serial_console_cflag = 0;
97 u_char initial_console_speed; 99 u_char initial_console_speed;
98 100
99 /* Base address of cd2401 chip on mvme166/7 */ 101 /* Base address of cd2401 chip on mvme166/7 */
100 102
101 #define BASE_ADDR (0xfff45000) 103 #define BASE_ADDR (0xfff45000)
102 #define pcc2chip ((volatile u_char *)0x 104 #define pcc2chip ((volatile u_char *)0xfff42000)
103 #define PccSCCMICR 0x1d 105 #define PccSCCMICR 0x1d
104 #define PccSCCTICR 0x1e 106 #define PccSCCTICR 0x1e
105 #define PccSCCRICR 0x1f 107 #define PccSCCRICR 0x1f
106 #define PccTPIACKR 0x25 108 #define PccTPIACKR 0x25
107 #define PccRPIACKR 0x27 109 #define PccRPIACKR 0x27
108 #define PccIMLR 0x3f 110 #define PccIMLR 0x3f
109 111
110 /* This is the per-port data structure */ 112 /* This is the per-port data structure */
111 struct cyclades_port cy_port[] = { 113 struct cyclades_port cy_port[] = {
112 /* CARD# */ !! 114 /* CARD# */
113 {-1}, /* ttyS0 */ !! 115 {-1 }, /* ttyS0 */
114 {-1}, /* ttyS1 */ !! 116 {-1 }, /* ttyS1 */
115 {-1}, /* ttyS2 */ !! 117 {-1 }, /* ttyS2 */
116 {-1}, /* ttyS3 */ !! 118 {-1 }, /* ttyS3 */
117 }; 119 };
>> 120 #define NR_PORTS (sizeof(cy_port)/sizeof(struct cyclades_port))
118 121
119 #define NR_PORTS ARRAY_SIZE(cy_port) !! 122 /*
>> 123 * tmp_buf is used as a temporary buffer by serial_write. We need to
>> 124 * lock it in case the copy_from_user blocks while swapping in a page,
>> 125 * and some other program tries to do a serial write at the same time.
>> 126 * Since the lock will only come under contention when the system is
>> 127 * swapping and available memory is low, it makes sense to share one
>> 128 * buffer across all the serial ports, since it significantly saves
>> 129 * memory if large numbers of serial ports are open.
>> 130 */
>> 131 static unsigned char *tmp_buf = 0;
>> 132 DECLARE_MUTEX(tmp_buf_sem);
120 133
121 /* 134 /*
122 * This is used to look up the divisor speeds 135 * This is used to look up the divisor speeds and the timeouts
123 * We're normally limited to 15 distinct baud 136 * We're normally limited to 15 distinct baud rates. The extra
124 * are accessed via settings in info->flags. 137 * are accessed via settings in info->flags.
125 * 0, 1, 2, 3, 4, 138 * 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
126 * 10, 11, 12, 13, 14, 1 139 * 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
127 * 140 * HI VHI
128 */ 141 */
129 static int baud_table[] = { 142 static int baud_table[] = {
130 0, 50, 75, 110, 134, 150, 200, 300, 60 !! 143 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
131 1800, 2400, 4800, 9600, 19200, 38400, !! 144 1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800,115200,150000,
132 0 !! 145 0};
133 }; <<
134 146
135 #if 0 147 #if 0
136 static char baud_co[] = { /* 25 MHz cloc !! 148 static char baud_co[] = { /* 25 MHz clock option table */
137 /* value => 00 01 02 03 !! 149 /* value => 00 01 02 03 04 */
138 /* divide by 8 32 128 512 2 !! 150 /* divide by 8 32 128 512 2048 */
139 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x !! 151 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02,
140 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x !! 152 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
141 }; !! 153
142 !! 154 static char baud_bpr[] = { /* 25 MHz baud rate period table */
143 static char baud_bpr[] = { /* 25 MHz baud !! 155 0x00, 0xf5, 0xa3, 0x6f, 0x5c, 0x51, 0xf5, 0xa3, 0x51, 0xa3,
144 0x00, 0xf5, 0xa3, 0x6f, 0x5c, 0x51, 0x !! 156 0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x36, 0x29, 0x1b, 0x15};
145 0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x <<
146 }; <<
147 #endif 157 #endif
148 158
149 /* I think 166 brd clocks 2401 at 20MHz.... */ 159 /* I think 166 brd clocks 2401 at 20MHz.... */
150 160
151 /* These values are written directly to tcor, 161 /* These values are written directly to tcor, and >> 5 for writing to rcor */
152 static u_char baud_co[] = { /* 20 MHz cloc !! 162 static u_char baud_co[] = { /* 20 MHz clock option table */
153 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x !! 163 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x60, 0x60, 0x40,
154 0x40, 0x40, 0x20, 0x20, 0x00, 0x00, 0x !! 164 0x40, 0x40, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
155 }; <<
156 165
157 /* These values written directly to tbpr/rbpr 166 /* These values written directly to tbpr/rbpr */
158 static u_char baud_bpr[] = { /* 20 MHz baud !! 167 static u_char baud_bpr[] = { /* 20 MHz baud rate period table */
159 0x00, 0xc0, 0x80, 0x58, 0x6c, 0x40, 0x !! 168 0x00, 0xc0, 0x80, 0x58, 0x6c, 0x40, 0xc0, 0x81, 0x40, 0x81,
160 0x57, 0x40, 0x81, 0x40, 0x81, 0x40, 0x !! 169 0x57, 0x40, 0x81, 0x40, 0x81, 0x40, 0x2b, 0x20, 0x15, 0x10};
161 }; !! 170
>> 171 static u_char baud_cor4[] = { /* receive threshold */
>> 172 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
>> 173 0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07};
>> 174
162 175
163 static u_char baud_cor4[] = { /* receive thr <<
164 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x <<
165 0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x <<
166 }; <<
167 176
168 static void shutdown(struct cyclades_port *); 177 static void shutdown(struct cyclades_port *);
169 static int startup(struct cyclades_port *); !! 178 static int startup (struct cyclades_port *);
170 static void cy_throttle(struct tty_struct *); 179 static void cy_throttle(struct tty_struct *);
171 static void cy_unthrottle(struct tty_struct *) 180 static void cy_unthrottle(struct tty_struct *);
172 static void config_setup(struct cyclades_port 181 static void config_setup(struct cyclades_port *);
173 extern void console_print(const char *); 182 extern void console_print(const char *);
174 #ifdef CYCLOM_SHOW_STATUS 183 #ifdef CYCLOM_SHOW_STATUS
175 static void show_status(int); 184 static void show_status(int);
176 #endif 185 #endif
177 186
178 #ifdef CONFIG_REMOTE_DEBUG 187 #ifdef CONFIG_REMOTE_DEBUG
179 static void debug_setup(void); 188 static void debug_setup(void);
180 void queueDebugChar(int c); !! 189 void queueDebugChar (int c);
181 int getDebugChar(void); 190 int getDebugChar(void);
182 191
183 #define DEBUG_PORT 1 192 #define DEBUG_PORT 1
184 #define DEBUG_LEN 256 193 #define DEBUG_LEN 256
185 194
186 typedef struct { 195 typedef struct {
187 int in; !! 196 int in;
188 int out; !! 197 int out;
189 unsigned char buf[DEBUG_LEN]; !! 198 unsigned char buf[DEBUG_LEN];
190 } debugq; 199 } debugq;
191 200
192 debugq debugiq; 201 debugq debugiq;
193 #endif 202 #endif
194 203
195 /* 204 /*
196 * I have my own version of udelay(), as it is 205 * I have my own version of udelay(), as it is needed when initialising
197 * the chip, before the delay loop has been ca 206 * the chip, before the delay loop has been calibrated. Should probably
198 * reference one of the vmechip2 or pccchip2 c 207 * reference one of the vmechip2 or pccchip2 counter for an accurate
199 * delay, but this wild guess will do for now. 208 * delay, but this wild guess will do for now.
200 */ 209 */
201 210
202 void my_udelay(long us) !! 211 void my_udelay (long us)
203 { 212 {
204 u_char x; 213 u_char x;
205 volatile u_char *p = &x; 214 volatile u_char *p = &x;
206 int i; 215 int i;
207 216
208 while (us--) 217 while (us--)
209 for (i = 100; i; i--) 218 for (i = 100; i; i--)
210 x |= *p; 219 x |= *p;
211 } 220 }
212 221
213 static inline int serial_paranoia_check(struct !! 222 static inline int
214 const char *routine) !! 223 serial_paranoia_check(struct cyclades_port *info, char *name,
>> 224 const char *routine)
215 { 225 {
216 #ifdef SERIAL_PARANOIA_CHECK 226 #ifdef SERIAL_PARANOIA_CHECK
217 if (!info) { !! 227 static const char *badmagic =
218 printk("Warning: null cyclades !! 228 "Warning: bad magic number for serial struct (%s) in %s\n";
219 routine); !! 229 static const char *badinfo =
220 return 1; !! 230 "Warning: null cyclades_port for (%s) in %s\n";
221 } !! 231 static const char *badrange =
222 !! 232 "Warning: cyclades_port out of range for (%s) in %s\n";
223 if ((long)info < (long)(&cy_port[0]) !! 233
224 || (long)(&cy_port[NR_PORTS]) < (l !! 234 if (!info) {
225 printk("Warning: cyclades_port !! 235 printk(badinfo, name, routine);
226 name, routine) !! 236 return 1;
227 return 1; !! 237 }
228 } !! 238
229 !! 239 if( (long)info < (long)(&cy_port[0])
230 if (info->magic != CYCLADES_MAGIC) { !! 240 || (long)(&cy_port[NR_PORTS]) < (long)info ){
231 printk("Warning: bad magic num !! 241 printk(badrange, name, routine);
232 "%s\n", name, !! 242 return 1;
233 return 1; !! 243 }
234 } !! 244
>> 245 if (info->magic != CYCLADES_MAGIC) {
>> 246 printk(badmagic, name, routine);
>> 247 return 1;
>> 248 }
235 #endif 249 #endif
236 return 0; 250 return 0;
237 } /* serial_para !! 251 } /* serial_paranoia_check */
238 252
239 #if 0 253 #if 0
240 /* The following diagnostic routines allow the 254 /* The following diagnostic routines allow the driver to spew
241 information on the screen, even (especially 255 information on the screen, even (especially!) during interrupts.
242 */ 256 */
243 void SP(char *data) !! 257 void
244 { !! 258 SP(char *data){
245 unsigned long flags; !! 259 unsigned long flags;
246 local_irq_save(flags); !! 260 local_irq_save(flags);
247 console_print(data); !! 261 console_print(data);
248 local_irq_restore(flags); !! 262 local_irq_restore(flags);
249 } 263 }
250 <<
251 char scrn[2]; 264 char scrn[2];
252 void CP(char data) !! 265 void
253 { !! 266 CP(char data){
254 unsigned long flags; !! 267 unsigned long flags;
255 local_irq_save(flags); !! 268 local_irq_save(flags);
256 scrn[0] = data; !! 269 scrn[0] = data;
257 console_print(scrn); !! 270 console_print(scrn);
258 local_irq_restore(flags); !! 271 local_irq_restore(flags);
259 } /* CP */ !! 272 }/* CP */
260 !! 273
261 void CP1(int data) !! 274 void CP1(int data) { (data<10)? CP(data+''): CP(data+'A'-10); }/* CP1 */
262 { !! 275 void CP2(int data) { CP1((data>>4) & 0x0f); CP1( data & 0x0f); }/* CP2 */
263 (data < 10) ? CP(data + '') : CP(data !! 276 void CP4(int data) { CP2((data>>8) & 0xff); CP2(data & 0xff); }/* CP4 */
264 } /* CP1 */ !! 277 void CP8(long data) { CP4((data>>16) & 0xffff); CP4(data & 0xffff); }/* CP8 */
265 void CP2(int data) <<
266 { <<
267 CP1((data >> 4) & 0x0f); <<
268 CP1(data & 0x0f); <<
269 } /* CP2 */ <<
270 void CP4(int data) <<
271 { <<
272 CP2((data >> 8) & 0xff); <<
273 CP2(data & 0xff); <<
274 } /* CP4 */ <<
275 void CP8(long data) <<
276 { <<
277 CP4((data >> 16) & 0xffff); <<
278 CP4(data & 0xffff); <<
279 } /* CP8 */ <<
280 #endif 278 #endif
281 279
282 /* This routine waits up to 1000 micro-seconds 280 /* This routine waits up to 1000 micro-seconds for the previous
283 command to the Cirrus chip to complete and 281 command to the Cirrus chip to complete and then issues the
284 new command. An error is returned if the p 282 new command. An error is returned if the previous command
285 didn't finish within the time limit. 283 didn't finish within the time limit.
286 */ 284 */
287 u_short write_cy_cmd(volatile u_char * base_ad !! 285 u_short
>> 286 write_cy_cmd(volatile u_char *base_addr, u_char cmd)
288 { 287 {
289 unsigned long flags; !! 288 unsigned long flags;
290 volatile int i; !! 289 volatile int i;
291 290
292 local_irq_save(flags); !! 291 local_irq_save(flags);
293 /* Check to see that the previous comm 292 /* Check to see that the previous command has completed */
294 for (i = 0; i < 100; i++) { !! 293 for(i = 0 ; i < 100 ; i++){
295 if (base_addr[CyCCR] == 0) { !! 294 if (base_addr[CyCCR] == 0){
296 break; !! 295 break;
297 } !! 296 }
298 my_udelay(10L); !! 297 my_udelay(10L);
299 } 298 }
300 /* if the CCR never cleared, the previ 299 /* if the CCR never cleared, the previous command
301 didn't finish within the "reasonabl !! 300 didn't finish within the "reasonable time" */
302 if (i == 10) { !! 301 if ( i == 10 ) {
303 local_irq_restore(flags); !! 302 local_irq_restore(flags);
304 return (-1); !! 303 return (-1);
305 } 304 }
306 305
307 /* Issue the new command */ 306 /* Issue the new command */
308 base_addr[CyCCR] = cmd; 307 base_addr[CyCCR] = cmd;
309 local_irq_restore(flags); !! 308 local_irq_restore(flags);
310 return (0); !! 309 return(0);
311 } /* write_cy_cm !! 310 } /* write_cy_cmd */
>> 311
312 312
313 /* cy_start and cy_stop provide software outpu 313 /* cy_start and cy_stop provide software output flow control as a
314 function of XON/XOFF, software CTS, and oth 314 function of XON/XOFF, software CTS, and other such stuff. */
315 315
316 static void cy_stop(struct tty_struct *tty) !! 316 static void
>> 317 cy_stop(struct tty_struct *tty)
317 { 318 {
318 struct cyclades_port *info = (struct c !! 319 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
319 volatile unsigned char *base_addr = (u !! 320 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
320 int channel; !! 321 int channel;
321 unsigned long flags; !! 322 unsigned long flags;
322 323
323 #ifdef SERIAL_DEBUG_OTHER 324 #ifdef SERIAL_DEBUG_OTHER
324 printk("cy_stop %s\n", tty->name); !! 325 printk("cy_stop %s\n", tty->name); /* */
325 #endif 326 #endif
326 327
327 if (serial_paranoia_check(info, tty->n !! 328 if (serial_paranoia_check(info, tty->name, "cy_stop"))
328 return; !! 329 return;
>> 330
>> 331 channel = info->line;
329 332
330 channel = info->line; !! 333 local_irq_save(flags);
>> 334 base_addr[CyCAR] = (u_char)(channel); /* index channel */
>> 335 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
>> 336 local_irq_restore(flags);
331 337
332 local_irq_save(flags); !! 338 return;
333 base_addr[CyCAR] = (u_char) (channel); !! 339 } /* cy_stop */
334 base_addr[CyIER] &= ~(CyTxMpty | CyTxR <<
335 local_irq_restore(flags); <<
336 } /* cy_stop */ <<
337 340
338 static void cy_start(struct tty_struct *tty) !! 341 static void
>> 342 cy_start(struct tty_struct *tty)
339 { 343 {
340 struct cyclades_port *info = (struct c !! 344 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
341 volatile unsigned char *base_addr = (u !! 345 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
342 int channel; !! 346 int channel;
343 unsigned long flags; !! 347 unsigned long flags;
344 348
345 #ifdef SERIAL_DEBUG_OTHER 349 #ifdef SERIAL_DEBUG_OTHER
346 printk("cy_start %s\n", tty->name); !! 350 printk("cy_start %s\n", tty->name); /* */
347 #endif 351 #endif
348 352
349 if (serial_paranoia_check(info, tty->n !! 353 if (serial_paranoia_check(info, tty->name, "cy_start"))
350 return; !! 354 return;
>> 355
>> 356 channel = info->line;
351 357
352 channel = info->line; !! 358 local_irq_save(flags);
>> 359 base_addr[CyCAR] = (u_char)(channel);
>> 360 base_addr[CyIER] |= CyTxMpty;
>> 361 local_irq_restore(flags);
>> 362
>> 363 return;
>> 364 } /* cy_start */
>> 365
>> 366
>> 367 /*
>> 368 * This routine is used by the interrupt handler to schedule
>> 369 * processing in the software interrupt portion of the driver
>> 370 * (also known as the "bottom half"). This can be called any
>> 371 * number of times for any channel without harm.
>> 372 */
>> 373 static inline void
>> 374 cy_sched_event(struct cyclades_port *info, int event)
>> 375 {
>> 376 info->event |= 1 << event; /* remember what kind of event and who */
>> 377 schedule_work(&info->tqueue);
>> 378 } /* cy_sched_event */
353 379
354 local_irq_save(flags); <<
355 base_addr[CyCAR] = (u_char) (channel); <<
356 base_addr[CyIER] |= CyTxMpty; <<
357 local_irq_restore(flags); <<
358 } /* cy_start */ <<
359 380
360 /* The real interrupt service routines are cal 381 /* The real interrupt service routines are called
361 whenever the card wants its hand held--char 382 whenever the card wants its hand held--chars
362 received, out buffer empty, modem change, e 383 received, out buffer empty, modem change, etc.
363 */ 384 */
364 static irqreturn_t cd2401_rxerr_interrupt(int !! 385 static irqreturn_t
>> 386 cd2401_rxerr_interrupt(int irq, void *dev_id, struct pt_regs *fp)
365 { 387 {
366 struct tty_struct *tty; !! 388 struct tty_struct *tty;
367 struct cyclades_port *info; !! 389 struct cyclades_port *info;
368 volatile unsigned char *base_addr = (u !! 390 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
369 unsigned char err, rfoc; !! 391 unsigned char err, rfoc;
370 int channel; !! 392 int channel;
371 char data; !! 393 char data;
372 !! 394
373 /* determine the channel and change to !! 395 /* determine the channel and change to that context */
374 channel = (u_short) (base_addr[CyLICR] !! 396 channel = (u_short ) (base_addr[CyLICR] >> 2);
375 info = &cy_port[channel]; !! 397 info = &cy_port[channel];
376 info->last_active = jiffies; !! 398 info->last_active = jiffies;
377 !! 399
378 if ((err = base_addr[CyRISR]) & CyTIME !! 400 if ((err = base_addr[CyRISR]) & CyTIMEOUT) {
379 /* This is a receive timeout i !! 401 /* This is a receive timeout interrupt, ignore it */
380 base_addr[CyREOIR] = CyNOTRANS !! 402 base_addr[CyREOIR] = CyNOTRANS;
381 return IRQ_HANDLED; !! 403 return IRQ_HANDLED;
382 } !! 404 }
383 405
384 /* Read a byte of data if there is any !! 406 /* Read a byte of data if there is any - assume the error
385 * is associated with this character * !! 407 * is associated with this character */
386 408
387 if ((rfoc = base_addr[CyRFOC]) != 0) !! 409 if ((rfoc = base_addr[CyRFOC]) != 0)
388 data = base_addr[CyRDR]; !! 410 data = base_addr[CyRDR];
389 else !! 411 else
390 data = 0; !! 412 data = 0;
391 413
392 /* if there is nowhere to put the data !! 414 /* if there is nowhere to put the data, discard it */
393 if (info->tty == 0) { !! 415 if(info->tty == 0) {
394 base_addr[CyREOIR] = rfoc ? 0 <<
395 return IRQ_HANDLED; <<
396 } else { /* there is an <<
397 tty = info->tty; <<
398 if (err & info->ignore_status_ <<
399 base_addr[CyREOIR] = r <<
400 return IRQ_HANDLED; <<
401 } <<
402 if (tty_buffer_request_room(tt <<
403 if (err & info->read_s <<
404 if (err & CyBR <<
405 tty_in <<
406 <<
407 if (in <<
408 <<
409 } <<
410 } else if (err <<
411 tty_in <<
412 <<
413 } else if (err <<
414 tty_in <<
415 <<
416 } else if (err <<
417 tty_in <<
418 <<
419 /* <<
420 If <<
421 ove <<
422 the <<
423 */ <<
424 if (tt <<
425 0) <<
426 <<
427 <<
428 } <<
429 /* The <<
430 /* a n <<
431 /* els <<
432 /* els <<
433 } else { <<
434 tty_in <<
435 <<
436 } <<
437 } else { <<
438 tty_insert_fli <<
439 } <<
440 } else { <<
441 /* there was a softwar <<
442 and nothing could b <<
443 } <<
444 } <<
445 tty_schedule_flip(tty); <<
446 /* end of service */ <<
447 base_addr[CyREOIR] = rfoc ? 0 : CyNOTR 416 base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
448 return IRQ_HANDLED; 417 return IRQ_HANDLED;
449 } /* cy_rxerr_in !! 418 }
450 !! 419 else { /* there is an open port for this data */
451 static irqreturn_t cd2401_modem_interrupt(int !! 420 tty = info->tty;
452 { !! 421 if(err & info->ignore_status_mask){
453 struct cyclades_port *info; !! 422 base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
454 volatile unsigned char *base_addr = (u !! 423 return IRQ_HANDLED;
455 int channel; !! 424 }
456 int mdm_change; !! 425 if (tty->flip.count < TTY_FLIPBUF_SIZE){
457 int mdm_status; !! 426 tty->flip.count++;
458 !! 427 if (err & info->read_status_mask){
459 /* determine the channel and change to !! 428 if(err & CyBREAK){
460 channel = (u_short) (base_addr[CyLICR] !! 429 *tty->flip.flag_buf_ptr++ = TTY_BREAK;
461 info = &cy_port[channel]; !! 430 *tty->flip.char_buf_ptr++ = data;
462 info->last_active = jiffies; !! 431 if (info->flags & ASYNC_SAK){
463 !! 432 do_SAK(tty);
464 mdm_change = base_addr[CyMISR]; !! 433 }
465 mdm_status = base_addr[CyMSVR1]; !! 434 }else if(err & CyFRAME){
466 !! 435 *tty->flip.flag_buf_ptr++ = TTY_FRAME;
467 if (info->tty == 0) { /* nowhere to !! 436 *tty->flip.char_buf_ptr++ = data;
468 ; !! 437 }else if(err & CyPARITY){
469 } else { !! 438 *tty->flip.flag_buf_ptr++ = TTY_PARITY;
470 if ((mdm_change & CyDCD) !! 439 *tty->flip.char_buf_ptr++ = data;
471 && (info->flags & ASYNC_CH !! 440 }else if(err & CyOVERRUN){
472 if (mdm_status & CyDCD !! 441 *tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
>> 442 *tty->flip.char_buf_ptr++ = 0;
>> 443 /*
>> 444 If the flip buffer itself is
>> 445 overflowing, we still loose
>> 446 the next incoming character.
>> 447 */
>> 448 if(tty->flip.count < TTY_FLIPBUF_SIZE){
>> 449 tty->flip.count++;
>> 450 *tty->flip.flag_buf_ptr++ = TTY_NORMAL;
>> 451 *tty->flip.char_buf_ptr++ = data;
>> 452 }
>> 453 /* These two conditions may imply */
>> 454 /* a normal read should be done. */
>> 455 /* else if(data & CyTIMEOUT) */
>> 456 /* else if(data & CySPECHAR) */
>> 457 }else{
>> 458 *tty->flip.flag_buf_ptr++ = 0;
>> 459 *tty->flip.char_buf_ptr++ = 0;
>> 460 }
>> 461 }else{
>> 462 *tty->flip.flag_buf_ptr++ = 0;
>> 463 *tty->flip.char_buf_ptr++ = 0;
>> 464 }
>> 465 }else{
>> 466 /* there was a software buffer overrun
>> 467 and nothing could be done about it!!! */
>> 468 }
>> 469 }
>> 470 schedule_delayed_work(&tty->flip.work, 1);
>> 471 /* end of service */
>> 472 base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
>> 473 return IRQ_HANDLED;
>> 474 } /* cy_rxerr_interrupt */
>> 475
>> 476 static irqreturn_t
>> 477 cd2401_modem_interrupt(int irq, void *dev_id, struct pt_regs *fp)
>> 478 {
>> 479 struct cyclades_port *info;
>> 480 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
>> 481 int channel;
>> 482 int mdm_change;
>> 483 int mdm_status;
>> 484
>> 485
>> 486 /* determine the channel and change to that context */
>> 487 channel = (u_short ) (base_addr[CyLICR] >> 2);
>> 488 info = &cy_port[channel];
>> 489 info->last_active = jiffies;
>> 490
>> 491 mdm_change = base_addr[CyMISR];
>> 492 mdm_status = base_addr[CyMSVR1];
>> 493
>> 494 if(info->tty == 0){ /* nowhere to put the data, ignore it */
>> 495 ;
>> 496 }else{
>> 497 if((mdm_change & CyDCD)
>> 498 && (info->flags & ASYNC_CHECK_CD)){
>> 499 if(mdm_status & CyDCD){
473 /* CP('!'); */ 500 /* CP('!'); */
474 wake_up_interr !! 501 cy_sched_event(info, Cy_EVENT_OPEN_WAKEUP);
475 } else { !! 502 } else {
476 /* CP('@'); */ 503 /* CP('@'); */
477 tty_hangup(inf !! 504 cy_sched_event(info, Cy_EVENT_HANGUP);
478 wake_up_interr !! 505 }
479 info->flags &= <<
480 } <<
481 } <<
482 if ((mdm_change & CyCTS) <<
483 && (info->flags & ASYNC_CT <<
484 if (info->tty->stopped <<
485 if (mdm_status <<
486 /* !!! <<
487 info-> <<
488 base_a <<
489 tty_wa <<
490 } <<
491 } else { <<
492 if (!(mdm_stat <<
493 /* !!! <<
494 info-> <<
495 base_a <<
496 ~( <<
497 } <<
498 } <<
499 } <<
500 if (mdm_status & CyDSR) { <<
501 } <<
502 } 506 }
503 base_addr[CyMEOIR] = 0; !! 507 if((mdm_change & CyCTS)
504 return IRQ_HANDLED; !! 508 && (info->flags & ASYNC_CTS_FLOW)){
505 } /* cy_modem_in !! 509 if(info->tty->stopped){
506 !! 510 if(mdm_status & CyCTS){
507 static irqreturn_t cd2401_tx_interrupt(int irq !! 511 /* !!! cy_start isn't used because... */
508 { !! 512 info->tty->stopped = 0;
509 struct cyclades_port *info; !! 513 base_addr[CyIER] |= CyTxMpty;
510 volatile unsigned char *base_addr = (u !! 514 cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
511 int channel; !! 515 }
512 int char_count, saved_cnt; !! 516 }else{
513 int outch; !! 517 if(!(mdm_status & CyCTS)){
>> 518 /* !!! cy_stop isn't used because... */
>> 519 info->tty->stopped = 1;
>> 520 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
>> 521 }
>> 522 }
>> 523 }
>> 524 if(mdm_status & CyDSR){
>> 525 }
>> 526 }
>> 527 base_addr[CyMEOIR] = 0;
>> 528 return IRQ_HANDLED;
>> 529 } /* cy_modem_interrupt */
>> 530
>> 531 static irqreturn_t
>> 532 cd2401_tx_interrupt(int irq, void *dev_id, struct pt_regs *fp)
>> 533 {
>> 534 struct cyclades_port *info;
>> 535 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
>> 536 int channel;
>> 537 int char_count, saved_cnt;
>> 538 int outch;
514 539
515 /* determine the channel and change to !! 540 /* determine the channel and change to that context */
516 channel = (u_short) (base_addr[CyLICR] !! 541 channel = (u_short ) (base_addr[CyLICR] >> 2);
517 542
518 #ifdef CONFIG_REMOTE_DEBUG 543 #ifdef CONFIG_REMOTE_DEBUG
519 if (channel == DEBUG_PORT) { !! 544 if (channel == DEBUG_PORT) {
520 panic("TxInt on debug port!!!" !! 545 panic ("TxInt on debug port!!!");
521 } !! 546 }
522 #endif 547 #endif
523 548
524 info = &cy_port[channel]; !! 549 info = &cy_port[channel];
525 550
526 /* validate the port number (as config !! 551 /* validate the port number (as configured and open) */
527 if ((channel < 0) || (NR_PORTS <= chan !! 552 if( (channel < 0) || (NR_PORTS <= channel) ){
528 base_addr[CyIER] &= ~(CyTxMpty !! 553 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
529 base_addr[CyTEOIR] = CyNOTRANS !! 554 base_addr[CyTEOIR] = CyNOTRANS;
530 return IRQ_HANDLED; !! 555 return IRQ_HANDLED;
531 } !! 556 }
532 info->last_active = jiffies; !! 557 info->last_active = jiffies;
533 if (info->tty == 0) { !! 558 if(info->tty == 0){
534 base_addr[CyIER] &= ~(CyTxMpty !! 559 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
535 base_addr[CyTEOIR] = CyNOTRANS !! 560 if (info->xmit_cnt < WAKEUP_CHARS) {
536 return IRQ_HANDLED; !! 561 cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
537 } !! 562 }
>> 563 base_addr[CyTEOIR] = CyNOTRANS;
>> 564 return IRQ_HANDLED;
>> 565 }
538 566
539 /* load the on-chip space available fo !! 567 /* load the on-chip space available for outbound data */
540 saved_cnt = char_count = base_addr[CyT !! 568 saved_cnt = char_count = base_addr[CyTFTC];
541 569
542 if (info->x_char) { /* send specia !! 570 if(info->x_char) { /* send special char */
543 outch = info->x_char; !! 571 outch = info->x_char;
>> 572 base_addr[CyTDR] = outch;
>> 573 char_count--;
>> 574 info->x_char = 0;
>> 575 }
>> 576
>> 577 if (info->x_break){
>> 578 /* The Cirrus chip requires the "Embedded Transmit
>> 579 Commands" of start break, delay, and end break
>> 580 sequences to be sent. The duration of the
>> 581 break is given in TICs, which runs at HZ
>> 582 (typically 100) and the PPR runs at 200 Hz,
>> 583 so the delay is duration * 200/HZ, and thus a
>> 584 break can run from 1/100 sec to about 5/4 sec.
>> 585 Need to check these values - RGH 141095.
>> 586 */
>> 587 base_addr[CyTDR] = 0; /* start break */
>> 588 base_addr[CyTDR] = 0x81;
>> 589 base_addr[CyTDR] = 0; /* delay a bit */
>> 590 base_addr[CyTDR] = 0x82;
>> 591 base_addr[CyTDR] = info->x_break*200/HZ;
>> 592 base_addr[CyTDR] = 0; /* terminate break */
>> 593 base_addr[CyTDR] = 0x83;
>> 594 char_count -= 7;
>> 595 info->x_break = 0;
>> 596 }
>> 597
>> 598 while (char_count > 0){
>> 599 if (!info->xmit_cnt){
>> 600 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
>> 601 break;
>> 602 }
>> 603 if (info->xmit_buf == 0){
>> 604 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
>> 605 break;
>> 606 }
>> 607 if (info->tty->stopped || info->tty->hw_stopped){
>> 608 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
>> 609 break;
>> 610 }
>> 611 /* Because the Embedded Transmit Commands have been
>> 612 enabled, we must check to see if the escape
>> 613 character, NULL, is being sent. If it is, we
>> 614 must ensure that there is room for it to be
>> 615 doubled in the output stream. Therefore we
>> 616 no longer advance the pointer when the character
>> 617 is fetched, but rather wait until after the check
>> 618 for a NULL output character. (This is necessary
>> 619 because there may not be room for the two chars
>> 620 needed to send a NULL.
>> 621 */
>> 622 outch = info->xmit_buf[info->xmit_tail];
>> 623 if( outch ){
>> 624 info->xmit_cnt--;
>> 625 info->xmit_tail = (info->xmit_tail + 1)
>> 626 & (PAGE_SIZE - 1);
>> 627 base_addr[CyTDR] = outch;
>> 628 char_count--;
>> 629 }else{
>> 630 if(char_count > 1){
>> 631 info->xmit_cnt--;
>> 632 info->xmit_tail = (info->xmit_tail + 1)
>> 633 & (PAGE_SIZE - 1);
544 base_addr[CyTDR] = outch; 634 base_addr[CyTDR] = outch;
>> 635 base_addr[CyTDR] = 0;
545 char_count--; 636 char_count--;
546 info->x_char = 0; !! 637 char_count--;
547 } !! 638 }else{
548 !! 639 break;
549 if (info->x_break) { !! 640 }
550 /* The Cirrus chip requires t <<
551 Commands" of start break, d <<
552 sequences to be sent. The <<
553 break is given in TICs, whi <<
554 (typically 100) and the PPR <<
555 so the delay is duration * <<
556 break can run from 1/100 se <<
557 Need to check these values <<
558 */ <<
559 base_addr[CyTDR] = 0; /* sta <<
560 base_addr[CyTDR] = 0x81; <<
561 base_addr[CyTDR] = 0; /* del <<
562 base_addr[CyTDR] = 0x82; <<
563 base_addr[CyTDR] = info->x_bre <<
564 base_addr[CyTDR] = 0; /* ter <<
565 base_addr[CyTDR] = 0x83; <<
566 char_count -= 7; <<
567 info->x_break = 0; <<
568 } <<
569 <<
570 while (char_count > 0) { <<
571 if (!info->xmit_cnt) { <<
572 base_addr[CyIER] &= ~( <<
573 break; <<
574 } <<
575 if (info->xmit_buf == 0) { <<
576 base_addr[CyIER] &= ~( <<
577 break; <<
578 } <<
579 if (info->tty->stopped || info <<
580 base_addr[CyIER] &= ~( <<
581 break; <<
582 } <<
583 /* Because the Embedded Transm <<
584 enabled, we must check to s <<
585 character, NULL, is being s <<
586 must ensure that there is r <<
587 doubled in the output strea <<
588 no longer advance the point <<
589 is fetched, but rather wait <<
590 for a NULL output character <<
591 because there may not be ro <<
592 needed to send a NULL. <<
593 */ <<
594 outch = info->xmit_buf[info->x <<
595 if (outch) { <<
596 info->xmit_cnt--; <<
597 info->xmit_tail = (inf <<
598 & (PAGE_SIZE - 1); <<
599 base_addr[CyTDR] = out <<
600 char_count--; <<
601 } else { <<
602 if (char_count > 1) { <<
603 info->xmit_cnt <<
604 info->xmit_tai <<
605 & (PAGE_SI <<
606 base_addr[CyTD <<
607 base_addr[CyTD <<
608 char_count--; <<
609 char_count--; <<
610 } else { <<
611 break; <<
612 } <<
613 } <<
614 } 641 }
>> 642 }
615 643
616 if (info->xmit_cnt < WAKEUP_CHARS) !! 644 if (info->xmit_cnt < WAKEUP_CHARS) {
617 tty_wakeup(info->tty); !! 645 cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
618 !! 646 }
619 base_addr[CyTEOIR] = (char_count != sa !! 647 base_addr[CyTEOIR] = (char_count != saved_cnt) ? 0 : CyNOTRANS;
620 return IRQ_HANDLED; !! 648 return IRQ_HANDLED;
621 } /* cy_tx_inter !! 649 } /* cy_tx_interrupt */
622 !! 650
623 static irqreturn_t cd2401_rx_interrupt(int irq !! 651 static irqreturn_t
624 { !! 652 cd2401_rx_interrupt(int irq, void *dev_id, struct pt_regs *fp)
625 struct tty_struct *tty; !! 653 {
626 struct cyclades_port *info; !! 654 struct tty_struct *tty;
627 volatile unsigned char *base_addr = (u !! 655 struct cyclades_port *info;
628 int channel; !! 656 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
629 char data; !! 657 int channel;
630 int char_count; !! 658 char data;
631 int save_cnt; !! 659 int char_count;
632 int len; !! 660 int save_cnt;
633 !! 661
634 /* determine the channel and change to !! 662 /* determine the channel and change to that context */
635 channel = (u_short) (base_addr[CyLICR] !! 663 channel = (u_short ) (base_addr[CyLICR] >> 2);
636 info = &cy_port[channel]; !! 664 info = &cy_port[channel];
637 info->last_active = jiffies; !! 665 info->last_active = jiffies;
638 save_cnt = char_count = base_addr[CyRF !! 666 save_cnt = char_count = base_addr[CyRFOC];
639 667
640 #ifdef CONFIG_REMOTE_DEBUG 668 #ifdef CONFIG_REMOTE_DEBUG
641 if (channel == DEBUG_PORT) { !! 669 if (channel == DEBUG_PORT) {
642 while (char_count--) { !! 670 while (char_count--) {
643 data = base_addr[CyRDR !! 671 data = base_addr[CyRDR];
644 queueDebugChar(data); !! 672 queueDebugChar(data);
645 } !! 673 }
646 } else !! 674 }
647 #endif !! 675 else
648 /* if there is nowhere to put !! 676 #endif
649 if (info->tty == 0) { !! 677 /* if there is nowhere to put the data, discard it */
650 while (char_count--) { !! 678 if(info->tty == 0){
651 data = base_addr[CyRDR !! 679 while(char_count--){
652 } !! 680 data = base_addr[CyRDR];
653 } else { /* there is an !! 681 }
654 tty = info->tty; !! 682 }else{ /* there is an open port for this data */
655 /* load # characters available !! 683 tty = info->tty;
>> 684 /* load # characters available from the chip */
656 685
657 #ifdef CYCLOM_ENABLE_MONITORING 686 #ifdef CYCLOM_ENABLE_MONITORING
658 ++info->mon.int_count; !! 687 ++info->mon.int_count;
659 info->mon.char_count += char_c !! 688 info->mon.char_count += char_count;
660 if (char_count > info->mon.cha !! 689 if (char_count > info->mon.char_max)
661 info->mon.char_max = c !! 690 info->mon.char_max = char_count;
662 info->mon.char_last = char_cou !! 691 info->mon.char_last = char_count;
663 #endif !! 692 #endif
664 len = tty_buffer_request_room( !! 693 while(char_count--){
665 while (len--) { !! 694 data = base_addr[CyRDR];
666 data = base_addr[CyRDR !! 695 if (tty->flip.count >= TTY_FLIPBUF_SIZE){
667 tty_insert_flip_char(t !! 696 continue;
>> 697 }
>> 698 tty->flip.count++;
>> 699 *tty->flip.flag_buf_ptr++ = TTY_NORMAL;
>> 700 *tty->flip.char_buf_ptr++ = data;
668 #ifdef CYCLOM_16Y_HACK 701 #ifdef CYCLOM_16Y_HACK
669 udelay(10L); !! 702 udelay(10L);
670 #endif 703 #endif
671 } !! 704 }
672 tty_schedule_flip(tty); !! 705 schedule_delayed_work(&tty->flip.work, 1);
673 } !! 706 }
674 /* end of service */ !! 707 /* end of service */
675 base_addr[CyREOIR] = save_cnt ? 0 : Cy !! 708 base_addr[CyREOIR] = save_cnt ? 0 : CyNOTRANS;
676 return IRQ_HANDLED; !! 709 return IRQ_HANDLED;
677 } /* cy_rx_inter !! 710 } /* cy_rx_interrupt */
>> 711
>> 712 /*
>> 713 * This routine is used to handle the "bottom half" processing for the
>> 714 * serial driver, known also the "software interrupt" processing.
>> 715 * This processing is done at the kernel interrupt level, after the
>> 716 * cy#/_interrupt() has returned, BUT WITH INTERRUPTS TURNED ON. This
>> 717 * is where time-consuming activities which can not be done in the
>> 718 * interrupt driver proper are done; the interrupt driver schedules
>> 719 * them using cy_sched_event(), and they get done here.
>> 720 *
>> 721 * This is done through one level of indirection--the task queue.
>> 722 * When a hardware interrupt service routine wants service by the
>> 723 * driver's bottom half, it enqueues the appropriate tq_struct (one
>> 724 * per port) to the keventd work queue and sets a request flag
>> 725 * that the work queue be processed.
>> 726 *
>> 727 * Although this may seem unwieldy, it gives the system a way to
>> 728 * pass an argument (in this case the pointer to the cyclades_port
>> 729 * structure) to the bottom half of the driver. Previous kernels
>> 730 * had to poll every port to see if that port needed servicing.
>> 731 */
>> 732 static void
>> 733 do_softint(void *private_)
>> 734 {
>> 735 struct cyclades_port *info = (struct cyclades_port *) private_;
>> 736 struct tty_struct *tty;
>> 737
>> 738 tty = info->tty;
>> 739 if (!tty)
>> 740 return;
>> 741
>> 742 if (test_and_clear_bit(Cy_EVENT_HANGUP, &info->event)) {
>> 743 tty_hangup(info->tty);
>> 744 wake_up_interruptible(&info->open_wait);
>> 745 info->flags &= ~ASYNC_NORMAL_ACTIVE;
>> 746 }
>> 747 if (test_and_clear_bit(Cy_EVENT_OPEN_WAKEUP, &info->event)) {
>> 748 wake_up_interruptible(&info->open_wait);
>> 749 }
>> 750 if (test_and_clear_bit(Cy_EVENT_WRITE_WAKEUP, &info->event)) {
>> 751 tty_wakeup(tty);
>> 752 }
>> 753 } /* do_softint */
>> 754
678 755
679 /* This is called whenever a port becomes acti 756 /* This is called whenever a port becomes active;
680 interrupts are enabled and DTR & RTS are tu 757 interrupts are enabled and DTR & RTS are turned on.
681 */ 758 */
682 static int startup(struct cyclades_port *info) !! 759 static int
>> 760 startup(struct cyclades_port * info)
683 { 761 {
684 unsigned long flags; !! 762 unsigned long flags;
685 volatile unsigned char *base_addr = (u !! 763 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
686 int channel; !! 764 int channel;
687 765
688 if (info->flags & ASYNC_INITIALIZED) { !! 766 if (info->flags & ASYNC_INITIALIZED){
689 return 0; !! 767 return 0;
690 } !! 768 }
691 769
692 if (!info->type) { !! 770 if (!info->type){
693 if (info->tty) { !! 771 if (info->tty){
694 set_bit(TTY_IO_ERROR, !! 772 set_bit(TTY_IO_ERROR, &info->tty->flags);
695 } <<
696 return 0; <<
697 } 773 }
698 if (!info->xmit_buf) { !! 774 return 0;
699 info->xmit_buf = (unsigned cha !! 775 }
700 if (!info->xmit_buf) { !! 776 if (!info->xmit_buf){
701 return -ENOMEM; !! 777 info->xmit_buf = (unsigned char *) get_zeroed_page (GFP_KERNEL);
702 } !! 778 if (!info->xmit_buf){
>> 779 return -ENOMEM;
703 } 780 }
>> 781 }
704 782
705 config_setup(info); !! 783 config_setup(info);
706 784
707 channel = info->line; !! 785 channel = info->line;
708 786
709 #ifdef SERIAL_DEBUG_OPEN 787 #ifdef SERIAL_DEBUG_OPEN
710 printk("startup channel %d\n", channel !! 788 printk("startup channel %d\n", channel);
711 #endif 789 #endif
712 790
713 local_irq_save(flags); !! 791 local_irq_save(flags);
714 base_addr[CyCAR] = (u_char) channel; !! 792 base_addr[CyCAR] = (u_char)channel;
715 write_cy_cmd(base_addr, CyENB_RCVR | C !! 793 write_cy_cmd(base_addr,CyENB_RCVR|CyENB_XMTR);
716 794
717 base_addr[CyCAR] = (u_char) channel; !! 795 base_addr[CyCAR] = (u_char)channel; /* !!! Is this needed? */
718 base_addr[CyMSVR1] = CyRTS; 796 base_addr[CyMSVR1] = CyRTS;
719 /* CP('S');CP('1'); */ 797 /* CP('S');CP('1'); */
720 base_addr[CyMSVR2] = CyDTR; 798 base_addr[CyMSVR2] = CyDTR;
721 799
722 #ifdef SERIAL_DEBUG_DTR 800 #ifdef SERIAL_DEBUG_DTR
723 printk("cyc: %d: raising DTR\n", __LIN !! 801 printk("cyc: %d: raising DTR\n", __LINE__);
724 printk(" status: 0x%x, 0x%x\n", ba !! 802 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
725 base_addr[CyMSVR2]); <<
726 #endif 803 #endif
727 804
728 base_addr[CyIER] |= CyRxData; 805 base_addr[CyIER] |= CyRxData;
729 info->flags |= ASYNC_INITIALIZED; 806 info->flags |= ASYNC_INITIALIZED;
730 807
731 if (info->tty) { !! 808 if (info->tty){
732 clear_bit(TTY_IO_ERROR, &info- !! 809 clear_bit(TTY_IO_ERROR, &info->tty->flags);
733 } 810 }
734 info->xmit_cnt = info->xmit_head = inf 811 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
735 812
736 local_irq_restore(flags); !! 813 local_irq_restore(flags);
737 814
738 #ifdef SERIAL_DEBUG_OPEN 815 #ifdef SERIAL_DEBUG_OPEN
739 printk(" done\n"); !! 816 printk(" done\n");
740 #endif 817 #endif
741 return 0; !! 818 return 0;
742 } /* startup */ !! 819 } /* startup */
743 820
744 void start_xmit(struct cyclades_port *info) !! 821 void
>> 822 start_xmit( struct cyclades_port *info )
745 { 823 {
746 unsigned long flags; !! 824 unsigned long flags;
747 volatile unsigned char *base_addr = (u !! 825 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
748 int channel; !! 826 int channel;
749 827
750 channel = info->line; !! 828 channel = info->line;
751 local_irq_save(flags); !! 829 local_irq_save(flags);
752 base_addr[CyCAR] = channel; 830 base_addr[CyCAR] = channel;
753 base_addr[CyIER] |= CyTxMpty; 831 base_addr[CyIER] |= CyTxMpty;
754 local_irq_restore(flags); !! 832 local_irq_restore(flags);
755 } /* start_xmit !! 833 } /* start_xmit */
756 834
757 /* 835 /*
758 * This routine shuts down a serial port; inte 836 * This routine shuts down a serial port; interrupts are disabled,
759 * and DTR is dropped if the hangup on close t 837 * and DTR is dropped if the hangup on close termio flag is on.
760 */ 838 */
761 static void shutdown(struct cyclades_port *inf !! 839 static void
>> 840 shutdown(struct cyclades_port * info)
762 { 841 {
763 unsigned long flags; !! 842 unsigned long flags;
764 volatile unsigned char *base_addr = (u !! 843 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
765 int channel; !! 844 int channel;
766 845
767 if (!(info->flags & ASYNC_INITIALIZED) !! 846 if (!(info->flags & ASYNC_INITIALIZED)){
768 /* CP('$'); */ 847 /* CP('$'); */
769 return; !! 848 return;
770 } !! 849 }
771 850
772 channel = info->line; !! 851 channel = info->line;
773 852
774 #ifdef SERIAL_DEBUG_OPEN 853 #ifdef SERIAL_DEBUG_OPEN
775 printk("shutdown channel %d\n", channe !! 854 printk("shutdown channel %d\n", channel);
776 #endif 855 #endif
777 856
778 /* !!! REALLY MUST WAIT FOR LAST CHARA !! 857 /* !!! REALLY MUST WAIT FOR LAST CHARACTER TO BE
779 SENT BEFORE DROPPING THE LINE !!! !! 858 SENT BEFORE DROPPING THE LINE !!! (Perhaps
780 set some flag that is read when XMT !! 859 set some flag that is read when XMTY happens.)
781 Other choices are to delay some fix !! 860 Other choices are to delay some fixed interval
782 or schedule some later processing. !! 861 or schedule some later processing.
783 */ !! 862 */
784 local_irq_save(flags); !! 863 local_irq_save(flags);
785 if (info->xmit_buf) { !! 864 if (info->xmit_buf){
786 free_page((unsigned long)info- !! 865 free_page((unsigned long) info->xmit_buf);
787 info->xmit_buf = NULL; !! 866 info->xmit_buf = 0;
788 } 867 }
789 868
790 base_addr[CyCAR] = (u_char) channel; !! 869 base_addr[CyCAR] = (u_char)channel;
791 if (!info->tty || (info->tty->termios- 870 if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
792 base_addr[CyMSVR1] = 0; !! 871 base_addr[CyMSVR1] = 0;
793 /* CP('C');CP('1'); */ 872 /* CP('C');CP('1'); */
794 base_addr[CyMSVR2] = 0; !! 873 base_addr[CyMSVR2] = 0;
795 #ifdef SERIAL_DEBUG_DTR 874 #ifdef SERIAL_DEBUG_DTR
796 printk("cyc: %d: dropping DTR\ !! 875 printk("cyc: %d: dropping DTR\n", __LINE__);
797 printk(" status: 0x%x, 0x% !! 876 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
798 base_addr[CyMSVR2]); <<
799 #endif 877 #endif
800 } !! 878 }
801 write_cy_cmd(base_addr, CyDIS_RCVR); !! 879 write_cy_cmd(base_addr,CyDIS_RCVR);
802 /* it may be appropriate to clear _XMI !! 880 /* it may be appropriate to clear _XMIT at
803 some later date (after testing)!!! !! 881 some later date (after testing)!!! */
804 882
805 if (info->tty) { !! 883 if (info->tty){
806 set_bit(TTY_IO_ERROR, &info->t !! 884 set_bit(TTY_IO_ERROR, &info->tty->flags);
807 } 885 }
808 info->flags &= ~ASYNC_INITIALIZED; 886 info->flags &= ~ASYNC_INITIALIZED;
809 local_irq_restore(flags); !! 887 local_irq_restore(flags);
810 888
811 #ifdef SERIAL_DEBUG_OPEN 889 #ifdef SERIAL_DEBUG_OPEN
812 printk(" done\n"); !! 890 printk(" done\n");
813 #endif 891 #endif
814 } /* shutdown */ !! 892 return;
>> 893 } /* shutdown */
815 894
816 /* 895 /*
817 * This routine finds or computes the various 896 * This routine finds or computes the various line characteristics.
818 */ 897 */
819 static void config_setup(struct cyclades_port !! 898 static void
>> 899 config_setup(struct cyclades_port * info)
820 { 900 {
821 unsigned long flags; !! 901 unsigned long flags;
822 volatile unsigned char *base_addr = (u !! 902 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
823 int channel; !! 903 int channel;
824 unsigned cflag; !! 904 unsigned cflag;
825 int i; !! 905 int i;
826 unsigned char ti, need_init_chan = 0; !! 906 unsigned char ti, need_init_chan = 0;
>> 907
>> 908 if (!info->tty || !info->tty->termios){
>> 909 return;
>> 910 }
>> 911 if (info->line == -1){
>> 912 return;
>> 913 }
>> 914 cflag = info->tty->termios->c_cflag;
827 915
828 if (!info->tty || !info->tty->termios) !! 916 /* baud rate */
829 return; !! 917 i = cflag & CBAUD;
830 } <<
831 if (info->line == -1) { <<
832 return; <<
833 } <<
834 cflag = info->tty->termios->c_cflag; <<
835 <<
836 /* baud rate */ <<
837 i = cflag & CBAUD; <<
838 #ifdef CBAUDEX 918 #ifdef CBAUDEX
839 /* Starting with kernel 1.1.65, there is direc 919 /* Starting with kernel 1.1.65, there is direct support for
840 higher baud rates. The following code supp 920 higher baud rates. The following code supports those
841 changes. The conditional aspect allows thi 921 changes. The conditional aspect allows this driver to be
842 used for earlier as well as later kernel ve 922 used for earlier as well as later kernel versions. (The
843 mapping is slightly different from serial.c 923 mapping is slightly different from serial.c because there
844 is still the possibility of supporting 75 k 924 is still the possibility of supporting 75 kbit/sec with
845 the Cyclades board.) 925 the Cyclades board.)
846 */ 926 */
847 if (i & CBAUDEX) { !! 927 if (i & CBAUDEX) {
848 if (i == B57600) !! 928 if (i == B57600)
849 i = 16; !! 929 i = 16;
850 else if (i == B115200) !! 930 else if(i == B115200)
851 i = 18; !! 931 i = 18;
852 #ifdef B78600 932 #ifdef B78600
853 else if (i == B78600) !! 933 else if(i == B78600)
854 i = 17; !! 934 i = 17;
855 #endif 935 #endif
856 else !! 936 else
857 info->tty->termios->c_ !! 937 info->tty->termios->c_cflag &= ~CBAUDEX;
858 } !! 938 }
859 #endif 939 #endif
860 if (i == 15) { !! 940 if (i == 15) {
861 if ((info->flags & ASYNC_SPD_M !! 941 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
862 i += 1; !! 942 i += 1;
863 if ((info->flags & ASYNC_SPD_M !! 943 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
864 i += 3; !! 944 i += 3;
865 } !! 945 }
866 /* Don't ever change the speed of the !! 946 /* Don't ever change the speed of the console port. It will
867 * run at the speed specified in booti !! 947 * run at the speed specified in bootinfo, or at 19.2K */
868 /* Actually, it should run at whatever !! 948 /* Actually, it should run at whatever speed 166Bug was using */
869 /* Note info->timeout isn't used at pr !! 949 /* Note info->timeout isn't used at present */
870 if (info != serial_console_info) { !! 950 if (info != serial_console_info) {
871 info->tbpr = baud_bpr[i]; !! 951 info->tbpr = baud_bpr[i]; /* Tx BPR */
872 info->tco = baud_co[i]; /* Tx !! 952 info->tco = baud_co[i]; /* Tx CO */
873 info->rbpr = baud_bpr[i]; !! 953 info->rbpr = baud_bpr[i]; /* Rx BPR */
874 info->rco = baud_co[i] >> 5; !! 954 info->rco = baud_co[i] >> 5; /* Rx CO */
875 if (baud_table[i] == 134) { !! 955 if (baud_table[i] == 134) {
876 info->timeout = !! 956 info->timeout = (info->xmit_fifo_size*HZ*30/269) + 2;
877 (info->xmit_fifo_s !! 957 /* get it right for 134.5 baud */
878 /* get it right for 13 !! 958 } else if (baud_table[i]) {
879 } else if (baud_table[i]) { !! 959 info->timeout = (info->xmit_fifo_size*HZ*15/baud_table[i]) + 2;
880 info->timeout = !! 960 /* this needs to be propagated into the card info */
881 (info->xmit_fifo_s <<
882 2; <<
883 /* this needs to be pr <<
884 } else { <<
885 info->timeout = 0; <<
886 } <<
887 } <<
888 /* By tradition (is it a standard?) a <<
889 implies the line should be/has been <<
890 later in this routine such a test i <<
891 <<
892 /* byte size and parity */ <<
893 info->cor7 = 0; <<
894 info->cor6 = 0; <<
895 info->cor5 = 0; <<
896 info->cor4 = (info->default_threshold <<
897 /* Following two lines added 101295, R <<
898 /* It is obviously wrong to access CyC <<
899 * try and remember to fix it later! * <<
900 channel = info->line; <<
901 base_addr[CyCAR] = (u_char) channel; <<
902 if (C_CLOCAL(info->tty)) { <<
903 if (base_addr[CyIER] & CyMdmCh <<
904 base_addr[CyIER] &= ~C <<
905 /* ignore 1->0 modem transitio <<
906 if (base_addr[CyCOR4] & (CyDSR <<
907 base_addr[CyCOR4] &= ~ <<
908 /* ignore 0->1 modem transitio <<
909 if (base_addr[CyCOR5] & (CyDSR <<
910 base_addr[CyCOR5] &= ~ <<
911 } else { 961 } else {
912 if ((base_addr[CyIER] & CyMdmC !! 962 info->timeout = 0;
913 base_addr[CyIER] |= Cy <<
914 /* act on 1->0 modem transitio <<
915 if ((base_addr[CyCOR4] & (CyDS <<
916 (CyDSR | CyCTS | CyDCD)) <<
917 base_addr[CyCOR4] |= C <<
918 /* act on 0->1 modem transitio <<
919 if ((base_addr[CyCOR5] & (CyDS <<
920 (CyDSR | CyCTS | CyDCD)) <<
921 base_addr[CyCOR5] |= C <<
922 } <<
923 info->cor3 = (cflag & CSTOPB) ? Cy_2_S <<
924 info->cor2 = CyETC; <<
925 switch (cflag & CSIZE) { <<
926 case CS5: <<
927 info->cor1 = Cy_5_BITS; <<
928 break; <<
929 case CS6: <<
930 info->cor1 = Cy_6_BITS; <<
931 break; <<
932 case CS7: <<
933 info->cor1 = Cy_7_BITS; <<
934 break; <<
935 case CS8: <<
936 info->cor1 = Cy_8_BITS; <<
937 break; <<
938 } <<
939 if (cflag & PARENB) { <<
940 if (cflag & PARODD) { <<
941 info->cor1 |= CyPARITY <<
942 } else { <<
943 info->cor1 |= CyPARITY <<
944 } <<
945 } else { <<
946 info->cor1 |= CyPARITY_NONE; <<
947 } 963 }
948 !! 964 }
949 /* CTS flow control flag */ !! 965 /* By tradition (is it a standard?) a baud rate of zero
>> 966 implies the line should be/has been closed. A bit
>> 967 later in this routine such a test is performed. */
>> 968
>> 969 /* byte size and parity */
>> 970 info->cor7 = 0;
>> 971 info->cor6 = 0;
>> 972 info->cor5 = 0;
>> 973 info->cor4 = (info->default_threshold
>> 974 ? info->default_threshold
>> 975 : baud_cor4[i]); /* receive threshold */
>> 976 /* Following two lines added 101295, RGH. */
>> 977 /* It is obviously wrong to access CyCORx, and not info->corx here,
>> 978 * try and remember to fix it later! */
>> 979 channel = info->line;
>> 980 base_addr[CyCAR] = (u_char)channel;
>> 981 if (C_CLOCAL(info->tty)) {
>> 982 if (base_addr[CyIER] & CyMdmCh)
>> 983 base_addr[CyIER] &= ~CyMdmCh; /* without modem intr */
>> 984 /* ignore 1->0 modem transitions */
>> 985 if (base_addr[CyCOR4] & (CyDSR|CyCTS|CyDCD))
>> 986 base_addr[CyCOR4] &= ~(CyDSR|CyCTS|CyDCD);
>> 987 /* ignore 0->1 modem transitions */
>> 988 if (base_addr[CyCOR5] & (CyDSR|CyCTS|CyDCD))
>> 989 base_addr[CyCOR5] &= ~(CyDSR|CyCTS|CyDCD);
>> 990 } else {
>> 991 if ((base_addr[CyIER] & CyMdmCh) != CyMdmCh)
>> 992 base_addr[CyIER] |= CyMdmCh; /* with modem intr */
>> 993 /* act on 1->0 modem transitions */
>> 994 if ((base_addr[CyCOR4] & (CyDSR|CyCTS|CyDCD)) != (CyDSR|CyCTS|CyDCD))
>> 995 base_addr[CyCOR4] |= CyDSR|CyCTS|CyDCD;
>> 996 /* act on 0->1 modem transitions */
>> 997 if ((base_addr[CyCOR5] & (CyDSR|CyCTS|CyDCD)) != (CyDSR|CyCTS|CyDCD))
>> 998 base_addr[CyCOR5] |= CyDSR|CyCTS|CyDCD;
>> 999 }
>> 1000 info->cor3 = (cflag & CSTOPB) ? Cy_2_STOP : Cy_1_STOP;
>> 1001 info->cor2 = CyETC;
>> 1002 switch(cflag & CSIZE){
>> 1003 case CS5:
>> 1004 info->cor1 = Cy_5_BITS;
>> 1005 break;
>> 1006 case CS6:
>> 1007 info->cor1 = Cy_6_BITS;
>> 1008 break;
>> 1009 case CS7:
>> 1010 info->cor1 = Cy_7_BITS;
>> 1011 break;
>> 1012 case CS8:
>> 1013 info->cor1 = Cy_8_BITS;
>> 1014 break;
>> 1015 }
>> 1016 if (cflag & PARENB){
>> 1017 if (cflag & PARODD){
>> 1018 info->cor1 |= CyPARITY_O;
>> 1019 }else{
>> 1020 info->cor1 |= CyPARITY_E;
>> 1021 }
>> 1022 }else{
>> 1023 info->cor1 |= CyPARITY_NONE;
>> 1024 }
>> 1025
>> 1026 /* CTS flow control flag */
950 #if 0 1027 #if 0
951 /* Don't complcate matters for now! RG !! 1028 /* Don't complcate matters for now! RGH 141095 */
952 if (cflag & CRTSCTS) { !! 1029 if (cflag & CRTSCTS){
953 info->flags |= ASYNC_CTS_FLOW; !! 1030 info->flags |= ASYNC_CTS_FLOW;
954 info->cor2 |= CyCtsAE; !! 1031 info->cor2 |= CyCtsAE;
955 } else { !! 1032 }else{
956 info->flags &= ~ASYNC_CTS_FLOW !! 1033 info->flags &= ~ASYNC_CTS_FLOW;
957 info->cor2 &= ~CyCtsAE; !! 1034 info->cor2 &= ~CyCtsAE;
958 } !! 1035 }
959 #endif !! 1036 #endif
960 if (cflag & CLOCAL) !! 1037 if (cflag & CLOCAL)
961 info->flags &= ~ASYNC_CHECK_CD !! 1038 info->flags &= ~ASYNC_CHECK_CD;
962 else !! 1039 else
963 info->flags |= ASYNC_CHECK_CD; !! 1040 info->flags |= ASYNC_CHECK_CD;
964 1041
965 /**************************************** 1042 /***********************************************
966 The hardware option, CyRtsAO, presents 1043 The hardware option, CyRtsAO, presents RTS when
967 the chip has characters to send. Sinc 1044 the chip has characters to send. Since most modems
968 use RTS as reverse (inbound) flow cont 1045 use RTS as reverse (inbound) flow control, this
969 option is not used. If inbound flow c 1046 option is not used. If inbound flow control is
970 necessary, DTR can be programmed to pr 1047 necessary, DTR can be programmed to provide the
971 appropriate signals for use with a non 1048 appropriate signals for use with a non-standard
972 cable. Contact Marcio Saito for detai 1049 cable. Contact Marcio Saito for details.
973 ***************************************** 1050 ***********************************************/
974 1051
975 channel = info->line; !! 1052 channel = info->line;
976 1053
977 local_irq_save(flags); !! 1054 local_irq_save(flags);
978 base_addr[CyCAR] = (u_char) channel; !! 1055 base_addr[CyCAR] = (u_char)channel;
979 1056
980 /* CyCMR set once only in mvme167_init 1057 /* CyCMR set once only in mvme167_init_serial() */
981 if (base_addr[CyLICR] != channel << 2) 1058 if (base_addr[CyLICR] != channel << 2)
982 base_addr[CyLICR] = channel << !! 1059 base_addr[CyLICR] = channel << 2;
983 if (base_addr[CyLIVR] != 0x5c) 1060 if (base_addr[CyLIVR] != 0x5c)
984 base_addr[CyLIVR] = 0x5c; !! 1061 base_addr[CyLIVR] = 0x5c;
985 1062
986 /* tx and rx baud rate */ !! 1063 /* tx and rx baud rate */
987 1064
988 if (base_addr[CyCOR1] != info->cor1) 1065 if (base_addr[CyCOR1] != info->cor1)
989 need_init_chan = 1; !! 1066 need_init_chan = 1;
990 if (base_addr[CyTCOR] != info->tco) 1067 if (base_addr[CyTCOR] != info->tco)
991 base_addr[CyTCOR] = info->tco; !! 1068 base_addr[CyTCOR] = info->tco;
992 if (base_addr[CyTBPR] != info->tbpr) 1069 if (base_addr[CyTBPR] != info->tbpr)
993 base_addr[CyTBPR] = info->tbpr !! 1070 base_addr[CyTBPR] = info->tbpr;
994 if (base_addr[CyRCOR] != info->rco) 1071 if (base_addr[CyRCOR] != info->rco)
995 base_addr[CyRCOR] = info->rco; !! 1072 base_addr[CyRCOR] = info->rco;
996 if (base_addr[CyRBPR] != info->rbpr) 1073 if (base_addr[CyRBPR] != info->rbpr)
997 base_addr[CyRBPR] = info->rbpr !! 1074 base_addr[CyRBPR] = info->rbpr;
998 1075
999 /* set line characteristics according 1076 /* set line characteristics according configuration */
1000 1077
1001 if (base_addr[CySCHR1] != START_CHAR( 1078 if (base_addr[CySCHR1] != START_CHAR(info->tty))
1002 base_addr[CySCHR1] = START_CH !! 1079 base_addr[CySCHR1] = START_CHAR(info->tty);
1003 if (base_addr[CySCHR2] != STOP_CHAR(i 1080 if (base_addr[CySCHR2] != STOP_CHAR(info->tty))
1004 base_addr[CySCHR2] = STOP_CHA !! 1081 base_addr[CySCHR2] = STOP_CHAR(info->tty);
1005 if (base_addr[CySCRL] != START_CHAR(i 1082 if (base_addr[CySCRL] != START_CHAR(info->tty))
1006 base_addr[CySCRL] = START_CHA !! 1083 base_addr[CySCRL] = START_CHAR(info->tty);
1007 if (base_addr[CySCRH] != START_CHAR(i 1084 if (base_addr[CySCRH] != START_CHAR(info->tty))
1008 base_addr[CySCRH] = START_CHA !! 1085 base_addr[CySCRH] = START_CHAR(info->tty);
1009 if (base_addr[CyCOR1] != info->cor1) 1086 if (base_addr[CyCOR1] != info->cor1)
1010 base_addr[CyCOR1] = info->cor !! 1087 base_addr[CyCOR1] = info->cor1;
1011 if (base_addr[CyCOR2] != info->cor2) 1088 if (base_addr[CyCOR2] != info->cor2)
1012 base_addr[CyCOR2] = info->cor !! 1089 base_addr[CyCOR2] = info->cor2;
1013 if (base_addr[CyCOR3] != info->cor3) 1090 if (base_addr[CyCOR3] != info->cor3)
1014 base_addr[CyCOR3] = info->cor !! 1091 base_addr[CyCOR3] = info->cor3;
1015 if (base_addr[CyCOR4] != info->cor4) 1092 if (base_addr[CyCOR4] != info->cor4)
1016 base_addr[CyCOR4] = info->cor !! 1093 base_addr[CyCOR4] = info->cor4;
1017 if (base_addr[CyCOR5] != info->cor5) 1094 if (base_addr[CyCOR5] != info->cor5)
1018 base_addr[CyCOR5] = info->cor !! 1095 base_addr[CyCOR5] = info->cor5;
1019 if (base_addr[CyCOR6] != info->cor6) 1096 if (base_addr[CyCOR6] != info->cor6)
1020 base_addr[CyCOR6] = info->cor !! 1097 base_addr[CyCOR6] = info->cor6;
1021 if (base_addr[CyCOR7] != info->cor7) 1098 if (base_addr[CyCOR7] != info->cor7)
1022 base_addr[CyCOR7] = info->cor !! 1099 base_addr[CyCOR7] = info->cor7;
1023 1100
1024 if (need_init_chan) 1101 if (need_init_chan)
1025 write_cy_cmd(base_addr, CyINI !! 1102 write_cy_cmd(base_addr,CyINIT_CHAN);
1026 1103
1027 base_addr[CyCAR] = (u_char) channel; !! 1104 base_addr[CyCAR] = (u_char)channel; /* !!! Is this needed? */
1028 1105
1029 /* 2ms default rx timeout */ 1106 /* 2ms default rx timeout */
1030 ti = info->default_timeout ? info->de 1107 ti = info->default_timeout ? info->default_timeout : 0x02;
1031 if (base_addr[CyRTPRL] != ti) 1108 if (base_addr[CyRTPRL] != ti)
1032 base_addr[CyRTPRL] = ti; !! 1109 base_addr[CyRTPRL] = ti;
1033 if (base_addr[CyRTPRH] != 0) 1110 if (base_addr[CyRTPRH] != 0)
1034 base_addr[CyRTPRH] = 0; !! 1111 base_addr[CyRTPRH] = 0;
1035 1112
1036 /* Set up RTS here also ????? RGH 141 1113 /* Set up RTS here also ????? RGH 141095 */
1037 if (i == 0) { /* baud rate !! 1114 if(i == 0){ /* baud rate is zero, turn off line */
1038 if ((base_addr[CyMSVR2] & CyD !! 1115 if ((base_addr[CyMSVR2] & CyDTR) == CyDTR)
1039 base_addr[CyMSVR2] = !! 1116 base_addr[CyMSVR2] = 0;
1040 #ifdef SERIAL_DEBUG_DTR 1117 #ifdef SERIAL_DEBUG_DTR
1041 printk("cyc: %d: dropping DTR !! 1118 printk("cyc: %d: dropping DTR\n", __LINE__);
1042 printk(" status: 0x%x, 0x !! 1119 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
1043 base_addr[CyMSVR2]); <<
1044 #endif 1120 #endif
1045 } else { !! 1121 }else{
1046 if ((base_addr[CyMSVR2] & CyD !! 1122 if ((base_addr[CyMSVR2] & CyDTR) != CyDTR)
1047 base_addr[CyMSVR2] = !! 1123 base_addr[CyMSVR2] = CyDTR;
1048 #ifdef SERIAL_DEBUG_DTR 1124 #ifdef SERIAL_DEBUG_DTR
1049 printk("cyc: %d: raising DTR\ !! 1125 printk("cyc: %d: raising DTR\n", __LINE__);
1050 printk(" status: 0x%x, 0x !! 1126 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
1051 base_addr[CyMSVR2]); <<
1052 #endif 1127 #endif
1053 } 1128 }
1054 1129
1055 if (info->tty) { !! 1130 if (info->tty){
1056 clear_bit(TTY_IO_ERROR, &info !! 1131 clear_bit(TTY_IO_ERROR, &info->tty->flags);
1057 } 1132 }
1058 1133
1059 local_irq_restore(flags); !! 1134 local_irq_restore(flags);
>> 1135
>> 1136 } /* config_setup */
1060 1137
1061 } /* config_set <<
1062 1138
1063 static void cy_put_char(struct tty_struct *tt !! 1139 static void
>> 1140 cy_put_char(struct tty_struct *tty, unsigned char ch)
1064 { 1141 {
1065 struct cyclades_port *info = (struct !! 1142 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1066 unsigned long flags; !! 1143 unsigned long flags;
1067 1144
1068 #ifdef SERIAL_DEBUG_IO 1145 #ifdef SERIAL_DEBUG_IO
1069 printk("cy_put_char %s(0x%02x)\n", tt !! 1146 printk("cy_put_char %s(0x%02x)\n", tty->name, ch);
1070 #endif 1147 #endif
1071 1148
1072 if (serial_paranoia_check(info, tty-> !! 1149 if (serial_paranoia_check(info, tty->name, "cy_put_char"))
1073 return; !! 1150 return;
1074 1151
1075 if (!info->xmit_buf) !! 1152 if (!tty || !info->xmit_buf)
1076 return; !! 1153 return;
1077 1154
1078 local_irq_save(flags); !! 1155 local_irq_save(flags);
1079 if (info->xmit_cnt >= PAGE_SIZE - 1) 1156 if (info->xmit_cnt >= PAGE_SIZE - 1) {
1080 local_irq_restore(flags); !! 1157 local_irq_restore(flags);
1081 return; !! 1158 return;
1082 } 1159 }
1083 1160
1084 info->xmit_buf[info->xmit_head++] = c 1161 info->xmit_buf[info->xmit_head++] = ch;
1085 info->xmit_head &= PAGE_SIZE - 1; 1162 info->xmit_head &= PAGE_SIZE - 1;
1086 info->xmit_cnt++; 1163 info->xmit_cnt++;
1087 local_irq_restore(flags); !! 1164 local_irq_restore(flags);
1088 } /* cy_put_cha !! 1165 } /* cy_put_char */
1089 1166
1090 static void cy_flush_chars(struct tty_struct <<
1091 { <<
1092 struct cyclades_port *info = (struct <<
1093 unsigned long flags; <<
1094 volatile unsigned char *base_addr = ( <<
1095 int channel; <<
1096 1167
>> 1168 static void
>> 1169 cy_flush_chars(struct tty_struct *tty)
>> 1170 {
>> 1171 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
>> 1172 unsigned long flags;
>> 1173 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
>> 1174 int channel;
>> 1175
1097 #ifdef SERIAL_DEBUG_IO 1176 #ifdef SERIAL_DEBUG_IO
1098 printk("cy_flush_chars %s\n", tty->na !! 1177 printk("cy_flush_chars %s\n", tty->name); /* */
1099 #endif 1178 #endif
1100 1179
1101 if (serial_paranoia_check(info, tty-> !! 1180 if (serial_paranoia_check(info, tty->name, "cy_flush_chars"))
1102 return; !! 1181 return;
1103 1182
1104 if (info->xmit_cnt <= 0 || tty->stopp !! 1183 if (info->xmit_cnt <= 0 || tty->stopped
1105 || tty->hw_stopped || !info->xmit !! 1184 || tty->hw_stopped || !info->xmit_buf)
1106 return; !! 1185 return;
1107 1186
1108 channel = info->line; !! 1187 channel = info->line;
1109 1188
1110 local_irq_save(flags); !! 1189 local_irq_save(flags);
1111 base_addr[CyCAR] = channel; 1190 base_addr[CyCAR] = channel;
1112 base_addr[CyIER] |= CyTxMpty; 1191 base_addr[CyIER] |= CyTxMpty;
1113 local_irq_restore(flags); !! 1192 local_irq_restore(flags);
1114 } /* cy_flush_c !! 1193 } /* cy_flush_chars */
>> 1194
1115 1195
1116 /* This routine gets called when tty_write ha 1196 /* This routine gets called when tty_write has put something into
1117 the write_queue. If the port is not alre 1197 the write_queue. If the port is not already transmitting stuff,
1118 start it off by enabling interrupts. The 1198 start it off by enabling interrupts. The interrupt service
1119 routine will then ensure that the charact 1199 routine will then ensure that the characters are sent. If the
1120 port is already active, there is no need 1200 port is already active, there is no need to kick it.
1121 */ 1201 */
1122 static int cy_write(struct tty_struct *tty, c !! 1202 static int
>> 1203 cy_write(struct tty_struct * tty,
>> 1204 const unsigned char *buf, int count)
1123 { 1205 {
1124 struct cyclades_port *info = (struct !! 1206 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1125 unsigned long flags; !! 1207 unsigned long flags;
1126 int c, total = 0; !! 1208 int c, total = 0;
1127 1209
1128 #ifdef SERIAL_DEBUG_IO 1210 #ifdef SERIAL_DEBUG_IO
1129 printk("cy_write %s\n", tty->name); !! 1211 printk("cy_write %s\n", tty->name); /* */
1130 #endif 1212 #endif
1131 1213
1132 if (serial_paranoia_check(info, tty-> !! 1214 if (serial_paranoia_check(info, tty->name, "cy_write")){
1133 return 0; !! 1215 return 0;
1134 } !! 1216 }
1135 !! 1217
1136 if (!info->xmit_buf) { !! 1218 if (!tty || !info->xmit_buf || !tmp_buf){
1137 return 0; !! 1219 return 0;
1138 } !! 1220 }
1139 !! 1221
1140 while (1) { !! 1222 while (1) {
1141 local_irq_save(flags); !! 1223 local_irq_save(flags);
1142 c = min_t(int, count, min(SER !! 1224 c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
1143 SER !! 1225 SERIAL_XMIT_SIZE - info->xmit_head));
1144 if (c <= 0) { !! 1226 if (c <= 0) {
1145 local_irq_restore(fla !! 1227 local_irq_restore(flags);
1146 break; !! 1228 break;
1147 } !! 1229 }
1148 !! 1230
1149 memcpy(info->xmit_buf + info- !! 1231 memcpy(info->xmit_buf + info->xmit_head, buf, c);
1150 info->xmit_head = !! 1232 info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
1151 (info->xmit_head + c) & ( !! 1233 info->xmit_cnt += c;
1152 info->xmit_cnt += c; !! 1234 local_irq_restore(flags);
1153 local_irq_restore(flags); !! 1235
1154 !! 1236 buf += c;
1155 buf += c; !! 1237 count -= c;
1156 count -= c; !! 1238 total += c;
1157 total += c; !! 1239 }
1158 } !! 1240
>> 1241 if (info->xmit_cnt
>> 1242 && !tty->stopped
>> 1243 && !tty->hw_stopped ) {
>> 1244 start_xmit(info);
>> 1245 }
>> 1246 return total;
>> 1247 } /* cy_write */
1159 1248
1160 if (info->xmit_cnt && !tty->stopped & <<
1161 start_xmit(info); <<
1162 } <<
1163 return total; <<
1164 } /* cy_write * <<
1165 1249
1166 static int cy_write_room(struct tty_struct *t !! 1250 static int
>> 1251 cy_write_room(struct tty_struct *tty)
1167 { 1252 {
1168 struct cyclades_port *info = (struct !! 1253 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1169 int ret; !! 1254 int ret;
1170 !! 1255
1171 #ifdef SERIAL_DEBUG_IO 1256 #ifdef SERIAL_DEBUG_IO
1172 printk("cy_write_room %s\n", tty->nam !! 1257 printk("cy_write_room %s\n", tty->name); /* */
1173 #endif 1258 #endif
1174 1259
1175 if (serial_paranoia_check(info, tty-> !! 1260 if (serial_paranoia_check(info, tty->name, "cy_write_room"))
1176 return 0; !! 1261 return 0;
1177 ret = PAGE_SIZE - info->xmit_cnt - 1; !! 1262 ret = PAGE_SIZE - info->xmit_cnt - 1;
1178 if (ret < 0) !! 1263 if (ret < 0)
1179 ret = 0; !! 1264 ret = 0;
1180 return ret; !! 1265 return ret;
1181 } /* cy_write_r !! 1266 } /* cy_write_room */
1182 1267
1183 static int cy_chars_in_buffer(struct tty_stru <<
1184 { <<
1185 struct cyclades_port *info = (struct <<
1186 1268
>> 1269 static int
>> 1270 cy_chars_in_buffer(struct tty_struct *tty)
>> 1271 {
>> 1272 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
>> 1273
1187 #ifdef SERIAL_DEBUG_IO 1274 #ifdef SERIAL_DEBUG_IO
1188 printk("cy_chars_in_buffer %s %d\n", !! 1275 printk("cy_chars_in_buffer %s %d\n", tty->name, info->xmit_cnt); /* */
1189 #endif 1276 #endif
1190 1277
1191 if (serial_paranoia_check(info, tty-> !! 1278 if (serial_paranoia_check(info, tty->name, "cy_chars_in_buffer"))
1192 return 0; !! 1279 return 0;
>> 1280
>> 1281 return info->xmit_cnt;
>> 1282 } /* cy_chars_in_buffer */
1193 1283
1194 return info->xmit_cnt; <<
1195 } /* cy_chars_i <<
1196 1284
1197 static void cy_flush_buffer(struct tty_struct !! 1285 static void
>> 1286 cy_flush_buffer(struct tty_struct *tty)
1198 { 1287 {
1199 struct cyclades_port *info = (struct !! 1288 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1200 unsigned long flags; !! 1289 unsigned long flags;
1201 !! 1290
1202 #ifdef SERIAL_DEBUG_IO 1291 #ifdef SERIAL_DEBUG_IO
1203 printk("cy_flush_buffer %s\n", tty->n !! 1292 printk("cy_flush_buffer %s\n", tty->name); /* */
1204 #endif 1293 #endif
1205 1294
1206 if (serial_paranoia_check(info, tty-> !! 1295 if (serial_paranoia_check(info, tty->name, "cy_flush_buffer"))
1207 return; !! 1296 return;
1208 local_irq_save(flags); !! 1297 local_irq_save(flags);
1209 info->xmit_cnt = info->xmit_head = in 1298 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
1210 local_irq_restore(flags); !! 1299 local_irq_restore(flags);
1211 tty_wakeup(tty); !! 1300 tty_wakeup(tty);
1212 } /* cy_flush_b !! 1301 } /* cy_flush_buffer */
>> 1302
1213 1303
1214 /* This routine is called by the upper-layer 1304 /* This routine is called by the upper-layer tty layer to signal
1215 that incoming characters should be throttl 1305 that incoming characters should be throttled or that the
1216 throttle should be released. 1306 throttle should be released.
1217 */ 1307 */
1218 static void cy_throttle(struct tty_struct *tt !! 1308 static void
>> 1309 cy_throttle(struct tty_struct * tty)
1219 { 1310 {
1220 struct cyclades_port *info = (struct !! 1311 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1221 unsigned long flags; !! 1312 unsigned long flags;
1222 volatile unsigned char *base_addr = ( !! 1313 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1223 int channel; !! 1314 int channel;
1224 1315
1225 #ifdef SERIAL_DEBUG_THROTTLE 1316 #ifdef SERIAL_DEBUG_THROTTLE
1226 char buf[64]; !! 1317 char buf[64];
1227 !! 1318
1228 printk("throttle %s: %d....\n", tty_n !! 1319 printk("throttle %s: %d....\n", tty_name(tty, buf),
1229 tty->ldisc.chars_in_buffer(tty !! 1320 tty->ldisc.chars_in_buffer(tty));
1230 printk("cy_throttle %s\n", tty->name) !! 1321 printk("cy_throttle %s\n", tty->name);
1231 #endif !! 1322 #endif
>> 1323
>> 1324 if (serial_paranoia_check(info, tty->name, "cy_nthrottle")){
>> 1325 return;
>> 1326 }
>> 1327
>> 1328 if (I_IXOFF(tty)) {
>> 1329 info->x_char = STOP_CHAR(tty);
>> 1330 /* Should use the "Send Special Character" feature!!! */
>> 1331 }
1232 1332
1233 if (serial_paranoia_check(info, tty-> !! 1333 channel = info->line;
1234 return; <<
1235 } <<
1236 1334
1237 if (I_IXOFF(tty)) { !! 1335 local_irq_save(flags);
1238 info->x_char = STOP_CHAR(tty) !! 1336 base_addr[CyCAR] = (u_char)channel;
1239 /* Should use the "Send Speci !! 1337 base_addr[CyMSVR1] = 0;
1240 } !! 1338 local_irq_restore(flags);
1241 1339
1242 channel = info->line; !! 1340 return;
>> 1341 } /* cy_throttle */
1243 1342
1244 local_irq_save(flags); <<
1245 base_addr[CyCAR] = (u_char) channel; <<
1246 base_addr[CyMSVR1] = 0; <<
1247 local_irq_restore(flags); <<
1248 } /* cy_throttl <<
1249 1343
1250 static void cy_unthrottle(struct tty_struct * !! 1344 static void
>> 1345 cy_unthrottle(struct tty_struct * tty)
1251 { 1346 {
1252 struct cyclades_port *info = (struct !! 1347 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1253 unsigned long flags; !! 1348 unsigned long flags;
1254 volatile unsigned char *base_addr = ( !! 1349 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1255 int channel; !! 1350 int channel;
1256 1351
1257 #ifdef SERIAL_DEBUG_THROTTLE 1352 #ifdef SERIAL_DEBUG_THROTTLE
1258 char buf[64]; !! 1353 char buf[64];
1259 !! 1354
1260 printk("throttle %s: %d....\n", tty_n !! 1355 printk("throttle %s: %d....\n", tty_name(tty, buf),
1261 tty->ldisc.chars_in_buffer(tty !! 1356 tty->ldisc.chars_in_buffer(tty));
1262 printk("cy_unthrottle %s\n", tty->nam !! 1357 printk("cy_unthrottle %s\n", tty->name);
1263 #endif !! 1358 #endif
1264 !! 1359
1265 if (serial_paranoia_check(info, tty-> !! 1360 if (serial_paranoia_check(info, tty->name, "cy_nthrottle")){
1266 return; !! 1361 return;
1267 } !! 1362 }
1268 !! 1363
1269 if (I_IXOFF(tty)) { !! 1364 if (I_IXOFF(tty)) {
1270 info->x_char = START_CHAR(tty !! 1365 info->x_char = START_CHAR(tty);
1271 /* Should use the "Send Speci !! 1366 /* Should use the "Send Special Character" feature!!! */
1272 } !! 1367 }
1273 1368
1274 channel = info->line; !! 1369 channel = info->line;
1275 1370
1276 local_irq_save(flags); !! 1371 local_irq_save(flags);
1277 base_addr[CyCAR] = (u_char) channel; !! 1372 base_addr[CyCAR] = (u_char)channel;
1278 base_addr[CyMSVR1] = CyRTS; 1373 base_addr[CyMSVR1] = CyRTS;
1279 local_irq_restore(flags); !! 1374 local_irq_restore(flags);
1280 } /* cy_unthrot !! 1375
>> 1376 return;
>> 1377 } /* cy_unthrottle */
1281 1378
1282 static int 1379 static int
1283 get_serial_info(struct cyclades_port *info, !! 1380 get_serial_info(struct cyclades_port * info,
1284 struct serial_struct __user * !! 1381 struct serial_struct * retinfo)
1285 { 1382 {
1286 struct serial_struct tmp; !! 1383 struct serial_struct tmp;
1287 1384
1288 /* CP('g'); */ 1385 /* CP('g'); */
1289 if (!retinfo) !! 1386 if (!retinfo)
1290 return -EFAULT; !! 1387 return -EFAULT;
1291 memset(&tmp, 0, sizeof(tmp)); !! 1388 memset(&tmp, 0, sizeof(tmp));
1292 tmp.type = info->type; !! 1389 tmp.type = info->type;
1293 tmp.line = info->line; !! 1390 tmp.line = info->line;
1294 tmp.port = info->line; !! 1391 tmp.port = info->line;
1295 tmp.irq = 0; !! 1392 tmp.irq = 0;
1296 tmp.flags = info->flags; !! 1393 tmp.flags = info->flags;
1297 tmp.baud_base = 0; /*!!! */ !! 1394 tmp.baud_base = 0; /*!!!*/
1298 tmp.close_delay = info->close_delay; !! 1395 tmp.close_delay = info->close_delay;
1299 tmp.custom_divisor = 0; /*!!! */ !! 1396 tmp.custom_divisor = 0; /*!!!*/
1300 tmp.hub6 = 0; /*!!! */ !! 1397 tmp.hub6 = 0; /*!!!*/
1301 return copy_to_user(retinfo, &tmp, si !! 1398 return copy_to_user(retinfo,&tmp,sizeof(*retinfo)) ? -EFAULT : 0;
1302 } /* get_serial !! 1399 } /* get_serial_info */
1303 1400
1304 static int 1401 static int
1305 set_serial_info(struct cyclades_port *info, !! 1402 set_serial_info(struct cyclades_port * info,
1306 struct serial_struct __user * !! 1403 struct serial_struct * new_info)
1307 { 1404 {
1308 struct serial_struct new_serial; !! 1405 struct serial_struct new_serial;
1309 struct cyclades_port old_info; !! 1406 struct cyclades_port old_info;
1310 1407
1311 /* CP('s'); */ 1408 /* CP('s'); */
1312 if (!new_info) !! 1409 if (!new_info)
1313 return -EFAULT; !! 1410 return -EFAULT;
1314 if (copy_from_user(&new_serial, new_i !! 1411 if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
1315 return -EFAULT; !! 1412 return -EFAULT;
1316 old_info = *info; !! 1413 old_info = *info;
1317 !! 1414
1318 if (!capable(CAP_SYS_ADMIN)) { !! 1415 if (!capable(CAP_SYS_ADMIN)) {
1319 if ((new_serial.close_delay ! !! 1416 if ((new_serial.close_delay != info->close_delay) ||
1320 ((new_serial.flags & ASYN !! 1417 ((new_serial.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK) !=
1321 (info->flags & ASYNC_FLA !! 1418 (info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK)))
1322 return -EPERM; !! 1419 return -EPERM;
1323 info->flags = ((info->flags & !! 1420 info->flags = ((info->flags & ~ASYNC_USR_MASK) |
1324 (new_serial.fl !! 1421 (new_serial.flags & ASYNC_USR_MASK));
1325 goto check_and_exit; !! 1422 goto check_and_exit;
1326 } !! 1423 }
1327 !! 1424
1328 /* !! 1425
1329 * OK, past this point, all the error !! 1426 /*
1330 * At this point, we start making cha !! 1427 * OK, past this point, all the error checking has been done.
1331 */ !! 1428 * At this point, we start making changes.....
>> 1429 */
>> 1430
>> 1431 info->flags = ((info->flags & ~ASYNC_FLAGS) |
>> 1432 (new_serial.flags & ASYNC_FLAGS));
>> 1433 info->close_delay = new_serial.close_delay;
1332 1434
1333 info->flags = ((info->flags & ~ASYNC_ <<
1334 (new_serial.flags & AS <<
1335 info->close_delay = new_serial.close_ <<
1336 1435
1337 check_and_exit: 1436 check_and_exit:
1338 if (info->flags & ASYNC_INITIALIZED) !! 1437 if (info->flags & ASYNC_INITIALIZED){
1339 config_setup(info); !! 1438 config_setup(info);
1340 return 0; !! 1439 return 0;
1341 } !! 1440 }else{
1342 return startup(info); !! 1441 return startup(info);
1343 } /* set_serial !! 1442 }
1344 !! 1443 } /* set_serial_info */
1345 static int cy_tiocmget(struct tty_struct *tty <<
1346 { <<
1347 struct cyclades_port *info = (struct <<
1348 int channel; <<
1349 volatile unsigned char *base_addr = ( <<
1350 unsigned long flags; <<
1351 unsigned char status; <<
1352 <<
1353 channel = info->line; <<
1354 <<
1355 local_irq_save(flags); <<
1356 base_addr[CyCAR] = (u_char) channel; <<
1357 status = base_addr[CyMSVR1] | base_ad <<
1358 local_irq_restore(flags); <<
1359 1444
1360 return ((status & CyRTS) ? TIOCM_RTS !! 1445 static int
1361 | ((status & CyDTR) ? TIOCM_DTR : !! 1446 cy_tiocmget(struct tty_struct *tty, struct file *file)
1362 | ((status & CyDCD) ? TIOCM_CAR : !! 1447 {
1363 | ((status & CyDSR) ? TIOCM_DSR : !! 1448 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
1364 | ((status & CyCTS) ? TIOCM_CTS : !! 1449 int channel;
1365 } /* cy_tiocmge !! 1450 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
>> 1451 unsigned long flags;
>> 1452 unsigned char status;
>> 1453 unsigned int result;
>> 1454
>> 1455 channel = info->line;
>> 1456
>> 1457 local_irq_save(flags);
>> 1458 base_addr[CyCAR] = (u_char)channel;
>> 1459 status = base_addr[CyMSVR1] | base_addr[CyMSVR2];
>> 1460 local_irq_restore(flags);
>> 1461
>> 1462 return ((status & CyRTS) ? TIOCM_RTS : 0)
>> 1463 | ((status & CyDTR) ? TIOCM_DTR : 0)
>> 1464 | ((status & CyDCD) ? TIOCM_CAR : 0)
>> 1465 | ((status & CyDSR) ? TIOCM_DSR : 0)
>> 1466 | ((status & CyCTS) ? TIOCM_CTS : 0);
>> 1467 } /* cy_tiocmget */
1366 1468
1367 static int 1469 static int
1368 cy_tiocmset(struct tty_struct *tty, struct fi 1470 cy_tiocmset(struct tty_struct *tty, struct file *file,
1369 unsigned int set, unsigned int cl 1471 unsigned int set, unsigned int clear)
1370 { 1472 {
1371 struct cyclades_port *info = (struct !! 1473 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
1372 int channel; !! 1474 int channel;
1373 volatile unsigned char *base_addr = ( !! 1475 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1374 unsigned long flags; !! 1476 unsigned long flags;
1375 !! 1477 unsigned int arg;
1376 channel = info->line; !! 1478
1377 !! 1479 channel = info->line;
1378 if (set & TIOCM_RTS) { !! 1480
1379 local_irq_save(flags); !! 1481 if (set & TIOCM_RTS){
1380 base_addr[CyCAR] = (u_char) c !! 1482 local_irq_save(flags);
>> 1483 base_addr[CyCAR] = (u_char)channel;
1381 base_addr[CyMSVR1] = CyRTS; 1484 base_addr[CyMSVR1] = CyRTS;
1382 local_irq_restore(flags); !! 1485 local_irq_restore(flags);
1383 } 1486 }
1384 if (set & TIOCM_DTR) { !! 1487 if (set & TIOCM_DTR){
1385 local_irq_save(flags); !! 1488 local_irq_save(flags);
1386 base_addr[CyCAR] = (u_char) c !! 1489 base_addr[CyCAR] = (u_char)channel;
1387 /* CP('S');CP('2'); */ 1490 /* CP('S');CP('2'); */
1388 base_addr[CyMSVR2] = CyDTR; !! 1491 base_addr[CyMSVR2] = CyDTR;
1389 #ifdef SERIAL_DEBUG_DTR 1492 #ifdef SERIAL_DEBUG_DTR
1390 printk("cyc: %d: raising DTR\ !! 1493 printk("cyc: %d: raising DTR\n", __LINE__);
1391 printk(" status: 0x%x, 0x !! 1494 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
1392 base_addr[CyMSVR2]); <<
1393 #endif 1495 #endif
1394 local_irq_restore(flags); !! 1496 local_irq_restore(flags);
1395 } 1497 }
1396 1498
1397 if (clear & TIOCM_RTS) { !! 1499 if (clear & TIOCM_RTS){
1398 local_irq_save(flags); !! 1500 local_irq_save(flags);
1399 base_addr[CyCAR] = (u_char) c !! 1501 base_addr[CyCAR] = (u_char)channel;
1400 base_addr[CyMSVR1] = 0; 1502 base_addr[CyMSVR1] = 0;
1401 local_irq_restore(flags); !! 1503 local_irq_restore(flags);
1402 } 1504 }
1403 if (clear & TIOCM_DTR) { !! 1505 if (clear & TIOCM_DTR){
1404 local_irq_save(flags); !! 1506 local_irq_save(flags);
1405 base_addr[CyCAR] = (u_char) c !! 1507 base_addr[CyCAR] = (u_char)channel;
1406 /* CP('C');CP('2'); */ 1508 /* CP('C');CP('2'); */
1407 base_addr[CyMSVR2] = 0; !! 1509 base_addr[CyMSVR2] = 0;
1408 #ifdef SERIAL_DEBUG_DTR 1510 #ifdef SERIAL_DEBUG_DTR
1409 printk("cyc: %d: dropping DTR !! 1511 printk("cyc: %d: dropping DTR\n", __LINE__);
1410 printk(" status: 0x%x, 0x !! 1512 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
1411 base_addr[CyMSVR2]); <<
1412 #endif 1513 #endif
1413 local_irq_restore(flags); !! 1514 local_irq_restore(flags);
1414 } 1515 }
1415 1516
1416 return 0; !! 1517 return 0;
1417 } /* set_modem_ !! 1518 } /* set_modem_info */
1418 1519
1419 static void send_break(struct cyclades_port * !! 1520 static void
1420 { /* Let the tr !! 1521 send_break( struct cyclades_port * info, int duration)
1421 requires s !! 1522 { /* Let the transmit ISR take care of this (since it
1422 */ !! 1523 requires stuffing characters into the output stream).
1423 info->x_break = duration; !! 1524 */
1424 if (!info->xmit_cnt) { !! 1525 info->x_break = duration;
1425 start_xmit(info); !! 1526 if (!info->xmit_cnt ) {
1426 } !! 1527 start_xmit(info);
1427 } /* send_break !! 1528 }
>> 1529 } /* send_break */
1428 1530
1429 static int 1531 static int
1430 get_mon_info(struct cyclades_port *info, stru !! 1532 get_mon_info(struct cyclades_port * info, struct cyclades_monitor * mon)
1431 { 1533 {
1432 1534
1433 if (copy_to_user(mon, &info->mon, siz !! 1535 if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor)))
1434 return -EFAULT; !! 1536 return -EFAULT;
1435 info->mon.int_count = 0; !! 1537 info->mon.int_count = 0;
1436 info->mon.char_count = 0; !! 1538 info->mon.char_count = 0;
1437 info->mon.char_max = 0; !! 1539 info->mon.char_max = 0;
1438 info->mon.char_last = 0; !! 1540 info->mon.char_last = 0;
1439 return 0; !! 1541 return 0;
1440 } 1542 }
1441 1543
1442 static int set_threshold(struct cyclades_port !! 1544 static int
>> 1545 set_threshold(struct cyclades_port * info, unsigned long *arg)
1443 { 1546 {
1444 volatile unsigned char *base_addr = ( !! 1547 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1445 unsigned long value; !! 1548 unsigned long value;
1446 int channel; !! 1549 int channel;
1447 !! 1550
1448 if (get_user(value, arg)) !! 1551 if (get_user(value, arg))
1449 return -EFAULT; !! 1552 return -EFAULT;
1450 !! 1553
1451 channel = info->line; !! 1554 channel = info->line;
1452 info->cor4 &= ~CyREC_FIFO; !! 1555 info->cor4 &= ~CyREC_FIFO;
1453 info->cor4 |= value & CyREC_FIFO; !! 1556 info->cor4 |= value & CyREC_FIFO;
1454 base_addr[CyCOR4] = info->cor4; !! 1557 base_addr[CyCOR4] = info->cor4;
1455 return 0; !! 1558 return 0;
1456 } 1559 }
1457 1560
1458 static int 1561 static int
1459 get_threshold(struct cyclades_port *info, uns !! 1562 get_threshold(struct cyclades_port * info, unsigned long *value)
1460 { 1563 {
1461 volatile unsigned char *base_addr = ( !! 1564 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1462 int channel; !! 1565 int channel;
1463 unsigned long tmp; !! 1566 unsigned long tmp;
1464 !! 1567
1465 channel = info->line; !! 1568 channel = info->line;
1466 1569
1467 tmp = base_addr[CyCOR4] & CyREC_FIFO; !! 1570 tmp = base_addr[CyCOR4] & CyREC_FIFO;
1468 return put_user(tmp, value); !! 1571 return put_user(tmp,value);
1469 } 1572 }
1470 1573
1471 static int 1574 static int
1472 set_default_threshold(struct cyclades_port *i !! 1575 set_default_threshold(struct cyclades_port * info, unsigned long *arg)
1473 { 1576 {
1474 unsigned long value; !! 1577 unsigned long value;
1475 1578
1476 if (get_user(value, arg)) !! 1579 if (get_user(value, arg))
1477 return -EFAULT; !! 1580 return -EFAULT;
1478 1581
1479 info->default_threshold = value & 0x0 !! 1582 info->default_threshold = value & 0x0f;
1480 return 0; !! 1583 return 0;
1481 } 1584 }
1482 1585
1483 static int 1586 static int
1484 get_default_threshold(struct cyclades_port *i !! 1587 get_default_threshold(struct cyclades_port * info, unsigned long *value)
1485 { 1588 {
1486 return put_user(info->default_thresho !! 1589 return put_user(info->default_threshold,value);
1487 } 1590 }
1488 1591
1489 static int set_timeout(struct cyclades_port * !! 1592 static int
>> 1593 set_timeout(struct cyclades_port * info, unsigned long *arg)
1490 { 1594 {
1491 volatile unsigned char *base_addr = ( !! 1595 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1492 int channel; !! 1596 int channel;
1493 unsigned long value; !! 1597 unsigned long value;
1494 !! 1598
1495 if (get_user(value, arg)) !! 1599 if (get_user(value, arg))
1496 return -EFAULT; !! 1600 return -EFAULT;
1497 !! 1601
1498 channel = info->line; !! 1602 channel = info->line;
1499 !! 1603
1500 base_addr[CyRTPRL] = value & 0xff; !! 1604 base_addr[CyRTPRL] = value & 0xff;
1501 base_addr[CyRTPRH] = (value >> 8) & 0 !! 1605 base_addr[CyRTPRH] = (value >> 8) & 0xff;
1502 return 0; !! 1606 return 0;
1503 } 1607 }
1504 1608
1505 static int get_timeout(struct cyclades_port * !! 1609 static int
>> 1610 get_timeout(struct cyclades_port * info, unsigned long *value)
1506 { 1611 {
1507 volatile unsigned char *base_addr = ( !! 1612 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1508 int channel; !! 1613 int channel;
1509 unsigned long tmp; !! 1614 unsigned long tmp;
>> 1615
>> 1616 channel = info->line;
1510 1617
1511 channel = info->line; !! 1618 tmp = base_addr[CyRTPRL];
1512 !! 1619 return put_user(tmp,value);
1513 tmp = base_addr[CyRTPRL]; <<
1514 return put_user(tmp, value); <<
1515 } 1620 }
1516 1621
1517 static int set_default_timeout(struct cyclade !! 1622 static int
>> 1623 set_default_timeout(struct cyclades_port * info, unsigned long value)
1518 { 1624 {
1519 info->default_timeout = value & 0xff; !! 1625 info->default_timeout = value & 0xff;
1520 return 0; !! 1626 return 0;
1521 } 1627 }
1522 1628
1523 static int 1629 static int
1524 get_default_timeout(struct cyclades_port *inf !! 1630 get_default_timeout(struct cyclades_port * info, unsigned long *value)
1525 { 1631 {
1526 return put_user(info->default_timeout !! 1632 return put_user(info->default_timeout,value);
1527 } 1633 }
1528 1634
1529 static int 1635 static int
1530 cy_ioctl(struct tty_struct *tty, struct file !! 1636 cy_ioctl(struct tty_struct *tty, struct file * file,
1531 unsigned int cmd, unsigned long arg) !! 1637 unsigned int cmd, unsigned long arg)
1532 { 1638 {
1533 unsigned long val; !! 1639 unsigned long val;
1534 struct cyclades_port *info = (struct !! 1640 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
1535 int ret_val = 0; !! 1641 int ret_val = 0;
1536 void __user *argp = (void __user *)ar <<
1537 1642
1538 #ifdef SERIAL_DEBUG_OTHER 1643 #ifdef SERIAL_DEBUG_OTHER
1539 printk("cy_ioctl %s, cmd = %x arg = % !! 1644 printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty->name, cmd, arg); /* */
1540 #endif 1645 #endif
1541 1646
1542 switch (cmd) { !! 1647 switch (cmd) {
1543 case CYGETMON: !! 1648 case CYGETMON:
1544 ret_val = get_mon_info(info, !! 1649 ret_val = get_mon_info(info, (struct cyclades_monitor *)arg);
1545 break; !! 1650 break;
1546 case CYGETTHRESH: !! 1651 case CYGETTHRESH:
1547 ret_val = get_threshold(info, !! 1652 ret_val = get_threshold(info, (unsigned long *)arg);
1548 break; !! 1653 break;
1549 case CYSETTHRESH: !! 1654 case CYSETTHRESH:
1550 ret_val = set_threshold(info, !! 1655 ret_val = set_threshold(info, (unsigned long *)arg);
1551 break; !! 1656 break;
1552 case CYGETDEFTHRESH: !! 1657 case CYGETDEFTHRESH:
1553 ret_val = get_default_thresho !! 1658 ret_val = get_default_threshold(info, (unsigned long *)arg);
1554 break; !! 1659 break;
1555 case CYSETDEFTHRESH: !! 1660 case CYSETDEFTHRESH:
1556 ret_val = set_default_thresho !! 1661 ret_val = set_default_threshold(info, (unsigned long *)arg);
1557 break; !! 1662 break;
1558 case CYGETTIMEOUT: !! 1663 case CYGETTIMEOUT:
1559 ret_val = get_timeout(info, a !! 1664 ret_val = get_timeout(info, (unsigned long *)arg);
1560 break; !! 1665 break;
1561 case CYSETTIMEOUT: !! 1666 case CYSETTIMEOUT:
1562 ret_val = set_timeout(info, a !! 1667 ret_val = set_timeout(info, (unsigned long *)arg);
1563 break; !! 1668 break;
1564 case CYGETDEFTIMEOUT: !! 1669 case CYGETDEFTIMEOUT:
1565 ret_val = get_default_timeout !! 1670 ret_val = get_default_timeout(info, (unsigned long *)arg);
1566 break; !! 1671 break;
1567 case CYSETDEFTIMEOUT: !! 1672 case CYSETDEFTIMEOUT:
1568 ret_val = set_default_timeout !! 1673 ret_val = set_default_timeout(info, (unsigned long)arg);
1569 break; !! 1674 break;
1570 case TCSBRK: /* SVID versi !! 1675 case TCSBRK: /* SVID version: non-zero arg --> no break */
1571 ret_val = tty_check_change(tt !! 1676 ret_val = tty_check_change(tty);
1572 if (ret_val) !! 1677 if (ret_val)
1573 break; !! 1678 break;
1574 tty_wait_until_sent(tty, 0); !! 1679 tty_wait_until_sent(tty,0);
1575 if (!arg) !! 1680 if (!arg)
1576 send_break(info, HZ / !! 1681 send_break(info, HZ/4); /* 1/4 second */
1577 break; !! 1682 break;
1578 case TCSBRKP: /* support fo !! 1683 case TCSBRKP: /* support for POSIX tcsendbreak() */
1579 ret_val = tty_check_change(tt !! 1684 ret_val = tty_check_change(tty);
1580 if (ret_val) !! 1685 if (ret_val)
1581 break; !! 1686 break;
1582 tty_wait_until_sent(tty, 0); !! 1687 tty_wait_until_sent(tty,0);
1583 send_break(info, arg ? arg * !! 1688 send_break(info, arg ? arg*(HZ/10) : HZ/4);
1584 break; !! 1689 break;
1585 1690
1586 /* The following commands are incompletely im 1691 /* The following commands are incompletely implemented!!! */
1587 case TIOCGSOFTCAR: !! 1692 case TIOCGSOFTCAR:
1588 ret_val = !! 1693 ret_val = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long *) arg);
1589 put_user(C_CLOCAL(tty) ? !! 1694 break;
1590 (unsigned long _ !! 1695 case TIOCSSOFTCAR:
1591 break; !! 1696 ret_val = get_user(val, (unsigned long *) arg);
1592 case TIOCSSOFTCAR: !! 1697 if (ret_val)
1593 ret_val = get_user(val, (unsi !! 1698 break;
1594 if (ret_val) !! 1699 tty->termios->c_cflag =
1595 break; !! 1700 ((tty->termios->c_cflag & ~CLOCAL) | (val ? CLOCAL : 0));
1596 tty->termios->c_cflag = !! 1701 break;
1597 ((tty->termios->c_cflag & !! 1702 case TIOCGSERIAL:
1598 break; !! 1703 ret_val = get_serial_info(info, (struct serial_struct *) arg);
1599 case TIOCGSERIAL: !! 1704 break;
1600 ret_val = get_serial_info(inf !! 1705 case TIOCSSERIAL:
1601 break; !! 1706 ret_val = set_serial_info(info,
1602 case TIOCSSERIAL: !! 1707 (struct serial_struct *) arg);
1603 ret_val = set_serial_info(inf !! 1708 break;
1604 break; !! 1709 default:
1605 default: !! 1710 ret_val = -ENOIOCTLCMD;
1606 ret_val = -ENOIOCTLCMD; !! 1711 }
1607 } <<
1608 1712
1609 #ifdef SERIAL_DEBUG_OTHER 1713 #ifdef SERIAL_DEBUG_OTHER
1610 printk("cy_ioctl done\n"); !! 1714 printk("cy_ioctl done\n");
1611 #endif 1715 #endif
1612 1716
1613 return ret_val; !! 1717 return ret_val;
1614 } /* cy_ioctl * !! 1718 } /* cy_ioctl */
>> 1719
>> 1720
>> 1721
1615 1722
1616 static void cy_set_termios(struct tty_struct !! 1723 static void
>> 1724 cy_set_termios(struct tty_struct *tty, struct termios * old_termios)
1617 { 1725 {
1618 struct cyclades_port *info = (struct !! 1726 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1619 1727
1620 #ifdef SERIAL_DEBUG_OTHER 1728 #ifdef SERIAL_DEBUG_OTHER
1621 printk("cy_set_termios %s\n", tty->na !! 1729 printk("cy_set_termios %s\n", tty->name);
1622 #endif 1730 #endif
1623 1731
1624 if (tty->termios->c_cflag == old_term !! 1732 if (tty->termios->c_cflag == old_termios->c_cflag)
1625 return; !! 1733 return;
1626 config_setup(info); !! 1734 config_setup(info);
1627 !! 1735
1628 if ((old_termios->c_cflag & CRTSCTS) !! 1736 if ((old_termios->c_cflag & CRTSCTS) &&
1629 !(tty->termios->c_cflag & CRTSCTS !! 1737 !(tty->termios->c_cflag & CRTSCTS)) {
1630 tty->stopped = 0; !! 1738 tty->stopped = 0;
1631 cy_start(tty); !! 1739 cy_start(tty);
1632 } !! 1740 }
1633 #ifdef tytso_patch_94Nov25_1726 1741 #ifdef tytso_patch_94Nov25_1726
1634 if (!(old_termios->c_cflag & CLOCAL) !! 1742 if (!(old_termios->c_cflag & CLOCAL) &&
1635 (tty->termios->c_cflag & CLOCAL)) !! 1743 (tty->termios->c_cflag & CLOCAL))
1636 wake_up_interruptible(&info-> !! 1744 wake_up_interruptible(&info->open_wait);
1637 #endif 1745 #endif
1638 } /* cy_set_ter <<
1639 1746
1640 static void cy_close(struct tty_struct *tty, !! 1747 return;
>> 1748 } /* cy_set_termios */
>> 1749
>> 1750
>> 1751 static void
>> 1752 cy_close(struct tty_struct * tty, struct file * filp)
1641 { 1753 {
1642 struct cyclades_port *info = (struct !! 1754 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
1643 1755
1644 /* CP('C'); */ 1756 /* CP('C'); */
1645 #ifdef SERIAL_DEBUG_OTHER 1757 #ifdef SERIAL_DEBUG_OTHER
1646 printk("cy_close %s\n", tty->name); !! 1758 printk("cy_close %s\n", tty->name);
1647 #endif 1759 #endif
1648 1760
1649 if (!info || serial_paranoia_check(in !! 1761 if (!info
1650 return; !! 1762 || serial_paranoia_check(info, tty->name, "cy_close")){
1651 } !! 1763 return;
>> 1764 }
1652 #ifdef SERIAL_DEBUG_OPEN 1765 #ifdef SERIAL_DEBUG_OPEN
1653 printk("cy_close %s, count = %d\n", t !! 1766 printk("cy_close %s, count = %d\n", tty->name, info->count);
1654 #endif 1767 #endif
1655 1768
1656 if ((tty->count == 1) && (info->count !! 1769 if ((tty->count == 1) && (info->count != 1)) {
1657 /* !! 1770 /*
1658 * Uh, oh. tty->count is 1, !! 1771 * Uh, oh. tty->count is 1, which means that the tty
1659 * structure will be freed. !! 1772 * structure will be freed. Info->count should always
1660 * be one in these conditions !! 1773 * be one in these conditions. If it's greater than
1661 * one, we've got real proble !! 1774 * one, we've got real problems, since it means the
1662 * serial port won't be shutd !! 1775 * serial port won't be shutdown.
1663 */ !! 1776 */
1664 printk("cy_close: bad serial !! 1777 printk("cy_close: bad serial port count; tty->count is 1, "
1665 "info->count is %d\n", !! 1778 "info->count is %d\n", info->count);
1666 info->count = 1; !! 1779 info->count = 1;
1667 } !! 1780 }
1668 #ifdef SERIAL_DEBUG_COUNT 1781 #ifdef SERIAL_DEBUG_COUNT
1669 printk("cyc: %d: decrementing count t !! 1782 printk("cyc: %d: decrementing count to %d\n", __LINE__, info->count - 1);
1670 info->count - 1); <<
1671 #endif 1783 #endif
1672 if (--info->count < 0) { !! 1784 if (--info->count < 0) {
1673 printk("cy_close: bad serial !! 1785 printk("cy_close: bad serial port count for ttys%d: %d\n",
1674 info->line, info->coun !! 1786 info->line, info->count);
1675 #ifdef SERIAL_DEBUG_COUNT 1787 #ifdef SERIAL_DEBUG_COUNT
1676 printk("cyc: %d: setting coun !! 1788 printk("cyc: %d: setting count to 0\n", __LINE__);
1677 #endif 1789 #endif
1678 info->count = 0; !! 1790 info->count = 0;
1679 } !! 1791 }
1680 if (info->count) !! 1792 if (info->count)
1681 return; !! 1793 return;
1682 info->flags |= ASYNC_CLOSING; !! 1794 info->flags |= ASYNC_CLOSING;
1683 if (info->flags & ASYNC_INITIALIZED) !! 1795 if (info->flags & ASYNC_INITIALIZED)
1684 tty_wait_until_sent(tty, 3000 !! 1796 tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */
1685 shutdown(info); !! 1797 shutdown(info);
1686 if (tty->driver->flush_buffer) !! 1798 if (tty->driver->flush_buffer)
1687 tty->driver->flush_buffer(tty !! 1799 tty->driver->flush_buffer(tty);
1688 tty_ldisc_flush(tty); !! 1800 tty_ldisc_flush(tty);
1689 info->tty = NULL; !! 1801 info->event = 0;
1690 if (info->blocked_open) { !! 1802 info->tty = 0;
1691 if (info->close_delay) { !! 1803 if (info->blocked_open) {
1692 msleep_interruptible( !! 1804 if (info->close_delay) {
1693 !! 1805 msleep_interruptible(jiffies_to_msecs(info->close_delay));
1694 } <<
1695 wake_up_interruptible(&info-> <<
1696 } 1806 }
1697 info->flags &= ~(ASYNC_NORMAL_ACTIVE !! 1807 wake_up_interruptible(&info->open_wait);
1698 wake_up_interruptible(&info->close_wa !! 1808 }
>> 1809 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
>> 1810 wake_up_interruptible(&info->close_wait);
1699 1811
1700 #ifdef SERIAL_DEBUG_OTHER 1812 #ifdef SERIAL_DEBUG_OTHER
1701 printk("cy_close done\n"); !! 1813 printk("cy_close done\n");
1702 #endif 1814 #endif
1703 } /* cy_close * !! 1815
>> 1816 return;
>> 1817 } /* cy_close */
1704 1818
1705 /* 1819 /*
1706 * cy_hangup() --- called by tty_hangup() whe 1820 * cy_hangup() --- called by tty_hangup() when a hangup is signaled.
1707 */ 1821 */
1708 void cy_hangup(struct tty_struct *tty) !! 1822 void
>> 1823 cy_hangup(struct tty_struct *tty)
1709 { 1824 {
1710 struct cyclades_port *info = (struct !! 1825 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
1711 !! 1826
1712 #ifdef SERIAL_DEBUG_OTHER 1827 #ifdef SERIAL_DEBUG_OTHER
1713 printk("cy_hangup %s\n", tty->name); !! 1828 printk("cy_hangup %s\n", tty->name); /* */
1714 #endif 1829 #endif
1715 1830
1716 if (serial_paranoia_check(info, tty-> !! 1831 if (serial_paranoia_check(info, tty->name, "cy_hangup"))
1717 return; !! 1832 return;
1718 !! 1833
1719 shutdown(info); !! 1834 shutdown(info);
1720 #if 0 1835 #if 0
1721 info->event = 0; !! 1836 info->event = 0;
1722 info->count = 0; !! 1837 info->count = 0;
1723 #ifdef SERIAL_DEBUG_COUNT 1838 #ifdef SERIAL_DEBUG_COUNT
1724 printk("cyc: %d: setting count to 0\n !! 1839 printk("cyc: %d: setting count to 0\n", __LINE__);
1725 #endif 1840 #endif
1726 info->tty = 0; !! 1841 info->tty = 0;
1727 #endif 1842 #endif
1728 info->flags &= ~ASYNC_NORMAL_ACTIVE; !! 1843 info->flags &= ~ASYNC_NORMAL_ACTIVE;
1729 wake_up_interruptible(&info->open_wai !! 1844 wake_up_interruptible(&info->open_wait);
1730 } /* cy_hangup !! 1845 } /* cy_hangup */
>> 1846
>> 1847
1731 1848
1732 /* 1849 /*
1733 * ------------------------------------------ 1850 * ------------------------------------------------------------
1734 * cy_open() and friends 1851 * cy_open() and friends
1735 * ------------------------------------------ 1852 * ------------------------------------------------------------
1736 */ 1853 */
1737 1854
1738 static int 1855 static int
1739 block_til_ready(struct tty_struct *tty, struc !! 1856 block_til_ready(struct tty_struct *tty, struct file * filp,
1740 struct cyclades_port *info) !! 1857 struct cyclades_port *info)
1741 { 1858 {
1742 DECLARE_WAITQUEUE(wait, current); !! 1859 DECLARE_WAITQUEUE(wait, current);
1743 unsigned long flags; !! 1860 unsigned long flags;
1744 int channel; !! 1861 int channel;
1745 int retval; !! 1862 int retval;
1746 volatile u_char *base_addr = (u_char !! 1863 volatile u_char *base_addr = (u_char *)BASE_ADDR;
1747 !! 1864
1748 /* !! 1865 /*
1749 * If the device is in the middle of !! 1866 * If the device is in the middle of being closed, then block
1750 * until it's done, and then try agai !! 1867 * until it's done, and then try again.
1751 */ !! 1868 */
1752 if (info->flags & ASYNC_CLOSING) { !! 1869 if (info->flags & ASYNC_CLOSING) {
1753 interruptible_sleep_on(&info- !! 1870 interruptible_sleep_on(&info->close_wait);
1754 if (info->flags & ASYNC_HUP_N !! 1871 if (info->flags & ASYNC_HUP_NOTIFY){
1755 return -EAGAIN; !! 1872 return -EAGAIN;
1756 } else { !! 1873 }else{
1757 return -ERESTARTSYS; !! 1874 return -ERESTARTSYS;
1758 } !! 1875 }
1759 } !! 1876 }
1760 !! 1877
1761 /* !! 1878 /*
1762 * If non-blocking mode is set, then !! 1879 * If non-blocking mode is set, then make the check up front
1763 * and then exit. !! 1880 * and then exit.
1764 */ !! 1881 */
1765 if (filp->f_flags & O_NONBLOCK) { !! 1882 if (filp->f_flags & O_NONBLOCK) {
1766 info->flags |= ASYNC_NORMAL_A !! 1883 info->flags |= ASYNC_NORMAL_ACTIVE;
1767 return 0; !! 1884 return 0;
1768 } !! 1885 }
1769 1886
1770 /* !! 1887 /*
1771 * Block waiting for the carrier dete !! 1888 * Block waiting for the carrier detect and the line to become
1772 * free (i.e., not in use by the call !! 1889 * free (i.e., not in use by the callout). While we are in
1773 * this loop, info->count is dropped !! 1890 * this loop, info->count is dropped by one, so that
1774 * cy_close() knows when to free thin !! 1891 * cy_close() knows when to free things. We restore it upon
1775 * exit, either normal or abnormal. !! 1892 * exit, either normal or abnormal.
1776 */ !! 1893 */
1777 retval = 0; !! 1894 retval = 0;
1778 add_wait_queue(&info->open_wait, &wai !! 1895 add_wait_queue(&info->open_wait, &wait);
1779 #ifdef SERIAL_DEBUG_OPEN 1896 #ifdef SERIAL_DEBUG_OPEN
1780 printk("block_til_ready before block: !! 1897 printk("block_til_ready before block: %s, count = %d\n",
1781 tty->name, info->count); !! 1898 tty->name, info->count);/**/
1782 /**/ <<
1783 #endif 1899 #endif
1784 info->count--; !! 1900 info->count--;
1785 #ifdef SERIAL_DEBUG_COUNT 1901 #ifdef SERIAL_DEBUG_COUNT
1786 printk("cyc: %d: decrementing count t !! 1902 printk("cyc: %d: decrementing count to %d\n", __LINE__, info->count);
1787 #endif 1903 #endif
1788 info->blocked_open++; !! 1904 info->blocked_open++;
1789 1905
1790 channel = info->line; !! 1906 channel = info->line;
1791 1907
1792 while (1) { !! 1908 while (1) {
1793 local_irq_save(flags); !! 1909 local_irq_save(flags);
1794 base_addr[CyCAR] = (u_char) c !! 1910 base_addr[CyCAR] = (u_char)channel;
1795 base_addr[CyMSVR1] = CyRTS; !! 1911 base_addr[CyMSVR1] = CyRTS;
1796 /* CP('S');CP('4'); */ 1912 /* CP('S');CP('4'); */
1797 base_addr[CyMSVR2] = CyDTR; !! 1913 base_addr[CyMSVR2] = CyDTR;
1798 #ifdef SERIAL_DEBUG_DTR 1914 #ifdef SERIAL_DEBUG_DTR
1799 printk("cyc: %d: raising DTR\ !! 1915 printk("cyc: %d: raising DTR\n", __LINE__);
1800 printk(" status: 0x%x, 0x !! 1916 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
1801 base_addr[CyMSVR2]); !! 1917 #endif
1802 #endif !! 1918 local_irq_restore(flags);
1803 local_irq_restore(flags); !! 1919 set_current_state(TASK_INTERRUPTIBLE);
1804 set_current_state(TASK_INTERR !! 1920 if (tty_hung_up_p(filp)
1805 if (tty_hung_up_p(filp) !! 1921 || !(info->flags & ASYNC_INITIALIZED) ){
1806 || !(info->flags & ASYNC_ !! 1922 if (info->flags & ASYNC_HUP_NOTIFY) {
1807 if (info->flags & ASY !! 1923 retval = -EAGAIN;
1808 retval = -EAG !! 1924 }else{
1809 } else { !! 1925 retval = -ERESTARTSYS;
1810 retval = -ERE !! 1926 }
1811 } !! 1927 break;
1812 break; !! 1928 }
1813 } !! 1929 local_irq_save(flags);
1814 local_irq_save(flags); !! 1930 base_addr[CyCAR] = (u_char)channel;
1815 base_addr[CyCAR] = (u_char) c <<
1816 /* CP('L');CP1(1 && C_CLOCAL(tty)); CP1(1 && 1931 /* CP('L');CP1(1 && C_CLOCAL(tty)); CP1(1 && (base_addr[CyMSVR1] & CyDCD) ); */
1817 if (!(info->flags & ASYNC_CLO !! 1932 if (!(info->flags & ASYNC_CLOSING)
1818 && (C_CLOCAL(tty) !! 1933 && (C_CLOCAL(tty)
1819 || (base_addr[CyMSVR1 !! 1934 || (base_addr[CyMSVR1] & CyDCD))) {
1820 local_irq_restore(fla !! 1935 local_irq_restore(flags);
1821 break; !! 1936 break;
1822 } !! 1937 }
1823 local_irq_restore(flags); !! 1938 local_irq_restore(flags);
1824 if (signal_pending(current)) !! 1939 if (signal_pending(current)) {
1825 retval = -ERESTARTSYS !! 1940 retval = -ERESTARTSYS;
1826 break; !! 1941 break;
1827 } !! 1942 }
1828 #ifdef SERIAL_DEBUG_OPEN 1943 #ifdef SERIAL_DEBUG_OPEN
1829 printk("block_til_ready block !! 1944 printk("block_til_ready blocking: %s, count = %d\n",
1830 tty->name, info->count !! 1945 tty->name, info->count);/**/
1831 /**/ !! 1946 #endif
1832 #endif !! 1947 schedule();
1833 schedule(); !! 1948 }
1834 } !! 1949 current->state = TASK_RUNNING;
1835 __set_current_state(TASK_RUNNING); !! 1950 remove_wait_queue(&info->open_wait, &wait);
1836 remove_wait_queue(&info->open_wait, & !! 1951 if (!tty_hung_up_p(filp)){
1837 if (!tty_hung_up_p(filp)) { !! 1952 info->count++;
1838 info->count++; <<
1839 #ifdef SERIAL_DEBUG_COUNT 1953 #ifdef SERIAL_DEBUG_COUNT
1840 printk("cyc: %d: incrementing !! 1954 printk("cyc: %d: incrementing count to %d\n", __LINE__, info->count);
1841 info->count); <<
1842 #endif 1955 #endif
1843 } !! 1956 }
1844 info->blocked_open--; !! 1957 info->blocked_open--;
1845 #ifdef SERIAL_DEBUG_OPEN 1958 #ifdef SERIAL_DEBUG_OPEN
1846 printk("block_til_ready after blockin !! 1959 printk("block_til_ready after blocking: %s, count = %d\n",
1847 tty->name, info->count); !! 1960 tty->name, info->count);/**/
1848 /**/ <<
1849 #endif 1961 #endif
1850 if (retval) !! 1962 if (retval)
1851 return retval; !! 1963 return retval;
1852 info->flags |= ASYNC_NORMAL_ACTIVE; !! 1964 info->flags |= ASYNC_NORMAL_ACTIVE;
1853 return 0; !! 1965 return 0;
1854 } /* block_til_ !! 1966 } /* block_til_ready */
1855 1967
1856 /* 1968 /*
1857 * This routine is called whenever a serial p 1969 * This routine is called whenever a serial port is opened. It
1858 * performs the serial-specific initializatio 1970 * performs the serial-specific initialization for the tty structure.
1859 */ 1971 */
1860 int cy_open(struct tty_struct *tty, struct fi !! 1972 int
>> 1973 cy_open(struct tty_struct *tty, struct file * filp)
1861 { 1974 {
1862 struct cyclades_port *info; !! 1975 struct cyclades_port *info;
1863 int retval, line; !! 1976 int retval, line;
1864 1977
1865 /* CP('O'); */ 1978 /* CP('O'); */
1866 line = tty->index; !! 1979 line = tty->index;
1867 if ((line < 0) || (NR_PORTS <= line)) !! 1980 if ((line < 0) || (NR_PORTS <= line)){
1868 return -ENODEV; !! 1981 return -ENODEV;
1869 } !! 1982 }
1870 info = &cy_port[line]; !! 1983 info = &cy_port[line];
1871 if (info->line < 0) { !! 1984 if (info->line < 0){
1872 return -ENODEV; !! 1985 return -ENODEV;
1873 } !! 1986 }
1874 #ifdef SERIAL_DEBUG_OTHER 1987 #ifdef SERIAL_DEBUG_OTHER
1875 printk("cy_open %s\n", tty->name); !! 1988 printk("cy_open %s\n", tty->name); /* */
1876 #endif 1989 #endif
1877 if (serial_paranoia_check(info, tty-> !! 1990 if (serial_paranoia_check(info, tty->name, "cy_open")){
1878 return -ENODEV; !! 1991 return -ENODEV;
1879 } !! 1992 }
1880 #ifdef SERIAL_DEBUG_OPEN 1993 #ifdef SERIAL_DEBUG_OPEN
1881 printk("cy_open %s, count = %d\n", tt !! 1994 printk("cy_open %s, count = %d\n", tty->name, info->count);/**/
1882 /**/ <<
1883 #endif 1995 #endif
1884 info->count++; !! 1996 info->count++;
1885 #ifdef SERIAL_DEBUG_COUNT 1997 #ifdef SERIAL_DEBUG_COUNT
1886 printk("cyc: %d: incrementing count t !! 1998 printk("cyc: %d: incrementing count to %d\n", __LINE__, info->count);
1887 #endif 1999 #endif
1888 tty->driver_data = info; !! 2000 tty->driver_data = info;
1889 info->tty = tty; !! 2001 info->tty = tty;
1890 2002
1891 /* !! 2003 if (!tmp_buf) {
1892 * Start up serial port !! 2004 tmp_buf = (unsigned char *) get_zeroed_page(GFP_KERNEL);
1893 */ !! 2005 if (!tmp_buf){
1894 retval = startup(info); !! 2006 return -ENOMEM;
1895 if (retval) { !! 2007 }
1896 return retval; !! 2008 }
1897 } !! 2009
>> 2010 /*
>> 2011 * Start up serial port
>> 2012 */
>> 2013 retval = startup(info);
>> 2014 if (retval){
>> 2015 return retval;
>> 2016 }
1898 2017
1899 retval = block_til_ready(tty, filp, i !! 2018 retval = block_til_ready(tty, filp, info);
1900 if (retval) { !! 2019 if (retval) {
1901 #ifdef SERIAL_DEBUG_OPEN 2020 #ifdef SERIAL_DEBUG_OPEN
1902 printk("cy_open returning aft !! 2021 printk("cy_open returning after block_til_ready with %d\n",
1903 retval); !! 2022 retval);
1904 #endif 2023 #endif
1905 return retval; !! 2024 return retval;
1906 } !! 2025 }
>> 2026
1907 #ifdef SERIAL_DEBUG_OPEN 2027 #ifdef SERIAL_DEBUG_OPEN
1908 printk("cy_open done\n"); !! 2028 printk("cy_open done\n");/**/
1909 /**/ <<
1910 #endif 2029 #endif
1911 return 0; !! 2030 return 0;
1912 } /* cy_open */ !! 2031 } /* cy_open */
>> 2032
>> 2033
1913 2034
1914 /* 2035 /*
1915 * ------------------------------------------ 2036 * ---------------------------------------------------------------------
1916 * serial167_init() and friends 2037 * serial167_init() and friends
1917 * 2038 *
1918 * serial167_init() is called at boot-time to 2039 * serial167_init() is called at boot-time to initialize the serial driver.
1919 * ------------------------------------------ 2040 * ---------------------------------------------------------------------
1920 */ 2041 */
1921 2042
1922 /* 2043 /*
1923 * This routine prints out the appropriate se 2044 * This routine prints out the appropriate serial driver version
1924 * number, and identifies which options were 2045 * number, and identifies which options were configured into this
1925 * driver. 2046 * driver.
1926 */ 2047 */
1927 static void show_version(void) !! 2048 static void
>> 2049 show_version(void)
1928 { 2050 {
1929 printk("MVME166/167 cd2401 driver\n") !! 2051 printk("MVME166/167 cd2401 driver\n");
1930 } /* show_versi !! 2052 } /* show_version */
1931 2053
1932 /* initialize chips on card -- return number 2054 /* initialize chips on card -- return number of valid
1933 chips (which is number of ports/4) */ 2055 chips (which is number of ports/4) */
1934 2056
1935 /* 2057 /*
1936 * This initialises the hardware to a reasona 2058 * This initialises the hardware to a reasonable state. It should
1937 * probe the chip first so as to copy 166-Bug 2059 * probe the chip first so as to copy 166-Bug setup as a default for
1938 * port 0. It initialises CMR to CyASYNC; th 2060 * port 0. It initialises CMR to CyASYNC; that is never done again, so
1939 * as to limit the number of CyINIT_CHAN comm 2061 * as to limit the number of CyINIT_CHAN commands in normal running.
1940 * 2062 *
1941 * ... I wonder what I should do if this fail 2063 * ... I wonder what I should do if this fails ...
1942 */ 2064 */
1943 2065
1944 void mvme167_serial_console_setup(int cflag) !! 2066 void
>> 2067 mvme167_serial_console_setup(int cflag)
1945 { 2068 {
1946 volatile unsigned char *base_addr = ( !! 2069 volatile unsigned char* base_addr = (u_char *)BASE_ADDR;
1947 int ch; 2070 int ch;
1948 u_char spd; 2071 u_char spd;
1949 u_char rcor, rbpr, badspeed = 0; 2072 u_char rcor, rbpr, badspeed = 0;
1950 unsigned long flags; 2073 unsigned long flags;
1951 2074
1952 local_irq_save(flags); 2075 local_irq_save(flags);
1953 2076
1954 /* 2077 /*
1955 * First probe channel zero of the ch 2078 * First probe channel zero of the chip, to see what speed has
1956 * been selected. 2079 * been selected.
1957 */ 2080 */
1958 2081
1959 base_addr[CyCAR] = 0; 2082 base_addr[CyCAR] = 0;
1960 2083
1961 rcor = base_addr[CyRCOR] << 5; 2084 rcor = base_addr[CyRCOR] << 5;
1962 rbpr = base_addr[CyRBPR]; 2085 rbpr = base_addr[CyRBPR];
1963 2086
1964 for (spd = 0; spd < sizeof(baud_bpr); 2087 for (spd = 0; spd < sizeof(baud_bpr); spd++)
1965 if (rbpr == baud_bpr[spd] && 2088 if (rbpr == baud_bpr[spd] && rcor == baud_co[spd])
1966 break; 2089 break;
1967 if (spd >= sizeof(baud_bpr)) { 2090 if (spd >= sizeof(baud_bpr)) {
1968 spd = 14; /* 19200 */ 2091 spd = 14; /* 19200 */
1969 badspeed = 1; /* Failed to 2092 badspeed = 1; /* Failed to identify speed */
1970 } 2093 }
1971 initial_console_speed = spd; 2094 initial_console_speed = spd;
1972 2095
1973 /* OK, we have chosen a speed, now re 2096 /* OK, we have chosen a speed, now reset and reinitialise */
1974 2097
1975 my_udelay(20000L); /* Allow time !! 2098 my_udelay(20000L); /* Allow time for any active o/p to complete */
1976 if (base_addr[CyCCR] != 0x00) { !! 2099 if(base_addr[CyCCR] != 0x00){
1977 local_irq_restore(flags); !! 2100 local_irq_restore(flags);
1978 /* printk(" chip is never idl !! 2101 /* printk(" chip is never idle (CCR != 0)\n"); */
1979 return; !! 2102 return;
1980 } !! 2103 }
1981 !! 2104
1982 base_addr[CyCCR] = CyCHIP_RESET; !! 2105 base_addr[CyCCR] = CyCHIP_RESET; /* Reset the chip */
1983 my_udelay(1000L); !! 2106 my_udelay(1000L);
1984 !! 2107
1985 if (base_addr[CyGFRCR] == 0x00) { !! 2108 if(base_addr[CyGFRCR] == 0x00){
1986 local_irq_restore(flags); !! 2109 local_irq_restore(flags);
1987 /* printk(" chip is not respo !! 2110 /* printk(" chip is not responding (GFRCR stayed 0)\n"); */
1988 return; !! 2111 return;
1989 } !! 2112 }
1990 2113
1991 /* 2114 /*
1992 * System clock is 20Mhz, divided by 2115 * System clock is 20Mhz, divided by 2048, so divide by 10 for a 1.0ms
1993 * tick 2116 * tick
1994 */ 2117 */
1995 2118
1996 base_addr[CyTPR] = 10; 2119 base_addr[CyTPR] = 10;
1997 2120
1998 base_addr[CyPILR1] = 0x01; /* In !! 2121 base_addr[CyPILR1] = 0x01; /* Interrupt level for modem change */
1999 base_addr[CyPILR2] = 0x02; /* In !! 2122 base_addr[CyPILR2] = 0x02; /* Interrupt level for tx ints */
2000 base_addr[CyPILR3] = 0x03; /* In !! 2123 base_addr[CyPILR3] = 0x03; /* Interrupt level for rx ints */
2001 2124
2002 /* 2125 /*
2003 * Attempt to set up all channels to 2126 * Attempt to set up all channels to something reasonable, and
2004 * bang out a INIT_CHAN command. We 2127 * bang out a INIT_CHAN command. We should then be able to limit
2005 * the ammount of fiddling we have to 2128 * the ammount of fiddling we have to do in normal running.
2006 */ 2129 */
2007 2130
2008 for (ch = 3; ch >= 0; ch--) { !! 2131 for (ch = 3; ch >= 0 ; ch--) {
2009 base_addr[CyCAR] = (u_char) c !! 2132 base_addr[CyCAR] = (u_char)ch;
2010 base_addr[CyIER] = 0; 2133 base_addr[CyIER] = 0;
2011 base_addr[CyCMR] = CyASYNC; 2134 base_addr[CyCMR] = CyASYNC;
2012 base_addr[CyLICR] = (u_char) !! 2135 base_addr[CyLICR] = (u_char)ch << 2;
2013 base_addr[CyLIVR] = 0x5c; 2136 base_addr[CyLIVR] = 0x5c;
2014 base_addr[CyTCOR] = baud_co[s 2137 base_addr[CyTCOR] = baud_co[spd];
2015 base_addr[CyTBPR] = baud_bpr[ 2138 base_addr[CyTBPR] = baud_bpr[spd];
2016 base_addr[CyRCOR] = baud_co[s 2139 base_addr[CyRCOR] = baud_co[spd] >> 5;
2017 base_addr[CyRBPR] = baud_bpr[ 2140 base_addr[CyRBPR] = baud_bpr[spd];
2018 base_addr[CySCHR1] = 'Q' & 0x 2141 base_addr[CySCHR1] = 'Q' & 0x1f;
2019 base_addr[CySCHR2] = 'X' & 0x 2142 base_addr[CySCHR2] = 'X' & 0x1f;
2020 base_addr[CySCRL] = 0; 2143 base_addr[CySCRL] = 0;
2021 base_addr[CySCRH] = 0; 2144 base_addr[CySCRH] = 0;
2022 base_addr[CyCOR1] = Cy_8_BITS 2145 base_addr[CyCOR1] = Cy_8_BITS | CyPARITY_NONE;
2023 base_addr[CyCOR2] = 0; 2146 base_addr[CyCOR2] = 0;
2024 base_addr[CyCOR3] = Cy_1_STOP 2147 base_addr[CyCOR3] = Cy_1_STOP;
2025 base_addr[CyCOR4] = baud_cor4 2148 base_addr[CyCOR4] = baud_cor4[spd];
2026 base_addr[CyCOR5] = 0; 2149 base_addr[CyCOR5] = 0;
2027 base_addr[CyCOR6] = 0; 2150 base_addr[CyCOR6] = 0;
2028 base_addr[CyCOR7] = 0; 2151 base_addr[CyCOR7] = 0;
2029 base_addr[CyRTPRL] = 2; 2152 base_addr[CyRTPRL] = 2;
2030 base_addr[CyRTPRH] = 0; 2153 base_addr[CyRTPRH] = 0;
2031 base_addr[CyMSVR1] = 0; !! 2154 base_addr[CyMSVR1] = 0;
2032 base_addr[CyMSVR2] = 0; !! 2155 base_addr[CyMSVR2] = 0;
2033 write_cy_cmd(base_addr, CyINI !! 2156 write_cy_cmd(base_addr,CyINIT_CHAN|CyDIS_RCVR|CyDIS_XMTR);
2034 } 2157 }
2035 2158
2036 /* 2159 /*
2037 * Now do specials for channel zero.. 2160 * Now do specials for channel zero....
2038 */ 2161 */
2039 2162
2040 base_addr[CyMSVR1] = CyRTS; !! 2163 base_addr[CyMSVR1] = CyRTS;
2041 base_addr[CyMSVR2] = CyDTR; !! 2164 base_addr[CyMSVR2] = CyDTR;
2042 base_addr[CyIER] = CyRxData; 2165 base_addr[CyIER] = CyRxData;
2043 write_cy_cmd(base_addr, CyENB_RCVR | !! 2166 write_cy_cmd(base_addr,CyENB_RCVR|CyENB_XMTR);
2044 2167
2045 local_irq_restore(flags); 2168 local_irq_restore(flags);
2046 2169
2047 my_udelay(20000L); /* Let it all 2170 my_udelay(20000L); /* Let it all settle down */
2048 2171
2049 printk("CD2401 initialised, chip is !! 2172 printk("CD2401 initialised, chip is rev 0x%02x\n", base_addr[CyGFRCR]);
2050 if (badspeed) 2173 if (badspeed)
2051 printk !! 2174 printk(" WARNING: Failed to identify line speed, rcor=%02x,rbpr=%02x\n",
2052 (" WARNING: Failed to i !! 2175 rcor >> 5, rbpr);
2053 rcor >> 5, rbpr); !! 2176 } /* serial_console_init */
2054 } /* serial_con <<
2055 2177
2056 static const struct tty_operations cy_ops = { !! 2178 static struct tty_operations cy_ops = {
2057 .open = cy_open, 2179 .open = cy_open,
2058 .close = cy_close, 2180 .close = cy_close,
2059 .write = cy_write, 2181 .write = cy_write,
2060 .put_char = cy_put_char, 2182 .put_char = cy_put_char,
2061 .flush_chars = cy_flush_chars, 2183 .flush_chars = cy_flush_chars,
2062 .write_room = cy_write_room, 2184 .write_room = cy_write_room,
2063 .chars_in_buffer = cy_chars_in_buffer 2185 .chars_in_buffer = cy_chars_in_buffer,
2064 .flush_buffer = cy_flush_buffer, 2186 .flush_buffer = cy_flush_buffer,
2065 .ioctl = cy_ioctl, 2187 .ioctl = cy_ioctl,
2066 .throttle = cy_throttle, 2188 .throttle = cy_throttle,
2067 .unthrottle = cy_unthrottle, 2189 .unthrottle = cy_unthrottle,
2068 .set_termios = cy_set_termios, 2190 .set_termios = cy_set_termios,
2069 .stop = cy_stop, 2191 .stop = cy_stop,
2070 .start = cy_start, 2192 .start = cy_start,
2071 .hangup = cy_hangup, 2193 .hangup = cy_hangup,
2072 .tiocmget = cy_tiocmget, 2194 .tiocmget = cy_tiocmget,
2073 .tiocmset = cy_tiocmset, 2195 .tiocmset = cy_tiocmset,
2074 }; 2196 };
2075 <<
2076 /* The serial driver boot-time initialization 2197 /* The serial driver boot-time initialization code!
2077 Hardware I/O ports are mapped to characte 2198 Hardware I/O ports are mapped to character special devices on a
2078 first found, first allocated manner. Tha 2199 first found, first allocated manner. That is, this code searches
2079 for Cyclom cards in the system. As each 2200 for Cyclom cards in the system. As each is found, it is probed
2080 to discover how many chips (and thus how 2201 to discover how many chips (and thus how many ports) are present.
2081 These ports are mapped to the tty ports 6 2202 These ports are mapped to the tty ports 64 and upward in monotonic
2082 fashion. If an 8-port card is replaced w 2203 fashion. If an 8-port card is replaced with a 16-port card, the
2083 port mapping on a following card will shi 2204 port mapping on a following card will shift.
2084 2205
2085 This approach is different from what is u 2206 This approach is different from what is used in the other serial
2086 device driver because the Cyclom is more 2207 device driver because the Cyclom is more properly a multiplexer,
2087 not just an aggregation of serial ports o 2208 not just an aggregation of serial ports on one card.
2088 2209
2089 If there are more cards with more ports t 2210 If there are more cards with more ports than have been statically
2090 allocated above, a warning is printed and 2211 allocated above, a warning is printed and the extra ports are ignored.
2091 */ 2212 */
2092 static int __init serial167_init(void) !! 2213 static int __init
>> 2214 serial167_init(void)
2093 { 2215 {
2094 struct cyclades_port *info; !! 2216 struct cyclades_port *info;
2095 int ret = 0; !! 2217 int ret = 0;
2096 int good_ports = 0; !! 2218 int good_ports = 0;
2097 int port_num = 0; !! 2219 int port_num = 0;
2098 int index; !! 2220 int index;
2099 int DefSpeed; !! 2221 int DefSpeed;
2100 #ifdef notyet 2222 #ifdef notyet
2101 struct sigaction sa; !! 2223 struct sigaction sa;
2102 #endif 2224 #endif
2103 2225
2104 if (!(mvme16x_config & MVME16x_CONFIG !! 2226 if (!(mvme16x_config &MVME16x_CONFIG_GOT_CD2401))
2105 return 0; !! 2227 return 0;
2106 2228
2107 cy_serial_driver = alloc_tty_driver(N !! 2229 cy_serial_driver = alloc_tty_driver(NR_PORTS);
2108 if (!cy_serial_driver) !! 2230 if (!cy_serial_driver)
2109 return -ENOMEM; !! 2231 return -ENOMEM;
2110 2232
2111 #if 0 2233 #if 0
2112 scrn[1] = '\0'; !! 2234 scrn[1] = '\0';
2113 #endif 2235 #endif
2114 2236
2115 show_version(); !! 2237 show_version();
2116 2238
2117 /* Has "console=0,9600n8" been used i !! 2239 /* Has "console=0,9600n8" been used in bootinfo to change speed? */
2118 if (serial_console_cflag) !! 2240 if (serial_console_cflag)
2119 DefSpeed = serial_console_cfl !! 2241 DefSpeed = serial_console_cflag & 0017;
2120 else { !! 2242 else {
2121 DefSpeed = initial_console_sp !! 2243 DefSpeed = initial_console_speed;
2122 serial_console_info = &cy_por !! 2244 serial_console_info = &cy_port[0];
2123 serial_console_cflag = DefSpe !! 2245 serial_console_cflag = DefSpeed | CS8;
2124 #if 0 2246 #if 0
2125 serial_console = 64; /*cal !! 2247 serial_console = 64; /*callout_driver.minor_start*/
2126 #endif 2248 #endif
2127 } !! 2249 }
2128 <<
2129 /* Initialize the tty_driver structur <<
2130 2250
2131 cy_serial_driver->owner = THIS_MODULE !! 2251 /* Initialize the tty_driver structure */
2132 cy_serial_driver->name = "ttyS"; !! 2252
2133 cy_serial_driver->major = TTY_MAJOR; !! 2253 cy_serial_driver->owner = THIS_MODULE;
2134 cy_serial_driver->minor_start = 64; !! 2254 cy_serial_driver->devfs_name = "tts/";
2135 cy_serial_driver->type = TTY_DRIVER_T !! 2255 cy_serial_driver->name = "ttyS";
2136 cy_serial_driver->subtype = SERIAL_TY !! 2256 cy_serial_driver->major = TTY_MAJOR;
2137 cy_serial_driver->init_termios = tty_ !! 2257 cy_serial_driver->minor_start = 64;
2138 cy_serial_driver->init_termios.c_cfla !! 2258 cy_serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
>> 2259 cy_serial_driver->subtype = SERIAL_TYPE_NORMAL;
>> 2260 cy_serial_driver->init_termios = tty_std_termios;
>> 2261 cy_serial_driver->init_termios.c_cflag =
2139 B9600 | CS8 | CREAD | HUPCL | CLO 2262 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
2140 cy_serial_driver->flags = TTY_DRIVER_ !! 2263 cy_serial_driver->flags = TTY_DRIVER_REAL_RAW;
2141 tty_set_operations(cy_serial_driver, !! 2264 tty_set_operations(cy_serial_driver, &cy_ops);
2142 2265
2143 ret = tty_register_driver(cy_serial_d !! 2266 ret = tty_register_driver(cy_serial_driver);
2144 if (ret) { !! 2267 if (ret) {
2145 printk(KERN_ERR "Couldn't reg !! 2268 printk(KERN_ERR "Couldn't register MVME166/7 serial driver\n");
2146 put_tty_driver(cy_serial_driv !! 2269 put_tty_driver(cy_serial_driver);
2147 return ret; !! 2270 return ret;
2148 } !! 2271 }
2149 !! 2272
2150 port_num = 0; !! 2273 port_num = 0;
2151 info = cy_port; !! 2274 info = cy_port;
2152 for (index = 0; index < 1; index++) { !! 2275 for (index = 0; index < 1; index++) {
2153 2276
2154 good_ports = 4; !! 2277 good_ports = 4;
2155 2278
2156 if (port_num < NR_PORTS) { !! 2279 if(port_num < NR_PORTS){
2157 while (good_ports-- & !! 2280 while( good_ports-- && port_num < NR_PORTS){
2158 /*** initialize port ***/ 2281 /*** initialize port ***/
2159 info->magic = !! 2282 info->magic = CYCLADES_MAGIC;
2160 info->type = !! 2283 info->type = PORT_CIRRUS;
2161 info->card = !! 2284 info->card = index;
2162 info->line = !! 2285 info->line = port_num;
2163 info->flags = !! 2286 info->flags = STD_COM_FLAGS;
2164 info->tty = N !! 2287 info->tty = 0;
2165 info->xmit_fi !! 2288 info->xmit_fifo_size = 12;
2166 info->cor1 = !! 2289 info->cor1 = CyPARITY_NONE|Cy_8_BITS;
2167 info->cor2 = !! 2290 info->cor2 = CyETC;
2168 info->cor3 = !! 2291 info->cor3 = Cy_1_STOP;
2169 info->cor4 = !! 2292 info->cor4 = 0x08; /* _very_ small receive threshold */
2170 info->cor5 = !! 2293 info->cor5 = 0;
2171 info->cor6 = !! 2294 info->cor6 = 0;
2172 info->cor7 = !! 2295 info->cor7 = 0;
2173 info->tbpr = !! 2296 info->tbpr = baud_bpr[DefSpeed]; /* Tx BPR */
2174 info->tco = b !! 2297 info->tco = baud_co[DefSpeed]; /* Tx CO */
2175 info->rbpr = !! 2298 info->rbpr = baud_bpr[DefSpeed]; /* Rx BPR */
2176 info->rco = b !! 2299 info->rco = baud_co[DefSpeed] >> 5; /* Rx CO */
2177 info->close_d !! 2300 info->close_delay = 0;
2178 info->x_char !! 2301 info->x_char = 0;
2179 info->count = !! 2302 info->event = 0;
>> 2303 info->count = 0;
2180 #ifdef SERIAL_DEBUG_COUNT 2304 #ifdef SERIAL_DEBUG_COUNT
2181 printk("cyc: !! 2305 printk("cyc: %d: setting count to 0\n", __LINE__);
2182 __LINE <<
2183 #endif 2306 #endif
2184 info->blocked !! 2307 info->blocked_open = 0;
2185 info->default !! 2308 info->default_threshold = 0;
2186 info->default !! 2309 info->default_timeout = 0;
2187 init_waitqueu !! 2310 INIT_WORK(&info->tqueue, do_softint, info);
2188 init_waitqueu !! 2311 init_waitqueue_head(&info->open_wait);
2189 /* info->sess !! 2312 init_waitqueue_head(&info->close_wait);
2190 /* info->pgrp !! 2313 /* info->session */
>> 2314 /* info->pgrp */
2191 /*** !!!!!!!! this may expose new bugs !!!!!! 2315 /*** !!!!!!!! this may expose new bugs !!!!!!!!! *********/
2192 info->read_st !! 2316 info->read_status_mask = CyTIMEOUT| CySPECHAR| CyBREAK
2193 CyTIMEOUT !! 2317 | CyPARITY| CyFRAME| CyOVERRUN;
2194 CyFRAME | !! 2318 /* info->timeout */
2195 /* info->time !! 2319
2196 !! 2320 printk("ttyS%d ", info->line);
2197 printk("ttyS% !! 2321 port_num++;info++;
2198 port_num++; !! 2322 if(!(port_num & 7)){
2199 info++; !! 2323 printk("\n ");
2200 if (!(port_nu !! 2324 }
2201 print !! 2325 }
2202 } !! 2326 }
2203 } !! 2327 printk("\n");
2204 } !! 2328 }
2205 printk("\n"); !! 2329 while( port_num < NR_PORTS){
2206 } !! 2330 info->line = -1;
2207 while (port_num < NR_PORTS) { !! 2331 port_num++;info++;
2208 info->line = -1; !! 2332 }
2209 port_num++; <<
2210 info++; <<
2211 } <<
2212 #ifdef CONFIG_REMOTE_DEBUG 2333 #ifdef CONFIG_REMOTE_DEBUG
2213 debug_setup(); !! 2334 debug_setup();
2214 #endif 2335 #endif
2215 ret = request_irq(MVME167_IRQ_SER_ERR !! 2336 ret = request_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt, 0,
2216 "cd2401_errors", cd !! 2337 "cd2401_errors", cd2401_rxerr_interrupt);
2217 if (ret) { !! 2338 if (ret) {
2218 printk(KERN_ERR "Could't get !! 2339 printk(KERN_ERR "Could't get cd2401_errors IRQ");
2219 goto cleanup_serial_driver; !! 2340 goto cleanup_serial_driver;
2220 } !! 2341 }
2221 !! 2342
2222 ret = request_irq(MVME167_IRQ_SER_MOD !! 2343 ret = request_irq(MVME167_IRQ_SER_MODEM, cd2401_modem_interrupt, 0,
2223 "cd2401_modem", cd2 !! 2344 "cd2401_modem", cd2401_modem_interrupt);
2224 if (ret) { !! 2345 if (ret) {
2225 printk(KERN_ERR "Could't get !! 2346 printk(KERN_ERR "Could't get cd2401_modem IRQ");
2226 goto cleanup_irq_cd2401_error !! 2347 goto cleanup_irq_cd2401_errors;
2227 } !! 2348 }
>> 2349
>> 2350 ret = request_irq(MVME167_IRQ_SER_TX, cd2401_tx_interrupt, 0,
>> 2351 "cd2401_txints", cd2401_tx_interrupt);
>> 2352 if (ret) {
>> 2353 printk(KERN_ERR "Could't get cd2401_txints IRQ");
>> 2354 goto cleanup_irq_cd2401_modem;
>> 2355 }
>> 2356
>> 2357 ret = request_irq(MVME167_IRQ_SER_RX, cd2401_rx_interrupt, 0,
>> 2358 "cd2401_rxints", cd2401_rx_interrupt);
>> 2359 if (ret) {
>> 2360 printk(KERN_ERR "Could't get cd2401_rxints IRQ");
>> 2361 goto cleanup_irq_cd2401_txints;
>> 2362 }
>> 2363
>> 2364 /* Now we have registered the interrupt handlers, allow the interrupts */
>> 2365
>> 2366 pcc2chip[PccSCCMICR] = 0x15; /* Serial ints are level 5 */
>> 2367 pcc2chip[PccSCCTICR] = 0x15;
>> 2368 pcc2chip[PccSCCRICR] = 0x15;
2228 2369
2229 ret = request_irq(MVME167_IRQ_SER_TX, !! 2370 pcc2chip[PccIMLR] = 3; /* Allow PCC2 ints above 3!? */
2230 "cd2401_txints", cd <<
2231 if (ret) { <<
2232 printk(KERN_ERR "Could't get <<
2233 goto cleanup_irq_cd2401_modem <<
2234 } <<
2235 <<
2236 ret = request_irq(MVME167_IRQ_SER_RX, <<
2237 "cd2401_rxints", cd <<
2238 if (ret) { <<
2239 printk(KERN_ERR "Could't get <<
2240 goto cleanup_irq_cd2401_txint <<
2241 } <<
2242 <<
2243 /* Now we have registered the interru <<
2244 2371
2245 pcc2chip[PccSCCMICR] = 0x15; /* Se !! 2372 return 0;
2246 pcc2chip[PccSCCTICR] = 0x15; <<
2247 pcc2chip[PccSCCRICR] = 0x15; <<
2248 <<
2249 pcc2chip[PccIMLR] = 3; /* Allow PCC2 <<
2250 <<
2251 return 0; <<
2252 cleanup_irq_cd2401_txints: 2373 cleanup_irq_cd2401_txints:
2253 free_irq(MVME167_IRQ_SER_TX, cd2401_t !! 2374 free_irq(MVME167_IRQ_SER_TX, cd2401_tx_interrupt);
2254 cleanup_irq_cd2401_modem: 2375 cleanup_irq_cd2401_modem:
2255 free_irq(MVME167_IRQ_SER_MODEM, cd240 !! 2376 free_irq(MVME167_IRQ_SER_MODEM, cd2401_modem_interrupt);
2256 cleanup_irq_cd2401_errors: 2377 cleanup_irq_cd2401_errors:
2257 free_irq(MVME167_IRQ_SER_ERR, cd2401_ !! 2378 free_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt);
2258 cleanup_serial_driver: 2379 cleanup_serial_driver:
2259 if (tty_unregister_driver(cy_serial_d !! 2380 if (tty_unregister_driver(cy_serial_driver))
2260 printk(KERN_ERR !! 2381 printk(KERN_ERR "Couldn't unregister MVME166/7 serial driver\n");
2261 "Couldn't unregister M !! 2382 put_tty_driver(cy_serial_driver);
2262 put_tty_driver(cy_serial_driver); !! 2383 return ret;
2263 return ret; !! 2384 } /* serial167_init */
2264 } /* serial167_ <<
2265 2385
2266 module_init(serial167_init); 2386 module_init(serial167_init);
2267 2387
>> 2388
2268 #ifdef CYCLOM_SHOW_STATUS 2389 #ifdef CYCLOM_SHOW_STATUS
2269 static void show_status(int line_num) !! 2390 static void
>> 2391 show_status(int line_num)
2270 { 2392 {
2271 volatile unsigned char *base_addr = ( !! 2393 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
2272 int channel; !! 2394 int channel;
2273 struct cyclades_port *info; !! 2395 struct cyclades_port * info;
2274 unsigned long flags; !! 2396 unsigned long flags;
>> 2397
>> 2398 info = &cy_port[line_num];
>> 2399 channel = info->line;
>> 2400 printk(" channel %d\n", channel);/**/
>> 2401
>> 2402 printk(" cy_port\n");
>> 2403 printk(" card line flags = %d %d %x\n",
>> 2404 info->card, info->line, info->flags);
>> 2405 printk(" *tty read_status_mask timeout xmit_fifo_size = %lx %x %x %x\n",
>> 2406 (long)info->tty, info->read_status_mask,
>> 2407 info->timeout, info->xmit_fifo_size);
>> 2408 printk(" cor1,cor2,cor3,cor4,cor5,cor6,cor7 = %x %x %x %x %x %x %x\n",
>> 2409 info->cor1, info->cor2, info->cor3, info->cor4, info->cor5,
>> 2410 info->cor6, info->cor7);
>> 2411 printk(" tbpr,tco,rbpr,rco = %d %d %d %d\n",
>> 2412 info->tbpr, info->tco, info->rbpr, info->rco);
>> 2413 printk(" close_delay event count = %d %d %d\n",
>> 2414 info->close_delay, info->event, info->count);
>> 2415 printk(" x_char blocked_open = %x %x\n",
>> 2416 info->x_char, info->blocked_open);
>> 2417 printk(" open_wait = %lx %lx %lx\n",
>> 2418 (long)info->open_wait);
2275 2419
2276 info = &cy_port[line_num]; <<
2277 channel = info->line; <<
2278 printk(" channel %d\n", channel); <<
2279 /**/ printk(" cy_port\n"); <<
2280 printk(" card line flags = %d %d %x\ <<
2281 info->card, info->line, info-> <<
2282 printk <<
2283 (" *tty read_status_mask timeout <<
2284 (long)info->tty, info->read_stat <<
2285 info->xmit_fifo_size); <<
2286 printk(" cor1,cor2,cor3,cor4,cor5,co <<
2287 info->cor1, info->cor2, info-> <<
2288 info->cor6, info->cor7); <<
2289 printk(" tbpr,tco,rbpr,rco = %d %d % <<
2290 info->rbpr, info->rco); <<
2291 printk(" close_delay event count = % <<
2292 info->event, info->count); <<
2293 printk(" x_char blocked_open = %x %x <<
2294 info->blocked_open); <<
2295 printk(" open_wait = %lx %lx %lx\n", <<
2296 2420
2297 local_irq_save(flags); !! 2421 local_irq_save(flags);
2298 2422
2299 /* Global Registers */ 2423 /* Global Registers */
2300 2424
2301 printk(" CyGFRCR %x\n", base_addr[CyG 2425 printk(" CyGFRCR %x\n", base_addr[CyGFRCR]);
2302 printk(" CyCAR %x\n", base_addr[CyCAR 2426 printk(" CyCAR %x\n", base_addr[CyCAR]);
2303 printk(" CyRISR %x\n", base_addr[CyRI 2427 printk(" CyRISR %x\n", base_addr[CyRISR]);
2304 printk(" CyTISR %x\n", base_addr[CyTI 2428 printk(" CyTISR %x\n", base_addr[CyTISR]);
2305 printk(" CyMISR %x\n", base_addr[CyMI 2429 printk(" CyMISR %x\n", base_addr[CyMISR]);
2306 printk(" CyRIR %x\n", base_addr[CyRIR 2430 printk(" CyRIR %x\n", base_addr[CyRIR]);
2307 printk(" CyTIR %x\n", base_addr[CyTIR 2431 printk(" CyTIR %x\n", base_addr[CyTIR]);
2308 printk(" CyMIR %x\n", base_addr[CyMIR 2432 printk(" CyMIR %x\n", base_addr[CyMIR]);
2309 printk(" CyTPR %x\n", base_addr[CyTPR 2433 printk(" CyTPR %x\n", base_addr[CyTPR]);
2310 2434
2311 base_addr[CyCAR] = (u_char) channel; !! 2435 base_addr[CyCAR] = (u_char)channel;
2312 2436
2313 /* Virtual Registers */ 2437 /* Virtual Registers */
2314 2438
2315 #if 0 2439 #if 0
2316 printk(" CyRIVR %x\n", base_addr[CyRI 2440 printk(" CyRIVR %x\n", base_addr[CyRIVR]);
2317 printk(" CyTIVR %x\n", base_addr[CyTI 2441 printk(" CyTIVR %x\n", base_addr[CyTIVR]);
2318 printk(" CyMIVR %x\n", base_addr[CyMI 2442 printk(" CyMIVR %x\n", base_addr[CyMIVR]);
2319 printk(" CyMISR %x\n", base_addr[CyMI 2443 printk(" CyMISR %x\n", base_addr[CyMISR]);
2320 #endif 2444 #endif
2321 2445
2322 /* Channel Registers */ 2446 /* Channel Registers */
2323 2447
2324 printk(" CyCCR %x\n", base_addr[CyCCR 2448 printk(" CyCCR %x\n", base_addr[CyCCR]);
2325 printk(" CyIER %x\n", base_addr[CyIER 2449 printk(" CyIER %x\n", base_addr[CyIER]);
2326 printk(" CyCOR1 %x\n", base_addr[CyCO 2450 printk(" CyCOR1 %x\n", base_addr[CyCOR1]);
2327 printk(" CyCOR2 %x\n", base_addr[CyCO 2451 printk(" CyCOR2 %x\n", base_addr[CyCOR2]);
2328 printk(" CyCOR3 %x\n", base_addr[CyCO 2452 printk(" CyCOR3 %x\n", base_addr[CyCOR3]);
2329 printk(" CyCOR4 %x\n", base_addr[CyCO 2453 printk(" CyCOR4 %x\n", base_addr[CyCOR4]);
2330 printk(" CyCOR5 %x\n", base_addr[CyCO 2454 printk(" CyCOR5 %x\n", base_addr[CyCOR5]);
2331 #if 0 2455 #if 0
2332 printk(" CyCCSR %x\n", base_addr[CyCC 2456 printk(" CyCCSR %x\n", base_addr[CyCCSR]);
2333 printk(" CyRDCR %x\n", base_addr[CyRD 2457 printk(" CyRDCR %x\n", base_addr[CyRDCR]);
2334 #endif 2458 #endif
2335 printk(" CySCHR1 %x\n", base_addr[CyS 2459 printk(" CySCHR1 %x\n", base_addr[CySCHR1]);
2336 printk(" CySCHR2 %x\n", base_addr[CyS 2460 printk(" CySCHR2 %x\n", base_addr[CySCHR2]);
2337 #if 0 2461 #if 0
2338 printk(" CySCHR3 %x\n", base_addr[CyS 2462 printk(" CySCHR3 %x\n", base_addr[CySCHR3]);
2339 printk(" CySCHR4 %x\n", base_addr[CyS 2463 printk(" CySCHR4 %x\n", base_addr[CySCHR4]);
2340 printk(" CySCRL %x\n", base_addr[CySC 2464 printk(" CySCRL %x\n", base_addr[CySCRL]);
2341 printk(" CySCRH %x\n", base_addr[CySC 2465 printk(" CySCRH %x\n", base_addr[CySCRH]);
2342 printk(" CyLNC %x\n", base_addr[CyLNC 2466 printk(" CyLNC %x\n", base_addr[CyLNC]);
2343 printk(" CyMCOR1 %x\n", base_addr[CyM 2467 printk(" CyMCOR1 %x\n", base_addr[CyMCOR1]);
2344 printk(" CyMCOR2 %x\n", base_addr[CyM 2468 printk(" CyMCOR2 %x\n", base_addr[CyMCOR2]);
2345 #endif 2469 #endif
2346 printk(" CyRTPRL %x\n", base_addr[CyR 2470 printk(" CyRTPRL %x\n", base_addr[CyRTPRL]);
2347 printk(" CyRTPRH %x\n", base_addr[CyR 2471 printk(" CyRTPRH %x\n", base_addr[CyRTPRH]);
2348 printk(" CyMSVR1 %x\n", base_addr[CyM 2472 printk(" CyMSVR1 %x\n", base_addr[CyMSVR1]);
2349 printk(" CyMSVR2 %x\n", base_addr[CyM 2473 printk(" CyMSVR2 %x\n", base_addr[CyMSVR2]);
2350 printk(" CyRBPR %x\n", base_addr[CyRB 2474 printk(" CyRBPR %x\n", base_addr[CyRBPR]);
2351 printk(" CyRCOR %x\n", base_addr[CyRC 2475 printk(" CyRCOR %x\n", base_addr[CyRCOR]);
2352 printk(" CyTBPR %x\n", base_addr[CyTB 2476 printk(" CyTBPR %x\n", base_addr[CyTBPR]);
2353 printk(" CyTCOR %x\n", base_addr[CyTC 2477 printk(" CyTCOR %x\n", base_addr[CyTCOR]);
2354 2478
2355 local_irq_restore(flags); !! 2479 local_irq_restore(flags);
2356 } /* show_statu !! 2480 } /* show_status */
2357 #endif 2481 #endif
2358 2482
>> 2483
2359 #if 0 2484 #if 0
2360 /* Dummy routine in mvme16x/config.c for now 2485 /* Dummy routine in mvme16x/config.c for now */
2361 2486
2362 /* Serial console setup. Called from linux/in 2487 /* Serial console setup. Called from linux/init/main.c */
2363 2488
2364 void console_setup(char *str, int *ints) 2489 void console_setup(char *str, int *ints)
2365 { 2490 {
2366 char *s; 2491 char *s;
2367 int baud, bits, parity; 2492 int baud, bits, parity;
2368 int cflag = 0; 2493 int cflag = 0;
2369 2494
2370 /* Sanity check. */ 2495 /* Sanity check. */
2371 if (ints[0] > 3 || ints[1] > 3) !! 2496 if (ints[0] > 3 || ints[1] > 3) return;
2372 return; <<
2373 2497
2374 /* Get baud, bits and parity */ 2498 /* Get baud, bits and parity */
2375 baud = 2400; 2499 baud = 2400;
2376 bits = 8; 2500 bits = 8;
2377 parity = 'n'; 2501 parity = 'n';
2378 if (ints[2]) !! 2502 if (ints[2]) baud = ints[2];
2379 baud = ints[2]; <<
2380 if ((s = strchr(str, ','))) { 2503 if ((s = strchr(str, ','))) {
2381 do { 2504 do {
2382 s++; 2505 s++;
2383 } while (*s >= '' && *s <= '9 !! 2506 } while(*s >= '' && *s <= '9');
2384 if (*s) !! 2507 if (*s) parity = *s++;
2385 parity = *s++; !! 2508 if (*s) bits = *s - '';
2386 if (*s) <<
2387 bits = *s - ''; <<
2388 } 2509 }
2389 2510
2390 /* Now construct a cflag setting. */ 2511 /* Now construct a cflag setting. */
2391 switch (baud) { !! 2512 switch(baud) {
2392 case 1200: !! 2513 case 1200:
2393 cflag |= B1200; !! 2514 cflag |= B1200;
2394 break; !! 2515 break;
2395 case 9600: !! 2516 case 9600:
2396 cflag |= B9600; !! 2517 cflag |= B9600;
2397 break; !! 2518 break;
2398 case 19200: !! 2519 case 19200:
2399 cflag |= B19200; !! 2520 cflag |= B19200;
2400 break; !! 2521 break;
2401 case 38400: !! 2522 case 38400:
2402 cflag |= B38400; !! 2523 cflag |= B38400;
2403 break; !! 2524 break;
2404 case 2400: !! 2525 case 2400:
2405 default: !! 2526 default:
2406 cflag |= B2400; !! 2527 cflag |= B2400;
2407 break; !! 2528 break;
2408 } 2529 }
2409 switch (bits) { !! 2530 switch(bits) {
2410 case 7: !! 2531 case 7:
2411 cflag |= CS7; !! 2532 cflag |= CS7;
2412 break; !! 2533 break;
2413 default: !! 2534 default:
2414 case 8: !! 2535 case 8:
2415 cflag |= CS8; !! 2536 cflag |= CS8;
2416 break; !! 2537 break;
2417 } 2538 }
2418 switch (parity) { !! 2539 switch(parity) {
2419 case 'o': !! 2540 case 'o': case 'O':
2420 case 'O': !! 2541 cflag |= PARODD;
2421 cflag |= PARODD; !! 2542 break;
2422 break; !! 2543 case 'e': case 'E':
2423 case 'e': !! 2544 cflag |= PARENB;
2424 case 'E': !! 2545 break;
2425 cflag |= PARENB; <<
2426 break; <<
2427 } 2546 }
2428 2547
2429 serial_console_info = &cy_port[ints[1 2548 serial_console_info = &cy_port[ints[1]];
2430 serial_console_cflag = cflag; 2549 serial_console_cflag = cflag;
2431 serial_console = ints[1] + 64; /*cal !! 2550 serial_console = ints[1] + 64; /*callout_driver.minor_start*/
2432 } 2551 }
2433 #endif 2552 #endif
2434 2553
2435 /* 2554 /*
2436 * The following is probably out of date for 2555 * The following is probably out of date for 2.1.x serial console stuff.
2437 * 2556 *
2438 * The console is registered early on from ar 2557 * The console is registered early on from arch/m68k/kernel/setup.c, and
2439 * it therefore relies on the chip being setu 2558 * it therefore relies on the chip being setup correctly by 166-Bug. This
2440 * seems reasonable, as the serial port has b 2559 * seems reasonable, as the serial port has been used to invoke the system
2441 * boot. It also means that this function mu 2560 * boot. It also means that this function must not rely on any data
2442 * initialisation performed by serial167_init 2561 * initialisation performed by serial167_init() etc.
2443 * 2562 *
2444 * Of course, once the console has been regis 2563 * Of course, once the console has been registered, we had better ensure
2445 * that serial167_init() doesn't leave the ch 2564 * that serial167_init() doesn't leave the chip non-functional.
2446 * 2565 *
2447 * The console must be locked when we get her 2566 * The console must be locked when we get here.
2448 */ 2567 */
2449 2568
2450 void serial167_console_write(struct console * !! 2569 void serial167_console_write(struct console *co, const char *str, unsigned count)
2451 unsigned count) <<
2452 { 2570 {
2453 volatile unsigned char *base_addr = ( !! 2571 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
2454 unsigned long flags; 2572 unsigned long flags;
2455 volatile u_char sink; 2573 volatile u_char sink;
2456 u_char ier; 2574 u_char ier;
2457 int port; 2575 int port;
2458 u_char do_lf = 0; 2576 u_char do_lf = 0;
2459 int i = 0; 2577 int i = 0;
2460 2578
2461 local_irq_save(flags); 2579 local_irq_save(flags);
2462 2580
2463 /* Ensure transmitter is enabled! */ 2581 /* Ensure transmitter is enabled! */
2464 2582
2465 port = 0; 2583 port = 0;
2466 base_addr[CyCAR] = (u_char) port; !! 2584 base_addr[CyCAR] = (u_char)port;
2467 while (base_addr[CyCCR]) 2585 while (base_addr[CyCCR])
2468 ; 2586 ;
2469 base_addr[CyCCR] = CyENB_XMTR; 2587 base_addr[CyCCR] = CyENB_XMTR;
2470 2588
2471 ier = base_addr[CyIER]; 2589 ier = base_addr[CyIER];
2472 base_addr[CyIER] = CyTxMpty; 2590 base_addr[CyIER] = CyTxMpty;
2473 2591
2474 while (1) { 2592 while (1) {
2475 if (pcc2chip[PccSCCTICR] & 0x !! 2593 if (pcc2chip[PccSCCTICR] & 0x20)
>> 2594 {
2476 /* We have a Tx int. 2595 /* We have a Tx int. Acknowledge it */
2477 sink = pcc2chip[PccTP 2596 sink = pcc2chip[PccTPIACKR];
2478 if ((base_addr[CyLICR 2597 if ((base_addr[CyLICR] >> 2) == port) {
2479 if (i == coun 2598 if (i == count) {
2480 /* La 2599 /* Last char of string is now output */
2481 base_ 2600 base_addr[CyTEOIR] = CyNOTRANS;
2482 break 2601 break;
2483 } 2602 }
2484 if (do_lf) { 2603 if (do_lf) {
2485 base_ 2604 base_addr[CyTDR] = '\n';
2486 str++ 2605 str++;
2487 i++; 2606 i++;
2488 do_lf 2607 do_lf = 0;
2489 } else if (*s !! 2608 }
>> 2609 else if (*str == '\n') {
2490 base_ 2610 base_addr[CyTDR] = '\r';
2491 do_lf 2611 do_lf = 1;
2492 } else { !! 2612 }
>> 2613 else {
2493 base_ 2614 base_addr[CyTDR] = *str++;
2494 i++; 2615 i++;
2495 } 2616 }
2496 base_addr[CyT 2617 base_addr[CyTEOIR] = 0;
2497 } else !! 2618 }
>> 2619 else
2498 base_addr[CyT 2620 base_addr[CyTEOIR] = CyNOTRANS;
2499 } 2621 }
2500 } 2622 }
2501 2623
2502 base_addr[CyIER] = ier; 2624 base_addr[CyIER] = ier;
2503 2625
2504 local_irq_restore(flags); 2626 local_irq_restore(flags);
2505 } 2627 }
2506 2628
2507 static struct tty_driver *serial167_console_d !! 2629 static struct tty_driver *serial167_console_device(struct console *c, int *index)
2508 <<
2509 { 2630 {
2510 *index = c->index; 2631 *index = c->index;
2511 return cy_serial_driver; 2632 return cy_serial_driver;
2512 } 2633 }
2513 2634
>> 2635
>> 2636 static int __init serial167_console_setup(struct console *co, char *options)
>> 2637 {
>> 2638 return 0;
>> 2639 }
>> 2640
>> 2641
2514 static struct console sercons = { 2642 static struct console sercons = {
2515 .name = "ttyS", !! 2643 .name = "ttyS",
2516 .write = serial167_console_write, !! 2644 .write = serial167_console_write,
2517 .device = serial167_console_device, !! 2645 .device = serial167_console_device,
2518 .flags = CON_PRINTBUFFER, !! 2646 .setup = serial167_console_setup,
2519 .index = -1, !! 2647 .flags = CON_PRINTBUFFER,
>> 2648 .index = -1,
2520 }; 2649 };
2521 2650
>> 2651
2522 static int __init serial167_console_init(void 2652 static int __init serial167_console_init(void)
2523 { 2653 {
2524 if (vme_brdtype == VME_TYPE_MVME166 | 2654 if (vme_brdtype == VME_TYPE_MVME166 ||
2525 vme_brdtype == VME_TYPE_MVME167 | !! 2655 vme_brdtype == VME_TYPE_MVME167 ||
2526 vme_brdtype == VME_TYPE_MVME177) !! 2656 vme_brdtype == VME_TYPE_MVME177) {
2527 mvme167_serial_console_setup( 2657 mvme167_serial_console_setup(0);
2528 register_console(&sercons); 2658 register_console(&sercons);
2529 } 2659 }
2530 return 0; 2660 return 0;
2531 } 2661 }
2532 <<
2533 console_initcall(serial167_console_init); 2662 console_initcall(serial167_console_init);
2534 2663
2535 #ifdef CONFIG_REMOTE_DEBUG 2664 #ifdef CONFIG_REMOTE_DEBUG
2536 void putDebugChar(int c) !! 2665 void putDebugChar (int c)
2537 { 2666 {
2538 volatile unsigned char *base_addr = ( !! 2667 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
2539 unsigned long flags; 2668 unsigned long flags;
2540 volatile u_char sink; 2669 volatile u_char sink;
2541 u_char ier; 2670 u_char ier;
2542 int port; 2671 int port;
2543 2672
2544 local_irq_save(flags); 2673 local_irq_save(flags);
2545 2674
2546 /* Ensure transmitter is enabled! */ 2675 /* Ensure transmitter is enabled! */
2547 2676
2548 port = DEBUG_PORT; 2677 port = DEBUG_PORT;
2549 base_addr[CyCAR] = (u_char) port; !! 2678 base_addr[CyCAR] = (u_char)port;
2550 while (base_addr[CyCCR]) 2679 while (base_addr[CyCCR])
2551 ; 2680 ;
2552 base_addr[CyCCR] = CyENB_XMTR; 2681 base_addr[CyCCR] = CyENB_XMTR;
2553 2682
2554 ier = base_addr[CyIER]; 2683 ier = base_addr[CyIER];
2555 base_addr[CyIER] = CyTxMpty; 2684 base_addr[CyIER] = CyTxMpty;
2556 2685
2557 while (1) { 2686 while (1) {
2558 if (pcc2chip[PccSCCTICR] & 0x !! 2687 if (pcc2chip[PccSCCTICR] & 0x20)
>> 2688 {
2559 /* We have a Tx int. 2689 /* We have a Tx int. Acknowledge it */
2560 sink = pcc2chip[PccTP 2690 sink = pcc2chip[PccTPIACKR];
2561 if ((base_addr[CyLICR 2691 if ((base_addr[CyLICR] >> 2) == port) {
2562 base_addr[CyT 2692 base_addr[CyTDR] = c;
2563 base_addr[CyT 2693 base_addr[CyTEOIR] = 0;
2564 break; 2694 break;
2565 } else !! 2695 }
>> 2696 else
2566 base_addr[CyT 2697 base_addr[CyTEOIR] = CyNOTRANS;
2567 } 2698 }
2568 } 2699 }
2569 2700
2570 base_addr[CyIER] = ier; 2701 base_addr[CyIER] = ier;
2571 2702
2572 local_irq_restore(flags); 2703 local_irq_restore(flags);
2573 } 2704 }
2574 2705
2575 int getDebugChar() 2706 int getDebugChar()
2576 { 2707 {
2577 volatile unsigned char *base_addr = ( !! 2708 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
2578 unsigned long flags; 2709 unsigned long flags;
2579 volatile u_char sink; 2710 volatile u_char sink;
2580 u_char ier; 2711 u_char ier;
2581 int port; 2712 int port;
2582 int i, c; 2713 int i, c;
2583 2714
2584 i = debugiq.out; 2715 i = debugiq.out;
2585 if (i != debugiq.in) { 2716 if (i != debugiq.in) {
2586 c = debugiq.buf[i]; 2717 c = debugiq.buf[i];
2587 if (++i == DEBUG_LEN) 2718 if (++i == DEBUG_LEN)
2588 i = 0; 2719 i = 0;
2589 debugiq.out = i; 2720 debugiq.out = i;
2590 return c; 2721 return c;
2591 } 2722 }
2592 /* OK, nothing in queue, wait in poll 2723 /* OK, nothing in queue, wait in poll loop */
2593 2724
2594 local_irq_save(flags); 2725 local_irq_save(flags);
2595 2726
2596 /* Ensure receiver is enabled! */ 2727 /* Ensure receiver is enabled! */
2597 2728
2598 port = DEBUG_PORT; 2729 port = DEBUG_PORT;
2599 base_addr[CyCAR] = (u_char) port; !! 2730 base_addr[CyCAR] = (u_char)port;
2600 #if 0 2731 #if 0
2601 while (base_addr[CyCCR]) 2732 while (base_addr[CyCCR])
2602 ; 2733 ;
2603 base_addr[CyCCR] = CyENB_RCVR; 2734 base_addr[CyCCR] = CyENB_RCVR;
2604 #endif 2735 #endif
2605 ier = base_addr[CyIER]; 2736 ier = base_addr[CyIER];
2606 base_addr[CyIER] = CyRxData; 2737 base_addr[CyIER] = CyRxData;
2607 2738
2608 while (1) { 2739 while (1) {
2609 if (pcc2chip[PccSCCRICR] & 0x !! 2740 if (pcc2chip[PccSCCRICR] & 0x20)
>> 2741 {
2610 /* We have a Rx int. 2742 /* We have a Rx int. Acknowledge it */
2611 sink = pcc2chip[PccRP 2743 sink = pcc2chip[PccRPIACKR];
2612 if ((base_addr[CyLICR 2744 if ((base_addr[CyLICR] >> 2) == port) {
2613 int cnt = bas 2745 int cnt = base_addr[CyRFOC];
2614 while (cnt-- !! 2746 while (cnt-- > 0)
>> 2747 {
2615 c = b 2748 c = base_addr[CyRDR];
2616 if (c 2749 if (c == 0)
2617 !! 2750 printk ("!! debug char is null (cnt=%d) !!", cnt);
2618 <<
2619 <<
2620 else 2751 else
2621 !! 2752 queueDebugChar (c);
2622 } 2753 }
2623 base_addr[CyR 2754 base_addr[CyREOIR] = 0;
2624 i = debugiq.o 2755 i = debugiq.out;
2625 if (i == debu 2756 if (i == debugiq.in)
2626 panic !! 2757 panic ("Debug input queue empty!");
2627 c = debugiq.b 2758 c = debugiq.buf[i];
2628 if (++i == DE 2759 if (++i == DEBUG_LEN)
2629 i = 0 2760 i = 0;
2630 debugiq.out = 2761 debugiq.out = i;
2631 break; 2762 break;
2632 } else !! 2763 }
>> 2764 else
2633 base_addr[CyR 2765 base_addr[CyREOIR] = CyNOTRANS;
2634 } 2766 }
2635 } 2767 }
2636 2768
2637 base_addr[CyIER] = ier; 2769 base_addr[CyIER] = ier;
2638 2770
2639 local_irq_restore(flags); 2771 local_irq_restore(flags);
2640 2772
2641 return (c); 2773 return (c);
2642 } 2774 }
2643 2775
2644 void queueDebugChar(int c) !! 2776 void queueDebugChar (int c)
2645 { 2777 {
2646 int i; 2778 int i;
2647 2779
2648 i = debugiq.in; 2780 i = debugiq.in;
2649 debugiq.buf[i] = c; 2781 debugiq.buf[i] = c;
2650 if (++i == DEBUG_LEN) 2782 if (++i == DEBUG_LEN)
2651 i = 0; 2783 i = 0;
2652 if (i != debugiq.out) 2784 if (i != debugiq.out)
2653 debugiq.in = i; 2785 debugiq.in = i;
2654 } 2786 }
2655 2787
2656 static void debug_setup() !! 2788 static void
>> 2789 debug_setup()
2657 { 2790 {
2658 unsigned long flags; !! 2791 unsigned long flags;
2659 volatile unsigned char *base_addr = ( !! 2792 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
2660 int i, cflag; !! 2793 int i, cflag;
2661 2794
2662 cflag = B19200; !! 2795 cflag = B19200;
2663 2796
2664 local_irq_save(flags); !! 2797 local_irq_save(flags);
2665 2798
2666 for (i = 0; i < 4; i++) { !! 2799 for (i = 0; i < 4; i++)
2667 base_addr[CyCAR] = i; !! 2800 {
2668 base_addr[CyLICR] = i << 2; !! 2801 base_addr[CyCAR] = i;
2669 } !! 2802 base_addr[CyLICR] = i << 2;
>> 2803 }
2670 2804
2671 debugiq.in = debugiq.out = 0; !!