aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2006-12-08 05:38:14 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-08 11:28:53 -0500
commit55b307da3e00b2281788860eefb42976a86d7752 (patch)
tree8d942f774c9bce13e90a5c97d3845568f4ac7961
parent3306ce3d0554e2e59cc429b7133e17e1513307cb (diff)
[PATCH] Char: mxser_new, rework to allow dynamic structs
This patch is preparation for further patches (pci probing) to allow allocated structures to be private data in pci_dev structure. Union two different structures used in the driver (hw_conf and port/board descriptor) to another 2: port and board not to initialize 2 different things and to have ports contained in board structure. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/char/mxser_new.c1196
-rw-r--r--drivers/char/mxser_new.h16
2 files changed, 584 insertions, 628 deletions
diff --git a/drivers/char/mxser_new.c b/drivers/char/mxser_new.c
index befff0548da3..7e53c7397832 100644
--- a/drivers/char/mxser_new.c
+++ b/drivers/char/mxser_new.c
@@ -57,7 +57,7 @@
57 57
58#include "mxser_new.h" 58#include "mxser_new.h"
59 59
60#define MXSER_VERSION "1.9.1" 60#define MXSER_VERSION "2.0"
61#define MXSERMAJOR 174 61#define MXSERMAJOR 174
62#define MXSERCUMAJOR 175 62#define MXSERCUMAJOR 175
63 63
@@ -85,8 +85,6 @@
85#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|\ 85#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|\
86 IXON|IXOFF)) 86 IXON|IXOFF))
87 87
88#define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? IRQF_SHARED : IRQF_DISABLED)
89
90#define C168_ASIC_ID 1 88#define C168_ASIC_ID 1
91#define C104_ASIC_ID 2 89#define C104_ASIC_ID 2
92#define C102_ASIC_ID 0xB 90#define C102_ASIC_ID 0xB
@@ -202,8 +200,6 @@ static const struct mxpciuart_info Gpci_uart_info[UART_INFO_NUM] = {
202}; 200};
203 201
204 202
205#ifdef CONFIG_PCI
206
207static struct pci_device_id mxser_pcibrds[] = { 203static struct pci_device_id mxser_pcibrds[] = {
208 { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C168), 204 { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C168),
209 .driver_data = MXSER_BOARD_C168_PCI }, 205 .driver_data = MXSER_BOARD_C168_PCI },
@@ -243,18 +239,8 @@ static struct pci_device_id mxser_pcibrds[] = {
243 .driver_data = MXSER_BOARD_CP104EL }, 239 .driver_data = MXSER_BOARD_CP104EL },
244 { } 240 { }
245}; 241};
246
247MODULE_DEVICE_TABLE(pci, mxser_pcibrds); 242MODULE_DEVICE_TABLE(pci, mxser_pcibrds);
248 243
249
250#endif
251
252typedef struct _moxa_pci_info {
253 unsigned short busNum;
254 unsigned short devNum;
255 struct pci_dev *pdev; /* add by Victor Yu. 06-23-2003 */
256} moxa_pci_info;
257
258static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 }; 244static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 };
259static int ttymajor = MXSERMAJOR; 245static int ttymajor = MXSERMAJOR;
260static int calloutmajor = MXSERCUMAJOR; 246static int calloutmajor = MXSERCUMAJOR;
@@ -301,69 +287,77 @@ struct mxser_mon_ext {
301 int iftype[32]; 287 int iftype[32];
302}; 288};
303 289
304struct mxser_hwconf { 290struct mxser_board;
305 int board_type; 291
306 int ports; 292struct mxser_port {
307 int irq; 293 struct mxser_board *board;
308 unsigned long vector; 294 struct tty_struct *tty;
309 unsigned long vector_mask; 295
310 int uart_type; 296 unsigned long ioaddr;
311 unsigned long ioaddr[MXSER_PORTS_PER_BOARD]; 297 unsigned long opmode_ioaddr;
312 int baud_base[MXSER_PORTS_PER_BOARD]; 298 int max_baud;
313 moxa_pci_info pciInfo;
314 int IsMoxaMustChipFlag; /* add by Victor Yu. 08-30-2002 */
315 int MaxCanSetBaudRate[MXSER_PORTS_PER_BOARD]; /* add by Victor Yu. 09-04-2002 */
316 unsigned long opmode_ioaddr[MXSER_PORTS_PER_BOARD]; /* add by Victor Yu. 01-05-2004 */
317};
318 299
319struct mxser_struct {
320 int port;
321 unsigned long base; /* port base address */
322 int irq; /* port using irq no. */
323 unsigned long vector; /* port irq vector */
324 unsigned long vectormask; /* port vector mask */
325 int rx_high_water; 300 int rx_high_water;
326 int rx_trigger; /* Rx fifo trigger level */ 301 int rx_trigger; /* Rx fifo trigger level */
327 int rx_low_water; 302 int rx_low_water;
328 int baud_base; /* max. speed */ 303 int baud_base; /* max. speed */
329 int flags; /* defined in tty.h */ 304 long realbaud;
330 int type; /* UART type */ 305 int type; /* UART type */
331 struct tty_struct *tty; 306 int flags; /* defined in tty.h */
332 int read_status_mask; 307 long session; /* Session of opening process */
333 int ignore_status_mask; 308 long pgrp; /* pgrp of opening process */
334 int xmit_fifo_size; 309
335 int custom_divisor;
336 int x_char; /* xon/xoff character */ 310 int x_char; /* xon/xoff character */
337 int close_delay;
338 unsigned short closing_wait;
339 int IER; /* Interrupt Enable Register */ 311 int IER; /* Interrupt Enable Register */
340 int MCR; /* Modem control register */ 312 int MCR; /* Modem control register */
313
314 unsigned char stop_rx;
315 unsigned char ldisc_stop_rx;
316
317 int custom_divisor;
318 int close_delay;
319 unsigned short closing_wait;
320 unsigned char err_shadow;
341 unsigned long event; 321 unsigned long event;
322
342 int count; /* # of fd on device */ 323 int count; /* # of fd on device */
343 int blocked_open; /* # of blocked opens */ 324 int blocked_open; /* # of blocked opens */
344 long session; /* Session of opening process */ 325 struct async_icount icount; /* kernel counters for 4 input interrupts */
345 long pgrp; /* pgrp of opening process */ 326 int timeout;
327
328 int read_status_mask;
329 int ignore_status_mask;
330 int xmit_fifo_size;
346 unsigned char *xmit_buf; 331 unsigned char *xmit_buf;
347 int xmit_head; 332 int xmit_head;
348 int xmit_tail; 333 int xmit_tail;
349 int xmit_cnt; 334 int xmit_cnt;
350 struct work_struct tqueue; 335
351 struct termios normal_termios; 336 struct termios normal_termios;
352 struct termios callout_termios; 337 struct termios callout_termios;
338
339 struct mxser_mon mon_data;
340
341 spinlock_t slock;
342 struct work_struct tqueue;
353 wait_queue_head_t open_wait; 343 wait_queue_head_t open_wait;
354 wait_queue_head_t close_wait; 344 wait_queue_head_t close_wait;
355 wait_queue_head_t delta_msr_wait; 345 wait_queue_head_t delta_msr_wait;
356 struct async_icount icount; /* kernel counters for the 4 input interrupts */ 346};
357 int timeout; 347
358 int IsMoxaMustChipFlag; /* add by Victor Yu. 08-30-2002 */ 348struct mxser_board {
359 int MaxCanSetBaudRate; /* add by Victor Yu. 09-04-2002 */ 349 struct pci_dev *pdev; /* temporary (until pci probing) */
360 unsigned long opmode_ioaddr; /* add by Victor Yu. 01-05-2004 */ 350
361 unsigned char stop_rx; 351 int irq;
362 unsigned char ldisc_stop_rx; 352 int board_type;
363 long realbaud; 353 unsigned int nports;
364 struct mxser_mon mon_data; 354 unsigned long vector;
365 unsigned char err_shadow; 355 unsigned long vector_mask;
366 spinlock_t slock; 356
357 int chip_flag;
358 int uart_type;
359
360 struct mxser_port ports[MXSER_PORTS_PER_BOARD];
367}; 361};
368 362
369struct mxser_mstatus { 363struct mxser_mstatus {
@@ -381,8 +375,8 @@ static int mxserBoardCAP[MXSER_BOARDS] = {
381 /* 0x180, 0x280, 0x200, 0x320 */ 375 /* 0x180, 0x280, 0x200, 0x320 */
382}; 376};
383 377
378static struct mxser_board mxser_boards[MXSER_BOARDS];
384static struct tty_driver *mxvar_sdriver; 379static struct tty_driver *mxvar_sdriver;
385static struct mxser_struct mxvar_table[MXSER_PORTS];
386static struct tty_struct *mxvar_tty[MXSER_PORTS + 1]; 380static struct tty_struct *mxvar_tty[MXSER_PORTS + 1];
387static struct termios *mxvar_termios[MXSER_PORTS + 1]; 381static struct termios *mxvar_termios[MXSER_PORTS + 1];
388static struct termios *mxvar_termios_locked[MXSER_PORTS + 1]; 382static struct termios *mxvar_termios_locked[MXSER_PORTS + 1];
@@ -394,21 +388,13 @@ static int mxser_set_baud_method[MXSER_PORTS + 1];
394static spinlock_t gm_lock; 388static spinlock_t gm_lock;
395 389
396/* 390/*
397 * This is used to figure out the divisor speeds and the timeouts
398 */
399
400static struct mxser_hwconf mxsercfg[MXSER_BOARDS];
401
402/*
403 * static functions: 391 * static functions:
404 */ 392 */
405 393
406static void mxser_getcfg(int board, struct mxser_hwconf *hwconf);
407static int mxser_init(void); 394static int mxser_init(void);
408 395
409/* static void mxser_poll(unsigned long); */ 396/* static void mxser_poll(unsigned long); */
410static int mxser_get_ISA_conf(int, struct mxser_hwconf *); 397static int mxser_get_ISA_conf(int, struct mxser_board *);
411static int mxser_get_PCI_conf(int, int, int, struct mxser_hwconf *);
412static void mxser_do_softint(void *); 398static void mxser_do_softint(void *);
413static int mxser_open(struct tty_struct *, struct file *); 399static int mxser_open(struct tty_struct *, struct file *);
414static void mxser_close(struct tty_struct *, struct file *); 400static void mxser_close(struct tty_struct *, struct file *);
@@ -428,24 +414,28 @@ static void mxser_start(struct tty_struct *);
428static void mxser_hangup(struct tty_struct *); 414static void mxser_hangup(struct tty_struct *);
429static void mxser_rs_break(struct tty_struct *, int); 415static void mxser_rs_break(struct tty_struct *, int);
430static irqreturn_t mxser_interrupt(int, void *, struct pt_regs *); 416static irqreturn_t mxser_interrupt(int, void *, struct pt_regs *);
431static void mxser_receive_chars(struct mxser_struct *, int *); 417static void mxser_receive_chars(struct mxser_port *, int *);
432static void mxser_transmit_chars(struct mxser_struct *); 418static void mxser_transmit_chars(struct mxser_port *);
433static void mxser_check_modem_status(struct mxser_struct *, int); 419static void mxser_check_modem_status(struct mxser_port *, int);
434static int mxser_block_til_ready(struct tty_struct *, struct file *, struct mxser_struct *); 420static int mxser_block_til_ready(struct tty_struct *, struct file *,
435static int mxser_startup(struct mxser_struct *); 421 struct mxser_port *);
436static void mxser_shutdown(struct mxser_struct *); 422static int mxser_startup(struct mxser_port *);
437static int mxser_change_speed(struct mxser_struct *, struct termios *old_termios); 423static void mxser_shutdown(struct mxser_port *);
438static int mxser_get_serial_info(struct mxser_struct *, struct serial_struct __user *); 424static int mxser_change_speed(struct mxser_port *, struct termios *);
439static int mxser_set_serial_info(struct mxser_struct *, struct serial_struct __user *); 425static int mxser_get_serial_info(struct mxser_port *,
440static int mxser_get_lsr_info(struct mxser_struct *, unsigned int __user *); 426 struct serial_struct __user *);
441static void mxser_send_break(struct mxser_struct *, int); 427static int mxser_set_serial_info(struct mxser_port *,
428 struct serial_struct __user *);
429static int mxser_get_lsr_info(struct mxser_port *, unsigned int __user *);
430static void mxser_send_break(struct mxser_port *, int);
442static int mxser_tiocmget(struct tty_struct *, struct file *); 431static int mxser_tiocmget(struct tty_struct *, struct file *);
443static int mxser_tiocmset(struct tty_struct *, struct file *, unsigned int, unsigned int); 432static int mxser_tiocmset(struct tty_struct *, struct file *, unsigned int,
444static int mxser_set_baud(struct mxser_struct *info, long newspd); 433 unsigned int);
445static void mxser_wait_until_sent(struct tty_struct *tty, int timeout); 434static int mxser_set_baud(struct mxser_port *, long);
435static void mxser_wait_until_sent(struct tty_struct *, int);
446 436
447static void mxser_startrx(struct tty_struct *tty); 437static void mxser_startrx(struct tty_struct *);
448static void mxser_stoprx(struct tty_struct *tty); 438static void mxser_stoprx(struct tty_struct *);
449 439
450 440
451static int CheckIsMoxaMust(int io) 441static int CheckIsMoxaMust(int io)
@@ -530,18 +520,18 @@ static void __exit mxser_module_exit(void)
530 for (i = 0; i < MXSER_BOARDS; i++) { 520 for (i = 0; i < MXSER_BOARDS; i++) {
531 struct pci_dev *pdev; 521 struct pci_dev *pdev;
532 522
533 if (mxsercfg[i].board_type == -1) 523 if (mxser_boards[i].board_type == -1)
534 continue; 524 continue;
535 else { 525 else {
536 pdev = mxsercfg[i].pciInfo.pdev; 526 pdev = mxser_boards[i].pdev;
537 free_irq(mxsercfg[i].irq, &mxvar_table[i * MXSER_PORTS_PER_BOARD]); 527 free_irq(mxser_boards[i].irq, &mxser_boards[i]);
538 if (pdev != NULL) { /* PCI */ 528 if (pdev != NULL) { /* PCI */
539 release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2)); 529 release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2));
540 release_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3)); 530 release_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3));
541 pci_dev_put(pdev); 531 pci_dev_put(pdev);
542 } else { 532 } else {
543 release_region(mxsercfg[i].ioaddr[0], 8 * mxsercfg[i].ports); 533 release_region(mxser_boards[i].ports[0].ioaddr, 8 * mxser_boards[i].nports);
544 release_region(mxsercfg[i].vector, 1); 534 release_region(mxser_boards[i].vector, 1);
545 } 535 }
546 } 536 }
547 } 537 }
@@ -549,7 +539,7 @@ static void __exit mxser_module_exit(void)
549 printk(KERN_DEBUG "Done.\n"); 539 printk(KERN_DEBUG "Done.\n");
550} 540}
551 541
552static void process_txrx_fifo(struct mxser_struct *info) 542static void process_txrx_fifo(struct mxser_port *info)
553{ 543{
554 int i; 544 int i;
555 545
@@ -558,60 +548,44 @@ static void process_txrx_fifo(struct mxser_struct *info)
558 info->rx_high_water = 1; 548 info->rx_high_water = 1;
559 info->rx_low_water = 1; 549 info->rx_low_water = 1;
560 info->xmit_fifo_size = 1; 550 info->xmit_fifo_size = 1;
561 } else { 551 } else
562 for (i = 0; i < UART_INFO_NUM; i++) { 552 for (i = 0; i < UART_INFO_NUM; i++)
563 if (info->IsMoxaMustChipFlag == Gpci_uart_info[i].type) { 553 if (info->board->chip_flag == Gpci_uart_info[i].type) {
564 info->rx_trigger = Gpci_uart_info[i].rx_trigger; 554 info->rx_trigger = Gpci_uart_info[i].rx_trigger;
565 info->rx_low_water = Gpci_uart_info[i].rx_low_water; 555 info->rx_low_water = Gpci_uart_info[i].rx_low_water;
566 info->rx_high_water = Gpci_uart_info[i].rx_high_water; 556 info->rx_high_water = Gpci_uart_info[i].rx_high_water;
567 info->xmit_fifo_size = Gpci_uart_info[i].xmit_fifo_size; 557 info->xmit_fifo_size = Gpci_uart_info[i].xmit_fifo_size;
568 break; 558 break;
569 } 559 }
570 }
571 }
572} 560}
573 561
574static int mxser_initbrd(int board, struct mxser_hwconf *hwconf) 562static int mxser_initbrd(struct mxser_board *brd)
575{ 563{
576 struct mxser_struct *info; 564 struct mxser_port *info;
565 unsigned int i;
577 int retval; 566 int retval;
578 int i, n;
579 567
580 n = board * MXSER_PORTS_PER_BOARD;
581 info = &mxvar_table[n];
582 /*if (verbose) */ { 568 /*if (verbose) */ {
583 printk(KERN_DEBUG " ttyM%d - ttyM%d ",
584 n, n + hwconf->ports - 1);
585 printk(" max. baud rate = %d bps.\n", 569 printk(" max. baud rate = %d bps.\n",
586 hwconf->MaxCanSetBaudRate[0]); 570 brd->ports[0].max_baud);
587 } 571 }
588 572
589 for (i = 0; i < hwconf->ports; i++, n++, info++) { 573 for (i = 0; i < brd->nports; i++) {
590 info->port = n; 574 info = &brd->ports[i];
591 info->base = hwconf->ioaddr[i]; 575 info->board = brd;
592 info->irq = hwconf->irq;
593 info->vector = hwconf->vector;
594 info->vectormask = hwconf->vector_mask;
595 info->opmode_ioaddr = hwconf->opmode_ioaddr[i]; /* add by Victor Yu. 01-05-2004 */
596 info->stop_rx = 0; 576 info->stop_rx = 0;
597 info->ldisc_stop_rx = 0; 577 info->ldisc_stop_rx = 0;
598 578
599 info->IsMoxaMustChipFlag = hwconf->IsMoxaMustChipFlag;
600 /* Enhance mode enabled here */ 579 /* Enhance mode enabled here */
601 if (info->IsMoxaMustChipFlag != MOXA_OTHER_UART) { 580 if (brd->chip_flag != MOXA_OTHER_UART)
602 ENABLE_MOXA_MUST_ENCHANCE_MODE(info->base); 581 ENABLE_MOXA_MUST_ENCHANCE_MODE(info->ioaddr);
603 }
604 582
605 info->flags = ASYNC_SHARE_IRQ; 583 info->flags = ASYNC_SHARE_IRQ;
606 info->type = hwconf->uart_type; 584 info->type = brd->uart_type;
607 info->baud_base = hwconf->baud_base[i];
608
609 info->MaxCanSetBaudRate = hwconf->MaxCanSetBaudRate[i];
610 585
611 process_txrx_fifo(info); 586 process_txrx_fifo(info);
612 587
613 588 info->custom_divisor = info->baud_base * 16;
614 info->custom_divisor = hwconf->baud_base[i] * 16;
615 info->close_delay = 5 * HZ / 10; 589 info->close_delay = 5 * HZ / 10;
616 info->closing_wait = 30 * HZ; 590 info->closing_wait = 30 * HZ;
617 INIT_WORK(&info->tqueue, mxser_do_softint, info); 591 INIT_WORK(&info->tqueue, mxser_do_softint, info);
@@ -622,118 +596,102 @@ static int mxser_initbrd(int board, struct mxser_hwconf *hwconf)
622 memset(&info->mon_data, 0, sizeof(struct mxser_mon)); 596 memset(&info->mon_data, 0, sizeof(struct mxser_mon));
623 info->err_shadow = 0; 597 info->err_shadow = 0;
624 spin_lock_init(&info->slock); 598 spin_lock_init(&info->slock);
599
600 /* before set INT ISR, disable all int */
601 outb(inb(info->ioaddr + UART_IER) & 0xf0,
602 info->ioaddr + UART_IER);
625 } 603 }
626 /* 604 /*
627 * Allocate the IRQ if necessary 605 * Allocate the IRQ if necessary
628 */ 606 */
629 607
630 608 retval = request_irq(brd->irq, mxser_interrupt,
631 /* before set INT ISR, disable all int */ 609 (brd->ports[0].flags & ASYNC_SHARE_IRQ) ? IRQF_SHARED :
632 for (i = 0; i < hwconf->ports; i++) { 610 IRQF_DISABLED, "mxser", brd);
633 outb(inb(hwconf->ioaddr[i] + UART_IER) & 0xf0,
634 hwconf->ioaddr[i] + UART_IER);
635 }
636
637 n = board * MXSER_PORTS_PER_BOARD;
638 info = &mxvar_table[n];
639
640 retval = request_irq(hwconf->irq, mxser_interrupt, IRQ_T(info),
641 "mxser", info);
642 if (retval) { 611 if (retval) {
643 printk(KERN_ERR "Board %d: %s", 612 printk(KERN_ERR "Board %s: Request irq failed, IRQ (%d) may "
644 board, mxser_brdname[hwconf->board_type - 1]); 613 "conflict with another device.\n",
645 printk(" Request irq failed, IRQ (%d) may conflict with" 614 mxser_brdname[brd->board_type - 1], brd->irq);
646 " another device.\n", info->irq);
647 return retval; 615 return retval;
648 } 616 }
649 return 0; 617 return 0;
650} 618}
651 619
652static void mxser_getcfg(int board, struct mxser_hwconf *hwconf) 620static int mxser_get_PCI_conf(int board_type, struct mxser_board *brd,
653{ 621 struct pci_dev *pdev)
654 mxsercfg[board] = *hwconf;
655}
656
657#ifdef CONFIG_PCI
658static int mxser_get_PCI_conf(int busnum, int devnum, int board_type, struct mxser_hwconf *hwconf)
659{ 622{
660 int i, j; 623 unsigned int i, j;
661 /* unsigned int val; */
662 unsigned long ioaddress; 624 unsigned long ioaddress;
663 struct pci_dev *pdev = hwconf->pciInfo.pdev;
664 625
665 /* io address */ 626 /* io address */
666 hwconf->board_type = board_type; 627 brd->board_type = board_type;
667 hwconf->ports = mxser_numports[board_type - 1]; 628 brd->nports = mxser_numports[board_type - 1];
668 ioaddress = pci_resource_start(pdev, 2); 629 ioaddress = pci_resource_start(pdev, 2);
669 request_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2), 630 request_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2),
670 "mxser(IO)"); 631 "mxser(IO)");
671 632
672 for (i = 0; i < hwconf->ports; i++) 633 for (i = 0; i < brd->nports; i++)
673 hwconf->ioaddr[i] = ioaddress + 8 * i; 634 brd->ports[i].ioaddr = ioaddress + 8 * i;
674 635
675 /* vector */ 636 /* vector */
676 ioaddress = pci_resource_start(pdev, 3); 637 ioaddress = pci_resource_start(pdev, 3);
677 request_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3), 638 request_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3),
678 "mxser(vector)"); 639 "mxser(vector)");
679 hwconf->vector = ioaddress; 640 brd->vector = ioaddress;
680 641
681 /* irq */ 642 /* irq */
682 hwconf->irq = hwconf->pciInfo.pdev->irq; 643 brd->irq = pdev->irq;
683 644
684 hwconf->IsMoxaMustChipFlag = CheckIsMoxaMust(hwconf->ioaddr[0]); 645 brd->chip_flag = CheckIsMoxaMust(brd->ports[0].ioaddr);
685 hwconf->uart_type = PORT_16550A; 646 brd->uart_type = PORT_16550A;
686 hwconf->vector_mask = 0; 647 brd->vector_mask = 0;
687 648
688 649 for (i = 0; i < brd->nports; i++) {
689 for (i = 0; i < hwconf->ports; i++) {
690 for (j = 0; j < UART_INFO_NUM; j++) { 650 for (j = 0; j < UART_INFO_NUM; j++) {
691 if (Gpci_uart_info[j].type == hwconf->IsMoxaMustChipFlag) { 651 if (Gpci_uart_info[j].type == brd->chip_flag) {
692 hwconf->MaxCanSetBaudRate[i] = Gpci_uart_info[j].max_baud; 652 brd->ports[i].max_baud =
653 Gpci_uart_info[j].max_baud;
693 654
694 /* exception....CP-102 */ 655 /* exception....CP-102 */
695 if (board_type == MXSER_BOARD_CP102) 656 if (board_type == MXSER_BOARD_CP102)
696 hwconf->MaxCanSetBaudRate[i] = 921600; 657 brd->ports[i].max_baud = 921600;
697 break; 658 break;
698 } 659 }
699 } 660 }
700 } 661 }
701 662
702 if (hwconf->IsMoxaMustChipFlag == MOXA_MUST_MU860_HWID) { 663 if (brd->chip_flag == MOXA_MUST_MU860_HWID) {
703 for (i = 0; i < hwconf->ports; i++) { 664 for (i = 0; i < brd->nports; i++) {
704 if (i < 4) 665 if (i < 4)
705 hwconf->opmode_ioaddr[i] = ioaddress + 4; 666 brd->ports[i].opmode_ioaddr = ioaddress + 4;
706 else 667 else
707 hwconf->opmode_ioaddr[i] = ioaddress + 0x0c; 668 brd->ports[i].opmode_ioaddr = ioaddress + 0x0c;
708 } 669 }
709 outb(0, ioaddress + 4); /* default set to RS232 mode */ 670 outb(0, ioaddress + 4); /* default set to RS232 mode */
710 outb(0, ioaddress + 0x0c); /* default set to RS232 mode */ 671 outb(0, ioaddress + 0x0c); /* default set to RS232 mode */
711 } 672 }
712 673
713 for (i = 0; i < hwconf->ports; i++) { 674 for (i = 0; i < brd->nports; i++) {
714 hwconf->vector_mask |= (1 << i); 675 brd->vector_mask |= (1 << i);
715 hwconf->baud_base[i] = 921600; 676 brd->ports[i].baud_base = 921600;
716 } 677 }
717 return 0; 678 return 0;
718} 679}
719#endif
720 680
721static int mxser_init(void) 681static int mxser_init(void)
722{ 682{
723 int i, m, retval, b, n;
724 struct pci_dev *pdev = NULL; 683 struct pci_dev *pdev = NULL;
725 int index; 684 struct mxser_board *brd;
726 unsigned char busnum, devnum; 685 unsigned int i, m;
727 struct mxser_hwconf hwconf; 686 int retval, b, n;
728 687
729 mxvar_sdriver = alloc_tty_driver(MXSER_PORTS + 1); 688 mxvar_sdriver = alloc_tty_driver(MXSER_PORTS + 1);
730 if (!mxvar_sdriver) 689 if (!mxvar_sdriver)
731 return -ENOMEM; 690 return -ENOMEM;
732 spin_lock_init(&gm_lock); 691 spin_lock_init(&gm_lock);
733 692
734 for (i = 0; i < MXSER_BOARDS; i++) { 693 for (i = 0; i < MXSER_BOARDS; i++)
735 mxsercfg[i].board_type = -1; 694 mxser_boards[i].board_type = -1;
736 }
737 695
738 printk(KERN_INFO "MOXA Smartio/Industio family driver version %s\n", 696 printk(KERN_INFO "MOXA Smartio/Industio family driver version %s\n",
739 MXSER_VERSION); 697 MXSER_VERSION);
@@ -756,13 +714,12 @@ static int mxser_init(void)
756 mxvar_sdriver->termios_locked = mxvar_termios_locked; 714 mxvar_sdriver->termios_locked = mxvar_termios_locked;
757 715
758 mxvar_diagflag = 0; 716 mxvar_diagflag = 0;
759 memset(mxvar_table, 0, MXSER_PORTS * sizeof(struct mxser_struct)); 717 memset(mxser_boards, 0, sizeof(mxser_boards));
760 memset(&mxvar_log, 0, sizeof(struct mxser_log)); 718 memset(&mxvar_log, 0, sizeof(struct mxser_log));
761 719
762 memset(&mxser_msr, 0, sizeof(unsigned char) * (MXSER_PORTS + 1)); 720 memset(&mxser_msr, 0, sizeof(unsigned char) * (MXSER_PORTS + 1));
763 memset(&mon_data_ext, 0, sizeof(struct mxser_mon_ext)); 721 memset(&mon_data_ext, 0, sizeof(struct mxser_mon_ext));
764 memset(&mxser_set_baud_method, 0, sizeof(int) * (MXSER_PORTS + 1)); 722 memset(&mxser_set_baud_method, 0, sizeof(int) * (MXSER_PORTS + 1));
765 memset(&hwconf, 0, sizeof(struct mxser_hwconf));
766 723
767 m = 0; 724 m = 0;
768 /* Start finding ISA boards here */ 725 /* Start finding ISA boards here */
@@ -772,11 +729,12 @@ static int mxser_init(void)
772 if (!(cap = mxserBoardCAP[b])) 729 if (!(cap = mxserBoardCAP[b]))
773 continue; 730 continue;
774 731
775 retval = mxser_get_ISA_conf(cap, &hwconf); 732 brd = &mxser_boards[m];
733 retval = mxser_get_ISA_conf(cap, brd);
776 734
777 if (retval != 0) 735 if (retval != 0)
778 printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n", 736 printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n",
779 mxser_brdname[hwconf.board_type - 1], ioaddr[b]); 737 mxser_brdname[brd->board_type - 1], ioaddr[b]);
780 738
781 if (retval <= 0) { 739 if (retval <= 0) {
782 if (retval == MXSER_ERR_IRQ) 740 if (retval == MXSER_ERR_IRQ)
@@ -795,17 +753,10 @@ static int mxser_init(void)
795 continue; 753 continue;
796 } 754 }
797 755
798 hwconf.pciInfo.busNum = 0; 756 brd->pdev = NULL;
799 hwconf.pciInfo.devNum = 0;
800 hwconf.pciInfo.pdev = NULL;
801 757
802 mxser_getcfg(m, &hwconf);
803 /*
804 * init mxsercfg first,
805 * or mxsercfg data is not correct on ISR.
806 */
807 /* mxser_initbrd will hook ISR. */ 758 /* mxser_initbrd will hook ISR. */
808 if (mxser_initbrd(m, &hwconf) < 0) 759 if (mxser_initbrd(brd) < 0)
809 continue; 760 continue;
810 761
811 m++; 762 m++;
@@ -818,11 +769,12 @@ static int mxser_init(void)
818 if (!(cap = ioaddr[b])) 769 if (!(cap = ioaddr[b]))
819 continue; 770 continue;
820 771
821 retval = mxser_get_ISA_conf(cap, &hwconf); 772 brd = &mxser_boards[m];
773 retval = mxser_get_ISA_conf(cap, &mxser_boards[m]);
822 774
823 if (retval != 0) 775 if (retval != 0)
824 printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n", 776 printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n",
825 mxser_brdname[hwconf.board_type - 1], ioaddr[b]); 777 mxser_brdname[brd->board_type - 1], ioaddr[b]);
826 778
827 if (retval <= 0) { 779 if (retval <= 0) {
828 if (retval == MXSER_ERR_IRQ) 780 if (retval == MXSER_ERR_IRQ)
@@ -841,26 +793,16 @@ static int mxser_init(void)
841 continue; 793 continue;
842 } 794 }
843 795
844 hwconf.pciInfo.busNum = 0; 796 brd->pdev = NULL;
845 hwconf.pciInfo.devNum = 0;
846 hwconf.pciInfo.pdev = NULL;
847
848 mxser_getcfg(m, &hwconf);
849 /*
850 * init mxsercfg first,
851 * or mxsercfg data is not correct on ISR.
852 */
853 /* mxser_initbrd will hook ISR. */ 797 /* mxser_initbrd will hook ISR. */
854 if (mxser_initbrd(m, &hwconf) < 0) 798 if (mxser_initbrd(brd) < 0)
855 continue; 799 continue;
856 800
857 m++; 801 m++;
858 } 802 }
859 803
860 /* start finding PCI board here */ 804 /* start finding PCI board here */
861#ifdef CONFIG_PCI
862 n = ARRAY_SIZE(mxser_pcibrds) - 1; 805 n = ARRAY_SIZE(mxser_pcibrds) - 1;
863 index = 0;
864 b = 0; 806 b = 0;
865 while (b < n) { 807 while (b < n) {
866 pdev = pci_get_device(mxser_pcibrds[b].vendor, 808 pdev = pci_get_device(mxser_pcibrds[b].vendor,
@@ -869,13 +811,9 @@ static int mxser_init(void)
869 b++; 811 b++;
870 continue; 812 continue;
871 } 813 }
872 hwconf.pciInfo.busNum = busnum = pdev->bus->number;
873 hwconf.pciInfo.devNum = devnum = PCI_SLOT(pdev->devfn) << 3;
874 hwconf.pciInfo.pdev = pdev;
875 printk(KERN_INFO "Found MOXA %s board(BusNo=%d,DevNo=%d)\n", 814 printk(KERN_INFO "Found MOXA %s board(BusNo=%d,DevNo=%d)\n",
876 mxser_brdname[(int) (mxser_pcibrds[b].driver_data) - 1], 815 mxser_brdname[(int) (mxser_pcibrds[b].driver_data) - 1],
877 busnum, devnum >> 3); 816 pdev->bus->number, PCI_SLOT(pdev->devfn));
878 index++;
879 if (m >= MXSER_BOARDS) 817 if (m >= MXSER_BOARDS)
880 printk(KERN_ERR 818 printk(KERN_ERR
881 "Too many Smartio/Industio family boards find " 819 "Too many Smartio/Industio family boards find "
@@ -887,9 +825,11 @@ static int mxser_init(void)
887 "fail !\n"); 825 "fail !\n");
888 continue; 826 continue;
889 } 827 }
890 retval = mxser_get_PCI_conf(busnum, devnum, 828 brd = &mxser_boards[m];
829 brd->pdev = pdev;
830 retval = mxser_get_PCI_conf(
891 (int)mxser_pcibrds[b].driver_data, 831 (int)mxser_pcibrds[b].driver_data,
892 &hwconf); 832 brd, pdev);
893 if (retval < 0) { 833 if (retval < 0) {
894 if (retval == MXSER_ERR_IRQ) 834 if (retval == MXSER_ERR_IRQ)
895 printk(KERN_ERR 835 printk(KERN_ERR
@@ -909,12 +849,8 @@ static int mxser_init(void)
909 "board not configured\n"); 849 "board not configured\n");
910 continue; 850 continue;
911 } 851 }
912 mxser_getcfg(m, &hwconf);
913 /* init mxsercfg first,
914 * or mxsercfg data is not correct on ISR.
915 */
916 /* mxser_initbrd will hook ISR. */ 852 /* mxser_initbrd will hook ISR. */
917 if (mxser_initbrd(m, &hwconf) < 0) 853 if (mxser_initbrd(brd) < 0)
918 continue; 854 continue;
919 m++; 855 m++;
920 /* Keep an extra reference if we succeeded. It will 856 /* Keep an extra reference if we succeeded. It will
@@ -922,7 +858,6 @@ static int mxser_init(void)
922 pci_dev_get(pdev); 858 pci_dev_get(pdev);
923 } 859 }
924 } 860 }
925#endif
926 861
927 retval = tty_register_driver(mxvar_sdriver); 862 retval = tty_register_driver(mxvar_sdriver);
928 if (retval) { 863 if (retval) {
@@ -931,10 +866,10 @@ static int mxser_init(void)
931 put_tty_driver(mxvar_sdriver); 866 put_tty_driver(mxvar_sdriver);
932 867
933 for (i = 0; i < MXSER_BOARDS; i++) { 868 for (i = 0; i < MXSER_BOARDS; i++) {
934 if (mxsercfg[i].board_type == -1) 869 if (mxser_boards[i].board_type == -1)
935 continue; 870 continue;
936 else { 871 else {
937 free_irq(mxsercfg[i].irq, &mxvar_table[i * MXSER_PORTS_PER_BOARD]); 872 free_irq(mxser_boards[i].irq, &mxser_boards[i]);
938 /* todo: release io, vector */ 873 /* todo: release io, vector */
939 } 874 }
940 } 875 }
@@ -946,7 +881,7 @@ static int mxser_init(void)
946 881
947static void mxser_do_softint(void *private_) 882static void mxser_do_softint(void *private_)
948{ 883{
949 struct mxser_struct *info = private_; 884 struct mxser_port *info = private_;
950 struct tty_struct *tty; 885 struct tty_struct *tty;
951 886
952 tty = info->tty; 887 tty = info->tty;
@@ -957,7 +892,7 @@ static void mxser_do_softint(void *private_)
957 tty_hangup(tty); 892 tty_hangup(tty);
958} 893}
959 894
960static unsigned char mxser_get_msr(int baseaddr, int mode, int port, struct mxser_struct *info) 895static unsigned char mxser_get_msr(int baseaddr, int mode, int port)
961{ 896{
962 unsigned char status = 0; 897 unsigned char status = 0;
963 898
@@ -980,7 +915,7 @@ static unsigned char mxser_get_msr(int baseaddr, int mode, int port, struct mxse
980 */ 915 */
981static int mxser_open(struct tty_struct *tty, struct file *filp) 916static int mxser_open(struct tty_struct *tty, struct file *filp)
982{ 917{
983 struct mxser_struct *info; 918 struct mxser_port *info;
984 int retval, line; 919 int retval, line;
985 920
986 /* initialize driver_data in case something fails */ 921 /* initialize driver_data in case something fails */
@@ -991,8 +926,8 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
991 return 0; 926 return 0;
992 if (line < 0 || line > MXSER_PORTS) 927 if (line < 0 || line > MXSER_PORTS)
993 return -ENODEV; 928 return -ENODEV;
994 info = mxvar_table + line; 929 info = &mxser_boards[line / MXSER_PORTS_PER_BOARD].ports[line % MXSER_PORTS_PER_BOARD];
995 if (!info->base) 930 if (!info->ioaddr)
996 return -ENODEV; 931 return -ENODEV;
997 932
998 tty->driver_data = info; 933 tty->driver_data = info;
@@ -1038,7 +973,7 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
1038 */ 973 */
1039static void mxser_close(struct tty_struct *tty, struct file *filp) 974static void mxser_close(struct tty_struct *tty, struct file *filp)
1040{ 975{
1041 struct mxser_struct *info = tty->driver_data; 976 struct mxser_port *info = tty->driver_data;
1042 977
1043 unsigned long timeout; 978 unsigned long timeout;
1044 unsigned long flags; 979 unsigned long flags;
@@ -1069,7 +1004,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
1069 } 1004 }
1070 if (--info->count < 0) { 1005 if (--info->count < 0) {
1071 printk(KERN_ERR "mxser_close: bad serial port count for " 1006 printk(KERN_ERR "mxser_close: bad serial port count for "
1072 "ttys%d: %d\n", info->port, info->count); 1007 "ttys%d: %d\n", tty->index, info->count);
1073 info->count = 0; 1008 info->count = 0;
1074 } 1009 }
1075 if (info->count) { 1010 if (info->count) {
@@ -1098,20 +1033,20 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
1098 * line status register. 1033 * line status register.
1099 */ 1034 */
1100 info->IER &= ~UART_IER_RLSI; 1035 info->IER &= ~UART_IER_RLSI;
1101 if (info->IsMoxaMustChipFlag) 1036 if (info->board->chip_flag)
1102 info->IER &= ~MOXA_MUST_RECV_ISR; 1037 info->IER &= ~MOXA_MUST_RECV_ISR;
1103/* by William 1038/* by William
1104 info->read_status_mask &= ~UART_LSR_DR; 1039 info->read_status_mask &= ~UART_LSR_DR;
1105*/ 1040*/
1106 if (info->flags & ASYNC_INITIALIZED) { 1041 if (info->flags & ASYNC_INITIALIZED) {
1107 outb(info->IER, info->base + UART_IER); 1042 outb(info->IER, info->ioaddr + UART_IER);
1108 /* 1043 /*
1109 * Before we drop DTR, make sure the UART transmitter 1044 * Before we drop DTR, make sure the UART transmitter
1110 * has completely drained; this is especially 1045 * has completely drained; this is especially
1111 * important if there is a transmit FIFO! 1046 * important if there is a transmit FIFO!
1112 */ 1047 */
1113 timeout = jiffies + HZ; 1048 timeout = jiffies + HZ;
1114 while (!(inb(info->base + UART_LSR) & UART_LSR_TEMT)) { 1049 while (!(inb(info->ioaddr + UART_LSR) & UART_LSR_TEMT)) {
1115 schedule_timeout_interruptible(5); 1050 schedule_timeout_interruptible(5);
1116 if (time_after(jiffies, timeout)) 1051 if (time_after(jiffies, timeout))
1117 break; 1052 break;
@@ -1146,7 +1081,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
1146static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count) 1081static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count)
1147{ 1082{
1148 int c, total = 0; 1083 int c, total = 0;
1149 struct mxser_struct *info = tty->driver_data; 1084 struct mxser_port *info = tty->driver_data;
1150 unsigned long flags; 1085 unsigned long flags;
1151 1086
1152 if (!info->xmit_buf) 1087 if (!info->xmit_buf)
@@ -1174,11 +1109,12 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou
1174 /*&& !(info->IER & UART_IER_THRI)*/) { 1109 /*&& !(info->IER & UART_IER_THRI)*/) {
1175 if (!tty->hw_stopped || 1110 if (!tty->hw_stopped ||
1176 (info->type == PORT_16550A) || 1111 (info->type == PORT_16550A) ||
1177 (info->IsMoxaMustChipFlag)) { 1112 (info->board->chip_flag)) {
1178 spin_lock_irqsave(&info->slock, flags); 1113 spin_lock_irqsave(&info->slock, flags);
1179 outb(info->IER & ~UART_IER_THRI, info->base + UART_IER); 1114 outb(info->IER & ~UART_IER_THRI, info->ioaddr +
1115 UART_IER);
1180 info->IER |= UART_IER_THRI; 1116 info->IER |= UART_IER_THRI;
1181 outb(info->IER, info->base + UART_IER); 1117 outb(info->IER, info->ioaddr + UART_IER);
1182 spin_unlock_irqrestore(&info->slock, flags); 1118 spin_unlock_irqrestore(&info->slock, flags);
1183 } 1119 }
1184 } 1120 }
@@ -1187,7 +1123,7 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou
1187 1123
1188static void mxser_put_char(struct tty_struct *tty, unsigned char ch) 1124static void mxser_put_char(struct tty_struct *tty, unsigned char ch)
1189{ 1125{
1190 struct mxser_struct *info = tty->driver_data; 1126 struct mxser_port *info = tty->driver_data;
1191 unsigned long flags; 1127 unsigned long flags;
1192 1128
1193 if (!info->xmit_buf) 1129 if (!info->xmit_buf)
@@ -1204,11 +1140,11 @@ static void mxser_put_char(struct tty_struct *tty, unsigned char ch)
1204 if (!tty->stopped /*&& !(info->IER & UART_IER_THRI)*/) { 1140 if (!tty->stopped /*&& !(info->IER & UART_IER_THRI)*/) {
1205 if (!tty->hw_stopped || 1141 if (!tty->hw_stopped ||
1206 (info->type == PORT_16550A) || 1142 (info->type == PORT_16550A) ||
1207 info->IsMoxaMustChipFlag) { 1143 info->board->chip_flag) {
1208 spin_lock_irqsave(&info->slock, flags); 1144 spin_lock_irqsave(&info->slock, flags);
1209 outb(info->IER & ~UART_IER_THRI, info->base + UART_IER); 1145 outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER);
1210 info->IER |= UART_IER_THRI; 1146 info->IER |= UART_IER_THRI;
1211 outb(info->IER, info->base + UART_IER); 1147 outb(info->IER, info->ioaddr + UART_IER);
1212 spin_unlock_irqrestore(&info->slock, flags); 1148 spin_unlock_irqrestore(&info->slock, flags);
1213 } 1149 }
1214 } 1150 }
@@ -1217,7 +1153,7 @@ static void mxser_put_char(struct tty_struct *tty, unsigned char ch)
1217 1153
1218static void mxser_flush_chars(struct tty_struct *tty) 1154static void mxser_flush_chars(struct tty_struct *tty)
1219{ 1155{
1220 struct mxser_struct *info = tty->driver_data; 1156 struct mxser_port *info = tty->driver_data;
1221 unsigned long flags; 1157 unsigned long flags;
1222 1158
1223 if (info->xmit_cnt <= 0 || 1159 if (info->xmit_cnt <= 0 ||
@@ -1225,22 +1161,22 @@ static void mxser_flush_chars(struct tty_struct *tty)
1225 !info->xmit_buf || 1161 !info->xmit_buf ||
1226 (tty->hw_stopped && 1162 (tty->hw_stopped &&
1227 (info->type != PORT_16550A) && 1163 (info->type != PORT_16550A) &&
1228 (!info->IsMoxaMustChipFlag) 1164 (!info->board->chip_flag)
1229 )) 1165 ))
1230 return; 1166 return;
1231 1167
1232 spin_lock_irqsave(&info->slock, flags); 1168 spin_lock_irqsave(&info->slock, flags);
1233 1169
1234 outb(info->IER & ~UART_IER_THRI, info->base + UART_IER); 1170 outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER);
1235 info->IER |= UART_IER_THRI; 1171 info->IER |= UART_IER_THRI;
1236 outb(info->IER, info->base + UART_IER); 1172 outb(info->IER, info->ioaddr + UART_IER);
1237 1173
1238 spin_unlock_irqrestore(&info->slock, flags); 1174 spin_unlock_irqrestore(&info->slock, flags);
1239} 1175}
1240 1176
1241static int mxser_write_room(struct tty_struct *tty) 1177static int mxser_write_room(struct tty_struct *tty)
1242{ 1178{
1243 struct mxser_struct *info = tty->driver_data; 1179 struct mxser_port *info = tty->driver_data;
1244 int ret; 1180 int ret;
1245 1181
1246 ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1; 1182 ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
@@ -1251,10 +1187,10 @@ static int mxser_write_room(struct tty_struct *tty)
1251 1187
1252static int mxser_chars_in_buffer(struct tty_struct *tty) 1188static int mxser_chars_in_buffer(struct tty_struct *tty)
1253{ 1189{
1254 struct mxser_struct *info = tty->driver_data; 1190 struct mxser_port *info = tty->driver_data;
1255 int len = info->xmit_cnt; 1191 int len = info->xmit_cnt;
1256 1192
1257 if (!(inb(info->base + UART_LSR) & UART_LSR_THRE)) 1193 if (!(inb(info->ioaddr + UART_LSR) & UART_LSR_THRE))
1258 len++; 1194 len++;
1259 1195
1260 return len; 1196 return len;
@@ -1262,7 +1198,7 @@ static int mxser_chars_in_buffer(struct tty_struct *tty)
1262 1198
1263static void mxser_flush_buffer(struct tty_struct *tty) 1199static void mxser_flush_buffer(struct tty_struct *tty)
1264{ 1200{
1265 struct mxser_struct *info = tty->driver_data; 1201 struct mxser_port *info = tty->driver_data;
1266 char fcr; 1202 char fcr;
1267 unsigned long flags; 1203 unsigned long flags;
1268 1204
@@ -1271,10 +1207,10 @@ static void mxser_flush_buffer(struct tty_struct *tty)
1271 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 1207 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
1272 1208
1273 /* below added by shinhay */ 1209 /* below added by shinhay */
1274 fcr = inb(info->base + UART_FCR); 1210 fcr = inb(info->ioaddr + UART_FCR);
1275 outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), 1211 outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
1276 info->base + UART_FCR); 1212 info->ioaddr + UART_FCR);
1277 outb(fcr, info->base + UART_FCR); 1213 outb(fcr, info->ioaddr + UART_FCR);
1278 1214
1279 spin_unlock_irqrestore(&info->slock, flags); 1215 spin_unlock_irqrestore(&info->slock, flags);
1280 /* above added by shinhay */ 1216 /* above added by shinhay */
@@ -1286,7 +1222,7 @@ static void mxser_flush_buffer(struct tty_struct *tty)
1286 1222
1287static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) 1223static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
1288{ 1224{
1289 struct mxser_struct *info = tty->driver_data; 1225 struct mxser_port *info = tty->driver_data;
1290 int retval; 1226 int retval;
1291 struct async_icount cprev, cnow; /* kernel counter temps */ 1227 struct async_icount cprev, cnow; /* kernel counter temps */
1292 struct serial_icounter_struct __user *p_cuser; 1228 struct serial_icounter_struct __user *p_cuser;
@@ -1305,7 +1241,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1305 int shiftbit; 1241 int shiftbit;
1306 unsigned char val, mask; 1242 unsigned char val, mask;
1307 1243
1308 p = info->port % 4; 1244 p = tty->index % 4;
1309 if (cmd == MOXA_SET_OP_MODE) { 1245 if (cmd == MOXA_SET_OP_MODE) {
1310 if (get_user(opmode, (int __user *) argp)) 1246 if (get_user(opmode, (int __user *) argp))
1311 return -EFAULT; 1247 return -EFAULT;
@@ -1465,7 +1401,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1465 1401
1466 len = mxser_chars_in_buffer(tty); 1402 len = mxser_chars_in_buffer(tty);
1467 1403
1468 lsr = inb(info->base + UART_LSR) & UART_LSR_TEMT; 1404 lsr = inb(info->ioaddr + UART_LSR) & UART_LSR_TEMT;
1469 1405
1470 len += (lsr ? 0 : 1); 1406 len += (lsr ? 0 : 1);
1471 1407
@@ -1479,10 +1415,10 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1479 1415
1480 /* info->mon_data.ser_param = tty->termios->c_cflag; */ 1416 /* info->mon_data.ser_param = tty->termios->c_cflag; */
1481 1417
1482 status = mxser_get_msr(info->base, 1, info->port, info); 1418 status = mxser_get_msr(info->ioaddr, 1, tty->index);
1483 mxser_check_modem_status(info, status); 1419 mxser_check_modem_status(info, status);
1484 1420
1485 mcr = inb(info->base + UART_MCR); 1421 mcr = inb(info->ioaddr + UART_MCR);
1486 if (mcr & MOXA_MUST_MCR_XON_FLAG) 1422 if (mcr & MOXA_MUST_MCR_XON_FLAG)
1487 info->mon_data.hold_reason &= ~NPPI_NOTIFY_XOFFHOLD; 1423 info->mon_data.hold_reason &= ~NPPI_NOTIFY_XOFFHOLD;
1488 else 1424 else
@@ -1518,7 +1454,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1518 1454
1519 if (get_user(method, (int __user *)argp)) 1455 if (get_user(method, (int __user *)argp))
1520 return -EFAULT; 1456 return -EFAULT;
1521 mxser_set_baud_method[info->port] = method; 1457 mxser_set_baud_method[tty->index] = method;
1522 if (copy_to_user(argp, &method, sizeof(int))) 1458 if (copy_to_user(argp, &method, sizeof(int)))
1523 return -EFAULT; 1459 return -EFAULT;
1524 1460
@@ -1536,14 +1472,17 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1536 1472
1537static int mxser_ioctl_special(unsigned int cmd, void __user *argp) 1473static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1538{ 1474{
1539 int i, result, status; 1475 struct mxser_port *port;
1476 int result, status;
1477 unsigned int i, j;
1540 1478
1541 switch (cmd) { 1479 switch (cmd) {
1542 case MOXA_GET_CONF: 1480 case MOXA_GET_CONF:
1543 if (copy_to_user(argp, mxsercfg, 1481/* if (copy_to_user(argp, mxsercfg,
1544 sizeof(struct mxser_hwconf) * 4)) 1482 sizeof(struct mxser_hwconf) * 4))
1545 return -EFAULT; 1483 return -EFAULT;
1546 return 0; 1484 return 0;*/
1485 return -ENXIO;
1547 case MOXA_GET_MAJOR: 1486 case MOXA_GET_MAJOR:
1548 if (copy_to_user(argp, &ttymajor, sizeof(int))) 1487 if (copy_to_user(argp, &ttymajor, sizeof(int)))
1549 return -EFAULT; 1488 return -EFAULT;
@@ -1556,96 +1495,106 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1556 1495
1557 case MOXA_CHKPORTENABLE: 1496 case MOXA_CHKPORTENABLE:
1558 result = 0; 1497 result = 0;
1559 for (i = 0; i < MXSER_PORTS; i++) { 1498
1560 if (mxvar_table[i].base) 1499 for (i = 0; i < MXSER_BOARDS; i++)
1561 result |= (1 << i); 1500 for (j = 0; j < MXSER_PORTS_PER_BOARD; j++)
1562 } 1501 if (mxser_boards[i].ports[j].ioaddr)
1502 result |= (1 << i);
1503
1563 return put_user(result, (unsigned long __user *)argp); 1504 return put_user(result, (unsigned long __user *)argp);
1564 case MOXA_GETDATACOUNT: 1505 case MOXA_GETDATACOUNT:
1565 if (copy_to_user(argp, &mxvar_log, sizeof(mxvar_log))) 1506 if (copy_to_user(argp, &mxvar_log, sizeof(mxvar_log)))
1566 return -EFAULT; 1507 return -EFAULT;
1567 return 0; 1508 return 0;
1568 case MOXA_GETMSTATUS: 1509 case MOXA_GETMSTATUS:
1569 for (i = 0; i < MXSER_PORTS; i++) { 1510 for (i = 0; i < MXSER_BOARDS; i++)
1570 GMStatus[i].ri = 0; 1511 for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) {
1571 if (!mxvar_table[i].base) { 1512 port = &mxser_boards[i].ports[j];
1572 GMStatus[i].dcd = 0; 1513
1573 GMStatus[i].dsr = 0; 1514 GMStatus[i].ri = 0;
1574 GMStatus[i].cts = 0; 1515 if (!port->ioaddr) {
1575 continue; 1516 GMStatus[i].dcd = 0;
1576 } 1517 GMStatus[i].dsr = 0;
1518 GMStatus[i].cts = 0;
1519 continue;
1520 }
1577 1521
1578 if (!mxvar_table[i].tty || !mxvar_table[i].tty->termios) 1522 if (!port->tty || !port->tty->termios)
1579 GMStatus[i].cflag = mxvar_table[i].normal_termios.c_cflag; 1523 GMStatus[i].cflag =
1580 else 1524 port->normal_termios.c_cflag;
1581 GMStatus[i].cflag = mxvar_table[i].tty->termios->c_cflag; 1525 else
1526 GMStatus[i].cflag =
1527 port->tty->termios->c_cflag;
1582 1528
1583 status = inb(mxvar_table[i].base + UART_MSR); 1529 status = inb(port->ioaddr + UART_MSR);
1584 if (status & 0x80 /*UART_MSR_DCD */ ) 1530 if (status & 0x80 /*UART_MSR_DCD */ )
1585 GMStatus[i].dcd = 1; 1531 GMStatus[i].dcd = 1;
1586 else 1532 else
1587 GMStatus[i].dcd = 0; 1533 GMStatus[i].dcd = 0;
1588 1534
1589 if (status & 0x20 /*UART_MSR_DSR */ ) 1535 if (status & 0x20 /*UART_MSR_DSR */ )
1590 GMStatus[i].dsr = 1; 1536 GMStatus[i].dsr = 1;
1591 else 1537 else
1592 GMStatus[i].dsr = 0; 1538 GMStatus[i].dsr = 0;
1593 1539
1594 1540
1595 if (status & 0x10 /*UART_MSR_CTS */ ) 1541 if (status & 0x10 /*UART_MSR_CTS */ )
1596 GMStatus[i].cts = 1; 1542 GMStatus[i].cts = 1;
1597 else 1543 else
1598 GMStatus[i].cts = 0; 1544 GMStatus[i].cts = 0;
1599 } 1545 }
1600 if (copy_to_user(argp, GMStatus, 1546 if (copy_to_user(argp, GMStatus,
1601 sizeof(struct mxser_mstatus) * MXSER_PORTS)) 1547 sizeof(struct mxser_mstatus) * MXSER_PORTS))
1602 return -EFAULT; 1548 return -EFAULT;
1603 return 0; 1549 return 0;
1604 case MOXA_ASPP_MON_EXT: { 1550 case MOXA_ASPP_MON_EXT: {
1605 int status, p, shiftbit; 1551 int status, p, shiftbit;
1606 unsigned long opmode; 1552 unsigned long opmode;
1607 unsigned cflag, iflag; 1553 unsigned cflag, iflag;
1608 1554
1609 for (i = 0; i < MXSER_PORTS; i++) { 1555 for (i = 0; i < MXSER_BOARDS; i++)
1610 if (!mxvar_table[i].base) 1556 for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) {
1557 port = &mxser_boards[i].ports[j];
1558 if (!port->ioaddr)
1611 continue; 1559 continue;
1612 1560
1613 status = mxser_get_msr(mxvar_table[i].base, 0, 1561 status = mxser_get_msr(port->ioaddr, 0, i);
1614 i, &(mxvar_table[i])); 1562/* mxser_check_modem_status(port, status); */
1615 /* 1563
1616 mxser_check_modem_status(&mxvar_table[i],
1617 status);
1618 */
1619 if (status & UART_MSR_TERI) 1564 if (status & UART_MSR_TERI)
1620 mxvar_table[i].icount.rng++; 1565 port->icount.rng++;
1621 if (status & UART_MSR_DDSR) 1566 if (status & UART_MSR_DDSR)
1622 mxvar_table[i].icount.dsr++; 1567 port->icount.dsr++;
1623 if (status & UART_MSR_DDCD) 1568 if (status & UART_MSR_DDCD)
1624 mxvar_table[i].icount.dcd++; 1569 port->icount.dcd++;
1625 if (status & UART_MSR_DCTS) 1570 if (status & UART_MSR_DCTS)
1626 mxvar_table[i].icount.cts++; 1571 port->icount.cts++;
1627 1572
1628 mxvar_table[i].mon_data.modem_status = status; 1573 port->mon_data.modem_status = status;
1629 mon_data_ext.rx_cnt[i] = mxvar_table[i].mon_data.rxcnt; 1574 mon_data_ext.rx_cnt[i] = port->mon_data.rxcnt;
1630 mon_data_ext.tx_cnt[i] = mxvar_table[i].mon_data.txcnt; 1575 mon_data_ext.tx_cnt[i] = port->mon_data.txcnt;
1631 mon_data_ext.up_rxcnt[i] = mxvar_table[i].mon_data.up_rxcnt; 1576 mon_data_ext.up_rxcnt[i] =
1632 mon_data_ext.up_txcnt[i] = mxvar_table[i].mon_data.up_txcnt; 1577 port->mon_data.up_rxcnt;
1633 mon_data_ext.modem_status[i] = mxvar_table[i].mon_data.modem_status; 1578 mon_data_ext.up_txcnt[i] =
1634 mon_data_ext.baudrate[i] = mxvar_table[i].realbaud; 1579 port->mon_data.up_txcnt;
1635 1580 mon_data_ext.modem_status[i] =
1636 if (!mxvar_table[i].tty || !mxvar_table[i].tty->termios) { 1581 port->mon_data.modem_status;
1637 cflag = mxvar_table[i].normal_termios.c_cflag; 1582 mon_data_ext.baudrate[i] = port->realbaud;
1638 iflag = mxvar_table[i].normal_termios.c_iflag; 1583
1584 if (!port->tty || !port->tty->termios) {
1585 cflag = port->normal_termios.c_cflag;
1586 iflag = port->normal_termios.c_iflag;
1639 } else { 1587 } else {
1640 cflag = mxvar_table[i].tty->termios->c_cflag; 1588 cflag = port->tty->termios->c_cflag;
1641 iflag = mxvar_table[i].tty->termios->c_iflag; 1589 iflag = port->tty->termios->c_iflag;
1642 } 1590 }
1643 1591
1644 mon_data_ext.databits[i] = cflag & CSIZE; 1592 mon_data_ext.databits[i] = cflag & CSIZE;
1645 1593
1646 mon_data_ext.stopbits[i] = cflag & CSTOPB; 1594 mon_data_ext.stopbits[i] = cflag & CSTOPB;
1647 1595
1648 mon_data_ext.parity[i] = cflag & (PARENB | PARODD | CMSPAR); 1596 mon_data_ext.parity[i] =
1597 cflag & (PARENB | PARODD | CMSPAR);
1649 1598
1650 mon_data_ext.flowctrl[i] = 0x00; 1599 mon_data_ext.flowctrl[i] = 0x00;
1651 1600
@@ -1655,26 +1604,26 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1655 if (iflag & (IXON | IXOFF)) 1604 if (iflag & (IXON | IXOFF))
1656 mon_data_ext.flowctrl[i] |= 0x0C; 1605 mon_data_ext.flowctrl[i] |= 0x0C;
1657 1606
1658 if (mxvar_table[i].type == PORT_16550A) 1607 if (port->type == PORT_16550A)
1659 mon_data_ext.fifo[i] = 1; 1608 mon_data_ext.fifo[i] = 1;
1660 else 1609 else
1661 mon_data_ext.fifo[i] = 0; 1610 mon_data_ext.fifo[i] = 0;
1662 1611
1663 p = i % 4; 1612 p = i % 4;
1664 shiftbit = p * 2; 1613 shiftbit = p * 2;
1665 opmode = inb(mxvar_table[i].opmode_ioaddr) >> shiftbit; 1614 opmode = inb(port->opmode_ioaddr) >> shiftbit;
1666 opmode &= OP_MODE_MASK; 1615 opmode &= OP_MODE_MASK;
1667 1616
1668 mon_data_ext.iftype[i] = opmode; 1617 mon_data_ext.iftype[i] = opmode;
1669 1618
1670 } 1619 }
1671 if (copy_to_user(argp, &mon_data_ext, sizeof(struct mxser_mon_ext))) 1620 if (copy_to_user(argp, &mon_data_ext,
1621 sizeof(mon_data_ext)))
1672 return -EFAULT; 1622 return -EFAULT;
1673 1623
1674 return 0; 1624 return 0;
1675 1625
1676 } 1626 } default:
1677 default:
1678 return -ENOIOCTLCMD; 1627 return -ENOIOCTLCMD;
1679 } 1628 }
1680 return 0; 1629 return 0;
@@ -1682,31 +1631,31 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1682 1631
1683static void mxser_stoprx(struct tty_struct *tty) 1632static void mxser_stoprx(struct tty_struct *tty)
1684{ 1633{
1685 struct mxser_struct *info = tty->driver_data; 1634 struct mxser_port *info = tty->driver_data;
1686 1635
1687 info->ldisc_stop_rx = 1; 1636 info->ldisc_stop_rx = 1;
1688 if (I_IXOFF(tty)) { 1637 if (I_IXOFF(tty)) {
1689 /* following add by Victor Yu. 09-02-2002 */ 1638 /* following add by Victor Yu. 09-02-2002 */
1690 if (info->IsMoxaMustChipFlag) { 1639 if (info->board->chip_flag) {
1691 info->IER &= ~MOXA_MUST_RECV_ISR; 1640 info->IER &= ~MOXA_MUST_RECV_ISR;
1692 outb(info->IER, info->base + UART_IER); 1641 outb(info->IER, info->ioaddr + UART_IER);
1693 } else if (!(info->flags & ASYNC_CLOSING)) { 1642 } else if (!(info->flags & ASYNC_CLOSING)) {
1694 info->x_char = STOP_CHAR(tty); 1643 info->x_char = STOP_CHAR(tty);
1695 outb(0, info->base + UART_IER); 1644 outb(0, info->ioaddr + UART_IER);
1696 info->IER |= UART_IER_THRI; 1645 info->IER |= UART_IER_THRI;
1697 outb(info->IER, info->base + UART_IER); 1646 outb(info->IER, info->ioaddr + UART_IER);
1698 } 1647 }
1699 } 1648 }
1700 1649
1701 if (info->tty->termios->c_cflag & CRTSCTS) { 1650 if (info->tty->termios->c_cflag & CRTSCTS) {
1702 info->MCR &= ~UART_MCR_RTS; 1651 info->MCR &= ~UART_MCR_RTS;
1703 outb(info->MCR, info->base + UART_MCR); 1652 outb(info->MCR, info->ioaddr + UART_MCR);
1704 } 1653 }
1705} 1654}
1706 1655
1707static void mxser_startrx(struct tty_struct *tty) 1656static void mxser_startrx(struct tty_struct *tty)
1708{ 1657{
1709 struct mxser_struct *info = tty->driver_data; 1658 struct mxser_port *info = tty->driver_data;
1710 1659
1711 info->ldisc_stop_rx = 0; 1660 info->ldisc_stop_rx = 0;
1712 if (I_IXOFF(tty)) { 1661 if (I_IXOFF(tty)) {
@@ -1714,21 +1663,21 @@ static void mxser_startrx(struct tty_struct *tty)
1714 info->x_char = 0; 1663 info->x_char = 0;
1715 else { 1664 else {
1716 /* following add by Victor Yu. 09-02-2002 */ 1665 /* following add by Victor Yu. 09-02-2002 */
1717 if (info->IsMoxaMustChipFlag) { 1666 if (info->board->chip_flag) {
1718 info->IER |= MOXA_MUST_RECV_ISR; 1667 info->IER |= MOXA_MUST_RECV_ISR;
1719 outb(info->IER, info->base + UART_IER); 1668 outb(info->IER, info->ioaddr + UART_IER);
1720 } else if (!(info->flags & ASYNC_CLOSING)) { 1669 } else if (!(info->flags & ASYNC_CLOSING)) {
1721 info->x_char = START_CHAR(tty); 1670 info->x_char = START_CHAR(tty);
1722 outb(0, info->base + UART_IER); 1671 outb(0, info->ioaddr + UART_IER);
1723 info->IER |= UART_IER_THRI; 1672 info->IER |= UART_IER_THRI;
1724 outb(info->IER, info->base + UART_IER); 1673 outb(info->IER, info->ioaddr + UART_IER);
1725 } 1674 }
1726 } 1675 }
1727 } 1676 }
1728 1677
1729 if (info->tty->termios->c_cflag & CRTSCTS) { 1678 if (info->tty->termios->c_cflag & CRTSCTS) {
1730 info->MCR |= UART_MCR_RTS; 1679 info->MCR |= UART_MCR_RTS;
1731 outb(info->MCR, info->base + UART_MCR); 1680 outb(info->MCR, info->ioaddr + UART_MCR);
1732 } 1681 }
1733} 1682}
1734 1683
@@ -1738,7 +1687,7 @@ static void mxser_startrx(struct tty_struct *tty)
1738 */ 1687 */
1739static void mxser_throttle(struct tty_struct *tty) 1688static void mxser_throttle(struct tty_struct *tty)
1740{ 1689{
1741 struct mxser_struct *info = tty->driver_data; 1690 struct mxser_port *info = tty->driver_data;
1742 unsigned long flags; 1691 unsigned long flags;
1743 1692
1744 spin_lock_irqsave(&info->slock, flags); 1693 spin_lock_irqsave(&info->slock, flags);
@@ -1748,7 +1697,7 @@ static void mxser_throttle(struct tty_struct *tty)
1748 1697
1749static void mxser_unthrottle(struct tty_struct *tty) 1698static void mxser_unthrottle(struct tty_struct *tty)
1750{ 1699{
1751 struct mxser_struct *info = tty->driver_data; 1700 struct mxser_port *info = tty->driver_data;
1752 unsigned long flags; 1701 unsigned long flags;
1753 1702
1754 spin_lock_irqsave(&info->slock, flags); 1703 spin_lock_irqsave(&info->slock, flags);
@@ -1758,7 +1707,7 @@ static void mxser_unthrottle(struct tty_struct *tty)
1758 1707
1759static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termios) 1708static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termios)
1760{ 1709{
1761 struct mxser_struct *info = tty->driver_data; 1710 struct mxser_port *info = tty->driver_data;
1762 unsigned long flags; 1711 unsigned long flags;
1763 1712
1764 if ((tty->termios->c_cflag != old_termios->c_cflag) || 1713 if ((tty->termios->c_cflag != old_termios->c_cflag) ||
@@ -1779,9 +1728,9 @@ static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termio
1779 tty->stopped = 0; 1728 tty->stopped = 0;
1780 1729
1781 /* following add by Victor Yu. 09-02-2002 */ 1730 /* following add by Victor Yu. 09-02-2002 */
1782 if (info->IsMoxaMustChipFlag) { 1731 if (info->board->chip_flag) {
1783 spin_lock_irqsave(&info->slock, flags); 1732 spin_lock_irqsave(&info->slock, flags);
1784 DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->base); 1733 DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->ioaddr);
1785 spin_unlock_irqrestore(&info->slock, flags); 1734 spin_unlock_irqrestore(&info->slock, flags);
1786 } 1735 }
1787 /* above add by Victor Yu. 09-02-2002 */ 1736 /* above add by Victor Yu. 09-02-2002 */
@@ -1798,28 +1747,28 @@ static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termio
1798 */ 1747 */
1799static void mxser_stop(struct tty_struct *tty) 1748static void mxser_stop(struct tty_struct *tty)
1800{ 1749{
1801 struct mxser_struct *info = tty->driver_data; 1750 struct mxser_port *info = tty->driver_data;
1802 unsigned long flags; 1751 unsigned long flags;
1803 1752
1804 spin_lock_irqsave(&info->slock, flags); 1753 spin_lock_irqsave(&info->slock, flags);
1805 if (info->IER & UART_IER_THRI) { 1754 if (info->IER & UART_IER_THRI) {
1806 info->IER &= ~UART_IER_THRI; 1755 info->IER &= ~UART_IER_THRI;
1807 outb(info->IER, info->base + UART_IER); 1756 outb(info->IER, info->ioaddr + UART_IER);
1808 } 1757 }
1809 spin_unlock_irqrestore(&info->slock, flags); 1758 spin_unlock_irqrestore(&info->slock, flags);
1810} 1759}
1811 1760
1812static void mxser_start(struct tty_struct *tty) 1761static void mxser_start(struct tty_struct *tty)
1813{ 1762{
1814 struct mxser_struct *info = tty->driver_data; 1763 struct mxser_port *info = tty->driver_data;
1815 unsigned long flags; 1764 unsigned long flags;
1816 1765
1817 spin_lock_irqsave(&info->slock, flags); 1766 spin_lock_irqsave(&info->slock, flags);
1818 if (info->xmit_cnt && info->xmit_buf 1767 if (info->xmit_cnt && info->xmit_buf
1819 /* && !(info->IER & UART_IER_THRI) */) { 1768 /* && !(info->IER & UART_IER_THRI) */) {
1820 outb(info->IER & ~UART_IER_THRI, info->base + UART_IER); 1769 outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER);
1821 info->IER |= UART_IER_THRI; 1770 info->IER |= UART_IER_THRI;
1822 outb(info->IER, info->base + UART_IER); 1771 outb(info->IER, info->ioaddr + UART_IER);
1823 } 1772 }
1824 spin_unlock_irqrestore(&info->slock, flags); 1773 spin_unlock_irqrestore(&info->slock, flags);
1825} 1774}
@@ -1829,7 +1778,7 @@ static void mxser_start(struct tty_struct *tty)
1829 */ 1778 */
1830static void mxser_wait_until_sent(struct tty_struct *tty, int timeout) 1779static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
1831{ 1780{
1832 struct mxser_struct *info = tty->driver_data; 1781 struct mxser_port *info = tty->driver_data;
1833 unsigned long orig_jiffies, char_time; 1782 unsigned long orig_jiffies, char_time;
1834 int lsr; 1783 int lsr;
1835 1784
@@ -1870,7 +1819,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
1870 timeout, char_time); 1819 timeout, char_time);
1871 printk("jiff=%lu...", jiffies); 1820 printk("jiff=%lu...", jiffies);
1872#endif 1821#endif
1873 while (!((lsr = inb(info->base + UART_LSR)) & UART_LSR_TEMT)) { 1822 while (!((lsr = inb(info->ioaddr + UART_LSR)) & UART_LSR_TEMT)) {
1874#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT 1823#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
1875 printk("lsr = %d (jiff=%lu)...", lsr, jiffies); 1824 printk("lsr = %d (jiff=%lu)...", lsr, jiffies);
1876#endif 1825#endif
@@ -1893,7 +1842,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
1893 */ 1842 */
1894void mxser_hangup(struct tty_struct *tty) 1843void mxser_hangup(struct tty_struct *tty)
1895{ 1844{
1896 struct mxser_struct *info = tty->driver_data; 1845 struct mxser_port *info = tty->driver_data;
1897 1846
1898 mxser_flush_buffer(tty); 1847 mxser_flush_buffer(tty);
1899 mxser_shutdown(info); 1848 mxser_shutdown(info);
@@ -1911,16 +1860,16 @@ void mxser_hangup(struct tty_struct *tty)
1911 */ 1860 */
1912static void mxser_rs_break(struct tty_struct *tty, int break_state) 1861static void mxser_rs_break(struct tty_struct *tty, int break_state)
1913{ 1862{
1914 struct mxser_struct *info = tty->driver_data; 1863 struct mxser_port *info = tty->driver_data;
1915 unsigned long flags; 1864 unsigned long flags;
1916 1865
1917 spin_lock_irqsave(&info->slock, flags); 1866 spin_lock_irqsave(&info->slock, flags);
1918 if (break_state == -1) 1867 if (break_state == -1)
1919 outb(inb(info->base + UART_LCR) | UART_LCR_SBC, 1868 outb(inb(info->ioaddr + UART_LCR) | UART_LCR_SBC,
1920 info->base + UART_LCR); 1869 info->ioaddr + UART_LCR);
1921 else 1870 else
1922 outb(inb(info->base + UART_LCR) & ~UART_LCR_SBC, 1871 outb(inb(info->ioaddr + UART_LCR) & ~UART_LCR_SBC,
1923 info->base + UART_LCR); 1872 info->ioaddr + UART_LCR);
1924 spin_unlock_irqrestore(&info->slock, flags); 1873 spin_unlock_irqrestore(&info->slock, flags);
1925} 1874}
1926 1875
@@ -1933,74 +1882,72 @@ static void mxser_rs_break(struct tty_struct *tty, int break_state)
1933static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs) 1882static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1934{ 1883{
1935 int status, iir, i; 1884 int status, iir, i;
1936 struct mxser_struct *info; 1885 struct mxser_board *brd = NULL;
1937 struct mxser_struct *port; 1886 struct mxser_port *port;
1938 int max, irqbits, bits, msr; 1887 int max, irqbits, bits, msr;
1939 int pass_counter = 0; 1888 int pass_counter = 0;
1940 unsigned int int_cnt; 1889 unsigned int int_cnt;
1941 int handled = IRQ_NONE; 1890 int handled = IRQ_NONE;
1942 1891
1943 port = NULL;
1944 /* spin_lock(&gm_lock); */ 1892 /* spin_lock(&gm_lock); */
1945 1893
1946 for (i = 0; i < MXSER_BOARDS; i++) { 1894 for (i = 0; i < MXSER_BOARDS; i++)
1947 if (dev_id == &(mxvar_table[i * MXSER_PORTS_PER_BOARD])) { 1895 if (dev_id == &mxser_boards[i]) {
1948 port = dev_id; 1896 brd = dev_id;
1949 break; 1897 break;
1950 } 1898 }
1951 }
1952 1899
1953 if (i == MXSER_BOARDS) 1900 if (i == MXSER_BOARDS)
1954 goto irq_stop; 1901 goto irq_stop;
1955 if (port == 0) 1902 if (brd == NULL)
1956 goto irq_stop; 1903 goto irq_stop;
1957 max = mxser_numports[mxsercfg[i].board_type - 1]; 1904 max = mxser_numports[brd->board_type - 1];
1958 while (1) { 1905 while (1) {
1959 irqbits = inb(port->vector) & port->vectormask; 1906 irqbits = inb(brd->vector) & brd->vector_mask;
1960 if (irqbits == port->vectormask) 1907 if (irqbits == brd->vector_mask)
1961 break; 1908 break;
1962 1909
1963 handled = IRQ_HANDLED; 1910 handled = IRQ_HANDLED;
1964 for (i = 0, bits = 1; i < max; i++, irqbits |= bits, bits <<= 1) { 1911 for (i = 0, bits = 1; i < max; i++, irqbits |= bits, bits <<= 1) {
1965 if (irqbits == port->vectormask) 1912 if (irqbits == brd->vector_mask)
1966 break; 1913 break;
1967 if (bits & irqbits) 1914 if (bits & irqbits)
1968 continue; 1915 continue;
1969 info = port + i; 1916 port = &brd->ports[i];
1970 1917
1971 int_cnt = 0; 1918 int_cnt = 0;
1972 do { 1919 do {
1973 /* following add by Victor Yu. 09-13-2002 */ 1920 /* following add by Victor Yu. 09-13-2002 */
1974 iir = inb(info->base + UART_IIR); 1921 iir = inb(port->ioaddr + UART_IIR);
1975 if (iir & UART_IIR_NO_INT) 1922 if (iir & UART_IIR_NO_INT)
1976 break; 1923 break;
1977 iir &= MOXA_MUST_IIR_MASK; 1924 iir &= MOXA_MUST_IIR_MASK;
1978 if (!info->tty) { 1925 if (!port->tty) {
1979 status = inb(info->base + UART_LSR); 1926 status = inb(port->ioaddr + UART_LSR);
1980 outb(0x27, info->base + UART_FCR); 1927 outb(0x27, port->ioaddr + UART_FCR);
1981 inb(info->base + UART_MSR); 1928 inb(port->ioaddr + UART_MSR);
1982 break; 1929 break;
1983 } 1930 }
1984 /* above add by Victor Yu. 09-13-2002 */ 1931 /* above add by Victor Yu. 09-13-2002 */
1985 1932
1986 spin_lock(&info->slock); 1933 spin_lock(&port->slock);
1987 /* following add by Victor Yu. 09-02-2002 */ 1934 /* following add by Victor Yu. 09-02-2002 */
1988 status = inb(info->base + UART_LSR); 1935 status = inb(port->ioaddr + UART_LSR);
1989 1936
1990 if (status & UART_LSR_PE) 1937 if (status & UART_LSR_PE)
1991 info->err_shadow |= NPPI_NOTIFY_PARITY; 1938 port->err_shadow |= NPPI_NOTIFY_PARITY;
1992 if (status & UART_LSR_FE) 1939 if (status & UART_LSR_FE)
1993 info->err_shadow |= NPPI_NOTIFY_FRAMING; 1940 port->err_shadow |= NPPI_NOTIFY_FRAMING;
1994 if (status & UART_LSR_OE) 1941 if (status & UART_LSR_OE)
1995 info->err_shadow |= 1942 port->err_shadow |=
1996 NPPI_NOTIFY_HW_OVERRUN; 1943 NPPI_NOTIFY_HW_OVERRUN;
1997 if (status & UART_LSR_BI) 1944 if (status & UART_LSR_BI)
1998 info->err_shadow |= NPPI_NOTIFY_BREAK; 1945 port->err_shadow |= NPPI_NOTIFY_BREAK;
1999 1946
2000 if (info->IsMoxaMustChipFlag) { 1947 if (port->board->chip_flag) {
2001 /* 1948 /*
2002 if ( (status & 0x02) && !(status & 0x01) ) { 1949 if ( (status & 0x02) && !(status & 0x01) ) {
2003 outb(info->base+UART_FCR, 0x23); 1950 outb(port->ioaddr+UART_FCR, 0x23);
2004 continue; 1951 continue;
2005 } 1952 }
2006 */ 1953 */
@@ -2008,33 +1955,33 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2008 iir == MOXA_MUST_IIR_RDA || 1955 iir == MOXA_MUST_IIR_RDA ||
2009 iir == MOXA_MUST_IIR_RTO || 1956 iir == MOXA_MUST_IIR_RTO ||
2010 iir == MOXA_MUST_IIR_LSR) 1957 iir == MOXA_MUST_IIR_LSR)
2011 mxser_receive_chars(info, 1958 mxser_receive_chars(port,
2012 &status); 1959 &status);
2013 1960
2014 } else { 1961 } else {
2015 /* above add by Victor Yu. 09-02-2002 */ 1962 /* above add by Victor Yu. 09-02-2002 */
2016 1963
2017 status &= info->read_status_mask; 1964 status &= port->read_status_mask;
2018 if (status & UART_LSR_DR) 1965 if (status & UART_LSR_DR)
2019 mxser_receive_chars(info, 1966 mxser_receive_chars(port,
2020 &status); 1967 &status);
2021 } 1968 }
2022 msr = inb(info->base + UART_MSR); 1969 msr = inb(port->ioaddr + UART_MSR);
2023 if (msr & UART_MSR_ANY_DELTA) 1970 if (msr & UART_MSR_ANY_DELTA)
2024 mxser_check_modem_status(info, msr); 1971 mxser_check_modem_status(port, msr);
2025 1972
2026 /* following add by Victor Yu. 09-13-2002 */ 1973 /* following add by Victor Yu. 09-13-2002 */
2027 if (info->IsMoxaMustChipFlag) { 1974 if (port->board->chip_flag) {
2028 if (iir == 0x02 && (status & 1975 if (iir == 0x02 && (status &
2029 UART_LSR_THRE)) 1976 UART_LSR_THRE))
2030 mxser_transmit_chars(info); 1977 mxser_transmit_chars(port);
2031 } else { 1978 } else {
2032 /* above add by Victor Yu. 09-13-2002 */ 1979 /* above add by Victor Yu. 09-13-2002 */
2033 1980
2034 if (status & UART_LSR_THRE) 1981 if (status & UART_LSR_THRE)
2035 mxser_transmit_chars(info); 1982 mxser_transmit_chars(port);
2036 } 1983 }
2037 spin_unlock(&info->slock); 1984 spin_unlock(&port->slock);
2038 } while (int_cnt++ < MXSER_ISR_PASS_LIMIT); 1985 } while (int_cnt++ < MXSER_ISR_PASS_LIMIT);
2039 } 1986 }
2040 if (pass_counter++ > MXSER_ISR_PASS_LIMIT) 1987 if (pass_counter++ > MXSER_ISR_PASS_LIMIT)
@@ -2046,9 +1993,9 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2046 return handled; 1993 return handled;
2047} 1994}
2048 1995
2049static void mxser_receive_chars(struct mxser_struct *info, int *status) 1996static void mxser_receive_chars(struct mxser_port *port, int *status)
2050{ 1997{
2051 struct tty_struct *tty = info->tty; 1998 struct tty_struct *tty = port->tty;
2052 unsigned char ch, gdl; 1999 unsigned char ch, gdl;
2053 int ignored = 0; 2000 int ignored = 0;
2054 int cnt = 0; 2001 int cnt = 0;
@@ -2056,42 +2003,42 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status)
2056 int max = 256; 2003 int max = 256;
2057 unsigned long flags; 2004 unsigned long flags;
2058 2005
2059 spin_lock_irqsave(&info->slock, flags); 2006 spin_lock_irqsave(&port->slock, flags);
2060 2007
2061 recv_room = tty->receive_room; 2008 recv_room = tty->receive_room;
2062 if ((recv_room == 0) && (!info->ldisc_stop_rx)) { 2009 if ((recv_room == 0) && (!port->ldisc_stop_rx)) {
2063 /* mxser_throttle(tty); */ 2010 /* mxser_throttle(tty); */
2064 mxser_stoprx(tty); 2011 mxser_stoprx(tty);
2065 /* return; */ 2012 /* return; */
2066 } 2013 }
2067 2014
2068 /* following add by Victor Yu. 09-02-2002 */ 2015 /* following add by Victor Yu. 09-02-2002 */
2069 if (info->IsMoxaMustChipFlag != MOXA_OTHER_UART) { 2016 if (port->board->chip_flag != MOXA_OTHER_UART) {
2070 2017
2071 if (*status & UART_LSR_SPECIAL) 2018 if (*status & UART_LSR_SPECIAL)
2072 goto intr_old; 2019 goto intr_old;
2073 /* following add by Victor Yu. 02-11-2004 */ 2020 /* following add by Victor Yu. 02-11-2004 */
2074 if (info->IsMoxaMustChipFlag == MOXA_MUST_MU860_HWID && 2021 if (port->board->chip_flag == MOXA_MUST_MU860_HWID &&
2075 (*status & MOXA_MUST_LSR_RERR)) 2022 (*status & MOXA_MUST_LSR_RERR))
2076 goto intr_old; 2023 goto intr_old;
2077 /* above add by Victor Yu. 02-14-2004 */ 2024 /* above add by Victor Yu. 02-14-2004 */
2078 if (*status & MOXA_MUST_LSR_RERR) 2025 if (*status & MOXA_MUST_LSR_RERR)
2079 goto intr_old; 2026 goto intr_old;
2080 2027
2081 gdl = inb(info->base + MOXA_MUST_GDL_REGISTER); 2028 gdl = inb(port->ioaddr + MOXA_MUST_GDL_REGISTER);
2082 2029
2083 /* add by Victor Yu. 02-11-2004 */ 2030 /* add by Victor Yu. 02-11-2004 */
2084 if (info->IsMoxaMustChipFlag == MOXA_MUST_MU150_HWID) 2031 if (port->board->chip_flag == MOXA_MUST_MU150_HWID)
2085 gdl &= MOXA_MUST_GDL_MASK; 2032 gdl &= MOXA_MUST_GDL_MASK;
2086 if (gdl >= recv_room) { 2033 if (gdl >= recv_room) {
2087 if (!info->ldisc_stop_rx) { 2034 if (!port->ldisc_stop_rx) {
2088 /* mxser_throttle(tty); */ 2035 /* mxser_throttle(tty); */
2089 mxser_stoprx(tty); 2036 mxser_stoprx(tty);
2090 } 2037 }
2091 /* return; */ 2038 /* return; */
2092 } 2039 }
2093 while (gdl--) { 2040 while (gdl--) {
2094 ch = inb(info->base + UART_RX); 2041 ch = inb(port->ioaddr + UART_RX);
2095 tty_insert_flip_char(tty, ch, 0); 2042 tty_insert_flip_char(tty, ch, 0);
2096 cnt++; 2043 cnt++;
2097 } 2044 }
@@ -2104,14 +2051,14 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status)
2104 if (max-- < 0) 2051 if (max-- < 0)
2105 break; 2052 break;
2106 2053
2107 ch = inb(info->base + UART_RX); 2054 ch = inb(port->ioaddr + UART_RX);
2108 /* following add by Victor Yu. 09-02-2002 */ 2055 /* following add by Victor Yu. 09-02-2002 */
2109 if (info->IsMoxaMustChipFlag && (*status & UART_LSR_OE) 2056 if (port->board->chip_flag && (*status & UART_LSR_OE)
2110 /*&& !(*status&UART_LSR_DR) */) 2057 /*&& !(*status&UART_LSR_DR) */)
2111 outb(0x23, info->base + UART_FCR); 2058 outb(0x23, port->ioaddr + UART_FCR);
2112 *status &= info->read_status_mask; 2059 *status &= port->read_status_mask;
2113 /* above add by Victor Yu. 09-02-2002 */ 2060 /* above add by Victor Yu. 09-02-2002 */
2114 if (*status & info->ignore_status_mask) { 2061 if (*status & port->ignore_status_mask) {
2115 if (++ignored > 100) 2062 if (++ignored > 100)
2116 break; 2063 break;
2117 } else { 2064 } else {
@@ -2120,22 +2067,22 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status)
2120 if (*status & UART_LSR_BI) { 2067 if (*status & UART_LSR_BI) {
2121 flag = TTY_BREAK; 2068 flag = TTY_BREAK;
2122/* added by casper 1/11/2000 */ 2069/* added by casper 1/11/2000 */
2123 info->icount.brk++; 2070 port->icount.brk++;
2124 2071
2125 if (info->flags & ASYNC_SAK) 2072 if (port->flags & ASYNC_SAK)
2126 do_SAK(tty); 2073 do_SAK(tty);
2127 } else if (*status & UART_LSR_PE) { 2074 } else if (*status & UART_LSR_PE) {
2128 flag = TTY_PARITY; 2075 flag = TTY_PARITY;
2129/* added by casper 1/11/2000 */ 2076/* added by casper 1/11/2000 */
2130 info->icount.parity++; 2077 port->icount.parity++;
2131 } else if (*status & UART_LSR_FE) { 2078 } else if (*status & UART_LSR_FE) {
2132 flag = TTY_FRAME; 2079 flag = TTY_FRAME;
2133/* added by casper 1/11/2000 */ 2080/* added by casper 1/11/2000 */
2134 info->icount.frame++; 2081 port->icount.frame++;
2135 } else if (*status & UART_LSR_OE) { 2082 } else if (*status & UART_LSR_OE) {
2136 flag = TTY_OVERRUN; 2083 flag = TTY_OVERRUN;
2137/* added by casper 1/11/2000 */ 2084/* added by casper 1/11/2000 */
2138 info->icount.overrun++; 2085 port->icount.overrun++;
2139 } else 2086 } else
2140 flags = TTY_BREAK; 2087 flags = TTY_BREAK;
2141 } else 2088 } else
@@ -2143,7 +2090,7 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status)
2143 tty_insert_flip_char(tty, ch, flag); 2090 tty_insert_flip_char(tty, ch, flag);
2144 cnt++; 2091 cnt++;
2145 if (cnt >= recv_room) { 2092 if (cnt >= recv_room) {
2146 if (!info->ldisc_stop_rx) { 2093 if (!port->ldisc_stop_rx) {
2147 /* mxser_throttle(tty); */ 2094 /* mxser_throttle(tty); */
2148 mxser_stoprx(tty); 2095 mxser_stoprx(tty);
2149 } 2096 }
@@ -2153,142 +2100,144 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status)
2153 } 2100 }
2154 2101
2155 /* following add by Victor Yu. 09-02-2002 */ 2102 /* following add by Victor Yu. 09-02-2002 */
2156 if (info->IsMoxaMustChipFlag) 2103 if (port->board->chip_flag)
2157 break; 2104 break;
2158 2105
2159 /* mask by Victor Yu. 09-02-2002 2106 /* mask by Victor Yu. 09-02-2002
2160 *status = inb(info->base + UART_LSR) & info->read_status_mask; 2107 *status = inb(port->ioaddr + UART_LSR) & port->read_status_mask;
2161 */ 2108 */
2162 /* following add by Victor Yu. 09-02-2002 */ 2109 /* following add by Victor Yu. 09-02-2002 */
2163 *status = inb(info->base + UART_LSR); 2110 *status = inb(port->ioaddr + UART_LSR);
2164 /* above add by Victor Yu. 09-02-2002 */ 2111 /* above add by Victor Yu. 09-02-2002 */
2165 } while (*status & UART_LSR_DR); 2112 } while (*status & UART_LSR_DR);
2166 2113
2167end_intr: /* add by Victor Yu. 09-02-2002 */ 2114end_intr: /* add by Victor Yu. 09-02-2002 */
2168 mxvar_log.rxcnt[info->port] += cnt; 2115 mxvar_log.rxcnt[port->tty->index] += cnt;
2169 info->mon_data.rxcnt += cnt; 2116 port->mon_data.rxcnt += cnt;
2170 info->mon_data.up_rxcnt += cnt; 2117 port->mon_data.up_rxcnt += cnt;
2171 spin_unlock_irqrestore(&info->slock, flags); 2118 spin_unlock_irqrestore(&port->slock, flags);
2172 2119
2173 tty_flip_buffer_push(tty); 2120 tty_flip_buffer_push(tty);
2174} 2121}
2175 2122
2176static void mxser_transmit_chars(struct mxser_struct *info) 2123static void mxser_transmit_chars(struct mxser_port *port)
2177{ 2124{
2178 int count, cnt; 2125 int count, cnt;
2179 unsigned long flags; 2126 unsigned long flags;
2180 2127
2181 spin_lock_irqsave(&info->slock, flags); 2128 spin_lock_irqsave(&port->slock, flags);
2182 2129
2183 if (info->x_char) { 2130 if (port->x_char) {
2184 outb(info->x_char, info->base + UART_TX); 2131 outb(port->x_char, port->ioaddr + UART_TX);
2185 info->x_char = 0; 2132 port->x_char = 0;
2186 mxvar_log.txcnt[info->port]++; 2133 mxvar_log.txcnt[port->tty->index]++;
2187 info->mon_data.txcnt++; 2134 port->mon_data.txcnt++;
2188 info->mon_data.up_txcnt++; 2135 port->mon_data.up_txcnt++;
2189 2136
2190/* added by casper 1/11/2000 */ 2137/* added by casper 1/11/2000 */
2191 info->icount.tx++; 2138 port->icount.tx++;
2192 goto unlock; 2139 goto unlock;
2193 } 2140 }
2194 2141
2195 if (info->xmit_buf == 0) 2142 if (port->xmit_buf == 0)
2196 goto unlock; 2143 goto unlock;
2197 2144
2198 if (info->xmit_cnt == 0) { 2145 if (port->xmit_cnt == 0) {
2199 if (info->xmit_cnt < WAKEUP_CHARS) { /* XXX what's this for?? */ 2146 if (port->xmit_cnt < WAKEUP_CHARS) { /* XXX what's this for?? */
2200 set_bit(MXSER_EVENT_TXLOW, &info->event); 2147 set_bit(MXSER_EVENT_TXLOW, &port->event);
2201 schedule_work(&info->tqueue); 2148 schedule_work(&port->tqueue);
2202 } 2149 }
2203 goto unlock; 2150 goto unlock;
2204 } 2151 }
2205 if (info->tty->stopped || (info->tty->hw_stopped && 2152 if (port->tty->stopped || (port->tty->hw_stopped &&
2206 (info->type != PORT_16550A) && 2153 (port->type != PORT_16550A) &&
2207 (!info->IsMoxaMustChipFlag))) { 2154 (!port->board->chip_flag))) {
2208 info->IER &= ~UART_IER_THRI; 2155 port->IER &= ~UART_IER_THRI;
2209 outb(info->IER, info->base + UART_IER); 2156 outb(port->IER, port->ioaddr + UART_IER);
2210 goto unlock; 2157 goto unlock;
2211 } 2158 }
2212 2159
2213 cnt = info->xmit_cnt; 2160 cnt = port->xmit_cnt;
2214 count = info->xmit_fifo_size; 2161 count = port->xmit_fifo_size;
2215 do { 2162 do {
2216 outb(info->xmit_buf[info->xmit_tail++], 2163 outb(port->xmit_buf[port->xmit_tail++],
2217 info->base + UART_TX); 2164 port->ioaddr + UART_TX);
2218 info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE - 1); 2165 port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE - 1);
2219 if (--info->xmit_cnt <= 0) 2166 if (--port->xmit_cnt <= 0)
2220 break; 2167 break;
2221 } while (--count > 0); 2168 } while (--count > 0);
2222 mxvar_log.txcnt[info->port] += (cnt - info->xmit_cnt); 2169 mxvar_log.txcnt[port->tty->index] += (cnt - port->xmit_cnt);
2223 2170
2224/* added by James 03-12-2004. */ 2171/* added by James 03-12-2004. */
2225 info->mon_data.txcnt += (cnt - info->xmit_cnt); 2172 port->mon_data.txcnt += (cnt - port->xmit_cnt);
2226 info->mon_data.up_txcnt += (cnt - info->xmit_cnt); 2173 port->mon_data.up_txcnt += (cnt - port->xmit_cnt);
2227 2174
2228/* added by casper 1/11/2000 */ 2175/* added by casper 1/11/2000 */
2229 info->icount.tx += (cnt - info->xmit_cnt); 2176 port->icount.tx += (cnt - port->xmit_cnt);
2230 2177
2231 if (info->xmit_cnt < WAKEUP_CHARS) { 2178 if (port->xmit_cnt < WAKEUP_CHARS) {
2232 set_bit(MXSER_EVENT_TXLOW, &info->event); 2179 set_bit(MXSER_EVENT_TXLOW, &port->event);
2233 schedule_work(&info->tqueue); 2180 schedule_work(&port->tqueue);
2234 } 2181 }
2235 if (info->xmit_cnt <= 0) { 2182 if (port->xmit_cnt <= 0) {
2236 info->IER &= ~UART_IER_THRI; 2183 port->IER &= ~UART_IER_THRI;
2237 outb(info->IER, info->base + UART_IER); 2184 outb(port->IER, port->ioaddr + UART_IER);
2238 } 2185 }
2239unlock: 2186unlock:
2240 spin_unlock_irqrestore(&info->slock, flags); 2187 spin_unlock_irqrestore(&port->slock, flags);
2241} 2188}
2242 2189
2243static void mxser_check_modem_status(struct mxser_struct *info, int status) 2190static void mxser_check_modem_status(struct mxser_port *port, int status)
2244{ 2191{
2245 /* update input line counters */ 2192 /* update input line counters */
2246 if (status & UART_MSR_TERI) 2193 if (status & UART_MSR_TERI)
2247 info->icount.rng++; 2194 port->icount.rng++;
2248 if (status & UART_MSR_DDSR) 2195 if (status & UART_MSR_DDSR)
2249 info->icount.dsr++; 2196 port->icount.dsr++;
2250 if (status & UART_MSR_DDCD) 2197 if (status & UART_MSR_DDCD)
2251 info->icount.dcd++; 2198 port->icount.dcd++;
2252 if (status & UART_MSR_DCTS) 2199 if (status & UART_MSR_DCTS)
2253 info->icount.cts++; 2200 port->icount.cts++;
2254 info->mon_data.modem_status = status; 2201 port->mon_data.modem_status = status;
2255 wake_up_interruptible(&info->delta_msr_wait); 2202 wake_up_interruptible(&port->delta_msr_wait);
2256 2203
2257 if ((info->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) { 2204 if ((port->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
2258 if (status & UART_MSR_DCD) 2205 if (status & UART_MSR_DCD)
2259 wake_up_interruptible(&info->open_wait); 2206 wake_up_interruptible(&port->open_wait);
2260 schedule_work(&info->tqueue); 2207 schedule_work(&port->tqueue);
2261 } 2208 }
2262 2209
2263 if (info->flags & ASYNC_CTS_FLOW) { 2210 if (port->flags & ASYNC_CTS_FLOW) {
2264 if (info->tty->hw_stopped) { 2211 if (port->tty->hw_stopped) {
2265 if (status & UART_MSR_CTS) { 2212 if (status & UART_MSR_CTS) {
2266 info->tty->hw_stopped = 0; 2213 port->tty->hw_stopped = 0;
2267 2214
2268 if ((info->type != PORT_16550A) && 2215 if ((port->type != PORT_16550A) &&
2269 (!info->IsMoxaMustChipFlag)) { 2216 (!port->board->chip_flag)) {
2270 outb(info->IER & ~UART_IER_THRI, 2217 outb(port->IER & ~UART_IER_THRI,
2271 info->base + UART_IER); 2218 port->ioaddr + UART_IER);
2272 info->IER |= UART_IER_THRI; 2219 port->IER |= UART_IER_THRI;
2273 outb(info->IER, info->base + UART_IER); 2220 outb(port->IER, port->ioaddr +
2221 UART_IER);
2274 } 2222 }
2275 set_bit(MXSER_EVENT_TXLOW, &info->event); 2223 set_bit(MXSER_EVENT_TXLOW, &port->event);
2276 schedule_work(&info->tqueue); 2224 schedule_work(&port->tqueue);
2277 } 2225 }
2278 } else { 2226 } else {
2279 if (!(status & UART_MSR_CTS)) { 2227 if (!(status & UART_MSR_CTS)) {
2280 info->tty->hw_stopped = 1; 2228 port->tty->hw_stopped = 1;
2281 if (info->type != PORT_16550A && 2229 if (port->type != PORT_16550A &&
2282 !info->IsMoxaMustChipFlag) { 2230 !port->board->chip_flag) {
2283 info->IER &= ~UART_IER_THRI; 2231 port->IER &= ~UART_IER_THRI;
2284 outb(info->IER, info->base + UART_IER); 2232 outb(port->IER, port->ioaddr +
2233 UART_IER);
2285 } 2234 }
2286 } 2235 }
2287 } 2236 }
2288 } 2237 }
2289} 2238}
2290 2239
2291static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, struct mxser_struct *info) 2240static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, struct mxser_port *port)
2292{ 2241{
2293 DECLARE_WAITQUEUE(wait, current); 2242 DECLARE_WAITQUEUE(wait, current);
2294 int retval; 2243 int retval;
@@ -2300,7 +2249,7 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru
2300 * then make the check up front and then exit. 2249 * then make the check up front and then exit.
2301 */ 2250 */
2302 if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) { 2251 if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) {
2303 info->flags |= ASYNC_NORMAL_ACTIVE; 2252 port->flags |= ASYNC_NORMAL_ACTIVE;
2304 return 0; 2253 return 0;
2305 } 2254 }
2306 2255
@@ -2310,34 +2259,34 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru
2310 /* 2259 /*
2311 * Block waiting for the carrier detect and the line to become 2260 * Block waiting for the carrier detect and the line to become
2312 * free (i.e., not in use by the callout). While we are in 2261 * free (i.e., not in use by the callout). While we are in
2313 * this loop, info->count is dropped by one, so that 2262 * this loop, port->count is dropped by one, so that
2314 * mxser_close() knows when to free things. We restore it upon 2263 * mxser_close() knows when to free things. We restore it upon
2315 * exit, either normal or abnormal. 2264 * exit, either normal or abnormal.
2316 */ 2265 */
2317 retval = 0; 2266 retval = 0;
2318 add_wait_queue(&info->open_wait, &wait); 2267 add_wait_queue(&port->open_wait, &wait);
2319 2268
2320 spin_lock_irqsave(&info->slock, flags); 2269 spin_lock_irqsave(&port->slock, flags);
2321 if (!tty_hung_up_p(filp)) 2270 if (!tty_hung_up_p(filp))
2322 info->count--; 2271 port->count--;
2323 spin_unlock_irqrestore(&info->slock, flags); 2272 spin_unlock_irqrestore(&port->slock, flags);
2324 info->blocked_open++; 2273 port->blocked_open++;
2325 while (1) { 2274 while (1) {
2326 spin_lock_irqsave(&info->slock, flags); 2275 spin_lock_irqsave(&port->slock, flags);
2327 outb(inb(info->base + UART_MCR) | 2276 outb(inb(port->ioaddr + UART_MCR) |
2328 UART_MCR_DTR | UART_MCR_RTS, info->base + UART_MCR); 2277 UART_MCR_DTR | UART_MCR_RTS, port->ioaddr + UART_MCR);
2329 spin_unlock_irqrestore(&info->slock, flags); 2278 spin_unlock_irqrestore(&port->slock, flags);
2330 set_current_state(TASK_INTERRUPTIBLE); 2279 set_current_state(TASK_INTERRUPTIBLE);
2331 if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)) { 2280 if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) {
2332 if (info->flags & ASYNC_HUP_NOTIFY) 2281 if (port->flags & ASYNC_HUP_NOTIFY)
2333 retval = -EAGAIN; 2282 retval = -EAGAIN;
2334 else 2283 else
2335 retval = -ERESTARTSYS; 2284 retval = -ERESTARTSYS;
2336 break; 2285 break;
2337 } 2286 }
2338 if (!(info->flags & ASYNC_CLOSING) && 2287 if (!(port->flags & ASYNC_CLOSING) &&
2339 (do_clocal || 2288 (do_clocal ||
2340 (inb(info->base + UART_MSR) & UART_MSR_DCD))) 2289 (inb(port->ioaddr + UART_MSR) & UART_MSR_DCD)))
2341 break; 2290 break;
2342 if (signal_pending(current)) { 2291 if (signal_pending(current)) {
2343 retval = -ERESTARTSYS; 2292 retval = -ERESTARTSYS;
@@ -2346,17 +2295,17 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru
2346 schedule(); 2295 schedule();
2347 } 2296 }
2348 set_current_state(TASK_RUNNING); 2297 set_current_state(TASK_RUNNING);
2349 remove_wait_queue(&info->open_wait, &wait); 2298 remove_wait_queue(&port->open_wait, &wait);
2350 if (!tty_hung_up_p(filp)) 2299 if (!tty_hung_up_p(filp))
2351 info->count++; 2300 port->count++;
2352 info->blocked_open--; 2301 port->blocked_open--;
2353 if (retval) 2302 if (retval)
2354 return retval; 2303 return retval;
2355 info->flags |= ASYNC_NORMAL_ACTIVE; 2304 port->flags |= ASYNC_NORMAL_ACTIVE;
2356 return 0; 2305 return 0;
2357} 2306}
2358 2307
2359static int mxser_startup(struct mxser_struct *info) 2308static int mxser_startup(struct mxser_port *info)
2360{ 2309{
2361 unsigned long page; 2310 unsigned long page;
2362 unsigned long flags; 2311 unsigned long flags;
@@ -2373,7 +2322,7 @@ static int mxser_startup(struct mxser_struct *info)
2373 return 0; 2322 return 0;
2374 } 2323 }
2375 2324
2376 if (!info->base || !info->type) { 2325 if (!info->ioaddr || !info->type) {
2377 if (info->tty) 2326 if (info->tty)
2378 set_bit(TTY_IO_ERROR, &info->tty->flags); 2327 set_bit(TTY_IO_ERROR, &info->tty->flags);
2379 free_page(page); 2328 free_page(page);
@@ -2389,20 +2338,20 @@ static int mxser_startup(struct mxser_struct *info)
2389 * Clear the FIFO buffers and disable them 2338 * Clear the FIFO buffers and disable them
2390 * (they will be reenabled in mxser_change_speed()) 2339 * (they will be reenabled in mxser_change_speed())
2391 */ 2340 */
2392 if (info->IsMoxaMustChipFlag) 2341 if (info->board->chip_flag)
2393 outb((UART_FCR_CLEAR_RCVR | 2342 outb((UART_FCR_CLEAR_RCVR |
2394 UART_FCR_CLEAR_XMIT | 2343 UART_FCR_CLEAR_XMIT |
2395 MOXA_MUST_FCR_GDA_MODE_ENABLE), info->base + UART_FCR); 2344 MOXA_MUST_FCR_GDA_MODE_ENABLE), info->ioaddr + UART_FCR);
2396 else 2345 else
2397 outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), 2346 outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
2398 info->base + UART_FCR); 2347 info->ioaddr + UART_FCR);
2399 2348
2400 /* 2349 /*
2401 * At this point there's no way the LSR could still be 0xFF; 2350 * At this point there's no way the LSR could still be 0xFF;
2402 * if it is, then bail out, because there's likely no UART 2351 * if it is, then bail out, because there's likely no UART
2403 * here. 2352 * here.
2404 */ 2353 */
2405 if (inb(info->base + UART_LSR) == 0xff) { 2354 if (inb(info->ioaddr + UART_LSR) == 0xff) {
2406 spin_unlock_irqrestore(&info->slock, flags); 2355 spin_unlock_irqrestore(&info->slock, flags);
2407 if (capable(CAP_SYS_ADMIN)) { 2356 if (capable(CAP_SYS_ADMIN)) {
2408 if (info->tty) 2357 if (info->tty)
@@ -2415,17 +2364,17 @@ static int mxser_startup(struct mxser_struct *info)
2415 /* 2364 /*
2416 * Clear the interrupt registers. 2365 * Clear the interrupt registers.
2417 */ 2366 */
2418 (void) inb(info->base + UART_LSR); 2367 (void) inb(info->ioaddr + UART_LSR);
2419 (void) inb(info->base + UART_RX); 2368 (void) inb(info->ioaddr + UART_RX);
2420 (void) inb(info->base + UART_IIR); 2369 (void) inb(info->ioaddr + UART_IIR);
2421 (void) inb(info->base + UART_MSR); 2370 (void) inb(info->ioaddr + UART_MSR);
2422 2371
2423 /* 2372 /*
2424 * Now, initialize the UART 2373 * Now, initialize the UART
2425 */ 2374 */
2426 outb(UART_LCR_WLEN8, info->base + UART_LCR); /* reset DLAB */ 2375 outb(UART_LCR_WLEN8, info->ioaddr + UART_LCR); /* reset DLAB */
2427 info->MCR = UART_MCR_DTR | UART_MCR_RTS; 2376 info->MCR = UART_MCR_DTR | UART_MCR_RTS;
2428 outb(info->MCR, info->base + UART_MCR); 2377 outb(info->MCR, info->ioaddr + UART_MCR);
2429 2378
2430 /* 2379 /*
2431 * Finally, enable interrupts 2380 * Finally, enable interrupts
@@ -2434,18 +2383,18 @@ static int mxser_startup(struct mxser_struct *info)
2434 /* info->IER = UART_IER_RLSI | UART_IER_RDI; */ 2383 /* info->IER = UART_IER_RLSI | UART_IER_RDI; */
2435 2384
2436 /* following add by Victor Yu. 08-30-2002 */ 2385 /* following add by Victor Yu. 08-30-2002 */
2437 if (info->IsMoxaMustChipFlag) 2386 if (info->board->chip_flag)
2438 info->IER |= MOXA_MUST_IER_EGDAI; 2387 info->IER |= MOXA_MUST_IER_EGDAI;
2439 /* above add by Victor Yu. 08-30-2002 */ 2388 /* above add by Victor Yu. 08-30-2002 */
2440 outb(info->IER, info->base + UART_IER); /* enable interrupts */ 2389 outb(info->IER, info->ioaddr + UART_IER); /* enable interrupts */
2441 2390
2442 /* 2391 /*
2443 * And clear the interrupt registers again for luck. 2392 * And clear the interrupt registers again for luck.
2444 */ 2393 */
2445 (void) inb(info->base + UART_LSR); 2394 (void) inb(info->ioaddr + UART_LSR);
2446 (void) inb(info->base + UART_RX); 2395 (void) inb(info->ioaddr + UART_RX);
2447 (void) inb(info->base + UART_IIR); 2396 (void) inb(info->ioaddr + UART_IIR);
2448 (void) inb(info->base + UART_MSR); 2397 (void) inb(info->ioaddr + UART_MSR);
2449 2398
2450 if (info->tty) 2399 if (info->tty)
2451 clear_bit(TTY_IO_ERROR, &info->tty->flags); 2400 clear_bit(TTY_IO_ERROR, &info->tty->flags);
@@ -2465,7 +2414,7 @@ static int mxser_startup(struct mxser_struct *info)
2465 * This routine will shutdown a serial port; interrupts maybe disabled, and 2414 * This routine will shutdown a serial port; interrupts maybe disabled, and
2466 * DTR is dropped if the hangup on close termio flag is on. 2415 * DTR is dropped if the hangup on close termio flag is on.
2467 */ 2416 */
2468static void mxser_shutdown(struct mxser_struct *info) 2417static void mxser_shutdown(struct mxser_port *info)
2469{ 2418{
2470 unsigned long flags; 2419 unsigned long flags;
2471 2420
@@ -2489,25 +2438,25 @@ static void mxser_shutdown(struct mxser_struct *info)
2489 } 2438 }
2490 2439
2491 info->IER = 0; 2440 info->IER = 0;
2492 outb(0x00, info->base + UART_IER); 2441 outb(0x00, info->ioaddr + UART_IER);
2493 2442
2494 if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) 2443 if (!info->tty || (info->tty->termios->c_cflag & HUPCL))
2495 info->MCR &= ~(UART_MCR_DTR | UART_MCR_RTS); 2444 info->MCR &= ~(UART_MCR_DTR | UART_MCR_RTS);
2496 outb(info->MCR, info->base + UART_MCR); 2445 outb(info->MCR, info->ioaddr + UART_MCR);
2497 2446
2498 /* clear Rx/Tx FIFO's */ 2447 /* clear Rx/Tx FIFO's */
2499 /* following add by Victor Yu. 08-30-2002 */ 2448 /* following add by Victor Yu. 08-30-2002 */
2500 if (info->IsMoxaMustChipFlag) 2449 if (info->board->chip_flag)
2501 outb((UART_FCR_CLEAR_RCVR | 2450 outb(UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT |
2502 UART_FCR_CLEAR_XMIT | 2451 MOXA_MUST_FCR_GDA_MODE_ENABLE,
2503 MOXA_MUST_FCR_GDA_MODE_ENABLE), info->base + UART_FCR); 2452 info->ioaddr + UART_FCR);
2504 else 2453 else
2505 /* above add by Victor Yu. 08-30-2002 */ 2454 /* above add by Victor Yu. 08-30-2002 */
2506 outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), 2455 outb(UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT,
2507 info->base + UART_FCR); 2456 info->ioaddr + UART_FCR);
2508 2457
2509 /* read data port to reset things */ 2458 /* read data port to reset things */
2510 (void) inb(info->base + UART_RX); 2459 (void) inb(info->ioaddr + UART_RX);
2511 2460
2512 if (info->tty) 2461 if (info->tty)
2513 set_bit(TTY_IO_ERROR, &info->tty->flags); 2462 set_bit(TTY_IO_ERROR, &info->tty->flags);
@@ -2515,8 +2464,8 @@ static void mxser_shutdown(struct mxser_struct *info)
2515 info->flags &= ~ASYNC_INITIALIZED; 2464 info->flags &= ~ASYNC_INITIALIZED;
2516 2465
2517 /* following add by Victor Yu. 09-23-2002 */ 2466 /* following add by Victor Yu. 09-23-2002 */
2518 if (info->IsMoxaMustChipFlag) 2467 if (info->board->chip_flag)
2519 SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(info->base); 2468 SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(info->ioaddr);
2520 /* above add by Victor Yu. 09-23-2002 */ 2469 /* above add by Victor Yu. 09-23-2002 */
2521 2470
2522 spin_unlock_irqrestore(&info->slock, flags); 2471 spin_unlock_irqrestore(&info->slock, flags);
@@ -2526,7 +2475,8 @@ static void mxser_shutdown(struct mxser_struct *info)
2526 * This routine is called to set the UART divisor registers to match 2475 * This routine is called to set the UART divisor registers to match
2527 * the specified baud rate for a serial port. 2476 * the specified baud rate for a serial port.
2528 */ 2477 */
2529static int mxser_change_speed(struct mxser_struct *info, struct termios *old_termios) 2478static int mxser_change_speed(struct mxser_port *info,
2479 struct termios *old_termios)
2530{ 2480{
2531 unsigned cflag, cval, fcr; 2481 unsigned cflag, cval, fcr;
2532 int ret = 0; 2482 int ret = 0;
@@ -2537,13 +2487,13 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2537 if (!info->tty || !info->tty->termios) 2487 if (!info->tty || !info->tty->termios)
2538 return ret; 2488 return ret;
2539 cflag = info->tty->termios->c_cflag; 2489 cflag = info->tty->termios->c_cflag;
2540 if (!(info->base)) 2490 if (!(info->ioaddr))
2541 return ret; 2491 return ret;
2542 2492
2543#ifndef B921600 2493#ifndef B921600
2544#define B921600 (B460800 +1) 2494#define B921600 (B460800 +1)
2545#endif 2495#endif
2546 if (mxser_set_baud_method[info->port] == 0) { 2496 if (mxser_set_baud_method[info->tty->index] == 0) {
2547 baud = tty_get_baud_rate(info->tty); 2497 baud = tty_get_baud_rate(info->tty);
2548 mxser_set_baud(info, baud); 2498 mxser_set_baud(info, baud);
2549 } 2499 }
@@ -2576,7 +2526,7 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2576 cval |= UART_LCR_SPAR; 2526 cval |= UART_LCR_SPAR;
2577 2527
2578 if ((info->type == PORT_8250) || (info->type == PORT_16450)) { 2528 if ((info->type == PORT_8250) || (info->type == PORT_16450)) {
2579 if (info->IsMoxaMustChipFlag) { 2529 if (info->board->chip_flag) {
2580 fcr = UART_FCR_ENABLE_FIFO; 2530 fcr = UART_FCR_ENABLE_FIFO;
2581 fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE; 2531 fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE;
2582 SET_MOXA_MUST_FIFO_VALUE(info); 2532 SET_MOXA_MUST_FIFO_VALUE(info);
@@ -2585,7 +2535,7 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2585 } else { 2535 } else {
2586 fcr = UART_FCR_ENABLE_FIFO; 2536 fcr = UART_FCR_ENABLE_FIFO;
2587 /* following add by Victor Yu. 08-30-2002 */ 2537 /* following add by Victor Yu. 08-30-2002 */
2588 if (info->IsMoxaMustChipFlag) { 2538 if (info->board->chip_flag) {
2589 fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE; 2539 fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE;
2590 SET_MOXA_MUST_FIFO_VALUE(info); 2540 SET_MOXA_MUST_FIFO_VALUE(info);
2591 } else { 2541 } else {
@@ -2613,9 +2563,9 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2613 if (cflag & CRTSCTS) { 2563 if (cflag & CRTSCTS) {
2614 info->flags |= ASYNC_CTS_FLOW; 2564 info->flags |= ASYNC_CTS_FLOW;
2615 info->IER |= UART_IER_MSI; 2565 info->IER |= UART_IER_MSI;
2616 if ((info->type == PORT_16550A) || (info->IsMoxaMustChipFlag)) { 2566 if ((info->type == PORT_16550A) || (info->board->chip_flag)) {
2617 info->MCR |= UART_MCR_AFE; 2567 info->MCR |= UART_MCR_AFE;
2618 /* status = mxser_get_msr(info->base, 0, info->port); */ 2568/* status = mxser_get_msr(info->ioaddr, 0, info->port); */
2619/* 2569/*
2620 save_flags(flags); 2570 save_flags(flags);
2621 cli(); 2571 cli();
@@ -2624,19 +2574,21 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2624*/ 2574*/
2625 /* mxser_check_modem_status(info, status); */ 2575 /* mxser_check_modem_status(info, status); */
2626 } else { 2576 } else {
2627 /* status = mxser_get_msr(info->base, 0, info->port); */ 2577/* status = mxser_get_msr(info->ioaddr, 0, info->port); */
2628 /* MX_LOCK(&info->slock); */ 2578 /* MX_LOCK(&info->slock); */
2629 status = inb(info->base + UART_MSR); 2579 status = inb(info->ioaddr + UART_MSR);
2630 /* MX_UNLOCK(&info->slock); */ 2580 /* MX_UNLOCK(&info->slock); */
2631 if (info->tty->hw_stopped) { 2581 if (info->tty->hw_stopped) {
2632 if (status & UART_MSR_CTS) { 2582 if (status & UART_MSR_CTS) {
2633 info->tty->hw_stopped = 0; 2583 info->tty->hw_stopped = 0;
2634 if (info->type != PORT_16550A && 2584 if (info->type != PORT_16550A &&
2635 !info->IsMoxaMustChipFlag) { 2585 !info->board->chip_flag) {
2636 outb(info->IER & ~UART_IER_THRI, 2586 outb(info->IER & ~UART_IER_THRI,
2637 info->base + UART_IER); 2587 info->ioaddr +
2588 UART_IER);
2638 info->IER |= UART_IER_THRI; 2589 info->IER |= UART_IER_THRI;
2639 outb(info->IER, info->base + UART_IER); 2590 outb(info->IER, info->ioaddr +
2591 UART_IER);
2640 } 2592 }
2641 set_bit(MXSER_EVENT_TXLOW, &info->event); 2593 set_bit(MXSER_EVENT_TXLOW, &info->event);
2642 schedule_work(&info->tqueue); } 2594 schedule_work(&info->tqueue); }
@@ -2644,9 +2596,10 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2644 if (!(status & UART_MSR_CTS)) { 2596 if (!(status & UART_MSR_CTS)) {
2645 info->tty->hw_stopped = 1; 2597 info->tty->hw_stopped = 1;
2646 if ((info->type != PORT_16550A) && 2598 if ((info->type != PORT_16550A) &&
2647 (!info->IsMoxaMustChipFlag)) { 2599 (!info->board->chip_flag)) {
2648 info->IER &= ~UART_IER_THRI; 2600 info->IER &= ~UART_IER_THRI;
2649 outb(info->IER, info->base + UART_IER); 2601 outb(info->IER, info->ioaddr +
2602 UART_IER);
2650 } 2603 }
2651 } 2604 }
2652 } 2605 }
@@ -2654,14 +2607,14 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2654 } else { 2607 } else {
2655 info->flags &= ~ASYNC_CTS_FLOW; 2608 info->flags &= ~ASYNC_CTS_FLOW;
2656 } 2609 }
2657 outb(info->MCR, info->base + UART_MCR); 2610 outb(info->MCR, info->ioaddr + UART_MCR);
2658 if (cflag & CLOCAL) { 2611 if (cflag & CLOCAL) {
2659 info->flags &= ~ASYNC_CHECK_CD; 2612 info->flags &= ~ASYNC_CHECK_CD;
2660 } else { 2613 } else {
2661 info->flags |= ASYNC_CHECK_CD; 2614 info->flags |= ASYNC_CHECK_CD;
2662 info->IER |= UART_IER_MSI; 2615 info->IER |= UART_IER_MSI;
2663 } 2616 }
2664 outb(info->IER, info->base + UART_IER); 2617 outb(info->IER, info->ioaddr + UART_IER);
2665 2618
2666 /* 2619 /*
2667 * Set up parity check flag 2620 * Set up parity check flag
@@ -2693,27 +2646,27 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2693 } 2646 }
2694 } 2647 }
2695 /* following add by Victor Yu. 09-02-2002 */ 2648 /* following add by Victor Yu. 09-02-2002 */
2696 if (info->IsMoxaMustChipFlag) { 2649 if (info->board->chip_flag) {
2697 spin_lock_irqsave(&info->slock, flags); 2650 spin_lock_irqsave(&info->slock, flags);
2698 SET_MOXA_MUST_XON1_VALUE(info->base, START_CHAR(info->tty)); 2651 SET_MOXA_MUST_XON1_VALUE(info->ioaddr, START_CHAR(info->tty));
2699 SET_MOXA_MUST_XOFF1_VALUE(info->base, STOP_CHAR(info->tty)); 2652 SET_MOXA_MUST_XOFF1_VALUE(info->ioaddr, STOP_CHAR(info->tty));
2700 if (I_IXON(info->tty)) { 2653 if (I_IXON(info->tty)) {
2701 ENABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->base); 2654 ENABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->ioaddr);
2702 } else { 2655 } else {
2703 DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->base); 2656 DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->ioaddr);
2704 } 2657 }
2705 if (I_IXOFF(info->tty)) { 2658 if (I_IXOFF(info->tty)) {
2706 ENABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(info->base); 2659 ENABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(info->ioaddr);
2707 } else { 2660 } else {
2708 DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(info->base); 2661 DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(info->ioaddr);
2709 } 2662 }
2710 /* 2663 /*
2711 if ( I_IXANY(info->tty) ) { 2664 if ( I_IXANY(info->tty) ) {
2712 info->MCR |= MOXA_MUST_MCR_XON_ANY; 2665 info->MCR |= MOXA_MUST_MCR_XON_ANY;
2713 ENABLE_MOXA_MUST_XON_ANY_FLOW_CONTROL(info->base); 2666 ENABLE_MOXA_MUST_XON_ANY_FLOW_CONTROL(info->ioaddr);
2714 } else { 2667 } else {
2715 info->MCR &= ~MOXA_MUST_MCR_XON_ANY; 2668 info->MCR &= ~MOXA_MUST_MCR_XON_ANY;
2716 DISABLE_MOXA_MUST_XON_ANY_FLOW_CONTROL(info->base); 2669 DISABLE_MOXA_MUST_XON_ANY_FLOW_CONTROL(info->ioaddr);
2717 } 2670 }
2718 */ 2671 */
2719 spin_unlock_irqrestore(&info->slock, flags); 2672 spin_unlock_irqrestore(&info->slock, flags);
@@ -2721,14 +2674,14 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2721 /* above add by Victor Yu. 09-02-2002 */ 2674 /* above add by Victor Yu. 09-02-2002 */
2722 2675
2723 2676
2724 outb(fcr, info->base + UART_FCR); /* set fcr */ 2677 outb(fcr, info->ioaddr + UART_FCR); /* set fcr */
2725 outb(cval, info->base + UART_LCR); 2678 outb(cval, info->ioaddr + UART_LCR);
2726 2679
2727 return ret; 2680 return ret;
2728} 2681}
2729 2682
2730 2683
2731static int mxser_set_baud(struct mxser_struct *info, long newspd) 2684static int mxser_set_baud(struct mxser_port *info, long newspd)
2732{ 2685{
2733 int quot = 0; 2686 int quot = 0;
2734 unsigned char cval; 2687 unsigned char cval;
@@ -2738,10 +2691,10 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
2738 if (!info->tty || !info->tty->termios) 2691 if (!info->tty || !info->tty->termios)
2739 return ret; 2692 return ret;
2740 2693
2741 if (!(info->base)) 2694 if (!(info->ioaddr))
2742 return ret; 2695 return ret;
2743 2696
2744 if (newspd > info->MaxCanSetBaudRate) 2697 if (newspd > info->max_baud)
2745 return 0; 2698 return 0;
2746 2699
2747 info->realbaud = newspd; 2700 info->realbaud = newspd;
@@ -2761,23 +2714,23 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
2761 if (quot) { 2714 if (quot) {
2762 spin_lock_irqsave(&info->slock, flags); 2715 spin_lock_irqsave(&info->slock, flags);
2763 info->MCR |= UART_MCR_DTR; 2716 info->MCR |= UART_MCR_DTR;
2764 outb(info->MCR, info->base + UART_MCR); 2717 outb(info->MCR, info->ioaddr + UART_MCR);
2765 spin_unlock_irqrestore(&info->slock, flags); 2718 spin_unlock_irqrestore(&info->slock, flags);
2766 } else { 2719 } else {
2767 spin_lock_irqsave(&info->slock, flags); 2720 spin_lock_irqsave(&info->slock, flags);
2768 info->MCR &= ~UART_MCR_DTR; 2721 info->MCR &= ~UART_MCR_DTR;
2769 outb(info->MCR, info->base + UART_MCR); 2722 outb(info->MCR, info->ioaddr + UART_MCR);
2770 spin_unlock_irqrestore(&info->slock, flags); 2723 spin_unlock_irqrestore(&info->slock, flags);
2771 return ret; 2724 return ret;
2772 } 2725 }
2773 2726
2774 cval = inb(info->base + UART_LCR); 2727 cval = inb(info->ioaddr + UART_LCR);
2775 2728
2776 outb(cval | UART_LCR_DLAB, info->base + UART_LCR); /* set DLAB */ 2729 outb(cval | UART_LCR_DLAB, info->ioaddr + UART_LCR); /* set DLAB */
2777 2730
2778 outb(quot & 0xff, info->base + UART_DLL); /* LS of divisor */ 2731 outb(quot & 0xff, info->ioaddr + UART_DLL); /* LS of divisor */
2779 outb(quot >> 8, info->base + UART_DLM); /* MS of divisor */ 2732 outb(quot >> 8, info->ioaddr + UART_DLM); /* MS of divisor */
2780 outb(cval, info->base + UART_LCR); /* reset DLAB */ 2733 outb(cval, info->ioaddr + UART_LCR); /* reset DLAB */
2781 2734
2782 2735
2783 return ret; 2736 return ret;
@@ -2788,7 +2741,8 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
2788 * friends of mxser_ioctl() 2741 * friends of mxser_ioctl()
2789 * ------------------------------------------------------------ 2742 * ------------------------------------------------------------
2790 */ 2743 */
2791static int mxser_get_serial_info(struct mxser_struct *info, struct serial_struct __user *retinfo) 2744static int mxser_get_serial_info(struct mxser_port *info,
2745 struct serial_struct __user *retinfo)
2792{ 2746{
2793 struct serial_struct tmp; 2747 struct serial_struct tmp;
2794 2748
@@ -2796,9 +2750,9 @@ static int mxser_get_serial_info(struct mxser_struct *info, struct serial_struct
2796 return -EFAULT; 2750 return -EFAULT;
2797 memset(&tmp, 0, sizeof(tmp)); 2751 memset(&tmp, 0, sizeof(tmp));
2798 tmp.type = info->type; 2752 tmp.type = info->type;
2799 tmp.line = info->port; 2753 tmp.line = info->tty->index;
2800 tmp.port = info->base; 2754 tmp.port = info->ioaddr;
2801 tmp.irq = info->irq; 2755 tmp.irq = info->board->irq;
2802 tmp.flags = info->flags; 2756 tmp.flags = info->flags;
2803 tmp.baud_base = info->baud_base; 2757 tmp.baud_base = info->baud_base;
2804 tmp.close_delay = info->close_delay; 2758 tmp.close_delay = info->close_delay;
@@ -2810,19 +2764,20 @@ static int mxser_get_serial_info(struct mxser_struct *info, struct serial_struct
2810 return 0; 2764 return 0;
2811} 2765}
2812 2766
2813static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct __user *new_info) 2767static int mxser_set_serial_info(struct mxser_port *info,
2768 struct serial_struct __user *new_info)
2814{ 2769{
2815 struct serial_struct new_serial; 2770 struct serial_struct new_serial;
2816 unsigned int flags; 2771 unsigned int flags;
2817 int retval = 0; 2772 int retval = 0;
2818 2773
2819 if (!new_info || !info->base) 2774 if (!new_info || !info->ioaddr)
2820 return -EFAULT; 2775 return -EFAULT;
2821 if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) 2776 if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
2822 return -EFAULT; 2777 return -EFAULT;
2823 2778
2824 if ((new_serial.irq != info->irq) || 2779 if ((new_serial.irq != info->board->irq) ||
2825 (new_serial.port != info->base) || 2780 (new_serial.port != info->ioaddr) ||
2826 (new_serial.custom_divisor != info->custom_divisor) || 2781 (new_serial.custom_divisor != info->custom_divisor) ||
2827 (new_serial.baud_base != info->baud_base)) 2782 (new_serial.baud_base != info->baud_base))
2828 return -EPERM; 2783 return -EPERM;
@@ -2856,12 +2811,11 @@ static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct
2856 process_txrx_fifo(info); 2811 process_txrx_fifo(info);
2857 2812
2858 if (info->flags & ASYNC_INITIALIZED) { 2813 if (info->flags & ASYNC_INITIALIZED) {
2859 if (flags != (info->flags & ASYNC_SPD_MASK)) { 2814 if (flags != (info->flags & ASYNC_SPD_MASK))
2860 mxser_change_speed(info, NULL); 2815 mxser_change_speed(info, NULL);
2861 } 2816 } else
2862 } else {
2863 retval = mxser_startup(info); 2817 retval = mxser_startup(info);
2864 } 2818
2865 return retval; 2819 return retval;
2866} 2820}
2867 2821
@@ -2875,14 +2829,15 @@ static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct
2875 * transmit holding register is empty. This functionality 2829 * transmit holding register is empty. This functionality
2876 * allows an RS485 driver to be written in user space. 2830 * allows an RS485 driver to be written in user space.
2877 */ 2831 */
2878static int mxser_get_lsr_info(struct mxser_struct *info, unsigned int __user *value) 2832static int mxser_get_lsr_info(struct mxser_port *info,
2833 unsigned int __user *value)
2879{ 2834{
2880 unsigned char status; 2835 unsigned char status;
2881 unsigned int result; 2836 unsigned int result;
2882 unsigned long flags; 2837 unsigned long flags;
2883 2838
2884 spin_lock_irqsave(&info->slock, flags); 2839 spin_lock_irqsave(&info->slock, flags);
2885 status = inb(info->base + UART_LSR); 2840 status = inb(info->ioaddr + UART_LSR);
2886 spin_unlock_irqrestore(&info->slock, flags); 2841 spin_unlock_irqrestore(&info->slock, flags);
2887 result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0); 2842 result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0);
2888 return put_user(result, value); 2843 return put_user(result, value);
@@ -2891,27 +2846,27 @@ static int mxser_get_lsr_info(struct mxser_struct *info, unsigned int __user *va
2891/* 2846/*
2892 * This routine sends a break character out the serial port. 2847 * This routine sends a break character out the serial port.
2893 */ 2848 */
2894static void mxser_send_break(struct mxser_struct *info, int duration) 2849static void mxser_send_break(struct mxser_port *info, int duration)
2895{ 2850{
2896 unsigned long flags; 2851 unsigned long flags;
2897 2852
2898 if (!info->base) 2853 if (!info->ioaddr)
2899 return; 2854 return;
2900 set_current_state(TASK_INTERRUPTIBLE); 2855 set_current_state(TASK_INTERRUPTIBLE);
2901 spin_lock_irqsave(&info->slock, flags); 2856 spin_lock_irqsave(&info->slock, flags);
2902 outb(inb(info->base + UART_LCR) | UART_LCR_SBC, 2857 outb(inb(info->ioaddr + UART_LCR) | UART_LCR_SBC,
2903 info->base + UART_LCR); 2858 info->ioaddr + UART_LCR);
2904 spin_unlock_irqrestore(&info->slock, flags); 2859 spin_unlock_irqrestore(&info->slock, flags);
2905 schedule_timeout(duration); 2860 schedule_timeout(duration);
2906 spin_lock_irqsave(&info->slock, flags); 2861 spin_lock_irqsave(&info->slock, flags);
2907 outb(inb(info->base + UART_LCR) & ~UART_LCR_SBC, 2862 outb(inb(info->ioaddr + UART_LCR) & ~UART_LCR_SBC,
2908 info->base + UART_LCR); 2863 info->ioaddr + UART_LCR);
2909 spin_unlock_irqrestore(&info->slock, flags); 2864 spin_unlock_irqrestore(&info->slock, flags);
2910} 2865}
2911 2866
2912static int mxser_tiocmget(struct tty_struct *tty, struct file *file) 2867static int mxser_tiocmget(struct tty_struct *tty, struct file *file)
2913{ 2868{
2914 struct mxser_struct *info = tty->driver_data; 2869 struct mxser_port *info = tty->driver_data;
2915 unsigned char control, status; 2870 unsigned char control, status;
2916 unsigned long flags; 2871 unsigned long flags;
2917 2872
@@ -2924,7 +2879,7 @@ static int mxser_tiocmget(struct tty_struct *tty, struct file *file)
2924 control = info->MCR; 2879 control = info->MCR;
2925 2880
2926 spin_lock_irqsave(&info->slock, flags); 2881 spin_lock_irqsave(&info->slock, flags);
2927 status = inb(info->base + UART_MSR); 2882 status = inb(info->ioaddr + UART_MSR);
2928 if (status & UART_MSR_ANY_DELTA) 2883 if (status & UART_MSR_ANY_DELTA)
2929 mxser_check_modem_status(info, status); 2884 mxser_check_modem_status(info, status);
2930 spin_unlock_irqrestore(&info->slock, flags); 2885 spin_unlock_irqrestore(&info->slock, flags);
@@ -2936,9 +2891,10 @@ static int mxser_tiocmget(struct tty_struct *tty, struct file *file)
2936 ((status & UART_MSR_CTS) ? TIOCM_CTS : 0); 2891 ((status & UART_MSR_CTS) ? TIOCM_CTS : 0);
2937} 2892}
2938 2893
2939static int mxser_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) 2894static int mxser_tiocmset(struct tty_struct *tty, struct file *file,
2895 unsigned int set, unsigned int clear)
2940{ 2896{
2941 struct mxser_struct *info = tty->driver_data; 2897 struct mxser_port *info = tty->driver_data;
2942 unsigned long flags; 2898 unsigned long flags;
2943 2899
2944 2900
@@ -2959,7 +2915,7 @@ static int mxser_tiocmset(struct tty_struct *tty, struct file *file, unsigned in
2959 if (clear & TIOCM_DTR) 2915 if (clear & TIOCM_DTR)
2960 info->MCR &= ~UART_MCR_DTR; 2916 info->MCR &= ~UART_MCR_DTR;
2961 2917
2962 outb(info->MCR, info->base + UART_MCR); 2918 outb(info->MCR, info->ioaddr + UART_MCR);
2963 spin_unlock_irqrestore(&info->slock, flags); 2919 spin_unlock_irqrestore(&info->slock, flags);
2964 return 0; 2920 return 0;
2965} 2921}
@@ -2969,49 +2925,49 @@ static int mxser_read_register(int, unsigned short *);
2969static int mxser_program_mode(int); 2925static int mxser_program_mode(int);
2970static void mxser_normal_mode(int); 2926static void mxser_normal_mode(int);
2971 2927
2972static int mxser_get_ISA_conf(int cap, struct mxser_hwconf *hwconf) 2928static int mxser_get_ISA_conf(int cap, struct mxser_board *brd)
2973{ 2929{
2974 int id, i, bits; 2930 int id, i, bits;
2975 unsigned short regs[16], irq; 2931 unsigned short regs[16], irq;
2976 unsigned char scratch, scratch2; 2932 unsigned char scratch, scratch2;
2977 2933
2978 hwconf->IsMoxaMustChipFlag = MOXA_OTHER_UART; 2934 brd->chip_flag = MOXA_OTHER_UART;
2979 2935
2980 id = mxser_read_register(cap, regs); 2936 id = mxser_read_register(cap, regs);
2981 if (id == C168_ASIC_ID) { 2937 if (id == C168_ASIC_ID) {
2982 hwconf->board_type = MXSER_BOARD_C168_ISA; 2938 brd->board_type = MXSER_BOARD_C168_ISA;
2983 hwconf->ports = 8; 2939 brd->nports = 8;
2984 } else if (id == C104_ASIC_ID) { 2940 } else if (id == C104_ASIC_ID) {
2985 hwconf->board_type = MXSER_BOARD_C104_ISA; 2941 brd->board_type = MXSER_BOARD_C104_ISA;
2986 hwconf->ports = 4; 2942 brd->nports = 4;
2987 } else if (id == C102_ASIC_ID) { 2943 } else if (id == C102_ASIC_ID) {
2988 hwconf->board_type = MXSER_BOARD_C102_ISA; 2944 brd->board_type = MXSER_BOARD_C102_ISA;
2989 hwconf->ports = 2; 2945 brd->nports = 2;
2990 } else if (id == CI132_ASIC_ID) { 2946 } else if (id == CI132_ASIC_ID) {
2991 hwconf->board_type = MXSER_BOARD_CI132; 2947 brd->board_type = MXSER_BOARD_CI132;
2992 hwconf->ports = 2; 2948 brd->nports = 2;
2993 } else if (id == CI134_ASIC_ID) { 2949 } else if (id == CI134_ASIC_ID) {
2994 hwconf->board_type = MXSER_BOARD_CI134; 2950 brd->board_type = MXSER_BOARD_CI134;
2995 hwconf->ports = 4; 2951 brd->nports = 4;
2996 } else if (id == CI104J_ASIC_ID) { 2952 } else if (id == CI104J_ASIC_ID) {
2997 hwconf->board_type = MXSER_BOARD_CI104J; 2953 brd->board_type = MXSER_BOARD_CI104J;
2998 hwconf->ports = 4; 2954 brd->nports = 4;
2999 } else 2955 } else
3000 return 0; 2956 return 0;
3001 2957
3002 irq = 0; 2958 irq = 0;
3003 if (hwconf->ports == 2) { 2959 if (brd->nports == 2) {
3004 irq = regs[9] & 0xF000; 2960 irq = regs[9] & 0xF000;
3005 irq = irq | (irq >> 4); 2961 irq = irq | (irq >> 4);
3006 if (irq != (regs[9] & 0xFF00)) 2962 if (irq != (regs[9] & 0xFF00))
3007 return MXSER_ERR_IRQ_CONFLIT; 2963 return MXSER_ERR_IRQ_CONFLIT;
3008 } else if (hwconf->ports == 4) { 2964 } else if (brd->nports == 4) {
3009 irq = regs[9] & 0xF000; 2965 irq = regs[9] & 0xF000;
3010 irq = irq | (irq >> 4); 2966 irq = irq | (irq >> 4);
3011 irq = irq | (irq >> 8); 2967 irq = irq | (irq >> 8);
3012 if (irq != regs[9]) 2968 if (irq != regs[9])
3013 return MXSER_ERR_IRQ_CONFLIT; 2969 return MXSER_ERR_IRQ_CONFLIT;
3014 } else if (hwconf->ports == 8) { 2970 } else if (brd->nports == 8) {
3015 irq = regs[9] & 0xF000; 2971 irq = regs[9] & 0xF000;
3016 irq = irq | (irq >> 4); 2972 irq = irq | (irq >> 4);
3017 irq = irq | (irq >> 8); 2973 irq = irq | (irq >> 8);
@@ -3021,23 +2977,23 @@ static int mxser_get_ISA_conf(int cap, struct mxser_hwconf *hwconf)
3021 2977
3022 if (!irq) 2978 if (!irq)
3023 return MXSER_ERR_IRQ; 2979 return MXSER_ERR_IRQ;
3024 hwconf->irq = ((int)(irq & 0xF000) >> 12); 2980 brd->irq = ((int)(irq & 0xF000) >> 12);
3025 for (i = 0; i < 8; i++) 2981 for (i = 0; i < 8; i++)
3026 hwconf->ioaddr[i] = (int) regs[i + 1] & 0xFFF8; 2982 brd->ports[i].ioaddr = (int) regs[i + 1] & 0xFFF8;
3027 if ((regs[12] & 0x80) == 0) 2983 if ((regs[12] & 0x80) == 0)
3028 return MXSER_ERR_VECTOR; 2984 return MXSER_ERR_VECTOR;
3029 hwconf->vector = (int)regs[11]; /* interrupt vector */ 2985 brd->vector = (int)regs[11]; /* interrupt vector */
3030 if (id == 1) 2986 if (id == 1)
3031 hwconf->vector_mask = 0x00FF; 2987 brd->vector_mask = 0x00FF;
3032 else 2988 else
3033 hwconf->vector_mask = 0x000F; 2989 brd->vector_mask = 0x000F;
3034 for (i = 7, bits = 0x0100; i >= 0; i--, bits <<= 1) { 2990 for (i = 7, bits = 0x0100; i >= 0; i--, bits <<= 1) {
3035 if (regs[12] & bits) { 2991 if (regs[12] & bits) {
3036 hwconf->baud_base[i] = 921600; 2992 brd->ports[i].baud_base = 921600;
3037 hwconf->MaxCanSetBaudRate[i] = 921600; /* add by Victor Yu. 09-04-2002 */ 2993 brd->ports[i].max_baud = 921600; /* add by Victor Yu. 09-04-2002 */
3038 } else { 2994 } else {
3039 hwconf->baud_base[i] = 115200; 2995 brd->ports[i].baud_base = 115200;
3040 hwconf->MaxCanSetBaudRate[i] = 115200; /* add by Victor Yu. 09-04-2002 */ 2996 brd->ports[i].max_baud = 115200; /* add by Victor Yu. 09-04-2002 */
3041 } 2997 }
3042 } 2998 }
3043 scratch2 = inb(cap + UART_LCR) & (~UART_LCR_DLAB); 2999 scratch2 = inb(cap + UART_LCR) & (~UART_LCR_DLAB);
@@ -3048,16 +3004,16 @@ static int mxser_get_ISA_conf(int cap, struct mxser_hwconf *hwconf)
3048 scratch = inb(cap + UART_IIR); 3004 scratch = inb(cap + UART_IIR);
3049 3005
3050 if (scratch & 0xC0) 3006 if (scratch & 0xC0)
3051 hwconf->uart_type = PORT_16550A; 3007 brd->uart_type = PORT_16550A;
3052 else 3008 else
3053 hwconf->uart_type = PORT_16450; 3009 brd->uart_type = PORT_16450;
3054 if (id == 1) 3010 if (id == 1)
3055 hwconf->ports = 8; 3011 brd->nports = 8;
3056 else 3012 else
3057 hwconf->ports = 4; 3013 brd->nports = 4;
3058 request_region(hwconf->ioaddr[0], 8 * hwconf->ports, "mxser(IO)"); 3014 request_region(brd->ports[0].ioaddr, 8 * brd->nports, "mxser(IO)");
3059 request_region(hwconf->vector, 1, "mxser(vector)"); 3015 request_region(brd->vector, 1, "mxser(vector)");
3060 return hwconf->ports; 3016 return brd->nports;
3061} 3017}
3062 3018
3063#define CHIP_SK 0x01 /* Serial Data Clock in Eprom */ 3019#define CHIP_SK 0x01 /* Serial Data Clock in Eprom */
diff --git a/drivers/char/mxser_new.h b/drivers/char/mxser_new.h
index 32ce1a800556..a08f0ecb09ba 100644
--- a/drivers/char/mxser_new.h
+++ b/drivers/char/mxser_new.h
@@ -300,16 +300,16 @@
300//#define MOXA_MUST_RBRL_VALUE 4 300//#define MOXA_MUST_RBRL_VALUE 4
301#define SET_MOXA_MUST_FIFO_VALUE(info) { \ 301#define SET_MOXA_MUST_FIFO_VALUE(info) { \
302 u8 __oldlcr, __efr; \ 302 u8 __oldlcr, __efr; \
303 __oldlcr = inb((info)->base+UART_LCR); \ 303 __oldlcr = inb((info)->ioaddr+UART_LCR); \
304 outb(MOXA_MUST_ENTER_ENCHANCE, (info)->base+UART_LCR); \ 304 outb(MOXA_MUST_ENTER_ENCHANCE, (info)->ioaddr+UART_LCR); \
305 __efr = inb((info)->base+MOXA_MUST_EFR_REGISTER); \ 305 __efr = inb((info)->ioaddr+MOXA_MUST_EFR_REGISTER); \
306 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \ 306 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
307 __efr |= MOXA_MUST_EFR_BANK1; \ 307 __efr |= MOXA_MUST_EFR_BANK1; \
308 outb(__efr, (info)->base+MOXA_MUST_EFR_REGISTER); \ 308 outb(__efr, (info)->ioaddr+MOXA_MUST_EFR_REGISTER); \
309 outb((u8)((info)->rx_high_water), (info)->base+MOXA_MUST_RBRTH_REGISTER); \ 309 outb((u8)((info)->rx_high_water), (info)->ioaddr+MOXA_MUST_RBRTH_REGISTER); \
310 outb((u8)((info)->rx_trigger), (info)->base+MOXA_MUST_RBRTI_REGISTER); \ 310 outb((u8)((info)->rx_trigger), (info)->ioaddr+MOXA_MUST_RBRTI_REGISTER); \
311 outb((u8)((info)->rx_low_water), (info)->base+MOXA_MUST_RBRTL_REGISTER); \ 311 outb((u8)((info)->rx_low_water), (info)->ioaddr+MOXA_MUST_RBRTL_REGISTER); \
312 outb(__oldlcr, (info)->base+UART_LCR); \ 312 outb(__oldlcr, (info)->ioaddr+UART_LCR); \
313} 313}
314 314
315 315