Commit 55b307da authored by Jiri Slaby's avatar Jiri Slaby Committed by Linus Torvalds

[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: default avatarJiri Slaby <jirislaby@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 3306ce3d
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
#include "mxser_new.h" #include "mxser_new.h"
#define MXSER_VERSION "1.9.1" #define MXSER_VERSION "2.0"
#define MXSERMAJOR 174 #define MXSERMAJOR 174
#define MXSERCUMAJOR 175 #define MXSERCUMAJOR 175
...@@ -85,8 +85,6 @@ ...@@ -85,8 +85,6 @@
#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|\ #define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|\
IXON|IXOFF)) IXON|IXOFF))
#define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? IRQF_SHARED : IRQF_DISABLED)
#define C168_ASIC_ID 1 #define C168_ASIC_ID 1
#define C104_ASIC_ID 2 #define C104_ASIC_ID 2
#define C102_ASIC_ID 0xB #define C102_ASIC_ID 0xB
...@@ -202,8 +200,6 @@ static const struct mxpciuart_info Gpci_uart_info[UART_INFO_NUM] = { ...@@ -202,8 +200,6 @@ static const struct mxpciuart_info Gpci_uart_info[UART_INFO_NUM] = {
}; };
#ifdef CONFIG_PCI
static struct pci_device_id mxser_pcibrds[] = { static struct pci_device_id mxser_pcibrds[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C168), { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C168),
.driver_data = MXSER_BOARD_C168_PCI }, .driver_data = MXSER_BOARD_C168_PCI },
...@@ -243,18 +239,8 @@ static struct pci_device_id mxser_pcibrds[] = { ...@@ -243,18 +239,8 @@ static struct pci_device_id mxser_pcibrds[] = {
.driver_data = MXSER_BOARD_CP104EL }, .driver_data = MXSER_BOARD_CP104EL },
{ } { }
}; };
MODULE_DEVICE_TABLE(pci, mxser_pcibrds); MODULE_DEVICE_TABLE(pci, mxser_pcibrds);
#endif
typedef struct _moxa_pci_info {
unsigned short busNum;
unsigned short devNum;
struct pci_dev *pdev; /* add by Victor Yu. 06-23-2003 */
} moxa_pci_info;
static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 }; static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 };
static int ttymajor = MXSERMAJOR; static int ttymajor = MXSERMAJOR;
static int calloutmajor = MXSERCUMAJOR; static int calloutmajor = MXSERCUMAJOR;
...@@ -301,69 +287,77 @@ struct mxser_mon_ext { ...@@ -301,69 +287,77 @@ struct mxser_mon_ext {
int iftype[32]; int iftype[32];
}; };
struct mxser_hwconf { struct mxser_board;
int board_type;
int ports; struct mxser_port {
int irq; struct mxser_board *board;
unsigned long vector; struct tty_struct *tty;
unsigned long vector_mask;
int uart_type; unsigned long ioaddr;
unsigned long ioaddr[MXSER_PORTS_PER_BOARD]; unsigned long opmode_ioaddr;
int baud_base[MXSER_PORTS_PER_BOARD]; int max_baud;
moxa_pci_info pciInfo;
int IsMoxaMustChipFlag; /* add by Victor Yu. 08-30-2002 */
int MaxCanSetBaudRate[MXSER_PORTS_PER_BOARD]; /* add by Victor Yu. 09-04-2002 */
unsigned long opmode_ioaddr[MXSER_PORTS_PER_BOARD]; /* add by Victor Yu. 01-05-2004 */
};
struct mxser_struct {
int port;
unsigned long base; /* port base address */
int irq; /* port using irq no. */
unsigned long vector; /* port irq vector */
unsigned long vectormask; /* port vector mask */
int rx_high_water; int rx_high_water;
int rx_trigger; /* Rx fifo trigger level */ int rx_trigger; /* Rx fifo trigger level */
int rx_low_water; int rx_low_water;
int baud_base; /* max. speed */ int baud_base; /* max. speed */
int flags; /* defined in tty.h */ long realbaud;
int type; /* UART type */ int type; /* UART type */
struct tty_struct *tty; int flags; /* defined in tty.h */
int read_status_mask; long session; /* Session of opening process */
int ignore_status_mask; long pgrp; /* pgrp of opening process */
int xmit_fifo_size;
int custom_divisor;
int x_char; /* xon/xoff character */ int x_char; /* xon/xoff character */
int close_delay;
unsigned short closing_wait;
int IER; /* Interrupt Enable Register */ int IER; /* Interrupt Enable Register */
int MCR; /* Modem control register */ int MCR; /* Modem control register */
unsigned char stop_rx;
unsigned char ldisc_stop_rx;
int custom_divisor;
int close_delay;
unsigned short closing_wait;
unsigned char err_shadow;
unsigned long event; unsigned long event;
int count; /* # of fd on device */ int count; /* # of fd on device */
int blocked_open; /* # of blocked opens */ int blocked_open; /* # of blocked opens */
long session; /* Session of opening process */ struct async_icount icount; /* kernel counters for 4 input interrupts */
long pgrp; /* pgrp of opening process */ int timeout;
int read_status_mask;
int ignore_status_mask;
int xmit_fifo_size;
unsigned char *xmit_buf; unsigned char *xmit_buf;
int xmit_head; int xmit_head;
int xmit_tail; int xmit_tail;
int xmit_cnt; int xmit_cnt;
struct work_struct tqueue;
struct termios normal_termios; struct termios normal_termios;
struct termios callout_termios; struct termios callout_termios;
struct mxser_mon mon_data;
spinlock_t slock;
struct work_struct tqueue;
wait_queue_head_t open_wait; wait_queue_head_t open_wait;
wait_queue_head_t close_wait; wait_queue_head_t close_wait;
wait_queue_head_t delta_msr_wait; wait_queue_head_t delta_msr_wait;
struct async_icount icount; /* kernel counters for the 4 input interrupts */ };
int timeout;
int IsMoxaMustChipFlag; /* add by Victor Yu. 08-30-2002 */ struct mxser_board {
int MaxCanSetBaudRate; /* add by Victor Yu. 09-04-2002 */ struct pci_dev *pdev; /* temporary (until pci probing) */
unsigned long opmode_ioaddr; /* add by Victor Yu. 01-05-2004 */
unsigned char stop_rx; int irq;
unsigned char ldisc_stop_rx; int board_type;
long realbaud; unsigned int nports;
struct mxser_mon mon_data; unsigned long vector;
unsigned char err_shadow; unsigned long vector_mask;
spinlock_t slock;
int chip_flag;
int uart_type;
struct mxser_port ports[MXSER_PORTS_PER_BOARD];
}; };
struct mxser_mstatus { struct mxser_mstatus {
...@@ -381,8 +375,8 @@ static int mxserBoardCAP[MXSER_BOARDS] = { ...@@ -381,8 +375,8 @@ static int mxserBoardCAP[MXSER_BOARDS] = {
/* 0x180, 0x280, 0x200, 0x320 */ /* 0x180, 0x280, 0x200, 0x320 */
}; };
static struct mxser_board mxser_boards[MXSER_BOARDS];
static struct tty_driver *mxvar_sdriver; static struct tty_driver *mxvar_sdriver;
static struct mxser_struct mxvar_table[MXSER_PORTS];
static struct tty_struct *mxvar_tty[MXSER_PORTS + 1]; static struct tty_struct *mxvar_tty[MXSER_PORTS + 1];
static struct termios *mxvar_termios[MXSER_PORTS + 1]; static struct termios *mxvar_termios[MXSER_PORTS + 1];
static struct termios *mxvar_termios_locked[MXSER_PORTS + 1]; static struct termios *mxvar_termios_locked[MXSER_PORTS + 1];
...@@ -393,22 +387,14 @@ static struct mxser_mon_ext mon_data_ext; ...@@ -393,22 +387,14 @@ static struct mxser_mon_ext mon_data_ext;
static int mxser_set_baud_method[MXSER_PORTS + 1]; static int mxser_set_baud_method[MXSER_PORTS + 1];
static spinlock_t gm_lock; static spinlock_t gm_lock;
/*
* This is used to figure out the divisor speeds and the timeouts
*/
static struct mxser_hwconf mxsercfg[MXSER_BOARDS];
/* /*
* static functions: * static functions:
*/ */
static void mxser_getcfg(int board, struct mxser_hwconf *hwconf);
static int mxser_init(void); static int mxser_init(void);
/* static void mxser_poll(unsigned long); */ /* static void mxser_poll(unsigned long); */
static int mxser_get_ISA_conf(int, struct mxser_hwconf *); static int mxser_get_ISA_conf(int, struct mxser_board *);
static int mxser_get_PCI_conf(int, int, int, struct mxser_hwconf *);
static void mxser_do_softint(void *); static void mxser_do_softint(void *);
static int mxser_open(struct tty_struct *, struct file *); static int mxser_open(struct tty_struct *, struct file *);
static void mxser_close(struct tty_struct *, struct file *); static void mxser_close(struct tty_struct *, struct file *);
...@@ -428,24 +414,28 @@ static void mxser_start(struct tty_struct *); ...@@ -428,24 +414,28 @@ static void mxser_start(struct tty_struct *);
static void mxser_hangup(struct tty_struct *); static void mxser_hangup(struct tty_struct *);
static void mxser_rs_break(struct tty_struct *, int); static void mxser_rs_break(struct tty_struct *, int);
static irqreturn_t mxser_interrupt(int, void *, struct pt_regs *); static irqreturn_t mxser_interrupt(int, void *, struct pt_regs *);
static void mxser_receive_chars(struct mxser_struct *, int *); static void mxser_receive_chars(struct mxser_port *, int *);
static void mxser_transmit_chars(struct mxser_struct *); static void mxser_transmit_chars(struct mxser_port *);
static void mxser_check_modem_status(struct mxser_struct *, int); static void mxser_check_modem_status(struct mxser_port *, int);
static int mxser_block_til_ready(struct tty_struct *, struct file *, struct mxser_struct *); static int mxser_block_til_ready(struct tty_struct *, struct file *,
static int mxser_startup(struct mxser_struct *); struct mxser_port *);
static void mxser_shutdown(struct mxser_struct *); static int mxser_startup(struct mxser_port *);
static int mxser_change_speed(struct mxser_struct *, struct termios *old_termios); static void mxser_shutdown(struct mxser_port *);
static int mxser_get_serial_info(struct mxser_struct *, struct serial_struct __user *); static int mxser_change_speed(struct mxser_port *, struct termios *);
static int mxser_set_serial_info(struct mxser_struct *, struct serial_struct __user *); static int mxser_get_serial_info(struct mxser_port *,
static int mxser_get_lsr_info(struct mxser_struct *, unsigned int __user *); struct serial_struct __user *);
static void mxser_send_break(struct mxser_struct *, int); static int mxser_set_serial_info(struct mxser_port *,
struct serial_struct __user *);
static int mxser_get_lsr_info(struct mxser_port *, unsigned int __user *);
static void mxser_send_break(struct mxser_port *, int);
static int mxser_tiocmget(struct tty_struct *, struct file *); static int mxser_tiocmget(struct tty_struct *, struct file *);
static int mxser_tiocmset(struct tty_struct *, struct file *, unsigned int, unsigned int); static int mxser_tiocmset(struct tty_struct *, struct file *, unsigned int,
static int mxser_set_baud(struct mxser_struct *info, long newspd); unsigned int);
static void mxser_wait_until_sent(struct tty_struct *tty, int timeout); static int mxser_set_baud(struct mxser_port *, long);
static void mxser_wait_until_sent(struct tty_struct *, int);
static void mxser_startrx(struct tty_struct *tty); static void mxser_startrx(struct tty_struct *);
static void mxser_stoprx(struct tty_struct *tty); static void mxser_stoprx(struct tty_struct *);
static int CheckIsMoxaMust(int io) static int CheckIsMoxaMust(int io)
...@@ -530,18 +520,18 @@ static void __exit mxser_module_exit(void) ...@@ -530,18 +520,18 @@ static void __exit mxser_module_exit(void)
for (i = 0; i < MXSER_BOARDS; i++) { for (i = 0; i < MXSER_BOARDS; i++) {
struct pci_dev *pdev; struct pci_dev *pdev;
if (mxsercfg[i].board_type == -1) if (mxser_boards[i].board_type == -1)
continue; continue;
else { else {
pdev = mxsercfg[i].pciInfo.pdev; pdev = mxser_boards[i].pdev;
free_irq(mxsercfg[i].irq, &mxvar_table[i * MXSER_PORTS_PER_BOARD]); free_irq(mxser_boards[i].irq, &mxser_boards[i]);
if (pdev != NULL) { /* PCI */ if (pdev != NULL) { /* PCI */
release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2)); release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2));
release_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3)); release_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3));
pci_dev_put(pdev); pci_dev_put(pdev);
} else { } else {
release_region(mxsercfg[i].ioaddr[0], 8 * mxsercfg[i].ports); release_region(mxser_boards[i].ports[0].ioaddr, 8 * mxser_boards[i].nports);
release_region(mxsercfg[i].vector, 1); release_region(mxser_boards[i].vector, 1);
} }
} }
} }
...@@ -549,7 +539,7 @@ static void __exit mxser_module_exit(void) ...@@ -549,7 +539,7 @@ static void __exit mxser_module_exit(void)
printk(KERN_DEBUG "Done.\n"); printk(KERN_DEBUG "Done.\n");
} }
static void process_txrx_fifo(struct mxser_struct *info) static void process_txrx_fifo(struct mxser_port *info)
{ {
int i; int i;
...@@ -558,60 +548,44 @@ static void process_txrx_fifo(struct mxser_struct *info) ...@@ -558,60 +548,44 @@ static void process_txrx_fifo(struct mxser_struct *info)
info->rx_high_water = 1; info->rx_high_water = 1;
info->rx_low_water = 1; info->rx_low_water = 1;
info->xmit_fifo_size = 1; info->xmit_fifo_size = 1;
} else { } else
for (i = 0; i < UART_INFO_NUM; i++) { for (i = 0; i < UART_INFO_NUM; i++)
if (info->IsMoxaMustChipFlag == Gpci_uart_info[i].type) { if (info->board->chip_flag == Gpci_uart_info[i].type) {
info->rx_trigger = Gpci_uart_info[i].rx_trigger; info->rx_trigger = Gpci_uart_info[i].rx_trigger;
info->rx_low_water = Gpci_uart_info[i].rx_low_water; info->rx_low_water = Gpci_uart_info[i].rx_low_water;
info->rx_high_water = Gpci_uart_info[i].rx_high_water; info->rx_high_water = Gpci_uart_info[i].rx_high_water;
info->xmit_fifo_size = Gpci_uart_info[i].xmit_fifo_size; info->xmit_fifo_size = Gpci_uart_info[i].xmit_fifo_size;
break; break;
} }
}
}
} }
static int mxser_initbrd(int board, struct mxser_hwconf *hwconf) static int mxser_initbrd(struct mxser_board *brd)
{ {
struct mxser_struct *info; struct mxser_port *info;
unsigned int i;
int retval; int retval;
int i, n;
n = board * MXSER_PORTS_PER_BOARD;
info = &mxvar_table[n];
/*if (verbose) */ { /*if (verbose) */ {
printk(KERN_DEBUG " ttyM%d - ttyM%d ",
n, n + hwconf->ports - 1);
printk(" max. baud rate = %d bps.\n", printk(" max. baud rate = %d bps.\n",
hwconf->MaxCanSetBaudRate[0]); brd->ports[0].max_baud);
} }
for (i = 0; i < hwconf->ports; i++, n++, info++) { for (i = 0; i < brd->nports; i++) {
info->port = n; info = &brd->ports[i];
info->base = hwconf->ioaddr[i]; info->board = brd;
info->irq = hwconf->irq;
info->vector = hwconf->vector;
info->vectormask = hwconf->vector_mask;
info->opmode_ioaddr = hwconf->opmode_ioaddr[i]; /* add by Victor Yu. 01-05-2004 */
info->stop_rx = 0; info->stop_rx = 0;
info->ldisc_stop_rx = 0; info->ldisc_stop_rx = 0;
info->IsMoxaMustChipFlag = hwconf->IsMoxaMustChipFlag;
/* Enhance mode enabled here */ /* Enhance mode enabled here */
if (info->IsMoxaMustChipFlag != MOXA_OTHER_UART) { if (brd->chip_flag != MOXA_OTHER_UART)
ENABLE_MOXA_MUST_ENCHANCE_MODE(info->base); ENABLE_MOXA_MUST_ENCHANCE_MODE(info->ioaddr);
}
info->flags = ASYNC_SHARE_IRQ; info->flags = ASYNC_SHARE_IRQ;
info->type = hwconf->uart_type; info->type = brd->uart_type;
info->baud_base = hwconf->baud_base[i];
info->MaxCanSetBaudRate = hwconf->MaxCanSetBaudRate[i];
process_txrx_fifo(info); process_txrx_fifo(info);
info->custom_divisor = info->baud_base * 16;
info->custom_divisor = hwconf->baud_base[i] * 16;
info->close_delay = 5 * HZ / 10; info->close_delay = 5 * HZ / 10;
info->closing_wait = 30 * HZ; info->closing_wait = 30 * HZ;
INIT_WORK(&info->tqueue, mxser_do_softint, info); INIT_WORK(&info->tqueue, mxser_do_softint, info);
...@@ -622,118 +596,102 @@ static int mxser_initbrd(int board, struct mxser_hwconf *hwconf) ...@@ -622,118 +596,102 @@ static int mxser_initbrd(int board, struct mxser_hwconf *hwconf)
memset(&info->mon_data, 0, sizeof(struct mxser_mon)); memset(&info->mon_data, 0, sizeof(struct mxser_mon));
info->err_shadow = 0; info->err_shadow = 0;
spin_lock_init(&info->slock); spin_lock_init(&info->slock);
/* before set INT ISR, disable all int */
outb(inb(info->ioaddr + UART_IER) & 0xf0,
info->ioaddr + UART_IER);
} }
/* /*
* Allocate the IRQ if necessary * Allocate the IRQ if necessary
*/ */
retval = request_irq(brd->irq, mxser_interrupt,
/* before set INT ISR, disable all int */ (brd->ports[0].flags & ASYNC_SHARE_IRQ) ? IRQF_SHARED :
for (i = 0; i < hwconf->ports; i++) { IRQF_DISABLED, "mxser", brd);
outb(inb(hwconf->ioaddr[i] + UART_IER) & 0xf0,
hwconf->ioaddr[i] + UART_IER);
}
n = board * MXSER_PORTS_PER_BOARD;
info = &mxvar_table[n];
retval = request_irq(hwconf->irq, mxser_interrupt, IRQ_T(info),
"mxser", info);
if (retval) { if (retval) {
printk(KERN_ERR "Board %d: %s", printk(KERN_ERR "Board %s: Request irq failed, IRQ (%d) may "
board, mxser_brdname[hwconf->board_type - 1]); "conflict with another device.\n",
printk(" Request irq failed, IRQ (%d) may conflict with" mxser_brdname[brd->board_type - 1], brd->irq);
" another device.\n", info->irq);
return retval; return retval;
} }
return 0; return 0;
} }
static void mxser_getcfg(int board, struct mxser_hwconf *hwconf) static int mxser_get_PCI_conf(int board_type, struct mxser_board *brd,
{ struct pci_dev *pdev)
mxsercfg[board] = *hwconf;
}
#ifdef CONFIG_PCI
static int mxser_get_PCI_conf(int busnum, int devnum, int board_type, struct mxser_hwconf *hwconf)
{ {
int i, j; unsigned int i, j;
/* unsigned int val; */
unsigned long ioaddress; unsigned long ioaddress;
struct pci_dev *pdev = hwconf->pciInfo.pdev;
/* io address */ /* io address */
hwconf->board_type = board_type; brd->board_type = board_type;
hwconf->ports = mxser_numports[board_type - 1]; brd->nports = mxser_numports[board_type - 1];
ioaddress = pci_resource_start(pdev, 2); ioaddress = pci_resource_start(pdev, 2);
request_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2), request_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2),
"mxser(IO)"); "mxser(IO)");
for (i = 0; i < hwconf->ports; i++) for (i = 0; i < brd->nports; i++)
hwconf->ioaddr[i] = ioaddress + 8 * i; brd->ports[i].ioaddr = ioaddress + 8 * i;
/* vector */ /* vector */
ioaddress = pci_resource_start(pdev, 3); ioaddress = pci_resource_start(pdev, 3);
request_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3), request_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3),
"mxser(vector)"); "mxser(vector)");
hwconf->vector = ioaddress; brd->vector = ioaddress;
/* irq */ /* irq */
hwconf->irq = hwconf->pciInfo.pdev->irq; brd->irq = pdev->irq;
hwconf->IsMoxaMustChipFlag = CheckIsMoxaMust(hwconf->ioaddr[0]); brd->chip_flag = CheckIsMoxaMust(brd->ports[0].ioaddr);
hwconf->uart_type = PORT_16550A; brd->uart_type = PORT_16550A;
hwconf->vector_mask = 0; brd->vector_mask = 0;
for (i = 0; i < brd->nports; i++) {
for (i = 0; i < hwconf->ports; i++) {
for (j = 0; j < UART_INFO_NUM; j++) { for (j = 0; j < UART_INFO_NUM; j++) {
if (Gpci_uart_info[j].type == hwconf->IsMoxaMustChipFlag) { if (Gpci_uart_info[j].type == brd->chip_flag) {
hwconf->MaxCanSetBaudRate[i] = Gpci_uart_info[j].max_baud; brd->ports[i].max_baud =
Gpci_uart_info[j].max_baud;
/* exception....CP-102 */ /* exception....CP-102 */
if (board_type == MXSER_BOARD_CP102) if (board_type == MXSER_BOARD_CP102)
hwconf->MaxCanSetBaudRate[i] = 921600; brd->ports[i].max_baud = 921600;
break; break;
} }
} }
} }
if (hwconf->IsMoxaMustChipFlag == MOXA_MUST_MU860_HWID) { if (brd->chip_flag == MOXA_MUST_MU860_HWID) {
for (i = 0; i < hwconf->ports; i++) { for (i = 0; i < brd->nports; i++) {
if (i < 4) if (i < 4)
hwconf->opmode_ioaddr[i] = ioaddress + 4; brd->ports[i].opmode_ioaddr = ioaddress + 4;
else else
hwconf->opmode_ioaddr[i] = ioaddress + 0x0c; brd->ports[i].opmode_ioaddr = ioaddress + 0x0c;
} }
outb(0, ioaddress + 4); /* default set to RS232 mode */ outb(0, ioaddress + 4); /* default set to RS232 mode */
outb(0, ioaddress + 0x0c); /* default set to RS232 mode */ outb(0, ioaddress + 0x0c); /* default set to RS232 mode */
} }
for (i = 0; i < hwconf->ports; i++) { for (i = 0; i < brd->nports; i++) {
hwconf->vector_mask |= (1 << i); brd->vector_mask |= (1 << i);
hwconf->baud_base[i] = 921600; brd->ports[i].baud_base = 921600;
} }
return 0; return 0;
} }
#endif
static int mxser_init(void) static int mxser_init(void)
{ {
int i, m, retval, b, n;
struct pci_dev *pdev = NULL; struct pci_dev *pdev = NULL;
int index; struct mxser_board *brd;
unsigned char busnum, devnum; unsigned int i, m;
struct mxser_hwconf hwconf; int retval, b, n;
mxvar_sdriver = alloc_tty_driver(MXSER_PORTS + 1); mxvar_sdriver = alloc_tty_driver(MXSER_PORTS + 1);
if (!mxvar_sdriver) if (!mxvar_sdriver)
return -ENOMEM; return -ENOMEM;
spin_lock_init(&gm_lock); spin_lock_init(&gm_lock);
for (i = 0; i < MXSER_BOARDS; i++) { for (i = 0; i < MXSER_BOARDS; i++)
mxsercfg[i].board_type = -1; mxser_boards[i].board_type = -1;
}
printk(KERN_INFO "MOXA Smartio/Industio family driver version %s\n", printk(KERN_INFO "MOXA Smartio/Industio family driver version %s\n",
MXSER_VERSION); MXSER_VERSION);
...@@ -756,13 +714,12 @@ static int mxser_init(void) ...@@ -756,13 +714,12 @@ static int mxser_init(void)
mxvar_sdriver->termios_locked = mxvar_termios_locked; mxvar_sdriver->termios_locked = mxvar_termios_locked;
mxvar_diagflag = 0; mxvar_diagflag = 0;
memset(mxvar_table, 0, MXSER_PORTS * sizeof(struct mxser_struct)); memset(mxser_boards, 0, sizeof(mxser_boards));
memset(&mxvar_log, 0, sizeof(struct mxser_log)); memset(&mxvar_log, 0, sizeof(struct mxser_log));
memset(&mxser_msr, 0, sizeof(unsigned char) * (MXSER_PORTS + 1)); memset(&mxser_msr, 0, sizeof(unsigned char) * (MXSER_PORTS + 1));
memset(&mon_data_ext, 0, sizeof(struct mxser_mon_ext)); memset(&mon_data_ext, 0, sizeof(struct mxser_mon_ext));
memset(&mxser_set_baud_method, 0, sizeof(int) * (MXSER_PORTS + 1)); memset(&mxser_set_baud_method, 0, sizeof(int) * (MXSER_PORTS + 1));
memset(&hwconf, 0, sizeof(struct mxser_hwconf));
m = 0; m = 0;
/* Start finding ISA boards here */ /* Start finding ISA boards here */
...@@ -772,11 +729,12 @@ static int mxser_init(void) ...@@ -772,11 +729,12 @@ static int mxser_init(void)
if (!(cap = mxserBoardCAP[b])) if (!(cap = mxserBoardCAP[b]))
continue; continue;
retval = mxser_get_ISA_conf(cap, &hwconf); brd = &mxser_boards[m];
retval = mxser_get_ISA_conf(cap, brd);
if (retval != 0) if (retval != 0)
printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n", printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n",
mxser_brdname[hwconf.board_type - 1], ioaddr[b]); mxser_brdname[brd->board_type - 1], ioaddr[b]);
if (retval <= 0) { if (retval <= 0) {
if (retval == MXSER_ERR_IRQ) if (retval == MXSER_ERR_IRQ)
...@@ -795,17 +753,10 @@ static int mxser_init(void) ...@@ -795,17 +753,10 @@ static int mxser_init(void)
continue; continue;
} }
hwconf.pciInfo.busNum = 0; brd->pdev = NULL;
hwconf.pciInfo.devNum = 0;
hwconf.pciInfo.pdev = NULL;
mxser_getcfg(m, &hwconf);
/*
* init mxsercfg first,
* or mxsercfg data is not correct on ISR.
*/
/* mxser_initbrd will hook ISR. */ /* mxser_initbrd will hook ISR. */
if (mxser_initbrd(m, &hwconf) < 0) if (mxser_initbrd(brd) < 0)
continue; continue;
m++; m++;
...@@ -818,11 +769,12 @@ static int mxser_init(void) ...@@ -818,11 +769,12 @@ static int mxser_init(void)
if (!(cap = ioaddr[b])) if (!(cap = ioaddr[b]))
continue; continue;
retval = mxser_get_ISA_conf(cap, &hwconf); brd = &mxser_boards[m];
retval = mxser_get_ISA_conf(cap, &mxser_boards[m]);
if (retval != 0) if (retval != 0)
printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n", printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n",
mxser_brdname[hwconf.board_type - 1], ioaddr[b]); mxser_brdname[brd->board_type - 1], ioaddr[b]);
if (retval <= 0) { if (retval <= 0) {
if (retval == MXSER_ERR_IRQ) if (retval == MXSER_ERR_IRQ)
...@@ -841,26 +793,16 @@ static int mxser_init(void) ...@@ -841,26 +793,16 @@ static int mxser_init(void)
continue; continue;
} }
hwconf.pciInfo.busNum = 0; brd->pdev = NULL;
hwconf.pciInfo.devNum = 0;
hwconf.pciInfo.pdev = NULL;
mxser_getcfg(m, &hwconf);
/*
* init mxsercfg first,
* or mxsercfg data is not correct on ISR.
*/
/* mxser_initbrd will hook ISR. */ /* mxser_initbrd will hook ISR. */
if (mxser_initbrd(m, &hwconf) < 0) if (mxser_initbrd(brd) < 0)
continue; continue;
m++; m++;
} }
/* start finding PCI board here */ /* start finding PCI board here */
#ifdef CONFIG_PCI
n = ARRAY_SIZE(mxser_pcibrds) - 1; n = ARRAY_SIZE(mxser_pcibrds) - 1;
index = 0;
b = 0; b = 0;
while (b < n) { while (b < n) {
pdev = pci_get_device(mxser_pcibrds[b].vendor, pdev = pci_get_device(mxser_pcibrds[b].vendor,
...@@ -869,13 +811,9 @@ static int mxser_init(void) ...@@ -869,13 +811,9 @@ static int mxser_init(void)
b++; b++;
continue; continue;
} }
hwconf.pciInfo.busNum = busnum = pdev->bus->number;
hwconf.pciInfo.devNum = devnum = PCI_SLOT(pdev->devfn) << 3;
hwconf.pciInfo.pdev = pdev;
printk(KERN_INFO "Found MOXA %s board(BusNo=%d,DevNo=%d)\n", printk(KERN_INFO "Found MOXA %s board(BusNo=%d,DevNo=%d)\n",
mxser_brdname[(int) (mxser_pcibrds[b].driver_data) - 1], mxser_brdname[(int) (mxser_pcibrds[b].driver_data) - 1],
busnum, devnum >> 3); pdev->bus->number, PCI_SLOT(pdev->devfn));
index++;
if (m >= MXSER_BOARDS) if (m >= MXSER_BOARDS)
printk(KERN_ERR printk(KERN_ERR
"Too many Smartio/Industio family boards find " "Too many Smartio/Industio family boards find "
...@@ -887,9 +825,11 @@ static int mxser_init(void) ...@@ -887,9 +825,11 @@ static int mxser_init(void)
"fail !\n"); "fail !\n");
continue; continue;
} }
retval = mxser_get_PCI_conf(busnum, devnum, brd = &mxser_boards[m];
brd->pdev = pdev;
retval = mxser_get_PCI_conf(
(int)mxser_pcibrds[b].driver_data, (int)mxser_pcibrds[b].driver_data,
&hwconf); brd, pdev);
if (retval < 0) { if (retval < 0) {
if (retval == MXSER_ERR_IRQ) if (retval == MXSER_ERR_IRQ)
printk(KERN_ERR printk(KERN_ERR
...@@ -909,12 +849,8 @@ static int mxser_init(void) ...@@ -909,12 +849,8 @@ static int mxser_init(void)
"board not configured\n"); "board not configured\n");
continue; continue;
} }
mxser_getcfg(m, &hwconf);
/* init mxsercfg first,
* or mxsercfg data is not correct on ISR.
*/
/* mxser_initbrd will hook ISR. */ /* mxser_initbrd will hook ISR. */
if (mxser_initbrd(m, &hwconf) < 0) if (mxser_initbrd(brd) < 0)
continue; continue;
m++; m++;
/* Keep an extra reference if we succeeded. It will /* Keep an extra reference if we succeeded. It will
...@@ -922,7 +858,6 @@ static int mxser_init(void) ...@@ -922,7 +858,6 @@ static int mxser_init(void)
pci_dev_get(pdev); pci_dev_get(pdev);
} }
} }
#endif
retval = tty_register_driver(mxvar_sdriver); retval = tty_register_driver(mxvar_sdriver);
if (retval) { if (retval) {
...@@ -931,10 +866,10 @@ static int mxser_init(void) ...@@ -931,10 +866,10 @@ static int mxser_init(void)
put_tty_driver(mxvar_sdriver); put_tty_driver(mxvar_sdriver);
for (i = 0; i < MXSER_BOARDS; i++) { for (i = 0; i < MXSER_BOARDS; i++) {
if (mxsercfg[i].board_type == -1) if (mxser_boards[i].board_type == -1)
continue; continue;
else { else {
free_irq(mxsercfg[i].irq, &mxvar_table[i * MXSER_PORTS_PER_BOARD]); free_irq(mxser_boards[i].irq, &mxser_boards[i]);
/* todo: release io, vector */ /* todo: release io, vector */
} }
} }
...@@ -946,7 +881,7 @@ static int mxser_init(void) ...@@ -946,7 +881,7 @@ static int mxser_init(void)
static void mxser_do_softint(void *private_) static void mxser_do_softint(void *private_)
{ {
struct mxser_struct *info = private_; struct mxser_port *info = private_;
struct tty_struct *tty; struct tty_struct *tty;
tty = info->tty; tty = info->tty;
...@@ -957,7 +892,7 @@ static void mxser_do_softint(void *private_) ...@@ -957,7 +892,7 @@ static void mxser_do_softint(void *private_)
tty_hangup(tty); tty_hangup(tty);
} }
static unsigned char mxser_get_msr(int baseaddr, int mode, int port, struct mxser_struct *info) static unsigned char mxser_get_msr(int baseaddr, int mode, int port)
{ {
unsigned char status = 0; unsigned char status = 0;
...@@ -980,7 +915,7 @@ static unsigned char mxser_get_msr(int baseaddr, int mode, int port, struct mxse ...@@ -980,7 +915,7 @@ static unsigned char mxser_get_msr(int baseaddr, int mode, int port, struct mxse
*/ */
static int mxser_open(struct tty_struct *tty, struct file *filp) static int mxser_open(struct tty_struct *tty, struct file *filp)
{ {
struct mxser_struct *info; struct mxser_port *info;
int retval, line; int retval, line;
/* initialize driver_data in case something fails */ /* initialize driver_data in case something fails */
...@@ -991,8 +926,8 @@ static int mxser_open(struct tty_struct *tty, struct file *filp) ...@@ -991,8 +926,8 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
return 0; return 0;
if (line < 0 || line > MXSER_PORTS) if (line < 0 || line > MXSER_PORTS)
return -ENODEV; return -ENODEV;
info = mxvar_table + line; info = &mxser_boards[line / MXSER_PORTS_PER_BOARD].ports[line % MXSER_PORTS_PER_BOARD];
if (!info->base) if (!info->ioaddr)
return -ENODEV; return -ENODEV;
tty->driver_data = info; tty->driver_data = info;
...@@ -1038,7 +973,7 @@ static int mxser_open(struct tty_struct *tty, struct file *filp) ...@@ -1038,7 +973,7 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
*/ */
static void mxser_close(struct tty_struct *tty, struct file *filp) static void mxser_close(struct tty_struct *tty, struct file *filp)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
unsigned long timeout; unsigned long timeout;
unsigned long flags; unsigned long flags;
...@@ -1069,7 +1004,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) ...@@ -1069,7 +1004,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
} }
if (--info->count < 0) { if (--info->count < 0) {
printk(KERN_ERR "mxser_close: bad serial port count for " printk(KERN_ERR "mxser_close: bad serial port count for "
"ttys%d: %d\n", info->port, info->count); "ttys%d: %d\n", tty->index, info->count);
info->count = 0; info->count = 0;
} }
if (info->count) { if (info->count) {
...@@ -1098,20 +1033,20 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) ...@@ -1098,20 +1033,20 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
* line status register. * line status register.
*/ */
info->IER &= ~UART_IER_RLSI; info->IER &= ~UART_IER_RLSI;
if (info->IsMoxaMustChipFlag) if (info->board->chip_flag)
info->IER &= ~MOXA_MUST_RECV_ISR; info->IER &= ~MOXA_MUST_RECV_ISR;
/* by William /* by William
info->read_status_mask &= ~UART_LSR_DR; info->read_status_mask &= ~UART_LSR_DR;
*/ */
if (info->flags & ASYNC_INITIALIZED) { if (info->flags & ASYNC_INITIALIZED) {
outb(info->IER, info->base + UART_IER); outb(info->IER, info->ioaddr + UART_IER);
/* /*
* Before we drop DTR, make sure the UART transmitter * Before we drop DTR, make sure the UART transmitter
* has completely drained; this is especially * has completely drained; this is especially
* important if there is a transmit FIFO! * important if there is a transmit FIFO!
*/ */
timeout = jiffies + HZ; timeout = jiffies + HZ;
while (!(inb(info->base + UART_LSR) & UART_LSR_TEMT)) { while (!(inb(info->ioaddr + UART_LSR) & UART_LSR_TEMT)) {
schedule_timeout_interruptible(5); schedule_timeout_interruptible(5);
if (time_after(jiffies, timeout)) if (time_after(jiffies, timeout))
break; break;
...@@ -1146,7 +1081,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) ...@@ -1146,7 +1081,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count) static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count)
{ {
int c, total = 0; int c, total = 0;
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
unsigned long flags; unsigned long flags;
if (!info->xmit_buf) if (!info->xmit_buf)
...@@ -1174,11 +1109,12 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou ...@@ -1174,11 +1109,12 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou
/*&& !(info->IER & UART_IER_THRI)*/) { /*&& !(info->IER & UART_IER_THRI)*/) {
if (!tty->hw_stopped || if (!tty->hw_stopped ||
(info->type == PORT_16550A) || (info->type == PORT_16550A) ||
(info->IsMoxaMustChipFlag)) { (info->board->chip_flag)) {
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&info->slock, flags);
outb(info->IER & ~UART_IER_THRI, info->base + UART_IER); outb(info->IER & ~UART_IER_THRI, info->ioaddr +
UART_IER);
info->IER |= UART_IER_THRI; info->IER |= UART_IER_THRI;
outb(info->IER, info->base + UART_IER); outb(info->IER, info->ioaddr + UART_IER);
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
} }
} }
...@@ -1187,7 +1123,7 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou ...@@ -1187,7 +1123,7 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou
static void mxser_put_char(struct tty_struct *tty, unsigned char ch) static void mxser_put_char(struct tty_struct *tty, unsigned char ch)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
unsigned long flags; unsigned long flags;
if (!info->xmit_buf) if (!info->xmit_buf)
...@@ -1204,11 +1140,11 @@ static void mxser_put_char(struct tty_struct *tty, unsigned char ch) ...@@ -1204,11 +1140,11 @@ static void mxser_put_char(struct tty_struct *tty, unsigned char ch)
if (!tty->stopped /*&& !(info->IER & UART_IER_THRI)*/) { if (!tty->stopped /*&& !(info->IER & UART_IER_THRI)*/) {
if (!tty->hw_stopped || if (!tty->hw_stopped ||
(info->type == PORT_16550A) || (info->type == PORT_16550A) ||
info->IsMoxaMustChipFlag) { info->board->chip_flag) {
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&info->slock, flags);
outb(info->IER & ~UART_IER_THRI, info->base + UART_IER); outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER);
info->IER |= UART_IER_THRI; info->IER |= UART_IER_THRI;
outb(info->IER, info->base + UART_IER); outb(info->IER, info->ioaddr + UART_IER);
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
} }
} }
...@@ -1217,7 +1153,7 @@ static void mxser_put_char(struct tty_struct *tty, unsigned char ch) ...@@ -1217,7 +1153,7 @@ static void mxser_put_char(struct tty_struct *tty, unsigned char ch)
static void mxser_flush_chars(struct tty_struct *tty) static void mxser_flush_chars(struct tty_struct *tty)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
unsigned long flags; unsigned long flags;
if (info->xmit_cnt <= 0 || if (info->xmit_cnt <= 0 ||
...@@ -1225,22 +1161,22 @@ static void mxser_flush_chars(struct tty_struct *tty) ...@@ -1225,22 +1161,22 @@ static void mxser_flush_chars(struct tty_struct *tty)
!info->xmit_buf || !info->xmit_buf ||
(tty->hw_stopped && (tty->hw_stopped &&
(info->type != PORT_16550A) && (info->type != PORT_16550A) &&
(!info->IsMoxaMustChipFlag) (!info->board->chip_flag)
)) ))
return; return;
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&info->slock, flags);
outb(info->IER & ~UART_IER_THRI, info->base + UART_IER); outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER);
info->IER |= UART_IER_THRI; info->IER |= UART_IER_THRI;
outb(info->IER, info->base + UART_IER); outb(info->IER, info->ioaddr + UART_IER);
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
} }
static int mxser_write_room(struct tty_struct *tty) static int mxser_write_room(struct tty_struct *tty)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
int ret; int ret;
ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1; ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
...@@ -1251,10 +1187,10 @@ static int mxser_write_room(struct tty_struct *tty) ...@@ -1251,10 +1187,10 @@ static int mxser_write_room(struct tty_struct *tty)
static int mxser_chars_in_buffer(struct tty_struct *tty) static int mxser_chars_in_buffer(struct tty_struct *tty)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
int len = info->xmit_cnt; int len = info->xmit_cnt;
if (!(inb(info->base + UART_LSR) & UART_LSR_THRE)) if (!(inb(info->ioaddr + UART_LSR) & UART_LSR_THRE))
len++; len++;
return len; return len;
...@@ -1262,7 +1198,7 @@ static int mxser_chars_in_buffer(struct tty_struct *tty) ...@@ -1262,7 +1198,7 @@ static int mxser_chars_in_buffer(struct tty_struct *tty)
static void mxser_flush_buffer(struct tty_struct *tty) static void mxser_flush_buffer(struct tty_struct *tty)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
char fcr; char fcr;
unsigned long flags; unsigned long flags;
...@@ -1271,10 +1207,10 @@ static void mxser_flush_buffer(struct tty_struct *tty) ...@@ -1271,10 +1207,10 @@ static void mxser_flush_buffer(struct tty_struct *tty)
info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
/* below added by shinhay */ /* below added by shinhay */
fcr = inb(info->base + UART_FCR); fcr = inb(info->ioaddr + UART_FCR);
outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
info->base + UART_FCR); info->ioaddr + UART_FCR);
outb(fcr, info->base + UART_FCR); outb(fcr, info->ioaddr + UART_FCR);
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
/* above added by shinhay */ /* above added by shinhay */
...@@ -1286,7 +1222,7 @@ static void mxser_flush_buffer(struct tty_struct *tty) ...@@ -1286,7 +1222,7 @@ static void mxser_flush_buffer(struct tty_struct *tty)
static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
int retval; int retval;
struct async_icount cprev, cnow; /* kernel counter temps */ struct async_icount cprev, cnow; /* kernel counter temps */
struct serial_icounter_struct __user *p_cuser; 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,7 +1241,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
int shiftbit; int shiftbit;
unsigned char val, mask; unsigned char val, mask;
p = info->port % 4; p = tty->index % 4;
if (cmd == MOXA_SET_OP_MODE) { if (cmd == MOXA_SET_OP_MODE) {
if (get_user(opmode, (int __user *) argp)) if (get_user(opmode, (int __user *) argp))
return -EFAULT; return -EFAULT;
...@@ -1465,7 +1401,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c ...@@ -1465,7 +1401,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
len = mxser_chars_in_buffer(tty); len = mxser_chars_in_buffer(tty);
lsr = inb(info->base + UART_LSR) & UART_LSR_TEMT; lsr = inb(info->ioaddr + UART_LSR) & UART_LSR_TEMT;
len += (lsr ? 0 : 1); len += (lsr ? 0 : 1);
...@@ -1479,10 +1415,10 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c ...@@ -1479,10 +1415,10 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
/* info->mon_data.ser_param = tty->termios->c_cflag; */ /* info->mon_data.ser_param = tty->termios->c_cflag; */
status = mxser_get_msr(info->base, 1, info->port, info); status = mxser_get_msr(info->ioaddr, 1, tty->index);
mxser_check_modem_status(info, status); mxser_check_modem_status(info, status);
mcr = inb(info->base + UART_MCR); mcr = inb(info->ioaddr + UART_MCR);
if (mcr & MOXA_MUST_MCR_XON_FLAG) if (mcr & MOXA_MUST_MCR_XON_FLAG)
info->mon_data.hold_reason &= ~NPPI_NOTIFY_XOFFHOLD; info->mon_data.hold_reason &= ~NPPI_NOTIFY_XOFFHOLD;
else else
...@@ -1518,7 +1454,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c ...@@ -1518,7 +1454,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
if (get_user(method, (int __user *)argp)) if (get_user(method, (int __user *)argp))
return -EFAULT; return -EFAULT;
mxser_set_baud_method[info->port] = method; mxser_set_baud_method[tty->index] = method;
if (copy_to_user(argp, &method, sizeof(int))) if (copy_to_user(argp, &method, sizeof(int)))
return -EFAULT; return -EFAULT;
...@@ -1536,14 +1472,17 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c ...@@ -1536,14 +1472,17 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
static int mxser_ioctl_special(unsigned int cmd, void __user *argp) static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
{ {
int i, result, status; struct mxser_port *port;
int result, status;
unsigned int i, j;
switch (cmd) { switch (cmd) {
case MOXA_GET_CONF: case MOXA_GET_CONF:
if (copy_to_user(argp, mxsercfg, /* if (copy_to_user(argp, mxsercfg,
sizeof(struct mxser_hwconf) * 4)) sizeof(struct mxser_hwconf) * 4))
return -EFAULT; return -EFAULT;
return 0; return 0;*/
return -ENXIO;
case MOXA_GET_MAJOR: case MOXA_GET_MAJOR:
if (copy_to_user(argp, &ttymajor, sizeof(int))) if (copy_to_user(argp, &ttymajor, sizeof(int)))
return -EFAULT; return -EFAULT;
...@@ -1556,96 +1495,106 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) ...@@ -1556,96 +1495,106 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
case MOXA_CHKPORTENABLE: case MOXA_CHKPORTENABLE:
result = 0; result = 0;
for (i = 0; i < MXSER_PORTS; i++) {
if (mxvar_table[i].base) for (i = 0; i < MXSER_BOARDS; i++)
result |= (1 << i); for (j = 0; j < MXSER_PORTS_PER_BOARD; j++)
} if (mxser_boards[i].ports[j].ioaddr)
result |= (1 << i);
return put_user(result, (unsigned long __user *)argp); return put_user(result, (unsigned long __user *)argp);
case MOXA_GETDATACOUNT: case MOXA_GETDATACOUNT:
if (copy_to_user(argp, &mxvar_log, sizeof(mxvar_log))) if (copy_to_user(argp, &mxvar_log, sizeof(mxvar_log)))
return -EFAULT; return -EFAULT;
return 0; return 0;
case MOXA_GETMSTATUS: case MOXA_GETMSTATUS:
for (i = 0; i < MXSER_PORTS; i++) { for (i = 0; i < MXSER_BOARDS; i++)
GMStatus[i].ri = 0; for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) {
if (!mxvar_table[i].base) { port = &mxser_boards[i].ports[j];
GMStatus[i].dcd = 0;
GMStatus[i].dsr = 0; GMStatus[i].ri = 0;
GMStatus[i].cts = 0; if (!port->ioaddr) {
continue; GMStatus[i].dcd = 0;
} GMStatus[i].dsr = 0;
GMStatus[i].cts = 0;
continue;
}
if (!mxvar_table[i].tty || !mxvar_table[i].tty->termios) if (!port->tty || !port->tty->termios)
GMStatus[i].cflag = mxvar_table[i].normal_termios.c_cflag; GMStatus[i].cflag =
else port->normal_termios.c_cflag;
GMStatus[i].cflag = mxvar_table[i].tty->termios->c_cflag; else
GMStatus[i].cflag =
port->tty->termios->c_cflag;
status = inb(mxvar_table[i].base + UART_MSR); status = inb(port->ioaddr + UART_MSR);
if (status & 0x80 /*UART_MSR_DCD */ ) if (status & 0x80 /*UART_MSR_DCD */ )
GMStatus[i].dcd = 1; GMStatus[i].dcd = 1;
else else
GMStatus[i].dcd = 0; GMStatus[i].dcd = 0;
if (status & 0x20 /*UART_MSR_DSR */ ) if (status & 0x20 /*UART_MSR_DSR */ )
GMStatus[i].dsr = 1; GMStatus[i].dsr = 1;
else else
GMStatus[i].dsr = 0; GMStatus[i].dsr = 0;
if (status & 0x10 /*UART_MSR_CTS */ ) if (status & 0x10 /*UART_MSR_CTS */ )
GMStatus[i].cts = 1; GMStatus[i].cts = 1;
else else
GMStatus[i].cts = 0; GMStatus[i].cts = 0;
} }
if (copy_to_user(argp, GMStatus, if (copy_to_user(argp, GMStatus,
sizeof(struct mxser_mstatus) * MXSER_PORTS)) sizeof(struct mxser_mstatus) * MXSER_PORTS))
return -EFAULT; return -EFAULT;
return 0; return 0;
case MOXA_ASPP_MON_EXT: { case MOXA_ASPP_MON_EXT: {
int status, p, shiftbit; int status, p, shiftbit;
unsigned long opmode; unsigned long opmode;
unsigned cflag, iflag; unsigned cflag, iflag;
for (i = 0; i < MXSER_PORTS; i++) { for (i = 0; i < MXSER_BOARDS; i++)
if (!mxvar_table[i].base) for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) {
port = &mxser_boards[i].ports[j];
if (!port->ioaddr)
continue; continue;
status = mxser_get_msr(mxvar_table[i].base, 0, status = mxser_get_msr(port->ioaddr, 0, i);
i, &(mxvar_table[i])); /* mxser_check_modem_status(port, status); */
/*
mxser_check_modem_status(&mxvar_table[i],
status);
*/
if (status & UART_MSR_TERI) if (status & UART_MSR_TERI)
mxvar_table[i].icount.rng++; port->icount.rng++;
if (status & UART_MSR_DDSR) if (status & UART_MSR_DDSR)
mxvar_table[i].icount.dsr++; port->icount.dsr++;
if (status & UART_MSR_DDCD) if (status & UART_MSR_DDCD)
mxvar_table[i].icount.dcd++; port->icount.dcd++;
if (status & UART_MSR_DCTS) if (status & UART_MSR_DCTS)
mxvar_table[i].icount.cts++; port->icount.cts++;
mxvar_table[i].mon_data.modem_status = status; port->mon_data.modem_status = status;
mon_data_ext.rx_cnt[i] = mxvar_table[i].mon_data.rxcnt; mon_data_ext.rx_cnt[i] = port->mon_data.rxcnt;
mon_data_ext.tx_cnt[i] = mxvar_table[i].mon_data.txcnt; mon_data_ext.tx_cnt[i] = port->mon_data.txcnt;
mon_data_ext.up_rxcnt[i] = mxvar_table[i].mon_data.up_rxcnt; mon_data_ext.up_rxcnt[i] =
mon_data_ext.up_txcnt[i] = mxvar_table[i].mon_data.up_txcnt; port->mon_data.up_rxcnt;
mon_data_ext.modem_status[i] = mxvar_table[i].mon_data.modem_status; mon_data_ext.up_txcnt[i] =
mon_data_ext.baudrate[i] = mxvar_table[i].realbaud; port->mon_data.up_txcnt;
mon_data_ext.modem_status[i] =
if (!mxvar_table[i].tty || !mxvar_table[i].tty->termios) { port->mon_data.modem_status;
cflag = mxvar_table[i].normal_termios.c_cflag; mon_data_ext.baudrate[i] = port->realbaud;
iflag = mxvar_table[i].normal_termios.c_iflag;
if (!port->tty || !port->tty->termios) {
cflag = port->normal_termios.c_cflag;
iflag = port->normal_termios.c_iflag;
} else { } else {
cflag = mxvar_table[i].tty->termios->c_cflag; cflag = port->tty->termios->c_cflag;
iflag = mxvar_table[i].tty->termios->c_iflag; iflag = port->tty->termios->c_iflag;
} }
mon_data_ext.databits[i] = cflag & CSIZE; mon_data_ext.databits[i] = cflag & CSIZE;
mon_data_ext.stopbits[i] = cflag & CSTOPB; mon_data_ext.stopbits[i] = cflag & CSTOPB;
mon_data_ext.parity[i] = cflag & (PARENB | PARODD | CMSPAR); mon_data_ext.parity[i] =
cflag & (PARENB | PARODD | CMSPAR);
mon_data_ext.flowctrl[i] = 0x00; mon_data_ext.flowctrl[i] = 0x00;
...@@ -1655,26 +1604,26 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) ...@@ -1655,26 +1604,26 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
if (iflag & (IXON | IXOFF)) if (iflag & (IXON | IXOFF))
mon_data_ext.flowctrl[i] |= 0x0C; mon_data_ext.flowctrl[i] |= 0x0C;
if (mxvar_table[i].type == PORT_16550A) if (port->type == PORT_16550A)
mon_data_ext.fifo[i] = 1; mon_data_ext.fifo[i] = 1;
else else
mon_data_ext.fifo[i] = 0; mon_data_ext.fifo[i] = 0;
p = i % 4; p = i % 4;
shiftbit = p * 2; shiftbit = p * 2;
opmode = inb(mxvar_table[i].opmode_ioaddr) >> shiftbit; opmode = inb(port->opmode_ioaddr) >> shiftbit;
opmode &= OP_MODE_MASK; opmode &= OP_MODE_MASK;
mon_data_ext.iftype[i] = opmode; mon_data_ext.iftype[i] = opmode;
} }
if (copy_to_user(argp, &mon_data_ext, sizeof(struct mxser_mon_ext))) if (copy_to_user(argp, &mon_data_ext,
sizeof(mon_data_ext)))
return -EFAULT; return -EFAULT;
return 0; return 0;
} } default:
default:
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
return 0; return 0;
...@@ -1682,31 +1631,31 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) ...@@ -1682,31 +1631,31 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
static void mxser_stoprx(struct tty_struct *tty) static void mxser_stoprx(struct tty_struct *tty)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
info->ldisc_stop_rx = 1; info->ldisc_stop_rx = 1;
if (I_IXOFF(tty)) { if (I_IXOFF(tty)) {
/* following add by Victor Yu. 09-02-2002 */ /* following add by Victor Yu. 09-02-2002 */
if (info->IsMoxaMustChipFlag) { if (info->board->chip_flag) {
info->IER &= ~MOXA_MUST_RECV_ISR; info->IER &= ~MOXA_MUST_RECV_ISR;
outb(info->IER, info->base + UART_IER); outb(info->IER, info->ioaddr + UART_IER);
} else if (!(info->flags & ASYNC_CLOSING)) { } else if (!(info->flags & ASYNC_CLOSING)) {
info->x_char = STOP_CHAR(tty); info->x_char = STOP_CHAR(tty);
outb(0, info->base + UART_IER); outb(0, info->ioaddr + UART_IER);
info->IER |= UART_IER_THRI; info->IER |= UART_IER_THRI;
outb(info->IER, info->base + UART_IER); outb(info->IER, info->ioaddr + UART_IER);
} }
} }
if (info->tty->termios->c_cflag & CRTSCTS) { if (info->tty->termios->c_cflag & CRTSCTS) {
info->MCR &= ~UART_MCR_RTS; info->MCR &= ~UART_MCR_RTS;
outb(info->MCR, info->base + UART_MCR); outb(info->MCR, info->ioaddr + UART_MCR);
} }
} }
static void mxser_startrx(struct tty_struct *tty) static void mxser_startrx(struct tty_struct *tty)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
info->ldisc_stop_rx = 0; info->ldisc_stop_rx = 0;
if (I_IXOFF(tty)) { if (I_IXOFF(tty)) {
...@@ -1714,21 +1663,21 @@ static void mxser_startrx(struct tty_struct *tty) ...@@ -1714,21 +1663,21 @@ static void mxser_startrx(struct tty_struct *tty)
info->x_char = 0; info->x_char = 0;
else { else {
/* following add by Victor Yu. 09-02-2002 */ /* following add by Victor Yu. 09-02-2002 */
if (info->IsMoxaMustChipFlag) { if (info->board->chip_flag) {
info->IER |= MOXA_MUST_RECV_ISR; info->IER |= MOXA_MUST_RECV_ISR;
outb(info->IER, info->base + UART_IER); outb(info->IER, info->ioaddr + UART_IER);
} else if (!(info->flags & ASYNC_CLOSING)) { } else if (!(info->flags & ASYNC_CLOSING)) {
info->x_char = START_CHAR(tty); info->x_char = START_CHAR(tty);
outb(0, info->base + UART_IER); outb(0, info->ioaddr + UART_IER);
info->IER |= UART_IER_THRI; info->IER |= UART_IER_THRI;
outb(info->IER, info->base + UART_IER); outb(info->IER, info->ioaddr + UART_IER);
} }
} }
} }
if (info->tty->termios->c_cflag & CRTSCTS) { if (info->tty->termios->c_cflag & CRTSCTS) {
info->MCR |= UART_MCR_RTS; info->MCR |= UART_MCR_RTS;
outb(info->MCR, info->base + UART_MCR); outb(info->MCR, info->ioaddr + UART_MCR);
} }
} }
...@@ -1738,7 +1687,7 @@ static void mxser_startrx(struct tty_struct *tty) ...@@ -1738,7 +1687,7 @@ static void mxser_startrx(struct tty_struct *tty)
*/ */
static void mxser_throttle(struct tty_struct *tty) static void mxser_throttle(struct tty_struct *tty)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&info->slock, flags);
...@@ -1748,7 +1697,7 @@ static void mxser_throttle(struct tty_struct *tty) ...@@ -1748,7 +1697,7 @@ static void mxser_throttle(struct tty_struct *tty)
static void mxser_unthrottle(struct tty_struct *tty) static void mxser_unthrottle(struct tty_struct *tty)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&info->slock, flags);
...@@ -1758,7 +1707,7 @@ static void mxser_unthrottle(struct tty_struct *tty) ...@@ -1758,7 +1707,7 @@ static void mxser_unthrottle(struct tty_struct *tty)
static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termios) static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termios)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
unsigned long flags; unsigned long flags;
if ((tty->termios->c_cflag != old_termios->c_cflag) || 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,9 +1728,9 @@ static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termio
tty->stopped = 0; tty->stopped = 0;
/* following add by Victor Yu. 09-02-2002 */ /* following add by Victor Yu. 09-02-2002 */
if (info->IsMoxaMustChipFlag) { if (info->board->chip_flag) {
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&info->slock, flags);
DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->base); DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->ioaddr);
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
} }
/* above add by Victor Yu. 09-02-2002 */ /* 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,28 +1747,28 @@ static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termio
*/ */
static void mxser_stop(struct tty_struct *tty) static void mxser_stop(struct tty_struct *tty)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&info->slock, flags);
if (info->IER & UART_IER_THRI) { if (info->IER & UART_IER_THRI) {
info->IER &= ~UART_IER_THRI; info->IER &= ~UART_IER_THRI;
outb(info->IER, info->base + UART_IER); outb(info->IER, info->ioaddr + UART_IER);
} }
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
} }
static void mxser_start(struct tty_struct *tty) static void mxser_start(struct tty_struct *tty)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&info->slock, flags);
if (info->xmit_cnt && info->xmit_buf if (info->xmit_cnt && info->xmit_buf
/* && !(info->IER & UART_IER_THRI) */) { /* && !(info->IER & UART_IER_THRI) */) {
outb(info->IER & ~UART_IER_THRI, info->base + UART_IER); outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER);
info->IER |= UART_IER_THRI; info->IER |= UART_IER_THRI;
outb(info->IER, info->base + UART_IER); outb(info->IER, info->ioaddr + UART_IER);
} }
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
} }
...@@ -1829,7 +1778,7 @@ static void mxser_start(struct tty_struct *tty) ...@@ -1829,7 +1778,7 @@ static void mxser_start(struct tty_struct *tty)
*/ */
static void mxser_wait_until_sent(struct tty_struct *tty, int timeout) static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
unsigned long orig_jiffies, char_time; unsigned long orig_jiffies, char_time;
int lsr; int lsr;
...@@ -1870,7 +1819,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout) ...@@ -1870,7 +1819,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
timeout, char_time); timeout, char_time);
printk("jiff=%lu...", jiffies); printk("jiff=%lu...", jiffies);
#endif #endif
while (!((lsr = inb(info->base + UART_LSR)) & UART_LSR_TEMT)) { while (!((lsr = inb(info->ioaddr + UART_LSR)) & UART_LSR_TEMT)) {
#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
printk("lsr = %d (jiff=%lu)...", lsr, jiffies); printk("lsr = %d (jiff=%lu)...", lsr, jiffies);
#endif #endif
...@@ -1893,7 +1842,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout) ...@@ -1893,7 +1842,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
*/ */
void mxser_hangup(struct tty_struct *tty) void mxser_hangup(struct tty_struct *tty)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
mxser_flush_buffer(tty); mxser_flush_buffer(tty);
mxser_shutdown(info); mxser_shutdown(info);
...@@ -1911,16 +1860,16 @@ void mxser_hangup(struct tty_struct *tty) ...@@ -1911,16 +1860,16 @@ void mxser_hangup(struct tty_struct *tty)
*/ */
static void mxser_rs_break(struct tty_struct *tty, int break_state) static void mxser_rs_break(struct tty_struct *tty, int break_state)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&info->slock, flags);
if (break_state == -1) if (break_state == -1)
outb(inb(info->base + UART_LCR) | UART_LCR_SBC, outb(inb(info->ioaddr + UART_LCR) | UART_LCR_SBC,
info->base + UART_LCR); info->ioaddr + UART_LCR);
else else
outb(inb(info->base + UART_LCR) & ~UART_LCR_SBC, outb(inb(info->ioaddr + UART_LCR) & ~UART_LCR_SBC,
info->base + UART_LCR); info->ioaddr + UART_LCR);
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
} }
...@@ -1933,74 +1882,72 @@ static void mxser_rs_break(struct tty_struct *tty, int break_state) ...@@ -1933,74 +1882,72 @@ static void mxser_rs_break(struct tty_struct *tty, int break_state)
static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs) static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{ {
int status, iir, i; int status, iir, i;
struct mxser_struct *info; struct mxser_board *brd = NULL;
struct mxser_struct *port; struct mxser_port *port;
int max, irqbits, bits, msr; int max, irqbits, bits, msr;
int pass_counter = 0; int pass_counter = 0;
unsigned int int_cnt; unsigned int int_cnt;
int handled = IRQ_NONE; int handled = IRQ_NONE;
port = NULL;
/* spin_lock(&gm_lock); */ /* spin_lock(&gm_lock); */
for (i = 0; i < MXSER_BOARDS; i++) { for (i = 0; i < MXSER_BOARDS; i++)
if (dev_id == &(mxvar_table[i * MXSER_PORTS_PER_BOARD])) { if (dev_id == &mxser_boards[i]) {
port = dev_id; brd = dev_id;
break; break;
} }
}
if (i == MXSER_BOARDS) if (i == MXSER_BOARDS)
goto irq_stop; goto irq_stop;
if (port == 0) if (brd == NULL)
goto irq_stop; goto irq_stop;
max = mxser_numports[mxsercfg[i].board_type - 1]; max = mxser_numports[brd->board_type - 1];
while (1) { while (1) {
irqbits = inb(port->vector) & port->vectormask; irqbits = inb(brd->vector) & brd->vector_mask;
if (irqbits == port->vectormask) if (irqbits == brd->vector_mask)
break; break;
handled = IRQ_HANDLED; handled = IRQ_HANDLED;
for (i = 0, bits = 1; i < max; i++, irqbits |= bits, bits <<= 1) { for (i = 0, bits = 1; i < max; i++, irqbits |= bits, bits <<= 1) {
if (irqbits == port->vectormask) if (irqbits == brd->vector_mask)
break; break;
if (bits & irqbits) if (bits & irqbits)
continue; continue;
info = port + i; port = &brd->ports[i];
int_cnt = 0; int_cnt = 0;
do { do {
/* following add by Victor Yu. 09-13-2002 */ /* following add by Victor Yu. 09-13-2002 */
iir = inb(info->base + UART_IIR); iir = inb(port->ioaddr + UART_IIR);
if (iir & UART_IIR_NO_INT) if (iir & UART_IIR_NO_INT)
break; break;
iir &= MOXA_MUST_IIR_MASK; iir &= MOXA_MUST_IIR_MASK;
if (!info->tty) { if (!port->tty) {
status = inb(info->base + UART_LSR); status = inb(port->ioaddr + UART_LSR);
outb(0x27, info->base + UART_FCR); outb(0x27, port->ioaddr + UART_FCR);
inb(info->base + UART_MSR); inb(port->ioaddr + UART_MSR);
break; break;
} }
/* above add by Victor Yu. 09-13-2002 */ /* above add by Victor Yu. 09-13-2002 */
spin_lock(&info->slock); spin_lock(&port->slock);
/* following add by Victor Yu. 09-02-2002 */ /* following add by Victor Yu. 09-02-2002 */
status = inb(info->base + UART_LSR); status = inb(port->ioaddr + UART_LSR);
if (status & UART_LSR_PE) if (status & UART_LSR_PE)
info->err_shadow |= NPPI_NOTIFY_PARITY; port->err_shadow |= NPPI_NOTIFY_PARITY;
if (status & UART_LSR_FE) if (status & UART_LSR_FE)
info->err_shadow |= NPPI_NOTIFY_FRAMING; port->err_shadow |= NPPI_NOTIFY_FRAMING;
if (status & UART_LSR_OE) if (status & UART_LSR_OE)
info->err_shadow |= port->err_shadow |=
NPPI_NOTIFY_HW_OVERRUN; NPPI_NOTIFY_HW_OVERRUN;
if (status & UART_LSR_BI) if (status & UART_LSR_BI)
info->err_shadow |= NPPI_NOTIFY_BREAK; port->err_shadow |= NPPI_NOTIFY_BREAK;
if (info->IsMoxaMustChipFlag) { if (port->board->chip_flag) {
/* /*
if ( (status & 0x02) && !(status & 0x01) ) { if ( (status & 0x02) && !(status & 0x01) ) {
outb(info->base+UART_FCR, 0x23); outb(port->ioaddr+UART_FCR, 0x23);
continue; continue;
} }
*/ */
...@@ -2008,33 +1955,33 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs) ...@@ -2008,33 +1955,33 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
iir == MOXA_MUST_IIR_RDA || iir == MOXA_MUST_IIR_RDA ||
iir == MOXA_MUST_IIR_RTO || iir == MOXA_MUST_IIR_RTO ||
iir == MOXA_MUST_IIR_LSR) iir == MOXA_MUST_IIR_LSR)
mxser_receive_chars(info, mxser_receive_chars(port,
&status); &status);
} else { } else {
/* above add by Victor Yu. 09-02-2002 */ /* above add by Victor Yu. 09-02-2002 */
status &= info->read_status_mask; status &= port->read_status_mask;
if (status & UART_LSR_DR) if (status & UART_LSR_DR)
mxser_receive_chars(info, mxser_receive_chars(port,
&status); &status);
} }
msr = inb(info->base + UART_MSR); msr = inb(port->ioaddr + UART_MSR);
if (msr & UART_MSR_ANY_DELTA) if (msr & UART_MSR_ANY_DELTA)
mxser_check_modem_status(info, msr); mxser_check_modem_status(port, msr);
/* following add by Victor Yu. 09-13-2002 */ /* following add by Victor Yu. 09-13-2002 */
if (info->IsMoxaMustChipFlag) { if (port->board->chip_flag) {
if (iir == 0x02 && (status & if (iir == 0x02 && (status &
UART_LSR_THRE)) UART_LSR_THRE))
mxser_transmit_chars(info); mxser_transmit_chars(port);
} else { } else {
/* above add by Victor Yu. 09-13-2002 */ /* above add by Victor Yu. 09-13-2002 */
if (status & UART_LSR_THRE) if (status & UART_LSR_THRE)
mxser_transmit_chars(info); mxser_transmit_chars(port);
} }
spin_unlock(&info->slock); spin_unlock(&port->slock);
} while (int_cnt++ < MXSER_ISR_PASS_LIMIT); } while (int_cnt++ < MXSER_ISR_PASS_LIMIT);
} }
if (pass_counter++ > MXSER_ISR_PASS_LIMIT) 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,9 +1993,9 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
return handled; return handled;
} }
static void mxser_receive_chars(struct mxser_struct *info, int *status) static void mxser_receive_chars(struct mxser_port *port, int *status)
{ {
struct tty_struct *tty = info->tty; struct tty_struct *tty = port->tty;
unsigned char ch, gdl; unsigned char ch, gdl;
int ignored = 0; int ignored = 0;
int cnt = 0; int cnt = 0;
...@@ -2056,42 +2003,42 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status) ...@@ -2056,42 +2003,42 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status)
int max = 256; int max = 256;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&port->slock, flags);
recv_room = tty->receive_room; recv_room = tty->receive_room;
if ((recv_room == 0) && (!info->ldisc_stop_rx)) { if ((recv_room == 0) && (!port->ldisc_stop_rx)) {
/* mxser_throttle(tty); */ /* mxser_throttle(tty); */
mxser_stoprx(tty); mxser_stoprx(tty);
/* return; */ /* return; */
} }
/* following add by Victor Yu. 09-02-2002 */ /* following add by Victor Yu. 09-02-2002 */
if (info->IsMoxaMustChipFlag != MOXA_OTHER_UART) { if (port->board->chip_flag != MOXA_OTHER_UART) {
if (*status & UART_LSR_SPECIAL) if (*status & UART_LSR_SPECIAL)
goto intr_old; goto intr_old;
/* following add by Victor Yu. 02-11-2004 */ /* following add by Victor Yu. 02-11-2004 */
if (info->IsMoxaMustChipFlag == MOXA_MUST_MU860_HWID && if (port->board->chip_flag == MOXA_MUST_MU860_HWID &&
(*status & MOXA_MUST_LSR_RERR)) (*status & MOXA_MUST_LSR_RERR))
goto intr_old; goto intr_old;
/* above add by Victor Yu. 02-14-2004 */ /* above add by Victor Yu. 02-14-2004 */
if (*status & MOXA_MUST_LSR_RERR) if (*status & MOXA_MUST_LSR_RERR)
goto intr_old; goto intr_old;
gdl = inb(info->base + MOXA_MUST_GDL_REGISTER); gdl = inb(port->ioaddr + MOXA_MUST_GDL_REGISTER);
/* add by Victor Yu. 02-11-2004 */ /* add by Victor Yu. 02-11-2004 */
if (info->IsMoxaMustChipFlag == MOXA_MUST_MU150_HWID) if (port->board->chip_flag == MOXA_MUST_MU150_HWID)
gdl &= MOXA_MUST_GDL_MASK; gdl &= MOXA_MUST_GDL_MASK;
if (gdl >= recv_room) { if (gdl >= recv_room) {
if (!info->ldisc_stop_rx) { if (!port->ldisc_stop_rx) {
/* mxser_throttle(tty); */ /* mxser_throttle(tty); */
mxser_stoprx(tty); mxser_stoprx(tty);
} }
/* return; */ /* return; */
} }
while (gdl--) { while (gdl--) {
ch = inb(info->base + UART_RX); ch = inb(port->ioaddr + UART_RX);
tty_insert_flip_char(tty, ch, 0); tty_insert_flip_char(tty, ch, 0);
cnt++; cnt++;
} }
...@@ -2104,14 +2051,14 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status) ...@@ -2104,14 +2051,14 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status)
if (max-- < 0) if (max-- < 0)
break; break;
ch = inb(info->base + UART_RX); ch = inb(port->ioaddr + UART_RX);
/* following add by Victor Yu. 09-02-2002 */ /* following add by Victor Yu. 09-02-2002 */
if (info->IsMoxaMustChipFlag && (*status & UART_LSR_OE) if (port->board->chip_flag && (*status & UART_LSR_OE)
/*&& !(*status&UART_LSR_DR) */) /*&& !(*status&UART_LSR_DR) */)
outb(0x23, info->base + UART_FCR); outb(0x23, port->ioaddr + UART_FCR);
*status &= info->read_status_mask; *status &= port->read_status_mask;
/* above add by Victor Yu. 09-02-2002 */ /* above add by Victor Yu. 09-02-2002 */
if (*status & info->ignore_status_mask) { if (*status & port->ignore_status_mask) {
if (++ignored > 100) if (++ignored > 100)
break; break;
} else { } else {
...@@ -2120,22 +2067,22 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status) ...@@ -2120,22 +2067,22 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status)
if (*status & UART_LSR_BI) { if (*status & UART_LSR_BI) {
flag = TTY_BREAK; flag = TTY_BREAK;
/* added by casper 1/11/2000 */ /* added by casper 1/11/2000 */
info->icount.brk++; port->icount.brk++;
if (info->flags & ASYNC_SAK) if (port->flags & ASYNC_SAK)
do_SAK(tty); do_SAK(tty);
} else if (*status & UART_LSR_PE) { } else if (*status & UART_LSR_PE) {
flag = TTY_PARITY; flag = TTY_PARITY;
/* added by casper 1/11/2000 */ /* added by casper 1/11/2000 */
info->icount.parity++; port->icount.parity++;
} else if (*status & UART_LSR_FE) { } else if (*status & UART_LSR_FE) {
flag = TTY_FRAME; flag = TTY_FRAME;
/* added by casper 1/11/2000 */ /* added by casper 1/11/2000 */
info->icount.frame++; port->icount.frame++;
} else if (*status & UART_LSR_OE) { } else if (*status & UART_LSR_OE) {
flag = TTY_OVERRUN; flag = TTY_OVERRUN;
/* added by casper 1/11/2000 */ /* added by casper 1/11/2000 */
info->icount.overrun++; port->icount.overrun++;
} else } else
flags = TTY_BREAK; flags = TTY_BREAK;
} else } else
...@@ -2143,7 +2090,7 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status) ...@@ -2143,7 +2090,7 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status)
tty_insert_flip_char(tty, ch, flag); tty_insert_flip_char(tty, ch, flag);
cnt++; cnt++;
if (cnt >= recv_room) { if (cnt >= recv_room) {
if (!info->ldisc_stop_rx) { if (!port->ldisc_stop_rx) {
/* mxser_throttle(tty); */ /* mxser_throttle(tty); */
mxser_stoprx(tty); mxser_stoprx(tty);
} }
...@@ -2153,142 +2100,144 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status) ...@@ -2153,142 +2100,144 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status)
} }
/* following add by Victor Yu. 09-02-2002 */ /* following add by Victor Yu. 09-02-2002 */
if (info->IsMoxaMustChipFlag) if (port->board->chip_flag)
break; break;
/* mask by Victor Yu. 09-02-2002 /* mask by Victor Yu. 09-02-2002
*status = inb(info->base + UART_LSR) & info->read_status_mask; *status = inb(port->ioaddr + UART_LSR) & port->read_status_mask;
*/ */
/* following add by Victor Yu. 09-02-2002 */ /* following add by Victor Yu. 09-02-2002 */
*status = inb(info->base + UART_LSR); *status = inb(port->ioaddr + UART_LSR);
/* above add by Victor Yu. 09-02-2002 */ /* above add by Victor Yu. 09-02-2002 */
} while (*status & UART_LSR_DR); } while (*status & UART_LSR_DR);
end_intr: /* add by Victor Yu. 09-02-2002 */ end_intr: /* add by Victor Yu. 09-02-2002 */
mxvar_log.rxcnt[info->port] += cnt; mxvar_log.rxcnt[port->tty->index] += cnt;
info->mon_data.rxcnt += cnt; port->mon_data.rxcnt += cnt;
info->mon_data.up_rxcnt += cnt; port->mon_data.up_rxcnt += cnt;
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&port->slock, flags);
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
} }
static void mxser_transmit_chars(struct mxser_struct *info) static void mxser_transmit_chars(struct mxser_port *port)
{ {
int count, cnt; int count, cnt;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&port->slock, flags);
if (info->x_char) { if (port->x_char) {
outb(info->x_char, info->base + UART_TX); outb(port->x_char, port->ioaddr + UART_TX);
info->x_char = 0; port->x_char = 0;
mxvar_log.txcnt[info->port]++; mxvar_log.txcnt[port->tty->index]++;
info->mon_data.txcnt++; port->mon_data.txcnt++;
info->mon_data.up_txcnt++; port->mon_data.up_txcnt++;
/* added by casper 1/11/2000 */ /* added by casper 1/11/2000 */
info->icount.tx++; port->icount.tx++;
goto unlock; goto unlock;
} }
if (info->xmit_buf == 0) if (port->xmit_buf == 0)
goto unlock; goto unlock;
if (info->xmit_cnt == 0) { if (port->xmit_cnt == 0) {
if (info->xmit_cnt < WAKEUP_CHARS) { /* XXX what's this for?? */ if (port->xmit_cnt < WAKEUP_CHARS) { /* XXX what's this for?? */
set_bit(MXSER_EVENT_TXLOW, &info->event); set_bit(MXSER_EVENT_TXLOW, &port->event);
schedule_work(&info->tqueue); schedule_work(&port->tqueue);
} }
goto unlock; goto unlock;
} }
if (info->tty->stopped || (info->tty->hw_stopped && if (port->tty->stopped || (port->tty->hw_stopped &&
(info->type != PORT_16550A) && (port->type != PORT_16550A) &&
(!info->IsMoxaMustChipFlag))) { (!port->board->chip_flag))) {
info->IER &= ~UART_IER_THRI; port->IER &= ~UART_IER_THRI;
outb(info->IER, info->base + UART_IER); outb(port->IER, port->ioaddr + UART_IER);
goto unlock; goto unlock;
} }
cnt = info->xmit_cnt; cnt = port->xmit_cnt;
count = info->xmit_fifo_size; count = port->xmit_fifo_size;
do { do {
outb(info->xmit_buf[info->xmit_tail++], outb(port->xmit_buf[port->xmit_tail++],
info->base + UART_TX); port->ioaddr + UART_TX);
info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE - 1); port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE - 1);
if (--info->xmit_cnt <= 0) if (--port->xmit_cnt <= 0)
break; break;
} while (--count > 0); } while (--count > 0);
mxvar_log.txcnt[info->port] += (cnt - info->xmit_cnt); mxvar_log.txcnt[port->tty->index] += (cnt - port->xmit_cnt);
/* added by James 03-12-2004. */ /* added by James 03-12-2004. */
info->mon_data.txcnt += (cnt - info->xmit_cnt); port->mon_data.txcnt += (cnt - port->xmit_cnt);
info->mon_data.up_txcnt += (cnt - info->xmit_cnt); port->mon_data.up_txcnt += (cnt - port->xmit_cnt);
/* added by casper 1/11/2000 */ /* added by casper 1/11/2000 */
info->icount.tx += (cnt - info->xmit_cnt); port->icount.tx += (cnt - port->xmit_cnt);
if (info->xmit_cnt < WAKEUP_CHARS) { if (port->xmit_cnt < WAKEUP_CHARS) {
set_bit(MXSER_EVENT_TXLOW, &info->event); set_bit(MXSER_EVENT_TXLOW, &port->event);
schedule_work(&info->tqueue); schedule_work(&port->tqueue);
} }
if (info->xmit_cnt <= 0) { if (port->xmit_cnt <= 0) {
info->IER &= ~UART_IER_THRI; port->IER &= ~UART_IER_THRI;
outb(info->IER, info->base + UART_IER); outb(port->IER, port->ioaddr + UART_IER);
} }
unlock: unlock:
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&port->slock, flags);
} }
static void mxser_check_modem_status(struct mxser_struct *info, int status) static void mxser_check_modem_status(struct mxser_port *port, int status)
{ {
/* update input line counters */ /* update input line counters */
if (status & UART_MSR_TERI) if (status & UART_MSR_TERI)
info->icount.rng++; port->icount.rng++;
if (status & UART_MSR_DDSR) if (status & UART_MSR_DDSR)
info->icount.dsr++; port->icount.dsr++;
if (status & UART_MSR_DDCD) if (status & UART_MSR_DDCD)
info->icount.dcd++; port->icount.dcd++;
if (status & UART_MSR_DCTS) if (status & UART_MSR_DCTS)
info->icount.cts++; port->icount.cts++;
info->mon_data.modem_status = status; port->mon_data.modem_status = status;
wake_up_interruptible(&info->delta_msr_wait); wake_up_interruptible(&port->delta_msr_wait);
if ((info->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) { if ((port->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
if (status & UART_MSR_DCD) if (status & UART_MSR_DCD)
wake_up_interruptible(&info->open_wait); wake_up_interruptible(&port->open_wait);
schedule_work(&info->tqueue); schedule_work(&port->tqueue);
} }
if (info->flags & ASYNC_CTS_FLOW) { if (port->flags & ASYNC_CTS_FLOW) {
if (info->tty->hw_stopped) { if (port->tty->hw_stopped) {
if (status & UART_MSR_CTS) { if (status & UART_MSR_CTS) {
info->tty->hw_stopped = 0; port->tty->hw_stopped = 0;
if ((info->type != PORT_16550A) && if ((port->type != PORT_16550A) &&
(!info->IsMoxaMustChipFlag)) { (!port->board->chip_flag)) {
outb(info->IER & ~UART_IER_THRI, outb(port->IER & ~UART_IER_THRI,
info->base + UART_IER); port->ioaddr + UART_IER);
info->IER |= UART_IER_THRI; port->IER |= UART_IER_THRI;
outb(info->IER, info->base + UART_IER); outb(port->IER, port->ioaddr +
UART_IER);
} }
set_bit(MXSER_EVENT_TXLOW, &info->event); set_bit(MXSER_EVENT_TXLOW, &port->event);
schedule_work(&info->tqueue); schedule_work(&port->tqueue);
} }
} else { } else {
if (!(status & UART_MSR_CTS)) { if (!(status & UART_MSR_CTS)) {
info->tty->hw_stopped = 1; port->tty->hw_stopped = 1;
if (info->type != PORT_16550A && if (port->type != PORT_16550A &&
!info->IsMoxaMustChipFlag) { !port->board->chip_flag) {
info->IER &= ~UART_IER_THRI; port->IER &= ~UART_IER_THRI;
outb(info->IER, info->base + UART_IER); outb(port->IER, port->ioaddr +
UART_IER);
} }
} }
} }
} }
} }
static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, struct mxser_struct *info) static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, struct mxser_port *port)
{ {
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
int retval; int retval;
...@@ -2300,7 +2249,7 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru ...@@ -2300,7 +2249,7 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru
* then make the check up front and then exit. * then make the check up front and then exit.
*/ */
if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) { if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) {
info->flags |= ASYNC_NORMAL_ACTIVE; port->flags |= ASYNC_NORMAL_ACTIVE;
return 0; return 0;
} }
...@@ -2310,34 +2259,34 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru ...@@ -2310,34 +2259,34 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru
/* /*
* Block waiting for the carrier detect and the line to become * Block waiting for the carrier detect and the line to become
* free (i.e., not in use by the callout). While we are in * free (i.e., not in use by the callout). While we are in
* this loop, info->count is dropped by one, so that * this loop, port->count is dropped by one, so that
* mxser_close() knows when to free things. We restore it upon * mxser_close() knows when to free things. We restore it upon
* exit, either normal or abnormal. * exit, either normal or abnormal.
*/ */
retval = 0; retval = 0;
add_wait_queue(&info->open_wait, &wait); add_wait_queue(&port->open_wait, &wait);
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&port->slock, flags);
if (!tty_hung_up_p(filp)) if (!tty_hung_up_p(filp))
info->count--; port->count--;
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&port->slock, flags);
info->blocked_open++; port->blocked_open++;
while (1) { while (1) {
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&port->slock, flags);
outb(inb(info->base + UART_MCR) | outb(inb(port->ioaddr + UART_MCR) |
UART_MCR_DTR | UART_MCR_RTS, info->base + UART_MCR); UART_MCR_DTR | UART_MCR_RTS, port->ioaddr + UART_MCR);
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&port->slock, flags);
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)) { if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) {
if (info->flags & ASYNC_HUP_NOTIFY) if (port->flags & ASYNC_HUP_NOTIFY)
retval = -EAGAIN; retval = -EAGAIN;
else else
retval = -ERESTARTSYS; retval = -ERESTARTSYS;
break; break;
} }
if (!(info->flags & ASYNC_CLOSING) && if (!(port->flags & ASYNC_CLOSING) &&
(do_clocal || (do_clocal ||
(inb(info->base + UART_MSR) & UART_MSR_DCD))) (inb(port->ioaddr + UART_MSR) & UART_MSR_DCD)))
break; break;
if (signal_pending(current)) { if (signal_pending(current)) {
retval = -ERESTARTSYS; retval = -ERESTARTSYS;
...@@ -2346,17 +2295,17 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru ...@@ -2346,17 +2295,17 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru
schedule(); schedule();
} }
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
remove_wait_queue(&info->open_wait, &wait); remove_wait_queue(&port->open_wait, &wait);
if (!tty_hung_up_p(filp)) if (!tty_hung_up_p(filp))
info->count++; port->count++;
info->blocked_open--; port->blocked_open--;
if (retval) if (retval)
return retval; return retval;
info->flags |= ASYNC_NORMAL_ACTIVE; port->flags |= ASYNC_NORMAL_ACTIVE;
return 0; return 0;
} }
static int mxser_startup(struct mxser_struct *info) static int mxser_startup(struct mxser_port *info)
{ {
unsigned long page; unsigned long page;
unsigned long flags; unsigned long flags;
...@@ -2373,7 +2322,7 @@ static int mxser_startup(struct mxser_struct *info) ...@@ -2373,7 +2322,7 @@ static int mxser_startup(struct mxser_struct *info)
return 0; return 0;
} }
if (!info->base || !info->type) { if (!info->ioaddr || !info->type) {
if (info->tty) if (info->tty)
set_bit(TTY_IO_ERROR, &info->tty->flags); set_bit(TTY_IO_ERROR, &info->tty->flags);
free_page(page); free_page(page);
...@@ -2389,20 +2338,20 @@ static int mxser_startup(struct mxser_struct *info) ...@@ -2389,20 +2338,20 @@ static int mxser_startup(struct mxser_struct *info)
* Clear the FIFO buffers and disable them * Clear the FIFO buffers and disable them
* (they will be reenabled in mxser_change_speed()) * (they will be reenabled in mxser_change_speed())
*/ */
if (info->IsMoxaMustChipFlag) if (info->board->chip_flag)
outb((UART_FCR_CLEAR_RCVR | outb((UART_FCR_CLEAR_RCVR |
UART_FCR_CLEAR_XMIT | UART_FCR_CLEAR_XMIT |
MOXA_MUST_FCR_GDA_MODE_ENABLE), info->base + UART_FCR); MOXA_MUST_FCR_GDA_MODE_ENABLE), info->ioaddr + UART_FCR);
else else
outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
info->base + UART_FCR); info->ioaddr + UART_FCR);
/* /*
* At this point there's no way the LSR could still be 0xFF; * At this point there's no way the LSR could still be 0xFF;
* if it is, then bail out, because there's likely no UART * if it is, then bail out, because there's likely no UART
* here. * here.
*/ */
if (inb(info->base + UART_LSR) == 0xff) { if (inb(info->ioaddr + UART_LSR) == 0xff) {
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
if (capable(CAP_SYS_ADMIN)) { if (capable(CAP_SYS_ADMIN)) {
if (info->tty) if (info->tty)
...@@ -2415,17 +2364,17 @@ static int mxser_startup(struct mxser_struct *info) ...@@ -2415,17 +2364,17 @@ static int mxser_startup(struct mxser_struct *info)
/* /*
* Clear the interrupt registers. * Clear the interrupt registers.
*/ */
(void) inb(info->base + UART_LSR); (void) inb(info->ioaddr + UART_LSR);
(void) inb(info->base + UART_RX); (void) inb(info->ioaddr + UART_RX);
(void) inb(info->base + UART_IIR); (void) inb(info->ioaddr + UART_IIR);
(void) inb(info->base + UART_MSR); (void) inb(info->ioaddr + UART_MSR);
/* /*
* Now, initialize the UART * Now, initialize the UART
*/ */
outb(UART_LCR_WLEN8, info->base + UART_LCR); /* reset DLAB */ outb(UART_LCR_WLEN8, info->ioaddr + UART_LCR); /* reset DLAB */
info->MCR = UART_MCR_DTR | UART_MCR_RTS; info->MCR = UART_MCR_DTR | UART_MCR_RTS;
outb(info->MCR, info->base + UART_MCR); outb(info->MCR, info->ioaddr + UART_MCR);
/* /*
* Finally, enable interrupts * Finally, enable interrupts
...@@ -2434,18 +2383,18 @@ static int mxser_startup(struct mxser_struct *info) ...@@ -2434,18 +2383,18 @@ static int mxser_startup(struct mxser_struct *info)
/* info->IER = UART_IER_RLSI | UART_IER_RDI; */ /* info->IER = UART_IER_RLSI | UART_IER_RDI; */
/* following add by Victor Yu. 08-30-2002 */ /* following add by Victor Yu. 08-30-2002 */
if (info->IsMoxaMustChipFlag) if (info->board->chip_flag)
info->IER |= MOXA_MUST_IER_EGDAI; info->IER |= MOXA_MUST_IER_EGDAI;
/* above add by Victor Yu. 08-30-2002 */ /* above add by Victor Yu. 08-30-2002 */
outb(info->IER, info->base + UART_IER); /* enable interrupts */ outb(info->IER, info->ioaddr + UART_IER); /* enable interrupts */
/* /*
* And clear the interrupt registers again for luck. * And clear the interrupt registers again for luck.
*/ */
(void) inb(info->base + UART_LSR); (void) inb(info->ioaddr + UART_LSR);
(void) inb(info->base + UART_RX); (void) inb(info->ioaddr + UART_RX);
(void) inb(info->base + UART_IIR); (void) inb(info->ioaddr + UART_IIR);
(void) inb(info->base + UART_MSR); (void) inb(info->ioaddr + UART_MSR);
if (info->tty) if (info->tty)
clear_bit(TTY_IO_ERROR, &info->tty->flags); clear_bit(TTY_IO_ERROR, &info->tty->flags);
...@@ -2465,7 +2414,7 @@ static int mxser_startup(struct mxser_struct *info) ...@@ -2465,7 +2414,7 @@ static int mxser_startup(struct mxser_struct *info)
* This routine will shutdown a serial port; interrupts maybe disabled, and * This routine will shutdown a serial port; interrupts maybe disabled, and
* DTR is dropped if the hangup on close termio flag is on. * DTR is dropped if the hangup on close termio flag is on.
*/ */
static void mxser_shutdown(struct mxser_struct *info) static void mxser_shutdown(struct mxser_port *info)
{ {
unsigned long flags; unsigned long flags;
...@@ -2489,25 +2438,25 @@ static void mxser_shutdown(struct mxser_struct *info) ...@@ -2489,25 +2438,25 @@ static void mxser_shutdown(struct mxser_struct *info)
} }
info->IER = 0; info->IER = 0;
outb(0x00, info->base + UART_IER); outb(0x00, info->ioaddr + UART_IER);
if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) if (!info->tty || (info->tty->termios->c_cflag & HUPCL))
info->MCR &= ~(UART_MCR_DTR | UART_MCR_RTS); info->MCR &= ~(UART_MCR_DTR | UART_MCR_RTS);
outb(info->MCR, info->base + UART_MCR); outb(info->MCR, info->ioaddr + UART_MCR);
/* clear Rx/Tx FIFO's */ /* clear Rx/Tx FIFO's */
/* following add by Victor Yu. 08-30-2002 */ /* following add by Victor Yu. 08-30-2002 */
if (info->IsMoxaMustChipFlag) if (info->board->chip_flag)
outb((UART_FCR_CLEAR_RCVR | outb(UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT |
UART_FCR_CLEAR_XMIT | MOXA_MUST_FCR_GDA_MODE_ENABLE,
MOXA_MUST_FCR_GDA_MODE_ENABLE), info->base + UART_FCR); info->ioaddr + UART_FCR);
else else
/* above add by Victor Yu. 08-30-2002 */ /* above add by Victor Yu. 08-30-2002 */
outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), outb(UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT,
info->base + UART_FCR); info->ioaddr + UART_FCR);
/* read data port to reset things */ /* read data port to reset things */
(void) inb(info->base + UART_RX); (void) inb(info->ioaddr + UART_RX);
if (info->tty) if (info->tty)
set_bit(TTY_IO_ERROR, &info->tty->flags); set_bit(TTY_IO_ERROR, &info->tty->flags);
...@@ -2515,8 +2464,8 @@ static void mxser_shutdown(struct mxser_struct *info) ...@@ -2515,8 +2464,8 @@ static void mxser_shutdown(struct mxser_struct *info)
info->flags &= ~ASYNC_INITIALIZED; info->flags &= ~ASYNC_INITIALIZED;
/* following add by Victor Yu. 09-23-2002 */ /* following add by Victor Yu. 09-23-2002 */
if (info->IsMoxaMustChipFlag) if (info->board->chip_flag)
SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(info->base); SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(info->ioaddr);
/* above add by Victor Yu. 09-23-2002 */ /* above add by Victor Yu. 09-23-2002 */
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
...@@ -2526,7 +2475,8 @@ static void mxser_shutdown(struct mxser_struct *info) ...@@ -2526,7 +2475,8 @@ static void mxser_shutdown(struct mxser_struct *info)
* This routine is called to set the UART divisor registers to match * This routine is called to set the UART divisor registers to match
* the specified baud rate for a serial port. * the specified baud rate for a serial port.
*/ */
static int mxser_change_speed(struct mxser_struct *info, struct termios *old_termios) static int mxser_change_speed(struct mxser_port *info,
struct termios *old_termios)
{ {
unsigned cflag, cval, fcr; unsigned cflag, cval, fcr;
int ret = 0; int ret = 0;
...@@ -2537,13 +2487,13 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter ...@@ -2537,13 +2487,13 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
if (!info->tty || !info->tty->termios) if (!info->tty || !info->tty->termios)
return ret; return ret;
cflag = info->tty->termios->c_cflag; cflag = info->tty->termios->c_cflag;
if (!(info->base)) if (!(info->ioaddr))
return ret; return ret;
#ifndef B921600 #ifndef B921600
#define B921600 (B460800 +1) #define B921600 (B460800 +1)
#endif #endif
if (mxser_set_baud_method[info->port] == 0) { if (mxser_set_baud_method[info->tty->index] == 0) {
baud = tty_get_baud_rate(info->tty); baud = tty_get_baud_rate(info->tty);
mxser_set_baud(info, baud); mxser_set_baud(info, baud);
} }
...@@ -2576,7 +2526,7 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter ...@@ -2576,7 +2526,7 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
cval |= UART_LCR_SPAR; cval |= UART_LCR_SPAR;
if ((info->type == PORT_8250) || (info->type == PORT_16450)) { if ((info->type == PORT_8250) || (info->type == PORT_16450)) {
if (info->IsMoxaMustChipFlag) { if (info->board->chip_flag) {
fcr = UART_FCR_ENABLE_FIFO; fcr = UART_FCR_ENABLE_FIFO;
fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE; fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE;
SET_MOXA_MUST_FIFO_VALUE(info); SET_MOXA_MUST_FIFO_VALUE(info);
...@@ -2585,7 +2535,7 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter ...@@ -2585,7 +2535,7 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
} else { } else {
fcr = UART_FCR_ENABLE_FIFO; fcr = UART_FCR_ENABLE_FIFO;
/* following add by Victor Yu. 08-30-2002 */ /* following add by Victor Yu. 08-30-2002 */
if (info->IsMoxaMustChipFlag) { if (info->board->chip_flag) {
fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE; fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE;
SET_MOXA_MUST_FIFO_VALUE(info); SET_MOXA_MUST_FIFO_VALUE(info);
} else { } else {
...@@ -2613,9 +2563,9 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter ...@@ -2613,9 +2563,9 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
if (cflag & CRTSCTS) { if (cflag & CRTSCTS) {
info->flags |= ASYNC_CTS_FLOW; info->flags |= ASYNC_CTS_FLOW;
info->IER |= UART_IER_MSI; info->IER |= UART_IER_MSI;
if ((info->type == PORT_16550A) || (info->IsMoxaMustChipFlag)) { if ((info->type == PORT_16550A) || (info->board->chip_flag)) {
info->MCR |= UART_MCR_AFE; info->MCR |= UART_MCR_AFE;
/* status = mxser_get_msr(info->base, 0, info->port); */ /* status = mxser_get_msr(info->ioaddr, 0, info->port); */
/* /*
save_flags(flags); save_flags(flags);
cli(); cli();
...@@ -2624,19 +2574,21 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter ...@@ -2624,19 +2574,21 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
*/ */
/* mxser_check_modem_status(info, status); */ /* mxser_check_modem_status(info, status); */
} else { } else {
/* status = mxser_get_msr(info->base, 0, info->port); */ /* status = mxser_get_msr(info->ioaddr, 0, info->port); */
/* MX_LOCK(&info->slock); */ /* MX_LOCK(&info->slock); */
status = inb(info->base + UART_MSR); status = inb(info->ioaddr + UART_MSR);
/* MX_UNLOCK(&info->slock); */ /* MX_UNLOCK(&info->slock); */
if (info->tty->hw_stopped) { if (info->tty->hw_stopped) {
if (status & UART_MSR_CTS) { if (status & UART_MSR_CTS) {
info->tty->hw_stopped = 0; info->tty->hw_stopped = 0;
if (info->type != PORT_16550A && if (info->type != PORT_16550A &&
!info->IsMoxaMustChipFlag) { !info->board->chip_flag) {
outb(info->IER & ~UART_IER_THRI, outb(info->IER & ~UART_IER_THRI,
info->base + UART_IER); info->ioaddr +
UART_IER);
info->IER |= UART_IER_THRI; info->IER |= UART_IER_THRI;
outb(info->IER, info->base + UART_IER); outb(info->IER, info->ioaddr +
UART_IER);
} }
set_bit(MXSER_EVENT_TXLOW, &info->event); set_bit(MXSER_EVENT_TXLOW, &info->event);
schedule_work(&info->tqueue); } schedule_work(&info->tqueue); }
...@@ -2644,9 +2596,10 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter ...@@ -2644,9 +2596,10 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
if (!(status & UART_MSR_CTS)) { if (!(status & UART_MSR_CTS)) {
info->tty->hw_stopped = 1; info->tty->hw_stopped = 1;
if ((info->type != PORT_16550A) && if ((info->type != PORT_16550A) &&
(!info->IsMoxaMustChipFlag)) { (!info->board->chip_flag)) {
info->IER &= ~UART_IER_THRI; info->IER &= ~UART_IER_THRI;
outb(info->IER, info->base + UART_IER); outb(info->IER, info->ioaddr +
UART_IER);
} }
} }
} }
...@@ -2654,14 +2607,14 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter ...@@ -2654,14 +2607,14 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
} else { } else {
info->flags &= ~ASYNC_CTS_FLOW; info->flags &= ~ASYNC_CTS_FLOW;
} }
outb(info->MCR, info->base + UART_MCR); outb(info->MCR, info->ioaddr + UART_MCR);
if (cflag & CLOCAL) { if (cflag & CLOCAL) {
info->flags &= ~ASYNC_CHECK_CD; info->flags &= ~ASYNC_CHECK_CD;
} else { } else {
info->flags |= ASYNC_CHECK_CD; info->flags |= ASYNC_CHECK_CD;
info->IER |= UART_IER_MSI; info->IER |= UART_IER_MSI;
} }
outb(info->IER, info->base + UART_IER); outb(info->IER, info->ioaddr + UART_IER);
/* /*
* Set up parity check flag * Set up parity check flag
...@@ -2693,27 +2646,27 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter ...@@ -2693,27 +2646,27 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
} }
} }
/* following add by Victor Yu. 09-02-2002 */ /* following add by Victor Yu. 09-02-2002 */
if (info->IsMoxaMustChipFlag) { if (info->board->chip_flag) {
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&info->slock, flags);
SET_MOXA_MUST_XON1_VALUE(info->base, START_CHAR(info->tty)); SET_MOXA_MUST_XON1_VALUE(info->ioaddr, START_CHAR(info->tty));
SET_MOXA_MUST_XOFF1_VALUE(info->base, STOP_CHAR(info->tty)); SET_MOXA_MUST_XOFF1_VALUE(info->ioaddr, STOP_CHAR(info->tty));
if (I_IXON(info->tty)) { if (I_IXON(info->tty)) {
ENABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->base); ENABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->ioaddr);
} else { } else {
DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->base); DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->ioaddr);
} }
if (I_IXOFF(info->tty)) { if (I_IXOFF(info->tty)) {
ENABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(info->base); ENABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(info->ioaddr);
} else { } else {
DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(info->base); DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(info->ioaddr);
} }
/* /*
if ( I_IXANY(info->tty) ) { if ( I_IXANY(info->tty) ) {
info->MCR |= MOXA_MUST_MCR_XON_ANY; info->MCR |= MOXA_MUST_MCR_XON_ANY;
ENABLE_MOXA_MUST_XON_ANY_FLOW_CONTROL(info->base); ENABLE_MOXA_MUST_XON_ANY_FLOW_CONTROL(info->ioaddr);
} else { } else {
info->MCR &= ~MOXA_MUST_MCR_XON_ANY; info->MCR &= ~MOXA_MUST_MCR_XON_ANY;
DISABLE_MOXA_MUST_XON_ANY_FLOW_CONTROL(info->base); DISABLE_MOXA_MUST_XON_ANY_FLOW_CONTROL(info->ioaddr);
} }
*/ */
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
...@@ -2721,14 +2674,14 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter ...@@ -2721,14 +2674,14 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
/* above add by Victor Yu. 09-02-2002 */ /* above add by Victor Yu. 09-02-2002 */
outb(fcr, info->base + UART_FCR); /* set fcr */ outb(fcr, info->ioaddr + UART_FCR); /* set fcr */
outb(cval, info->base + UART_LCR); outb(cval, info->ioaddr + UART_LCR);
return ret; return ret;
} }
static int mxser_set_baud(struct mxser_struct *info, long newspd) static int mxser_set_baud(struct mxser_port *info, long newspd)
{ {
int quot = 0; int quot = 0;
unsigned char cval; unsigned char cval;
...@@ -2738,10 +2691,10 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd) ...@@ -2738,10 +2691,10 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
if (!info->tty || !info->tty->termios) if (!info->tty || !info->tty->termios)
return ret; return ret;
if (!(info->base)) if (!(info->ioaddr))
return ret; return ret;
if (newspd > info->MaxCanSetBaudRate) if (newspd > info->max_baud)
return 0; return 0;
info->realbaud = newspd; info->realbaud = newspd;
...@@ -2761,23 +2714,23 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd) ...@@ -2761,23 +2714,23 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
if (quot) { if (quot) {
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&info->slock, flags);
info->MCR |= UART_MCR_DTR; info->MCR |= UART_MCR_DTR;
outb(info->MCR, info->base + UART_MCR); outb(info->MCR, info->ioaddr + UART_MCR);
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
} else { } else {
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&info->slock, flags);
info->MCR &= ~UART_MCR_DTR; info->MCR &= ~UART_MCR_DTR;
outb(info->MCR, info->base + UART_MCR); outb(info->MCR, info->ioaddr + UART_MCR);
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
return ret; return ret;
} }
cval = inb(info->base + UART_LCR); cval = inb(info->ioaddr + UART_LCR);
outb(cval | UART_LCR_DLAB, info->base + UART_LCR); /* set DLAB */ outb(cval | UART_LCR_DLAB, info->ioaddr + UART_LCR); /* set DLAB */
outb(quot & 0xff, info->base + UART_DLL); /* LS of divisor */ outb(quot & 0xff, info->ioaddr + UART_DLL); /* LS of divisor */
outb(quot >> 8, info->base + UART_DLM); /* MS of divisor */ outb(quot >> 8, info->ioaddr + UART_DLM); /* MS of divisor */
outb(cval, info->base + UART_LCR); /* reset DLAB */ outb(cval, info->ioaddr + UART_LCR); /* reset DLAB */
return ret; return ret;
...@@ -2788,7 +2741,8 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd) ...@@ -2788,7 +2741,8 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
* friends of mxser_ioctl() * friends of mxser_ioctl()
* ------------------------------------------------------------ * ------------------------------------------------------------
*/ */
static int mxser_get_serial_info(struct mxser_struct *info, struct serial_struct __user *retinfo) static int mxser_get_serial_info(struct mxser_port *info,
struct serial_struct __user *retinfo)
{ {
struct serial_struct tmp; struct serial_struct tmp;
...@@ -2796,9 +2750,9 @@ static int mxser_get_serial_info(struct mxser_struct *info, struct serial_struct ...@@ -2796,9 +2750,9 @@ static int mxser_get_serial_info(struct mxser_struct *info, struct serial_struct
return -EFAULT; return -EFAULT;
memset(&tmp, 0, sizeof(tmp)); memset(&tmp, 0, sizeof(tmp));
tmp.type = info->type; tmp.type = info->type;
tmp.line = info->port; tmp.line = info->tty->index;
tmp.port = info->base; tmp.port = info->ioaddr;
tmp.irq = info->irq; tmp.irq = info->board->irq;
tmp.flags = info->flags; tmp.flags = info->flags;
tmp.baud_base = info->baud_base; tmp.baud_base = info->baud_base;
tmp.close_delay = info->close_delay; tmp.close_delay = info->close_delay;
...@@ -2810,19 +2764,20 @@ static int mxser_get_serial_info(struct mxser_struct *info, struct serial_struct ...@@ -2810,19 +2764,20 @@ static int mxser_get_serial_info(struct mxser_struct *info, struct serial_struct
return 0; return 0;
} }
static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct __user *new_info) static int mxser_set_serial_info(struct mxser_port *info,
struct serial_struct __user *new_info)
{ {
struct serial_struct new_serial; struct serial_struct new_serial;
unsigned int flags; unsigned int flags;
int retval = 0; int retval = 0;
if (!new_info || !info->base) if (!new_info || !info->ioaddr)
return -EFAULT; return -EFAULT;
if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
return -EFAULT; return -EFAULT;
if ((new_serial.irq != info->irq) || if ((new_serial.irq != info->board->irq) ||
(new_serial.port != info->base) || (new_serial.port != info->ioaddr) ||
(new_serial.custom_divisor != info->custom_divisor) || (new_serial.custom_divisor != info->custom_divisor) ||
(new_serial.baud_base != info->baud_base)) (new_serial.baud_base != info->baud_base))
return -EPERM; return -EPERM;
...@@ -2856,12 +2811,11 @@ static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct ...@@ -2856,12 +2811,11 @@ static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct
process_txrx_fifo(info); process_txrx_fifo(info);
if (info->flags & ASYNC_INITIALIZED) { if (info->flags & ASYNC_INITIALIZED) {
if (flags != (info->flags & ASYNC_SPD_MASK)) { if (flags != (info->flags & ASYNC_SPD_MASK))
mxser_change_speed(info, NULL); mxser_change_speed(info, NULL);
} } else
} else {
retval = mxser_startup(info); retval = mxser_startup(info);
}
return retval; return retval;
} }
...@@ -2875,14 +2829,15 @@ static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct ...@@ -2875,14 +2829,15 @@ static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct
* transmit holding register is empty. This functionality * transmit holding register is empty. This functionality
* allows an RS485 driver to be written in user space. * allows an RS485 driver to be written in user space.
*/ */
static int mxser_get_lsr_info(struct mxser_struct *info, unsigned int __user *value) static int mxser_get_lsr_info(struct mxser_port *info,
unsigned int __user *value)
{ {
unsigned char status; unsigned char status;
unsigned int result; unsigned int result;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&info->slock, flags);
status = inb(info->base + UART_LSR); status = inb(info->ioaddr + UART_LSR);
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0); result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0);
return put_user(result, value); return put_user(result, value);
...@@ -2891,27 +2846,27 @@ static int mxser_get_lsr_info(struct mxser_struct *info, unsigned int __user *va ...@@ -2891,27 +2846,27 @@ static int mxser_get_lsr_info(struct mxser_struct *info, unsigned int __user *va
/* /*
* This routine sends a break character out the serial port. * This routine sends a break character out the serial port.
*/ */
static void mxser_send_break(struct mxser_struct *info, int duration) static void mxser_send_break(struct mxser_port *info, int duration)
{ {
unsigned long flags; unsigned long flags;
if (!info->base) if (!info->ioaddr)
return; return;
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&info->slock, flags);
outb(inb(info->base + UART_LCR) | UART_LCR_SBC, outb(inb(info->ioaddr + UART_LCR) | UART_LCR_SBC,
info->base + UART_LCR); info->ioaddr + UART_LCR);
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
schedule_timeout(duration); schedule_timeout(duration);
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&info->slock, flags);
outb(inb(info->base + UART_LCR) & ~UART_LCR_SBC, outb(inb(info->ioaddr + UART_LCR) & ~UART_LCR_SBC,
info->base + UART_LCR); info->ioaddr + UART_LCR);
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
} }
static int mxser_tiocmget(struct tty_struct *tty, struct file *file) static int mxser_tiocmget(struct tty_struct *tty, struct file *file)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
unsigned char control, status; unsigned char control, status;
unsigned long flags; unsigned long flags;
...@@ -2924,7 +2879,7 @@ static int mxser_tiocmget(struct tty_struct *tty, struct file *file) ...@@ -2924,7 +2879,7 @@ static int mxser_tiocmget(struct tty_struct *tty, struct file *file)
control = info->MCR; control = info->MCR;
spin_lock_irqsave(&info->slock, flags); spin_lock_irqsave(&info->slock, flags);
status = inb(info->base + UART_MSR); status = inb(info->ioaddr + UART_MSR);
if (status & UART_MSR_ANY_DELTA) if (status & UART_MSR_ANY_DELTA)
mxser_check_modem_status(info, status); mxser_check_modem_status(info, status);
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
...@@ -2936,9 +2891,10 @@ static int mxser_tiocmget(struct tty_struct *tty, struct file *file) ...@@ -2936,9 +2891,10 @@ static int mxser_tiocmget(struct tty_struct *tty, struct file *file)
((status & UART_MSR_CTS) ? TIOCM_CTS : 0); ((status & UART_MSR_CTS) ? TIOCM_CTS : 0);
} }
static int mxser_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) static int mxser_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear)
{ {
struct mxser_struct *info = tty->driver_data; struct mxser_port *info = tty->driver_data;
unsigned long flags; unsigned long flags;
...@@ -2959,7 +2915,7 @@ static int mxser_tiocmset(struct tty_struct *tty, struct file *file, unsigned in ...@@ -2959,7 +2915,7 @@ static int mxser_tiocmset(struct tty_struct *tty, struct file *file, unsigned in
if (clear & TIOCM_DTR) if (clear & TIOCM_DTR)
info->MCR &= ~UART_MCR_DTR; info->MCR &= ~UART_MCR_DTR;
outb(info->MCR, info->base + UART_MCR); outb(info->MCR, info->ioaddr + UART_MCR);
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
return 0; return 0;
} }
...@@ -2969,49 +2925,49 @@ static int mxser_read_register(int, unsigned short *); ...@@ -2969,49 +2925,49 @@ static int mxser_read_register(int, unsigned short *);
static int mxser_program_mode(int); static int mxser_program_mode(int);
static void mxser_normal_mode(int); static void mxser_normal_mode(int);
static int mxser_get_ISA_conf(int cap, struct mxser_hwconf *hwconf) static int mxser_get_ISA_conf(int cap, struct mxser_board *brd)
{ {
int id, i, bits; int id, i, bits;
unsigned short regs[16], irq; unsigned short regs[16], irq;
unsigned char scratch, scratch2; unsigned char scratch, scratch2;
hwconf->IsMoxaMustChipFlag = MOXA_OTHER_UART; brd->chip_flag = MOXA_OTHER_UART;
id = mxser_read_register(cap, regs); id = mxser_read_register(cap, regs);
if (id == C168_ASIC_ID) { if (id == C168_ASIC_ID) {
hwconf->board_type = MXSER_BOARD_C168_ISA; brd->board_type = MXSER_BOARD_C168_ISA;
hwconf->ports = 8; brd->nports = 8;
} else if (id == C104_ASIC_ID) { } else if (id == C104_ASIC_ID) {
hwconf->board_type = MXSER_BOARD_C104_ISA; brd->board_type = MXSER_BOARD_C104_ISA;
hwconf->ports = 4; brd->nports = 4;
} else if (id == C102_ASIC_ID) { } else if (id == C102_ASIC_ID) {
hwconf->board_type = MXSER_BOARD_C102_ISA; brd->board_type = MXSER_BOARD_C102_ISA;
hwconf->ports = 2; brd->nports = 2;
} else if (id == CI132_ASIC_ID) { } else if (id == CI132_ASIC_ID) {
hwconf->board_type = MXSER_BOARD_CI132; brd->board_type = MXSER_BOARD_CI132;
hwconf->ports = 2; brd->nports = 2;
} else if (id == CI134_ASIC_ID) { } else if (id == CI134_ASIC_ID) {
hwconf->board_type = MXSER_BOARD_CI134; brd->board_type = MXSER_BOARD_CI134;
hwconf->ports = 4; brd->nports = 4;
} else if (id == CI104J_ASIC_ID) { } else if (id == CI104J_ASIC_ID) {
hwconf->board_type = MXSER_BOARD_CI104J; brd->board_type = MXSER_BOARD_CI104J;
hwconf->ports = 4; brd->nports = 4;
} else } else
return 0; return 0;
irq = 0; irq = 0;
if (hwconf->ports == 2) { if (brd->nports == 2) {
irq = regs[9] & 0xF000; irq = regs[9] & 0xF000;
irq = irq | (irq >> 4); irq = irq | (irq >> 4);
if (irq != (regs[9] & 0xFF00)) if (irq != (regs[9] & 0xFF00))
return MXSER_ERR_IRQ_CONFLIT; return MXSER_ERR_IRQ_CONFLIT;
} else if (hwconf->ports == 4) { } else if (brd->nports == 4) {
irq = regs[9] & 0xF000; irq = regs[9] & 0xF000;
irq = irq | (irq >> 4); irq = irq | (irq >> 4);
irq = irq | (irq >> 8); irq = irq | (irq >> 8);
if (irq != regs[9]) if (irq != regs[9])
return MXSER_ERR_IRQ_CONFLIT; return MXSER_ERR_IRQ_CONFLIT;
} else if (hwconf->ports == 8) { } else if (brd->nports == 8) {
irq = regs[9] & 0xF000; irq = regs[9] & 0xF000;
irq = irq | (irq >> 4); irq = irq | (irq >> 4);
irq = irq | (irq >> 8); irq = irq | (irq >> 8);
...@@ -3021,23 +2977,23 @@ static int mxser_get_ISA_conf(int cap, struct mxser_hwconf *hwconf) ...@@ -3021,23 +2977,23 @@ static int mxser_get_ISA_conf(int cap, struct mxser_hwconf *hwconf)
if (!irq) if (!irq)
return MXSER_ERR_IRQ; return MXSER_ERR_IRQ;
hwconf->irq = ((int)(irq & 0xF000) >> 12); brd->irq = ((int)(irq & 0xF000) >> 12);
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
hwconf->ioaddr[i] = (int) regs[i + 1] & 0xFFF8; brd->ports[i].ioaddr = (int) regs[i + 1] & 0xFFF8;
if ((regs[12] & 0x80) == 0) if ((regs[12] & 0x80) == 0)
return MXSER_ERR_VECTOR; return MXSER_ERR_VECTOR;
hwconf->vector = (int)regs[11]; /* interrupt vector */ brd->vector = (int)regs[11]; /* interrupt vector */
if (id == 1) if (id == 1)
hwconf->vector_mask = 0x00FF; brd->vector_mask = 0x00FF;
else else
hwconf->vector_mask = 0x000F; brd->vector_mask = 0x000F;
for (i = 7, bits = 0x0100; i >= 0; i--, bits <<= 1) { for (i = 7, bits = 0x0100; i >= 0; i--, bits <<= 1) {
if (regs[12] & bits) { if (regs[12] & bits) {
hwconf->baud_base[i] = 921600; brd->ports[i].baud_base = 921600;
hwconf->MaxCanSetBaudRate[i] = 921600; /* add by Victor Yu. 09-04-2002 */ brd->ports[i].max_baud = 921600; /* add by Victor Yu. 09-04-2002 */
} else { } else {
hwconf->baud_base[i] = 115200; brd->ports[i].baud_base = 115200;
hwconf->MaxCanSetBaudRate[i] = 115200; /* add by Victor Yu. 09-04-2002 */ brd->ports[i].max_baud = 115200; /* add by Victor Yu. 09-04-2002 */
} }
} }
scratch2 = inb(cap + UART_LCR) & (~UART_LCR_DLAB); 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,16 +3004,16 @@ static int mxser_get_ISA_conf(int cap, struct mxser_hwconf *hwconf)
scratch = inb(cap + UART_IIR); scratch = inb(cap + UART_IIR);
if (scratch & 0xC0) if (scratch & 0xC0)
hwconf->uart_type = PORT_16550A; brd->uart_type = PORT_16550A;
else else
hwconf->uart_type = PORT_16450; brd->uart_type = PORT_16450;
if (id == 1) if (id == 1)
hwconf->ports = 8; brd->nports = 8;
else else
hwconf->ports = 4; brd->nports = 4;
request_region(hwconf->ioaddr[0], 8 * hwconf->ports, "mxser(IO)"); request_region(brd->ports[0].ioaddr, 8 * brd->nports, "mxser(IO)");
request_region(hwconf->vector, 1, "mxser(vector)"); request_region(brd->vector, 1, "mxser(vector)");
return hwconf->ports; return brd->nports;
} }
#define CHIP_SK 0x01 /* Serial Data Clock in Eprom */ #define CHIP_SK 0x01 /* Serial Data Clock in Eprom */
......
...@@ -300,16 +300,16 @@ ...@@ -300,16 +300,16 @@
//#define MOXA_MUST_RBRL_VALUE 4 //#define MOXA_MUST_RBRL_VALUE 4
#define SET_MOXA_MUST_FIFO_VALUE(info) { \ #define SET_MOXA_MUST_FIFO_VALUE(info) { \
u8 __oldlcr, __efr; \ u8 __oldlcr, __efr; \
__oldlcr = inb((info)->base+UART_LCR); \ __oldlcr = inb((info)->ioaddr+UART_LCR); \
outb(MOXA_MUST_ENTER_ENCHANCE, (info)->base+UART_LCR); \ outb(MOXA_MUST_ENTER_ENCHANCE, (info)->ioaddr+UART_LCR); \
__efr = inb((info)->base+MOXA_MUST_EFR_REGISTER); \ __efr = inb((info)->ioaddr+MOXA_MUST_EFR_REGISTER); \
__efr &= ~MOXA_MUST_EFR_BANK_MASK; \ __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
__efr |= MOXA_MUST_EFR_BANK1; \ __efr |= MOXA_MUST_EFR_BANK1; \
outb(__efr, (info)->base+MOXA_MUST_EFR_REGISTER); \ outb(__efr, (info)->ioaddr+MOXA_MUST_EFR_REGISTER); \
outb((u8)((info)->rx_high_water), (info)->base+MOXA_MUST_RBRTH_REGISTER); \ outb((u8)((info)->rx_high_water), (info)->ioaddr+MOXA_MUST_RBRTH_REGISTER); \
outb((u8)((info)->rx_trigger), (info)->base+MOXA_MUST_RBRTI_REGISTER); \ outb((u8)((info)->rx_trigger), (info)->ioaddr+MOXA_MUST_RBRTI_REGISTER); \
outb((u8)((info)->rx_low_water), (info)->base+MOXA_MUST_RBRTL_REGISTER); \ outb((u8)((info)->rx_low_water), (info)->ioaddr+MOXA_MUST_RBRTL_REGISTER); \
outb(__oldlcr, (info)->base+UART_LCR); \ outb(__oldlcr, (info)->ioaddr+UART_LCR); \
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment