patch-2.3.19 linux/drivers/char/cyclades.c
Next file: linux/drivers/char/drm/fops.c
Previous file: linux/drivers/char/c-qcam.c
Back to the patch index
Back to the overall index
- Lines: 1666
- Date:
Sat Oct 2 07:50:16 1999
- Orig file:
v2.3.18/linux/drivers/char/cyclades.c
- Orig date:
Fri Sep 10 23:57:29 1999
diff -u --recursive --new-file v2.3.18/linux/drivers/char/cyclades.c linux/drivers/char/cyclades.c
@@ -1,7 +1,7 @@
-#define BLOCKMOVE
+#undef BLOCKMOVE
#define Z_WAKE
static char rcsid[] =
-"$Revision: 2.3.1.1 $$Date: 1999/07/15 16:45:53 $";
+"$Revision: 2.3.2.2 $$Date: 1999/10/01 11:27:43 $";
/*
* linux/drivers/char/cyclades.c
@@ -9,9 +9,8 @@
* This file contains the driver for the Cyclades Cyclom-Y multiport
* serial boards.
*
- * Maintained by Ivan Passos (ivan@cyclades.com),
- * Marcio Saito (marcio@cyclades.com) and
- * Randolph Bentson (bentson@grieg.seaslug.org).
+ * Initially written by Randolph Bentson (bentson@grieg.seaslug.org).
+ * Maintained by Ivan Passos (ivan@cyclades.com).
*
* For Technical support and installation problems, please send e-mail
* to support@cyclades.com.
@@ -31,6 +30,25 @@
* void cleanup_module(void);
*
* $Log: cyclades.c,v $
+ * Revision 2.3.2.2 1999/10/01 11:27:43 ivan
+ * Fixed bug in cyz_poll that would make all ports but port 0
+ * unable to transmit/receive data (Cyclades-Z only);
+ * Implemented logic to prevent the RX buffer from being stuck with
+ * due to a driver / firmware race condition in interrupt op mode
+ * (Cyclades-Z only);
+ * Fixed bug in block_til_ready logic that would lead to a system crash;
+ * Revisited cy_close spinlock usage;
+ *
+ * Revision 2.3.2.1 1999/09/28 11:01:22 ivan
+ * Revisited CONFIG_PCI conditional compilation for PCI board support;
+ * Implemented TIOCGICOUNT and TIOCMIWAIT ioctl support;
+ * _Major_ cleanup on the Cyclades-Z interrupt support code / logic;
+ * Removed CTS handling from the driver -- this is now completely handled
+ * by the firmware (Cyclades-Z only);
+ * Flush RX on-board buffers on a port open (Cyclades-Z only);
+ * Fixed handling of ASYNC_SPD_* TTY flags;
+ * Module unload now unmaps all memory area allocated by ioremap;
+ *
* Revision 2.3.1.1 1999/07/15 16:45:53 ivan
* Removed CY_PROC conditional compilation;
* Implemented SMP-awareness for the driver;
@@ -655,7 +673,8 @@
#define cy_put_user put_user
-static unsigned long cy_get_user(unsigned long *addr)
+static unsigned long
+cy_get_user(unsigned long *addr)
{
unsigned long result = 0;
int error = get_user (result, addr);
@@ -829,6 +848,7 @@
static unsigned short cy_pci_nboard = 0;
static unsigned short cy_isa_nboard = 0;
static unsigned short cy_nboard = 0;
+#ifdef CONFIG_PCI
static unsigned short cy_pci_dev_id[] = {
PCI_DEVICE_ID_CYCLOM_Y_Lo, /* PCI < 1Mb */
PCI_DEVICE_ID_CYCLOM_Y_Hi, /* PCI > 1Mb */
@@ -840,10 +860,11 @@
PCI_DEVICE_ID_CYCLOM_Z_Hi, /* Z PCI > 1Mb */
0 /* end of table */
};
-
+#endif
static void cy_start(struct tty_struct *);
static void set_line_char(struct cyclades_port *);
+static int cyz_issue_cmd(struct cyclades_card *, uclong, ucchar, uclong);
#ifndef CONFIG_COBALT_27
static unsigned detect_isa_irq (volatile ucchar *);
#endif /* CONFIG_COBALT_27 */
@@ -864,6 +885,9 @@
cyz_timerlist = {
NULL, NULL, 0, 0, cyz_poll
};
+#else /* CONFIG_CYZ_INTR */
+static void cyz_rx_restart(unsigned long);
+static struct timer_list cyz_rx_full_timer[NR_PORTS];
#endif /* CONFIG_CYZ_INTR */
/**************************************************
@@ -968,6 +992,17 @@
if (test_and_clear_bit(Cy_EVENT_OPEN_WAKEUP, &info->event)) {
wake_up_interruptible(&info->open_wait);
}
+#ifdef CONFIG_CYZ_INTR
+ if (test_and_clear_bit(Cy_EVENT_Z_RX_FULL, &info->event)) {
+ cyz_rx_full_timer[info->line].expires = jiffies + 1;
+ cyz_rx_full_timer[info->line].function = cyz_rx_restart;
+ cyz_rx_full_timer[info->line].data = (unsigned long)info;
+ add_timer(&cyz_rx_full_timer[info->line]);
+ }
+#endif
+ if (test_and_clear_bit(Cy_EVENT_DELTA_WAKEUP, &info->event)) {
+ wake_up_interruptible(&info->delta_msr_wait);
+ }
if (test_and_clear_bit(Cy_EVENT_WRITE_WAKEUP, &info->event)) {
if((tty->flags & (1<< TTY_DO_WRITE_WAKEUP))
&& tty->ldisc.write_wakeup){
@@ -1016,7 +1051,8 @@
} /* cyy_issue_cmd */
#ifndef CONFIG_COBALT_27 /* ISA interrupt detection code */
-static unsigned detect_isa_irq (volatile ucchar *address)
+static unsigned
+detect_isa_irq (volatile ucchar *address)
{
int irq;
unsigned long irqs, flags;
@@ -1151,7 +1187,19 @@
j = (cy_readb(base_addr+(CyRIVR<<index)) & CyIVRMask);
if ( j == CyIVRRxEx ) { /* exception */
data = cy_readb(base_addr+(CyRDSR<<index));
+
+ /* For statistics only */
+ if (data & CyBREAK)
+ info->icount.brk++;
+ else if(data & CyFRAME)
+ info->icount.frame++;
+ else if(data & CyPARITY)
+ info->icount.parity++;
+ else if(data & CyOVERRUN)
+ info->icount.overrun++;
+
if(data & info->ignore_status_mask){
+ info->icount.rx++;
continue;
}
if (tty->flip.count < TTY_FLIPBUF_SIZE){
@@ -1159,9 +1207,10 @@
if (data & info->read_status_mask){
if(data & CyBREAK){
*tty->flip.flag_buf_ptr++ =
- TTY_BREAK;
+ TTY_BREAK;
*tty->flip.char_buf_ptr++ =
cy_readb(base_addr+(CyRDSR<<index));
+ info->icount.rx++;
if (info->flags & ASYNC_SAK){
do_SAK(tty);
}
@@ -1170,17 +1219,20 @@
TTY_FRAME;
*tty->flip.char_buf_ptr++ =
cy_readb(base_addr+(CyRDSR<<index));
+ info->icount.rx++;
info->idle_stats.frame_errs++;
}else if(data & CyPARITY){
*tty->flip.flag_buf_ptr++ =
TTY_PARITY;
*tty->flip.char_buf_ptr++ =
cy_readb(base_addr+(CyRDSR<<index));
+ info->icount.rx++;
info->idle_stats.parity_errs++;
}else if(data & CyOVERRUN){
*tty->flip.flag_buf_ptr++ =
TTY_OVERRUN;
*tty->flip.char_buf_ptr++ = 0;
+ info->icount.rx++;
/* If the flip buffer itself is
overflowing, we still lose
the next incoming character.
@@ -1192,6 +1244,7 @@
TTY_NORMAL;
*tty->flip.char_buf_ptr++ =
cy_readb(base_addr+(CyRDSR<<index));
+ info->icount.rx++;
}
info->idle_stats.overruns++;
/* These two conditions may imply */
@@ -1201,15 +1254,18 @@
}else{
*tty->flip.flag_buf_ptr++ = 0;
*tty->flip.char_buf_ptr++ = 0;
+ info->icount.rx++;
}
}else{
*tty->flip.flag_buf_ptr++ = 0;
*tty->flip.char_buf_ptr++ = 0;
+ info->icount.rx++;
}
}else{
/* there was a software buffer
overrun and nothing could be
done about it!!! */
+ info->icount.buf_overrun++;
info->idle_stats.overruns++;
}
} else { /* normal character reception */
@@ -1233,6 +1289,7 @@
data = cy_readb(base_addr+(CyRDSR<<index));
*tty->flip.flag_buf_ptr++ = TTY_NORMAL;
*tty->flip.char_buf_ptr++ = data;
+ info->icount.rx++;
#ifdef CY_16Y_HACK
udelay(10L);
#endif
@@ -1286,11 +1343,11 @@
/* load the on-chip space for outbound data */
char_count = info->xmit_fifo_size;
-
if(info->x_char) { /* send special char */
outch = info->x_char;
cy_writeb((u_long)base_addr+(CyTDR<<index), outch);
char_count--;
+ info->icount.tx++;
info->x_char = 0;
}
@@ -1351,6 +1408,7 @@
info->xmit_tail = (info->xmit_tail + 1)
& (SERIAL_XMIT_SIZE - 1);
cy_writeb((u_long)base_addr+(CyTDR<<index), outch);
+ info->icount.tx++;
}else{
if(char_count > 1){
info->xmit_cnt--;
@@ -1359,6 +1417,7 @@
cy_writeb((u_long)base_addr+(CyTDR<<index),
outch);
cy_writeb((u_long)base_addr+(CyTDR<<index), 0);
+ info->icount.tx++;
char_count--;
}else{
}
@@ -1397,6 +1456,16 @@
if(info->tty == 0){/* no place for data, ignore it*/
;
}else{
+ if (mdm_change & CyANY_DELTA) {
+ /* For statistics only */
+ if (mdm_change & CyDCD) info->icount.dcd++;
+ if (mdm_change & CyCTS) info->icount.cts++;
+ if (mdm_change & CyDSR) info->icount.dsr++;
+ if (mdm_change & CyRI) info->icount.rng++;
+
+ cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP);
+ }
+
if((mdm_change & CyDCD)
&& (info->flags & ASYNC_CHECK_CD)){
if(mdm_status & CyDCD){
@@ -1438,9 +1507,9 @@
}
}
}
- if(mdm_status & CyDSR){
+ if(mdm_change & CyDSR){
}
- if(mdm_status & CyRI){
+ if(mdm_change & CyRI){
}
}
/* end of service */
@@ -1497,7 +1566,6 @@
return 0;
} /* cyz_fetch_msg */
-
static int
cyz_issue_cmd( struct cyclades_card *cinfo,
uclong channel, ucchar cmd, uclong param)
@@ -1532,12 +1600,184 @@
return(0);
} /* cyz_issue_cmd */
+static void
+cyz_handle_rx(struct cyclades_port *info, volatile struct BUF_CTRL *buf_ctrl)
+{
+ struct cyclades_card *cinfo = &cy_card[info->card];
+ struct tty_struct *tty = info->tty;
+ volatile int char_count;
+#ifdef BLOCKMOVE
+ int small_count;
+#else
+ char data;
+#endif
+ volatile uclong rx_put, rx_get, rx_bufsize;
+
+/* Removed due to compilation problems in Alpha systems */
+// if ((char_count = CHARS_IN_BUF(buf_ctrl))){
+
+ rx_get = cy_readl(&buf_ctrl->rx_get);
+ rx_put = cy_readl(&buf_ctrl->rx_put);
+ rx_bufsize = cy_readl(&buf_ctrl->rx_bufsize);
+ if (rx_put >= rx_get)
+ char_count = rx_put - rx_get;
+ else
+ char_count = rx_put - rx_get + rx_bufsize;
+
+ if ( char_count ) {
+ info->last_active = jiffies;
+ info->jiffies[1] = jiffies;
+
+#ifdef CY_ENABLE_MONITORING
+ info->mon.int_count++;
+ info->mon.char_count += char_count;
+ if (char_count > info->mon.char_max)
+ info->mon.char_max = char_count;
+ info->mon.char_last = char_count;
+#endif
+ if(tty == 0){
+ /* flush received characters */
+ rx_get = (rx_get + char_count) & (rx_bufsize - 1);
+ info->rflush_count++;
+ }else{
+#ifdef BLOCKMOVE
+ /* we'd like to use memcpy(t, f, n) and memset(s, c, count)
+ for performance, but because of buffer boundaries, there
+ may be several steps to the operation */
+ while(0 < (small_count =
+ cy_min((rx_bufsize - rx_get),
+ cy_min((TTY_FLIPBUF_SIZE - tty->flip.count), char_count))
+ )) {
+ memcpy_fromio(tty->flip.char_buf_ptr,
+ (char *)(cinfo->base_addr
+ + cy_readl(&buf_ctrl->rx_bufaddr)
+ + rx_get),
+ small_count);
+
+ tty->flip.char_buf_ptr += small_count;
+ memset(tty->flip.flag_buf_ptr, TTY_NORMAL, small_count);
+ tty->flip.flag_buf_ptr += small_count;
+ rx_get = (rx_get + small_count) & (rx_bufsize - 1);
+ char_count -= small_count;
+ info->icount.rx += small_count;
+ info->idle_stats.recv_bytes += small_count;
+ tty->flip.count += small_count;
+ }
+#else
+ while(char_count--){
+ if (tty->flip.count >= TTY_FLIPBUF_SIZE){
#ifdef CONFIG_CYZ_INTR
+ cy_sched_event(info, Cy_EVENT_Z_RX_FULL);
+#endif
+ break;
+ }
+ data = cy_readb(cinfo->base_addr +
+ cy_readl(&buf_ctrl->rx_bufaddr) + rx_get);
+ rx_get = (rx_get + 1) & (rx_bufsize - 1);
+ tty->flip.count++;
+ *tty->flip.flag_buf_ptr++ = TTY_NORMAL;
+ *tty->flip.char_buf_ptr++ = data;
+ info->idle_stats.recv_bytes++;
+ info->icount.rx++;
+ }
+#endif
+ info->idle_stats.recv_idle = jiffies;
+ queue_task(&tty->flip.tqueue, &tq_timer);
+ }
+ /* Update rx_get */
+ cy_writel(&buf_ctrl->rx_get, rx_get);
+ }
+}
+
static void
-cyz_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+cyz_handle_tx(struct cyclades_port *info, volatile struct BUF_CTRL *buf_ctrl)
+{
+ struct cyclades_card *cinfo = &cy_card[info->card];
+ struct tty_struct *tty = info->tty;
+ char data;
+ volatile int char_count;
+#ifdef BLOCKMOVE
+ int small_count;
+#endif
+ volatile uclong tx_put, tx_get, tx_bufsize;
+
+/* Removed due to compilation problems in Alpha systems */
+// if ((char_count = SPACE_IN_BUF(buf_ctrl))){
+
+ tx_get = cy_readl(&buf_ctrl->tx_get);
+ tx_put = cy_readl(&buf_ctrl->tx_put);
+ tx_bufsize = cy_readl(&buf_ctrl->tx_bufsize);
+ if (tx_put >= tx_get)
+ char_count = tx_get - tx_put - 1 + tx_bufsize;
+ else
+ char_count = tx_get - tx_put - 1;
+
+ if ( char_count ) {
+
+ if( tty == 0 ){
+ goto ztxdone;
+ }
+
+ if(info->x_char) { /* send special char */
+ data = info->x_char;
+
+ cy_writeb((cinfo->base_addr +
+ cy_readl(&buf_ctrl->tx_bufaddr) + tx_put), data);
+ tx_put = (tx_put + 1) & (tx_bufsize - 1);
+ info->x_char = 0;
+ char_count--;
+ info->icount.tx++;
+ info->last_active = jiffies;
+ info->jiffies[2] = jiffies;
+ }
+#ifdef BLOCKMOVE
+ while(0 < (small_count =
+ cy_min((tx_bufsize - tx_put),
+ cy_min ((SERIAL_XMIT_SIZE - info->xmit_tail),
+ cy_min(info->xmit_cnt, char_count))))){
+
+ memcpy_toio((char *)(cinfo->base_addr
+ + cy_readl(&buf_ctrl->tx_bufaddr) + tx_put),
+ &info->xmit_buf[info->xmit_tail],
+ small_count);
+
+ tx_put = (tx_put + small_count) & (tx_bufsize - 1);
+ char_count -= small_count;
+ info->icount.tx += small_count;
+ info->xmit_cnt -= small_count;
+ info->xmit_tail =
+ (info->xmit_tail + small_count) & (SERIAL_XMIT_SIZE - 1);
+ info->last_active = jiffies;
+ info->jiffies[2] = jiffies;
+ }
+#else
+ while (info->xmit_cnt && char_count){
+ data = info->xmit_buf[info->xmit_tail];
+ info->xmit_cnt--;
+ info->xmit_tail = (info->xmit_tail + 1) & (SERIAL_XMIT_SIZE - 1);
+
+ cy_writeb(cinfo->base_addr +
+ cy_readl(&buf_ctrl->tx_bufaddr) + tx_put, data);
+ tx_put = (tx_put + 1) & (tx_bufsize - 1);
+ char_count--;
+ info->icount.tx++;
+ info->last_active = jiffies;
+ info->jiffies[2] = jiffies;
+ }
+#endif
+ ztxdone:
+ if (info->xmit_cnt < WAKEUP_CHARS) {
+ cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
+ }
+ /* Update tx_put */
+ cy_writel(&buf_ctrl->tx_put, tx_put);
+ }
+}
+
+static void
+cyz_handle_cmd(struct cyclades_card *cinfo)
{
struct tty_struct *tty;
- struct cyclades_card *cinfo;
struct cyclades_port *info;
static volatile struct FIRM_ID *firm_id;
static volatile struct ZFW_CTRL *zfw_ctrl;
@@ -1548,541 +1788,200 @@
ucchar cmd;
uclong param;
uclong hw_ver, fw_ver;
- char data;
- volatile int char_count, special_count;
-#ifdef BLOCKMOVE
- int small_count;
-#endif
- volatile uclong tx_put, tx_get, tx_bufsize;
- volatile uclong rx_put, rx_get, rx_bufsize;
-
- if((cinfo = (struct cyclades_card *)dev_id) == 0){
-#ifdef CY_DEBUG_INTERRUPTS
- printk("cyz_interrupt: spurious interrupt %d\n\r", irq);
-#endif
- return; /* spurious interrupt */
- }
+ int special_count;
+ int delta_count;
- firm_id = (struct FIRM_ID *)(cinfo->base_addr + ID_ADDRESS);
- if (!ISZLOADED(*cinfo)) {
-#ifdef CY_DEBUG_INTERRUPTS
- printk("cyz_interrupt: board not yet loaded (INT %d).\n\r", irq);
-#endif
- return;
+ firm_id = (struct FIRM_ID *)(cinfo->base_addr + ID_ADDRESS);
+ zfw_ctrl = (struct ZFW_CTRL *)
+ (cinfo->base_addr + cy_readl(&firm_id->zfwctrl_addr));
+ board_ctrl = &(zfw_ctrl->board_ctrl);
+ fw_ver = cy_readl(&board_ctrl->fw_version);
+ hw_ver = cy_readl(&((struct RUNTIME_9060 *)(cinfo->ctl_addr))->mail_box_0);
+
+ while(cyz_fetch_msg(cinfo, &channel, &cmd, ¶m) == 1) {
+ special_count = 0;
+ delta_count = 0;
+ info = &cy_port[channel + cinfo->first_line];
+ if((tty = info->tty) == 0) {
+ continue;
}
+ ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
+ buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]);
- zfw_ctrl = (struct ZFW_CTRL *)
- (cinfo->base_addr + cy_readl(&firm_id->zfwctrl_addr));
- board_ctrl = &(zfw_ctrl->board_ctrl);
- fw_ver = cy_readl(&board_ctrl->fw_version);
- hw_ver = cy_readl(&((struct RUNTIME_9060 *)
- (cinfo->ctl_addr))->mail_box_0);
-
- while(cyz_fetch_msg(cinfo, &channel, &cmd, ¶m) == 1) {
- special_count = 0;
- info = &cy_port[channel + cinfo->first_line];
- if((tty = info->tty) == 0) continue;
- ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
- buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]);
-
- switch(cmd){
+ switch(cmd) {
case C_CM_PR_ERROR:
tty->flip.count++;
*tty->flip.flag_buf_ptr++ = TTY_PARITY;
*tty->flip.char_buf_ptr++ = 0;
+ info->icount.rx++;
special_count++;
- break;
+ break;
case C_CM_FR_ERROR:
tty->flip.count++;
*tty->flip.flag_buf_ptr++ = TTY_FRAME;
*tty->flip.char_buf_ptr++ = 0;
+ info->icount.rx++;
special_count++;
- break;
+ break;
case C_CM_RXBRK:
tty->flip.count++;
*tty->flip.flag_buf_ptr++ = TTY_BREAK;
*tty->flip.char_buf_ptr++ = 0;
+ info->icount.rx++;
special_count++;
- break;
+ break;
case C_CM_MDCD:
+ info->icount.dcd++;
+ delta_count++;
if (info->flags & ASYNC_CHECK_CD){
if ((fw_ver > 241 ?
- ((u_long)param) :
- cy_readl(&ch_ctrl[channel].rs_status)) & C_RS_DCD) {
- /* SP("Open Wakeup\n"); */
- cy_sched_event(info,
- Cy_EVENT_OPEN_WAKEUP);
- }else if(!((info->flags
- & ASYNC_CALLOUT_ACTIVE)
- &&(info->flags
- & ASYNC_CALLOUT_NOHUP))){
- /* SP("Hangup\n"); */
- cy_sched_event(info,
- Cy_EVENT_HANGUP);
+ ((u_long)param) :
+ cy_readl(&ch_ctrl->rs_status)) & C_RS_DCD) {
+ cy_sched_event(info, Cy_EVENT_OPEN_WAKEUP);
+ }else if(!((info->flags & ASYNC_CALLOUT_ACTIVE)
+ &&(info->flags & ASYNC_CALLOUT_NOHUP))){
+ cy_sched_event(info, Cy_EVENT_HANGUP);
}
}
- break;
+ break;
case C_CM_MCTS:
- if (info->flags & ASYNC_CTS_FLOW) {
- if(info->tty->hw_stopped){
- if( cy_readl(&ch_ctrl[channel].rs_status) & C_RS_DCD){
- /* cy_start isn't used because...
- HW flow is handled by the board */
- /* SP("Write Wakeup\n"); */
- cy_sched_event(info,
- Cy_EVENT_WRITE_WAKEUP);
- }
- }else{
- if(!(cy_readl(&ch_ctrl[channel].rs_status) & C_RS_CTS)){
- /* cy_stop isn't used because
- HW flow is handled by the board */
- /* SP("Write stop\n"); */
- }
- }
- }
- break;
+ info->icount.cts++;
+ delta_count++;
+ break;
case C_CM_MRI:
- break;
+ info->icount.rng++;
+ delta_count++;
+ break;
case C_CM_MDSR:
- break;
+ info->icount.dsr++;
+ delta_count++;
+ break;
#ifdef Z_WAKE
case C_CM_IOCTLW:
cy_sched_event(info, Cy_EVENT_SHUTDOWN_WAKEUP);
- break;
+ break;
#endif
+#ifdef CONFIG_CYZ_INTR
case C_CM_RXHIWM:
case C_CM_RXNNDT:
+ case C_CM_INTBACK2:
/* Reception Interrupt */
#ifdef CY_DEBUG_INTERRUPTS
- printk("cyz_interrupt: rcvd intr, card %d, port %ld\n\r",
- info->card, channel);
-#endif
-
- rx_get = cy_readl(&buf_ctrl->rx_get);
- rx_put = cy_readl(&buf_ctrl->rx_put);
- rx_bufsize = cy_readl(&buf_ctrl->rx_bufsize);
- if (rx_put >= rx_get)
- char_count = rx_put - rx_get;
- else
- char_count = rx_put - rx_get + rx_bufsize;
-
- if ( char_count ){
-
-#ifdef CY_ENABLE_MONITORING
- info->mon.int_count++;
- info->mon.char_count += char_count;
- if (char_count > info->mon.char_max)
- info->mon.char_max = char_count;
- info->mon.char_last = char_count;
-#endif
- info->idle_stats.recv_bytes += char_count;
- info->idle_stats.recv_idle = jiffies;
- if( tty == 0){
- /* flush received characters */
- rx_get = (rx_get + char_count) & (rx_bufsize - 1);
- /* SP("-"); */
- info->rflush_count++;
- }else{
-#ifdef BLOCKMOVE
- /* we'd like to use memcpy(t, f, n) and memset(s, c, count)
- for performance, but because of buffer boundaries, there
- may be several steps to the operation */
- while(0 < (small_count
- = cy_min((rx_bufsize - rx_get),
- cy_min((TTY_FLIPBUF_SIZE - tty->flip.count),
- char_count)))){
-
- memcpy_fromio(tty->flip.char_buf_ptr,
- (char *)(cinfo->base_addr
- + cy_readl(&buf_ctrl->rx_bufaddr)
- + rx_get),
- small_count);
-
- tty->flip.char_buf_ptr += small_count;
- memset(tty->flip.flag_buf_ptr,
- TTY_NORMAL,
- small_count);
- tty->flip.flag_buf_ptr += small_count;
- rx_get = (rx_get + small_count) & (rx_bufsize - 1);
- char_count -= small_count;
- tty->flip.count += small_count;
- }
-#else
- while(char_count--){
- if (tty->flip.count >= TTY_FLIPBUF_SIZE){
- break;
- }
- data = cy_readb(cinfo->base_addr +
- cy_readl(&buf_ctrl->rx_bufaddr) + rx_get);
- rx_get = (rx_get + 1) & (rx_bufsize - 1);
- tty->flip.count++;
- *tty->flip.flag_buf_ptr++ = TTY_NORMAL;
- *tty->flip.char_buf_ptr++ = data;
- }
+ printk("cyz_interrupt: rcvd intr, card %d, port %ld\n\r",
+ info->card, channel);
#endif
- queue_task(&tty->flip.tqueue, &tq_timer);
- }
- /* Update rx_get */
- cy_writel(&buf_ctrl->rx_get, rx_get);
- }
+ cyz_handle_rx(info, buf_ctrl);
break;
case C_CM_TXBEMPTY:
case C_CM_TXLOWWM:
case C_CM_INTBACK:
/* Transmission Interrupt */
#ifdef CY_DEBUG_INTERRUPTS
- printk("cyz_interrupt: xmit intr, card %d, port %ld\n\r",
- info->card, channel);
-#endif
-
- tx_get = cy_readl(&buf_ctrl->tx_get);
- tx_put = cy_readl(&buf_ctrl->tx_put);
- tx_bufsize = cy_readl(&buf_ctrl->tx_bufsize);
- if (tx_put >= tx_get)
- char_count = tx_get - tx_put - 1 + tx_bufsize;
- else
- char_count = tx_get - tx_put - 1;
-
- if ( char_count ){
-
- if( tty == 0 ){
- goto ztxdone;
- }
-
- if(info->x_char) { /* send special char */
- data = info->x_char;
-
- cy_writeb((cinfo->base_addr +
- cy_readl(&buf_ctrl->tx_bufaddr) + tx_put), data);
- tx_put = (tx_put + 1) & (tx_bufsize - 1);
- info->x_char = 0;
- char_count--;
- }
-#ifdef BLOCKMOVE
- while(0 < (small_count
- = cy_min((tx_bufsize - tx_put),
- cy_min ((SERIAL_XMIT_SIZE - info->xmit_tail),
- cy_min(info->xmit_cnt, char_count))))){
-
- memcpy_toio((char *)(cinfo->base_addr
- + cy_readl(&buf_ctrl->tx_bufaddr) + tx_put),
- &info->xmit_buf[info->xmit_tail],
- small_count);
-
- tx_put = (tx_put + small_count) & (tx_bufsize - 1);
- char_count -= small_count;
- info->xmit_cnt -= small_count;
- info->xmit_tail =
- (info->xmit_tail + small_count) & (SERIAL_XMIT_SIZE - 1);
- }
-#else
- while (info->xmit_cnt && char_count){
- data = info->xmit_buf[info->xmit_tail];
- info->xmit_cnt--;
- info->xmit_tail =
- (info->xmit_tail + 1) & (SERIAL_XMIT_SIZE - 1);
-
- cy_writeb(cinfo->base_addr +
- cy_readl(&buf_ctrl->tx_bufaddr) + tx_put,
- data);
- tx_put = (tx_put + 1) & (tx_bufsize - 1);
- char_count--;
- }
-
+ printk("cyz_interrupt: xmit intr, card %d, port %ld\n\r",
+ info->card, channel);
#endif
- ztxdone:
- if (info->xmit_cnt < WAKEUP_CHARS) {
- cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
- }
- /* Update tx_put */
- cy_writel(&buf_ctrl->tx_put, tx_put);
- }
+ cyz_handle_tx(info, buf_ctrl);
break;
+#endif /* CONFIG_CYZ_INTR */
case C_CM_FATAL:
/* should do something with this !!! */
- break;
- }
- if(special_count){
- queue_task(&tty->flip.tqueue, &tq_timer);
- }
+ break;
+ default:
+ break;
}
+ if(delta_count)
+ cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP);
+ if(special_count)
+ queue_task(&tty->flip.tqueue, &tq_timer);
+ }
+}
+
+#ifdef CONFIG_CYZ_INTR
+static void
+cyz_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct cyclades_card *cinfo;
+
+ if((cinfo = (struct cyclades_card *)dev_id) == 0){
+#ifdef CY_DEBUG_INTERRUPTS
+ printk("cyz_interrupt: spurious interrupt %d\n\r", irq);
+#endif
+ return; /* spurious interrupt */
+ }
+
+ if (!ISZLOADED(*cinfo)) {
+#ifdef CY_DEBUG_INTERRUPTS
+ printk("cyz_interrupt: board not yet loaded (IRQ%d).\n\r", irq);
+#endif
+ return;
+ }
+
+ /* Handle the interrupts */
+ cyz_handle_cmd(cinfo);
return;
} /* cyz_interrupt */
+static void
+cyz_rx_restart(unsigned long arg)
+{
+ struct cyclades_port *info = (struct cyclades_port *)arg;
+ int retval;
+ int card = info->card;
+ uclong channel = (info->line) - (cy_card[card].first_line);
+
+ cyz_rx_full_timer[info->card].expires = jiffies + HZ;
+ retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_INTBACK2, 0L);
+ if (retval != 0){
+ printk("cyc:cyz_rx_restart retval was %x\n", retval);
+ }
+}
+
#else /* CONFIG_CYZ_INTR */
static void
cyz_poll(unsigned long arg)
{
+ struct cyclades_card *cinfo;
+ struct cyclades_port *info;
+ struct tty_struct *tty;
static volatile struct FIRM_ID *firm_id;
static volatile struct ZFW_CTRL *zfw_ctrl;
static volatile struct BOARD_CTRL *board_ctrl;
static volatile struct CH_CTRL *ch_ctrl;
static volatile struct BUF_CTRL *buf_ctrl;
- struct cyclades_card *cinfo;
- struct cyclades_port *info;
- struct tty_struct *tty;
int card, port;
- int char_count;
-#ifdef BLOCKMOVE
- int small_count;
-#endif
- char data;
- uclong channel;
- ucchar cmd;
- uclong param;
- uclong hw_ver, fw_ver;
- volatile uclong tx_put, tx_get, tx_bufsize;
- volatile uclong rx_put, rx_get, rx_bufsize;
cyz_timerlist.expires = jiffies + (HZ);
for (card = 0 ; card < NR_CARDS ; card++){
cinfo = &cy_card[card];
- if (!IS_CYC_Z(*cinfo)) continue;
+ if (!IS_CYC_Z(*cinfo)) continue;
+ if (!ISZLOADED(*cinfo)) continue;
- firm_id = (struct FIRM_ID *)(cinfo->base_addr + ID_ADDRESS);
- if (!ISZLOADED(*cinfo)) {
+ /* Skip first polling cycle to avoid racing conditions with the FW */
+ if (!cinfo->intr_enabled) {
+ cinfo->intr_enabled = 1;
continue;
}
+ firm_id = (struct FIRM_ID *)(cinfo->base_addr + ID_ADDRESS);
zfw_ctrl = (struct ZFW_CTRL *)
- (cinfo->base_addr + cy_readl(&firm_id->zfwctrl_addr));
+ (cinfo->base_addr + cy_readl(&firm_id->zfwctrl_addr));
board_ctrl = &(zfw_ctrl->board_ctrl);
- fw_ver = cy_readl(&board_ctrl->fw_version);
- hw_ver = cy_readl(&((struct RUNTIME_9060 *)
- (cinfo->ctl_addr))->mail_box_0);
-
- while(cyz_fetch_msg(cinfo, &channel, &cmd, ¶m) == 1){
- char_count = 0;
- info = &cy_port[ channel + cinfo->first_line ];
- if((tty = info->tty) == 0) continue;
- ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
- buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]);
- info->jiffies[0] = jiffies;
- switch(cmd){
- case C_CM_PR_ERROR:
- tty->flip.count++;
- *tty->flip.flag_buf_ptr++ = TTY_PARITY;
- *tty->flip.char_buf_ptr++ = 0;
- char_count++;
- break;
- case C_CM_FR_ERROR:
- tty->flip.count++;
- *tty->flip.flag_buf_ptr++ = TTY_FRAME;
- *tty->flip.char_buf_ptr++ = 0;
- char_count++;
- break;
- case C_CM_RXBRK:
- tty->flip.count++;
- *tty->flip.flag_buf_ptr++ = TTY_BREAK;
- *tty->flip.char_buf_ptr++ = 0;
- char_count++;
- break;
- case C_CM_MDCD:
- if (info->flags & ASYNC_CHECK_CD){
- if ((fw_ver > 241 ?
- ((u_long)param) :
- cy_readl(&ch_ctrl[channel].rs_status)) & C_RS_DCD) {
- cy_sched_event(info,
- Cy_EVENT_OPEN_WAKEUP);
- }else if(!((info->flags
- & ASYNC_CALLOUT_ACTIVE)
- &&(info->flags
- & ASYNC_CALLOUT_NOHUP))){
- cy_sched_event(info,
- Cy_EVENT_HANGUP);
- }
- }
- break;
- case C_CM_MCTS:
- if (info->flags & ASYNC_CTS_FLOW) {
- if(info->tty->hw_stopped){
- if( cy_readl(&ch_ctrl[channel].rs_status) & C_RS_DCD){
- /* cy_start isn't used because...
- HW flow is handled by the board */
- cy_sched_event(info,
- Cy_EVENT_WRITE_WAKEUP);
- }
- }else{
- if(!(cy_readl(&ch_ctrl[channel].rs_status) & C_RS_CTS)){
- /* cy_stop isn't used because
- HW flow is handled by the board */
- }
- }
- }
- break;
- case C_CM_MRI:
- break;
- case C_CM_MDSR:
- break;
-#ifdef Z_WAKE
- case C_CM_IOCTLW:
- cy_sched_event(info, Cy_EVENT_SHUTDOWN_WAKEUP);
- break;
-#endif
- case C_CM_FATAL:
- /* should do something with this !!! */
- break;
- }
- if(char_count){
- queue_task(&tty->flip.tqueue, &tq_timer);
- }
- }
+ cyz_handle_cmd(cinfo);
+
for (port = 0; port < cy_readl(&board_ctrl->n_channel); port++){
info = &cy_port[ port + cinfo->first_line ];
tty = info->tty;
ch_ctrl = &(zfw_ctrl->ch_ctrl[port]);
buf_ctrl = &(zfw_ctrl->buf_ctrl[port]);
-/* Removed due to compilation problems in Alpha systems */
-// if ((char_count = CHARS_IN_BUF(buf_ctrl))){
-
- rx_get = cy_readl(&buf_ctrl->rx_get);
- rx_put = cy_readl(&buf_ctrl->rx_put);
- rx_bufsize = cy_readl(&buf_ctrl->rx_bufsize);
- if (rx_put >= rx_get)
- char_count = rx_put - rx_get;
- else
- char_count = rx_put - rx_get + rx_bufsize;
-
- if ( char_count ){
-
- info->last_active = jiffies;
- info->jiffies[1] = jiffies;
-
-#ifdef CY_ENABLE_MONITORING
- info->mon.int_count++;
- info->mon.char_count += char_count;
- if (char_count > info->mon.char_max)
- info->mon.char_max = char_count;
- info->mon.char_last = char_count;
-#endif
- info->idle_stats.recv_bytes += char_count;
- info->idle_stats.recv_idle = jiffies;
- if( tty == 0){
- /* flush received characters */
- rx_get = (rx_get + char_count) & (rx_bufsize - 1);
- info->rflush_count++;
- }else{
-#ifdef BLOCKMOVE
- /* we'd like to use memcpy(t, f, n) and memset(s, c, count)
- for performance, but because of buffer boundaries, there
- may be several steps to the operation */
- while(0 < (small_count
- = cy_min((rx_bufsize - rx_get),
- cy_min((TTY_FLIPBUF_SIZE - tty->flip.count),
- char_count)))){
-
- memcpy_fromio(tty->flip.char_buf_ptr,
- (char *)(cinfo->base_addr
- + cy_readl(&buf_ctrl->rx_bufaddr)
- + rx_get),
- small_count);
-
- tty->flip.char_buf_ptr += small_count;
- memset(tty->flip.flag_buf_ptr,
- TTY_NORMAL,
- small_count);
- tty->flip.flag_buf_ptr += small_count;
- rx_get = (rx_get + small_count) & (rx_bufsize - 1);
- char_count -= small_count;
- tty->flip.count += small_count;
- }
-#else
- while(char_count--){
- if (tty->flip.count >= TTY_FLIPBUF_SIZE){
- break;
- }
- data = cy_readb(cinfo->base_addr +
- cy_readl(&buf_ctrl->rx_bufaddr) + rx_get);
- rx_get = (rx_get + 1) & (rx_bufsize - 1);
- tty->flip.count++;
- *tty->flip.flag_buf_ptr++ = TTY_NORMAL;
- *tty->flip.char_buf_ptr++ = data;
- }
-#endif
- queue_task(&tty->flip.tqueue, &tq_timer);
- }
- /* Update rx_get */
- cy_writel(&buf_ctrl->rx_get, rx_get);
- }
-
-/* Removed due to compilation problems in Alpha systems */
-// if ((char_count = SPACE_IN_BUF(buf_ctrl))){
-
- tx_get = cy_readl(&buf_ctrl->tx_get);
- tx_put = cy_readl(&buf_ctrl->tx_put);
- tx_bufsize = cy_readl(&buf_ctrl->tx_bufsize);
- if (tx_put >= tx_get)
- char_count = tx_get - tx_put - 1 + tx_bufsize;
- else
- char_count = tx_get - tx_put - 1;
-
- if ( char_count ){
-
- if( tty == 0 ){
- goto ztxdone;
- }
-
- if(info->x_char) { /* send special char */
- data = info->x_char;
-
- cy_writeb((cinfo->base_addr +
- cy_readl(&buf_ctrl->tx_bufaddr) + tx_put), data);
- tx_put = (tx_put + 1) & (tx_bufsize - 1);
- info->x_char = 0;
- char_count--;
- info->last_active = jiffies;
- info->jiffies[2] = jiffies;
- }
-#ifdef BLOCKMOVE
- while(0 < (small_count
- = cy_min((tx_bufsize - tx_put),
- cy_min ((SERIAL_XMIT_SIZE - info->xmit_tail),
- cy_min(info->xmit_cnt, char_count))))){
-
- memcpy_toio((char *)(cinfo->base_addr
- + cy_readl(&buf_ctrl->tx_bufaddr) + tx_put),
- &info->xmit_buf[info->xmit_tail],
- small_count);
-
- tx_put = (tx_put + small_count) & (tx_bufsize - 1);
- char_count -= small_count;
- info->xmit_cnt -= small_count;
- info->xmit_tail =
- (info->xmit_tail + small_count) & (SERIAL_XMIT_SIZE - 1);
- info->last_active = jiffies;
- info->jiffies[2] = jiffies;
- }
-#else
- while (info->xmit_cnt && char_count){
- data = info->xmit_buf[info->xmit_tail];
- info->xmit_cnt--;
- info->xmit_tail =
- (info->xmit_tail + 1) & (SERIAL_XMIT_SIZE - 1);
-
- cy_writeb(cinfo->base_addr +
- cy_readl(&buf_ctrl->tx_bufaddr) + tx_put,
- data);
- tx_put = (tx_put + 1) & (tx_bufsize - 1);
- char_count--;
- info->last_active = jiffies;
- info->jiffies[2] = jiffies;
- }
-
-#endif
- ztxdone:
- if (info->xmit_cnt < WAKEUP_CHARS) {
- cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
- }
- /* Update tx_put */
- cy_writel(&buf_ctrl->tx_put, tx_put);
- }
+ cyz_handle_rx(info, buf_ctrl);
+ cyz_handle_tx(info, buf_ctrl);
}
- /* poll every 40 ms */
+ /* poll every 'cyz_polling_cycle' period */
cyz_timerlist.expires = jiffies + cyz_polling_cycle;
}
add_timer(&cyz_timerlist);
@@ -2220,29 +2119,34 @@
cy_writel(&ch_ctrl[channel].intr_enable,
C_IN_TXBEMPTY|C_IN_TXLOWWM|C_IN_RXHIWM|C_IN_RXNNDT|
C_IN_IOCTLW|
- C_IN_MDCD|C_IN_MCTS);
+ C_IN_MDCD);
#else
cy_writel(&ch_ctrl[channel].intr_enable,
C_IN_IOCTLW|
- C_IN_MDCD|C_IN_MCTS);
+ C_IN_MDCD);
#endif /* CONFIG_CYZ_INTR */
#else
#ifdef CONFIG_CYZ_INTR
cy_writel(&ch_ctrl[channel].intr_enable,
C_IN_TXBEMPTY|C_IN_TXLOWWM|C_IN_RXHIWM|C_IN_RXNNDT|
- C_IN_MDCD|C_IN_MCTS);
+ C_IN_MDCD);
#else
cy_writel(&ch_ctrl[channel].intr_enable,
- C_IN_MDCD|C_IN_MCTS);
+ C_IN_MDCD);
#endif /* CONFIG_CYZ_INTR */
#endif /* Z_WAKE */
- retval = cyz_issue_cmd( &cy_card[card],
- channel, C_CM_IOCTL, 0L); /* was C_CM_RESET */
+ retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_IOCTL, 0L);
if (retval != 0){
printk("cyc:startup(1) retval was %x\n", retval);
}
+ /* Flush RX buffers before raising DTR and RTS */
+ retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_FLUSH_RX, 0L);
+ if (retval != 0){
+ printk("cyc:startup(2) retval was %x\n", retval);
+ }
+
/* set timeout !!! */
/* set RTS and DTR !!! */
cy_writel(&ch_ctrl[channel].rs_control,
@@ -2250,7 +2154,7 @@
retval = cyz_issue_cmd(&cy_card[info->card],
channel, C_CM_IOCTLM, 0L);
if (retval != 0){
- printk("cyc:startup(2) retval was %x\n", retval);
+ printk("cyc:startup(3) retval was %x\n", retval);
}
#ifdef CY_DEBUG_DTR
printk("cyc:startup raising Z DTR\n");
@@ -2353,6 +2257,9 @@
CY_LOCK(info, flags);
+ /* Clear delta_msr_wait queue to avoid mem leaks. */
+ wake_up_interruptible(&info->delta_msr_wait);
+
if (info->xmit_buf){
unsigned char * temp;
temp = info->xmit_buf;
@@ -2419,7 +2326,7 @@
retval = cyz_issue_cmd(&cy_card[info->card],
channel, C_CM_IOCTLM, 0L);
if (retval != 0){
- printk("cyc:shutdown retval (2) was %x\n", retval);
+ printk("cyc:shutdown retval was %x\n", retval);
}
#ifdef CY_DEBUG_DTR
printk("cyc:shutdown dropping Z DTR\n");
@@ -2556,7 +2463,7 @@
set_current_state(TASK_INTERRUPTIBLE);
if (tty_hung_up_p(filp)
|| !(info->flags & ASYNC_INITIALIZED) ){
- return ((info->flags & ASYNC_HUP_NOTIFY) ?
+ retval = ((info->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS);
break;
}
@@ -2617,7 +2524,7 @@
set_current_state(TASK_INTERRUPTIBLE);
if (tty_hung_up_p(filp)
|| !(info->flags & ASYNC_INITIALIZED) ){
- return ((info->flags & ASYNC_HUP_NOTIFY) ?
+ retval = ((info->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS);
break;
}
@@ -2707,6 +2614,10 @@
interrupts should be enabled as soon as the first open happens
to one of its ports. */
if (!cy_card[info->card].intr_enabled) {
+ /* Enable interrupts on the PLX chip */
+ cy_writew(cy_card[info->card].ctl_addr+0x68,
+ cy_readw(cy_card[info->card].ctl_addr+0x68)|0x0900);
+ /* Enable interrupts on the FW */
retval = cyz_issue_cmd(&cy_card[info->card],
0, C_CM_IRQ_ENBL, 0L);
if (retval != 0){
@@ -2791,7 +2702,8 @@
/*
* cy_wait_until_sent() --- wait until the transmitter is empty
*/
-static void cy_wait_until_sent(struct tty_struct *tty, int timeout)
+static void
+cy_wait_until_sent(struct tty_struct *tty, int timeout)
{
struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
unsigned char *base_addr;
@@ -2873,9 +2785,9 @@
* This routine is called when a particular tty device is closed.
*/
static void
-cy_close(struct tty_struct * tty, struct file * filp)
+cy_close(struct tty_struct *tty, struct file *filp)
{
- struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
+ struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
unsigned long flags;
#ifdef CY_DEBUG_OTHER
@@ -2979,7 +2891,7 @@
retval = cyz_issue_cmd(&cy_card[info->card], channel,
C_CM_IOCTLW, 0L);
if (retval != 0){
- printk("cyc:shutdown retval (1) was %x\n", retval);
+ printk("cyc:cy_close retval was %x\n", retval);
}
CY_UNLOCK(info, flags);
interruptible_sleep_on(&info->shutdown_wait);
@@ -3000,11 +2912,13 @@
info->event = 0;
info->tty = 0;
if (info->blocked_open) {
+ CY_UNLOCK(info, flags);
if (info->close_delay) {
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(info->close_delay);
}
wake_up_interruptible(&info->open_wait);
+ CY_LOCK(info, flags);
}
info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CALLOUT_ACTIVE|
ASYNC_CLOSING);
@@ -3273,6 +3187,20 @@
cflag = info->tty->termios->c_cflag;
iflag = info->tty->termios->c_iflag;
+ /*
+ * Set up the tty->alt_speed kludge
+ */
+ if (info->tty) {
+ if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+ info->tty->alt_speed = 57600;
+ if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+ info->tty->alt_speed = 115200;
+ if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+ info->tty->alt_speed = 230400;
+ if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+ info->tty->alt_speed = 460800;
+ }
+
card = info->card;
channel = (info->line) - (cy_card[card].first_line);
chip_number = channel / 4;
@@ -3282,7 +3210,11 @@
index = cy_card[card].bus_index;
/* baud rate */
- baud = tty_get_baud_rate(info->tty);
+ if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) {
+ baud = info->baud;
+ } else {
+ baud = tty_get_baud_rate(info->tty);
+ }
if (baud > CD1400_MAX_SPEED) {
baud = CD1400_MAX_SPEED;
}
@@ -3483,6 +3415,7 @@
struct BOARD_CTRL *board_ctrl;
struct CH_CTRL *ch_ctrl;
struct BUF_CTRL *buf_ctrl;
+ uclong sw_flow;
int retval;
firm_id = (struct FIRM_ID *)
@@ -3498,7 +3431,11 @@
buf_ctrl = &zfw_ctrl->buf_ctrl[channel];
/* baud rate */
- baud = tty_get_baud_rate(info->tty);
+ if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) {
+ baud = info->baud;
+ } else {
+ baud = tty_get_baud_rate(info->tty);
+ }
if (baud > CYZ_MAX_SPEED) {
baud = CYZ_MAX_SPEED;
}
@@ -3540,14 +3477,24 @@
/* CTS flow control flag */
if (cflag & CRTSCTS){
- info->flags |= ASYNC_CTS_FLOW;
cy_writel(&ch_ctrl->hw_flow,
cy_readl(&ch_ctrl->hw_flow) | C_RS_CTS | C_RS_RTS);
}else{
- info->flags &= ~ASYNC_CTS_FLOW;
cy_writel(&ch_ctrl->hw_flow,
cy_readl(&ch_ctrl->hw_flow) & ~(C_RS_CTS | C_RS_RTS));
}
+ /* As the HW flow control is done in firmware, the driver doesn't
+ need to care about it */
+ info->flags &= ~ASYNC_CTS_FLOW;
+
+ /* XON/XOFF/XANY flow control flags */
+ sw_flow = 0;
+ if (iflag & IXON){
+ sw_flow |= C_FL_OXX;
+ if (iflag & IXANY)
+ sw_flow |= C_FL_OIXANY;
+ }
+ cy_writel(&ch_ctrl->sw_flow, sw_flow);
retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_IOCTL, 0L);
if (retval != 0){
@@ -3562,14 +3509,6 @@
info->flags |= ASYNC_CHECK_CD;
}
- if (iflag & IXON){
- cy_writel(&ch_ctrl->sw_flow,
- cy_readl(&ch_ctrl->sw_flow) | C_FL_OXX);
- } else {
- cy_writel(&ch_ctrl->sw_flow,
- cy_readl(&ch_ctrl->sw_flow) & ~C_FL_OXX);
- }
-
if(baud == 0){ /* baud rate is zero, turn off line */
cy_writel(&ch_ctrl->rs_control,
cy_readl(&ch_ctrl->rs_control) & ~C_RS_DTR);
@@ -3595,20 +3534,6 @@
}
}
- /*
- * Set up the tty->alt_speed kludge
- */
- if (info->tty) {
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
- info->tty->alt_speed = 57600;
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
- info->tty->alt_speed = 115200;
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
- info->tty->alt_speed = 230400;
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
- info->tty->alt_speed = 460800;
- }
-
} /* set_line_char */
@@ -3749,7 +3674,7 @@
}
}
- return cy_put_user(result,(unsigned int *) value);
+ return cy_put_user(result, value);
} /* get_modem_info */
@@ -4208,7 +4133,10 @@
unsigned int cmd, unsigned long arg)
{
struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
+ struct cyclades_icount cprev, cnow; /* kernel counter temps */
+ struct serial_icounter_struct *p_cuser; /* user space */
int ret_val = 0;
+ unsigned long flags;
if (serial_paranoia_check(info, tty->device, "cy_ioctl"))
return -ENODEV;
@@ -4264,6 +4192,7 @@
if (copy_to_user((void *)arg, (void *)&cy_card[info->card],
sizeof (struct cyclades_card))) {
ret_val = -EFAULT;
+ break;
}
ret_val = 0;
break;
@@ -4300,6 +4229,77 @@
case TIOCSSERIAL:
ret_val = set_serial_info(info, (struct serial_struct *) arg);
break;
+ /*
+ * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
+ * - mask passed in arg for lines of interest
+ * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
+ * Caller should use TIOCGICOUNT to see which one it was
+ */
+ case TIOCMIWAIT:
+ CY_LOCK(info, flags);
+ /* note the counters on entry */
+ cprev = info->icount;
+ CY_UNLOCK(info, flags);
+ while (1) {
+ interruptible_sleep_on(&info->delta_msr_wait);
+ /* see if a signal did it */
+ if (signal_pending(current)) {
+ return -ERESTARTSYS;
+ }
+
+ CY_LOCK(info, flags);
+ cnow = info->icount; /* atomic copy */
+ CY_UNLOCK(info, flags);
+
+ if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
+ cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) {
+ return -EIO; /* no change => error */
+ }
+ if ( ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
+ ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
+ ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
+ ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) {
+ return 0;
+ }
+ cprev = cnow;
+ }
+ /* NOTREACHED */
+
+ /*
+ * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
+ * Return: write counters to the user passed counter struct
+ * NB: both 1->0 and 0->1 transitions are counted except for
+ * RI where only 0->1 is counted.
+ */
+ case TIOCGICOUNT:
+ CY_LOCK(info, flags);
+ cnow = info->icount;
+ CY_UNLOCK(info, flags);
+ p_cuser = (struct serial_icounter_struct *) arg;
+ ret_val = put_user(cnow.cts, &p_cuser->cts);
+ if (ret_val) return ret_val;
+ ret_val = put_user(cnow.dsr, &p_cuser->dsr);
+ if (ret_val) return ret_val;
+ ret_val = put_user(cnow.rng, &p_cuser->rng);
+ if (ret_val) return ret_val;
+ ret_val = put_user(cnow.dcd, &p_cuser->dcd);
+ if (ret_val) return ret_val;
+ ret_val = put_user(cnow.rx, &p_cuser->rx);
+ if (ret_val) return ret_val;
+ ret_val = put_user(cnow.tx, &p_cuser->tx);
+ if (ret_val) return ret_val;
+ ret_val = put_user(cnow.frame, &p_cuser->frame);
+ if (ret_val) return ret_val;
+ ret_val = put_user(cnow.overrun, &p_cuser->overrun);
+ if (ret_val) return ret_val;
+ ret_val = put_user(cnow.parity, &p_cuser->parity);
+ if (ret_val) return ret_val;
+ ret_val = put_user(cnow.brk, &p_cuser->brk);
+ if (ret_val) return ret_val;
+ ret_val = put_user(cnow.buf_overrun, &p_cuser->buf_overrun);
+ if (ret_val) return ret_val;
+ ret_val = 0;
+ break;
default:
ret_val = -ENOIOCTLCMD;
}
@@ -4328,7 +4328,8 @@
#endif
if ((tty->termios->c_cflag == old_termios->c_cflag) &&
- ((tty->termios->c_iflag & IXON) == (old_termios->c_iflag & IXON)))
+ ((tty->termios->c_iflag & (IXON|IXANY)) ==
+ (old_termios->c_iflag & (IXON|IXANY))))
return;
set_line_char(info);
@@ -4819,7 +4820,8 @@
} /* cy_detect_isa */
#endif /* CONFIG_COBALT_27 */
-static void plx_init(uclong addr, uclong initctl)
+static void
+plx_init(uclong addr, uclong initctl)
{
/* Reset PLX */
cy_writel(addr + initctl, cy_readl(addr + initctl) | 0x40000000);
@@ -4851,6 +4853,7 @@
unsigned short device_id,dev_index = 0;
uclong mailbox;
uclong Ze_addr0[NR_CARDS], Ze_addr2[NR_CARDS], ZeIndex = 0;
+ unsigned char Ze_irq[NR_CARDS];
if(pci_present() == 0) { /* PCI bus not present */
return(0);
@@ -4872,8 +4875,8 @@
/* read PCI configuration area */
cy_pci_irq = pdev->irq;
cy_pci_addr0 = pdev->resource[0].start;
- cy_pci_addr1 = pdev->resource[1].start;
- cy_pci_addr2 = pdev->resource[2].start;
+ cy_pci_addr1 = pdev->resource[1].start;
+ cy_pci_addr2 = pdev->resource[2].start;
pci_read_config_byte(pdev, PCI_REVISION_ID, &cyy_rev_id);
device_id &= ~PCI_DEVICE_ID_MASK;
@@ -4892,7 +4895,7 @@
if (pdev->resource[2].flags & ~PCI_BASE_ADDRESS_IO_MASK) {
printk(" Warning: PCI I/O bit incorrectly set. "
"Ignoring it...\n");
- cy_pci_addr2 &= PCI_BASE_ADDRESS_IO_MASK;
+ pdev->resource[2].flags &= PCI_BASE_ADDRESS_IO_MASK;
}
#if defined(__alpha__)
@@ -5020,11 +5023,14 @@
printk("Cyclades-Z/PCI: found winaddr=0x%lx ctladdr=0x%lx\n",
(ulong)cy_pci_addr2, (ulong)cy_pci_addr0);
#endif
- cy_pci_addr0 &= PCI_BASE_ADDRESS_MEM_MASK;
#if !defined(__alpha__)
cy_pci_addr0 = (ulong)ioremap(cy_pci_addr0, CyPCI_Zctl);
#endif
+ /* Disable interrupts on the PLX before resetting it */
+ cy_writew(cy_pci_addr0+0x68,
+ cy_readw(cy_pci_addr0+0x68) & ~0x0900);
+
plx_init(cy_pci_addr0, 0x6c);
/* For some yet unknown reason, once the PLX9060 reloads
the EEPROM, the IRQ is lost and, thus, we have to
@@ -5034,12 +5040,11 @@
mailbox = (uclong)cy_readl(&((struct RUNTIME_9060 *)
cy_pci_addr0)->mail_box_0);
- cy_pci_addr2 &= PCI_BASE_ADDRESS_MEM_MASK;
- if (cy_pci_addr2 & ~PCI_BASE_ADDRESS_IO_MASK) {
+ if (pdev->resource[2].flags & ~PCI_BASE_ADDRESS_IO_MASK) {
printk(" Warning: PCI I/O bit incorrectly set. "
"Ignoring it...\n");
- cy_pci_addr2 &= PCI_BASE_ADDRESS_IO_MASK;
+ pdev->resource[2].flags &= PCI_BASE_ADDRESS_IO_MASK;
}
if (mailbox == ZE_V1) {
#if !defined(__alpha__)
@@ -5053,6 +5058,7 @@
} else {
Ze_addr0[ZeIndex] = cy_pci_addr0;
Ze_addr2[ZeIndex] = cy_pci_addr2;
+ Ze_irq[ZeIndex] = cy_pci_irq;
ZeIndex++;
}
i--;
@@ -5154,11 +5160,6 @@
printk("%d channels starting from port %d.\n",
cy_pci_nchan,cy_next_channel);
-#ifdef CONFIG_CYZ_INTR
- /* Enable interrupts on the PLX chip */
- cy_writew(cy_pci_addr0+0x68,
- cy_readw(cy_pci_addr0+0x68)|0x0900);
-#endif /* CONFIG_CYZ_INTR */
cy_next_channel += cy_pci_nchan;
}
}
@@ -5166,9 +5167,11 @@
for (; ZeIndex != 0 && i < NR_CARDS; i++) {
cy_pci_addr0 = Ze_addr0[0];
cy_pci_addr2 = Ze_addr2[0];
+ cy_pci_irq = Ze_irq[0];
for (j = 0 ; j < ZeIndex-1 ; j++) {
Ze_addr0[j] = Ze_addr0[j+1];
Ze_addr2[j] = Ze_addr2[j+1];
+ Ze_irq[j] = Ze_irq[j+1];
}
ZeIndex--;
mailbox = (uclong)cy_readl(&((struct RUNTIME_9060 *)
@@ -5241,11 +5244,6 @@
printk("%d channels starting from port %d.\n",
cy_pci_nchan,cy_next_channel);
-#ifdef CONFIG_CYZ_INTR
- /* Enable interrupts on the PLX chip */
- cy_writew(cy_pci_addr0+0x68,
- cy_readw(cy_pci_addr0+0x68)|0x0900);
-#endif /* CONFIG_CYZ_INTR */
cy_next_channel += cy_pci_nchan;
}
if (ZeIndex != 0) {
@@ -5501,6 +5499,11 @@
info->rco = 0;
info->close_delay = 5*HZ/10;
info->closing_wait = CLOSING_WAIT_DELAY;
+ info->icount.cts = info->icount.dsr =
+ info->icount.rng = info->icount.dcd = 0;
+ info->icount.rx = info->icount.tx = 0;
+ info->icount.frame = info->icount.parity = 0;
+ info->icount.overrun = info->icount.brk = 0;
info->x_char = 0;
info->event = 0;
info->count = 0;
@@ -5519,6 +5522,7 @@
init_waitqueue_head(&info->open_wait);
init_waitqueue_head(&info->close_wait);
init_waitqueue_head(&info->shutdown_wait);
+ init_waitqueue_head(&info->delta_msr_wait);
/* info->session */
/* info->pgrp */
info->read_status_mask = 0;
@@ -5552,6 +5556,11 @@
info->cor5 = 0;
info->close_delay = 5*HZ/10;
info->closing_wait = CLOSING_WAIT_DELAY;
+ info->icount.cts = info->icount.dsr =
+ info->icount.rng = info->icount.dcd = 0;
+ info->icount.rx = info->icount.tx = 0;
+ info->icount.frame = info->icount.parity = 0;
+ info->icount.overrun = info->icount.brk = 0;
chip_number = (port - cinfo->first_line) / 4;
if ((info->chip_rev = cy_readb(cinfo->base_addr +
(cy_chip_offset[chip_number]<<index) +
@@ -5589,6 +5598,7 @@
init_waitqueue_head(&info->open_wait);
init_waitqueue_head(&info->close_wait);
init_waitqueue_head(&info->shutdown_wait);
+ init_waitqueue_head(&info->delta_msr_wait);
/* info->session */
/* info->pgrp */
info->read_status_mask =
@@ -5650,13 +5660,16 @@
restore_flags(flags);
for (i = 0; i < NR_CARDS; i++) {
- if (cy_card[i].base_addr != 0
+ if (cy_card[i].base_addr != 0) {
+ iounmap((void *)cy_card[i].base_addr);
+ if (cy_card[i].ctl_addr != 0)
+ iounmap((void *)cy_card[i].ctl_addr);
+ if (cy_card[i].irq
#ifndef CONFIG_CYZ_INTR
- && cy_card[i].num_chips != -1 /* not a Z card */
+ && cy_card[i].num_chips != -1 /* not a Z card */
#endif /* CONFIG_CYZ_INTR */
- && cy_card[i].irq)
- {
- free_irq(cy_card[i].irq, &cy_card[i]);
+ )
+ free_irq(cy_card[i].irq, &cy_card[i]);
}
}
if (tmp_buf) {
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)