aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/epca.c2611
1 files changed, 1202 insertions, 1409 deletions
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index c6c56fb8ba50..ffcecde9e2a5 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -1,34 +1,30 @@
1/* 1/*
2
3
4 Copyright (C) 1996 Digi International. 2 Copyright (C) 1996 Digi International.
5 3
6 For technical support please email digiLinux@dgii.com or 4 For technical support please email digiLinux@dgii.com or
7 call Digi tech support at (612) 912-3456 5 call Digi tech support at (612) 912-3456
8 6
9 ** This driver is no longer supported by Digi ** 7 ** This driver is no longer supported by Digi **
10 8
11 Much of this design and code came from epca.c which was 9 Much of this design and code came from epca.c which was
12 copyright (C) 1994, 1995 Troy De Jongh, and subsquently 10 copyright (C) 1994, 1995 Troy De Jongh, and subsquently
13 modified by David Nugent, Christoph Lameter, Mike McLagan. 11 modified by David Nugent, Christoph Lameter, Mike McLagan.
14
15 This program is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation; either version 2 of the License, or
18 (at your option) any later version.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28
29--------------------------------------------------------------------------- */
30/* See README.epca for change history --DAT*/
31 12
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26*/
27/* See README.epca for change history --DAT*/
32 28
33#include <linux/module.h> 29#include <linux/module.h>
34#include <linux/kernel.h> 30#include <linux/kernel.h>
@@ -54,13 +50,10 @@
54#include "epca.h" 50#include "epca.h"
55#include "epcaconfig.h" 51#include "epcaconfig.h"
56 52
57/* ---------------------- Begin defines ------------------------ */
58
59#define VERSION "1.3.0.1-LK2.6" 53#define VERSION "1.3.0.1-LK2.6"
60 54
61/* This major needs to be submitted to Linux to join the majors list */ 55/* This major needs to be submitted to Linux to join the majors list */
62 56#define DIGIINFOMAJOR 35 /* For Digi specific ioctl */
63#define DIGIINFOMAJOR 35 /* For Digi specific ioctl */
64 57
65 58
66#define MAXCARDS 7 59#define MAXCARDS 7
@@ -68,60 +61,48 @@
68 61
69#define PFX "epca: " 62#define PFX "epca: "
70 63
71/* ----------------- Begin global definitions ------------------- */
72
73static int nbdevs, num_cards, liloconfig; 64static int nbdevs, num_cards, liloconfig;
74static int digi_poller_inhibited = 1 ; 65static int digi_poller_inhibited = 1 ;
75 66
76static int setup_error_code; 67static int setup_error_code;
77static int invalid_lilo_config; 68static int invalid_lilo_config;
78 69
79/* The ISA boards do window flipping into the same spaces so its only sane 70/*
80 with a single lock. It's still pretty efficient */ 71 * The ISA boards do window flipping into the same spaces so its only sane with
81 72 * a single lock. It's still pretty efficient.
73 */
82static DEFINE_SPINLOCK(epca_lock); 74static DEFINE_SPINLOCK(epca_lock);
83 75
84/* ----------------------------------------------------------------------- 76/* MAXBOARDS is typically 12, but ISA and EISA cards are restricted to 7 below. */
85 MAXBOARDS is typically 12, but ISA and EISA cards are restricted to
86 7 below.
87--------------------------------------------------------------------------*/
88static struct board_info boards[MAXBOARDS]; 77static struct board_info boards[MAXBOARDS];
89 78
90
91/* ------------- Begin structures used for driver registeration ---------- */
92
93static struct tty_driver *pc_driver; 79static struct tty_driver *pc_driver;
94static struct tty_driver *pc_info; 80static struct tty_driver *pc_info;
95 81
96/* ------------------ Begin Digi specific structures -------------------- */ 82/* ------------------ Begin Digi specific structures -------------------- */
97 83
98/* ------------------------------------------------------------------------ 84/*
99 digi_channels represents an array of structures that keep track of 85 * digi_channels represents an array of structures that keep track of each
100 each channel of the Digi product. Information such as transmit and 86 * channel of the Digi product. Information such as transmit and receive
101 receive pointers, termio data, and signal definitions (DTR, CTS, etc ...) 87 * pointers, termio data, and signal definitions (DTR, CTS, etc ...) are stored
102 are stored here. This structure is NOT used to overlay the cards 88 * here. This structure is NOT used to overlay the cards physical channel
103 physical channel structure. 89 * structure.
104-------------------------------------------------------------------------- */ 90 */
105
106static struct channel digi_channels[MAX_ALLOC]; 91static struct channel digi_channels[MAX_ALLOC];
107 92
108/* ------------------------------------------------------------------------ 93/*
109 card_ptr is an array used to hold the address of the 94 * card_ptr is an array used to hold the address of the first channel structure
110 first channel structure of each card. This array will hold 95 * of each card. This array will hold the addresses of various channels located
111 the addresses of various channels located in digi_channels. 96 * in digi_channels.
112-------------------------------------------------------------------------- */ 97 */
113static struct channel *card_ptr[MAXCARDS]; 98static struct channel *card_ptr[MAXCARDS];
114 99
115static struct timer_list epca_timer; 100static struct timer_list epca_timer;
116 101
117/* ---------------------- Begin function prototypes --------------------- */ 102/*
118 103 * Begin generic memory functions. These functions will be alias (point at)
119/* ---------------------------------------------------------------------- 104 * more specific functions dependent on the board being configured.
120 Begin generic memory functions. These functions will be alias 105 */
121 (point at) more specific functions dependent on the board being
122 configured.
123----------------------------------------------------------------------- */
124
125static void memwinon(struct board_info *b, unsigned int win); 106static void memwinon(struct board_info *b, unsigned int win);
126static void memwinoff(struct board_info *b, unsigned int win); 107static void memwinoff(struct board_info *b, unsigned int win);
127static void globalwinon(struct channel *ch); 108static void globalwinon(struct channel *ch);
@@ -170,8 +151,6 @@ static void dummy_memoff(struct channel *ch);
170static void dummy_assertgwinon(struct channel *ch); 151static void dummy_assertgwinon(struct channel *ch);
171static void dummy_assertmemoff(struct channel *ch); 152static void dummy_assertmemoff(struct channel *ch);
172 153
173/* ------------------- Begin declare functions ----------------------- */
174
175static struct channel *verifyChannel(struct tty_struct *); 154static struct channel *verifyChannel(struct tty_struct *);
176static void pc_sched_event(struct channel *, int); 155static void pc_sched_event(struct channel *, int);
177static void epca_error(int, char *); 156static void epca_error(int, char *);
@@ -213,62 +192,55 @@ static int pc_write(struct tty_struct *, const unsigned char *, int);
213static int pc_init(void); 192static int pc_init(void);
214static int init_PCI(void); 193static int init_PCI(void);
215 194
216 195/*
217/* ------------------------------------------------------------------ 196 * Table of functions for each board to handle memory. Mantaining parallelism
218 Table of functions for each board to handle memory. Mantaining 197 * is a *very* good idea here. The idea is for the runtime code to blindly call
219 parallelism is a *very* good idea here. The idea is for the 198 * these functions, not knowing/caring about the underlying hardware. This
220 runtime code to blindly call these functions, not knowing/caring 199 * stuff should contain no conditionals; if more functionality is needed a
221 about the underlying hardware. This stuff should contain no 200 * different entry should be established. These calls are the interface calls
222 conditionals; if more functionality is needed a different entry 201 * and are the only functions that should be accessed. Anyone caught making
223 should be established. These calls are the interface calls and 202 * direct calls deserves what they get.
224 are the only functions that should be accessed. Anyone caught 203 */
225 making direct calls deserves what they get.
226-------------------------------------------------------------------- */
227
228static void memwinon(struct board_info *b, unsigned int win) 204static void memwinon(struct board_info *b, unsigned int win)
229{ 205{
230 (b->memwinon)(b, win); 206 b->memwinon(b, win);
231} 207}
232 208
233static void memwinoff(struct board_info *b, unsigned int win) 209static void memwinoff(struct board_info *b, unsigned int win)
234{ 210{
235 (b->memwinoff)(b, win); 211 b->memwinoff(b, win);
236} 212}
237 213
238static void globalwinon(struct channel *ch) 214static void globalwinon(struct channel *ch)
239{ 215{
240 (ch->board->globalwinon)(ch); 216 ch->board->globalwinon(ch);
241} 217}
242 218
243static void rxwinon(struct channel *ch) 219static void rxwinon(struct channel *ch)
244{ 220{
245 (ch->board->rxwinon)(ch); 221 ch->board->rxwinon(ch);
246} 222}
247 223
248static void txwinon(struct channel *ch) 224static void txwinon(struct channel *ch)
249{ 225{
250 (ch->board->txwinon)(ch); 226 ch->board->txwinon(ch);
251} 227}
252 228
253static void memoff(struct channel *ch) 229static void memoff(struct channel *ch)
254{ 230{
255 (ch->board->memoff)(ch); 231 ch->board->memoff(ch);
256} 232}
257static void assertgwinon(struct channel *ch) 233static void assertgwinon(struct channel *ch)
258{ 234{
259 (ch->board->assertgwinon)(ch); 235 ch->board->assertgwinon(ch);
260} 236}
261 237
262static void assertmemoff(struct channel *ch) 238static void assertmemoff(struct channel *ch)
263{ 239{
264 (ch->board->assertmemoff)(ch); 240 ch->board->assertmemoff(ch);
265} 241}
266 242
267/* --------------------------------------------------------- 243/* PCXEM windowing is the same as that used in the PCXR and CX series cards. */
268 PCXEM windowing is the same as that used in the PCXR
269 and CX series cards.
270------------------------------------------------------------ */
271
272static void pcxem_memwinon(struct board_info *b, unsigned int win) 244static void pcxem_memwinon(struct board_info *b, unsigned int win)
273{ 245{
274 outb_p(FEPWIN|win, b->port + 1); 246 outb_p(FEPWIN|win, b->port + 1);
@@ -300,32 +272,30 @@ static void pcxem_memoff(struct channel *ch)
300} 272}
301 273
302/* ----------------- Begin pcxe memory window stuff ------------------ */ 274/* ----------------- Begin pcxe memory window stuff ------------------ */
303
304static void pcxe_memwinon(struct board_info *b, unsigned int win) 275static void pcxe_memwinon(struct board_info *b, unsigned int win)
305{ 276{
306 outb_p(FEPWIN | win, b->port + 1); 277 outb_p(FEPWIN | win, b->port + 1);
307} 278}
308 279
309static void pcxe_memwinoff(struct board_info *b, unsigned int win) 280static void pcxe_memwinoff(struct board_info *b, unsigned int win)
310{ 281{
311 outb_p(inb(b->port) & ~FEPMEM, 282 outb_p(inb(b->port) & ~FEPMEM, b->port + 1);
312 b->port + 1);
313 outb_p(0, b->port + 1); 283 outb_p(0, b->port + 1);
314} 284}
315 285
316static void pcxe_globalwinon(struct channel *ch) 286static void pcxe_globalwinon(struct channel *ch)
317{ 287{
318 outb_p( FEPWIN, (int)ch->board->port + 1); 288 outb_p(FEPWIN, (int)ch->board->port + 1);
319} 289}
320 290
321static void pcxe_rxwinon(struct channel *ch) 291static void pcxe_rxwinon(struct channel *ch)
322{ 292{
323 outb_p(ch->rxwin, (int)ch->board->port + 1); 293 outb_p(ch->rxwin, (int)ch->board->port + 1);
324} 294}
325 295
326static void pcxe_txwinon(struct channel *ch) 296static void pcxe_txwinon(struct channel *ch)
327{ 297{
328 outb_p(ch->txwin, (int)ch->board->port + 1); 298 outb_p(ch->txwin, (int)ch->board->port + 1);
329} 299}
330 300
331static void pcxe_memoff(struct channel *ch) 301static void pcxe_memoff(struct channel *ch)
@@ -335,10 +305,9 @@ static void pcxe_memoff(struct channel *ch)
335} 305}
336 306
337/* ------------- Begin pc64xe and pcxi memory window stuff -------------- */ 307/* ------------- Begin pc64xe and pcxi memory window stuff -------------- */
338
339static void pcxi_memwinon(struct board_info *b, unsigned int win) 308static void pcxi_memwinon(struct board_info *b, unsigned int win)
340{ 309{
341 outb_p(inb(b->port) | FEPMEM, b->port); 310 outb_p(inb(b->port) | FEPMEM, b->port);
342} 311}
343 312
344static void pcxi_memwinoff(struct board_info *b, unsigned int win) 313static void pcxi_memwinoff(struct board_info *b, unsigned int win)
@@ -353,12 +322,12 @@ static void pcxi_globalwinon(struct channel *ch)
353 322
354static void pcxi_rxwinon(struct channel *ch) 323static void pcxi_rxwinon(struct channel *ch)
355{ 324{
356 outb_p(FEPMEM, ch->board->port); 325 outb_p(FEPMEM, ch->board->port);
357} 326}
358 327
359static void pcxi_txwinon(struct channel *ch) 328static void pcxi_txwinon(struct channel *ch)
360{ 329{
361 outb_p(FEPMEM, ch->board->port); 330 outb_p(FEPMEM, ch->board->port);
362} 331}
363 332
364static void pcxi_memoff(struct channel *ch) 333static void pcxi_memoff(struct channel *ch)
@@ -376,16 +345,13 @@ static void pcxi_assertmemoff(struct channel *ch)
376 epcaassert(!(inb(ch->board->port) & FEPMEM), "Memory on"); 345 epcaassert(!(inb(ch->board->port) & FEPMEM), "Memory on");
377} 346}
378 347
379 348/*
380/* ---------------------------------------------------------------------- 349 * Not all of the cards need specific memory windowing routines. Some cards
381 Not all of the cards need specific memory windowing routines. Some 350 * (Such as PCI) needs no windowing routines at all. We provide these do
382 cards (Such as PCI) needs no windowing routines at all. We provide 351 * nothing routines so that the same code base can be used. The driver will
383 these do nothing routines so that the same code base can be used. 352 * ALWAYS call a windowing routine if it thinks it needs to; regardless of the
384 The driver will ALWAYS call a windowing routine if it thinks it needs 353 * card. However, dependent on the card the routine may or may not do anything.
385 to; regardless of the card. However, dependent on the card the routine 354 */
386 may or may not do anything.
387---------------------------------------------------------------------------*/
388
389static void dummy_memwinon(struct board_info *b, unsigned int win) 355static void dummy_memwinon(struct board_info *b, unsigned int win)
390{ 356{
391} 357}
@@ -418,15 +384,14 @@ static void dummy_assertmemoff(struct channel *ch)
418{ 384{
419} 385}
420 386
421/* ----------------- Begin verifyChannel function ----------------------- */
422static struct channel *verifyChannel(struct tty_struct *tty) 387static struct channel *verifyChannel(struct tty_struct *tty)
423{ /* Begin verifyChannel */ 388{
424 /* -------------------------------------------------------------------- 389 /*
425 This routine basically provides a sanity check. It insures that 390 * This routine basically provides a sanity check. It insures that the
426 the channel returned is within the proper range of addresses as 391 * channel returned is within the proper range of addresses as well as
427 well as properly initialized. If some bogus info gets passed in 392 * properly initialized. If some bogus info gets passed in
428 through tty->driver_data this should catch it. 393 * through tty->driver_data this should catch it.
429 --------------------------------------------------------------------- */ 394 */
430 if (tty) { 395 if (tty) {
431 struct channel *ch = (struct channel *)tty->driver_data; 396 struct channel *ch = (struct channel *)tty->driver_data;
432 if ((ch >= &digi_channels[0]) && (ch < &digi_channels[nbdevs])) { 397 if ((ch >= &digi_channels[0]) && (ch < &digi_channels[nbdevs])) {
@@ -435,62 +400,55 @@ static struct channel *verifyChannel(struct tty_struct *tty)
435 } 400 }
436 } 401 }
437 return NULL; 402 return NULL;
438 403}
439} /* End verifyChannel */
440
441/* ------------------ Begin pc_sched_event ------------------------- */
442 404
443static void pc_sched_event(struct channel *ch, int event) 405static void pc_sched_event(struct channel *ch, int event)
444{ 406{
445 /* ---------------------------------------------------------------------- 407 /*
446 We call this to schedule interrupt processing on some event. The 408 * We call this to schedule interrupt processing on some event. The
447 kernel sees our request and calls the related routine in OUR driver. 409 * kernel sees our request and calls the related routine in OUR driver.
448 -------------------------------------------------------------------------*/ 410 */
449 ch->event |= 1 << event; 411 ch->event |= 1 << event;
450 schedule_work(&ch->tqueue); 412 schedule_work(&ch->tqueue);
451} /* End pc_sched_event */ 413}
452
453/* ------------------ Begin epca_error ------------------------- */
454 414
455static void epca_error(int line, char *msg) 415static void epca_error(int line, char *msg)
456{ 416{
457 printk(KERN_ERR "epca_error (Digi): line = %d %s\n",line,msg); 417 printk(KERN_ERR "epca_error (Digi): line = %d %s\n",line,msg);
458} 418}
459 419
460/* ------------------ Begin pc_close ------------------------- */ 420static void pc_close(struct tty_struct *tty, struct file *filp)
461static void pc_close(struct tty_struct * tty, struct file * filp)
462{ 421{
463 struct channel *ch; 422 struct channel *ch;
464 unsigned long flags; 423 unsigned long flags;
465 /* --------------------------------------------------------- 424 /*
466 verifyChannel returns the channel from the tty struct 425 * verifyChannel returns the channel from the tty struct if it is
467 if it is valid. This serves as a sanity check. 426 * valid. This serves as a sanity check.
468 ------------------------------------------------------------- */ 427 */
469 if ((ch = verifyChannel(tty)) != NULL) { /* Begin if ch != NULL */ 428 if ((ch = verifyChannel(tty)) != NULL) {
470 spin_lock_irqsave(&epca_lock, flags); 429 spin_lock_irqsave(&epca_lock, flags);
471 if (tty_hung_up_p(filp)) { 430 if (tty_hung_up_p(filp)) {
472 spin_unlock_irqrestore(&epca_lock, flags); 431 spin_unlock_irqrestore(&epca_lock, flags);
473 return; 432 return;
474 } 433 }
475 /* Check to see if the channel is open more than once */
476 if (ch->count-- > 1) { 434 if (ch->count-- > 1) {
477 /* Begin channel is open more than once */ 435 /* Begin channel is open more than once */
478 /* ------------------------------------------------------------- 436 /*
479 Return without doing anything. Someone might still be using 437 * Return without doing anything. Someone might still
480 the channel. 438 * be using the channel.
481 ---------------------------------------------------------------- */ 439 */
482 spin_unlock_irqrestore(&epca_lock, flags); 440 spin_unlock_irqrestore(&epca_lock, flags);
483 return; 441 return;
484 } /* End channel is open more than once */ 442 }
485 443
486 /* Port open only once go ahead with shutdown & reset */ 444 /* Port open only once go ahead with shutdown & reset */
487 BUG_ON(ch->count < 0); 445 BUG_ON(ch->count < 0);
488 446
489 /* --------------------------------------------------------------- 447 /*
490 Let the rest of the driver know the channel is being closed. 448 * Let the rest of the driver know the channel is being closed.
491 This becomes important if an open is attempted before close 449 * This becomes important if an open is attempted before close
492 is finished. 450 * is finished.
493 ------------------------------------------------------------------ */ 451 */
494 ch->asyncflags |= ASYNC_CLOSING; 452 ch->asyncflags |= ASYNC_CLOSING;
495 tty->closing = 1; 453 tty->closing = 1;
496 454
@@ -498,7 +456,7 @@ static void pc_close(struct tty_struct * tty, struct file * filp)
498 456
499 if (ch->asyncflags & ASYNC_INITIALIZED) { 457 if (ch->asyncflags & ASYNC_INITIALIZED) {
500 /* Setup an event to indicate when the transmit buffer empties */ 458 /* Setup an event to indicate when the transmit buffer empties */
501 setup_empty_event(tty, ch); 459 setup_empty_event(tty, ch);
502 tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */ 460 tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */
503 } 461 }
504 if (tty->driver->flush_buffer) 462 if (tty->driver->flush_buffer)
@@ -513,27 +471,24 @@ static void pc_close(struct tty_struct * tty, struct file * filp)
513 ch->tty = NULL; 471 ch->tty = NULL;
514 spin_unlock_irqrestore(&epca_lock, flags); 472 spin_unlock_irqrestore(&epca_lock, flags);
515 473
516 if (ch->blocked_open) { /* Begin if blocked_open */ 474 if (ch->blocked_open) {
517 if (ch->close_delay) 475 if (ch->close_delay)
518 msleep_interruptible(jiffies_to_msecs(ch->close_delay)); 476 msleep_interruptible(jiffies_to_msecs(ch->close_delay));
519 wake_up_interruptible(&ch->open_wait); 477 wake_up_interruptible(&ch->open_wait);
520 } /* End if blocked_open */ 478 }
521 ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED | 479 ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED |
522 ASYNC_CLOSING); 480 ASYNC_CLOSING);
523 wake_up_interruptible(&ch->close_wait); 481 wake_up_interruptible(&ch->close_wait);
524 } /* End if ch != NULL */ 482 }
525} /* End pc_close */ 483}
526
527/* ------------------ Begin shutdown ------------------------- */
528 484
529static void shutdown(struct channel *ch) 485static void shutdown(struct channel *ch)
530{ /* Begin shutdown */ 486{
531
532 unsigned long flags; 487 unsigned long flags;
533 struct tty_struct *tty; 488 struct tty_struct *tty;
534 struct board_chan __iomem *bc; 489 struct board_chan __iomem *bc;
535 490
536 if (!(ch->asyncflags & ASYNC_INITIALIZED)) 491 if (!(ch->asyncflags & ASYNC_INITIALIZED))
537 return; 492 return;
538 493
539 spin_lock_irqsave(&epca_lock, flags); 494 spin_lock_irqsave(&epca_lock, flags);
@@ -541,50 +496,40 @@ static void shutdown(struct channel *ch)
541 globalwinon(ch); 496 globalwinon(ch);
542 bc = ch->brdchan; 497 bc = ch->brdchan;
543 498
544 /* ------------------------------------------------------------------ 499 /*
545 In order for an event to be generated on the receipt of data the 500 * In order for an event to be generated on the receipt of data the
546 idata flag must be set. Since we are shutting down, this is not 501 * idata flag must be set. Since we are shutting down, this is not
547 necessary clear this flag. 502 * necessary clear this flag.
548 --------------------------------------------------------------------- */ 503 */
549
550 if (bc) 504 if (bc)
551 writeb(0, &bc->idata); 505 writeb(0, &bc->idata);
552 tty = ch->tty; 506 tty = ch->tty;
553 507
554 /* ---------------------------------------------------------------- 508 /* If we're a modem control device and HUPCL is on, drop RTS & DTR. */
555 If we're a modem control device and HUPCL is on, drop RTS & DTR.
556 ------------------------------------------------------------------ */
557
558 if (tty->termios->c_cflag & HUPCL) { 509 if (tty->termios->c_cflag & HUPCL) {
559 ch->omodem &= ~(ch->m_rts | ch->m_dtr); 510 ch->omodem &= ~(ch->m_rts | ch->m_dtr);
560 fepcmd(ch, SETMODEM, 0, ch->m_dtr | ch->m_rts, 10, 1); 511 fepcmd(ch, SETMODEM, 0, ch->m_dtr | ch->m_rts, 10, 1);
561 } 512 }
562 memoff(ch); 513 memoff(ch);
563 514
564 /* ------------------------------------------------------------------ 515 /*
565 The channel has officialy been closed. The next time it is opened 516 * The channel has officialy been closed. The next time it is opened it
566 it will have to reinitialized. Set a flag to indicate this. 517 * will have to reinitialized. Set a flag to indicate this.
567 ---------------------------------------------------------------------- */ 518 */
568
569 /* Prevent future Digi programmed interrupts from coming active */ 519 /* Prevent future Digi programmed interrupts from coming active */
570
571 ch->asyncflags &= ~ASYNC_INITIALIZED; 520 ch->asyncflags &= ~ASYNC_INITIALIZED;
572 spin_unlock_irqrestore(&epca_lock, flags); 521 spin_unlock_irqrestore(&epca_lock, flags);
573 522}
574} /* End shutdown */
575
576/* ------------------ Begin pc_hangup ------------------------- */
577 523
578static void pc_hangup(struct tty_struct *tty) 524static void pc_hangup(struct tty_struct *tty)
579{ /* Begin pc_hangup */ 525{
580 struct channel *ch; 526 struct channel *ch;
581
582 /* ---------------------------------------------------------
583 verifyChannel returns the channel from the tty struct
584 if it is valid. This serves as a sanity check.
585 ------------------------------------------------------------- */
586 527
587 if ((ch = verifyChannel(tty)) != NULL) { /* Begin if ch != NULL */ 528 /*
529 * verifyChannel returns the channel from the tty struct if it is
530 * valid. This serves as a sanity check.
531 */
532 if ((ch = verifyChannel(tty)) != NULL) {
588 unsigned long flags; 533 unsigned long flags;
589 534
590 if (tty->driver->flush_buffer) 535 if (tty->driver->flush_buffer)
@@ -599,15 +544,12 @@ static void pc_hangup(struct tty_struct *tty)
599 ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED); 544 ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED);
600 spin_unlock_irqrestore(&epca_lock, flags); 545 spin_unlock_irqrestore(&epca_lock, flags);
601 wake_up_interruptible(&ch->open_wait); 546 wake_up_interruptible(&ch->open_wait);
602 } /* End if ch != NULL */ 547 }
603 548}
604} /* End pc_hangup */
605
606/* ------------------ Begin pc_write ------------------------- */
607 549
608static int pc_write(struct tty_struct * tty, 550static int pc_write(struct tty_struct *tty,
609 const unsigned char *buf, int bytesAvailable) 551 const unsigned char *buf, int bytesAvailable)
610{ /* Begin pc_write */ 552{
611 unsigned int head, tail; 553 unsigned int head, tail;
612 int dataLen; 554 int dataLen;
613 int size; 555 int size;
@@ -617,25 +559,23 @@ static int pc_write(struct tty_struct * tty,
617 int remain; 559 int remain;
618 struct board_chan __iomem *bc; 560 struct board_chan __iomem *bc;
619 561
620 /* ---------------------------------------------------------------- 562 /*
621 pc_write is primarily called directly by the kernel routine 563 * pc_write is primarily called directly by the kernel routine
622 tty_write (Though it can also be called by put_char) found in 564 * tty_write (Though it can also be called by put_char) found in
623 tty_io.c. pc_write is passed a line discipline buffer where 565 * tty_io.c. pc_write is passed a line discipline buffer where the data
624 the data to be written out is stored. The line discipline 566 * to be written out is stored. The line discipline implementation
625 implementation itself is done at the kernel level and is not 567 * itself is done at the kernel level and is not brought into the
626 brought into the driver. 568 * driver.
627 ------------------------------------------------------------------- */ 569 */
628
629 /* ---------------------------------------------------------
630 verifyChannel returns the channel from the tty struct
631 if it is valid. This serves as a sanity check.
632 ------------------------------------------------------------- */
633 570
571 /*
572 * verifyChannel returns the channel from the tty struct if it is
573 * valid. This serves as a sanity check.
574 */
634 if ((ch = verifyChannel(tty)) == NULL) 575 if ((ch = verifyChannel(tty)) == NULL)
635 return 0; 576 return 0;
636 577
637 /* Make a pointer to the channel data structure found on the board. */ 578 /* Make a pointer to the channel data structure found on the board. */
638
639 bc = ch->brdchan; 579 bc = ch->brdchan;
640 size = ch->txbufsize; 580 size = ch->txbufsize;
641 amountCopied = 0; 581 amountCopied = 0;
@@ -650,37 +590,36 @@ static int pc_write(struct tty_struct * tty,
650 tail = readw(&bc->tout); 590 tail = readw(&bc->tout);
651 tail &= (size - 1); 591 tail &= (size - 1);
652 592
653 /* If head >= tail, head has not wrapped around. */ 593 if (head >= tail) {
654 if (head >= tail) { /* Begin head has not wrapped */ 594 /* head has not wrapped */
655 /* --------------------------------------------------------------- 595 /*
656 remain (much like dataLen above) represents the total amount of 596 * remain (much like dataLen above) represents the total amount
657 space available on the card for data. Here dataLen represents 597 * of space available on the card for data. Here dataLen
658 the space existing between the head pointer and the end of 598 * represents the space existing between the head pointer and
659 buffer. This is important because a memcpy cannot be told to 599 * the end of buffer. This is important because a memcpy cannot
660 automatically wrap around when it hits the buffer end. 600 * be told to automatically wrap around when it hits the buffer
661 ------------------------------------------------------------------ */ 601 * end.
602 */
662 dataLen = size - head; 603 dataLen = size - head;
663 remain = size - (head - tail) - 1; 604 remain = size - (head - tail) - 1;
664 } else { /* Begin head has wrapped around */ 605 } else {
665 606 /* head has wrapped around */
666 remain = tail - head - 1; 607 remain = tail - head - 1;
667 dataLen = remain; 608 dataLen = remain;
668 609 }
669 } /* End head has wrapped around */ 610 /*
670 /* ------------------------------------------------------------------- 611 * Check the space on the card. If we have more data than space; reduce
671 Check the space on the card. If we have more data than 612 * the amount of data to fit the space.
672 space; reduce the amount of data to fit the space. 613 */
673 ---------------------------------------------------------------------- */
674 bytesAvailable = min(remain, bytesAvailable); 614 bytesAvailable = min(remain, bytesAvailable);
675 txwinon(ch); 615 txwinon(ch);
676 while (bytesAvailable > 0) 616 while (bytesAvailable > 0) {
677 { /* Begin while there is data to copy onto card */ 617 /* there is data to copy onto card */
678
679 /* -----------------------------------------------------------------
680 If head is not wrapped, the below will make sure the first
681 data copy fills to the end of card buffer.
682 ------------------------------------------------------------------- */
683 618
619 /*
620 * If head is not wrapped, the below will make sure the first
621 * data copy fills to the end of card buffer.
622 */
684 dataLen = min(bytesAvailable, dataLen); 623 dataLen = min(bytesAvailable, dataLen);
685 memcpy_toio(ch->txptr + head, buf, dataLen); 624 memcpy_toio(ch->txptr + head, buf, dataLen);
686 buf += dataLen; 625 buf += dataLen;
@@ -692,7 +631,7 @@ static int pc_write(struct tty_struct * tty,
692 head = 0; 631 head = 0;
693 dataLen = tail; 632 dataLen = tail;
694 } 633 }
695 } /* End while there is data to copy onto card */ 634 }
696 ch->statusflags |= TXBUSY; 635 ch->statusflags |= TXBUSY;
697 globalwinon(ch); 636 globalwinon(ch);
698 writew(head, &bc->tin); 637 writew(head, &bc->tin);
@@ -703,22 +642,16 @@ static int pc_write(struct tty_struct * tty,
703 } 642 }
704 memoff(ch); 643 memoff(ch);
705 spin_unlock_irqrestore(&epca_lock, flags); 644 spin_unlock_irqrestore(&epca_lock, flags);
706 return(amountCopied); 645 return amountCopied;
707 646}
708} /* End pc_write */
709
710/* ------------------ Begin pc_put_char ------------------------- */
711 647
712static void pc_put_char(struct tty_struct *tty, unsigned char c) 648static void pc_put_char(struct tty_struct *tty, unsigned char c)
713{ /* Begin pc_put_char */ 649{
714 pc_write(tty, &c, 1); 650 pc_write(tty, &c, 1);
715} /* End pc_put_char */ 651}
716
717/* ------------------ Begin pc_write_room ------------------------- */
718 652
719static int pc_write_room(struct tty_struct *tty) 653static int pc_write_room(struct tty_struct *tty)
720{ /* Begin pc_write_room */ 654{
721
722 int remain; 655 int remain;
723 struct channel *ch; 656 struct channel *ch;
724 unsigned long flags; 657 unsigned long flags;
@@ -727,11 +660,10 @@ static int pc_write_room(struct tty_struct *tty)
727 660
728 remain = 0; 661 remain = 0;
729 662
730 /* --------------------------------------------------------- 663 /*
731 verifyChannel returns the channel from the tty struct 664 * verifyChannel returns the channel from the tty struct if it is
732 if it is valid. This serves as a sanity check. 665 * valid. This serves as a sanity check.
733 ------------------------------------------------------------- */ 666 */
734
735 if ((ch = verifyChannel(tty)) != NULL) { 667 if ((ch = verifyChannel(tty)) != NULL) {
736 spin_lock_irqsave(&epca_lock, flags); 668 spin_lock_irqsave(&epca_lock, flags);
737 globalwinon(ch); 669 globalwinon(ch);
@@ -757,14 +689,10 @@ static int pc_write_room(struct tty_struct *tty)
757 } 689 }
758 /* Return how much room is left on card */ 690 /* Return how much room is left on card */
759 return remain; 691 return remain;
760 692}
761} /* End pc_write_room */
762
763/* ------------------ Begin pc_chars_in_buffer ---------------------- */
764 693
765static int pc_chars_in_buffer(struct tty_struct *tty) 694static int pc_chars_in_buffer(struct tty_struct *tty)
766{ /* Begin pc_chars_in_buffer */ 695{
767
768 int chars; 696 int chars;
769 unsigned int ctail, head, tail; 697 unsigned int ctail, head, tail;
770 int remain; 698 int remain;
@@ -772,13 +700,12 @@ static int pc_chars_in_buffer(struct tty_struct *tty)
772 struct channel *ch; 700 struct channel *ch;
773 struct board_chan __iomem *bc; 701 struct board_chan __iomem *bc;
774 702
775 /* --------------------------------------------------------- 703 /*
776 verifyChannel returns the channel from the tty struct 704 * verifyChannel returns the channel from the tty struct if it is
777 if it is valid. This serves as a sanity check. 705 * valid. This serves as a sanity check.
778 ------------------------------------------------------------- */ 706 */
779
780 if ((ch = verifyChannel(tty)) == NULL) 707 if ((ch = verifyChannel(tty)) == NULL)
781 return(0); 708 return 0;
782 709
783 spin_lock_irqsave(&epca_lock, flags); 710 spin_lock_irqsave(&epca_lock, flags);
784 globalwinon(ch); 711 globalwinon(ch);
@@ -793,45 +720,40 @@ static int pc_chars_in_buffer(struct tty_struct *tty)
793 else { /* Begin if some space on the card has been used */ 720 else { /* Begin if some space on the card has been used */
794 head = readw(&bc->tin) & (ch->txbufsize - 1); 721 head = readw(&bc->tin) & (ch->txbufsize - 1);
795 tail &= (ch->txbufsize - 1); 722 tail &= (ch->txbufsize - 1);
796 /* -------------------------------------------------------------- 723 /*
797 The logic here is basically opposite of the above pc_write_room 724 * The logic here is basically opposite of the above
798 here we are finding the amount of bytes in the buffer filled. 725 * pc_write_room here we are finding the amount of bytes in the
799 Not the amount of bytes empty. 726 * buffer filled. Not the amount of bytes empty.
800 ------------------------------------------------------------------- */ 727 */
801 if ((remain = tail - head - 1) < 0 ) 728 if ((remain = tail - head - 1) < 0 )
802 remain += ch->txbufsize; 729 remain += ch->txbufsize;
803 chars = (int)(ch->txbufsize - remain); 730 chars = (int)(ch->txbufsize - remain);
804 /* ------------------------------------------------------------- 731 /*
805 Make it possible to wakeup anything waiting for output 732 * Make it possible to wakeup anything waiting for output in
806 in tty_ioctl.c, etc. 733 * tty_ioctl.c, etc.
807 734 *
808 If not already set. Setup an event to indicate when the 735 * If not already set. Setup an event to indicate when the
809 transmit buffer empties 736 * transmit buffer empties.
810 ----------------------------------------------------------------- */ 737 */
811 if (!(ch->statusflags & EMPTYWAIT)) 738 if (!(ch->statusflags & EMPTYWAIT))
812 setup_empty_event(tty,ch); 739 setup_empty_event(tty,ch);
813
814 } /* End if some space on the card has been used */ 740 } /* End if some space on the card has been used */
815 memoff(ch); 741 memoff(ch);
816 spin_unlock_irqrestore(&epca_lock, flags); 742 spin_unlock_irqrestore(&epca_lock, flags);
817 /* Return number of characters residing on card. */ 743 /* Return number of characters residing on card. */
818 return(chars); 744 return chars;
819 745}
820} /* End pc_chars_in_buffer */
821
822/* ------------------ Begin pc_flush_buffer ---------------------- */
823 746
824static void pc_flush_buffer(struct tty_struct *tty) 747static void pc_flush_buffer(struct tty_struct *tty)
825{ /* Begin pc_flush_buffer */ 748{
826
827 unsigned int tail; 749 unsigned int tail;
828 unsigned long flags; 750 unsigned long flags;
829 struct channel *ch; 751 struct channel *ch;
830 struct board_chan __iomem *bc; 752 struct board_chan __iomem *bc;
831 /* --------------------------------------------------------- 753 /*
832 verifyChannel returns the channel from the tty struct 754 * verifyChannel returns the channel from the tty struct if it is
833 if it is valid. This serves as a sanity check. 755 * valid. This serves as a sanity check.
834 ------------------------------------------------------------- */ 756 */
835 if ((ch = verifyChannel(tty)) == NULL) 757 if ((ch = verifyChannel(tty)) == NULL)
836 return; 758 return;
837 759
@@ -844,51 +766,47 @@ static void pc_flush_buffer(struct tty_struct *tty)
844 memoff(ch); 766 memoff(ch);
845 spin_unlock_irqrestore(&epca_lock, flags); 767 spin_unlock_irqrestore(&epca_lock, flags);
846 tty_wakeup(tty); 768 tty_wakeup(tty);
847} /* End pc_flush_buffer */ 769}
848
849/* ------------------ Begin pc_flush_chars ---------------------- */
850 770
851static void pc_flush_chars(struct tty_struct *tty) 771static void pc_flush_chars(struct tty_struct *tty)
852{ /* Begin pc_flush_chars */ 772{
853 struct channel * ch; 773 struct channel *ch;
854 /* --------------------------------------------------------- 774 /*
855 verifyChannel returns the channel from the tty struct 775 * verifyChannel returns the channel from the tty struct if it is
856 if it is valid. This serves as a sanity check. 776 * valid. This serves as a sanity check.
857 ------------------------------------------------------------- */ 777 */
858 if ((ch = verifyChannel(tty)) != NULL) { 778 if ((ch = verifyChannel(tty)) != NULL) {
859 unsigned long flags; 779 unsigned long flags;
860 spin_lock_irqsave(&epca_lock, flags); 780 spin_lock_irqsave(&epca_lock, flags);
861 /* ---------------------------------------------------------------- 781 /*
862 If not already set and the transmitter is busy setup an event 782 * If not already set and the transmitter is busy setup an
863 to indicate when the transmit empties. 783 * event to indicate when the transmit empties.
864 ------------------------------------------------------------------- */ 784 */
865 if ((ch->statusflags & TXBUSY) && !(ch->statusflags & EMPTYWAIT)) 785 if ((ch->statusflags & TXBUSY) && !(ch->statusflags & EMPTYWAIT))
866 setup_empty_event(tty,ch); 786 setup_empty_event(tty,ch);
867 spin_unlock_irqrestore(&epca_lock, flags); 787 spin_unlock_irqrestore(&epca_lock, flags);
868 } 788 }
869} /* End pc_flush_chars */ 789}
870
871/* ------------------ Begin block_til_ready ---------------------- */
872 790
873static int block_til_ready(struct tty_struct *tty, 791static int block_til_ready(struct tty_struct *tty,
874 struct file *filp, struct channel *ch) 792 struct file *filp, struct channel *ch)
875{ /* Begin block_til_ready */ 793{
876 DECLARE_WAITQUEUE(wait,current); 794 DECLARE_WAITQUEUE(wait,current);
877 int retval, do_clocal = 0; 795 int retval, do_clocal = 0;
878 unsigned long flags; 796 unsigned long flags;
879 797
880 if (tty_hung_up_p(filp)) { 798 if (tty_hung_up_p(filp)) {
881 if (ch->asyncflags & ASYNC_HUP_NOTIFY) 799 if (ch->asyncflags & ASYNC_HUP_NOTIFY)
882 retval = -EAGAIN; 800 retval = -EAGAIN;
883 else 801 else
884 retval = -ERESTARTSYS; 802 retval = -ERESTARTSYS;
885 return(retval); 803 return retval;
886 } 804 }
887 805
888 /* ----------------------------------------------------------------- 806 /*
889 If the device is in the middle of being closed, then block 807 * If the device is in the middle of being closed, then block until
890 until it's done, and then try again. 808 * it's done, and then try again.
891 -------------------------------------------------------------------- */ 809 */
892 if (ch->asyncflags & ASYNC_CLOSING) { 810 if (ch->asyncflags & ASYNC_CLOSING) {
893 interruptible_sleep_on(&ch->close_wait); 811 interruptible_sleep_on(&ch->close_wait);
894 812
@@ -899,17 +817,17 @@ static int block_til_ready(struct tty_struct *tty,
899 } 817 }
900 818
901 if (filp->f_flags & O_NONBLOCK) { 819 if (filp->f_flags & O_NONBLOCK) {
902 /* ----------------------------------------------------------------- 820 /*
903 If non-blocking mode is set, then make the check up front 821 * If non-blocking mode is set, then make the check up front
904 and then exit. 822 * and then exit.
905 -------------------------------------------------------------------- */ 823 */
906 ch->asyncflags |= ASYNC_NORMAL_ACTIVE; 824 ch->asyncflags |= ASYNC_NORMAL_ACTIVE;
907 return 0; 825 return 0;
908 } 826 }
909 if (tty->termios->c_cflag & CLOCAL) 827 if (tty->termios->c_cflag & CLOCAL)
910 do_clocal = 1; 828 do_clocal = 1;
911 /* Block waiting for the carrier detect and the line to become free */ 829 /* Block waiting for the carrier detect and the line to become free */
912 830
913 retval = 0; 831 retval = 0;
914 add_wait_queue(&ch->open_wait, &wait); 832 add_wait_queue(&ch->open_wait, &wait);
915 833
@@ -918,19 +836,18 @@ static int block_til_ready(struct tty_struct *tty,
918 if (!tty_hung_up_p(filp)) 836 if (!tty_hung_up_p(filp))
919 ch->count--; 837 ch->count--;
920 ch->blocked_open++; 838 ch->blocked_open++;
921 while(1) 839 while (1) {
922 { /* Begin forever while */
923 set_current_state(TASK_INTERRUPTIBLE); 840 set_current_state(TASK_INTERRUPTIBLE);
924 if (tty_hung_up_p(filp) || 841 if (tty_hung_up_p(filp) ||
925 !(ch->asyncflags & ASYNC_INITIALIZED)) 842 !(ch->asyncflags & ASYNC_INITIALIZED))
926 { 843 {
927 if (ch->asyncflags & ASYNC_HUP_NOTIFY) 844 if (ch->asyncflags & ASYNC_HUP_NOTIFY)
928 retval = -EAGAIN; 845 retval = -EAGAIN;
929 else 846 else
930 retval = -ERESTARTSYS; 847 retval = -ERESTARTSYS;
931 break; 848 break;
932 } 849 }
933 if (!(ch->asyncflags & ASYNC_CLOSING) && 850 if (!(ch->asyncflags & ASYNC_CLOSING) &&
934 (do_clocal || (ch->imodem & ch->dcd))) 851 (do_clocal || (ch->imodem & ch->dcd)))
935 break; 852 break;
936 if (signal_pending(current)) { 853 if (signal_pending(current)) {
@@ -938,16 +855,15 @@ static int block_til_ready(struct tty_struct *tty,
938 break; 855 break;
939 } 856 }
940 spin_unlock_irqrestore(&epca_lock, flags); 857 spin_unlock_irqrestore(&epca_lock, flags);
941 /* --------------------------------------------------------------- 858 /*
942 Allow someone else to be scheduled. We will occasionally go 859 * Allow someone else to be scheduled. We will occasionally go
943 through this loop until one of the above conditions change. 860 * through this loop until one of the above conditions change.
944 The below schedule call will allow other processes to enter and 861 * The below schedule call will allow other processes to enter
945 prevent this loop from hogging the cpu. 862 * and prevent this loop from hogging the cpu.
946 ------------------------------------------------------------------ */ 863 */
947 schedule(); 864 schedule();
948 spin_lock_irqsave(&epca_lock, flags); 865 spin_lock_irqsave(&epca_lock, flags);
949 866 }
950 } /* End forever while */
951 867
952 __set_current_state(TASK_RUNNING); 868 __set_current_state(TASK_RUNNING);
953 remove_wait_queue(&ch->open_wait, &wait); 869 remove_wait_queue(&ch->open_wait, &wait);
@@ -962,13 +878,10 @@ static int block_til_ready(struct tty_struct *tty,
962 878
963 ch->asyncflags |= ASYNC_NORMAL_ACTIVE; 879 ch->asyncflags |= ASYNC_NORMAL_ACTIVE;
964 return 0; 880 return 0;
965} /* End block_til_ready */ 881}
966
967/* ------------------ Begin pc_open ---------------------- */
968 882
969static int pc_open(struct tty_struct *tty, struct file * filp) 883static int pc_open(struct tty_struct *tty, struct file * filp)
970{ /* Begin pc_open */ 884{
971
972 struct channel *ch; 885 struct channel *ch;
973 unsigned long flags; 886 unsigned long flags;
974 int line, retval, boardnum; 887 int line, retval, boardnum;
@@ -984,12 +897,11 @@ static int pc_open(struct tty_struct *tty, struct file * filp)
984 897
985 /* Check status of board configured in system. */ 898 /* Check status of board configured in system. */
986 899
987 /* ----------------------------------------------------------------- 900 /*
988 I check to see if the epca_setup routine detected an user error. 901 * I check to see if the epca_setup routine detected an user error. It
989 It might be better to put this in pc_init, but for the moment it 902 * might be better to put this in pc_init, but for the moment it goes
990 goes here. 903 * here.
991 ---------------------------------------------------------------------- */ 904 */
992
993 if (invalid_lilo_config) { 905 if (invalid_lilo_config) {
994 if (setup_error_code & INVALID_BOARD_TYPE) 906 if (setup_error_code & INVALID_BOARD_TYPE)
995 printk(KERN_ERR "epca: pc_open: Invalid board type specified in kernel options.\n"); 907 printk(KERN_ERR "epca: pc_open: Invalid board type specified in kernel options.\n");
@@ -1010,49 +922,48 @@ static int pc_open(struct tty_struct *tty, struct file * filp)
1010 tty->driver_data = NULL; /* Mark this device as 'down' */ 922 tty->driver_data = NULL; /* Mark this device as 'down' */
1011 return(-ENODEV); 923 return(-ENODEV);
1012 } 924 }
1013 925
1014 if ((bc = ch->brdchan) == 0) { 926 if ((bc = ch->brdchan) == 0) {
1015 tty->driver_data = NULL; 927 tty->driver_data = NULL;
1016 return -ENODEV; 928 return -ENODEV;
1017 } 929 }
1018 930
1019 spin_lock_irqsave(&epca_lock, flags); 931 spin_lock_irqsave(&epca_lock, flags);
1020 /* ------------------------------------------------------------------ 932 /*
1021 Every time a channel is opened, increment a counter. This is 933 * Every time a channel is opened, increment a counter. This is
1022 necessary because we do not wish to flush and shutdown the channel 934 * necessary because we do not wish to flush and shutdown the channel
1023 until the last app holding the channel open, closes it. 935 * until the last app holding the channel open, closes it.
1024 --------------------------------------------------------------------- */ 936 */
1025 ch->count++; 937 ch->count++;
1026 /* ---------------------------------------------------------------- 938 /*
1027 Set a kernel structures pointer to our local channel 939 * Set a kernel structures pointer to our local channel structure. This
1028 structure. This way we can get to it when passed only 940 * way we can get to it when passed only a tty struct.
1029 a tty struct. 941 */
1030 ------------------------------------------------------------------ */
1031 tty->driver_data = ch; 942 tty->driver_data = ch;
1032 /* ---------------------------------------------------------------- 943 /*
1033 If this is the first time the channel has been opened, initialize 944 * If this is the first time the channel has been opened, initialize
1034 the tty->termios struct otherwise let pc_close handle it. 945 * the tty->termios struct otherwise let pc_close handle it.
1035 -------------------------------------------------------------------- */ 946 */
1036 globalwinon(ch); 947 globalwinon(ch);
1037 ch->statusflags = 0; 948 ch->statusflags = 0;
1038 949
1039 /* Save boards current modem status */ 950 /* Save boards current modem status */
1040 ch->imodem = readb(&bc->mstat); 951 ch->imodem = readb(&bc->mstat);
1041 952
1042 /* ---------------------------------------------------------------- 953 /*
1043 Set receive head and tail ptrs to each other. This indicates 954 * Set receive head and tail ptrs to each other. This indicates no data
1044 no data available to read. 955 * available to read.
1045 ----------------------------------------------------------------- */ 956 */
1046 head = readw(&bc->rin); 957 head = readw(&bc->rin);
1047 writew(head, &bc->rout); 958 writew(head, &bc->rout);
1048 959
1049 /* Set the channels associated tty structure */ 960 /* Set the channels associated tty structure */
1050 ch->tty = tty; 961 ch->tty = tty;
1051 962
1052 /* ----------------------------------------------------------------- 963 /*
1053 The below routine generally sets up parity, baud, flow control 964 * The below routine generally sets up parity, baud, flow control
1054 issues, etc.... It effect both control flags and input flags. 965 * issues, etc.... It effect both control flags and input flags.
1055 -------------------------------------------------------------------- */ 966 */
1056 epcaparam(tty,ch); 967 epcaparam(tty,ch);
1057 ch->asyncflags |= ASYNC_INITIALIZED; 968 ch->asyncflags |= ASYNC_INITIALIZED;
1058 memoff(ch); 969 memoff(ch);
@@ -1061,10 +972,10 @@ static int pc_open(struct tty_struct *tty, struct file * filp)
1061 retval = block_til_ready(tty, filp, ch); 972 retval = block_til_ready(tty, filp, ch);
1062 if (retval) 973 if (retval)
1063 return retval; 974 return retval;
1064 /* ------------------------------------------------------------- 975 /*
1065 Set this again in case a hangup set it to zero while this 976 * Set this again in case a hangup set it to zero while this open() was
1066 open() was waiting for the line... 977 * waiting for the line...
1067 --------------------------------------------------------------- */ 978 */
1068 spin_lock_irqsave(&epca_lock, flags); 979 spin_lock_irqsave(&epca_lock, flags);
1069 ch->tty = tty; 980 ch->tty = tty;
1070 globalwinon(ch); 981 globalwinon(ch);
@@ -1073,13 +984,12 @@ static int pc_open(struct tty_struct *tty, struct file * filp)
1073 memoff(ch); 984 memoff(ch);
1074 spin_unlock_irqrestore(&epca_lock, flags); 985 spin_unlock_irqrestore(&epca_lock, flags);
1075 return 0; 986 return 0;
1076} /* End pc_open */ 987}
1077 988
1078static int __init epca_module_init(void) 989static int __init epca_module_init(void)
1079{ /* Begin init_module */ 990{
1080 return pc_init(); 991 return pc_init();
1081} 992}
1082
1083module_init(epca_module_init); 993module_init(epca_module_init);
1084 994
1085static struct pci_driver epca_driver; 995static struct pci_driver epca_driver;
@@ -1092,8 +1002,7 @@ static void __exit epca_module_exit(void)
1092 1002
1093 del_timer_sync(&epca_timer); 1003 del_timer_sync(&epca_timer);
1094 1004
1095 if ((tty_unregister_driver(pc_driver)) || 1005 if (tty_unregister_driver(pc_driver) || tty_unregister_driver(pc_info))
1096 (tty_unregister_driver(pc_info)))
1097 { 1006 {
1098 printk(KERN_WARNING "epca: cleanup_module failed to un-register tty driver\n"); 1007 printk(KERN_WARNING "epca: cleanup_module failed to un-register tty driver\n");
1099 return; 1008 return;
@@ -1101,23 +1010,20 @@ static void __exit epca_module_exit(void)
1101 put_tty_driver(pc_driver); 1010 put_tty_driver(pc_driver);
1102 put_tty_driver(pc_info); 1011 put_tty_driver(pc_info);
1103 1012
1104 for (crd = 0; crd < num_cards; crd++) { /* Begin for each card */ 1013 for (crd = 0; crd < num_cards; crd++) {
1105 bd = &boards[crd]; 1014 bd = &boards[crd];
1106 if (!bd) 1015 if (!bd) { /* sanity check */
1107 { /* Begin sanity check */
1108 printk(KERN_ERR "<Error> - Digi : cleanup_module failed\n"); 1016 printk(KERN_ERR "<Error> - Digi : cleanup_module failed\n");
1109 return; 1017 return;
1110 } /* End sanity check */ 1018 }
1111 ch = card_ptr[crd]; 1019 ch = card_ptr[crd];
1112 for (count = 0; count < bd->numports; count++, ch++) 1020 for (count = 0; count < bd->numports; count++, ch++) {
1113 { /* Begin for each port */
1114 if (ch && ch->tty) 1021 if (ch && ch->tty)
1115 tty_hangup(ch->tty); 1022 tty_hangup(ch->tty);
1116 } /* End for each port */ 1023 }
1117 } /* End for each card */ 1024 }
1118 pci_unregister_driver (&epca_driver); 1025 pci_unregister_driver(&epca_driver);
1119} 1026}
1120
1121module_exit(epca_module_exit); 1027module_exit(epca_module_exit);
1122 1028
1123static const struct tty_operations pc_ops = { 1029static const struct tty_operations pc_ops = {
@@ -1148,10 +1054,8 @@ static struct tty_operations info_ops = {
1148 .ioctl = info_ioctl, 1054 .ioctl = info_ioctl,
1149}; 1055};
1150 1056
1151/* ------------------ Begin pc_init ---------------------- */
1152
1153static int __init pc_init(void) 1057static int __init pc_init(void)
1154{ /* Begin pc_init */ 1058{
1155 int crd; 1059 int crd;
1156 struct board_info *bd; 1060 struct board_info *bd;
1157 unsigned char board_id = 0; 1061 unsigned char board_id = 0;
@@ -1169,63 +1073,57 @@ static int __init pc_init(void)
1169 if (!pc_info) 1073 if (!pc_info)
1170 goto out2; 1074 goto out2;
1171 1075
1172 /* ----------------------------------------------------------------------- 1076 /*
1173 If epca_setup has not been ran by LILO set num_cards to defaults; copy 1077 * If epca_setup has not been ran by LILO set num_cards to defaults;
1174 board structure defined by digiConfig into drivers board structure. 1078 * copy board structure defined by digiConfig into drivers board
1175 Note : If LILO has ran epca_setup then epca_setup will handle defining 1079 * structure. Note : If LILO has ran epca_setup then epca_setup will
1176 num_cards as well as copying the data into the board structure. 1080 * handle defining num_cards as well as copying the data into the board
1177 -------------------------------------------------------------------------- */ 1081 * structure.
1178 if (!liloconfig) { /* Begin driver has been configured via. epcaconfig */ 1082 */
1179 1083 if (!liloconfig) {
1084 /* driver has been configured via. epcaconfig */
1180 nbdevs = NBDEVS; 1085 nbdevs = NBDEVS;
1181 num_cards = NUMCARDS; 1086 num_cards = NUMCARDS;
1182 memcpy((void *)&boards, (void *)&static_boards, 1087 memcpy(&boards, &static_boards,
1183 (sizeof(struct board_info) * NUMCARDS)); 1088 sizeof(struct board_info) * NUMCARDS);
1184 } /* End driver has been configured via. epcaconfig */ 1089 }
1185
1186 /* -----------------------------------------------------------------
1187 Note : If lilo was used to configure the driver and the
1188 ignore epcaconfig option was choosen (digiepca=2) then
1189 nbdevs and num_cards will equal 0 at this point. This is
1190 okay; PCI cards will still be picked up if detected.
1191 --------------------------------------------------------------------- */
1192
1193 /* -----------------------------------------------------------
1194 Set up interrupt, we will worry about memory allocation in
1195 post_fep_init.
1196 --------------------------------------------------------------- */
1197 1090
1091 /*
1092 * Note : If lilo was used to configure the driver and the ignore
1093 * epcaconfig option was choosen (digiepca=2) then nbdevs and num_cards
1094 * will equal 0 at this point. This is okay; PCI cards will still be
1095 * picked up if detected.
1096 */
1198 1097
1098 /*
1099 * Set up interrupt, we will worry about memory allocation in
1100 * post_fep_init.
1101 */
1199 printk(KERN_INFO "DIGI epca driver version %s loaded.\n",VERSION); 1102 printk(KERN_INFO "DIGI epca driver version %s loaded.\n",VERSION);
1200 1103
1201 /* ------------------------------------------------------------------ 1104 /*
1202 NOTE : This code assumes that the number of ports found in 1105 * NOTE : This code assumes that the number of ports found in the
1203 the boards array is correct. This could be wrong if 1106 * boards array is correct. This could be wrong if the card in question
1204 the card in question is PCI (And therefore has no ports 1107 * is PCI (And therefore has no ports entry in the boards structure.)
1205 entry in the boards structure.) The rest of the 1108 * The rest of the information will be valid for PCI because the
1206 information will be valid for PCI because the beginning 1109 * beginning of pc_init scans for PCI and determines i/o and base
1207 of pc_init scans for PCI and determines i/o and base 1110 * memory addresses. I am not sure if it is possible to read the number
1208 memory addresses. I am not sure if it is possible to 1111 * of ports supported by the card prior to it being booted (Since that
1209 read the number of ports supported by the card prior to 1112 * is the state it is in when pc_init is run). Because it is not
1210 it being booted (Since that is the state it is in when 1113 * possible to query the number of supported ports until after the card
1211 pc_init is run). Because it is not possible to query the 1114 * has booted; we are required to calculate the card_ptrs as the card
1212 number of supported ports until after the card has booted; 1115 * is initialized (Inside post_fep_init). The negative thing about this
1213 we are required to calculate the card_ptrs as the card is 1116 * approach is that digiDload's call to GET_INFO will have a bad port
1214 is initialized (Inside post_fep_init). The negative thing 1117 * value. (Since this is called prior to post_fep_init.)
1215 about this approach is that digiDload's call to GET_INFO 1118 */
1216 will have a bad port value. (Since this is called prior
1217 to post_fep_init.)
1218
1219 --------------------------------------------------------------------- */
1220
1221 pci_boards_found = 0; 1119 pci_boards_found = 0;
1222 if(num_cards < MAXBOARDS) 1120 if (num_cards < MAXBOARDS)
1223 pci_boards_found += init_PCI(); 1121 pci_boards_found += init_PCI();
1224 num_cards += pci_boards_found; 1122 num_cards += pci_boards_found;
1225 1123
1226 pc_driver->owner = THIS_MODULE; 1124 pc_driver->owner = THIS_MODULE;
1227 pc_driver->name = "ttyD"; 1125 pc_driver->name = "ttyD";
1228 pc_driver->major = DIGI_MAJOR; 1126 pc_driver->major = DIGI_MAJOR;
1229 pc_driver->minor_start = 0; 1127 pc_driver->minor_start = 0;
1230 pc_driver->type = TTY_DRIVER_TYPE_SERIAL; 1128 pc_driver->type = TTY_DRIVER_TYPE_SERIAL;
1231 pc_driver->subtype = SERIAL_TYPE_NORMAL; 1129 pc_driver->subtype = SERIAL_TYPE_NORMAL;
@@ -1256,120 +1154,108 @@ static int __init pc_init(void)
1256 tty_set_operations(pc_info, &info_ops); 1154 tty_set_operations(pc_info, &info_ops);
1257 1155
1258 1156
1259 for (crd = 0; crd < num_cards; crd++) 1157 for (crd = 0; crd < num_cards; crd++) {
1260 { /* Begin for each card */ 1158 /*
1261 1159 * This is where the appropriate memory handlers for the
1262 /* ------------------------------------------------------------------ 1160 * hardware is set. Everything at runtime blindly jumps through
1263 This is where the appropriate memory handlers for the hardware is 1161 * these vectors.
1264 set. Everything at runtime blindly jumps through these vectors. 1162 */
1265 ---------------------------------------------------------------------- */
1266 1163
1267 /* defined in epcaconfig.h */ 1164 /* defined in epcaconfig.h */
1268 bd = &boards[crd]; 1165 bd = &boards[crd];
1269 1166
1270 switch (bd->type) 1167 switch (bd->type) {
1271 { /* Begin switch on bd->type {board type} */ 1168 case PCXEM:
1272 case PCXEM: 1169 case EISAXEM:
1273 case EISAXEM: 1170 bd->memwinon = pcxem_memwinon;
1274 bd->memwinon = pcxem_memwinon ; 1171 bd->memwinoff = pcxem_memwinoff;
1275 bd->memwinoff = pcxem_memwinoff ; 1172 bd->globalwinon = pcxem_globalwinon;
1276 bd->globalwinon = pcxem_globalwinon ; 1173 bd->txwinon = pcxem_txwinon;
1277 bd->txwinon = pcxem_txwinon ; 1174 bd->rxwinon = pcxem_rxwinon;
1278 bd->rxwinon = pcxem_rxwinon ; 1175 bd->memoff = pcxem_memoff;
1279 bd->memoff = pcxem_memoff ; 1176 bd->assertgwinon = dummy_assertgwinon;
1280 bd->assertgwinon = dummy_assertgwinon; 1177 bd->assertmemoff = dummy_assertmemoff;
1281 bd->assertmemoff = dummy_assertmemoff;
1282 break;
1283
1284 case PCIXEM:
1285 case PCIXRJ:
1286 case PCIXR:
1287 bd->memwinon = dummy_memwinon;
1288 bd->memwinoff = dummy_memwinoff;
1289 bd->globalwinon = dummy_globalwinon;
1290 bd->txwinon = dummy_txwinon;
1291 bd->rxwinon = dummy_rxwinon;
1292 bd->memoff = dummy_memoff;
1293 bd->assertgwinon = dummy_assertgwinon;
1294 bd->assertmemoff = dummy_assertmemoff;
1295 break;
1296
1297 case PCXE:
1298 case PCXEVE:
1299
1300 bd->memwinon = pcxe_memwinon;
1301 bd->memwinoff = pcxe_memwinoff;
1302 bd->globalwinon = pcxe_globalwinon;
1303 bd->txwinon = pcxe_txwinon;
1304 bd->rxwinon = pcxe_rxwinon;
1305 bd->memoff = pcxe_memoff;
1306 bd->assertgwinon = dummy_assertgwinon;
1307 bd->assertmemoff = dummy_assertmemoff;
1308 break;
1309
1310 case PCXI:
1311 case PC64XE:
1312
1313 bd->memwinon = pcxi_memwinon;
1314 bd->memwinoff = pcxi_memwinoff;
1315 bd->globalwinon = pcxi_globalwinon;
1316 bd->txwinon = pcxi_txwinon;
1317 bd->rxwinon = pcxi_rxwinon;
1318 bd->memoff = pcxi_memoff;
1319 bd->assertgwinon = pcxi_assertgwinon;
1320 bd->assertmemoff = pcxi_assertmemoff;
1321 break;
1322
1323 default:
1324 break;
1325
1326 } /* End switch on bd->type */
1327
1328 /* ---------------------------------------------------------------
1329 Some cards need a memory segment to be defined for use in
1330 transmit and receive windowing operations. These boards
1331 are listed in the below switch. In the case of the XI the
1332 amount of memory on the board is variable so the memory_seg
1333 is also variable. This code determines what they segment
1334 should be.
1335 ----------------------------------------------------------------- */
1336
1337 switch (bd->type)
1338 { /* Begin switch on bd->type {board type} */
1339
1340 case PCXE:
1341 case PCXEVE:
1342 case PC64XE:
1343 bd->memory_seg = 0xf000;
1344 break; 1178 break;
1345 1179
1346 case PCXI: 1180 case PCIXEM:
1347 board_id = inb((int)bd->port); 1181 case PCIXRJ:
1348 if ((board_id & 0x1) == 0x1) 1182 case PCIXR:
1349 { /* Begin it's an XI card */ 1183 bd->memwinon = dummy_memwinon;
1350 1184 bd->memwinoff = dummy_memwinoff;
1351 /* Is it a 64K board */ 1185 bd->globalwinon = dummy_globalwinon;
1352 if ((board_id & 0x30) == 0) 1186 bd->txwinon = dummy_txwinon;
1353 bd->memory_seg = 0xf000; 1187 bd->rxwinon = dummy_rxwinon;
1354 1188 bd->memoff = dummy_memoff;
1355 /* Is it a 128K board */ 1189 bd->assertgwinon = dummy_assertgwinon;
1356 if ((board_id & 0x30) == 0x10) 1190 bd->assertmemoff = dummy_assertmemoff;
1357 bd->memory_seg = 0xe000; 1191 break;
1358 1192
1359 /* Is is a 256K board */ 1193 case PCXE:
1360 if ((board_id & 0x30) == 0x20) 1194 case PCXEVE:
1361 bd->memory_seg = 0xc000; 1195 bd->memwinon = pcxe_memwinon;
1196 bd->memwinoff = pcxe_memwinoff;
1197 bd->globalwinon = pcxe_globalwinon;
1198 bd->txwinon = pcxe_txwinon;
1199 bd->rxwinon = pcxe_rxwinon;
1200 bd->memoff = pcxe_memoff;
1201 bd->assertgwinon = dummy_assertgwinon;
1202 bd->assertmemoff = dummy_assertmemoff;
1203 break;
1362 1204
1363 /* Is it a 512K board */ 1205 case PCXI:
1364 if ((board_id & 0x30) == 0x30) 1206 case PC64XE:
1365 bd->memory_seg = 0x8000; 1207 bd->memwinon = pcxi_memwinon;
1208 bd->memwinoff = pcxi_memwinoff;
1209 bd->globalwinon = pcxi_globalwinon;
1210 bd->txwinon = pcxi_txwinon;
1211 bd->rxwinon = pcxi_rxwinon;
1212 bd->memoff = pcxi_memoff;
1213 bd->assertgwinon = pcxi_assertgwinon;
1214 bd->assertmemoff = pcxi_assertmemoff;
1215 break;
1366 1216
1367 } else printk(KERN_ERR "epca: Board at 0x%x doesn't appear to be an XI\n",(int)bd->port); 1217 default:
1368 break; 1218 break;
1219 }
1369 1220
1370 } /* End switch on bd->type */ 1221 /*
1222 * Some cards need a memory segment to be defined for use in
1223 * transmit and receive windowing operations. These boards are
1224 * listed in the below switch. In the case of the XI the amount
1225 * of memory on the board is variable so the memory_seg is also
1226 * variable. This code determines what they segment should be.
1227 */
1228 switch (bd->type) {
1229 case PCXE:
1230 case PCXEVE:
1231 case PC64XE:
1232 bd->memory_seg = 0xf000;
1233 break;
1371 1234
1372 } /* End for each card */ 1235 case PCXI:
1236 board_id = inb((int)bd->port);
1237 if ((board_id & 0x1) == 0x1) {
1238 /* it's an XI card */
1239 /* Is it a 64K board */
1240 if ((board_id & 0x30) == 0)
1241 bd->memory_seg = 0xf000;
1242
1243 /* Is it a 128K board */
1244 if ((board_id & 0x30) == 0x10)
1245 bd->memory_seg = 0xe000;
1246
1247 /* Is is a 256K board */
1248 if ((board_id & 0x30) == 0x20)
1249 bd->memory_seg = 0xc000;
1250
1251 /* Is it a 512K board */
1252 if ((board_id & 0x30) == 0x30)
1253 bd->memory_seg = 0x8000;
1254 } else
1255 printk(KERN_ERR "epca: Board at 0x%x doesn't appear to be an XI\n",(int)bd->port);
1256 break;
1257 }
1258 }
1373 1259
1374 err = tty_register_driver(pc_driver); 1260 err = tty_register_driver(pc_driver);
1375 if (err) { 1261 if (err) {
@@ -1383,10 +1269,7 @@ static int __init pc_init(void)
1383 goto out4; 1269 goto out4;
1384 } 1270 }
1385 1271
1386 /* ------------------------------------------------------------------- 1272 /* Start up the poller to check for events on all enabled boards */
1387 Start up the poller to check for events on all enabled boards
1388 ---------------------------------------------------------------------- */
1389
1390 init_timer(&epca_timer); 1273 init_timer(&epca_timer);
1391 epca_timer.function = epcapoll; 1274 epca_timer.function = epcapoll;
1392 mod_timer(&epca_timer, jiffies + HZ/25); 1275 mod_timer(&epca_timer, jiffies + HZ/25);
@@ -1400,51 +1283,47 @@ out2:
1400 put_tty_driver(pc_driver); 1283 put_tty_driver(pc_driver);
1401out1: 1284out1:
1402 return err; 1285 return err;
1403 1286}
1404} /* End pc_init */
1405
1406/* ------------------ Begin post_fep_init ---------------------- */
1407 1287
1408static void post_fep_init(unsigned int crd) 1288static void post_fep_init(unsigned int crd)
1409{ /* Begin post_fep_init */ 1289{
1410
1411 int i; 1290 int i;
1412 void __iomem *memaddr; 1291 void __iomem *memaddr;
1413 struct global_data __iomem *gd; 1292 struct global_data __iomem *gd;
1414 struct board_info *bd; 1293 struct board_info *bd;
1415 struct board_chan __iomem *bc; 1294 struct board_chan __iomem *bc;
1416 struct channel *ch; 1295 struct channel *ch;
1417 int shrinkmem = 0, lowwater ; 1296 int shrinkmem = 0, lowwater;
1418
1419 /* -------------------------------------------------------------
1420 This call is made by the user via. the ioctl call DIGI_INIT.
1421 It is responsible for setting up all the card specific stuff.
1422 ---------------------------------------------------------------- */
1423 bd = &boards[crd];
1424 1297
1425 /* ----------------------------------------------------------------- 1298 /*
1426 If this is a PCI board, get the port info. Remember PCI cards 1299 * This call is made by the user via. the ioctl call DIGI_INIT. It is
1427 do not have entries into the epcaconfig.h file, so we can't get 1300 * responsible for setting up all the card specific stuff.
1428 the number of ports from it. Unfortunetly, this means that anyone 1301 */
1429 doing a DIGI_GETINFO before the board has booted will get an invalid 1302 bd = &boards[crd];
1430 number of ports returned (It should return 0). Calls to DIGI_GETINFO
1431 after DIGI_INIT has been called will return the proper values.
1432 ------------------------------------------------------------------- */
1433 1303
1304 /*
1305 * If this is a PCI board, get the port info. Remember PCI cards do not
1306 * have entries into the epcaconfig.h file, so we can't get the number
1307 * of ports from it. Unfortunetly, this means that anyone doing a
1308 * DIGI_GETINFO before the board has booted will get an invalid number
1309 * of ports returned (It should return 0). Calls to DIGI_GETINFO after
1310 * DIGI_INIT has been called will return the proper values.
1311 */
1434 if (bd->type >= PCIXEM) { /* Begin get PCI number of ports */ 1312 if (bd->type >= PCIXEM) { /* Begin get PCI number of ports */
1435 /* -------------------------------------------------------------------- 1313 /*
1436 Below we use XEMPORTS as a memory offset regardless of which PCI 1314 * Below we use XEMPORTS as a memory offset regardless of which
1437 card it is. This is because all of the supported PCI cards have 1315 * PCI card it is. This is because all of the supported PCI
1438 the same memory offset for the channel data. This will have to be 1316 * cards have the same memory offset for the channel data. This
1439 changed if we ever develop a PCI/XE card. NOTE : The FEP manual 1317 * will have to be changed if we ever develop a PCI/XE card.
1440 states that the port offset is 0xC22 as opposed to 0xC02. This is 1318 * NOTE : The FEP manual states that the port offset is 0xC22
1441 only true for PC/XE, and PC/XI cards; not for the XEM, or CX series. 1319 * as opposed to 0xC02. This is only true for PC/XE, and PC/XI
1442 On the PCI cards the number of ports is determined by reading a 1320 * cards; not for the XEM, or CX series. On the PCI cards the
1443 ID PROM located in the box attached to the card. The card can then 1321 * number of ports is determined by reading a ID PROM located
1444 determine the index the id to determine the number of ports available. 1322 * in the box attached to the card. The card can then determine
1445 (FYI - The id should be located at 0x1ac (And may use up to 4 bytes 1323 * the index the id to determine the number of ports available.
1446 if the box in question is a XEM or CX)). 1324 * (FYI - The id should be located at 0x1ac (And may use up to
1447 ------------------------------------------------------------------------ */ 1325 * 4 bytes if the box in question is a XEM or CX)).
1326 */
1448 /* PCI cards are already remapped at this point ISA are not */ 1327 /* PCI cards are already remapped at this point ISA are not */
1449 bd->numports = readw(bd->re_map_membase + XEMPORTS); 1328 bd->numports = readw(bd->re_map_membase + XEMPORTS);
1450 epcaassert(bd->numports <= 64,"PCI returned a invalid number of ports"); 1329 epcaassert(bd->numports <= 64,"PCI returned a invalid number of ports");
@@ -1465,95 +1344,87 @@ static void post_fep_init(unsigned int crd)
1465 1344
1466 memaddr = bd->re_map_membase; 1345 memaddr = bd->re_map_membase;
1467 1346
1468 /* ----------------------------------------------------------------- 1347 /*
1469 The below assignment will set bc to point at the BEGINING of 1348 * The below assignment will set bc to point at the BEGINING of the
1470 the cards channel structures. For 1 card there will be between 1349 * cards channel structures. For 1 card there will be between 8 and 64
1471 8 and 64 of these structures. 1350 * of these structures.
1472 -------------------------------------------------------------------- */ 1351 */
1473
1474 bc = memaddr + CHANSTRUCT; 1352 bc = memaddr + CHANSTRUCT;
1475 1353
1476 /* ------------------------------------------------------------------- 1354 /*
1477 The below assignment will set gd to point at the BEGINING of 1355 * The below assignment will set gd to point at the BEGINING of global
1478 global memory address 0xc00. The first data in that global 1356 * memory address 0xc00. The first data in that global memory actually
1479 memory actually starts at address 0xc1a. The command in 1357 * starts at address 0xc1a. The command in pointer begins at 0xd10.
1480 pointer begins at 0xd10. 1358 */
1481 ---------------------------------------------------------------------- */
1482
1483 gd = memaddr + GLOBAL; 1359 gd = memaddr + GLOBAL;
1484 1360
1485 /* -------------------------------------------------------------------- 1361 /*
1486 XEPORTS (address 0xc22) points at the number of channels the 1362 * XEPORTS (address 0xc22) points at the number of channels the card
1487 card supports. (For 64XE, XI, XEM, and XR use 0xc02) 1363 * supports. (For 64XE, XI, XEM, and XR use 0xc02)
1488 ----------------------------------------------------------------------- */ 1364 */
1489
1490 if ((bd->type == PCXEVE || bd->type == PCXE) && (readw(memaddr + XEPORTS) < 3)) 1365 if ((bd->type == PCXEVE || bd->type == PCXE) && (readw(memaddr + XEPORTS) < 3))
1491 shrinkmem = 1; 1366 shrinkmem = 1;
1492 if (bd->type < PCIXEM) 1367 if (bd->type < PCIXEM)
1493 if (!request_region((int)bd->port, 4, board_desc[bd->type])) 1368 if (!request_region((int)bd->port, 4, board_desc[bd->type]))
1494 return; 1369 return;
1495 memwinon(bd, 0); 1370 memwinon(bd, 0);
1496 1371
1497 /* -------------------------------------------------------------------- 1372 /*
1498 Remember ch is the main drivers channels structure, while bc is 1373 * Remember ch is the main drivers channels structure, while bc is the
1499 the cards channel structure. 1374 * cards channel structure.
1500 ------------------------------------------------------------------------ */ 1375 */
1501 1376 for (i = 0; i < bd->numports; i++, ch++, bc++) {
1502 /* For every port on the card do ..... */
1503
1504 for (i = 0; i < bd->numports; i++, ch++, bc++) { /* Begin for each port */
1505 unsigned long flags; 1377 unsigned long flags;
1506 u16 tseg, rseg; 1378 u16 tseg, rseg;
1507 1379
1508 ch->brdchan = bc; 1380 ch->brdchan = bc;
1509 ch->mailbox = gd; 1381 ch->mailbox = gd;
1510 INIT_WORK(&ch->tqueue, do_softint); 1382 INIT_WORK(&ch->tqueue, do_softint);
1511 ch->board = &boards[crd]; 1383 ch->board = &boards[crd];
1512 1384
1513 spin_lock_irqsave(&epca_lock, flags); 1385 spin_lock_irqsave(&epca_lock, flags);
1514 switch (bd->type) { 1386 switch (bd->type) {
1515 /* ---------------------------------------------------------------- 1387 /*
1516 Since some of the boards use different bitmaps for their 1388 * Since some of the boards use different bitmaps for
1517 control signals we cannot hard code these values and retain 1389 * their control signals we cannot hard code these
1518 portability. We virtualize this data here. 1390 * values and retain portability. We virtualize this
1519 ------------------------------------------------------------------- */ 1391 * data here.
1520 case EISAXEM: 1392 */
1521 case PCXEM: 1393 case EISAXEM:
1522 case PCIXEM: 1394 case PCXEM:
1523 case PCIXRJ: 1395 case PCIXEM:
1524 case PCIXR: 1396 case PCIXRJ:
1525 ch->m_rts = 0x02 ; 1397 case PCIXR:
1526 ch->m_dcd = 0x80 ; 1398 ch->m_rts = 0x02;
1527 ch->m_dsr = 0x20 ; 1399 ch->m_dcd = 0x80;
1528 ch->m_cts = 0x10 ; 1400 ch->m_dsr = 0x20;
1529 ch->m_ri = 0x40 ; 1401 ch->m_cts = 0x10;
1530 ch->m_dtr = 0x01 ; 1402 ch->m_ri = 0x40;
1531 break; 1403 ch->m_dtr = 0x01;
1532 1404 break;
1533 case PCXE: 1405
1534 case PCXEVE: 1406 case PCXE:
1535 case PCXI: 1407 case PCXEVE:
1536 case PC64XE: 1408 case PCXI:
1537 ch->m_rts = 0x02 ; 1409 case PC64XE:
1538 ch->m_dcd = 0x08 ; 1410 ch->m_rts = 0x02;
1539 ch->m_dsr = 0x10 ; 1411 ch->m_dcd = 0x08;
1540 ch->m_cts = 0x20 ; 1412 ch->m_dsr = 0x10;
1541 ch->m_ri = 0x40 ; 1413 ch->m_cts = 0x20;
1542 ch->m_dtr = 0x80 ; 1414 ch->m_ri = 0x40;
1543 break; 1415 ch->m_dtr = 0x80;
1544 1416 break;
1545 } /* End switch bd->type */ 1417 }
1546 1418
1547 if (boards[crd].altpin) { 1419 if (boards[crd].altpin) {
1548 ch->dsr = ch->m_dcd; 1420 ch->dsr = ch->m_dcd;
1549 ch->dcd = ch->m_dsr; 1421 ch->dcd = ch->m_dsr;
1550 ch->digiext.digi_flags |= DIGI_ALTPIN; 1422 ch->digiext.digi_flags |= DIGI_ALTPIN;
1551 } 1423 } else {
1552 else {
1553 ch->dcd = ch->m_dcd; 1424 ch->dcd = ch->m_dcd;
1554 ch->dsr = ch->m_dsr; 1425 ch->dsr = ch->m_dsr;
1555 } 1426 }
1556 1427
1557 ch->boardnum = crd; 1428 ch->boardnum = crd;
1558 ch->channelnum = i; 1429 ch->channelnum = i;
1559 ch->magic = EPCA_MAGIC; 1430 ch->magic = EPCA_MAGIC;
@@ -1568,71 +1439,67 @@ static void post_fep_init(unsigned int crd)
1568 rseg = readw(&bc->rseg); 1439 rseg = readw(&bc->rseg);
1569 1440
1570 switch (bd->type) { 1441 switch (bd->type) {
1442 case PCIXEM:
1443 case PCIXRJ:
1444 case PCIXR:
1445 /* Cover all the 2MEG cards */
1446 ch->txptr = memaddr + ((tseg << 4) & 0x1fffff);
1447 ch->rxptr = memaddr + ((rseg << 4) & 0x1fffff);
1448 ch->txwin = FEPWIN | (tseg >> 11);
1449 ch->rxwin = FEPWIN | (rseg >> 11);
1450 break;
1571 1451
1572 case PCIXEM: 1452 case PCXEM:
1573 case PCIXRJ: 1453 case EISAXEM:
1574 case PCIXR: 1454 /* Cover all the 32K windowed cards */
1575 /* Cover all the 2MEG cards */ 1455 /* Mask equal to window size - 1 */
1576 ch->txptr = memaddr + ((tseg << 4) & 0x1fffff); 1456 ch->txptr = memaddr + ((tseg << 4) & 0x7fff);
1577 ch->rxptr = memaddr + ((rseg << 4) & 0x1fffff); 1457 ch->rxptr = memaddr + ((rseg << 4) & 0x7fff);
1578 ch->txwin = FEPWIN | (tseg >> 11); 1458 ch->txwin = FEPWIN | (tseg >> 11);
1579 ch->rxwin = FEPWIN | (rseg >> 11); 1459 ch->rxwin = FEPWIN | (rseg >> 11);
1580 break; 1460 break;
1581 1461
1582 case PCXEM: 1462 case PCXEVE:
1583 case EISAXEM: 1463 case PCXE:
1584 /* Cover all the 32K windowed cards */ 1464 ch->txptr = memaddr + (((tseg - bd->memory_seg) << 4) & 0x1fff);
1585 /* Mask equal to window size - 1 */ 1465 ch->txwin = FEPWIN | ((tseg - bd->memory_seg) >> 9);
1586 ch->txptr = memaddr + ((tseg << 4) & 0x7fff); 1466 ch->rxptr = memaddr + (((rseg - bd->memory_seg) << 4) & 0x1fff);
1587 ch->rxptr = memaddr + ((rseg << 4) & 0x7fff); 1467 ch->rxwin = FEPWIN | ((rseg - bd->memory_seg) >>9 );
1588 ch->txwin = FEPWIN | (tseg >> 11); 1468 break;
1589 ch->rxwin = FEPWIN | (rseg >> 11); 1469
1590 break; 1470 case PCXI:
1591 1471 case PC64XE:
1592 case PCXEVE: 1472 ch->txptr = memaddr + ((tseg - bd->memory_seg) << 4);
1593 case PCXE: 1473 ch->rxptr = memaddr + ((rseg - bd->memory_seg) << 4);
1594 ch->txptr = memaddr + (((tseg - bd->memory_seg) << 4) & 0x1fff); 1474 ch->txwin = ch->rxwin = 0;
1595 ch->txwin = FEPWIN | ((tseg - bd->memory_seg) >> 9); 1475 break;
1596 ch->rxptr = memaddr + (((rseg - bd->memory_seg) << 4) & 0x1fff); 1476 }
1597 ch->rxwin = FEPWIN | ((rseg - bd->memory_seg) >>9 );
1598 break;
1599
1600 case PCXI:
1601 case PC64XE:
1602 ch->txptr = memaddr + ((tseg - bd->memory_seg) << 4);
1603 ch->rxptr = memaddr + ((rseg - bd->memory_seg) << 4);
1604 ch->txwin = ch->rxwin = 0;
1605 break;
1606
1607 } /* End switch bd->type */
1608 1477
1609 ch->txbufhead = 0; 1478 ch->txbufhead = 0;
1610 ch->txbufsize = readw(&bc->tmax) + 1; 1479 ch->txbufsize = readw(&bc->tmax) + 1;
1611 1480
1612 ch->rxbufhead = 0; 1481 ch->rxbufhead = 0;
1613 ch->rxbufsize = readw(&bc->rmax) + 1; 1482 ch->rxbufsize = readw(&bc->rmax) + 1;
1614 1483
1615 lowwater = ch->txbufsize >= 2000 ? 1024 : (ch->txbufsize / 2); 1484 lowwater = ch->txbufsize >= 2000 ? 1024 : (ch->txbufsize / 2);
1616 1485
1617 /* Set transmitter low water mark */ 1486 /* Set transmitter low water mark */
1618 fepcmd(ch, STXLWATER, lowwater, 0, 10, 0); 1487 fepcmd(ch, STXLWATER, lowwater, 0, 10, 0);
1619 1488
1620 /* Set receiver low water mark */ 1489 /* Set receiver low water mark */
1621
1622 fepcmd(ch, SRXLWATER, (ch->rxbufsize / 4), 0, 10, 0); 1490 fepcmd(ch, SRXLWATER, (ch->rxbufsize / 4), 0, 10, 0);
1623 1491
1624 /* Set receiver high water mark */ 1492 /* Set receiver high water mark */
1625
1626 fepcmd(ch, SRXHWATER, (3 * ch->rxbufsize / 4), 0, 10, 0); 1493 fepcmd(ch, SRXHWATER, (3 * ch->rxbufsize / 4), 0, 10, 0);
1627 1494
1628 writew(100, &bc->edelay); 1495 writew(100, &bc->edelay);
1629 writeb(1, &bc->idata); 1496 writeb(1, &bc->idata);
1630 1497
1631 ch->startc = readb(&bc->startc); 1498 ch->startc = readb(&bc->startc);
1632 ch->stopc = readb(&bc->stopc); 1499 ch->stopc = readb(&bc->stopc);
1633 ch->startca = readb(&bc->startca); 1500 ch->startca = readb(&bc->startca);
1634 ch->stopca = readb(&bc->stopca); 1501 ch->stopca = readb(&bc->stopca);
1635 1502
1636 ch->fepcflag = 0; 1503 ch->fepcflag = 0;
1637 ch->fepiflag = 0; 1504 ch->fepiflag = 0;
1638 ch->fepoflag = 0; 1505 ch->fepoflag = 0;
@@ -1640,7 +1507,7 @@ static void post_fep_init(unsigned int crd)
1640 ch->fepstopc = 0; 1507 ch->fepstopc = 0;
1641 ch->fepstartca = 0; 1508 ch->fepstartca = 0;
1642 ch->fepstopca = 0; 1509 ch->fepstopca = 0;
1643 1510
1644 ch->close_delay = 50; 1511 ch->close_delay = 50;
1645 ch->count = 0; 1512 ch->count = 0;
1646 ch->blocked_open = 0; 1513 ch->blocked_open = 0;
@@ -1648,80 +1515,66 @@ static void post_fep_init(unsigned int crd)
1648 init_waitqueue_head(&ch->close_wait); 1515 init_waitqueue_head(&ch->close_wait);
1649 1516
1650 spin_unlock_irqrestore(&epca_lock, flags); 1517 spin_unlock_irqrestore(&epca_lock, flags);
1651 } /* End for each port */ 1518 }
1652 1519
1653 printk(KERN_INFO 1520 printk(KERN_INFO
1654 "Digi PC/Xx Driver V%s: %s I/O = 0x%lx Mem = 0x%lx Ports = %d\n", 1521 "Digi PC/Xx Driver V%s: %s I/O = 0x%lx Mem = 0x%lx Ports = %d\n",
1655 VERSION, board_desc[bd->type], (long)bd->port, (long)bd->membase, bd->numports); 1522 VERSION, board_desc[bd->type], (long)bd->port, (long)bd->membase, bd->numports);
1656 memwinoff(bd, 0); 1523 memwinoff(bd, 0);
1657 1524}
1658} /* End post_fep_init */
1659
1660/* --------------------- Begin epcapoll ------------------------ */
1661 1525
1662static void epcapoll(unsigned long ignored) 1526static void epcapoll(unsigned long ignored)
1663{ /* Begin epcapoll */ 1527{
1664
1665 unsigned long flags; 1528 unsigned long flags;
1666 int crd; 1529 int crd;
1667 volatile unsigned int head, tail; 1530 volatile unsigned int head, tail;
1668 struct channel *ch; 1531 struct channel *ch;
1669 struct board_info *bd; 1532 struct board_info *bd;
1670 1533
1671 /* ------------------------------------------------------------------- 1534 /*
1672 This routine is called upon every timer interrupt. Even though 1535 * This routine is called upon every timer interrupt. Even though the
1673 the Digi series cards are capable of generating interrupts this 1536 * Digi series cards are capable of generating interrupts this method
1674 method of non-looping polling is more efficient. This routine 1537 * of non-looping polling is more efficient. This routine checks for
1675 checks for card generated events (Such as receive data, are transmit 1538 * card generated events (Such as receive data, are transmit buffer
1676 buffer empty) and acts on those events. 1539 * empty) and acts on those events.
1677 ----------------------------------------------------------------------- */ 1540 */
1678 1541 for (crd = 0; crd < num_cards; crd++) {
1679 for (crd = 0; crd < num_cards; crd++)
1680 { /* Begin for each card */
1681
1682 bd = &boards[crd]; 1542 bd = &boards[crd];
1683 ch = card_ptr[crd]; 1543 ch = card_ptr[crd];
1684 1544
1685 if ((bd->status == DISABLED) || digi_poller_inhibited) 1545 if ((bd->status == DISABLED) || digi_poller_inhibited)
1686 continue; /* Begin loop next interation */ 1546 continue;
1687
1688 /* -----------------------------------------------------------
1689 assertmemoff is not needed here; indeed it is an empty subroutine.
1690 It is being kept because future boards may need this as well as
1691 some legacy boards.
1692 ---------------------------------------------------------------- */
1693 1547
1548 /*
1549 * assertmemoff is not needed here; indeed it is an empty
1550 * subroutine. It is being kept because future boards may need
1551 * this as well as some legacy boards.
1552 */
1694 spin_lock_irqsave(&epca_lock, flags); 1553 spin_lock_irqsave(&epca_lock, flags);
1695 1554
1696 assertmemoff(ch); 1555 assertmemoff(ch);
1697 1556
1698 globalwinon(ch); 1557 globalwinon(ch);
1699 1558
1700 /* --------------------------------------------------------------- 1559 /*
1701 In this case head and tail actually refer to the event queue not 1560 * In this case head and tail actually refer to the event queue
1702 the transmit or receive queue. 1561 * not the transmit or receive queue.
1703 ------------------------------------------------------------------- */ 1562 */
1704
1705 head = readw(&ch->mailbox->ein); 1563 head = readw(&ch->mailbox->ein);
1706 tail = readw(&ch->mailbox->eout); 1564 tail = readw(&ch->mailbox->eout);
1707
1708 /* If head isn't equal to tail we have an event */
1709 1565
1566 /* If head isn't equal to tail we have an event */
1710 if (head != tail) 1567 if (head != tail)
1711 doevent(crd); 1568 doevent(crd);
1712 memoff(ch); 1569 memoff(ch);
1713 1570
1714 spin_unlock_irqrestore(&epca_lock, flags); 1571 spin_unlock_irqrestore(&epca_lock, flags);
1715
1716 } /* End for each card */ 1572 } /* End for each card */
1717 mod_timer(&epca_timer, jiffies + (HZ / 25)); 1573 mod_timer(&epca_timer, jiffies + (HZ / 25));
1718} /* End epcapoll */ 1574}
1719
1720/* --------------------- Begin doevent ------------------------ */
1721 1575
1722static void doevent(int crd) 1576static void doevent(int crd)
1723{ /* Begin doevent */ 1577{
1724
1725 void __iomem *eventbuf; 1578 void __iomem *eventbuf;
1726 struct channel *ch, *chan0; 1579 struct channel *ch, *chan0;
1727 static struct tty_struct *tty; 1580 static struct tty_struct *tty;
@@ -1731,28 +1584,28 @@ static void doevent(int crd)
1731 int event, channel; 1584 int event, channel;
1732 int mstat, lstat; 1585 int mstat, lstat;
1733 1586
1734 /* ------------------------------------------------------------------- 1587 /*
1735 This subroutine is called by epcapoll when an event is detected 1588 * This subroutine is called by epcapoll when an event is detected
1736 in the event queue. This routine responds to those events. 1589 * in the event queue. This routine responds to those events.
1737 --------------------------------------------------------------------- */ 1590 */
1738 bd = &boards[crd]; 1591 bd = &boards[crd];
1739 1592
1740 chan0 = card_ptr[crd]; 1593 chan0 = card_ptr[crd];
1741 epcaassert(chan0 <= &digi_channels[nbdevs - 1], "ch out of range"); 1594 epcaassert(chan0 <= &digi_channels[nbdevs - 1], "ch out of range");
1742 assertgwinon(chan0); 1595 assertgwinon(chan0);
1743 while ((tail = readw(&chan0->mailbox->eout)) != (head = readw(&chan0->mailbox->ein))) 1596 while ((tail = readw(&chan0->mailbox->eout)) != (head = readw(&chan0->mailbox->ein))) { /* Begin while something in event queue */
1744 { /* Begin while something in event queue */
1745 assertgwinon(chan0); 1597 assertgwinon(chan0);
1746 eventbuf = bd->re_map_membase + tail + ISTART; 1598 eventbuf = bd->re_map_membase + tail + ISTART;
1747 /* Get the channel the event occurred on */ 1599 /* Get the channel the event occurred on */
1748 channel = readb(eventbuf); 1600 channel = readb(eventbuf);
1749 /* Get the actual event code that occurred */ 1601 /* Get the actual event code that occurred */
1750 event = readb(eventbuf + 1); 1602 event = readb(eventbuf + 1);
1751 /* ---------------------------------------------------------------- 1603 /*
1752 The two assignments below get the current modem status (mstat) 1604 * The two assignments below get the current modem status
1753 and the previous modem status (lstat). These are useful becuase 1605 * (mstat) and the previous modem status (lstat). These are
1754 an event could signal a change in modem signals itself. 1606 * useful becuase an event could signal a change in modem
1755 ------------------------------------------------------------------- */ 1607 * signals itself.
1608 */
1756 mstat = readb(eventbuf + 2); 1609 mstat = readb(eventbuf + 2);
1757 lstat = readb(eventbuf + 3); 1610 lstat = readb(eventbuf + 3);
1758 1611
@@ -1772,37 +1625,36 @@ static void doevent(int crd)
1772 assertgwinon(ch); 1625 assertgwinon(ch);
1773 } /* End DATA_IND */ 1626 } /* End DATA_IND */
1774 /* else *//* Fix for DCD transition missed bug */ 1627 /* else *//* Fix for DCD transition missed bug */
1775 if (event & MODEMCHG_IND) { /* Begin MODEMCHG_IND */ 1628 if (event & MODEMCHG_IND) {
1776 /* A modem signal change has been indicated */ 1629 /* A modem signal change has been indicated */
1777 ch->imodem = mstat; 1630 ch->imodem = mstat;
1778 if (ch->asyncflags & ASYNC_CHECK_CD) { 1631 if (ch->asyncflags & ASYNC_CHECK_CD) {
1779 if (mstat & ch->dcd) /* We are now receiving dcd */ 1632 if (mstat & ch->dcd) /* We are now receiving dcd */
1780 wake_up_interruptible(&ch->open_wait); 1633 wake_up_interruptible(&ch->open_wait);
1781 else 1634 else
1782 pc_sched_event(ch, EPCA_EVENT_HANGUP); /* No dcd; hangup */ 1635 pc_sched_event(ch, EPCA_EVENT_HANGUP); /* No dcd; hangup */
1783 } 1636 }
1784 } /* End MODEMCHG_IND */ 1637 }
1785 tty = ch->tty; 1638 tty = ch->tty;
1786 if (tty) { /* Begin if valid tty */ 1639 if (tty) {
1787 if (event & BREAK_IND) { /* Begin if BREAK_IND */ 1640 if (event & BREAK_IND) {
1788 /* A break has been indicated */ 1641 /* A break has been indicated */
1789 tty_insert_flip_char(tty, 0, TTY_BREAK); 1642 tty_insert_flip_char(tty, 0, TTY_BREAK);
1790 tty_schedule_flip(tty); 1643 tty_schedule_flip(tty);
1791 } else if (event & LOWTX_IND) { /* Begin LOWTX_IND */ 1644 } else if (event & LOWTX_IND) {
1792 if (ch->statusflags & LOWWAIT) 1645 if (ch->statusflags & LOWWAIT) {
1793 { /* Begin if LOWWAIT */
1794 ch->statusflags &= ~LOWWAIT; 1646 ch->statusflags &= ~LOWWAIT;
1795 tty_wakeup(tty); 1647 tty_wakeup(tty);
1796 } /* End if LOWWAIT */ 1648 }
1797 } else if (event & EMPTYTX_IND) { /* Begin EMPTYTX_IND */ 1649 } else if (event & EMPTYTX_IND) {
1798 /* This event is generated by setup_empty_event */ 1650 /* This event is generated by setup_empty_event */
1799 ch->statusflags &= ~TXBUSY; 1651 ch->statusflags &= ~TXBUSY;
1800 if (ch->statusflags & EMPTYWAIT) { /* Begin if EMPTYWAIT */ 1652 if (ch->statusflags & EMPTYWAIT) {
1801 ch->statusflags &= ~EMPTYWAIT; 1653 ch->statusflags &= ~EMPTYWAIT;
1802 tty_wakeup(tty); 1654 tty_wakeup(tty);
1803 } /* End if EMPTYWAIT */ 1655 }
1804 } /* End EMPTYTX_IND */ 1656 }
1805 } /* End if valid tty */ 1657 }
1806 next: 1658 next:
1807 globalwinon(ch); 1659 globalwinon(ch);
1808 BUG_ON(!bc); 1660 BUG_ON(!bc);
@@ -1810,13 +1662,11 @@ static void doevent(int crd)
1810 writew((tail + 4) & (IMAX - ISTART - 4), &chan0->mailbox->eout); 1662 writew((tail + 4) & (IMAX - ISTART - 4), &chan0->mailbox->eout);
1811 globalwinon(chan0); 1663 globalwinon(chan0);
1812 } /* End while something in event queue */ 1664 } /* End while something in event queue */
1813} /* End doevent */ 1665}
1814
1815/* --------------------- Begin fepcmd ------------------------ */
1816 1666
1817static void fepcmd(struct channel *ch, int cmd, int word_or_byte, 1667static void fepcmd(struct channel *ch, int cmd, int word_or_byte,
1818 int byte2, int ncmds, int bytecmd) 1668 int byte2, int ncmds, int bytecmd)
1819{ /* Begin fepcmd */ 1669{
1820 unchar __iomem *memaddr; 1670 unchar __iomem *memaddr;
1821 unsigned int head, cmdTail, cmdStart, cmdMax; 1671 unsigned int head, cmdTail, cmdStart, cmdMax;
1822 long count; 1672 long count;
@@ -1831,11 +1681,11 @@ static void fepcmd(struct channel *ch, int cmd, int word_or_byte,
1831 head = readw(&ch->mailbox->cin); 1681 head = readw(&ch->mailbox->cin);
1832 /* cmdStart is a base address */ 1682 /* cmdStart is a base address */
1833 cmdStart = readw(&ch->mailbox->cstart); 1683 cmdStart = readw(&ch->mailbox->cstart);
1834 /* ------------------------------------------------------------------ 1684 /*
1835 We do the addition below because we do not want a max pointer 1685 * We do the addition below because we do not want a max pointer
1836 relative to cmdStart. We want a max pointer that points at the 1686 * relative to cmdStart. We want a max pointer that points at the
1837 physical end of the command queue. 1687 * physical end of the command queue.
1838 -------------------------------------------------------------------- */ 1688 */
1839 cmdMax = (cmdStart + 4 + readw(&ch->mailbox->cmax)); 1689 cmdMax = (cmdStart + 4 + readw(&ch->mailbox->cmax));
1840 memaddr = ch->board->re_map_membase; 1690 memaddr = ch->board->re_map_membase;
1841 1691
@@ -1860,7 +1710,7 @@ static void fepcmd(struct channel *ch, int cmd, int word_or_byte,
1860 writew(head, &ch->mailbox->cin); 1710 writew(head, &ch->mailbox->cin);
1861 count = FEPTIMEOUT; 1711 count = FEPTIMEOUT;
1862 1712
1863 for (;;) { /* Begin forever loop */ 1713 for (;;) {
1864 count--; 1714 count--;
1865 if (count == 0) { 1715 if (count == 0) {
1866 printk(KERN_ERR "<Error> - Fep not responding in fepcmd()\n"); 1716 printk(KERN_ERR "<Error> - Fep not responding in fepcmd()\n");
@@ -1869,26 +1719,23 @@ static void fepcmd(struct channel *ch, int cmd, int word_or_byte,
1869 head = readw(&ch->mailbox->cin); 1719 head = readw(&ch->mailbox->cin);
1870 cmdTail = readw(&ch->mailbox->cout); 1720 cmdTail = readw(&ch->mailbox->cout);
1871 n = (head - cmdTail) & (cmdMax - cmdStart - 4); 1721 n = (head - cmdTail) & (cmdMax - cmdStart - 4);
1872 /* ---------------------------------------------------------- 1722 /*
1873 Basically this will break when the FEP acknowledges the 1723 * Basically this will break when the FEP acknowledges the
1874 command by incrementing cmdTail (Making it equal to head). 1724 * command by incrementing cmdTail (Making it equal to head).
1875 ------------------------------------------------------------- */ 1725 */
1876 if (n <= ncmds * (sizeof(short) * 4)) 1726 if (n <= ncmds * (sizeof(short) * 4))
1877 break; /* Well nearly forever :-) */ 1727 break;
1878 } /* End forever loop */ 1728 }
1879} /* End fepcmd */ 1729}
1880
1881/* ---------------------------------------------------------------------
1882 Digi products use fields in their channels structures that are very
1883 similar to the c_cflag and c_iflag fields typically found in UNIX
1884 termios structures. The below three routines allow mappings
1885 between these hardware "flags" and their respective Linux flags.
1886------------------------------------------------------------------------- */
1887
1888/* --------------------- Begin termios2digi_h -------------------- */
1889 1730
1731/*
1732 * Digi products use fields in their channels structures that are very similar
1733 * to the c_cflag and c_iflag fields typically found in UNIX termios
1734 * structures. The below three routines allow mappings between these hardware
1735 * "flags" and their respective Linux flags.
1736 */
1890static unsigned termios2digi_h(struct channel *ch, unsigned cflag) 1737static unsigned termios2digi_h(struct channel *ch, unsigned cflag)
1891{ /* Begin termios2digi_h */ 1738{
1892 unsigned res = 0; 1739 unsigned res = 0;
1893 1740
1894 if (cflag & CRTSCTS) { 1741 if (cflag & CRTSCTS) {
@@ -1918,86 +1765,73 @@ static unsigned termios2digi_h(struct channel *ch, unsigned cflag)
1918 ch->digiext.digi_flags |= CTSPACE; 1765 ch->digiext.digi_flags |= CTSPACE;
1919 1766
1920 return res; 1767 return res;
1768}
1921 1769
1922} /* End termios2digi_h */
1923
1924/* --------------------- Begin termios2digi_i -------------------- */
1925static unsigned termios2digi_i(struct channel *ch, unsigned iflag) 1770static unsigned termios2digi_i(struct channel *ch, unsigned iflag)
1926{ /* Begin termios2digi_i */ 1771{
1927 1772 unsigned res = iflag & (IGNBRK | BRKINT | IGNPAR | PARMRK |
1928 unsigned res = iflag & (IGNBRK | BRKINT | IGNPAR | PARMRK |
1929 INPCK | ISTRIP|IXON|IXANY|IXOFF); 1773 INPCK | ISTRIP|IXON|IXANY|IXOFF);
1930 if (ch->digiext.digi_flags & DIGI_AIXON) 1774 if (ch->digiext.digi_flags & DIGI_AIXON)
1931 res |= IAIXON; 1775 res |= IAIXON;
1932 return res; 1776 return res;
1933 1777}
1934} /* End termios2digi_i */
1935
1936/* --------------------- Begin termios2digi_c -------------------- */
1937 1778
1938static unsigned termios2digi_c(struct channel *ch, unsigned cflag) 1779static unsigned termios2digi_c(struct channel *ch, unsigned cflag)
1939{ /* Begin termios2digi_c */ 1780{
1940
1941 unsigned res = 0; 1781 unsigned res = 0;
1942 if (cflag & CBAUDEX) { /* Begin detected CBAUDEX */ 1782 if (cflag & CBAUDEX) {
1943 ch->digiext.digi_flags |= DIGI_FAST; 1783 ch->digiext.digi_flags |= DIGI_FAST;
1944 /* ------------------------------------------------------------- 1784 /*
1945 HUPCL bit is used by FEP to indicate fast baud 1785 * HUPCL bit is used by FEP to indicate fast baud table is to
1946 table is to be used. 1786 * be used.
1947 ----------------------------------------------------------------- */ 1787 */
1948 res |= FEP_HUPCL; 1788 res |= FEP_HUPCL;
1949 } /* End detected CBAUDEX */ 1789 } else
1950 else ch->digiext.digi_flags &= ~DIGI_FAST; 1790 ch->digiext.digi_flags &= ~DIGI_FAST;
1951 /* ------------------------------------------------------------------- 1791 /*
1952 CBAUD has bit position 0x1000 set these days to indicate Linux 1792 * CBAUD has bit position 0x1000 set these days to indicate Linux
1953 baud rate remap. Digi hardware can't handle the bit assignment. 1793 * baud rate remap. Digi hardware can't handle the bit assignment.
1954 (We use a different bit assignment for high speed.). Clear this 1794 * (We use a different bit assignment for high speed.). Clear this
1955 bit out. 1795 * bit out.
1956 ---------------------------------------------------------------------- */ 1796 */
1957 res |= cflag & ((CBAUD ^ CBAUDEX) | PARODD | PARENB | CSTOPB | CSIZE); 1797 res |= cflag & ((CBAUD ^ CBAUDEX) | PARODD | PARENB | CSTOPB | CSIZE);
1958 /* ------------------------------------------------------------- 1798 /*
1959 This gets a little confusing. The Digi cards have their own 1799 * This gets a little confusing. The Digi cards have their own
1960 representation of c_cflags controling baud rate. For the most 1800 * representation of c_cflags controling baud rate. For the most part
1961 part this is identical to the Linux implementation. However; 1801 * this is identical to the Linux implementation. However; Digi
1962 Digi supports one rate (76800) that Linux doesn't. This means 1802 * supports one rate (76800) that Linux doesn't. This means that the
1963 that the c_cflag entry that would normally mean 76800 for Digi 1803 * c_cflag entry that would normally mean 76800 for Digi actually means
1964 actually means 115200 under Linux. Without the below mapping, 1804 * 115200 under Linux. Without the below mapping, a stty 115200 would
1965 a stty 115200 would only drive the board at 76800. Since 1805 * only drive the board at 76800. Since the rate 230400 is also found
1966 the rate 230400 is also found after 76800, the same problem afflicts 1806 * after 76800, the same problem afflicts us when we choose a rate of
1967 us when we choose a rate of 230400. Without the below modificiation 1807 * 230400. Without the below modificiation stty 230400 would actually
1968 stty 230400 would actually give us 115200. 1808 * give us 115200.
1969 1809 *
1970 There are two additional differences. The Linux value for CLOCAL 1810 * There are two additional differences. The Linux value for CLOCAL
1971 (0x800; 0004000) has no meaning to the Digi hardware. Also in 1811 * (0x800; 0004000) has no meaning to the Digi hardware. Also in later
1972 later releases of Linux; the CBAUD define has CBAUDEX (0x1000; 1812 * releases of Linux; the CBAUD define has CBAUDEX (0x1000; 0010000)
1973 0010000) ored into it (CBAUD = 0x100f as opposed to 0xf). CBAUDEX 1813 * ored into it (CBAUD = 0x100f as opposed to 0xf). CBAUDEX should be
1974 should be checked for a screened out prior to termios2digi_c 1814 * checked for a screened out prior to termios2digi_c returning. Since
1975 returning. Since CLOCAL isn't used by the board this can be 1815 * CLOCAL isn't used by the board this can be ignored as long as the
1976 ignored as long as the returned value is used only by Digi hardware. 1816 * returned value is used only by Digi hardware.
1977 ----------------------------------------------------------------- */ 1817 */
1978 if (cflag & CBAUDEX) { 1818 if (cflag & CBAUDEX) {
1979 /* ------------------------------------------------------------- 1819 /*
1980 The below code is trying to guarantee that only baud rates 1820 * The below code is trying to guarantee that only baud rates
1981 115200 and 230400 are remapped. We use exclusive or because 1821 * 115200 and 230400 are remapped. We use exclusive or because
1982 the various baud rates share common bit positions and therefore 1822 * the various baud rates share common bit positions and
1983 can't be tested for easily. 1823 * therefore can't be tested for easily.
1984 ----------------------------------------------------------------- */ 1824 */
1985 1825 if ((!((cflag & 0x7) ^ (B115200 & ~CBAUDEX))) ||
1986
1987 if ((!((cflag & 0x7) ^ (B115200 & ~CBAUDEX))) ||
1988 (!((cflag & 0x7) ^ (B230400 & ~CBAUDEX)))) 1826 (!((cflag & 0x7) ^ (B230400 & ~CBAUDEX))))
1989 res += 1; 1827 res += 1;
1990 } 1828 }
1991 return res; 1829 return res;
1992 1830}
1993} /* End termios2digi_c */
1994
1995/* --------------------- Begin epcaparam ----------------------- */
1996 1831
1997/* Caller must hold the locks */ 1832/* Caller must hold the locks */
1998static void epcaparam(struct tty_struct *tty, struct channel *ch) 1833static void epcaparam(struct tty_struct *tty, struct channel *ch)
1999{ /* Begin epcaparam */ 1834{
2000
2001 unsigned int cmdHead; 1835 unsigned int cmdHead;
2002 struct ktermios *ts; 1836 struct ktermios *ts;
2003 struct board_chan __iomem *bc; 1837 struct board_chan __iomem *bc;
@@ -2013,28 +1847,29 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch)
2013 writew(cmdHead, &bc->rout); 1847 writew(cmdHead, &bc->rout);
2014 cmdHead = readw(&bc->tin); 1848 cmdHead = readw(&bc->tin);
2015 /* Changing baud in mid-stream transmission can be wonderful */ 1849 /* Changing baud in mid-stream transmission can be wonderful */
2016 /* --------------------------------------------------------------- 1850 /*
2017 Flush current transmit buffer by setting cmdTail pointer (tout) 1851 * Flush current transmit buffer by setting cmdTail pointer
2018 to cmdHead pointer (tin). Hopefully the transmit buffer is empty. 1852 * (tout) to cmdHead pointer (tin). Hopefully the transmit
2019 ----------------------------------------------------------------- */ 1853 * buffer is empty.
1854 */
2020 fepcmd(ch, STOUT, (unsigned) cmdHead, 0, 0, 0); 1855 fepcmd(ch, STOUT, (unsigned) cmdHead, 0, 0, 0);
2021 mval = 0; 1856 mval = 0;
2022 } else { /* Begin CBAUD not detected */ 1857 } else { /* Begin CBAUD not detected */
2023 /* ------------------------------------------------------------------- 1858 /*
2024 c_cflags have changed but that change had nothing to do with BAUD. 1859 * c_cflags have changed but that change had nothing to do with
2025 Propagate the change to the card. 1860 * BAUD. Propagate the change to the card.
2026 ---------------------------------------------------------------------- */ 1861 */
2027 cflag = termios2digi_c(ch, ts->c_cflag); 1862 cflag = termios2digi_c(ch, ts->c_cflag);
2028 if (cflag != ch->fepcflag) { 1863 if (cflag != ch->fepcflag) {
2029 ch->fepcflag = cflag; 1864 ch->fepcflag = cflag;
2030 /* Set baud rate, char size, stop bits, parity */ 1865 /* Set baud rate, char size, stop bits, parity */
2031 fepcmd(ch, SETCTRLFLAGS, (unsigned) cflag, 0, 0, 0); 1866 fepcmd(ch, SETCTRLFLAGS, (unsigned) cflag, 0, 0, 0);
2032 } 1867 }
2033 /* ---------------------------------------------------------------- 1868 /*
2034 If the user has not forced CLOCAL and if the device is not a 1869 * If the user has not forced CLOCAL and if the device is not a
2035 CALLOUT device (Which is always CLOCAL) we set flags such that 1870 * CALLOUT device (Which is always CLOCAL) we set flags such
2036 the driver will wait on carrier detect. 1871 * that the driver will wait on carrier detect.
2037 ------------------------------------------------------------------- */ 1872 */
2038 if (ts->c_cflag & CLOCAL) 1873 if (ts->c_cflag & CLOCAL)
2039 ch->asyncflags &= ~ASYNC_CHECK_CD; 1874 ch->asyncflags &= ~ASYNC_CHECK_CD;
2040 else 1875 else
@@ -2045,19 +1880,19 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch)
2045 /* Check input mode flags */ 1880 /* Check input mode flags */
2046 if (iflag != ch->fepiflag) { 1881 if (iflag != ch->fepiflag) {
2047 ch->fepiflag = iflag; 1882 ch->fepiflag = iflag;
2048 /* --------------------------------------------------------------- 1883 /*
2049 Command sets channels iflag structure on the board. Such things 1884 * Command sets channels iflag structure on the board. Such
2050 as input soft flow control, handling of parity errors, and 1885 * things as input soft flow control, handling of parity
2051 break handling are all set here. 1886 * errors, and break handling are all set here.
2052 ------------------------------------------------------------------- */ 1887 */
2053 /* break handling, parity handling, input stripping, flow control chars */ 1888 /* break handling, parity handling, input stripping, flow control chars */
2054 fepcmd(ch, SETIFLAGS, (unsigned int) ch->fepiflag, 0, 0, 0); 1889 fepcmd(ch, SETIFLAGS, (unsigned int) ch->fepiflag, 0, 0, 0);
2055 } 1890 }
2056 /* --------------------------------------------------------------- 1891 /*
2057 Set the board mint value for this channel. This will cause hardware 1892 * Set the board mint value for this channel. This will cause hardware
2058 events to be generated each time the DCD signal (Described in mint) 1893 * events to be generated each time the DCD signal (Described in mint)
2059 changes. 1894 * changes.
2060 ------------------------------------------------------------------- */ 1895 */
2061 writeb(ch->dcd, &bc->mint); 1896 writeb(ch->dcd, &bc->mint);
2062 if ((ts->c_cflag & CLOCAL) || (ch->digiext.digi_flags & DIGI_FORCEDCD)) 1897 if ((ts->c_cflag & CLOCAL) || (ch->digiext.digi_flags & DIGI_FORCEDCD))
2063 if (ch->digiext.digi_flags & DIGI_FORCEDCD) 1898 if (ch->digiext.digi_flags & DIGI_FORCEDCD)
@@ -2066,23 +1901,23 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch)
2066 hflow = termios2digi_h(ch, ts->c_cflag); 1901 hflow = termios2digi_h(ch, ts->c_cflag);
2067 if (hflow != ch->hflow) { 1902 if (hflow != ch->hflow) {
2068 ch->hflow = hflow; 1903 ch->hflow = hflow;
2069 /* -------------------------------------------------------------- 1904 /*
2070 Hard flow control has been selected but the board is not 1905 * Hard flow control has been selected but the board is not
2071 using it. Activate hard flow control now. 1906 * using it. Activate hard flow control now.
2072 ----------------------------------------------------------------- */ 1907 */
2073 fepcmd(ch, SETHFLOW, hflow, 0xff, 0, 1); 1908 fepcmd(ch, SETHFLOW, hflow, 0xff, 0, 1);
2074 } 1909 }
2075 mval ^= ch->modemfake & (mval ^ ch->modem); 1910 mval ^= ch->modemfake & (mval ^ ch->modem);
2076 1911
2077 if (ch->omodem ^ mval) { 1912 if (ch->omodem ^ mval) {
2078 ch->omodem = mval; 1913 ch->omodem = mval;
2079 /* -------------------------------------------------------------- 1914 /*
2080 The below command sets the DTR and RTS mstat structure. If 1915 * The below command sets the DTR and RTS mstat structure. If
2081 hard flow control is NOT active these changes will drive the 1916 * hard flow control is NOT active these changes will drive the
2082 output of the actual DTR and RTS lines. If hard flow control 1917 * output of the actual DTR and RTS lines. If hard flow control
2083 is active, the changes will be saved in the mstat structure and 1918 * is active, the changes will be saved in the mstat structure
2084 only asserted when hard flow control is turned off. 1919 * and only asserted when hard flow control is turned off.
2085 ----------------------------------------------------------------- */ 1920 */
2086 1921
2087 /* First reset DTR & RTS; then set them */ 1922 /* First reset DTR & RTS; then set them */
2088 fepcmd(ch, SETMODEM, 0, ((ch->m_dtr)|(ch->m_rts)), 0, 1); 1923 fepcmd(ch, SETMODEM, 0, ((ch->m_dtr)|(ch->m_rts)), 0, 1);
@@ -2091,28 +1926,26 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch)
2091 if (ch->startc != ch->fepstartc || ch->stopc != ch->fepstopc) { 1926 if (ch->startc != ch->fepstartc || ch->stopc != ch->fepstopc) {
2092 ch->fepstartc = ch->startc; 1927 ch->fepstartc = ch->startc;
2093 ch->fepstopc = ch->stopc; 1928 ch->fepstopc = ch->stopc;
2094 /* ------------------------------------------------------------ 1929 /*
2095 The XON / XOFF characters have changed; propagate these 1930 * The XON / XOFF characters have changed; propagate these
2096 changes to the card. 1931 * changes to the card.
2097 --------------------------------------------------------------- */ 1932 */
2098 fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1); 1933 fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1);
2099 } 1934 }
2100 if (ch->startca != ch->fepstartca || ch->stopca != ch->fepstopca) { 1935 if (ch->startca != ch->fepstartca || ch->stopca != ch->fepstopca) {
2101 ch->fepstartca = ch->startca; 1936 ch->fepstartca = ch->startca;
2102 ch->fepstopca = ch->stopca; 1937 ch->fepstopca = ch->stopca;
2103 /* --------------------------------------------------------------- 1938 /*
2104 Similar to the above, this time the auxilarly XON / XOFF 1939 * Similar to the above, this time the auxilarly XON / XOFF
2105 characters have changed; propagate these changes to the card. 1940 * characters have changed; propagate these changes to the card.
2106 ------------------------------------------------------------------ */ 1941 */
2107 fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1); 1942 fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1);
2108 } 1943 }
2109} /* End epcaparam */ 1944}
2110 1945
2111/* --------------------- Begin receive_data ----------------------- */
2112/* Caller holds lock */ 1946/* Caller holds lock */
2113static void receive_data(struct channel *ch) 1947static void receive_data(struct channel *ch)
2114{ /* Begin receive_data */ 1948{
2115
2116 unchar *rptr; 1949 unchar *rptr;
2117 struct ktermios *ts = NULL; 1950 struct ktermios *ts = NULL;
2118 struct tty_struct *tty; 1951 struct tty_struct *tty;
@@ -2121,11 +1954,10 @@ static void receive_data(struct channel *ch)
2121 unsigned int tail, head; 1954 unsigned int tail, head;
2122 unsigned int wrapmask; 1955 unsigned int wrapmask;
2123 1956
2124 /* --------------------------------------------------------------- 1957 /*
2125 This routine is called by doint when a receive data event 1958 * This routine is called by doint when a receive data event has taken
2126 has taken place. 1959 * place.
2127 ------------------------------------------------------------------- */ 1960 */
2128
2129 globalwinon(ch); 1961 globalwinon(ch);
2130 if (ch->statusflags & RXSTOPPED) 1962 if (ch->statusflags & RXSTOPPED)
2131 return; 1963 return;
@@ -2136,10 +1968,10 @@ static void receive_data(struct channel *ch)
2136 BUG_ON(!bc); 1968 BUG_ON(!bc);
2137 wrapmask = ch->rxbufsize - 1; 1969 wrapmask = ch->rxbufsize - 1;
2138 1970
2139 /* --------------------------------------------------------------------- 1971 /*
2140 Get the head and tail pointers to the receiver queue. Wrap the 1972 * Get the head and tail pointers to the receiver queue. Wrap the head
2141 head pointer if it has reached the end of the buffer. 1973 * pointer if it has reached the end of the buffer.
2142 ------------------------------------------------------------------------ */ 1974 */
2143 head = readw(&bc->rin); 1975 head = readw(&bc->rin);
2144 head &= wrapmask; 1976 head &= wrapmask;
2145 tail = readw(&bc->rout) & wrapmask; 1977 tail = readw(&bc->rout) & wrapmask;
@@ -2148,10 +1980,7 @@ static void receive_data(struct channel *ch)
2148 if (bytesAvailable == 0) 1980 if (bytesAvailable == 0)
2149 return; 1981 return;
2150 1982
2151 /* ------------------------------------------------------------------ 1983 /* If CREAD bit is off or device not open, set TX tail to head */
2152 If CREAD bit is off or device not open, set TX tail to head
2153 --------------------------------------------------------------------- */
2154
2155 if (!tty || !ts || !(ts->c_cflag & CREAD)) { 1984 if (!tty || !ts || !(ts->c_cflag & CREAD)) {
2156 writew(head, &bc->rout); 1985 writew(head, &bc->rout);
2157 return; 1986 return;
@@ -2168,22 +1997,20 @@ static void receive_data(struct channel *ch)
2168 rxwinon(ch); 1997 rxwinon(ch);
2169 while (bytesAvailable > 0) { /* Begin while there is data on the card */ 1998 while (bytesAvailable > 0) { /* Begin while there is data on the card */
2170 wrapgap = (head >= tail) ? head - tail : ch->rxbufsize - tail; 1999 wrapgap = (head >= tail) ? head - tail : ch->rxbufsize - tail;
2171 /* --------------------------------------------------------------- 2000 /*
2172 Even if head has wrapped around only report the amount of 2001 * Even if head has wrapped around only report the amount of
2173 data to be equal to the size - tail. Remember memcpy can't 2002 * data to be equal to the size - tail. Remember memcpy can't
2174 automaticly wrap around the receive buffer. 2003 * automaticly wrap around the receive buffer.
2175 ----------------------------------------------------------------- */ 2004 */
2176 dataToRead = (wrapgap < bytesAvailable) ? wrapgap : bytesAvailable; 2005 dataToRead = (wrapgap < bytesAvailable) ? wrapgap : bytesAvailable;
2177 /* -------------------------------------------------------------- 2006 /* Make sure we don't overflow the buffer */
2178 Make sure we don't overflow the buffer
2179 ----------------------------------------------------------------- */
2180 dataToRead = tty_prepare_flip_string(tty, &rptr, dataToRead); 2007 dataToRead = tty_prepare_flip_string(tty, &rptr, dataToRead);
2181 if (dataToRead == 0) 2008 if (dataToRead == 0)
2182 break; 2009 break;
2183 /* --------------------------------------------------------------- 2010 /*
2184 Move data read from our card into the line disciplines buffer 2011 * Move data read from our card into the line disciplines
2185 for translation if necessary. 2012 * buffer for translation if necessary.
2186 ------------------------------------------------------------------ */ 2013 */
2187 memcpy_fromio(rptr, ch->rxptr + tail, dataToRead); 2014 memcpy_fromio(rptr, ch->rxptr + tail, dataToRead);
2188 tail = (tail + dataToRead) & wrapmask; 2015 tail = (tail + dataToRead) & wrapmask;
2189 bytesAvailable -= dataToRead; 2016 bytesAvailable -= dataToRead;
@@ -2191,28 +2018,26 @@ static void receive_data(struct channel *ch)
2191 globalwinon(ch); 2018 globalwinon(ch);
2192 writew(tail, &bc->rout); 2019 writew(tail, &bc->rout);
2193 /* Must be called with global data */ 2020 /* Must be called with global data */
2194 tty_schedule_flip(ch->tty); 2021 tty_schedule_flip(ch->tty);
2195 return; 2022}
2196} /* End receive_data */
2197 2023
2198static int info_ioctl(struct tty_struct *tty, struct file * file, 2024static int info_ioctl(struct tty_struct *tty, struct file *file,
2199 unsigned int cmd, unsigned long arg) 2025 unsigned int cmd, unsigned long arg)
2200{ 2026{
2201 switch (cmd) 2027 switch (cmd) {
2202 { /* Begin switch cmd */ 2028 case DIGI_GETINFO:
2203 case DIGI_GETINFO: 2029 {
2204 { /* Begin case DIGI_GETINFO */ 2030 struct digi_info di;
2205 struct digi_info di ;
2206 int brd; 2031 int brd;
2207 2032
2208 if(get_user(brd, (unsigned int __user *)arg)) 2033 if (get_user(brd, (unsigned int __user *)arg))
2209 return -EFAULT; 2034 return -EFAULT;
2210 if (brd < 0 || brd >= num_cards || num_cards == 0) 2035 if (brd < 0 || brd >= num_cards || num_cards == 0)
2211 return -ENODEV; 2036 return -ENODEV;
2212 2037
2213 memset(&di, 0, sizeof(di)); 2038 memset(&di, 0, sizeof(di));
2214 2039
2215 di.board = brd ; 2040 di.board = brd;
2216 di.status = boards[brd].status; 2041 di.status = boards[brd].status;
2217 di.type = boards[brd].type ; 2042 di.type = boards[brd].type ;
2218 di.numports = boards[brd].numports ; 2043 di.numports = boards[brd].numports ;
@@ -2220,45 +2045,44 @@ static int info_ioctl(struct tty_struct *tty, struct file * file,
2220 di.port = (unsigned char *)boards[brd].port ; 2045 di.port = (unsigned char *)boards[brd].port ;
2221 di.membase = (unsigned char *)boards[brd].membase ; 2046 di.membase = (unsigned char *)boards[brd].membase ;
2222 2047
2223 if (copy_to_user((void __user *)arg, &di, sizeof (di))) 2048 if (copy_to_user((void __user *)arg, &di, sizeof(di)))
2224 return -EFAULT; 2049 return -EFAULT;
2225 break; 2050 break;
2226 2051
2227 } /* End case DIGI_GETINFO */ 2052 }
2228
2229 case DIGI_POLLER:
2230 { /* Begin case DIGI_POLLER */
2231 2053
2232 int brd = arg & 0xff000000 >> 16 ; 2054 case DIGI_POLLER:
2233 unsigned char state = arg & 0xff ; 2055 {
2056 int brd = arg & 0xff000000 >> 16;
2057 unsigned char state = arg & 0xff;
2234 2058
2235 if (brd < 0 || brd >= num_cards) { 2059 if (brd < 0 || brd >= num_cards) {
2236 printk(KERN_ERR "epca: DIGI POLLER : brd not valid!\n"); 2060 printk(KERN_ERR "epca: DIGI POLLER : brd not valid!\n");
2237 return (-ENODEV); 2061 return -ENODEV;
2238 } 2062 }
2239 digi_poller_inhibited = state ; 2063 digi_poller_inhibited = state;
2240 break ; 2064 break;
2241 } /* End case DIGI_POLLER */ 2065 }
2242 2066
2243 case DIGI_INIT: 2067 case DIGI_INIT:
2244 { /* Begin case DIGI_INIT */ 2068 {
2245 /* ------------------------------------------------------------ 2069 /*
2246 This call is made by the apps to complete the initilization 2070 * This call is made by the apps to complete the
2247 of the board(s). This routine is responsible for setting 2071 * initilization of the board(s). This routine is
2248 the card to its initial state and setting the drivers control 2072 * responsible for setting the card to its initial
2249 fields to the sutianle settings for the card in question. 2073 * state and setting the drivers control fields to the
2250 ---------------------------------------------------------------- */ 2074 * sutianle settings for the card in question.
2251 int crd ; 2075 */
2252 for (crd = 0; crd < num_cards; crd++) 2076 int crd;
2253 post_fep_init (crd); 2077 for (crd = 0; crd < num_cards; crd++)
2254 break ; 2078 post_fep_init(crd);
2255 } /* End case DIGI_INIT */ 2079 break;
2256 default: 2080 }
2257 return -ENOTTY; 2081 default:
2258 } /* End switch cmd */ 2082 return -ENOTTY;
2259 return (0) ; 2083 }
2084 return 0;
2260} 2085}
2261/* --------------------- Begin pc_ioctl ----------------------- */
2262 2086
2263static int pc_tiocmget(struct tty_struct *tty, struct file *file) 2087static int pc_tiocmget(struct tty_struct *tty, struct file *file)
2264{ 2088{
@@ -2304,9 +2128,9 @@ static int pc_tiocmset(struct tty_struct *tty, struct file *file,
2304 2128
2305 spin_lock_irqsave(&epca_lock, flags); 2129 spin_lock_irqsave(&epca_lock, flags);
2306 /* 2130 /*
2307 * I think this modemfake stuff is broken. It doesn't 2131 * I think this modemfake stuff is broken. It doesn't correctly reflect
2308 * correctly reflect the behaviour desired by the TIOCM* 2132 * the behaviour desired by the TIOCM* ioctls. Therefore this is
2309 * ioctls. Therefore this is probably broken. 2133 * probably broken.
2310 */ 2134 */
2311 if (set & TIOCM_RTS) { 2135 if (set & TIOCM_RTS) {
2312 ch->modemfake |= ch->m_rts; 2136 ch->modemfake |= ch->m_rts;
@@ -2325,10 +2149,10 @@ static int pc_tiocmset(struct tty_struct *tty, struct file *file,
2325 ch->modem &= ~ch->m_dtr; 2149 ch->modem &= ~ch->m_dtr;
2326 } 2150 }
2327 globalwinon(ch); 2151 globalwinon(ch);
2328 /* -------------------------------------------------------------- 2152 /*
2329 The below routine generally sets up parity, baud, flow control 2153 * The below routine generally sets up parity, baud, flow control
2330 issues, etc.... It effect both control flags and input flags. 2154 * issues, etc.... It effect both control flags and input flags.
2331 ------------------------------------------------------------------ */ 2155 */
2332 epcaparam(tty,ch); 2156 epcaparam(tty,ch);
2333 memoff(ch); 2157 memoff(ch);
2334 spin_unlock_irqrestore(&epca_lock, flags); 2158 spin_unlock_irqrestore(&epca_lock, flags);
@@ -2337,8 +2161,7 @@ static int pc_tiocmset(struct tty_struct *tty, struct file *file,
2337 2161
2338static int pc_ioctl(struct tty_struct *tty, struct file * file, 2162static int pc_ioctl(struct tty_struct *tty, struct file * file,
2339 unsigned int cmd, unsigned long arg) 2163 unsigned int cmd, unsigned long arg)
2340{ /* Begin pc_ioctl */ 2164{
2341
2342 digiflow_t dflow; 2165 digiflow_t dflow;
2343 int retval; 2166 int retval;
2344 unsigned long flags; 2167 unsigned long flags;
@@ -2347,49 +2170,47 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
2347 struct board_chan __iomem *bc; 2170 struct board_chan __iomem *bc;
2348 struct channel *ch = (struct channel *) tty->driver_data; 2171 struct channel *ch = (struct channel *) tty->driver_data;
2349 void __user *argp = (void __user *)arg; 2172 void __user *argp = (void __user *)arg;
2350 2173
2351 if (ch) 2174 if (ch)
2352 bc = ch->brdchan; 2175 bc = ch->brdchan;
2353 else 2176 else
2354 return -EINVAL; 2177 return -EINVAL;
2355 2178
2356 /* ------------------------------------------------------------------- 2179 /*
2357 For POSIX compliance we need to add more ioctls. See tty_ioctl.c 2180 * For POSIX compliance we need to add more ioctls. See tty_ioctl.c in
2358 in /usr/src/linux/drivers/char for a good example. In particular 2181 * /usr/src/linux/drivers/char for a good example. In particular think
2359 think about adding TCSETAF, TCSETAW, TCSETA, TCSETSF, TCSETSW, TCSETS. 2182 * about adding TCSETAF, TCSETAW, TCSETA, TCSETSF, TCSETSW, TCSETS.
2360 ---------------------------------------------------------------------- */ 2183 */
2361 2184 switch (cmd) {
2362 switch (cmd) 2185 case TCSBRK: /* SVID version: non-zero arg --> no break */
2363 { /* Begin switch cmd */ 2186 retval = tty_check_change(tty);
2364 case TCSBRK: /* SVID version: non-zero arg --> no break */ 2187 if (retval)
2365 retval = tty_check_change(tty); 2188 return retval;
2366 if (retval) 2189 /* Setup an event to indicate when the transmit buffer empties */
2367 return retval; 2190 spin_lock_irqsave(&epca_lock, flags);
2368 /* Setup an event to indicate when the transmit buffer empties */ 2191 setup_empty_event(tty,ch);
2369 spin_lock_irqsave(&epca_lock, flags); 2192 spin_unlock_irqrestore(&epca_lock, flags);
2370 setup_empty_event(tty,ch); 2193 tty_wait_until_sent(tty, 0);
2371 spin_unlock_irqrestore(&epca_lock, flags); 2194 if (!arg)
2372 tty_wait_until_sent(tty, 0); 2195 digi_send_break(ch, HZ / 4); /* 1/4 second */
2373 if (!arg) 2196 return 0;
2374 digi_send_break(ch, HZ/4); /* 1/4 second */ 2197 case TCSBRKP: /* support for POSIX tcsendbreak() */
2375 return 0; 2198 retval = tty_check_change(tty);
2376 case TCSBRKP: /* support for POSIX tcsendbreak() */ 2199 if (retval)
2377 retval = tty_check_change(tty); 2200 return retval;
2378 if (retval)
2379 return retval;
2380 2201
2381 /* Setup an event to indicate when the transmit buffer empties */ 2202 /* Setup an event to indicate when the transmit buffer empties */
2382 spin_lock_irqsave(&epca_lock, flags); 2203 spin_lock_irqsave(&epca_lock, flags);
2383 setup_empty_event(tty,ch); 2204 setup_empty_event(tty,ch);
2384 spin_unlock_irqrestore(&epca_lock, flags); 2205 spin_unlock_irqrestore(&epca_lock, flags);
2385 tty_wait_until_sent(tty, 0); 2206 tty_wait_until_sent(tty, 0);
2386 digi_send_break(ch, arg ? arg*(HZ/10) : HZ/4); 2207 digi_send_break(ch, arg ? arg*(HZ/10) : HZ/4);
2387 return 0; 2208 return 0;
2388 case TIOCGSOFTCAR: 2209 case TIOCGSOFTCAR:
2389 if (put_user(C_CLOCAL(tty)?1:0, (unsigned long __user *)arg)) 2210 if (put_user(C_CLOCAL(tty)?1:0, (unsigned long __user *)arg))
2390 return -EFAULT; 2211 return -EFAULT;
2391 return 0; 2212 return 0;
2392 case TIOCSSOFTCAR: 2213 case TIOCSSOFTCAR:
2393 { 2214 {
2394 unsigned int value; 2215 unsigned int value;
2395 2216
@@ -2400,144 +2221,141 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
2400 (value ? CLOCAL : 0)); 2221 (value ? CLOCAL : 0));
2401 return 0; 2222 return 0;
2402 } 2223 }
2403 case TIOCMODG: 2224 case TIOCMODG:
2404 mflag = pc_tiocmget(tty, file); 2225 mflag = pc_tiocmget(tty, file);
2405 if (put_user(mflag, (unsigned long __user *)argp)) 2226 if (put_user(mflag, (unsigned long __user *)argp))
2406 return -EFAULT; 2227 return -EFAULT;
2407 break; 2228 break;
2408 case TIOCMODS: 2229 case TIOCMODS:
2409 if (get_user(mstat, (unsigned __user *)argp)) 2230 if (get_user(mstat, (unsigned __user *)argp))
2410 return -EFAULT; 2231 return -EFAULT;
2411 return pc_tiocmset(tty, file, mstat, ~mstat); 2232 return pc_tiocmset(tty, file, mstat, ~mstat);
2412 case TIOCSDTR: 2233 case TIOCSDTR:
2413 spin_lock_irqsave(&epca_lock, flags); 2234 spin_lock_irqsave(&epca_lock, flags);
2414 ch->omodem |= ch->m_dtr; 2235 ch->omodem |= ch->m_dtr;
2415 globalwinon(ch); 2236 globalwinon(ch);
2416 fepcmd(ch, SETMODEM, ch->m_dtr, 0, 10, 1); 2237 fepcmd(ch, SETMODEM, ch->m_dtr, 0, 10, 1);
2417 memoff(ch); 2238 memoff(ch);
2418 spin_unlock_irqrestore(&epca_lock, flags); 2239 spin_unlock_irqrestore(&epca_lock, flags);
2419 break; 2240 break;
2420 2241
2421 case TIOCCDTR: 2242 case TIOCCDTR:
2243 spin_lock_irqsave(&epca_lock, flags);
2244 ch->omodem &= ~ch->m_dtr;
2245 globalwinon(ch);
2246 fepcmd(ch, SETMODEM, 0, ch->m_dtr, 10, 1);
2247 memoff(ch);
2248 spin_unlock_irqrestore(&epca_lock, flags);
2249 break;
2250 case DIGI_GETA:
2251 if (copy_to_user(argp, &ch->digiext, sizeof(digi_t)))
2252 return -EFAULT;
2253 break;
2254 case DIGI_SETAW:
2255 case DIGI_SETAF:
2256 if (cmd == DIGI_SETAW) {
2257 /* Setup an event to indicate when the transmit buffer empties */
2422 spin_lock_irqsave(&epca_lock, flags); 2258 spin_lock_irqsave(&epca_lock, flags);
2423 ch->omodem &= ~ch->m_dtr; 2259 setup_empty_event(tty,ch);
2424 globalwinon(ch);
2425 fepcmd(ch, SETMODEM, 0, ch->m_dtr, 10, 1);
2426 memoff(ch);
2427 spin_unlock_irqrestore(&epca_lock, flags); 2260 spin_unlock_irqrestore(&epca_lock, flags);
2428 break; 2261 tty_wait_until_sent(tty, 0);
2429 case DIGI_GETA: 2262 } else {
2430 if (copy_to_user(argp, &ch->digiext, sizeof(digi_t))) 2263 /* ldisc lock already held in ioctl */
2431 return -EFAULT; 2264 if (tty->ldisc.flush_buffer)
2432 break; 2265 tty->ldisc.flush_buffer(tty);
2433 case DIGI_SETAW: 2266 }
2434 case DIGI_SETAF: 2267 /* Fall Thru */
2435 if (cmd == DIGI_SETAW) { 2268 case DIGI_SETA:
2436 /* Setup an event to indicate when the transmit buffer empties */ 2269 if (copy_from_user(&ch->digiext, argp, sizeof(digi_t)))
2437 spin_lock_irqsave(&epca_lock, flags); 2270 return -EFAULT;
2438 setup_empty_event(tty,ch); 2271
2439 spin_unlock_irqrestore(&epca_lock, flags); 2272 if (ch->digiext.digi_flags & DIGI_ALTPIN) {
2440 tty_wait_until_sent(tty, 0); 2273 ch->dcd = ch->m_dsr;
2441 } else { 2274 ch->dsr = ch->m_dcd;
2442 /* ldisc lock already held in ioctl */ 2275 } else {
2443 if (tty->ldisc.flush_buffer) 2276 ch->dcd = ch->m_dcd;
2444 tty->ldisc.flush_buffer(tty); 2277 ch->dsr = ch->m_dsr;
2445 }
2446 /* Fall Thru */
2447 case DIGI_SETA:
2448 if (copy_from_user(&ch->digiext, argp, sizeof(digi_t)))
2449 return -EFAULT;
2450
2451 if (ch->digiext.digi_flags & DIGI_ALTPIN) {
2452 ch->dcd = ch->m_dsr;
2453 ch->dsr = ch->m_dcd;
2454 } else {
2455 ch->dcd = ch->m_dcd;
2456 ch->dsr = ch->m_dsr;
2457 } 2278 }
2458
2459 spin_lock_irqsave(&epca_lock, flags);
2460 globalwinon(ch);
2461 2279
2462 /* ----------------------------------------------------------------- 2280 spin_lock_irqsave(&epca_lock, flags);
2463 The below routine generally sets up parity, baud, flow control 2281 globalwinon(ch);
2464 issues, etc.... It effect both control flags and input flags.
2465 ------------------------------------------------------------------- */
2466 2282
2467 epcaparam(tty,ch); 2283 /*
2468 memoff(ch); 2284 * The below routine generally sets up parity, baud, flow
2469 spin_unlock_irqrestore(&epca_lock, flags); 2285 * control issues, etc.... It effect both control flags and
2470 break; 2286 * input flags.
2287 */
2288 epcaparam(tty,ch);
2289 memoff(ch);
2290 spin_unlock_irqrestore(&epca_lock, flags);
2291 break;
2292
2293 case DIGI_GETFLOW:
2294 case DIGI_GETAFLOW:
2295 spin_lock_irqsave(&epca_lock, flags);
2296 globalwinon(ch);
2297 if (cmd == DIGI_GETFLOW) {
2298 dflow.startc = readb(&bc->startc);
2299 dflow.stopc = readb(&bc->stopc);
2300 } else {
2301 dflow.startc = readb(&bc->startca);
2302 dflow.stopc = readb(&bc->stopca);
2303 }
2304 memoff(ch);
2305 spin_unlock_irqrestore(&epca_lock, flags);
2306
2307 if (copy_to_user(argp, &dflow, sizeof(dflow)))
2308 return -EFAULT;
2309 break;
2310
2311 case DIGI_SETAFLOW:
2312 case DIGI_SETFLOW:
2313 if (cmd == DIGI_SETFLOW) {
2314 startc = ch->startc;
2315 stopc = ch->stopc;
2316 } else {
2317 startc = ch->startca;
2318 stopc = ch->stopca;
2319 }
2320
2321 if (copy_from_user(&dflow, argp, sizeof(dflow)))
2322 return -EFAULT;
2471 2323
2472 case DIGI_GETFLOW: 2324 if (dflow.startc != startc || dflow.stopc != stopc) { /* Begin if setflow toggled */
2473 case DIGI_GETAFLOW:
2474 spin_lock_irqsave(&epca_lock, flags); 2325 spin_lock_irqsave(&epca_lock, flags);
2475 globalwinon(ch); 2326 globalwinon(ch);
2476 if (cmd == DIGI_GETFLOW) {
2477 dflow.startc = readb(&bc->startc);
2478 dflow.stopc = readb(&bc->stopc);
2479 } else {
2480 dflow.startc = readb(&bc->startca);
2481 dflow.stopc = readb(&bc->stopca);
2482 }
2483 memoff(ch);
2484 spin_unlock_irqrestore(&epca_lock, flags);
2485 2327
2486 if (copy_to_user(argp, &dflow, sizeof(dflow)))
2487 return -EFAULT;
2488 break;
2489
2490 case DIGI_SETAFLOW:
2491 case DIGI_SETFLOW:
2492 if (cmd == DIGI_SETFLOW) { 2328 if (cmd == DIGI_SETFLOW) {
2493 startc = ch->startc; 2329 ch->fepstartc = ch->startc = dflow.startc;
2494 stopc = ch->stopc; 2330 ch->fepstopc = ch->stopc = dflow.stopc;
2331 fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1);
2495 } else { 2332 } else {
2496 startc = ch->startca; 2333 ch->fepstartca = ch->startca = dflow.startc;
2497 stopc = ch->stopca; 2334 ch->fepstopca = ch->stopca = dflow.stopc;
2335 fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1);
2498 } 2336 }
2499 2337
2500 if (copy_from_user(&dflow, argp, sizeof(dflow))) 2338 if (ch->statusflags & TXSTOPPED)
2501 return -EFAULT; 2339 pc_start(tty);
2502 2340
2503 if (dflow.startc != startc || dflow.stopc != stopc) { /* Begin if setflow toggled */ 2341 memoff(ch);
2504 spin_lock_irqsave(&epca_lock, flags); 2342 spin_unlock_irqrestore(&epca_lock, flags);
2505 globalwinon(ch); 2343 } /* End if setflow toggled */
2506 2344 break;
2507 if (cmd == DIGI_SETFLOW) { 2345 default:
2508 ch->fepstartc = ch->startc = dflow.startc; 2346 return -ENOIOCTLCMD;
2509 ch->fepstopc = ch->stopc = dflow.stopc; 2347 }
2510 fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1);
2511 } else {
2512 ch->fepstartca = ch->startca = dflow.startc;
2513 ch->fepstopca = ch->stopca = dflow.stopc;
2514 fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1);
2515 }
2516
2517 if (ch->statusflags & TXSTOPPED)
2518 pc_start(tty);
2519
2520 memoff(ch);
2521 spin_unlock_irqrestore(&epca_lock, flags);
2522 } /* End if setflow toggled */
2523 break;
2524 default:
2525 return -ENOIOCTLCMD;
2526 } /* End switch cmd */
2527 return 0; 2348 return 0;
2528} /* End pc_ioctl */ 2349}
2529
2530/* --------------------- Begin pc_set_termios ----------------------- */
2531 2350
2532static void pc_set_termios(struct tty_struct *tty, struct ktermios *old_termios) 2351static void pc_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
2533{ /* Begin pc_set_termios */ 2352{
2534
2535 struct channel *ch; 2353 struct channel *ch;
2536 unsigned long flags; 2354 unsigned long flags;
2537 /* --------------------------------------------------------- 2355 /*
2538 verifyChannel returns the channel from the tty struct 2356 * verifyChannel returns the channel from the tty struct if it is
2539 if it is valid. This serves as a sanity check. 2357 * valid. This serves as a sanity check.
2540 ------------------------------------------------------------- */ 2358 */
2541 if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ 2359 if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */
2542 spin_lock_irqsave(&epca_lock, flags); 2360 spin_lock_irqsave(&epca_lock, flags);
2543 globalwinon(ch); 2361 globalwinon(ch);
@@ -2554,47 +2372,40 @@ static void pc_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
2554 wake_up_interruptible(&ch->open_wait); 2372 wake_up_interruptible(&ch->open_wait);
2555 2373
2556 } /* End if channel valid */ 2374 } /* End if channel valid */
2557 2375}
2558} /* End pc_set_termios */
2559
2560/* --------------------- Begin do_softint ----------------------- */
2561 2376
2562static void do_softint(struct work_struct *work) 2377static void do_softint(struct work_struct *work)
2563{ /* Begin do_softint */ 2378{
2564 struct channel *ch = container_of(work, struct channel, tqueue); 2379 struct channel *ch = container_of(work, struct channel, tqueue);
2565 /* Called in response to a modem change event */ 2380 /* Called in response to a modem change event */
2566 if (ch && ch->magic == EPCA_MAGIC) { /* Begin EPCA_MAGIC */ 2381 if (ch && ch->magic == EPCA_MAGIC) {
2567 struct tty_struct *tty = ch->tty; 2382 struct tty_struct *tty = ch->tty;
2568 2383
2569 if (tty && tty->driver_data) { 2384 if (tty && tty->driver_data) {
2570 if (test_and_clear_bit(EPCA_EVENT_HANGUP, &ch->event)) { /* Begin if clear_bit */ 2385 if (test_and_clear_bit(EPCA_EVENT_HANGUP, &ch->event)) {
2571 tty_hangup(tty); /* FIXME: module removal race here - AKPM */ 2386 tty_hangup(tty); /* FIXME: module removal race here - AKPM */
2572 wake_up_interruptible(&ch->open_wait); 2387 wake_up_interruptible(&ch->open_wait);
2573 ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE; 2388 ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE;
2574 } /* End if clear_bit */ 2389 }
2575 } 2390 }
2576 } /* End EPCA_MAGIC */ 2391 }
2577} /* End do_softint */ 2392}
2578
2579/* ------------------------------------------------------------
2580 pc_stop and pc_start provide software flow control to the
2581 routine and the pc_ioctl routine.
2582---------------------------------------------------------------- */
2583
2584/* --------------------- Begin pc_stop ----------------------- */
2585 2393
2394/*
2395 * pc_stop and pc_start provide software flow control to the routine and the
2396 * pc_ioctl routine.
2397 */
2586static void pc_stop(struct tty_struct *tty) 2398static void pc_stop(struct tty_struct *tty)
2587{ /* Begin pc_stop */ 2399{
2588
2589 struct channel *ch; 2400 struct channel *ch;
2590 unsigned long flags; 2401 unsigned long flags;
2591 /* --------------------------------------------------------- 2402 /*
2592 verifyChannel returns the channel from the tty struct 2403 * verifyChannel returns the channel from the tty struct if it is
2593 if it is valid. This serves as a sanity check. 2404 * valid. This serves as a sanity check.
2594 ------------------------------------------------------------- */ 2405 */
2595 if ((ch = verifyChannel(tty)) != NULL) { /* Begin if valid channel */ 2406 if ((ch = verifyChannel(tty)) != NULL) {
2596 spin_lock_irqsave(&epca_lock, flags); 2407 spin_lock_irqsave(&epca_lock, flags);
2597 if ((ch->statusflags & TXSTOPPED) == 0) { /* Begin if transmit stop requested */ 2408 if ((ch->statusflags & TXSTOPPED) == 0) { /* Begin if transmit stop requested */
2598 globalwinon(ch); 2409 globalwinon(ch);
2599 /* STOP transmitting now !! */ 2410 /* STOP transmitting now !! */
2600 fepcmd(ch, PAUSETX, 0, 0, 0, 0); 2411 fepcmd(ch, PAUSETX, 0, 0, 0, 0);
@@ -2602,19 +2413,17 @@ static void pc_stop(struct tty_struct *tty)
2602 memoff(ch); 2413 memoff(ch);
2603 } /* End if transmit stop requested */ 2414 } /* End if transmit stop requested */
2604 spin_unlock_irqrestore(&epca_lock, flags); 2415 spin_unlock_irqrestore(&epca_lock, flags);
2605 } /* End if valid channel */ 2416 }
2606} /* End pc_stop */ 2417}
2607
2608/* --------------------- Begin pc_start ----------------------- */
2609 2418
2610static void pc_start(struct tty_struct *tty) 2419static void pc_start(struct tty_struct *tty)
2611{ /* Begin pc_start */ 2420{
2612 struct channel *ch; 2421 struct channel *ch;
2613 /* --------------------------------------------------------- 2422 /*
2614 verifyChannel returns the channel from the tty struct 2423 * verifyChannel returns the channel from the tty struct if it is
2615 if it is valid. This serves as a sanity check. 2424 * valid. This serves as a sanity check.
2616 ------------------------------------------------------------- */ 2425 */
2617 if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ 2426 if ((ch = verifyChannel(tty)) != NULL) {
2618 unsigned long flags; 2427 unsigned long flags;
2619 spin_lock_irqsave(&epca_lock, flags); 2428 spin_lock_irqsave(&epca_lock, flags);
2620 /* Just in case output was resumed because of a change in Digi-flow */ 2429 /* Just in case output was resumed because of a change in Digi-flow */
@@ -2630,28 +2439,25 @@ static void pc_start(struct tty_struct *tty)
2630 memoff(ch); 2439 memoff(ch);
2631 } /* End transmit resume requested */ 2440 } /* End transmit resume requested */
2632 spin_unlock_irqrestore(&epca_lock, flags); 2441 spin_unlock_irqrestore(&epca_lock, flags);
2633 } /* End if channel valid */ 2442 }
2634} /* End pc_start */ 2443}
2635 2444
2636/* ------------------------------------------------------------------ 2445/*
2637 The below routines pc_throttle and pc_unthrottle are used 2446 * The below routines pc_throttle and pc_unthrottle are used to slow (And
2638 to slow (And resume) the receipt of data into the kernels 2447 * resume) the receipt of data into the kernels receive buffers. The exact
2639 receive buffers. The exact occurrence of this depends on the 2448 * occurrence of this depends on the size of the kernels receive buffer and
2640 size of the kernels receive buffer and what the 'watermarks' 2449 * what the 'watermarks' are set to for that buffer. See the n_ttys.c file for
2641 are set to for that buffer. See the n_ttys.c file for more 2450 * more details.
2642 details. 2451 */
2643______________________________________________________________________ */ 2452static void pc_throttle(struct tty_struct *tty)
2644/* --------------------- Begin throttle ----------------------- */ 2453{
2645
2646static void pc_throttle(struct tty_struct * tty)
2647{ /* Begin pc_throttle */
2648 struct channel *ch; 2454 struct channel *ch;
2649 unsigned long flags; 2455 unsigned long flags;
2650 /* --------------------------------------------------------- 2456 /*
2651 verifyChannel returns the channel from the tty struct 2457 * verifyChannel returns the channel from the tty struct if it is
2652 if it is valid. This serves as a sanity check. 2458 * valid. This serves as a sanity check.
2653 ------------------------------------------------------------- */ 2459 */
2654 if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ 2460 if ((ch = verifyChannel(tty)) != NULL) {
2655 spin_lock_irqsave(&epca_lock, flags); 2461 spin_lock_irqsave(&epca_lock, flags);
2656 if ((ch->statusflags & RXSTOPPED) == 0) { 2462 if ((ch->statusflags & RXSTOPPED) == 0) {
2657 globalwinon(ch); 2463 globalwinon(ch);
@@ -2660,20 +2466,18 @@ static void pc_throttle(struct tty_struct * tty)
2660 memoff(ch); 2466 memoff(ch);
2661 } 2467 }
2662 spin_unlock_irqrestore(&epca_lock, flags); 2468 spin_unlock_irqrestore(&epca_lock, flags);
2663 } /* End if channel valid */ 2469 }
2664} /* End pc_throttle */ 2470}
2665
2666/* --------------------- Begin unthrottle ----------------------- */
2667 2471
2668static void pc_unthrottle(struct tty_struct *tty) 2472static void pc_unthrottle(struct tty_struct *tty)
2669{ /* Begin pc_unthrottle */ 2473{
2670 struct channel *ch; 2474 struct channel *ch;
2671 unsigned long flags; 2475 unsigned long flags;
2672 /* --------------------------------------------------------- 2476 /*
2673 verifyChannel returns the channel from the tty struct 2477 * verifyChannel returns the channel from the tty struct if it is
2674 if it is valid. This serves as a sanity check. 2478 * valid. This serves as a sanity check.
2675 ------------------------------------------------------------- */ 2479 */
2676 if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ 2480 if ((ch = verifyChannel(tty)) != NULL) {
2677 /* Just in case output was resumed because of a change in Digi-flow */ 2481 /* Just in case output was resumed because of a change in Digi-flow */
2678 spin_lock_irqsave(&epca_lock, flags); 2482 spin_lock_irqsave(&epca_lock, flags);
2679 if (ch->statusflags & RXSTOPPED) { 2483 if (ch->statusflags & RXSTOPPED) {
@@ -2683,151 +2487,143 @@ static void pc_unthrottle(struct tty_struct *tty)
2683 memoff(ch); 2487 memoff(ch);
2684 } 2488 }
2685 spin_unlock_irqrestore(&epca_lock, flags); 2489 spin_unlock_irqrestore(&epca_lock, flags);
2686 } /* End if channel valid */ 2490 }
2687} /* End pc_unthrottle */ 2491}
2688
2689/* --------------------- Begin digi_send_break ----------------------- */
2690 2492
2691void digi_send_break(struct channel *ch, int msec) 2493void digi_send_break(struct channel *ch, int msec)
2692{ /* Begin digi_send_break */ 2494{
2693 unsigned long flags; 2495 unsigned long flags;
2694 2496
2695 spin_lock_irqsave(&epca_lock, flags); 2497 spin_lock_irqsave(&epca_lock, flags);
2696 globalwinon(ch); 2498 globalwinon(ch);
2697 /* -------------------------------------------------------------------- 2499 /*
2698 Maybe I should send an infinite break here, schedule() for 2500 * Maybe I should send an infinite break here, schedule() for msec
2699 msec amount of time, and then stop the break. This way, 2501 * amount of time, and then stop the break. This way, the user can't
2700 the user can't screw up the FEP by causing digi_send_break() 2502 * screw up the FEP by causing digi_send_break() to be called (i.e. via
2701 to be called (i.e. via an ioctl()) more than once in msec amount 2503 * an ioctl()) more than once in msec amount of time.
2702 of time. Try this for now... 2504 * Try this for now...
2703 ------------------------------------------------------------------------ */ 2505 */
2704 fepcmd(ch, SENDBREAK, msec, 0, 10, 0); 2506 fepcmd(ch, SENDBREAK, msec, 0, 10, 0);
2705 memoff(ch); 2507 memoff(ch);
2706 spin_unlock_irqrestore(&epca_lock, flags); 2508 spin_unlock_irqrestore(&epca_lock, flags);
2707} /* End digi_send_break */ 2509}
2708
2709/* --------------------- Begin setup_empty_event ----------------------- */
2710 2510
2711/* Caller MUST hold the lock */ 2511/* Caller MUST hold the lock */
2712
2713static void setup_empty_event(struct tty_struct *tty, struct channel *ch) 2512static void setup_empty_event(struct tty_struct *tty, struct channel *ch)
2714{ /* Begin setup_empty_event */ 2513{
2715
2716 struct board_chan __iomem *bc = ch->brdchan; 2514 struct board_chan __iomem *bc = ch->brdchan;
2717 2515
2718 globalwinon(ch); 2516 globalwinon(ch);
2719 ch->statusflags |= EMPTYWAIT; 2517 ch->statusflags |= EMPTYWAIT;
2720 /* ------------------------------------------------------------------ 2518 /*
2721 When set the iempty flag request a event to be generated when the 2519 * When set the iempty flag request a event to be generated when the
2722 transmit buffer is empty (If there is no BREAK in progress). 2520 * transmit buffer is empty (If there is no BREAK in progress).
2723 --------------------------------------------------------------------- */ 2521 */
2724 writeb(1, &bc->iempty); 2522 writeb(1, &bc->iempty);
2725 memoff(ch); 2523 memoff(ch);
2726} /* End setup_empty_event */ 2524}
2727 2525
2728/* ---------------------- Begin epca_setup -------------------------- */
2729void epca_setup(char *str, int *ints) 2526void epca_setup(char *str, int *ints)
2730{ /* Begin epca_setup */ 2527{
2731 struct board_info board; 2528 struct board_info board;
2732 int index, loop, last; 2529 int index, loop, last;
2733 char *temp, *t2; 2530 char *temp, *t2;
2734 unsigned len; 2531 unsigned len;
2735 2532
2736 /* ---------------------------------------------------------------------- 2533 /*
2737 If this routine looks a little strange it is because it is only called 2534 * If this routine looks a little strange it is because it is only
2738 if a LILO append command is given to boot the kernel with parameters. 2535 * called if a LILO append command is given to boot the kernel with
2739 In this way, we can provide the user a method of changing his board 2536 * parameters. In this way, we can provide the user a method of
2740 configuration without rebuilding the kernel. 2537 * changing his board configuration without rebuilding the kernel.
2741 ----------------------------------------------------------------------- */ 2538 */
2742 if (!liloconfig) 2539 if (!liloconfig)
2743 liloconfig = 1; 2540 liloconfig = 1;
2744 2541
2745 memset(&board, 0, sizeof(board)); 2542 memset(&board, 0, sizeof(board));
2746 2543
2747 /* Assume the data is int first, later we can change it */ 2544 /* Assume the data is int first, later we can change it */
2748 /* I think that array position 0 of ints holds the number of args */ 2545 /* I think that array position 0 of ints holds the number of args */
2749 for (last = 0, index = 1; index <= ints[0]; index++) 2546 for (last = 0, index = 1; index <= ints[0]; index++)
2750 switch(index) 2547 switch (index) { /* Begin parse switch */
2751 { /* Begin parse switch */ 2548 case 1:
2752 case 1: 2549 board.status = ints[index];
2753 board.status = ints[index]; 2550 /*
2754 /* --------------------------------------------------------- 2551 * We check for 2 (As opposed to 1; because 2 is a flag
2755 We check for 2 (As opposed to 1; because 2 is a flag 2552 * instructing the driver to ignore epcaconfig.) For
2756 instructing the driver to ignore epcaconfig.) For this 2553 * this reason we check for 2.
2757 reason we check for 2. 2554 */
2758 ------------------------------------------------------------ */ 2555 if (board.status == 2) { /* Begin ignore epcaconfig as well as lilo cmd line */
2759 if (board.status == 2) { /* Begin ignore epcaconfig as well as lilo cmd line */ 2556 nbdevs = 0;
2760 nbdevs = 0; 2557 num_cards = 0;
2761 num_cards = 0; 2558 return;
2762 return; 2559 } /* End ignore epcaconfig as well as lilo cmd line */
2763 } /* End ignore epcaconfig as well as lilo cmd line */ 2560
2764 2561 if (board.status > 2) {
2765 if (board.status > 2) { 2562 printk(KERN_ERR "epca_setup: Invalid board status 0x%x\n", board.status);
2766 printk(KERN_ERR "epca_setup: Invalid board status 0x%x\n", board.status); 2563 invalid_lilo_config = 1;
2767 invalid_lilo_config = 1; 2564 setup_error_code |= INVALID_BOARD_STATUS;
2768 setup_error_code |= INVALID_BOARD_STATUS; 2565 return;
2769 return; 2566 }
2770 } 2567 last = index;
2771 last = index; 2568 break;
2772 break; 2569 case 2:
2773 case 2: 2570 board.type = ints[index];
2774 board.type = ints[index]; 2571 if (board.type >= PCIXEM) {
2775 if (board.type >= PCIXEM) { 2572 printk(KERN_ERR "epca_setup: Invalid board type 0x%x\n", board.type);
2776 printk(KERN_ERR "epca_setup: Invalid board type 0x%x\n", board.type); 2573 invalid_lilo_config = 1;
2777 invalid_lilo_config = 1; 2574 setup_error_code |= INVALID_BOARD_TYPE;
2778 setup_error_code |= INVALID_BOARD_TYPE; 2575 return;
2779 return; 2576 }
2780 } 2577 last = index;
2781 last = index; 2578 break;
2782 break; 2579 case 3:
2783 case 3: 2580 board.altpin = ints[index];
2784 board.altpin = ints[index]; 2581 if (board.altpin > 1) {
2785 if (board.altpin > 1) { 2582 printk(KERN_ERR "epca_setup: Invalid board altpin 0x%x\n", board.altpin);
2786 printk(KERN_ERR "epca_setup: Invalid board altpin 0x%x\n", board.altpin); 2583 invalid_lilo_config = 1;
2787 invalid_lilo_config = 1; 2584 setup_error_code |= INVALID_ALTPIN;
2788 setup_error_code |= INVALID_ALTPIN; 2585 return;
2789 return; 2586 }
2790 } 2587 last = index;
2791 last = index; 2588 break;
2792 break; 2589
2793 2590 case 4:
2794 case 4: 2591 board.numports = ints[index];
2795 board.numports = ints[index]; 2592 if (board.numports < 2 || board.numports > 256) {
2796 if (board.numports < 2 || board.numports > 256) { 2593 printk(KERN_ERR "epca_setup: Invalid board numports 0x%x\n", board.numports);
2797 printk(KERN_ERR "epca_setup: Invalid board numports 0x%x\n", board.numports); 2594 invalid_lilo_config = 1;
2798 invalid_lilo_config = 1; 2595 setup_error_code |= INVALID_NUM_PORTS;
2799 setup_error_code |= INVALID_NUM_PORTS; 2596 return;
2800 return; 2597 }
2801 } 2598 nbdevs += board.numports;
2802 nbdevs += board.numports; 2599 last = index;
2803 last = index; 2600 break;
2804 break;
2805
2806 case 5:
2807 board.port = ints[index];
2808 if (ints[index] <= 0) {
2809 printk(KERN_ERR "epca_setup: Invalid io port 0x%x\n", (unsigned int)board.port);
2810 invalid_lilo_config = 1;
2811 setup_error_code |= INVALID_PORT_BASE;
2812 return;
2813 }
2814 last = index;
2815 break;
2816
2817 case 6:
2818 board.membase = ints[index];
2819 if (ints[index] <= 0) {
2820 printk(KERN_ERR "epca_setup: Invalid memory base 0x%x\n",(unsigned int)board.membase);
2821 invalid_lilo_config = 1;
2822 setup_error_code |= INVALID_MEM_BASE;
2823 return;
2824 }
2825 last = index;
2826 break;
2827 2601
2828 default: 2602 case 5:
2829 printk(KERN_ERR "<Error> - epca_setup: Too many integer parms\n"); 2603 board.port = ints[index];
2604 if (ints[index] <= 0) {
2605 printk(KERN_ERR "epca_setup: Invalid io port 0x%x\n", (unsigned int)board.port);
2606 invalid_lilo_config = 1;
2607 setup_error_code |= INVALID_PORT_BASE;
2830 return; 2608 return;
2609 }
2610 last = index;
2611 break;
2612
2613 case 6:
2614 board.membase = ints[index];
2615 if (ints[index] <= 0) {
2616 printk(KERN_ERR "epca_setup: Invalid memory base 0x%x\n",(unsigned int)board.membase);
2617 invalid_lilo_config = 1;
2618 setup_error_code |= INVALID_MEM_BASE;
2619 return;
2620 }
2621 last = index;
2622 break;
2623
2624 default:
2625 printk(KERN_ERR "<Error> - epca_setup: Too many integer parms\n");
2626 return;
2831 2627
2832 } /* End parse switch */ 2628 } /* End parse switch */
2833 2629
@@ -2844,120 +2640,121 @@ void epca_setup(char *str, int *ints)
2844 /* Set index to the number of args + 1 */ 2640 /* Set index to the number of args + 1 */
2845 index = last + 1; 2641 index = last + 1;
2846 2642
2847 switch(index) 2643 switch (index) {
2848 { 2644 case 1:
2849 case 1: 2645 len = strlen(str);
2850 len = strlen(str); 2646 if (strncmp("Disable", str, len) == 0)
2851 if (strncmp("Disable", str, len) == 0) 2647 board.status = 0;
2852 board.status = 0; 2648 else if (strncmp("Enable", str, len) == 0)
2853 else if (strncmp("Enable", str, len) == 0) 2649 board.status = 1;
2854 board.status = 1; 2650 else {
2855 else { 2651 printk(KERN_ERR "epca_setup: Invalid status %s\n", str);
2856 printk(KERN_ERR "epca_setup: Invalid status %s\n", str); 2652 invalid_lilo_config = 1;
2857 invalid_lilo_config = 1; 2653 setup_error_code |= INVALID_BOARD_STATUS;
2858 setup_error_code |= INVALID_BOARD_STATUS; 2654 return;
2859 return; 2655 }
2860 } 2656 last = index;
2861 last = index; 2657 break;
2862 break;
2863
2864 case 2:
2865 for(loop = 0; loop < EPCA_NUM_TYPES; loop++)
2866 if (strcmp(board_desc[loop], str) == 0)
2867 break;
2868 /* ---------------------------------------------------------------
2869 If the index incremented above refers to a legitamate board
2870 type set it here.
2871 ------------------------------------------------------------------*/
2872 if (index < EPCA_NUM_TYPES)
2873 board.type = loop;
2874 else {
2875 printk(KERN_ERR "epca_setup: Invalid board type: %s\n", str);
2876 invalid_lilo_config = 1;
2877 setup_error_code |= INVALID_BOARD_TYPE;
2878 return;
2879 }
2880 last = index;
2881 break;
2882
2883 case 3:
2884 len = strlen(str);
2885 if (strncmp("Disable", str, len) == 0)
2886 board.altpin = 0;
2887 else if (strncmp("Enable", str, len) == 0)
2888 board.altpin = 1;
2889 else {
2890 printk(KERN_ERR "epca_setup: Invalid altpin %s\n", str);
2891 invalid_lilo_config = 1;
2892 setup_error_code |= INVALID_ALTPIN;
2893 return;
2894 }
2895 last = index;
2896 break;
2897
2898 case 4:
2899 t2 = str;
2900 while (isdigit(*t2))
2901 t2++;
2902
2903 if (*t2) {
2904 printk(KERN_ERR "epca_setup: Invalid port count %s\n", str);
2905 invalid_lilo_config = 1;
2906 setup_error_code |= INVALID_NUM_PORTS;
2907 return;
2908 }
2909 2658
2910 /* ------------------------------------------------------------ 2659 case 2:
2911 There is not a man page for simple_strtoul but the code can be 2660 for (loop = 0; loop < EPCA_NUM_TYPES; loop++)
2912 found in vsprintf.c. The first argument is the string to 2661 if (strcmp(board_desc[loop], str) == 0)
2913 translate (To an unsigned long obviously), the second argument 2662 break;
2914 can be the address of any character variable or a NULL. If a 2663 /*
2915 variable is given, the end pointer of the string will be stored 2664 * If the index incremented above refers to a
2916 in that variable; if a NULL is given the end pointer will 2665 * legitamate board type set it here.
2917 not be returned. The last argument is the base to use. If 2666 */
2918 a 0 is indicated, the routine will attempt to determine the 2667 if (index < EPCA_NUM_TYPES)
2919 proper base by looking at the values prefix (A '0' for octal, 2668 board.type = loop;
2920 a 'x' for hex, etc ... If a value is given it will use that 2669 else {
2921 value as the base. 2670 printk(KERN_ERR "epca_setup: Invalid board type: %s\n", str);
2922 ---------------------------------------------------------------- */ 2671 invalid_lilo_config = 1;
2923 board.numports = simple_strtoul(str, NULL, 0); 2672 setup_error_code |= INVALID_BOARD_TYPE;
2924 nbdevs += board.numports; 2673 return;
2925 last = index; 2674 }
2926 break; 2675 last = index;
2927 2676 break;
2928 case 5:
2929 t2 = str;
2930 while (isxdigit(*t2))
2931 t2++;
2932
2933 if (*t2) {
2934 printk(KERN_ERR "epca_setup: Invalid i/o address %s\n", str);
2935 invalid_lilo_config = 1;
2936 setup_error_code |= INVALID_PORT_BASE;
2937 return;
2938 }
2939 2677
2940 board.port = simple_strtoul(str, NULL, 16); 2678 case 3:
2941 last = index; 2679 len = strlen(str);
2942 break; 2680 if (strncmp("Disable", str, len) == 0)
2681 board.altpin = 0;
2682 else if (strncmp("Enable", str, len) == 0)
2683 board.altpin = 1;
2684 else {
2685 printk(KERN_ERR "epca_setup: Invalid altpin %s\n", str);
2686 invalid_lilo_config = 1;
2687 setup_error_code |= INVALID_ALTPIN;
2688 return;
2689 }
2690 last = index;
2691 break;
2943 2692
2944 case 6: 2693 case 4:
2945 t2 = str; 2694 t2 = str;
2946 while (isxdigit(*t2)) 2695 while (isdigit(*t2))
2947 t2++; 2696 t2++;
2948 2697
2949 if (*t2) { 2698 if (*t2) {
2950 printk(KERN_ERR "epca_setup: Invalid memory base %s\n",str); 2699 printk(KERN_ERR "epca_setup: Invalid port count %s\n", str);
2951 invalid_lilo_config = 1; 2700 invalid_lilo_config = 1;
2952 setup_error_code |= INVALID_MEM_BASE; 2701 setup_error_code |= INVALID_NUM_PORTS;
2953 return; 2702 return;
2954 } 2703 }
2955 board.membase = simple_strtoul(str, NULL, 16); 2704
2956 last = index; 2705 /*
2957 break; 2706 * There is not a man page for simple_strtoul but the
2958 default: 2707 * code can be found in vsprintf.c. The first argument
2959 printk(KERN_ERR "epca: Too many string parms\n"); 2708 * is the string to translate (To an unsigned long
2709 * obviously), the second argument can be the address
2710 * of any character variable or a NULL. If a variable
2711 * is given, the end pointer of the string will be
2712 * stored in that variable; if a NULL is given the end
2713 * pointer will not be returned. The last argument is
2714 * the base to use. If a 0 is indicated, the routine
2715 * will attempt to determine the proper base by looking
2716 * at the values prefix (A '0' for octal, a 'x' for
2717 * hex, etc ... If a value is given it will use that
2718 * value as the base.
2719 */
2720 board.numports = simple_strtoul(str, NULL, 0);
2721 nbdevs += board.numports;
2722 last = index;
2723 break;
2724
2725 case 5:
2726 t2 = str;
2727 while (isxdigit(*t2))
2728 t2++;
2729
2730 if (*t2) {
2731 printk(KERN_ERR "epca_setup: Invalid i/o address %s\n", str);
2732 invalid_lilo_config = 1;
2733 setup_error_code |= INVALID_PORT_BASE;
2734 return;
2735 }
2736
2737 board.port = simple_strtoul(str, NULL, 16);
2738 last = index;
2739 break;
2740
2741 case 6:
2742 t2 = str;
2743 while (isxdigit(*t2))
2744 t2++;
2745
2746 if (*t2) {
2747 printk(KERN_ERR "epca_setup: Invalid memory base %s\n",str);
2748 invalid_lilo_config = 1;
2749 setup_error_code |= INVALID_MEM_BASE;
2960 return; 2750 return;
2751 }
2752 board.membase = simple_strtoul(str, NULL, 16);
2753 last = index;
2754 break;
2755 default:
2756 printk(KERN_ERR "epca: Too many string parms\n");
2757 return;
2961 } 2758 }
2962 str = temp; 2759 str = temp;
2963 } /* End while there is a string arg */ 2760 } /* End while there is a string arg */
@@ -2966,19 +2763,16 @@ void epca_setup(char *str, int *ints)
2966 printk(KERN_ERR "epca: Insufficient parms specified\n"); 2763 printk(KERN_ERR "epca: Insufficient parms specified\n");
2967 return; 2764 return;
2968 } 2765 }
2969 2766
2970 /* I should REALLY validate the stuff here */ 2767 /* I should REALLY validate the stuff here */
2971 /* Copies our local copy of board into boards */ 2768 /* Copies our local copy of board into boards */
2972 memcpy((void *)&boards[num_cards],(void *)&board, sizeof(board)); 2769 memcpy((void *)&boards[num_cards],(void *)&board, sizeof(board));
2973 /* Does this get called once per lilo arg are what ? */ 2770 /* Does this get called once per lilo arg are what ? */
2974 printk(KERN_INFO "PC/Xx: Added board %i, %s %i ports at 0x%4.4X base 0x%6.6X\n", 2771 printk(KERN_INFO "PC/Xx: Added board %i, %s %i ports at 0x%4.4X base 0x%6.6X\n",
2975 num_cards, board_desc[board.type], 2772 num_cards, board_desc[board.type],
2976 board.numports, (int)board.port, (unsigned int) board.membase); 2773 board.numports, (int)board.port, (unsigned int) board.membase);
2977 num_cards++; 2774 num_cards++;
2978} /* End epca_setup */ 2775}
2979
2980
2981/* ------------------------ Begin init_PCI --------------------------- */
2982 2776
2983enum epic_board_types { 2777enum epic_board_types {
2984 brd_xr = 0, 2778 brd_xr = 0,
@@ -2987,7 +2781,6 @@ enum epic_board_types {
2987 brd_xrj, 2781 brd_xrj,
2988}; 2782};
2989 2783
2990
2991/* indexed directly by epic_board_types enum */ 2784/* indexed directly by epic_board_types enum */
2992static struct { 2785static struct {
2993 unsigned char board_type; 2786 unsigned char board_type;
@@ -2999,7 +2792,7 @@ static struct {
2999 { PCIXRJ, 2, }, 2792 { PCIXRJ, 2, },
3000}; 2793};
3001 2794
3002static int __devinit epca_init_one (struct pci_dev *pdev, 2795static int __devinit epca_init_one(struct pci_dev *pdev,
3003 const struct pci_device_id *ent) 2796 const struct pci_device_id *ent)
3004{ 2797{
3005 static int board_num = -1; 2798 static int board_num = -1;
@@ -3013,7 +2806,7 @@ static int __devinit epca_init_one (struct pci_dev *pdev,
3013 board_idx = board_num + num_cards; 2806 board_idx = board_num + num_cards;
3014 if (board_idx >= MAXBOARDS) 2807 if (board_idx >= MAXBOARDS)
3015 goto err_out; 2808 goto err_out;
3016 2809
3017 addr = pci_resource_start (pdev, epca_info_tbl[info_idx].bar_idx); 2810 addr = pci_resource_start (pdev, epca_info_tbl[info_idx].bar_idx);
3018 if (!addr) { 2811 if (!addr) {
3019 printk (KERN_ERR PFX "PCI region #%d not available (size 0)\n", 2812 printk (KERN_ERR PFX "PCI region #%d not available (size 0)\n",
@@ -3053,15 +2846,15 @@ static int __devinit epca_init_one (struct pci_dev *pdev,
3053 goto err_out_free_memregion; 2846 goto err_out_free_memregion;
3054 } 2847 }
3055 2848
3056 /* -------------------------------------------------------------- 2849 /*
3057 I don't know what the below does, but the hardware guys say 2850 * I don't know what the below does, but the hardware guys say its
3058 its required on everything except PLX (In this case XRJ). 2851 * required on everything except PLX (In this case XRJ).
3059 ---------------------------------------------------------------- */ 2852 */
3060 if (info_idx != brd_xrj) { 2853 if (info_idx != brd_xrj) {
3061 pci_write_config_byte(pdev, 0x40, 0); 2854 pci_write_config_byte(pdev, 0x40, 0);
3062 pci_write_config_byte(pdev, 0x46, 0); 2855 pci_write_config_byte(pdev, 0x46, 0);
3063 } 2856 }
3064 2857
3065 return 0; 2858 return 0;
3066 2859
3067err_out_free_memregion: 2860err_out_free_memregion:
@@ -3086,7 +2879,7 @@ static struct pci_device_id epca_pci_tbl[] = {
3086MODULE_DEVICE_TABLE(pci, epca_pci_tbl); 2879MODULE_DEVICE_TABLE(pci, epca_pci_tbl);
3087 2880
3088int __init init_PCI (void) 2881int __init init_PCI (void)
3089{ /* Begin init_PCI */ 2882{
3090 memset (&epca_driver, 0, sizeof (epca_driver)); 2883 memset (&epca_driver, 0, sizeof (epca_driver));
3091 epca_driver.name = "epca"; 2884 epca_driver.name = "epca";
3092 epca_driver.id_table = epca_pci_tbl; 2885 epca_driver.id_table = epca_pci_tbl;