Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]

Diff markup

Differences between /linux/drivers/char/serial167.c (Version 2.6.25.8) and /linux/drivers/char/serial167.c (Version 2.6.31.13)


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