提交 02f1175c 编写于 作者: J Jiri Slaby 提交者: Linus Torvalds

[PATCH] Char: cyclades, Lindent the code

make the code indented by tabs.
Signed-off-by: NJiri Slaby <jirislaby@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 e941027f
#undef BLOCKMOVE #undef BLOCKMOVE
#define Z_WAKE #define Z_WAKE
#undef Z_EXT_CHARS_IN_BUFFER #undef Z_EXT_CHARS_IN_BUFFER
static char rcsid[] = static char rcsid[] = "$Revision: 2.3.2.20 $$Date: 2004/02/25 18:14:16 $";
"$Revision: 2.3.2.20 $$Date: 2004/02/25 18:14:16 $";
/* /*
* linux/drivers/char/cyclades.c * linux/drivers/char/cyclades.c
...@@ -676,8 +675,8 @@ static char rcsid[] = ...@@ -676,8 +675,8 @@ static char rcsid[] =
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
static void cy_throttle (struct tty_struct *tty); static void cy_throttle(struct tty_struct *tty);
static void cy_send_xchar (struct tty_struct *tty, char ch); static void cy_send_xchar(struct tty_struct *tty, char ch);
#define IS_CYC_Z(card) ((card).num_chips == -1) #define IS_CYC_Z(card) ((card).num_chips == -1)
...@@ -721,8 +720,9 @@ static unsigned int cy_isa_addresses[] = { ...@@ -721,8 +720,9 @@ static unsigned int cy_isa_addresses[] = {
0xDA000, 0xDA000,
0xDC000, 0xDC000,
0xDE000, 0xDE000,
0,0,0,0,0,0,0,0 0, 0, 0, 0, 0, 0, 0, 0
}; };
#define NR_ISA_ADDRS ARRAY_SIZE(cy_isa_addresses) #define NR_ISA_ADDRS ARRAY_SIZE(cy_isa_addresses)
#ifdef MODULE #ifdef MODULE
...@@ -758,35 +758,41 @@ static int cy_next_channel; /* next minor available */ ...@@ -758,35 +758,41 @@ static int cy_next_channel; /* next minor available */
*/ */
static int baud_table[] = { static int baud_table[] = {
0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800,115200,150000, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 115200, 150000,
230400, 0}; 230400, 0
};
static char baud_co_25[] = { /* 25 MHz clock option table */ static char baud_co_25[] = { /* 25 MHz clock option table */
/* value => 00 01 02 03 04 */ /* value => 00 01 02 03 04 */
/* divide by 8 32 128 512 2048 */ /* divide by 8 32 128 512 2048 */
0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02,
0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static char baud_bpr_25[] = { /* 25 MHz baud rate period table */ static char baud_bpr_25[] = { /* 25 MHz baud rate period table */
0x00, 0xf5, 0xa3, 0x6f, 0x5c, 0x51, 0xf5, 0xa3, 0x51, 0xa3, 0x00, 0xf5, 0xa3, 0x6f, 0x5c, 0x51, 0xf5, 0xa3, 0x51, 0xa3,
0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x36, 0x29, 0x1b, 0x15}; 0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x36, 0x29, 0x1b, 0x15
};
static char baud_co_60[] = { /* 60 MHz clock option table (CD1400 J) */ static char baud_co_60[] = { /* 60 MHz clock option table (CD1400 J) */
/* value => 00 01 02 03 04 */ /* value => 00 01 02 03 04 */
/* divide by 8 32 128 512 2048 */ /* divide by 8 32 128 512 2048 */
0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03,
0x03, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00}; 0x00
};
static char baud_bpr_60[] = { /* 60 MHz baud rate period table (CD1400 J) */ static char baud_bpr_60[] = { /* 60 MHz baud rate period table (CD1400 J) */
0x00, 0x82, 0x21, 0xff, 0xdb, 0xc3, 0x92, 0x62, 0xc3, 0x62, 0x00, 0x82, 0x21, 0xff, 0xdb, 0xc3, 0x92, 0x62, 0xc3, 0x62,
0x41, 0xc3, 0x62, 0xc3, 0x62, 0xc3, 0x82, 0x62, 0x41, 0x32, 0x41, 0xc3, 0x62, 0xc3, 0x62, 0xc3, 0x82, 0x62, 0x41, 0x32,
0x21}; 0x21
};
static char baud_cor3[] = { /* receive threshold */ static char baud_cor3[] = { /* receive threshold */
0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07, 0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07,
0x07}; 0x07
};
/* /*
* The Cyclades driver implements HW flow control as any serial driver. * The Cyclades driver implements HW flow control as any serial driver.
...@@ -802,13 +808,13 @@ static char baud_cor3[] = { /* receive threshold */ ...@@ -802,13 +808,13 @@ static char baud_cor3[] = { /* receive threshold */
static char rflow_thr[] = { /* rflow threshold */ static char rflow_thr[] = { /* rflow threshold */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
0x0a}; 0x0a
};
/* The Cyclom-Ye has placed the sequential chips in non-sequential /* The Cyclom-Ye has placed the sequential chips in non-sequential
* address order. This look-up table overcomes that problem. * address order. This look-up table overcomes that problem.
*/ */
static int cy_chip_offset [] = static int cy_chip_offset[] = { 0x0000,
{ 0x0000,
0x0400, 0x0400,
0x0800, 0x0800,
0x0C00, 0x0C00,
...@@ -816,7 +822,7 @@ static int cy_chip_offset [] = ...@@ -816,7 +822,7 @@ static int cy_chip_offset [] =
0x0600, 0x0600,
0x0A00, 0x0A00,
0x0E00 0x0E00
}; };
/* PCI related definitions */ /* PCI related definitions */
...@@ -834,7 +840,7 @@ static unsigned short cy_pci_dev_id[] = { ...@@ -834,7 +840,7 @@ static unsigned short cy_pci_dev_id[] = {
PCI_DEVICE_ID_CYCLOM_Z_Lo, /* Z PCI < 1Mb */ PCI_DEVICE_ID_CYCLOM_Z_Lo, /* Z PCI < 1Mb */
PCI_DEVICE_ID_CYCLOM_Z_Hi, /* Z PCI > 1Mb */ PCI_DEVICE_ID_CYCLOM_Z_Hi, /* Z PCI > 1Mb */
0 /* end of table */ 0 /* end of table */
}; };
#endif #endif
static void cy_start(struct tty_struct *); static void cy_start(struct tty_struct *);
...@@ -844,7 +850,7 @@ static int cyz_issue_cmd(struct cyclades_card *, uclong, ucchar, uclong); ...@@ -844,7 +850,7 @@ static int cyz_issue_cmd(struct cyclades_card *, uclong, ucchar, uclong);
static unsigned detect_isa_irq(void __iomem *); static unsigned detect_isa_irq(void __iomem *);
#endif /* CONFIG_ISA */ #endif /* CONFIG_ISA */
static int cyclades_get_proc_info(char *, char **, off_t , int , int *, void *); static int cyclades_get_proc_info(char *, char **, off_t, int, int *, void *);
#ifndef CONFIG_CYZ_INTR #ifndef CONFIG_CYZ_INTR
static void cyz_poll(unsigned long); static void cyz_poll(unsigned long);
...@@ -860,8 +866,7 @@ static void cyz_rx_restart(unsigned long); ...@@ -860,8 +866,7 @@ static void cyz_rx_restart(unsigned long);
static struct timer_list cyz_rx_full_timer[NR_PORTS]; static struct timer_list cyz_rx_full_timer[NR_PORTS];
#endif /* CONFIG_CYZ_INTR */ #endif /* CONFIG_CYZ_INTR */
static inline int static inline int serial_paranoia_check(struct cyclades_port *info,
serial_paranoia_check(struct cyclades_port *info,
char *name, const char *routine) char *name, const char *routine)
{ {
#ifdef SERIAL_PARANOIA_CHECK #ifdef SERIAL_PARANOIA_CHECK
...@@ -877,8 +882,8 @@ serial_paranoia_check(struct cyclades_port *info, ...@@ -877,8 +882,8 @@ serial_paranoia_check(struct cyclades_port *info,
return 1; return 1;
} }
if( (long)info < (long)(&cy_port[0]) if ((long)info < (long)(&cy_port[0]) ||
|| (long)(&cy_port[NR_PORTS]) < (long)info ){ (long)(&cy_port[NR_PORTS]) < (long)info) {
printk(badrange, name, routine); printk(badrange, name, routine);
return 1; return 1;
} }
...@@ -897,14 +902,12 @@ serial_paranoia_check(struct cyclades_port *info, ...@@ -897,14 +902,12 @@ serial_paranoia_check(struct cyclades_port *info,
* (also known as the "bottom half"). This can be called any * (also known as the "bottom half"). This can be called any
* number of times for any channel without harm. * number of times for any channel without harm.
*/ */
static inline void static inline void cy_sched_event(struct cyclades_port *info, int event)
cy_sched_event(struct cyclades_port *info, int event)
{ {
info->event |= 1 << event; /* remember what kind of event and who */ info->event |= 1 << event; /* remember what kind of event and who */
schedule_work(&info->tqueue); schedule_work(&info->tqueue);
} /* cy_sched_event */ } /* cy_sched_event */
/* /*
* This routine is used to handle the "bottom half" processing for the * This routine is used to handle the "bottom half" processing for the
* serial driver, known also the "software interrupt" processing. * serial driver, known also the "software interrupt" processing.
...@@ -941,30 +944,25 @@ do_softint(struct work_struct *work) ...@@ -941,30 +944,25 @@ do_softint(struct work_struct *work)
wake_up_interruptible(&info->open_wait); wake_up_interruptible(&info->open_wait);
info->flags &= ~ASYNC_NORMAL_ACTIVE; info->flags &= ~ASYNC_NORMAL_ACTIVE;
} }
if (test_and_clear_bit(Cy_EVENT_OPEN_WAKEUP, &info->event)) { if (test_and_clear_bit(Cy_EVENT_OPEN_WAKEUP, &info->event))
wake_up_interruptible(&info->open_wait); wake_up_interruptible(&info->open_wait);
}
#ifdef CONFIG_CYZ_INTR #ifdef CONFIG_CYZ_INTR
if (test_and_clear_bit(Cy_EVENT_Z_RX_FULL, &info->event)) { if (test_and_clear_bit(Cy_EVENT_Z_RX_FULL, &info->event)) {
if (cyz_rx_full_timer[info->line].function == NULL) { if (cyz_rx_full_timer[info->line].function == NULL) {
cyz_rx_full_timer[info->line].expires = jiffies + 1; 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].function = cyz_rx_restart;
cyz_rx_full_timer[info->line].data = (unsigned long)info; cyz_rx_full_timer[info->line].data =
(unsigned long)info;
add_timer(&cyz_rx_full_timer[info->line]); add_timer(&cyz_rx_full_timer[info->line]);
} }
} }
#endif #endif
if (test_and_clear_bit(Cy_EVENT_DELTA_WAKEUP, &info->event)) { if (test_and_clear_bit(Cy_EVENT_DELTA_WAKEUP, &info->event))
wake_up_interruptible(&info->delta_msr_wait); wake_up_interruptible(&info->delta_msr_wait);
}
if (test_and_clear_bit(Cy_EVENT_WRITE_WAKEUP, &info->event)) {
tty_wakeup(tty); tty_wakeup(tty);
wake_up_interruptible(&tty->write_wait);
}
#ifdef Z_WAKE #ifdef Z_WAKE
if (test_and_clear_bit(Cy_EVENT_SHUTDOWN_WAKEUP, &info->event)) { if (test_and_clear_bit(Cy_EVENT_SHUTDOWN_WAKEUP, &info->event))
wake_up_interruptible(&info->shutdown_wait); wake_up_interruptible(&info->shutdown_wait);
}
#endif #endif
} /* do_softint */ } /* do_softint */
...@@ -979,32 +977,31 @@ do_softint(struct work_struct *work) ...@@ -979,32 +977,31 @@ do_softint(struct work_struct *work)
This function is only called from inside spinlock-protected code. This function is only called from inside spinlock-protected code.
*/ */
static int static int cyy_issue_cmd(void __iomem * base_addr, u_char cmd, int index)
cyy_issue_cmd(void __iomem *base_addr, u_char cmd, int index)
{ {
volatile int i; volatile int i;
/* Check to see that the previous command has completed */ /* Check to see that the previous command has completed */
for(i = 0 ; i < 100 ; i++){ for (i = 0; i < 100; i++) {
if (cy_readb(base_addr+(CyCCR<<index)) == 0){ if (cy_readb(base_addr + (CyCCR << index)) == 0) {
break; break;
} }
udelay(10L); udelay(10L);
} }
/* if the CCR never cleared, the previous command /* if the CCR never cleared, the previous command
didn't finish within the "reasonable time" */ didn't finish within the "reasonable time" */
if (i == 100) return (-1); if (i == 100)
return (-1);
/* Issue the new command */ /* Issue the new command */
cy_writeb(base_addr+(CyCCR<<index), cmd); cy_writeb(base_addr + (CyCCR << index), cmd);
return(0); return (0);
} /* cyy_issue_cmd */ } /* cyy_issue_cmd */
#ifdef CONFIG_ISA #ifdef CONFIG_ISA
/* ISA interrupt detection code */ /* ISA interrupt detection code */
static unsigned static unsigned detect_isa_irq(void __iomem * address)
detect_isa_irq(void __iomem *address)
{ {
int irq; int irq;
unsigned long irqs, flags; unsigned long irqs, flags;
...@@ -1015,7 +1012,7 @@ detect_isa_irq(void __iomem *address) ...@@ -1015,7 +1012,7 @@ detect_isa_irq(void __iomem *address)
irq = probe_irq_off(probe_irq_on()); irq = probe_irq_off(probe_irq_on());
/* Clear interrupts on the board first */ /* Clear interrupts on the board first */
cy_writeb(address + (Cy_ClrIntr<<index), 0); cy_writeb(address + (Cy_ClrIntr << index), 0);
/* Cy_ClrIntr is 0x1800 */ /* Cy_ClrIntr is 0x1800 */
irqs = probe_irq_on(); irqs = probe_irq_on();
...@@ -1024,12 +1021,12 @@ detect_isa_irq(void __iomem *address) ...@@ -1024,12 +1021,12 @@ detect_isa_irq(void __iomem *address)
/* Enable the Tx interrupts on the CD1400 */ /* Enable the Tx interrupts on the CD1400 */
local_irq_save(flags); local_irq_save(flags);
cy_writeb(address + (CyCAR<<index), 0); cy_writeb(address + (CyCAR << index), 0);
cyy_issue_cmd(address, CyCHAN_CTL|CyENB_XMTR, index); cyy_issue_cmd(address, CyCHAN_CTL | CyENB_XMTR, index);
cy_writeb(address + (CyCAR<<index), 0); cy_writeb(address + (CyCAR << index), 0);
cy_writeb(address + (CySRER<<index), cy_writeb(address + (CySRER << index),
cy_readb(address + (CySRER<<index)) | CyTxRdy); cy_readb(address + (CySRER << index)) | CyTxRdy);
local_irq_restore(flags); local_irq_restore(flags);
/* Wait ... */ /* Wait ... */
...@@ -1039,22 +1036,22 @@ detect_isa_irq(void __iomem *address) ...@@ -1039,22 +1036,22 @@ detect_isa_irq(void __iomem *address)
irq = probe_irq_off(irqs); irq = probe_irq_off(irqs);
/* Clean up */ /* Clean up */
save_xir = (u_char) cy_readb(address + (CyTIR<<index)); save_xir = (u_char) cy_readb(address + (CyTIR << index));
save_car = cy_readb(address + (CyCAR<<index)); save_car = cy_readb(address + (CyCAR << index));
cy_writeb(address + (CyCAR<<index), (save_xir & 0x3)); cy_writeb(address + (CyCAR << index), (save_xir & 0x3));
cy_writeb(address + (CySRER<<index), cy_writeb(address + (CySRER << index),
cy_readb(address + (CySRER<<index)) & ~CyTxRdy); cy_readb(address + (CySRER << index)) & ~CyTxRdy);
cy_writeb(address + (CyTIR<<index), (save_xir & 0x3f)); cy_writeb(address + (CyTIR << index), (save_xir & 0x3f));
cy_writeb(address + (CyCAR<<index), (save_car)); cy_writeb(address + (CyCAR << index), (save_car));
cy_writeb(address + (Cy_ClrIntr<<index), 0); cy_writeb(address + (Cy_ClrIntr << index), 0);
/* Cy_ClrIntr is 0x1800 */ /* Cy_ClrIntr is 0x1800 */
return (irq > 0)? irq : 0; return (irq > 0) ? irq : 0;
} }
#endif /* CONFIG_ISA */ #endif /* CONFIG_ISA */
static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
void __iomem *base_addr, int status, int index) void __iomem * base_addr, int status, int index)
{ {
struct cyclades_port *info; struct cyclades_port *info;
struct tty_struct *tty; struct tty_struct *tty;
...@@ -1069,85 +1066,122 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, ...@@ -1069,85 +1066,122 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
#endif #endif
/* determine the channel & change to that context */ /* determine the channel & change to that context */
spin_lock(&cinfo->card_lock); spin_lock(&cinfo->card_lock);
save_xir = (u_char) cy_readb(base_addr+(CyRIR<<index)); save_xir = (u_char) cy_readb(base_addr + (CyRIR << index));
channel = (u_short ) (save_xir & CyIRChannel); channel = (u_short) (save_xir & CyIRChannel);
i = channel + chip * 4 + cinfo->first_line; i = channel + chip * 4 + cinfo->first_line;
info = &cy_port[i]; info = &cy_port[i];
info->last_active = jiffies; info->last_active = jiffies;
save_car = cy_readb(base_addr+(CyCAR<<index)); save_car = cy_readb(base_addr + (CyCAR << index));
cy_writeb(base_addr+(CyCAR<<index), save_xir); cy_writeb(base_addr + (CyCAR << index), save_xir);
/* if there is nowhere to put the data, discard it */ /* if there is nowhere to put the data, discard it */
if(info->tty == 0){ if (info->tty == 0) {
j = (cy_readb(base_addr+(CyRIVR<<index)) & CyIVRMask); j = (cy_readb(base_addr + (CyRIVR << index)) &
if ( j == CyIVRRxEx ) { /* exception */ CyIVRMask);
data = cy_readb(base_addr+(CyRDSR<<index)); if (j == CyIVRRxEx) { /* exception */
data = cy_readb(base_addr + (CyRDSR << index));
} else { /* normal character reception */ } else { /* normal character reception */
char_count = cy_readb(base_addr+(CyRDCR<<index)); char_count = cy_readb(base_addr +
while(char_count--){ (CyRDCR << index));
data = cy_readb(base_addr+(CyRDSR<<index)); while (char_count--) {
data = cy_readb(base_addr +
(CyRDSR << index));
} }
} }
}else{ /* there is an open port for this data */ } else { /* there is an open port for this data */
tty = info->tty; tty = info->tty;
j = (cy_readb(base_addr+(CyRIVR<<index)) & CyIVRMask); j = (cy_readb(base_addr + (CyRIVR << index)) &
if ( j == CyIVRRxEx ) { /* exception */ CyIVRMask);
data = cy_readb(base_addr+(CyRDSR<<index)); if (j == CyIVRRxEx) { /* exception */
data = cy_readb(base_addr + (CyRDSR << index));
/* For statistics only */ /* For statistics only */
if (data & CyBREAK) if (data & CyBREAK)
info->icount.brk++; info->icount.brk++;
else if(data & CyFRAME) else if (data & CyFRAME)
info->icount.frame++; info->icount.frame++;
else if(data & CyPARITY) else if (data & CyPARITY)
info->icount.parity++; info->icount.parity++;
else if(data & CyOVERRUN) else if (data & CyOVERRUN)
info->icount.overrun++; info->icount.overrun++;
if(data & info->ignore_status_mask){ if (data & info->ignore_status_mask) {
info->icount.rx++; info->icount.rx++;
return; return;
} }
if (tty_buffer_request_room(tty, 1)) { if (tty_buffer_request_room(tty, 1)) {
if (data & info->read_status_mask){ if (data & info->read_status_mask) {
if(data & CyBREAK){ if (data & CyBREAK) {
tty_insert_flip_char(tty, cy_readb(base_addr+(CyRDSR<<index)), TTY_BREAK); tty_insert_flip_char(
tty,
cy_readb(
base_addr +
(CyRDSR <<
index)),
TTY_BREAK);
info->icount.rx++; info->icount.rx++;
if (info->flags & ASYNC_SAK){ if (info->flags &
ASYNC_SAK) {
do_SAK(tty); do_SAK(tty);
} }
}else if(data & CyFRAME){ } else if (data & CyFRAME) {
tty_insert_flip_char(tty, cy_readb(base_addr+(CyRDSR<<index)), TTY_FRAME); tty_insert_flip_char(
tty,
cy_readb(
base_addr +
(CyRDSR <<
index)),
TTY_FRAME);
info->icount.rx++; info->icount.rx++;
info->idle_stats.frame_errs++; info->idle_stats.
}else if(data & CyPARITY){ frame_errs++;
} else if (data & CyPARITY) {
/* Pieces of seven... */ /* Pieces of seven... */
tty_insert_flip_char(tty, cy_readb(base_addr+(CyRDSR<<index)), TTY_PARITY); tty_insert_flip_char(
tty,
cy_readb(
base_addr +
(CyRDSR <<
index)),
TTY_PARITY);
info->icount.rx++; info->icount.rx++;
info->idle_stats.parity_errs++; info->idle_stats.
}else if(data & CyOVERRUN){ parity_errs++;
tty_insert_flip_char(tty, 0, TTY_OVERRUN); } else if (data & CyOVERRUN) {
tty_insert_flip_char(
tty, 0,
TTY_OVERRUN);
info->icount.rx++; info->icount.rx++;
/* If the flip buffer itself is /* If the flip buffer itself is
overflowing, we still lose overflowing, we still lose
the next incoming character. the next incoming character.
*/ */
tty_insert_flip_char(tty, cy_readb(base_addr+(CyRDSR<<index)), TTY_FRAME); tty_insert_flip_char(
tty,
cy_readb(
base_addr +
(CyRDSR <<
index)),
TTY_FRAME);
info->icount.rx++; info->icount.rx++;
info->idle_stats.overruns++; info->idle_stats.
overruns++;
/* These two conditions may imply */ /* These two conditions may imply */
/* a normal read should be done. */ /* a normal read should be done. */
/* }else if(data & CyTIMEOUT){ */ /* }else if(data & CyTIMEOUT){ */
/* }else if(data & CySPECHAR){ */ /* }else if(data & CySPECHAR){ */
}else { } else {
tty_insert_flip_char(tty, 0, TTY_NORMAL); tty_insert_flip_char(
tty, 0,
TTY_NORMAL);
info->icount.rx++; info->icount.rx++;
} }
}else{ } else {
tty_insert_flip_char(tty, 0, TTY_NORMAL); tty_insert_flip_char(tty, 0,
TTY_NORMAL);
info->icount.rx++; info->icount.rx++;
} }
}else{ } else {
/* there was a software buffer /* there was a software buffer
overrun and nothing could be overrun and nothing could be
done about it!!! */ done about it!!! */
...@@ -1156,7 +1190,8 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, ...@@ -1156,7 +1190,8 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
} }
} else { /* normal character reception */ } else { /* normal character reception */
/* load # chars available from the chip */ /* load # chars available from the chip */
char_count = cy_readb(base_addr+(CyRDCR<<index)); char_count = cy_readb(base_addr +
(CyRDCR << index));
#ifdef CY_ENABLE_MONITORING #ifdef CY_ENABLE_MONITORING
++info->mon.int_count; ++info->mon.int_count;
...@@ -1166,9 +1201,11 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, ...@@ -1166,9 +1201,11 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
info->mon.char_last = char_count; info->mon.char_last = char_count;
#endif #endif
len = tty_buffer_request_room(tty, char_count); len = tty_buffer_request_room(tty, char_count);
while(len--){ while (len--) {
data = cy_readb(base_addr+(CyRDSR<<index)); data = cy_readb(base_addr +
tty_insert_flip_char(tty, data, TTY_NORMAL); (CyRDSR << index));
tty_insert_flip_char(tty, data,
TTY_NORMAL);
info->idle_stats.recv_bytes++; info->idle_stats.recv_bytes++;
info->icount.rx++; info->icount.rx++;
#ifdef CY_16Y_HACK #ifdef CY_16Y_HACK
...@@ -1180,12 +1217,11 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, ...@@ -1180,12 +1217,11 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
tty_schedule_flip(tty); tty_schedule_flip(tty);
} }
/* end of service */ /* end of service */
cy_writeb(base_addr+(CyRIR<<index), (save_xir & 0x3f)); cy_writeb(base_addr + (CyRIR << index), (save_xir & 0x3f));
cy_writeb(base_addr+(CyCAR<<index), (save_car)); cy_writeb(base_addr + (CyCAR << index), (save_car));
spin_unlock(&cinfo->card_lock); spin_unlock(&cinfo->card_lock);
} }
if (status & CySRTransmit) { /* transmission interrupt */ if (status & CySRTransmit) { /* transmission interrupt */
/* Since we only get here when the transmit buffer /* Since we only get here when the transmit buffer
is empty, we know we can always stuff a dozen is empty, we know we can always stuff a dozen
...@@ -1196,32 +1232,34 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, ...@@ -1196,32 +1232,34 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
/* determine the channel & change to that context */ /* determine the channel & change to that context */
spin_lock(&cinfo->card_lock); spin_lock(&cinfo->card_lock);
save_xir = (u_char) cy_readb(base_addr+(CyTIR<<index)); save_xir = (u_char) cy_readb(base_addr + (CyTIR << index));
channel = (u_short ) (save_xir & CyIRChannel); channel = (u_short) (save_xir & CyIRChannel);
i = channel + chip * 4 + cinfo->first_line; i = channel + chip * 4 + cinfo->first_line;
save_car = cy_readb(base_addr+(CyCAR<<index)); save_car = cy_readb(base_addr + (CyCAR << index));
cy_writeb(base_addr+(CyCAR<<index), save_xir); cy_writeb(base_addr + (CyCAR << index), save_xir);
/* validate the port# (as configured and open) */ /* validate the port# (as configured and open) */
if( (i < 0) || (NR_PORTS <= i) ){ if ((i < 0) || (NR_PORTS <= i)) {
cy_writeb(base_addr+(CySRER<<index), cy_writeb(base_addr + (CySRER << index),
cy_readb(base_addr+(CySRER<<index)) & ~CyTxRdy); cy_readb(base_addr + (CySRER << index)) &
~CyTxRdy);
goto txend; goto txend;
} }
info = &cy_port[i]; info = &cy_port[i];
info->last_active = jiffies; info->last_active = jiffies;
if(info->tty == 0){ if (info->tty == 0) {
cy_writeb(base_addr+(CySRER<<index), cy_writeb(base_addr + (CySRER << index),
cy_readb(base_addr+(CySRER<<index)) & ~CyTxRdy); cy_readb(base_addr + (CySRER << index)) &
~CyTxRdy);
goto txdone; goto txdone;
} }
/* load the on-chip space for outbound data */ /* load the on-chip space for outbound data */
char_count = info->xmit_fifo_size; char_count = info->xmit_fifo_size;
if(info->x_char) { /* send special char */ if (info->x_char) { /* send special char */
outch = info->x_char; outch = info->x_char;
cy_writeb(base_addr+(CyTDR<<index), outch); cy_writeb(base_addr + (CyTDR << index), outch);
char_count--; char_count--;
info->icount.tx++; info->icount.tx++;
info->x_char = 0; info->x_char = 0;
...@@ -1229,42 +1267,44 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, ...@@ -1229,42 +1267,44 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
if (info->breakon || info->breakoff) { if (info->breakon || info->breakoff) {
if (info->breakon) { if (info->breakon) {
cy_writeb(base_addr + (CyTDR<<index), 0); cy_writeb(base_addr + (CyTDR << index), 0);
cy_writeb(base_addr + (CyTDR<<index), 0x81); cy_writeb(base_addr + (CyTDR << index), 0x81);
info->breakon = 0; info->breakon = 0;
char_count -= 2; char_count -= 2;
} }
if (info->breakoff) { if (info->breakoff) {
cy_writeb(base_addr + (CyTDR<<index), 0); cy_writeb(base_addr + (CyTDR << index), 0);
cy_writeb(base_addr + (CyTDR<<index), 0x83); cy_writeb(base_addr + (CyTDR << index), 0x83);
info->breakoff = 0; info->breakoff = 0;
char_count -= 2; char_count -= 2;
} }
} }
while (char_count-- > 0){ while (char_count-- > 0) {
if (!info->xmit_cnt){ if (!info->xmit_cnt) {
if (cy_readb(base_addr+(CySRER<<index))&CyTxMpty) { if (cy_readb(base_addr + (CySRER << index)) &
cy_writeb(base_addr+(CySRER<<index), CyTxMpty) {
cy_readb(base_addr+(CySRER<<index)) & cy_writeb(base_addr + (CySRER << index),
cy_readb(base_addr +
(CySRER << index)) &
~CyTxMpty); ~CyTxMpty);
} else { } else {
cy_writeb(base_addr+(CySRER<<index), cy_writeb(base_addr + (CySRER << index),
((cy_readb(base_addr+(CySRER<<index)) (cy_readb(base_addr +
& ~CyTxRdy) (CySRER << index)) &
| CyTxMpty)); ~CyTxRdy) | CyTxMpty);
} }
goto txdone; goto txdone;
} }
if (info->xmit_buf == 0){ if (info->xmit_buf == 0) {
cy_writeb(base_addr+(CySRER<<index), cy_writeb(base_addr + (CySRER << index),
cy_readb(base_addr+(CySRER<<index)) & cy_readb(base_addr + (CySRER << index))&
~CyTxRdy); ~CyTxRdy);
goto txdone; goto txdone;
} }
if (info->tty->stopped || info->tty->hw_stopped){ if (info->tty->stopped || info->tty->hw_stopped) {
cy_writeb(base_addr+(CySRER<<index), cy_writeb(base_addr + (CySRER << index),
cy_readb(base_addr+(CySRER<<index)) & cy_readb(base_addr + (CySRER << index))&
~CyTxRdy); ~CyTxRdy);
goto txdone; goto txdone;
} }
...@@ -1280,23 +1320,24 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, ...@@ -1280,23 +1320,24 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
room for the two chars needed to send a NULL.) room for the two chars needed to send a NULL.)
*/ */
outch = info->xmit_buf[info->xmit_tail]; outch = info->xmit_buf[info->xmit_tail];
if( outch ){ if (outch) {
info->xmit_cnt--; info->xmit_cnt--;
info->xmit_tail = (info->xmit_tail + 1) info->xmit_tail = (info->xmit_tail + 1) &
& (SERIAL_XMIT_SIZE - 1); (SERIAL_XMIT_SIZE - 1);
cy_writeb(base_addr+(CyTDR<<index), outch); cy_writeb(base_addr + (CyTDR << index), outch);
info->icount.tx++; info->icount.tx++;
}else{ } else {
if(char_count > 1){ if (char_count > 1) {
info->xmit_cnt--; info->xmit_cnt--;
info->xmit_tail = (info->xmit_tail + 1) info->xmit_tail = (info->xmit_tail + 1)&
& (SERIAL_XMIT_SIZE - 1); (SERIAL_XMIT_SIZE - 1);
cy_writeb(base_addr+(CyTDR<<index), cy_writeb(base_addr + (CyTDR << index),
outch); outch);
cy_writeb(base_addr+(CyTDR<<index), 0); cy_writeb(base_addr + (CyTDR << index),
0);
info->icount.tx++; info->icount.tx++;
char_count--; char_count--;
}else{ } else {
} }
} }
} }
...@@ -1307,9 +1348,8 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, ...@@ -1307,9 +1348,8 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
} }
txend: txend:
/* end of service */ /* end of service */
cy_writeb(base_addr+(CyTIR<<index), cy_writeb(base_addr + (CyTIR << index), (save_xir & 0x3f));
(save_xir & 0x3f)); cy_writeb(base_addr + (CyCAR << index), (save_car));
cy_writeb(base_addr+(CyCAR<<index), (save_car));
spin_unlock(&cinfo->card_lock); spin_unlock(&cinfo->card_lock);
} }
...@@ -1317,73 +1357,80 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, ...@@ -1317,73 +1357,80 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
/* determine the channel & change to that context */ /* determine the channel & change to that context */
spin_lock(&cinfo->card_lock); spin_lock(&cinfo->card_lock);
save_xir = (u_char) cy_readb(base_addr+(CyMIR<<index)); save_xir = (u_char) cy_readb(base_addr + (CyMIR << index));
channel = (u_short ) (save_xir & CyIRChannel); channel = (u_short) (save_xir & CyIRChannel);
info = &cy_port[channel + chip * 4 info = &cy_port[channel + chip * 4 + cinfo->first_line];
+ cinfo->first_line];
info->last_active = jiffies; info->last_active = jiffies;
save_car = cy_readb(base_addr+(CyCAR<<index)); save_car = cy_readb(base_addr + (CyCAR << index));
cy_writeb(base_addr+(CyCAR<<index), save_xir); cy_writeb(base_addr + (CyCAR << index), save_xir);
mdm_change = cy_readb(base_addr+(CyMISR<<index)); mdm_change = cy_readb(base_addr + (CyMISR << index));
mdm_status = cy_readb(base_addr+(CyMSVR1<<index)); mdm_status = cy_readb(base_addr + (CyMSVR1 << index));
if(info->tty == 0){/* no place for data, ignore it*/ if (info->tty == 0) { /* no place for data, ignore it */
; ;
}else{ } else {
if (mdm_change & CyANY_DELTA) { if (mdm_change & CyANY_DELTA) {
/* For statistics only */ /* For statistics only */
if (mdm_change & CyDCD) info->icount.dcd++; if (mdm_change & CyDCD)
if (mdm_change & CyCTS) info->icount.cts++; info->icount.dcd++;
if (mdm_change & CyDSR) info->icount.dsr++; if (mdm_change & CyCTS)
if (mdm_change & CyRI) info->icount.rng++; 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); cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP);
} }
if((mdm_change & CyDCD) if ((mdm_change & CyDCD) &&
&& (info->flags & ASYNC_CHECK_CD)){ (info->flags & ASYNC_CHECK_CD)) {
if(mdm_status & CyDCD){ if (mdm_status & CyDCD) {
cy_sched_event(info, cy_sched_event(info,
Cy_EVENT_OPEN_WAKEUP); Cy_EVENT_OPEN_WAKEUP);
}else{ } else {
cy_sched_event(info, cy_sched_event(info, Cy_EVENT_HANGUP);
Cy_EVENT_HANGUP);
} }
} }
if((mdm_change & CyCTS) if ((mdm_change & CyCTS) &&
&& (info->flags & ASYNC_CTS_FLOW)){ (info->flags & ASYNC_CTS_FLOW)) {
if(info->tty->hw_stopped){ if (info->tty->hw_stopped) {
if(mdm_status & CyCTS){ if (mdm_status & CyCTS) {
/* cy_start isn't used /* cy_start isn't used
because... !!! */ because... !!! */
info->tty->hw_stopped = 0; info->tty->hw_stopped = 0;
cy_writeb(base_addr+(CySRER<<index), cy_writeb(base_addr +
cy_readb(base_addr+(CySRER<<index)) | (CySRER << index),
cy_readb(base_addr +
(CySRER <<
index))|
CyTxRdy); CyTxRdy);
cy_sched_event(info, cy_sched_event(info,
Cy_EVENT_WRITE_WAKEUP); Cy_EVENT_WRITE_WAKEUP);
} }
}else{ } else {
if(!(mdm_status & CyCTS)){ if (!(mdm_status & CyCTS)) {
/* cy_stop isn't used /* cy_stop isn't used
because ... !!! */ because ... !!! */
info->tty->hw_stopped = 1; info->tty->hw_stopped = 1;
cy_writeb(base_addr+(CySRER<<index), cy_writeb(base_addr +
cy_readb(base_addr+(CySRER<<index)) & (CySRER << index),
cy_readb(base_addr +
(CySRER <<
index)) &
~CyTxRdy); ~CyTxRdy);
} }
} }
} }
if(mdm_change & CyDSR){ if (mdm_change & CyDSR) {
} }
if(mdm_change & CyRI){ if (mdm_change & CyRI) {
} }
} }
/* end of service */ /* end of service */
cy_writeb(base_addr+(CyMIR<<index), cy_writeb(base_addr + (CyMIR << index), (save_xir & 0x3f));
(save_xir & 0x3f)); cy_writeb(base_addr + (CyCAR << index), save_car);
cy_writeb(base_addr+(CyCAR<<index), save_car);
spin_unlock(&cinfo->card_lock); spin_unlock(&cinfo->card_lock);
} }
} }
...@@ -1392,8 +1439,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, ...@@ -1392,8 +1439,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
whenever the card wants its hand held--chars whenever the card wants its hand held--chars
received, out buffer empty, modem change, etc. received, out buffer empty, modem change, etc.
*/ */
static irqreturn_t static irqreturn_t cyy_interrupt(int irq, void *dev_id)
cyy_interrupt(int irq, void *dev_id)
{ {
int status; int status;
struct cyclades_card *cinfo; struct cyclades_card *cinfo;
...@@ -1403,7 +1449,7 @@ cyy_interrupt(int irq, void *dev_id) ...@@ -1403,7 +1449,7 @@ cyy_interrupt(int irq, void *dev_id)
int too_many; int too_many;
int had_work; int had_work;
if((cinfo = (struct cyclades_card *)dev_id) == 0){ if ((cinfo = (struct cyclades_card *)dev_id) == 0) {
#ifdef CY_DEBUG_INTERRUPTS #ifdef CY_DEBUG_INTERRUPTS
printk("cyy_interrupt: spurious interrupt %d\n\r", irq); printk("cyy_interrupt: spurious interrupt %d\n\r", irq);
#endif #endif
...@@ -1413,35 +1459,37 @@ cyy_interrupt(int irq, void *dev_id) ...@@ -1413,35 +1459,37 @@ cyy_interrupt(int irq, void *dev_id)
card_base_addr = cinfo->base_addr; card_base_addr = cinfo->base_addr;
index = cinfo->bus_index; index = cinfo->bus_index;
/* This loop checks all chips in the card. Make a note whenever /* This loop checks all chips in the card. Make a note whenever
_any_ chip had some work to do, as this is considered an _any_ chip had some work to do, as this is considered an
indication that there will be more to do. Only when no chip indication that there will be more to do. Only when no chip
has any work does this outermost loop exit. has any work does this outermost loop exit.
*/ */
do{ do {
had_work = 0; had_work = 0;
for ( chip = 0 ; chip < cinfo->num_chips ; chip ++) { for (chip = 0; chip < cinfo->num_chips; chip++) {
base_addr = cinfo->base_addr + (cy_chip_offset[chip]<<index); base_addr = cinfo->base_addr +
(cy_chip_offset[chip] << index);
too_many = 0; too_many = 0;
while ( (status = cy_readb(base_addr+(CySVRR<<index))) != 0x00) { while ((status = cy_readb(base_addr +
(CySVRR << index))) != 0x00) {
had_work++; had_work++;
/* The purpose of the following test is to ensure that /* The purpose of the following test is to ensure that
no chip can monopolize the driver. This forces the no chip can monopolize the driver. This forces the
chips to be checked in a round-robin fashion (after chips to be checked in a round-robin fashion (after
draining each of a bunch (1000) of characters). draining each of a bunch (1000) of characters).
*/ */
if(1000<too_many++){ if (1000 < too_many++) {
break; break;
} }
cyy_intr_chip(cinfo, chip, base_addr, status, index); cyy_intr_chip(cinfo, chip, base_addr, status,
index);
} }
} }
} while(had_work); } while (had_work);
/* clear interrupts */ /* clear interrupts */
spin_lock(&cinfo->card_lock); spin_lock(&cinfo->card_lock);
cy_writeb(card_base_addr + (Cy_ClrIntr<<index), 0); cy_writeb(card_base_addr + (Cy_ClrIntr << index), 0);
/* Cy_ClrIntr is 0x1800 */ /* Cy_ClrIntr is 0x1800 */
spin_unlock(&cinfo->card_lock); spin_unlock(&cinfo->card_lock);
return IRQ_HANDLED; return IRQ_HANDLED;
...@@ -1453,8 +1501,8 @@ cyy_interrupt(int irq, void *dev_id) ...@@ -1453,8 +1501,8 @@ cyy_interrupt(int irq, void *dev_id)
/***********************************************************/ /***********************************************************/
static int static int
cyz_fetch_msg( struct cyclades_card *cinfo, cyz_fetch_msg(struct cyclades_card *cinfo,
uclong *channel, ucchar *cmd, uclong *param) uclong * channel, ucchar * cmd, uclong * param)
{ {
struct FIRM_ID __iomem *firm_id; struct FIRM_ID __iomem *firm_id;
struct ZFW_CTRL __iomem *zfw_ctrl; struct ZFW_CTRL __iomem *zfw_ctrl;
...@@ -1462,27 +1510,28 @@ cyz_fetch_msg( struct cyclades_card *cinfo, ...@@ -1462,27 +1510,28 @@ cyz_fetch_msg( struct cyclades_card *cinfo,
unsigned long loc_doorbell; unsigned long loc_doorbell;
firm_id = cinfo->base_addr + ID_ADDRESS; firm_id = cinfo->base_addr + ID_ADDRESS;
if (!ISZLOADED(*cinfo)){ if (!ISZLOADED(*cinfo)) {
return (-1); return (-1);
} }
zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) &
0xfffff);
board_ctrl = &zfw_ctrl->board_ctrl; board_ctrl = &zfw_ctrl->board_ctrl;
loc_doorbell = cy_readl(&((struct RUNTIME_9060 __iomem *) loc_doorbell = cy_readl(&((struct RUNTIME_9060 __iomem *)
(cinfo->ctl_addr))->loc_doorbell); (cinfo->ctl_addr))->loc_doorbell);
if (loc_doorbell){ if (loc_doorbell) {
*cmd = (char)(0xff & loc_doorbell); *cmd = (char)(0xff & loc_doorbell);
*channel = cy_readl(&board_ctrl->fwcmd_channel); *channel = cy_readl(&board_ctrl->fwcmd_channel);
*param = (uclong)cy_readl(&board_ctrl->fwcmd_param); *param = (uclong) cy_readl(&board_ctrl->fwcmd_param);
cy_writel(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->loc_doorbell, cy_writel(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->
0xffffffff); loc_doorbell, 0xffffffff);
return 1; return 1;
} }
return 0; return 0;
} /* cyz_fetch_msg */ } /* cyz_fetch_msg */
static int static int
cyz_issue_cmd( struct cyclades_card *cinfo, cyz_issue_cmd(struct cyclades_card *cinfo,
uclong channel, ucchar cmd, uclong param) uclong channel, ucchar cmd, uclong param)
{ {
struct FIRM_ID __iomem *firm_id; struct FIRM_ID __iomem *firm_id;
...@@ -1492,31 +1541,33 @@ cyz_issue_cmd( struct cyclades_card *cinfo, ...@@ -1492,31 +1541,33 @@ cyz_issue_cmd( struct cyclades_card *cinfo,
int index; int index;
firm_id = cinfo->base_addr + ID_ADDRESS; firm_id = cinfo->base_addr + ID_ADDRESS;
if (!ISZLOADED(*cinfo)){ if (!ISZLOADED(*cinfo)) {
return (-1); return (-1);
} }
zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) &
0xfffff);
board_ctrl = &zfw_ctrl->board_ctrl; board_ctrl = &zfw_ctrl->board_ctrl;
index = 0; index = 0;
pci_doorbell = &((struct RUNTIME_9060 __iomem *) (cinfo->ctl_addr))->pci_doorbell; pci_doorbell =
while( (cy_readl(pci_doorbell) & 0xff) != 0){ &((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->pci_doorbell;
if (index++ == 1000){ while ((cy_readl(pci_doorbell) & 0xff) != 0) {
return((int)(cy_readl(pci_doorbell) & 0xff)); if (index++ == 1000) {
return ((int)(cy_readl(pci_doorbell) & 0xff));
} }
udelay(50L); udelay(50L);
} }
cy_writel(&board_ctrl->hcmd_channel, channel); cy_writel(&board_ctrl->hcmd_channel, channel);
cy_writel(&board_ctrl->hcmd_param , param); cy_writel(&board_ctrl->hcmd_param, param);
cy_writel(pci_doorbell, (long)cmd); cy_writel(pci_doorbell, (long)cmd);
return(0); return (0);
} /* cyz_issue_cmd */ } /* cyz_issue_cmd */
static void static void
cyz_handle_rx(struct cyclades_port *info, cyz_handle_rx(struct cyclades_port *info,
volatile struct CH_CTRL __iomem *ch_ctrl, volatile struct CH_CTRL __iomem * ch_ctrl,
volatile struct BUF_CTRL __iomem *buf_ctrl) volatile struct BUF_CTRL __iomem * buf_ctrl)
{ {
struct cyclades_card *cinfo = &cy_card[info->card]; struct cyclades_card *cinfo = &cy_card[info->card];
struct tty_struct *tty = info->tty; struct tty_struct *tty = info->tty;
...@@ -1538,7 +1589,7 @@ cyz_handle_rx(struct cyclades_port *info, ...@@ -1538,7 +1589,7 @@ cyz_handle_rx(struct cyclades_port *info,
else else
char_count = rx_put - rx_get + rx_bufsize; char_count = rx_put - rx_get + rx_bufsize;
if ( char_count ) { if (char_count) {
info->last_active = jiffies; info->last_active = jiffies;
info->jiffies[1] = jiffies; info->jiffies[1] = jiffies;
...@@ -1549,28 +1600,31 @@ cyz_handle_rx(struct cyclades_port *info, ...@@ -1549,28 +1600,31 @@ cyz_handle_rx(struct cyclades_port *info,
info->mon.char_max = char_count; info->mon.char_max = char_count;
info->mon.char_last = char_count; info->mon.char_last = char_count;
#endif #endif
if(tty == 0){ if (tty == 0) {
/* flush received characters */ /* flush received characters */
new_rx_get = (new_rx_get + char_count) & (rx_bufsize - 1); new_rx_get = (new_rx_get + char_count) &
(rx_bufsize - 1);
info->rflush_count++; info->rflush_count++;
}else{ } else {
#ifdef BLOCKMOVE #ifdef BLOCKMOVE
/* we'd like to use memcpy(t, f, n) and memset(s, c, count) /* we'd like to use memcpy(t, f, n) and memset(s, c, count)
for performance, but because of buffer boundaries, there for performance, but because of buffer boundaries, there
may be several steps to the operation */ may be several steps to the operation */
while(0 < (small_count = while (0 < (small_count = min_t(unsigned int,
min_t(unsigned int, (rx_bufsize - new_rx_get), rx_bufsize - new_rx_get,
min_t(unsigned int, (TTY_FLIPBUF_SIZE - tty->flip.count), char_count)) min_t(unsigned int, TTY_FLIPBUF_SIZE -
)) { tty->flip.count, char_count)))){
memcpy_fromio(tty->flip.char_buf_ptr, memcpy_fromio(tty->flip.char_buf_ptr,
(char *)(cinfo->base_addr (char *)(cinfo->base_addr + rx_bufaddr +
+ rx_bufaddr + new_rx_get), new_rx_get),
small_count); small_count);
tty->flip.char_buf_ptr += small_count; tty->flip.char_buf_ptr += small_count;
memset(tty->flip.flag_buf_ptr, TTY_NORMAL, small_count); memset(tty->flip.flag_buf_ptr, TTY_NORMAL,
small_count);
tty->flip.flag_buf_ptr += small_count; tty->flip.flag_buf_ptr += small_count;
new_rx_get = (new_rx_get + small_count) & (rx_bufsize - 1); new_rx_get = (new_rx_get + small_count) &
(rx_bufsize - 1);
char_count -= small_count; char_count -= small_count;
info->icount.rx += small_count; info->icount.rx += small_count;
info->idle_stats.recv_bytes += small_count; info->idle_stats.recv_bytes += small_count;
...@@ -1578,9 +1632,10 @@ cyz_handle_rx(struct cyclades_port *info, ...@@ -1578,9 +1632,10 @@ cyz_handle_rx(struct cyclades_port *info,
} }
#else #else
len = tty_buffer_request_room(tty, char_count); len = tty_buffer_request_room(tty, char_count);
while(len--){ while (len--) {
data = cy_readb(cinfo->base_addr + rx_bufaddr + new_rx_get); data = cy_readb(cinfo->base_addr + rx_bufaddr +
new_rx_get = (new_rx_get + 1) & (rx_bufsize - 1); new_rx_get);
new_rx_get = (new_rx_get + 1)& (rx_bufsize - 1);
tty_insert_flip_char(tty, data, TTY_NORMAL); tty_insert_flip_char(tty, data, TTY_NORMAL);
info->idle_stats.recv_bytes++; info->idle_stats.recv_bytes++;
info->icount.rx++; info->icount.rx++;
...@@ -1594,7 +1649,7 @@ cyz_handle_rx(struct cyclades_port *info, ...@@ -1594,7 +1649,7 @@ cyz_handle_rx(struct cyclades_port *info,
char_count = rx_put - rx_get; char_count = rx_put - rx_get;
else else
char_count = rx_put - rx_get + rx_bufsize; char_count = rx_put - rx_get + rx_bufsize;
if(char_count >= cy_readl(&buf_ctrl->rx_threshold)) { if (char_count >= cy_readl(&buf_ctrl->rx_threshold)) {
cy_sched_event(info, Cy_EVENT_Z_RX_FULL); cy_sched_event(info, Cy_EVENT_Z_RX_FULL);
} }
#endif #endif
...@@ -1608,8 +1663,8 @@ cyz_handle_rx(struct cyclades_port *info, ...@@ -1608,8 +1663,8 @@ cyz_handle_rx(struct cyclades_port *info,
static void static void
cyz_handle_tx(struct cyclades_port *info, cyz_handle_tx(struct cyclades_port *info,
volatile struct CH_CTRL __iomem *ch_ctrl, volatile struct CH_CTRL __iomem * ch_ctrl,
volatile struct BUF_CTRL __iomem *buf_ctrl) volatile struct BUF_CTRL __iomem * buf_ctrl)
{ {
struct cyclades_card *cinfo = &cy_card[info->card]; struct cyclades_card *cinfo = &cy_card[info->card];
struct tty_struct *tty = info->tty; struct tty_struct *tty = info->tty;
...@@ -1632,16 +1687,16 @@ cyz_handle_tx(struct cyclades_port *info, ...@@ -1632,16 +1687,16 @@ cyz_handle_tx(struct cyclades_port *info,
else else
char_count = tx_get - tx_put - 1; char_count = tx_get - tx_put - 1;
if ( char_count ) { if (char_count) {
if( tty == 0 ){ if (tty == 0) {
goto ztxdone; goto ztxdone;
} }
if(info->x_char) { /* send special char */ if (info->x_char) { /* send special char */
data = info->x_char; data = info->x_char;
cy_writeb((cinfo->base_addr + tx_bufaddr + tx_put), data); cy_writeb(cinfo->base_addr + tx_bufaddr + tx_put, data);
tx_put = (tx_put + 1) & (tx_bufsize - 1); tx_put = (tx_put + 1) & (tx_bufsize - 1);
info->x_char = 0; info->x_char = 0;
char_count--; char_count--;
...@@ -1650,12 +1705,14 @@ cyz_handle_tx(struct cyclades_port *info, ...@@ -1650,12 +1705,14 @@ cyz_handle_tx(struct cyclades_port *info,
info->jiffies[2] = jiffies; info->jiffies[2] = jiffies;
} }
#ifdef BLOCKMOVE #ifdef BLOCKMOVE
while(0 < (small_count = while (0 < (small_count = min_t(unsigned int,
min_t(unsigned int, (tx_bufsize - tx_put), tx_bufsize - tx_put, min_t(unsigned int,
min_t(unsigned int, (SERIAL_XMIT_SIZE - info->xmit_tail), (SERIAL_XMIT_SIZE - info->xmit_tail),
min_t(unsigned int, info->xmit_cnt, char_count))))) { min_t(unsigned int, info->xmit_cnt,
char_count))))) {
memcpy_toio((char *)(cinfo->base_addr + tx_bufaddr + tx_put),
memcpy_toio((char *)(cinfo->base_addr + tx_bufaddr +
tx_put),
&info->xmit_buf[info->xmit_tail], &info->xmit_buf[info->xmit_tail],
small_count); small_count);
...@@ -1663,16 +1720,17 @@ cyz_handle_tx(struct cyclades_port *info, ...@@ -1663,16 +1720,17 @@ cyz_handle_tx(struct cyclades_port *info,
char_count -= small_count; char_count -= small_count;
info->icount.tx += small_count; info->icount.tx += small_count;
info->xmit_cnt -= small_count; info->xmit_cnt -= small_count;
info->xmit_tail = info->xmit_tail = (info->xmit_tail + small_count) &
(info->xmit_tail + small_count) & (SERIAL_XMIT_SIZE - 1); (SERIAL_XMIT_SIZE - 1);
info->last_active = jiffies; info->last_active = jiffies;
info->jiffies[2] = jiffies; info->jiffies[2] = jiffies;
} }
#else #else
while (info->xmit_cnt && char_count){ while (info->xmit_cnt && char_count) {
data = info->xmit_buf[info->xmit_tail]; data = info->xmit_buf[info->xmit_tail];
info->xmit_cnt--; info->xmit_cnt--;
info->xmit_tail = (info->xmit_tail + 1) & (SERIAL_XMIT_SIZE - 1); info->xmit_tail = (info->xmit_tail + 1) &
(SERIAL_XMIT_SIZE - 1);
cy_writeb(cinfo->base_addr + tx_bufaddr + tx_put, data); cy_writeb(cinfo->base_addr + tx_bufaddr + tx_put, data);
tx_put = (tx_put + 1) & (tx_bufsize - 1); tx_put = (tx_put + 1) & (tx_bufsize - 1);
...@@ -1682,7 +1740,7 @@ cyz_handle_tx(struct cyclades_port *info, ...@@ -1682,7 +1740,7 @@ cyz_handle_tx(struct cyclades_port *info,
info->jiffies[2] = jiffies; info->jiffies[2] = jiffies;
} }
#endif #endif
ztxdone: ztxdone:
if (info->xmit_cnt < WAKEUP_CHARS) { if (info->xmit_cnt < WAKEUP_CHARS) {
cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP); cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
} }
...@@ -1691,8 +1749,7 @@ cyz_handle_tx(struct cyclades_port *info, ...@@ -1691,8 +1749,7 @@ cyz_handle_tx(struct cyclades_port *info,
} }
} }
static void static void cyz_handle_cmd(struct cyclades_card *cinfo)
cyz_handle_cmd(struct cyclades_card *cinfo)
{ {
struct tty_struct *tty; struct tty_struct *tty;
struct cyclades_port *info; struct cyclades_port *info;
...@@ -1709,23 +1766,24 @@ cyz_handle_cmd(struct cyclades_card *cinfo) ...@@ -1709,23 +1766,24 @@ cyz_handle_cmd(struct cyclades_card *cinfo)
int delta_count; int delta_count;
firm_id = cinfo->base_addr + ID_ADDRESS; firm_id = cinfo->base_addr + ID_ADDRESS;
zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) &
0xfffff);
board_ctrl = &zfw_ctrl->board_ctrl; board_ctrl = &zfw_ctrl->board_ctrl;
fw_ver = cy_readl(&board_ctrl->fw_version); fw_ver = cy_readl(&board_ctrl->fw_version);
hw_ver = cy_readl(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->mail_box_0); hw_ver = cy_readl(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->
mail_box_0);
while(cyz_fetch_msg(cinfo, &channel, &cmd, &param) == 1) { while (cyz_fetch_msg(cinfo, &channel, &cmd, &param) == 1) {
special_count = 0; special_count = 0;
delta_count = 0; delta_count = 0;
info = &cy_port[channel + cinfo->first_line]; info = &cy_port[channel + cinfo->first_line];
if((tty = info->tty) == 0) { if ((tty = info->tty) == 0) {
continue; continue;
} }
ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]); ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]); buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]);
switch(cmd) { switch (cmd) {
case C_CM_PR_ERROR: case C_CM_PR_ERROR:
tty_insert_flip_char(tty, 0, TTY_PARITY); tty_insert_flip_char(tty, 0, TTY_PARITY);
info->icount.rx++; info->icount.rx++;
...@@ -1744,12 +1802,13 @@ cyz_handle_cmd(struct cyclades_card *cinfo) ...@@ -1744,12 +1802,13 @@ cyz_handle_cmd(struct cyclades_card *cinfo)
case C_CM_MDCD: case C_CM_MDCD:
info->icount.dcd++; info->icount.dcd++;
delta_count++; delta_count++;
if (info->flags & ASYNC_CHECK_CD){ if (info->flags & ASYNC_CHECK_CD) {
if ((fw_ver > 241 ? if ((fw_ver > 241 ? ((u_long) param) :
((u_long)param) : cy_readl(&ch_ctrl->rs_status)) &
cy_readl(&ch_ctrl->rs_status)) & C_RS_DCD) { C_RS_DCD) {
cy_sched_event(info, Cy_EVENT_OPEN_WAKEUP); cy_sched_event(info,
}else{ Cy_EVENT_OPEN_WAKEUP);
} else {
cy_sched_event(info, Cy_EVENT_HANGUP); cy_sched_event(info, Cy_EVENT_HANGUP);
} }
} }
...@@ -1777,8 +1836,8 @@ cyz_handle_cmd(struct cyclades_card *cinfo) ...@@ -1777,8 +1836,8 @@ cyz_handle_cmd(struct cyclades_card *cinfo)
case C_CM_INTBACK2: case C_CM_INTBACK2:
/* Reception Interrupt */ /* Reception Interrupt */
#ifdef CY_DEBUG_INTERRUPTS #ifdef CY_DEBUG_INTERRUPTS
printk("cyz_interrupt: rcvd intr, card %d, port %ld\n\r", printk("cyz_interrupt: rcvd intr, card %d, "
info->card, channel); "port %ld\n\r", info->card, channel);
#endif #endif
cyz_handle_rx(info, ch_ctrl, buf_ctrl); cyz_handle_rx(info, ch_ctrl, buf_ctrl);
break; break;
...@@ -1787,8 +1846,8 @@ cyz_handle_cmd(struct cyclades_card *cinfo) ...@@ -1787,8 +1846,8 @@ cyz_handle_cmd(struct cyclades_card *cinfo)
case C_CM_INTBACK: case C_CM_INTBACK:
/* Transmission Interrupt */ /* Transmission Interrupt */
#ifdef CY_DEBUG_INTERRUPTS #ifdef CY_DEBUG_INTERRUPTS
printk("cyz_interrupt: xmit intr, card %d, port %ld\n\r", printk("cyz_interrupt: xmit intr, card %d, "
info->card, channel); "port %ld\n\r", info->card, channel);
#endif #endif
cyz_handle_tx(info, ch_ctrl, buf_ctrl); cyz_handle_tx(info, ch_ctrl, buf_ctrl);
break; break;
...@@ -1799,20 +1858,19 @@ cyz_handle_cmd(struct cyclades_card *cinfo) ...@@ -1799,20 +1858,19 @@ cyz_handle_cmd(struct cyclades_card *cinfo)
default: default:
break; break;
} }
if(delta_count) if (delta_count)
cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP); cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP);
if(special_count) if (special_count)
tty_schedule_flip(tty); tty_schedule_flip(tty);
} }
} }
#ifdef CONFIG_CYZ_INTR #ifdef CONFIG_CYZ_INTR
static irqreturn_t static irqreturn_t cyz_interrupt(int irq, void *dev_id)
cyz_interrupt(int irq, void *dev_id)
{ {
struct cyclades_card *cinfo; struct cyclades_card *cinfo;
if((cinfo = (struct cyclades_card *)dev_id) == 0){ if ((cinfo = (struct cyclades_card *)dev_id) == 0) {
#ifdef CY_DEBUG_INTERRUPTS #ifdef CY_DEBUG_INTERRUPTS
printk("cyz_interrupt: spurious interrupt %d\n\r", irq); printk("cyz_interrupt: spurious interrupt %d\n\r", irq);
#endif #endif
...@@ -1832,8 +1890,7 @@ cyz_interrupt(int irq, void *dev_id) ...@@ -1832,8 +1890,7 @@ cyz_interrupt(int irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} /* cyz_interrupt */ } /* cyz_interrupt */
static void static void cyz_rx_restart(unsigned long arg)
cyz_rx_restart(unsigned long arg)
{ {
struct cyclades_port *info = (struct cyclades_port *)arg; struct cyclades_port *info = (struct cyclades_port *)arg;
int retval; int retval;
...@@ -1843,7 +1900,7 @@ cyz_rx_restart(unsigned long arg) ...@@ -1843,7 +1900,7 @@ cyz_rx_restart(unsigned long arg)
CY_LOCK(info, flags); CY_LOCK(info, flags);
retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_INTBACK2, 0L); retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_INTBACK2, 0L);
if (retval != 0){ if (retval != 0) {
printk("cyc:cyz_rx_restart retval on ttyC%d was %x\n", printk("cyc:cyz_rx_restart retval on ttyC%d was %x\n",
info->line, retval); info->line, retval);
} }
...@@ -1853,8 +1910,7 @@ cyz_rx_restart(unsigned long arg) ...@@ -1853,8 +1910,7 @@ cyz_rx_restart(unsigned long arg)
#else /* CONFIG_CYZ_INTR */ #else /* CONFIG_CYZ_INTR */
static void static void cyz_poll(unsigned long arg)
cyz_poll(unsigned long arg)
{ {
struct cyclades_card *cinfo; struct cyclades_card *cinfo;
struct cyclades_port *info; struct cyclades_port *info;
...@@ -1867,27 +1923,30 @@ cyz_poll(unsigned long arg) ...@@ -1867,27 +1923,30 @@ cyz_poll(unsigned long arg)
int card, port; int card, port;
cyz_timerlist.expires = jiffies + (HZ); cyz_timerlist.expires = jiffies + (HZ);
for (card = 0 ; card < NR_CARDS ; card++){ for (card = 0; card < NR_CARDS; card++) {
cinfo = &cy_card[card]; cinfo = &cy_card[card];
if (!IS_CYC_Z(*cinfo)) continue; if (!IS_CYC_Z(*cinfo))
if (!ISZLOADED(*cinfo)) continue; continue;
if (!ISZLOADED(*cinfo))
continue;
firm_id = cinfo->base_addr + ID_ADDRESS; firm_id = cinfo->base_addr + ID_ADDRESS;
zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); zfw_ctrl = cinfo->base_addr +
(cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
board_ctrl = &(zfw_ctrl->board_ctrl); board_ctrl = &(zfw_ctrl->board_ctrl);
/* Skip first polling cycle to avoid racing conditions with the FW */ /* Skip first polling cycle to avoid racing conditions with the FW */
if (!cinfo->intr_enabled) { if (!cinfo->intr_enabled) {
cinfo->nports = (int) cy_readl(&board_ctrl->n_channel); cinfo->nports = (int)cy_readl(&board_ctrl->n_channel);
cinfo->intr_enabled = 1; cinfo->intr_enabled = 1;
continue; continue;
} }
cyz_handle_cmd(cinfo); cyz_handle_cmd(cinfo);
for (port = 0 ; port < cinfo->nports ; port++) { for (port = 0; port < cinfo->nports; port++) {
info = &cy_port[ port + cinfo->first_line ]; info = &cy_port[port + cinfo->first_line];
tty = info->tty; tty = info->tty;
ch_ctrl = &(zfw_ctrl->ch_ctrl[port]); ch_ctrl = &(zfw_ctrl->ch_ctrl[port]);
buf_ctrl = &(zfw_ctrl->buf_ctrl[port]); buf_ctrl = &(zfw_ctrl->buf_ctrl[port]);
...@@ -1909,17 +1968,15 @@ cyz_poll(unsigned long arg) ...@@ -1909,17 +1968,15 @@ cyz_poll(unsigned long arg)
/********** End of block of Cyclades-Z specific code *********/ /********** End of block of Cyclades-Z specific code *********/
/***********************************************************/ /***********************************************************/
/* This is called whenever a port becomes active; /* This is called whenever a port becomes active;
interrupts are enabled and DTR & RTS are turned on. interrupts are enabled and DTR & RTS are turned on.
*/ */
static int static int startup(struct cyclades_port *info)
startup(struct cyclades_port * info)
{ {
unsigned long flags; unsigned long flags;
int retval = 0; int retval = 0;
void __iomem *base_addr; void __iomem *base_addr;
int card,chip,channel,index; int card, chip, channel, index;
unsigned long page; unsigned long page;
card = info->card; card = info->card;
...@@ -1931,13 +1988,13 @@ startup(struct cyclades_port * info) ...@@ -1931,13 +1988,13 @@ startup(struct cyclades_port * info)
CY_LOCK(info, flags); CY_LOCK(info, flags);
if (info->flags & ASYNC_INITIALIZED){ if (info->flags & ASYNC_INITIALIZED) {
free_page(page); free_page(page);
goto errout; goto errout;
} }
if (!info->type){ if (!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);
...@@ -1947,48 +2004,52 @@ startup(struct cyclades_port * info) ...@@ -1947,48 +2004,52 @@ startup(struct cyclades_port * info)
if (info->xmit_buf) if (info->xmit_buf)
free_page(page); free_page(page);
else else
info->xmit_buf = (unsigned char *) page; info->xmit_buf = (unsigned char *)page;
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
set_line_char(info); set_line_char(info);
if (!IS_CYC_Z(cy_card[card])) { if (!IS_CYC_Z(cy_card[card])) {
chip = channel>>2; chip = channel >> 2;
channel &= 0x03; channel &= 0x03;
index = cy_card[card].bus_index; index = cy_card[card].bus_index;
base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); base_addr = cy_card[card].base_addr +
(cy_chip_offset[chip] << index);
#ifdef CY_DEBUG_OPEN #ifdef CY_DEBUG_OPEN
printk("cyc startup card %d, chip %d, channel %d, base_addr %lx\n", printk("cyc startup card %d, chip %d, channel %d, "
card, chip, channel, (long)base_addr);/**/ "base_addr %lx\n",
card, chip, channel, (long)base_addr);
/**/
#endif #endif
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
cy_writeb(base_addr+(CyRTPR<<index), (info->default_timeout cy_writeb(base_addr + (CyRTPR << index),
? info->default_timeout : 0x02)); /* 10ms rx timeout */ (info->default_timeout ? info->default_timeout : 0x02));
/* 10ms rx timeout */
cyy_issue_cmd(base_addr,CyCHAN_CTL|CyENB_RCVR|CyENB_XMTR,index); cyy_issue_cmd(base_addr, CyCHAN_CTL | CyENB_RCVR | CyENB_XMTR,
index);
cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
cy_writeb(base_addr+(CyMSVR1<<index), CyRTS); cy_writeb(base_addr + (CyMSVR1 << index), CyRTS);
cy_writeb(base_addr+(CyMSVR2<<index), CyDTR); cy_writeb(base_addr + (CyMSVR2 << index), CyDTR);
#ifdef CY_DEBUG_DTR #ifdef CY_DEBUG_DTR
printk("cyc:startup raising DTR\n"); printk("cyc:startup raising DTR\n");
printk(" status: 0x%x, 0x%x\n", printk(" status: 0x%x, 0x%x\n",
cy_readb(base_addr+(CyMSVR1<<index)), cy_readb(base_addr + (CyMSVR1 << index)),
cy_readb(base_addr+(CyMSVR2<<index))); cy_readb(base_addr + (CyMSVR2 << index)));
#endif #endif
cy_writeb(base_addr+(CySRER<<index), cy_writeb(base_addr + (CySRER << index),
cy_readb(base_addr+(CySRER<<index)) | CyRxData); cy_readb(base_addr + (CySRER << index)) | CyRxData);
info->flags |= ASYNC_INITIALIZED; info->flags |= ASYNC_INITIALIZED;
if (info->tty){ if (info->tty) {
clear_bit(TTY_IO_ERROR, &info->tty->flags); clear_bit(TTY_IO_ERROR, &info->tty->flags);
} }
info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
...@@ -2010,53 +2071,52 @@ startup(struct cyclades_port * info) ...@@ -2010,53 +2071,52 @@ startup(struct cyclades_port * info)
base_addr = cy_card[card].base_addr; base_addr = cy_card[card].base_addr;
firm_id = base_addr + ID_ADDRESS; firm_id = base_addr + ID_ADDRESS;
if (!ISZLOADED(cy_card[card])){ if (!ISZLOADED(cy_card[card])) {
return -ENODEV; return -ENODEV;
} }
zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); zfw_ctrl = cy_card[card].base_addr +
(cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
board_ctrl = &zfw_ctrl->board_ctrl; board_ctrl = &zfw_ctrl->board_ctrl;
ch_ctrl = zfw_ctrl->ch_ctrl; ch_ctrl = zfw_ctrl->ch_ctrl;
#ifdef CY_DEBUG_OPEN #ifdef CY_DEBUG_OPEN
printk("cyc startup Z card %d, channel %d, base_addr %lx\n", printk("cyc startup Z card %d, channel %d, base_addr %lx\n",
card, channel, (long)base_addr);/**/ card, channel, (long)base_addr);
/**/
#endif #endif
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writel(&ch_ctrl[channel].op_mode, C_CH_ENABLE); cy_writel(&ch_ctrl[channel].op_mode, C_CH_ENABLE);
#ifdef Z_WAKE #ifdef Z_WAKE
#ifdef CONFIG_CYZ_INTR #ifdef CONFIG_CYZ_INTR
cy_writel(&ch_ctrl[channel].intr_enable, cy_writel(&ch_ctrl[channel].intr_enable,
C_IN_TXBEMPTY|C_IN_TXLOWWM|C_IN_RXHIWM|C_IN_RXNNDT| C_IN_TXBEMPTY | C_IN_TXLOWWM | C_IN_RXHIWM |
C_IN_IOCTLW| C_IN_RXNNDT | C_IN_IOCTLW | C_IN_MDCD);
C_IN_MDCD);
#else #else
cy_writel(&ch_ctrl[channel].intr_enable, cy_writel(&ch_ctrl[channel].intr_enable,
C_IN_IOCTLW| C_IN_IOCTLW | C_IN_MDCD);
C_IN_MDCD);
#endif /* CONFIG_CYZ_INTR */ #endif /* CONFIG_CYZ_INTR */
#else #else
#ifdef CONFIG_CYZ_INTR #ifdef CONFIG_CYZ_INTR
cy_writel(&ch_ctrl[channel].intr_enable, cy_writel(&ch_ctrl[channel].intr_enable,
C_IN_TXBEMPTY|C_IN_TXLOWWM|C_IN_RXHIWM|C_IN_RXNNDT| C_IN_TXBEMPTY | C_IN_TXLOWWM | C_IN_RXHIWM |
C_IN_MDCD); C_IN_RXNNDT | C_IN_MDCD);
#else #else
cy_writel(&ch_ctrl[channel].intr_enable, cy_writel(&ch_ctrl[channel].intr_enable, C_IN_MDCD);
C_IN_MDCD);
#endif /* CONFIG_CYZ_INTR */ #endif /* CONFIG_CYZ_INTR */
#endif /* Z_WAKE */ #endif /* Z_WAKE */
retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_IOCTL, 0L); retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_IOCTL, 0L);
if (retval != 0){ if (retval != 0) {
printk("cyc:startup(1) retval on ttyC%d was %x\n", printk("cyc:startup(1) retval on ttyC%d was %x\n",
info->line, retval); info->line, retval);
} }
/* Flush RX buffers before raising DTR and RTS */ /* Flush RX buffers before raising DTR and RTS */
retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_FLUSH_RX, 0L); retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_FLUSH_RX,
if (retval != 0){ 0L);
if (retval != 0) {
printk("cyc:startup(2) retval on ttyC%d was %x\n", printk("cyc:startup(2) retval on ttyC%d was %x\n",
info->line, retval); info->line, retval);
} }
...@@ -2064,10 +2124,11 @@ startup(struct cyclades_port * info) ...@@ -2064,10 +2124,11 @@ startup(struct cyclades_port * info)
/* set timeout !!! */ /* set timeout !!! */
/* set RTS and DTR !!! */ /* set RTS and DTR !!! */
cy_writel(&ch_ctrl[channel].rs_control, cy_writel(&ch_ctrl[channel].rs_control,
cy_readl(&ch_ctrl[channel].rs_control) | C_RS_RTS | C_RS_DTR) ; cy_readl(&ch_ctrl[channel].rs_control) | C_RS_RTS |
retval = cyz_issue_cmd(&cy_card[info->card], C_RS_DTR);
channel, C_CM_IOCTLM, 0L); retval = cyz_issue_cmd(&cy_card[info->card], channel,
if (retval != 0){ C_CM_IOCTLM, 0L);
if (retval != 0) {
printk("cyc:startup(3) retval on ttyC%d was %x\n", printk("cyc:startup(3) retval on ttyC%d was %x\n",
info->line, retval); info->line, retval);
} }
...@@ -2078,7 +2139,7 @@ startup(struct cyclades_port * info) ...@@ -2078,7 +2139,7 @@ startup(struct cyclades_port * info)
/* enable send, recv, modem !!! */ /* enable send, recv, modem !!! */
info->flags |= ASYNC_INITIALIZED; info->flags |= ASYNC_INITIALIZED;
if (info->tty){ if (info->tty) {
clear_bit(TTY_IO_ERROR, &info->tty->flags); clear_bit(TTY_IO_ERROR, &info->tty->flags);
} }
info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
...@@ -2101,34 +2162,34 @@ startup(struct cyclades_port * info) ...@@ -2101,34 +2162,34 @@ startup(struct cyclades_port * info)
return retval; return retval;
} /* startup */ } /* startup */
static void start_xmit(struct cyclades_port *info)
static void
start_xmit( struct cyclades_port *info )
{ {
unsigned long flags; unsigned long flags;
void __iomem *base_addr; void __iomem *base_addr;
int card,chip,channel,index; int card, chip, channel, index;
card = info->card; card = info->card;
channel = (info->line) - (cy_card[card].first_line); channel = (info->line) - (cy_card[card].first_line);
if (!IS_CYC_Z(cy_card[card])) { if (!IS_CYC_Z(cy_card[card])) {
chip = channel>>2; chip = channel >> 2;
channel &= 0x03; channel &= 0x03;
index = cy_card[card].bus_index; index = cy_card[card].bus_index;
base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); base_addr = cy_card[card].base_addr +
(cy_chip_offset[chip] << index);
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writeb(base_addr+(CyCAR<<index), channel); cy_writeb(base_addr + (CyCAR << index), channel);
cy_writeb(base_addr+(CySRER<<index), cy_writeb(base_addr + (CySRER << index),
cy_readb(base_addr+(CySRER<<index)) | CyTxRdy); cy_readb(base_addr + (CySRER << index)) | CyTxRdy);
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
} else { } else {
#ifdef CONFIG_CYZ_INTR #ifdef CONFIG_CYZ_INTR
int retval; int retval;
CY_LOCK(info, flags); CY_LOCK(info, flags);
retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_INTBACK, 0L); retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_INTBACK,
if (retval != 0){ 0L);
if (retval != 0) {
printk("cyc:start_xmit retval on ttyC%d was %x\n", printk("cyc:start_xmit retval on ttyC%d was %x\n",
info->line, retval); info->line, retval);
} }
...@@ -2143,27 +2204,28 @@ start_xmit( struct cyclades_port *info ) ...@@ -2143,27 +2204,28 @@ start_xmit( struct cyclades_port *info )
* This routine shuts down a serial port; interrupts are disabled, * This routine shuts down a serial port; interrupts are disabled,
* and DTR is dropped if the hangup on close termio flag is on. * and DTR is dropped if the hangup on close termio flag is on.
*/ */
static void static void shutdown(struct cyclades_port *info)
shutdown(struct cyclades_port * info)
{ {
unsigned long flags; unsigned long flags;
void __iomem *base_addr; void __iomem *base_addr;
int card,chip,channel,index; int card, chip, channel, index;
if (!(info->flags & ASYNC_INITIALIZED)){ if (!(info->flags & ASYNC_INITIALIZED)) {
return; return;
} }
card = info->card; card = info->card;
channel = info->line - cy_card[card].first_line; channel = info->line - cy_card[card].first_line;
if (!IS_CYC_Z(cy_card[card])) { if (!IS_CYC_Z(cy_card[card])) {
chip = channel>>2; chip = channel >> 2;
channel &= 0x03; channel &= 0x03;
index = cy_card[card].bus_index; index = cy_card[card].bus_index;
base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); base_addr = cy_card[card].base_addr +
(cy_chip_offset[chip] << index);
#ifdef CY_DEBUG_OPEN #ifdef CY_DEBUG_OPEN
printk("cyc shutdown Y card %d, chip %d, channel %d, base_addr %lx\n", printk("cyc shutdown Y card %d, chip %d, channel %d, "
"base_addr %lx\n",
card, chip, channel, (long)base_addr); card, chip, channel, (long)base_addr);
#endif #endif
...@@ -2172,28 +2234,28 @@ shutdown(struct cyclades_port * info) ...@@ -2172,28 +2234,28 @@ shutdown(struct cyclades_port * info)
/* Clear delta_msr_wait queue to avoid mem leaks. */ /* Clear delta_msr_wait queue to avoid mem leaks. */
wake_up_interruptible(&info->delta_msr_wait); wake_up_interruptible(&info->delta_msr_wait);
if (info->xmit_buf){ if (info->xmit_buf) {
unsigned char * temp; unsigned char *temp;
temp = info->xmit_buf; temp = info->xmit_buf;
info->xmit_buf = NULL; info->xmit_buf = NULL;
free_page((unsigned long) temp); free_page((unsigned long)temp);
} }
cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) { if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
cy_writeb(base_addr+(CyMSVR1<<index), ~CyRTS); cy_writeb(base_addr + (CyMSVR1 << index), ~CyRTS);
cy_writeb(base_addr+(CyMSVR2<<index), ~CyDTR); cy_writeb(base_addr + (CyMSVR2 << index), ~CyDTR);
#ifdef CY_DEBUG_DTR #ifdef CY_DEBUG_DTR
printk("cyc shutdown dropping DTR\n"); printk("cyc shutdown dropping DTR\n");
printk(" status: 0x%x, 0x%x\n", printk(" status: 0x%x, 0x%x\n",
cy_readb(base_addr+(CyMSVR1<<index)), cy_readb(base_addr + (CyMSVR1 << index)),
cy_readb(base_addr+(CyMSVR2<<index))); cy_readb(base_addr + (CyMSVR2 << index)));
#endif #endif
} }
cyy_issue_cmd(base_addr,CyCHAN_CTL|CyDIS_RCVR,index); cyy_issue_cmd(base_addr, CyCHAN_CTL | CyDIS_RCVR, index);
/* it may be appropriate to clear _XMIT at /* it may be appropriate to clear _XMIT at
some later date (after testing)!!! */ some later date (after testing)!!! */
if (info->tty){ if (info->tty) {
set_bit(TTY_IO_ERROR, &info->tty->flags); set_bit(TTY_IO_ERROR, &info->tty->flags);
} }
info->flags &= ~ASYNC_INITIALIZED; info->flags &= ~ASYNC_INITIALIZED;
...@@ -2216,26 +2278,27 @@ shutdown(struct cyclades_port * info) ...@@ -2216,26 +2278,27 @@ shutdown(struct cyclades_port * info)
return; return;
} }
zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); zfw_ctrl = cy_card[card].base_addr +
(cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
board_ctrl = &zfw_ctrl->board_ctrl; board_ctrl = &zfw_ctrl->board_ctrl;
ch_ctrl = zfw_ctrl->ch_ctrl; ch_ctrl = zfw_ctrl->ch_ctrl;
CY_LOCK(info, flags); CY_LOCK(info, flags);
if (info->xmit_buf){ if (info->xmit_buf) {
unsigned char * temp; unsigned char *temp;
temp = info->xmit_buf; temp = info->xmit_buf;
info->xmit_buf = NULL; info->xmit_buf = NULL;
free_page((unsigned long) temp); free_page((unsigned long)temp);
} }
if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) { if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
cy_writel(&ch_ctrl[channel].rs_control, cy_writel(&ch_ctrl[channel].rs_control,
(uclong)(cy_readl(&ch_ctrl[channel].rs_control) & (uclong)(cy_readl(&ch_ctrl[channel].rs_control)&
~(C_RS_RTS | C_RS_DTR))); ~(C_RS_RTS | C_RS_DTR)));
retval = cyz_issue_cmd(&cy_card[info->card], retval = cyz_issue_cmd(&cy_card[info->card], channel,
channel, C_CM_IOCTLM, 0L); C_CM_IOCTLM, 0L);
if (retval != 0){ if (retval != 0) {
printk("cyc:shutdown retval on ttyC%d was %x\n", printk("cyc:shutdown retval on ttyC%d was %x\n",
info->line, retval); info->line, retval);
} }
...@@ -2244,7 +2307,7 @@ shutdown(struct cyclades_port * info) ...@@ -2244,7 +2307,7 @@ shutdown(struct cyclades_port * info)
#endif #endif
} }
if (info->tty){ if (info->tty) {
set_bit(TTY_IO_ERROR, &info->tty->flags); set_bit(TTY_IO_ERROR, &info->tty->flags);
} }
info->flags &= ~ASYNC_INITIALIZED; info->flags &= ~ASYNC_INITIALIZED;
...@@ -2258,7 +2321,6 @@ shutdown(struct cyclades_port * info) ...@@ -2258,7 +2321,6 @@ shutdown(struct cyclades_port * info)
return; return;
} /* shutdown */ } /* shutdown */
/* /*
* ------------------------------------------------------------ * ------------------------------------------------------------
* cy_open() and friends * cy_open() and friends
...@@ -2266,13 +2328,13 @@ shutdown(struct cyclades_port * info) ...@@ -2266,13 +2328,13 @@ shutdown(struct cyclades_port * info)
*/ */
static int static int
block_til_ready(struct tty_struct *tty, struct file * filp, block_til_ready(struct tty_struct *tty, struct file *filp,
struct cyclades_port *info) struct cyclades_port *info)
{ {
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
struct cyclades_card *cinfo; struct cyclades_card *cinfo;
unsigned long flags; unsigned long flags;
int chip, channel,index; int chip, channel, index;
int retval; int retval;
void __iomem *base_addr; void __iomem *base_addr;
...@@ -2287,15 +2349,15 @@ block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -2287,15 +2349,15 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
if (info->flags & ASYNC_CLOSING) { if (info->flags & ASYNC_CLOSING) {
interruptible_sleep_on(&info->close_wait); interruptible_sleep_on(&info->close_wait);
} }
return ((info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); return ((info->
flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS);
} }
/* /*
* If non-blocking mode is set, then make the check up front * If non-blocking mode is set, then make the check up front
* and then exit. * and then exit.
*/ */
if ((filp->f_flags & O_NONBLOCK) || if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) {
(tty->flags & (1 << TTY_IO_ERROR))) {
info->flags |= ASYNC_NORMAL_ACTIVE; info->flags |= ASYNC_NORMAL_ACTIVE;
return 0; return 0;
} }
...@@ -2311,7 +2373,8 @@ block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -2311,7 +2373,8 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
add_wait_queue(&info->open_wait, &wait); add_wait_queue(&info->open_wait, &wait);
#ifdef CY_DEBUG_OPEN #ifdef CY_DEBUG_OPEN
printk("cyc block_til_ready before block: ttyC%d, count = %d\n", printk("cyc block_til_ready before block: ttyC%d, count = %d\n",
info->line, info->count);/**/ info->line, info->count);
/**/
#endif #endif
CY_LOCK(info, flags); CY_LOCK(info, flags);
if (!tty_hung_up_p(filp)) if (!tty_hung_up_p(filp))
...@@ -2324,39 +2387,45 @@ block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -2324,39 +2387,45 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
info->blocked_open++; info->blocked_open++;
if (!IS_CYC_Z(*cinfo)) { if (!IS_CYC_Z(*cinfo)) {
chip = channel>>2; chip = channel >> 2;
channel &= 0x03; channel &= 0x03;
index = cinfo->bus_index; index = cinfo->bus_index;
base_addr = cinfo->base_addr + (cy_chip_offset[chip]<<index); base_addr = cinfo->base_addr + (cy_chip_offset[chip] << index);
while (1) { while (1) {
CY_LOCK(info, flags); CY_LOCK(info, flags);
if ((tty->termios->c_cflag & CBAUD)){ if ((tty->termios->c_cflag & CBAUD)) {
cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); cy_writeb(base_addr + (CyCAR << index),
cy_writeb(base_addr+(CyMSVR1<<index), CyRTS); (u_char) channel);
cy_writeb(base_addr+(CyMSVR2<<index), CyDTR); cy_writeb(base_addr + (CyMSVR1 << index),
CyRTS);
cy_writeb(base_addr + (CyMSVR2 << index),
CyDTR);
#ifdef CY_DEBUG_DTR #ifdef CY_DEBUG_DTR
printk("cyc:block_til_ready raising DTR\n"); printk("cyc:block_til_ready raising DTR\n");
printk(" status: 0x%x, 0x%x\n", printk(" status: 0x%x, 0x%x\n",
cy_readb(base_addr+(CyMSVR1<<index)), cy_readb(base_addr +
cy_readb(base_addr+(CyMSVR2<<index))); (CyMSVR1 << index)),
cy_readb(base_addr +
(CyMSVR2 << index)));
#endif #endif
} }
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
if (tty_hung_up_p(filp) if (tty_hung_up_p(filp) ||
|| !(info->flags & ASYNC_INITIALIZED) ){ !(info->flags & ASYNC_INITIALIZED)) {
retval = ((info->flags & ASYNC_HUP_NOTIFY) ? retval = ((info->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS); -EAGAIN : -ERESTARTSYS);
break; break;
} }
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); cy_writeb(base_addr + (CyCAR << index),
if (!(info->flags & ASYNC_CLOSING) (u_char) channel);
&& (C_CLOCAL(tty) if (!(info->flags & ASYNC_CLOSING) && (C_CLOCAL(tty) ||
|| (cy_readb(base_addr+(CyMSVR1<<index)) & CyDCD))) { (cy_readb(base_addr +
(CyMSVR1 << index)) & CyDCD))) {
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
break; break;
} }
...@@ -2367,8 +2436,10 @@ block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -2367,8 +2436,10 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
break; break;
} }
#ifdef CY_DEBUG_OPEN #ifdef CY_DEBUG_OPEN
printk("cyc block_til_ready blocking: ttyC%d, count = %d\n", printk("cyc block_til_ready blocking: ttyC%d, "
info->line, info->count);/**/ "count = %d\n",
info->line, info->count);
/**/
#endif #endif
schedule(); schedule();
} }
...@@ -2381,25 +2452,28 @@ block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -2381,25 +2452,28 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
base_addr = cinfo->base_addr; base_addr = cinfo->base_addr;
firm_id = base_addr + ID_ADDRESS; firm_id = base_addr + ID_ADDRESS;
if (!ISZLOADED(*cinfo)){ if (!ISZLOADED(*cinfo)) {
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
remove_wait_queue(&info->open_wait, &wait); remove_wait_queue(&info->open_wait, &wait);
return -EINVAL; return -EINVAL;
} }
zfw_ctrl = base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); zfw_ctrl = base_addr + (cy_readl(&firm_id->zfwctrl_addr) &
0xfffff);
board_ctrl = &zfw_ctrl->board_ctrl; board_ctrl = &zfw_ctrl->board_ctrl;
ch_ctrl = zfw_ctrl->ch_ctrl; ch_ctrl = zfw_ctrl->ch_ctrl;
while (1) { while (1) {
if ((tty->termios->c_cflag & CBAUD)){ if ((tty->termios->c_cflag & CBAUD)) {
cy_writel(&ch_ctrl[channel].rs_control, cy_writel(&ch_ctrl[channel].rs_control,
cy_readl(&ch_ctrl[channel].rs_control) | cy_readl(&ch_ctrl[channel].
(C_RS_RTS | C_RS_DTR)); rs_control) | (C_RS_RTS |
C_RS_DTR));
retval = cyz_issue_cmd(&cy_card[info->card], retval = cyz_issue_cmd(&cy_card[info->card],
channel, C_CM_IOCTLM, 0L); channel, C_CM_IOCTLM, 0L);
if (retval != 0){ if (retval != 0) {
printk("cyc:block_til_ready retval on ttyC%d was %x\n", printk("cyc:block_til_ready retval on "
"ttyC%d was %x\n",
info->line, retval); info->line, retval);
} }
#ifdef CY_DEBUG_DTR #ifdef CY_DEBUG_DTR
...@@ -2408,15 +2482,15 @@ block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -2408,15 +2482,15 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
} }
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
if (tty_hung_up_p(filp) if (tty_hung_up_p(filp) ||
|| !(info->flags & ASYNC_INITIALIZED) ){ !(info->flags & ASYNC_INITIALIZED)) {
retval = ((info->flags & ASYNC_HUP_NOTIFY) ? retval = ((info->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS); -EAGAIN : -ERESTARTSYS);
break; break;
} }
if (!(info->flags & ASYNC_CLOSING) if (!(info->flags & ASYNC_CLOSING) && (C_CLOCAL(tty) ||
&& (C_CLOCAL(tty) (cy_readl(&ch_ctrl[channel].rs_status) &
|| (cy_readl(&ch_ctrl[channel].rs_status) & C_RS_DCD))) { C_RS_DCD))) {
break; break;
} }
if (signal_pending(current)) { if (signal_pending(current)) {
...@@ -2424,15 +2498,17 @@ block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -2424,15 +2498,17 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
break; break;
} }
#ifdef CY_DEBUG_OPEN #ifdef CY_DEBUG_OPEN
printk("cyc block_til_ready blocking: ttyC%d, count = %d\n", printk("cyc block_til_ready blocking: ttyC%d, "
info->line, info->count);/**/ "count = %d\n",
info->line, info->count);
/**/
#endif #endif
schedule(); schedule();
} }
} }
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
remove_wait_queue(&info->open_wait, &wait); remove_wait_queue(&info->open_wait, &wait);
if (!tty_hung_up_p(filp)){ if (!tty_hung_up_p(filp)) {
info->count++; info->count++;
#ifdef CY_DEBUG_COUNT #ifdef CY_DEBUG_COUNT
printk("cyc:block_til_ready (%d): incrementing count to %d\n", printk("cyc:block_til_ready (%d): incrementing count to %d\n",
...@@ -2442,7 +2518,8 @@ block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -2442,7 +2518,8 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
info->blocked_open--; info->blocked_open--;
#ifdef CY_DEBUG_OPEN #ifdef CY_DEBUG_OPEN
printk("cyc:block_til_ready after blocking: ttyC%d, count = %d\n", printk("cyc:block_til_ready after blocking: ttyC%d, count = %d\n",
info->line, info->count);/**/ info->line, info->count);
/**/
#endif #endif
if (retval) if (retval)
return retval; return retval;
...@@ -2450,23 +2527,21 @@ block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -2450,23 +2527,21 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
return 0; return 0;
} /* block_til_ready */ } /* block_til_ready */
/* /*
* This routine is called whenever a serial port is opened. It * This routine is called whenever a serial port is opened. It
* performs the serial-specific initialization for the tty structure. * performs the serial-specific initialization for the tty structure.
*/ */
static int static int cy_open(struct tty_struct *tty, struct file *filp)
cy_open(struct tty_struct *tty, struct file * filp)
{ {
struct cyclades_port *info; struct cyclades_port *info;
int retval, line; int retval, line;
line = tty->index; line = tty->index;
if ((line < 0) || (NR_PORTS <= line)){ if ((line < 0) || (NR_PORTS <= line)) {
return -ENODEV; return -ENODEV;
} }
info = &cy_port[line]; info = &cy_port[line];
if (info->line < 0){ if (info->line < 0) {
return -ENODEV; return -ENODEV;
} }
...@@ -2479,40 +2554,49 @@ cy_open(struct tty_struct *tty, struct file * filp) ...@@ -2479,40 +2554,49 @@ cy_open(struct tty_struct *tty, struct file * filp)
struct FIRM_ID __iomem *firm_id = cinfo->base_addr + ID_ADDRESS; struct FIRM_ID __iomem *firm_id = cinfo->base_addr + ID_ADDRESS;
if (!ISZLOADED(*cinfo)) { if (!ISZLOADED(*cinfo)) {
if (((ZE_V1 ==cy_readl(&((struct RUNTIME_9060 __iomem *) if (((ZE_V1 == cy_readl(
&((struct RUNTIME_9060 __iomem *)
(cinfo->ctl_addr))->mail_box_0)) && (cinfo->ctl_addr))->mail_box_0)) &&
Z_FPGA_CHECK (*cinfo)) && Z_FPGA_CHECK(*cinfo)) &&
(ZFIRM_HLT == cy_readl (&firm_id->signature))) (ZFIRM_HLT == cy_readl(
{ &firm_id->signature))) {
printk ("cyc:Cyclades-Z Error: you need an external power supply for this number of ports.\n\rFirmware halted.\r\n"); printk("cyc:Cyclades-Z Error: you need an "
"external power supply for this number "
"of ports.\n\rFirmware halted.\r\n");
} else { } else {
printk("cyc:Cyclades-Z firmware not yet loaded\n"); printk("cyc:Cyclades-Z firmware not yet "
"loaded\n");
} }
return -ENODEV; return -ENODEV;
} }
#ifdef CONFIG_CYZ_INTR #ifdef CONFIG_CYZ_INTR
else { else {
/* In case this Z board is operating in interrupt mode, its /* In case this Z board is operating in interrupt mode, its
interrupts should be enabled as soon as the first open happens interrupts should be enabled as soon as the first open
to one of its ports. */ happens to one of its ports. */
if (!cinfo->intr_enabled) { if (!cinfo->intr_enabled) {
struct ZFW_CTRL __iomem *zfw_ctrl; struct ZFW_CTRL __iomem *zfw_ctrl;
struct BOARD_CTRL __iomem *board_ctrl; struct BOARD_CTRL __iomem *board_ctrl;
zfw_ctrl = cinfo->base_addr + (cy_readl (&firm_id->zfwctrl_addr) & 0xfffff); zfw_ctrl = cinfo->base_addr +
(cy_readl(&firm_id->zfwctrl_addr) &
0xfffff);
board_ctrl = &zfw_ctrl->board_ctrl; board_ctrl = &zfw_ctrl->board_ctrl;
/* Enable interrupts on the PLX chip */ /* Enable interrupts on the PLX chip */
cy_writew(cinfo->ctl_addr+0x68, cy_writew(cinfo->ctl_addr + 0x68,
cy_readw(cinfo->ctl_addr+0x68)|0x0900); cy_readw(cinfo->ctl_addr +
0x68) | 0x0900);
/* Enable interrupts on the FW */ /* Enable interrupts on the FW */
retval = cyz_issue_cmd(cinfo, retval = cyz_issue_cmd(cinfo, 0,
0, C_CM_IRQ_ENBL, 0L); C_CM_IRQ_ENBL, 0L);
if (retval != 0){ if (retval != 0) {
printk("cyc:IRQ enable retval was %x\n", retval); printk("cyc:IRQ enable retval was %x\n",
retval);
} }
cinfo->nports = (int) cy_readl (&board_ctrl->n_channel); cinfo->nports =
(int)cy_readl(&board_ctrl->n_channel);
cinfo->intr_enabled = 1; cinfo->intr_enabled = 1;
} }
} }
...@@ -2526,12 +2610,12 @@ cy_open(struct tty_struct *tty, struct file * filp) ...@@ -2526,12 +2610,12 @@ cy_open(struct tty_struct *tty, struct file * filp)
#endif #endif
tty->driver_data = info; tty->driver_data = info;
info->tty = tty; info->tty = tty;
if (serial_paranoia_check(info, tty->name, "cy_open")){ if (serial_paranoia_check(info, tty->name, "cy_open")) {
return -ENODEV; return -ENODEV;
} }
#ifdef CY_DEBUG_OPEN #ifdef CY_DEBUG_OPEN
printk("cyc:cy_open ttyC%d, count = %d\n", printk("cyc:cy_open ttyC%d, count = %d\n", info->line, info->count);
info->line, info->count);/**/ /**/
#endif #endif
info->count++; info->count++;
#ifdef CY_DEBUG_COUNT #ifdef CY_DEBUG_COUNT
...@@ -2545,14 +2629,15 @@ cy_open(struct tty_struct *tty, struct file * filp) ...@@ -2545,14 +2629,15 @@ cy_open(struct tty_struct *tty, struct file * filp)
if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) { if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) {
if (info->flags & ASYNC_CLOSING) if (info->flags & ASYNC_CLOSING)
interruptible_sleep_on(&info->close_wait); interruptible_sleep_on(&info->close_wait);
return ((info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); return ((info->
flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS);
} }
/* /*
* Start up serial port * Start up serial port
*/ */
retval = startup(info); retval = startup(info);
if (retval){ if (retval) {
return retval; return retval;
} }
...@@ -2568,22 +2653,20 @@ cy_open(struct tty_struct *tty, struct file * filp) ...@@ -2568,22 +2653,20 @@ cy_open(struct tty_struct *tty, struct file * filp)
info->throttle = 0; info->throttle = 0;
#ifdef CY_DEBUG_OPEN #ifdef CY_DEBUG_OPEN
printk(" cyc:cy_open done\n");/**/ printk(" cyc:cy_open done\n");
/**/
#endif #endif
return 0; return 0;
} /* cy_open */ } /* cy_open */
/* /*
* cy_wait_until_sent() --- wait until the transmitter is empty * cy_wait_until_sent() --- wait until the transmitter is empty
*/ */
static void static void cy_wait_until_sent(struct tty_struct *tty, int timeout)
cy_wait_until_sent(struct tty_struct *tty, int timeout)
{ {
struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
void __iomem *base_addr; void __iomem *base_addr;
int card,chip,channel,index; int card, chip, channel, index;
unsigned long orig_jiffies; unsigned long orig_jiffies;
int char_time; int char_time;
...@@ -2593,7 +2676,6 @@ cy_wait_until_sent(struct tty_struct *tty, int timeout) ...@@ -2593,7 +2676,6 @@ cy_wait_until_sent(struct tty_struct *tty, int timeout)
if (info->xmit_fifo_size == 0) if (info->xmit_fifo_size == 0)
return; /* Just in case.... */ return; /* Just in case.... */
orig_jiffies = jiffies; orig_jiffies = jiffies;
/* /*
* Set the check interval to be 1/5 of the estimated time to * Set the check interval to be 1/5 of the estimated time to
...@@ -2603,7 +2685,7 @@ cy_wait_until_sent(struct tty_struct *tty, int timeout) ...@@ -2603,7 +2685,7 @@ cy_wait_until_sent(struct tty_struct *tty, int timeout)
* Note: we have to use pretty tight timings here to satisfy * Note: we have to use pretty tight timings here to satisfy
* the NIST-PCTS. * the NIST-PCTS.
*/ */
char_time = (info->timeout - HZ/50) / info->xmit_fifo_size; char_time = (info->timeout - HZ / 50) / info->xmit_fifo_size;
char_time = char_time / 5; char_time = char_time / 5;
if (char_time <= 0) if (char_time <= 0)
char_time = 1; char_time = 1;
...@@ -2620,8 +2702,8 @@ cy_wait_until_sent(struct tty_struct *tty, int timeout) ...@@ -2620,8 +2702,8 @@ cy_wait_until_sent(struct tty_struct *tty, int timeout)
* UART bug of some kind. So, we clamp the timeout parameter at * UART bug of some kind. So, we clamp the timeout parameter at
* 2*info->timeout. * 2*info->timeout.
*/ */
if (!timeout || timeout > 2*info->timeout) if (!timeout || timeout > 2 * info->timeout)
timeout = 2*info->timeout; timeout = 2 * info->timeout;
#ifdef CY_DEBUG_WAIT_UNTIL_SENT #ifdef CY_DEBUG_WAIT_UNTIL_SENT
printk("In cy_wait_until_sent(%d) check=%lu...", timeout, char_time); printk("In cy_wait_until_sent(%d) check=%lu...", timeout, char_time);
printk("jiff=%lu...", jiffies); printk("jiff=%lu...", jiffies);
...@@ -2629,17 +2711,19 @@ cy_wait_until_sent(struct tty_struct *tty, int timeout) ...@@ -2629,17 +2711,19 @@ cy_wait_until_sent(struct tty_struct *tty, int timeout)
card = info->card; card = info->card;
channel = (info->line) - (cy_card[card].first_line); channel = (info->line) - (cy_card[card].first_line);
if (!IS_CYC_Z(cy_card[card])) { if (!IS_CYC_Z(cy_card[card])) {
chip = channel>>2; chip = channel >> 2;
channel &= 0x03; channel &= 0x03;
index = cy_card[card].bus_index; index = cy_card[card].bus_index;
base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); base_addr =
while (cy_readb(base_addr+(CySRER<<index)) & CyTxRdy) { cy_card[card].base_addr + (cy_chip_offset[chip] << index);
while (cy_readb(base_addr + (CySRER << index)) & CyTxRdy) {
#ifdef CY_DEBUG_WAIT_UNTIL_SENT #ifdef CY_DEBUG_WAIT_UNTIL_SENT
printk("Not clean (jiff=%lu)...", jiffies); printk("Not clean (jiff=%lu)...", jiffies);
#endif #endif
if (msleep_interruptible(jiffies_to_msecs(char_time))) if (msleep_interruptible(jiffies_to_msecs(char_time)))
break; break;
if (timeout && time_after(jiffies, orig_jiffies + timeout)) if (timeout && time_after(jiffies, orig_jiffies +
timeout))
break; break;
} }
} else { } else {
...@@ -2655,8 +2739,7 @@ cy_wait_until_sent(struct tty_struct *tty, int timeout) ...@@ -2655,8 +2739,7 @@ cy_wait_until_sent(struct tty_struct *tty, int timeout)
/* /*
* This routine is called when a particular tty device is closed. * This routine is called when a particular tty device is closed.
*/ */
static void 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; unsigned long flags;
...@@ -2665,7 +2748,7 @@ cy_close(struct tty_struct *tty, struct file *filp) ...@@ -2665,7 +2748,7 @@ cy_close(struct tty_struct *tty, struct file *filp)
printk("cyc:cy_close ttyC%d\n", info->line); printk("cyc:cy_close ttyC%d\n", info->line);
#endif #endif
if (!info || serial_paranoia_check(info, tty->name, "cy_close")){ if (!info || serial_paranoia_check(info, tty->name, "cy_close")) {
return; return;
} }
...@@ -2675,7 +2758,6 @@ cy_close(struct tty_struct *tty, struct file *filp) ...@@ -2675,7 +2758,6 @@ cy_close(struct tty_struct *tty, struct file *filp)
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
return; return;
} }
#ifdef CY_DEBUG_OPEN #ifdef CY_DEBUG_OPEN
printk("cyc:cy_close ttyC%d, count = %d\n", info->line, info->count); printk("cyc:cy_close ttyC%d, count = %d\n", info->line, info->count);
#endif #endif
...@@ -2721,12 +2803,13 @@ cy_close(struct tty_struct *tty, struct file *filp) ...@@ -2721,12 +2803,13 @@ cy_close(struct tty_struct *tty, struct file *filp)
if (!IS_CYC_Z(cy_card[info->card])) { if (!IS_CYC_Z(cy_card[info->card])) {
int channel = info->line - cy_card[info->card].first_line; int channel = info->line - cy_card[info->card].first_line;
int index = cy_card[info->card].bus_index; int index = cy_card[info->card].bus_index;
void __iomem *base_addr = cy_card[info->card].base_addr + (cy_chip_offset[channel>>2] << index); void __iomem *base_addr = cy_card[info->card].base_addr +
(cy_chip_offset[channel >> 2] << index);
/* Stop accepting input */ /* Stop accepting input */
channel &= 0x03; channel &= 0x03;
cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
cy_writeb(base_addr+(CySRER<<index), cy_writeb(base_addr + (CySRER << index),
cy_readb(base_addr+(CySRER<<index)) & ~CyRxData); cy_readb(base_addr + (CySRER << index)) & ~CyRxData);
if (info->flags & ASYNC_INITIALIZED) { if (info->flags & ASYNC_INITIALIZED) {
/* Waiting for on-board buffers to be empty before closing /* Waiting for on-board buffers to be empty before closing
the port */ the port */
...@@ -2739,7 +2822,8 @@ cy_close(struct tty_struct *tty, struct file *filp) ...@@ -2739,7 +2822,8 @@ cy_close(struct tty_struct *tty, struct file *filp)
/* Waiting for on-board buffers to be empty before closing the port */ /* Waiting for on-board buffers to be empty before closing the port */
void __iomem *base_addr = cy_card[info->card].base_addr; void __iomem *base_addr = cy_card[info->card].base_addr;
struct FIRM_ID __iomem *firm_id = base_addr + ID_ADDRESS; struct FIRM_ID __iomem *firm_id = base_addr + ID_ADDRESS;
struct ZFW_CTRL __iomem *zfw_ctrl = base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); struct ZFW_CTRL __iomem *zfw_ctrl =
base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
struct CH_CTRL __iomem *ch_ctrl = zfw_ctrl->ch_ctrl; struct CH_CTRL __iomem *ch_ctrl = zfw_ctrl->ch_ctrl;
int channel = info->line - cy_card[info->card].first_line; int channel = info->line - cy_card[info->card].first_line;
int retval; int retval;
...@@ -2747,7 +2831,7 @@ cy_close(struct tty_struct *tty, struct file *filp) ...@@ -2747,7 +2831,7 @@ cy_close(struct tty_struct *tty, struct file *filp)
if (cy_readl(&ch_ctrl[channel].flow_status) != C_FS_TXIDLE) { if (cy_readl(&ch_ctrl[channel].flow_status) != C_FS_TXIDLE) {
retval = cyz_issue_cmd(&cy_card[info->card], channel, retval = cyz_issue_cmd(&cy_card[info->card], channel,
C_CM_IOCTLW, 0L); C_CM_IOCTLW, 0L);
if (retval != 0){ if (retval != 0) {
printk("cyc:cy_close retval on ttyC%d was %x\n", printk("cyc:cy_close retval on ttyC%d was %x\n",
info->line, retval); info->line, retval);
} }
...@@ -2771,12 +2855,13 @@ cy_close(struct tty_struct *tty, struct file *filp) ...@@ -2771,12 +2855,13 @@ cy_close(struct tty_struct *tty, struct file *filp)
if (info->blocked_open) { if (info->blocked_open) {
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
if (info->close_delay) { if (info->close_delay) {
msleep_interruptible(jiffies_to_msecs(info->close_delay)); msleep_interruptible(jiffies_to_msecs
(info->close_delay));
} }
wake_up_interruptible(&info->open_wait); wake_up_interruptible(&info->open_wait);
CY_LOCK(info, flags); CY_LOCK(info, flags);
} }
info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
wake_up_interruptible(&info->close_wait); wake_up_interruptible(&info->close_wait);
#ifdef CY_DEBUG_OTHER #ifdef CY_DEBUG_OTHER
...@@ -2787,7 +2872,6 @@ cy_close(struct tty_struct *tty, struct file *filp) ...@@ -2787,7 +2872,6 @@ cy_close(struct tty_struct *tty, struct file *filp)
return; return;
} /* cy_close */ } /* cy_close */
/* This routine gets called when tty_write has put something into /* This routine gets called when tty_write has put something into
* the write_queue. The characters may come from user space or * the write_queue. The characters may come from user space or
* kernel space. * kernel space.
...@@ -2801,8 +2885,7 @@ cy_close(struct tty_struct *tty, struct file *filp) ...@@ -2801,8 +2885,7 @@ cy_close(struct tty_struct *tty, struct file *filp)
* If the port is already active, there is no need to kick it. * If the port is already active, there is no need to kick it.
* *
*/ */
static int static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
cy_write(struct tty_struct * tty, const unsigned char *buf, int count)
{ {
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
unsigned long flags; unsigned long flags;
...@@ -2812,7 +2895,7 @@ cy_write(struct tty_struct * tty, const unsigned char *buf, int count) ...@@ -2812,7 +2895,7 @@ cy_write(struct tty_struct * tty, const unsigned char *buf, int count)
printk("cyc:cy_write ttyC%d\n", info->line); /* */ printk("cyc:cy_write ttyC%d\n", info->line); /* */
#endif #endif
if (serial_paranoia_check(info, tty->name, "cy_write")){ if (serial_paranoia_check(info, tty->name, "cy_write")) {
return 0; return 0;
} }
...@@ -2828,7 +2911,8 @@ cy_write(struct tty_struct * tty, const unsigned char *buf, int count) ...@@ -2828,7 +2911,8 @@ cy_write(struct tty_struct * tty, const unsigned char *buf, int count)
break; break;
memcpy(info->xmit_buf + info->xmit_head, buf, c); memcpy(info->xmit_buf + info->xmit_head, buf, c);
info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1); info->xmit_head = (info->xmit_head + c) &
(SERIAL_XMIT_SIZE - 1);
info->xmit_cnt += c; info->xmit_cnt += c;
buf += c; buf += c;
count -= c; count -= c;
...@@ -2845,7 +2929,6 @@ cy_write(struct tty_struct * tty, const unsigned char *buf, int count) ...@@ -2845,7 +2929,6 @@ cy_write(struct tty_struct * tty, const unsigned char *buf, int count)
return ret; return ret;
} /* cy_write */ } /* cy_write */
/* /*
* This routine is called by the kernel to write a single * This routine is called by the kernel to write a single
* character to the tty device. If the kernel uses this routine, * character to the tty device. If the kernel uses this routine,
...@@ -2853,8 +2936,7 @@ cy_write(struct tty_struct * tty, const unsigned char *buf, int count) ...@@ -2853,8 +2936,7 @@ cy_write(struct tty_struct * tty, const unsigned char *buf, int count)
* done stuffing characters into the driver. If there is no room * done stuffing characters into the driver. If there is no room
* in the queue, the character is ignored. * in the queue, the character is ignored.
*/ */
static void static void cy_put_char(struct tty_struct *tty, unsigned char ch)
cy_put_char(struct tty_struct *tty, unsigned char ch)
{ {
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
unsigned long flags; unsigned long flags;
...@@ -2883,13 +2965,11 @@ cy_put_char(struct tty_struct *tty, unsigned char ch) ...@@ -2883,13 +2965,11 @@ cy_put_char(struct tty_struct *tty, unsigned char ch)
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
} /* cy_put_char */ } /* cy_put_char */
/* /*
* This routine is called by the kernel after it has written a * This routine is called by the kernel after it has written a
* series of characters to the tty device using put_char(). * series of characters to the tty device using put_char().
*/ */
static void static void cy_flush_chars(struct tty_struct *tty)
cy_flush_chars(struct tty_struct *tty)
{ {
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
...@@ -2900,22 +2980,20 @@ cy_flush_chars(struct tty_struct *tty) ...@@ -2900,22 +2980,20 @@ cy_flush_chars(struct tty_struct *tty)
if (serial_paranoia_check(info, tty->name, "cy_flush_chars")) if (serial_paranoia_check(info, tty->name, "cy_flush_chars"))
return; return;
if (info->xmit_cnt <= 0 || tty->stopped if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
|| tty->hw_stopped || !info->xmit_buf) !info->xmit_buf)
return; return;
start_xmit(info); start_xmit(info);
} /* cy_flush_chars */ } /* cy_flush_chars */
/* /*
* This routine returns the numbers of characters the tty driver * This routine returns the numbers of characters the tty driver
* will accept for queuing to be written. This number is subject * will accept for queuing to be written. This number is subject
* to change as output buffers get emptied, or if the output flow * to change as output buffers get emptied, or if the output flow
* control is activated. * control is activated.
*/ */
static int static int cy_write_room(struct tty_struct *tty)
cy_write_room(struct tty_struct *tty)
{ {
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
int ret; int ret;
...@@ -2932,9 +3010,7 @@ cy_write_room(struct tty_struct *tty) ...@@ -2932,9 +3010,7 @@ cy_write_room(struct tty_struct *tty)
return ret; return ret;
} /* cy_write_room */ } /* cy_write_room */
static int cy_chars_in_buffer(struct tty_struct *tty)
static int
cy_chars_in_buffer(struct tty_struct *tty)
{ {
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
int card, channel; int card, channel;
...@@ -2949,8 +3025,7 @@ cy_chars_in_buffer(struct tty_struct *tty) ...@@ -2949,8 +3025,7 @@ cy_chars_in_buffer(struct tty_struct *tty)
if (!IS_CYC_Z(cy_card[card])) { if (!IS_CYC_Z(cy_card[card])) {
#endif /* Z_EXT_CHARS_IN_BUFFER */ #endif /* Z_EXT_CHARS_IN_BUFFER */
#ifdef CY_DEBUG_IO #ifdef CY_DEBUG_IO
printk("cyc:cy_chars_in_buffer ttyC%d %d\n", printk("cyc:cy_chars_in_buffer ttyC%d %d\n", info->line, info->xmit_cnt); /* */
info->line, info->xmit_cnt); /* */
#endif #endif
return info->xmit_cnt; return info->xmit_cnt;
#ifdef Z_EXT_CHARS_IN_BUFFER #ifdef Z_EXT_CHARS_IN_BUFFER
...@@ -2963,7 +3038,8 @@ cy_chars_in_buffer(struct tty_struct *tty) ...@@ -2963,7 +3038,8 @@ cy_chars_in_buffer(struct tty_struct *tty)
volatile uclong tx_put, tx_get, tx_bufsize; volatile uclong tx_put, tx_get, tx_bufsize;
firm_id = cy_card[card].base_addr + ID_ADDRESS; firm_id = cy_card[card].base_addr + ID_ADDRESS;
zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); zfw_ctrl = cy_card[card].base_addr +
(cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]); ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]); buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]);
...@@ -2975,26 +3051,24 @@ cy_chars_in_buffer(struct tty_struct *tty) ...@@ -2975,26 +3051,24 @@ cy_chars_in_buffer(struct tty_struct *tty)
else else
char_count = tx_put - tx_get + tx_bufsize; char_count = tx_put - tx_get + tx_bufsize;
#ifdef CY_DEBUG_IO #ifdef CY_DEBUG_IO
printk("cyc:cy_chars_in_buffer ttyC%d %d\n", printk("cyc:cy_chars_in_buffer ttyC%d %d\n", info->line, info->xmit_cnt + char_count); /* */
info->line, info->xmit_cnt + char_count); /* */
#endif #endif
return (info->xmit_cnt + char_count); return (info->xmit_cnt + char_count);
} }
#endif /* Z_EXT_CHARS_IN_BUFFER */ #endif /* Z_EXT_CHARS_IN_BUFFER */
} /* cy_chars_in_buffer */ } /* cy_chars_in_buffer */
/* /*
* ------------------------------------------------------------ * ------------------------------------------------------------
* cy_ioctl() and friends * cy_ioctl() and friends
* ------------------------------------------------------------ * ------------------------------------------------------------
*/ */
static void static void cyy_baud_calc(struct cyclades_port *info, uclong baud)
cyy_baud_calc(struct cyclades_port *info, uclong baud)
{ {
int co, co_val, bpr; int co, co_val, bpr;
uclong cy_clock = ((info->chip_rev >= CD1400_REV_J) ? 60000000 : 25000000); uclong cy_clock = ((info->chip_rev >= CD1400_REV_J) ? 60000000 :
25000000);
if (baud == 0) { if (baud == 0) {
info->tbpr = info->tco = info->rbpr = info->rco = 0; info->tbpr = info->tco = info->rbpr = info->rco = 0;
...@@ -3019,22 +3093,20 @@ cyy_baud_calc(struct cyclades_port *info, uclong baud) ...@@ -3019,22 +3093,20 @@ cyy_baud_calc(struct cyclades_port *info, uclong baud)
* This routine finds or computes the various line characteristics. * This routine finds or computes the various line characteristics.
* It used to be called config_setup * It used to be called config_setup
*/ */
static void static void set_line_char(struct cyclades_port *info)
set_line_char(struct cyclades_port * info)
{ {
unsigned long flags; unsigned long flags;
void __iomem *base_addr; void __iomem *base_addr;
int card,chip,channel,index; int card, chip, channel, index;
unsigned cflag, iflag; unsigned cflag, iflag;
unsigned short chip_number; unsigned short chip_number;
int baud, baud_rate = 0; int baud, baud_rate = 0;
int i; int i;
if (!info->tty || !info->tty->termios) {
if (!info->tty || !info->tty->termios){
return; return;
} }
if (info->line == -1){ if (info->line == -1) {
return; return;
} }
cflag = info->tty->termios->c_cflag; cflag = info->tty->termios->c_cflag;
...@@ -3064,8 +3136,8 @@ set_line_char(struct cyclades_port * info) ...@@ -3064,8 +3136,8 @@ set_line_char(struct cyclades_port * info)
/* baud rate */ /* baud rate */
baud = tty_get_baud_rate(info->tty); baud = tty_get_baud_rate(info->tty);
if ((baud == 38400) && if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) { ASYNC_SPD_CUST) {
if (info->custom_divisor) if (info->custom_divisor)
baud_rate = info->baud / info->custom_divisor; baud_rate = info->baud / info->custom_divisor;
else else
...@@ -3083,11 +3155,11 @@ set_line_char(struct cyclades_port * info) ...@@ -3083,11 +3155,11 @@ set_line_char(struct cyclades_port * info)
i = 19; /* CD1400_MAX_SPEED */ i = 19; /* CD1400_MAX_SPEED */
} }
if ((baud == 38400) && if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) { ASYNC_SPD_CUST) {
cyy_baud_calc(info, baud_rate); cyy_baud_calc(info, baud_rate);
} else { } else {
if(info->chip_rev >= CD1400_REV_J) { if (info->chip_rev >= CD1400_REV_J) {
/* It is a CD1400 rev. J or later */ /* It is a CD1400 rev. J or later */
info->tbpr = baud_bpr_60[i]; /* Tx BPR */ info->tbpr = baud_bpr_60[i]; /* Tx BPR */
info->tco = baud_co_60[i]; /* Tx CO */ info->tco = baud_co_60[i]; /* Tx CO */
...@@ -3102,12 +3174,15 @@ set_line_char(struct cyclades_port * info) ...@@ -3102,12 +3174,15 @@ set_line_char(struct cyclades_port * info)
} }
if (baud_table[i] == 134) { if (baud_table[i] == 134) {
/* get it right for 134.5 baud */ /* get it right for 134.5 baud */
info->timeout = (info->xmit_fifo_size*HZ*30/269) + 2; info->timeout = (info->xmit_fifo_size * HZ * 30 / 269) +
} else if ((baud == 38400) && 2;
((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) { } else if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
info->timeout = (info->xmit_fifo_size*HZ*15/baud_rate) + 2; ASYNC_SPD_CUST) {
info->timeout = (info->xmit_fifo_size * HZ * 15 /
baud_rate) + 2;
} else if (baud_table[i]) { } else if (baud_table[i]) {
info->timeout = (info->xmit_fifo_size*HZ*15/baud_table[i]) + 2; info->timeout = (info->xmit_fifo_size * HZ * 15 /
baud_table[i]) + 2;
/* this needs to be propagated into the card info */ /* this needs to be propagated into the card info */
} else { } else {
info->timeout = 0; info->timeout = 0;
...@@ -3119,11 +3194,11 @@ set_line_char(struct cyclades_port * info) ...@@ -3119,11 +3194,11 @@ set_line_char(struct cyclades_port * info)
/* byte size and parity */ /* byte size and parity */
info->cor5 = 0; info->cor5 = 0;
info->cor4 = 0; info->cor4 = 0;
info->cor3 = (info->default_threshold /* receive threshold */
? info->default_threshold info->cor3 = (info->default_threshold ?
: baud_cor3[i]); /* receive threshold */ info->default_threshold : baud_cor3[i]);
info->cor2 = CyETC; info->cor2 = CyETC;
switch(cflag & CSIZE){ switch (cflag & CSIZE) {
case CS5: case CS5:
info->cor1 = Cy_5_BITS; info->cor1 = Cy_5_BITS;
break; break;
...@@ -3137,24 +3212,24 @@ set_line_char(struct cyclades_port * info) ...@@ -3137,24 +3212,24 @@ set_line_char(struct cyclades_port * info)
info->cor1 = Cy_8_BITS; info->cor1 = Cy_8_BITS;
break; break;
} }
if(cflag & CSTOPB){ if (cflag & CSTOPB) {
info->cor1 |= Cy_2_STOP; info->cor1 |= Cy_2_STOP;
} }
if (cflag & PARENB){ if (cflag & PARENB) {
if (cflag & PARODD){ if (cflag & PARODD) {
info->cor1 |= CyPARITY_O; info->cor1 |= CyPARITY_O;
}else{ } else {
info->cor1 |= CyPARITY_E; info->cor1 |= CyPARITY_E;
} }
}else{ } else {
info->cor1 |= CyPARITY_NONE; info->cor1 |= CyPARITY_NONE;
} }
/* CTS flow control flag */ /* CTS flow control flag */
if (cflag & CRTSCTS){ if (cflag & CRTSCTS) {
info->flags |= ASYNC_CTS_FLOW; info->flags |= ASYNC_CTS_FLOW;
info->cor2 |= CyCtsAE; info->cor2 |= CyCtsAE;
}else{ } else {
info->flags &= ~ASYNC_CTS_FLOW; info->flags &= ~ASYNC_CTS_FLOW;
info->cor2 &= ~CyCtsAE; info->cor2 &= ~CyCtsAE;
} }
...@@ -3173,98 +3248,105 @@ set_line_char(struct cyclades_port * info) ...@@ -3173,98 +3248,105 @@ set_line_char(struct cyclades_port * info)
cable. Contact Marcio Saito for details. cable. Contact Marcio Saito for details.
***********************************************/ ***********************************************/
chip = channel>>2; chip = channel >> 2;
channel &= 0x03; channel &= 0x03;
base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); base_addr = cy_card[card].base_addr +
(cy_chip_offset[chip] << index);
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
/* tx and rx baud rate */ /* tx and rx baud rate */
cy_writeb(base_addr+(CyTCOR<<index), info->tco); cy_writeb(base_addr + (CyTCOR << index), info->tco);
cy_writeb(base_addr+(CyTBPR<<index), info->tbpr); cy_writeb(base_addr + (CyTBPR << index), info->tbpr);
cy_writeb(base_addr+(CyRCOR<<index), info->rco); cy_writeb(base_addr + (CyRCOR << index), info->rco);
cy_writeb(base_addr+(CyRBPR<<index), info->rbpr); cy_writeb(base_addr + (CyRBPR << index), info->rbpr);
/* set line characteristics according configuration */ /* set line characteristics according configuration */
cy_writeb(base_addr+(CySCHR1<<index), cy_writeb(base_addr + (CySCHR1 << index),
START_CHAR(info->tty)); START_CHAR(info->tty));
cy_writeb(base_addr+(CySCHR2<<index), cy_writeb(base_addr + (CySCHR2 << index), STOP_CHAR(info->tty));
STOP_CHAR(info->tty)); cy_writeb(base_addr + (CyCOR1 << index), info->cor1);
cy_writeb(base_addr+(CyCOR1<<index), info->cor1); cy_writeb(base_addr + (CyCOR2 << index), info->cor2);
cy_writeb(base_addr+(CyCOR2<<index), info->cor2); cy_writeb(base_addr + (CyCOR3 << index), info->cor3);
cy_writeb(base_addr+(CyCOR3<<index), info->cor3); cy_writeb(base_addr + (CyCOR4 << index), info->cor4);
cy_writeb(base_addr+(CyCOR4<<index), info->cor4); cy_writeb(base_addr + (CyCOR5 << index), info->cor5);
cy_writeb(base_addr+(CyCOR5<<index), info->cor5);
cyy_issue_cmd(base_addr, CyCOR_CHANGE | CyCOR1ch | CyCOR2ch |
cyy_issue_cmd(base_addr, CyCOR3ch, index);
CyCOR_CHANGE|CyCOR1ch|CyCOR2ch|CyCOR3ch,index);
cy_writeb(base_addr + (CyCAR << index), (u_char) channel); /* !!! Is this needed? */
cy_writeb(base_addr+(CyCAR<<index), cy_writeb(base_addr + (CyRTPR << index),
(u_char)channel); /* !!! Is this needed? */ (info->default_timeout ? info->default_timeout : 0x02));
cy_writeb(base_addr+(CyRTPR<<index), (info->default_timeout /* 10ms rx timeout */
? info->default_timeout
: 0x02)); /* 10ms rx timeout */
if (C_CLOCAL(info->tty)) { if (C_CLOCAL(info->tty)) {
/* without modem intr */ /* without modem intr */
cy_writeb(base_addr+(CySRER<<index), cy_writeb(base_addr + (CySRER << index),
cy_readb(base_addr+(CySRER<<index)) | CyMdmCh); cy_readb(base_addr +
(CySRER << index)) | CyMdmCh);
/* act on 1->0 modem transitions */ /* act on 1->0 modem transitions */
if ((cflag & CRTSCTS) && info->rflow) { if ((cflag & CRTSCTS) && info->rflow) {
cy_writeb(base_addr+(CyMCOR1<<index), cy_writeb(base_addr + (CyMCOR1 << index),
(CyCTS|rflow_thr[i])); (CyCTS | rflow_thr[i]));
} else { } else {
cy_writeb(base_addr+(CyMCOR1<<index), CyCTS); cy_writeb(base_addr + (CyMCOR1 << index),
CyCTS);
} }
/* act on 0->1 modem transitions */ /* act on 0->1 modem transitions */
cy_writeb(base_addr+(CyMCOR2<<index), CyCTS); cy_writeb(base_addr + (CyMCOR2 << index), CyCTS);
} else { } else {
/* without modem intr */ /* without modem intr */
cy_writeb(base_addr+(CySRER<<index), cy_writeb(base_addr + (CySRER << index),
cy_readb(base_addr+(CySRER<<index)) | CyMdmCh); cy_readb(base_addr +
(CySRER << index)) | CyMdmCh);
/* act on 1->0 modem transitions */ /* act on 1->0 modem transitions */
if ((cflag & CRTSCTS) && info->rflow) { if ((cflag & CRTSCTS) && info->rflow) {
cy_writeb(base_addr+(CyMCOR1<<index), cy_writeb(base_addr + (CyMCOR1 << index),
(CyDSR|CyCTS|CyRI|CyDCD|rflow_thr[i])); (CyDSR | CyCTS | CyRI | CyDCD |
rflow_thr[i]));
} else { } else {
cy_writeb(base_addr+(CyMCOR1<<index), cy_writeb(base_addr + (CyMCOR1 << index),
CyDSR|CyCTS|CyRI|CyDCD); CyDSR | CyCTS | CyRI | CyDCD);
} }
/* act on 0->1 modem transitions */ /* act on 0->1 modem transitions */
cy_writeb(base_addr+(CyMCOR2<<index), cy_writeb(base_addr + (CyMCOR2 << index),
CyDSR|CyCTS|CyRI|CyDCD); CyDSR | CyCTS | CyRI | CyDCD);
} }
if(i == 0){ /* baud rate is zero, turn off line */ if (i == 0) { /* baud rate is zero, turn off line */
if (info->rtsdtr_inv) { if (info->rtsdtr_inv) {
cy_writeb(base_addr+(CyMSVR1<<index), ~CyRTS); cy_writeb(base_addr + (CyMSVR1 << index),
~CyRTS);
} else { } else {
cy_writeb(base_addr+(CyMSVR2<<index), ~CyDTR); cy_writeb(base_addr + (CyMSVR2 << index),
~CyDTR);
} }
#ifdef CY_DEBUG_DTR #ifdef CY_DEBUG_DTR
printk("cyc:set_line_char dropping DTR\n"); printk("cyc:set_line_char dropping DTR\n");
printk(" status: 0x%x, 0x%x\n", printk(" status: 0x%x, 0x%x\n",
cy_readb(base_addr+(CyMSVR1<<index)), cy_readb(base_addr + (CyMSVR1 << index)),
cy_readb(base_addr+(CyMSVR2<<index))); cy_readb(base_addr + (CyMSVR2 << index)));
#endif #endif
}else{ } else {
if (info->rtsdtr_inv) { if (info->rtsdtr_inv) {
cy_writeb(base_addr+(CyMSVR1<<index), CyRTS); cy_writeb(base_addr + (CyMSVR1 << index),
CyRTS);
} else { } else {
cy_writeb(base_addr+(CyMSVR2<<index), CyDTR); cy_writeb(base_addr + (CyMSVR2 << index),
CyDTR);
} }
#ifdef CY_DEBUG_DTR #ifdef CY_DEBUG_DTR
printk("cyc:set_line_char raising DTR\n"); printk("cyc:set_line_char raising DTR\n");
printk(" status: 0x%x, 0x%x\n", printk(" status: 0x%x, 0x%x\n",
cy_readb(base_addr+(CyMSVR1<<index)), cy_readb(base_addr + (CyMSVR1 << index)),
cy_readb(base_addr+(CyMSVR2<<index))); cy_readb(base_addr + (CyMSVR2 << index)));
#endif #endif
} }
if (info->tty){ if (info->tty) {
clear_bit(TTY_IO_ERROR, &info->tty->flags); clear_bit(TTY_IO_ERROR, &info->tty->flags);
} }
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
...@@ -3283,15 +3365,16 @@ set_line_char(struct cyclades_port * info) ...@@ -3283,15 +3365,16 @@ set_line_char(struct cyclades_port * info)
return; return;
} }
zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); zfw_ctrl = cy_card[card].base_addr +
(cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
board_ctrl = &zfw_ctrl->board_ctrl; board_ctrl = &zfw_ctrl->board_ctrl;
ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]); ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
buf_ctrl = &zfw_ctrl->buf_ctrl[channel]; buf_ctrl = &zfw_ctrl->buf_ctrl[channel];
/* baud rate */ /* baud rate */
baud = tty_get_baud_rate(info->tty); baud = tty_get_baud_rate(info->tty);
if ((baud == 38400) && if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) { ASYNC_SPD_CUST) {
if (info->custom_divisor) if (info->custom_divisor)
baud_rate = info->baud / info->custom_divisor; baud_rate = info->baud / info->custom_divisor;
else else
...@@ -3299,60 +3382,73 @@ set_line_char(struct cyclades_port * info) ...@@ -3299,60 +3382,73 @@ set_line_char(struct cyclades_port * info)
} else if (baud > CYZ_MAX_SPEED) { } else if (baud > CYZ_MAX_SPEED) {
baud = CYZ_MAX_SPEED; baud = CYZ_MAX_SPEED;
} }
cy_writel(&ch_ctrl->comm_baud , baud); cy_writel(&ch_ctrl->comm_baud, baud);
if (baud == 134) { if (baud == 134) {
/* get it right for 134.5 baud */ /* get it right for 134.5 baud */
info->timeout = (info->xmit_fifo_size*HZ*30/269) + 2; info->timeout = (info->xmit_fifo_size * HZ * 30 / 269) +
} else if ((baud == 38400) && 2;
((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) { } else if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
info->timeout = (info->xmit_fifo_size*HZ*15/baud_rate) + 2; ASYNC_SPD_CUST) {
info->timeout = (info->xmit_fifo_size * HZ * 15 /
baud_rate) + 2;
} else if (baud) { } else if (baud) {
info->timeout = (info->xmit_fifo_size*HZ*15/baud) + 2; info->timeout = (info->xmit_fifo_size * HZ * 15 /
baud) + 2;
/* this needs to be propagated into the card info */ /* this needs to be propagated into the card info */
} else { } else {
info->timeout = 0; info->timeout = 0;
} }
/* byte size and parity */ /* byte size and parity */
switch(cflag & CSIZE){ switch (cflag & CSIZE) {
case CS5: cy_writel(&ch_ctrl->comm_data_l , C_DL_CS5); break; case CS5:
case CS6: cy_writel(&ch_ctrl->comm_data_l , C_DL_CS6); break; cy_writel(&ch_ctrl->comm_data_l, C_DL_CS5);
case CS7: cy_writel(&ch_ctrl->comm_data_l , C_DL_CS7); break; break;
case CS8: cy_writel(&ch_ctrl->comm_data_l , C_DL_CS8); break; case CS6:
cy_writel(&ch_ctrl->comm_data_l, C_DL_CS6);
break;
case CS7:
cy_writel(&ch_ctrl->comm_data_l, C_DL_CS7);
break;
case CS8:
cy_writel(&ch_ctrl->comm_data_l, C_DL_CS8);
break;
} }
if(cflag & CSTOPB){ if (cflag & CSTOPB) {
cy_writel(&ch_ctrl->comm_data_l, cy_writel(&ch_ctrl->comm_data_l,
cy_readl(&ch_ctrl->comm_data_l) | C_DL_2STOP); cy_readl(&ch_ctrl->comm_data_l) | C_DL_2STOP);
}else{ } else {
cy_writel(&ch_ctrl->comm_data_l, cy_writel(&ch_ctrl->comm_data_l,
cy_readl(&ch_ctrl->comm_data_l) | C_DL_1STOP); cy_readl(&ch_ctrl->comm_data_l) | C_DL_1STOP);
} }
if (cflag & PARENB){ if (cflag & PARENB) {
if (cflag & PARODD){ if (cflag & PARODD) {
cy_writel(&ch_ctrl->comm_parity , C_PR_ODD); cy_writel(&ch_ctrl->comm_parity, C_PR_ODD);
}else{ } else {
cy_writel(&ch_ctrl->comm_parity , C_PR_EVEN); cy_writel(&ch_ctrl->comm_parity, C_PR_EVEN);
} }
}else{ } else {
cy_writel(&ch_ctrl->comm_parity , C_PR_NONE); cy_writel(&ch_ctrl->comm_parity, C_PR_NONE);
} }
/* CTS flow control flag */ /* CTS flow control flag */
if (cflag & CRTSCTS){ if (cflag & CRTSCTS) {
cy_writel(&ch_ctrl->hw_flow, cy_writel(&ch_ctrl->hw_flow,
cy_readl(&ch_ctrl->hw_flow) | C_RS_CTS | C_RS_RTS); cy_readl(&ch_ctrl->
}else{ hw_flow) | C_RS_CTS | C_RS_RTS);
} else {
cy_writel(&ch_ctrl->hw_flow, cy_writel(&ch_ctrl->hw_flow,
cy_readl(&ch_ctrl->hw_flow) & ~(C_RS_CTS | C_RS_RTS)); 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 /* As the HW flow control is done in firmware, the driver
need to care about it */ doesn't need to care about it */
info->flags &= ~ASYNC_CTS_FLOW; info->flags &= ~ASYNC_CTS_FLOW;
/* XON/XOFF/XANY flow control flags */ /* XON/XOFF/XANY flow control flags */
sw_flow = 0; sw_flow = 0;
if (iflag & IXON){ if (iflag & IXON) {
sw_flow |= C_FL_OXX; sw_flow |= C_FL_OXX;
if (iflag & IXANY) if (iflag & IXANY)
sw_flow |= C_FL_OIXANY; sw_flow |= C_FL_OIXANY;
...@@ -3360,25 +3456,25 @@ set_line_char(struct cyclades_port * info) ...@@ -3360,25 +3456,25 @@ set_line_char(struct cyclades_port * info)
cy_writel(&ch_ctrl->sw_flow, sw_flow); cy_writel(&ch_ctrl->sw_flow, sw_flow);
retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_IOCTL, 0L); retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_IOCTL, 0L);
if (retval != 0){ if (retval != 0) {
printk("cyc:set_line_char retval on ttyC%d was %x\n", printk("cyc:set_line_char retval on ttyC%d was %x\n",
info->line, retval); info->line, retval);
} }
/* CD sensitivity */ /* CD sensitivity */
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;
} }
if(baud == 0){ /* baud rate is zero, turn off line */ if (baud == 0) { /* baud rate is zero, turn off line */
cy_writel(&ch_ctrl->rs_control, cy_writel(&ch_ctrl->rs_control,
cy_readl(&ch_ctrl->rs_control) & ~C_RS_DTR); cy_readl(&ch_ctrl->rs_control) & ~C_RS_DTR);
#ifdef CY_DEBUG_DTR #ifdef CY_DEBUG_DTR
printk("cyc:set_line_char dropping Z DTR\n"); printk("cyc:set_line_char dropping Z DTR\n");
#endif #endif
}else{ } else {
cy_writel(&ch_ctrl->rs_control, cy_writel(&ch_ctrl->rs_control,
cy_readl(&ch_ctrl->rs_control) | C_RS_DTR); cy_readl(&ch_ctrl->rs_control) | C_RS_DTR);
#ifdef CY_DEBUG_DTR #ifdef CY_DEBUG_DTR
...@@ -3386,21 +3482,20 @@ set_line_char(struct cyclades_port * info) ...@@ -3386,21 +3482,20 @@ set_line_char(struct cyclades_port * info)
#endif #endif
} }
retval = cyz_issue_cmd( &cy_card[card], channel, C_CM_IOCTLM, 0L); retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_IOCTLM,0L);
if (retval != 0){ if (retval != 0) {
printk("cyc:set_line_char(2) retval on ttyC%d was %x\n", printk("cyc:set_line_char(2) retval on ttyC%d was %x\n",
info->line, retval); info->line, retval);
} }
if (info->tty){ if (info->tty) {
clear_bit(TTY_IO_ERROR, &info->tty->flags); clear_bit(TTY_IO_ERROR, &info->tty->flags);
} }
} }
} /* set_line_char */ } /* set_line_char */
static int static int
get_serial_info(struct cyclades_port * info, get_serial_info(struct cyclades_port *info,
struct serial_struct __user * retinfo) struct serial_struct __user * retinfo)
{ {
struct serial_struct tmp; struct serial_struct tmp;
...@@ -3417,36 +3512,35 @@ get_serial_info(struct cyclades_port * info, ...@@ -3417,36 +3512,35 @@ get_serial_info(struct cyclades_port * info,
tmp.close_delay = info->close_delay; tmp.close_delay = info->close_delay;
tmp.baud_base = info->baud; tmp.baud_base = info->baud;
tmp.custom_divisor = info->custom_divisor; tmp.custom_divisor = info->custom_divisor;
tmp.hub6 = 0; /*!!!*/ tmp.hub6 = 0; /*!!! */
return copy_to_user(retinfo,&tmp,sizeof(*retinfo))?-EFAULT:0; return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
} /* get_serial_info */ } /* get_serial_info */
static int static int
set_serial_info(struct cyclades_port * info, set_serial_info(struct cyclades_port *info,
struct serial_struct __user * new_info) struct serial_struct __user * new_info)
{ {
struct serial_struct new_serial; struct serial_struct new_serial;
struct cyclades_port old_info; struct cyclades_port old_info;
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;
old_info = *info; old_info = *info;
if (!capable(CAP_SYS_ADMIN)) { if (!capable(CAP_SYS_ADMIN)) {
if ((new_serial.close_delay != info->close_delay) || if (new_serial.close_delay != info->close_delay ||
(new_serial.baud_base != info->baud) || new_serial.baud_base != info->baud ||
((new_serial.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK) != (new_serial.flags & ASYNC_FLAGS &
(info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK))) ~ASYNC_USR_MASK) !=
(info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK))
return -EPERM; return -EPERM;
info->flags = ((info->flags & ~ASYNC_USR_MASK) | info->flags = (info->flags & ~ASYNC_USR_MASK) |
(new_serial.flags & ASYNC_USR_MASK)); (new_serial.flags & ASYNC_USR_MASK);
info->baud = new_serial.baud_base; info->baud = new_serial.baud_base;
info->custom_divisor = new_serial.custom_divisor; info->custom_divisor = new_serial.custom_divisor;
goto check_and_exit; goto check_and_exit;
} }
/* /*
* OK, past this point, all the error checking has been done. * OK, past this point, all the error checking has been done.
* At this point, we start making changes..... * At this point, we start making changes.....
...@@ -3454,16 +3548,16 @@ set_serial_info(struct cyclades_port * info, ...@@ -3454,16 +3548,16 @@ set_serial_info(struct cyclades_port * info,
info->baud = new_serial.baud_base; info->baud = new_serial.baud_base;
info->custom_divisor = new_serial.custom_divisor; info->custom_divisor = new_serial.custom_divisor;
info->flags = ((info->flags & ~ASYNC_FLAGS) | info->flags = (info->flags & ~ASYNC_FLAGS) |
(new_serial.flags & ASYNC_FLAGS)); (new_serial.flags & ASYNC_FLAGS);
info->close_delay = new_serial.close_delay * HZ/100; info->close_delay = new_serial.close_delay * HZ / 100;
info->closing_wait = new_serial.closing_wait * HZ/100; info->closing_wait = new_serial.closing_wait * HZ / 100;
check_and_exit: check_and_exit:
if (info->flags & ASYNC_INITIALIZED){ if (info->flags & ASYNC_INITIALIZED) {
set_line_char(info); set_line_char(info);
return 0; return 0;
}else{ } else {
return startup(info); return startup(info);
} }
} /* set_serial_info */ } /* set_serial_info */
...@@ -3478,7 +3572,7 @@ set_serial_info(struct cyclades_port * info, ...@@ -3478,7 +3572,7 @@ set_serial_info(struct cyclades_port * info,
* 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 get_lsr_info(struct cyclades_port *info, unsigned int __user *value) static int get_lsr_info(struct cyclades_port *info, unsigned int __user * value)
{ {
int card, chip, channel, index; int card, chip, channel, index;
unsigned char status; unsigned char status;
...@@ -3489,27 +3583,28 @@ static int get_lsr_info(struct cyclades_port *info, unsigned int __user *value) ...@@ -3489,27 +3583,28 @@ static int get_lsr_info(struct cyclades_port *info, unsigned int __user *value)
card = info->card; card = info->card;
channel = (info->line) - (cy_card[card].first_line); channel = (info->line) - (cy_card[card].first_line);
if (!IS_CYC_Z(cy_card[card])) { if (!IS_CYC_Z(cy_card[card])) {
chip = channel>>2; chip = channel >> 2;
channel &= 0x03; channel &= 0x03;
index = cy_card[card].bus_index; index = cy_card[card].bus_index;
base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); base_addr =
cy_card[card].base_addr + (cy_chip_offset[chip] << index);
CY_LOCK(info, flags); CY_LOCK(info, flags);
status = cy_readb(base_addr+(CySRER<<index)) & (CyTxRdy|CyTxMpty); status = cy_readb(base_addr + (CySRER << index)) &
(CyTxRdy | CyTxMpty);
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
result = (status ? 0 : TIOCSER_TEMT); result = (status ? 0 : TIOCSER_TEMT);
} else { } else {
/* Not supported yet */ /* Not supported yet */
return -EINVAL; return -EINVAL;
} }
return put_user(result, (unsigned long __user *) value); return put_user(result, (unsigned long __user *)value);
} }
static int static int cy_tiocmget(struct tty_struct *tty, struct file *file)
cy_tiocmget(struct tty_struct *tty, struct file *file)
{ {
struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
int card,chip,channel,index; int card, chip, channel, index;
void __iomem *base_addr; void __iomem *base_addr;
unsigned long flags; unsigned long flags;
unsigned char status; unsigned char status;
...@@ -3526,48 +3621,50 @@ cy_tiocmget(struct tty_struct *tty, struct file *file) ...@@ -3526,48 +3621,50 @@ cy_tiocmget(struct tty_struct *tty, struct file *file)
card = info->card; card = info->card;
channel = (info->line) - (cy_card[card].first_line); channel = (info->line) - (cy_card[card].first_line);
if (!IS_CYC_Z(cy_card[card])) { if (!IS_CYC_Z(cy_card[card])) {
chip = channel>>2; chip = channel >> 2;
channel &= 0x03; channel &= 0x03;
index = cy_card[card].bus_index; index = cy_card[card].bus_index;
base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); base_addr =
cy_card[card].base_addr + (cy_chip_offset[chip] << index);
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
status = cy_readb(base_addr+(CyMSVR1<<index)); status = cy_readb(base_addr + (CyMSVR1 << index));
status |= cy_readb(base_addr+(CyMSVR2<<index)); status |= cy_readb(base_addr + (CyMSVR2 << index));
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
if (info->rtsdtr_inv) { if (info->rtsdtr_inv) {
result = ((status & CyRTS) ? TIOCM_DTR : 0) result = ((status & CyRTS) ? TIOCM_DTR : 0) |
| ((status & CyDTR) ? TIOCM_RTS : 0); ((status & CyDTR) ? TIOCM_RTS : 0);
} else { } else {
result = ((status & CyRTS) ? TIOCM_RTS : 0) result = ((status & CyRTS) ? TIOCM_RTS : 0) |
| ((status & CyDTR) ? TIOCM_DTR : 0); ((status & CyDTR) ? TIOCM_DTR : 0);
} }
result |= ((status & CyDCD) ? TIOCM_CAR : 0) result |= ((status & CyDCD) ? TIOCM_CAR : 0) |
| ((status & CyRI) ? TIOCM_RNG : 0) ((status & CyRI) ? TIOCM_RNG : 0) |
| ((status & CyDSR) ? TIOCM_DSR : 0) ((status & CyDSR) ? TIOCM_DSR : 0) |
| ((status & CyCTS) ? TIOCM_CTS : 0); ((status & CyCTS) ? TIOCM_CTS : 0);
} else { } else {
base_addr = cy_card[card].base_addr; base_addr = cy_card[card].base_addr;
if (cy_card[card].num_chips != -1){ if (cy_card[card].num_chips != -1) {
return -EINVAL; return -EINVAL;
} }
firm_id = cy_card[card].base_addr + ID_ADDRESS; firm_id = cy_card[card].base_addr + ID_ADDRESS;
if (ISZLOADED(cy_card[card])) { if (ISZLOADED(cy_card[card])) {
zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); zfw_ctrl = cy_card[card].base_addr +
(cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
board_ctrl = &zfw_ctrl->board_ctrl; board_ctrl = &zfw_ctrl->board_ctrl;
ch_ctrl = zfw_ctrl->ch_ctrl; ch_ctrl = zfw_ctrl->ch_ctrl;
lstatus = cy_readl(&ch_ctrl[channel].rs_status); lstatus = cy_readl(&ch_ctrl[channel].rs_status);
result = ((lstatus & C_RS_RTS) ? TIOCM_RTS : 0) result = ((lstatus & C_RS_RTS) ? TIOCM_RTS : 0) |
| ((lstatus & C_RS_DTR) ? TIOCM_DTR : 0) ((lstatus & C_RS_DTR) ? TIOCM_DTR : 0) |
| ((lstatus & C_RS_DCD) ? TIOCM_CAR : 0) ((lstatus & C_RS_DCD) ? TIOCM_CAR : 0) |
| ((lstatus & C_RS_RI) ? TIOCM_RNG : 0) ((lstatus & C_RS_RI) ? TIOCM_RNG : 0) |
| ((lstatus & C_RS_DSR) ? TIOCM_DSR : 0) ((lstatus & C_RS_DSR) ? TIOCM_DSR : 0) |
| ((lstatus & C_RS_CTS) ? TIOCM_CTS : 0); ((lstatus & C_RS_CTS) ? TIOCM_CTS : 0);
}else{ } else {
result = 0; result = 0;
return -ENODEV; return -ENODEV;
} }
...@@ -3576,13 +3673,12 @@ cy_tiocmget(struct tty_struct *tty, struct file *file) ...@@ -3576,13 +3673,12 @@ cy_tiocmget(struct tty_struct *tty, struct file *file)
return result; return result;
} /* cy_tiomget */ } /* cy_tiomget */
static int static int
cy_tiocmset(struct tty_struct *tty, struct file *file, cy_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear) unsigned int set, unsigned int clear)
{ {
struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
int card,chip,channel,index; int card, chip, channel, index;
void __iomem *base_addr; void __iomem *base_addr;
unsigned long flags; unsigned long flags;
struct FIRM_ID __iomem *firm_id; struct FIRM_ID __iomem *firm_id;
...@@ -3597,61 +3693,74 @@ cy_tiocmset(struct tty_struct *tty, struct file *file, ...@@ -3597,61 +3693,74 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
card = info->card; card = info->card;
channel = (info->line) - (cy_card[card].first_line); channel = (info->line) - (cy_card[card].first_line);
if (!IS_CYC_Z(cy_card[card])) { if (!IS_CYC_Z(cy_card[card])) {
chip = channel>>2; chip = channel >> 2;
channel &= 0x03; channel &= 0x03;
index = cy_card[card].bus_index; index = cy_card[card].bus_index;
base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); base_addr =
cy_card[card].base_addr + (cy_chip_offset[chip] << index);
if (set & TIOCM_RTS){ if (set & TIOCM_RTS) {
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); cy_writeb(base_addr + (CyCAR << index),
(u_char) channel);
if (info->rtsdtr_inv) { if (info->rtsdtr_inv) {
cy_writeb(base_addr+(CyMSVR2<<index), CyDTR); cy_writeb(base_addr + (CyMSVR2 << index),
CyDTR);
} else { } else {
cy_writeb(base_addr+(CyMSVR1<<index), CyRTS); cy_writeb(base_addr + (CyMSVR1 << index),
CyRTS);
} }
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
} }
if (clear & TIOCM_RTS) { if (clear & TIOCM_RTS) {
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); cy_writeb(base_addr + (CyCAR << index),
(u_char) channel);
if (info->rtsdtr_inv) { if (info->rtsdtr_inv) {
cy_writeb(base_addr+(CyMSVR2<<index), ~CyDTR); cy_writeb(base_addr + (CyMSVR2 << index),
~CyDTR);
} else { } else {
cy_writeb(base_addr+(CyMSVR1<<index), ~CyRTS); cy_writeb(base_addr + (CyMSVR1 << index),
~CyRTS);
} }
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
} }
if (set & TIOCM_DTR){ if (set & TIOCM_DTR) {
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); cy_writeb(base_addr + (CyCAR << index),
(u_char) channel);
if (info->rtsdtr_inv) { if (info->rtsdtr_inv) {
cy_writeb(base_addr+(CyMSVR1<<index), CyRTS); cy_writeb(base_addr + (CyMSVR1 << index),
CyRTS);
} else { } else {
cy_writeb(base_addr+(CyMSVR2<<index), CyDTR); cy_writeb(base_addr + (CyMSVR2 << index),
CyDTR);
} }
#ifdef CY_DEBUG_DTR #ifdef CY_DEBUG_DTR
printk("cyc:set_modem_info raising DTR\n"); printk("cyc:set_modem_info raising DTR\n");
printk(" status: 0x%x, 0x%x\n", printk(" status: 0x%x, 0x%x\n",
cy_readb(base_addr+(CyMSVR1<<index)), cy_readb(base_addr + (CyMSVR1 << index)),
cy_readb(base_addr+(CyMSVR2<<index))); cy_readb(base_addr + (CyMSVR2 << index)));
#endif #endif
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
} }
if (clear & TIOCM_DTR) { if (clear & TIOCM_DTR) {
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); cy_writeb(base_addr + (CyCAR << index),
(u_char) channel);
if (info->rtsdtr_inv) { if (info->rtsdtr_inv) {
cy_writeb(base_addr+(CyMSVR1<<index), ~CyRTS); cy_writeb(base_addr + (CyMSVR1 << index),
~CyRTS);
} else { } else {
cy_writeb(base_addr+(CyMSVR2<<index), ~CyDTR); cy_writeb(base_addr + (CyMSVR2 << index),
~CyDTR);
} }
#ifdef CY_DEBUG_DTR #ifdef CY_DEBUG_DTR
printk("cyc:set_modem_info dropping DTR\n"); printk("cyc:set_modem_info dropping DTR\n");
printk(" status: 0x%x, 0x%x\n", printk(" status: 0x%x, 0x%x\n",
cy_readb(base_addr+(CyMSVR1<<index)), cy_readb(base_addr + (CyMSVR1 << index)),
cy_readb(base_addr+(CyMSVR2<<index))); cy_readb(base_addr + (CyMSVR2 << index)));
#endif #endif
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
} }
...@@ -3660,26 +3769,30 @@ cy_tiocmset(struct tty_struct *tty, struct file *file, ...@@ -3660,26 +3769,30 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
firm_id = cy_card[card].base_addr + ID_ADDRESS; firm_id = cy_card[card].base_addr + ID_ADDRESS;
if (ISZLOADED(cy_card[card])) { if (ISZLOADED(cy_card[card])) {
zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); zfw_ctrl = cy_card[card].base_addr +
(cy_readl(&firm_id->zfwctrl_addr) & 0xfffff);
board_ctrl = &zfw_ctrl->board_ctrl; board_ctrl = &zfw_ctrl->board_ctrl;
ch_ctrl = zfw_ctrl->ch_ctrl; ch_ctrl = zfw_ctrl->ch_ctrl;
if (set & TIOCM_RTS){ if (set & TIOCM_RTS) {
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writel(&ch_ctrl[channel].rs_control, cy_writel(&ch_ctrl[channel].rs_control,
cy_readl(&ch_ctrl[channel].rs_control) | C_RS_RTS); cy_readl(&ch_ctrl[channel].
rs_control) | C_RS_RTS);
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
} }
if (clear & TIOCM_RTS) { if (clear & TIOCM_RTS) {
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writel(&ch_ctrl[channel].rs_control, cy_writel(&ch_ctrl[channel].rs_control,
cy_readl(&ch_ctrl[channel].rs_control) & ~C_RS_RTS); cy_readl(&ch_ctrl[channel].
rs_control) & ~C_RS_RTS);
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
} }
if (set & TIOCM_DTR){ if (set & TIOCM_DTR) {
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writel(&ch_ctrl[channel].rs_control, cy_writel(&ch_ctrl[channel].rs_control,
cy_readl(&ch_ctrl[channel].rs_control) | C_RS_DTR); cy_readl(&ch_ctrl[channel].
rs_control) | C_RS_DTR);
#ifdef CY_DEBUG_DTR #ifdef CY_DEBUG_DTR
printk("cyc:set_modem_info raising Z DTR\n"); printk("cyc:set_modem_info raising Z DTR\n");
#endif #endif
...@@ -3688,19 +3801,20 @@ cy_tiocmset(struct tty_struct *tty, struct file *file, ...@@ -3688,19 +3801,20 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
if (clear & TIOCM_DTR) { if (clear & TIOCM_DTR) {
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writel(&ch_ctrl[channel].rs_control, cy_writel(&ch_ctrl[channel].rs_control,
cy_readl(&ch_ctrl[channel].rs_control) & ~C_RS_DTR); cy_readl(&ch_ctrl[channel].
rs_control) & ~C_RS_DTR);
#ifdef CY_DEBUG_DTR #ifdef CY_DEBUG_DTR
printk("cyc:set_modem_info clearing Z DTR\n"); printk("cyc:set_modem_info clearing Z DTR\n");
#endif #endif
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
} }
}else{ } else {
return -ENODEV; return -ENODEV;
} }
CY_LOCK(info, flags); CY_LOCK(info, flags);
retval = cyz_issue_cmd(&cy_card[info->card], retval = cyz_issue_cmd(&cy_card[info->card],
channel, C_CM_IOCTLM,0L); channel, C_CM_IOCTLM, 0L);
if (retval != 0){ if (retval != 0) {
printk("cyc:set_modem_info retval on ttyC%d was %x\n", printk("cyc:set_modem_info retval on ttyC%d was %x\n",
info->line, retval); info->line, retval);
} }
...@@ -3712,10 +3826,9 @@ cy_tiocmset(struct tty_struct *tty, struct file *file, ...@@ -3712,10 +3826,9 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
/* /*
* cy_break() --- routine which turns the break handling on or off * cy_break() --- routine which turns the break handling on or off
*/ */
static void static void cy_break(struct tty_struct *tty, int break_state)
cy_break(struct tty_struct *tty, int break_state)
{ {
struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
unsigned long flags; unsigned long flags;
if (serial_paranoia_check(info, tty->name, "cy_break")) if (serial_paranoia_check(info, tty->name, "cy_break"))
...@@ -3750,19 +3863,19 @@ cy_break(struct tty_struct *tty, int break_state) ...@@ -3750,19 +3863,19 @@ cy_break(struct tty_struct *tty, int break_state)
if (break_state == -1) { if (break_state == -1) {
retval = cyz_issue_cmd(&cy_card[info->card], retval = cyz_issue_cmd(&cy_card[info->card],
(info->line) - (cy_card[info->card].first_line), info->line - cy_card[info->card].first_line,
C_CM_SET_BREAK, 0L); C_CM_SET_BREAK, 0L);
if (retval != 0) { if (retval != 0) {
printk("cyc:cy_break (set) retval on ttyC%d was %x\n", printk("cyc:cy_break (set) retval on ttyC%d "
info->line, retval); "was %x\n", info->line, retval);
} }
} else { } else {
retval = cyz_issue_cmd(&cy_card[info->card], retval = cyz_issue_cmd(&cy_card[info->card],
(info->line) - (cy_card[info->card].first_line), info->line - cy_card[info->card].first_line,
C_CM_CLR_BREAK, 0L); C_CM_CLR_BREAK, 0L);
if (retval != 0) { if (retval != 0) {
printk("cyc:cy_break (clr) retval on ttyC%d was %x\n", printk("cyc:cy_break (clr) retval on ttyC%d "
info->line, retval); "was %x\n", info->line, retval);
} }
} }
} }
...@@ -3770,149 +3883,141 @@ cy_break(struct tty_struct *tty, int break_state) ...@@ -3770,149 +3883,141 @@ cy_break(struct tty_struct *tty, int break_state)
} /* cy_break */ } /* cy_break */
static int static int
get_mon_info(struct cyclades_port * info, struct cyclades_monitor __user * mon) get_mon_info(struct cyclades_port *info, struct cyclades_monitor __user * mon)
{ {
if(copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor))) if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor)))
return -EFAULT; return -EFAULT;
info->mon.int_count = 0; info->mon.int_count = 0;
info->mon.char_count = 0; info->mon.char_count = 0;
info->mon.char_max = 0; info->mon.char_max = 0;
info->mon.char_last = 0; info->mon.char_last = 0;
return 0; return 0;
}/* get_mon_info */ } /* get_mon_info */
static int set_threshold(struct cyclades_port *info, unsigned long value)
static int
set_threshold(struct cyclades_port * info, unsigned long value)
{ {
void __iomem *base_addr; void __iomem *base_addr;
int card,channel,chip,index; int card, channel, chip, index;
unsigned long flags; unsigned long flags;
card = info->card; card = info->card;
channel = info->line - cy_card[card].first_line; channel = info->line - cy_card[card].first_line;
if (!IS_CYC_Z(cy_card[card])) { if (!IS_CYC_Z(cy_card[card])) {
chip = channel>>2; chip = channel >> 2;
channel &= 0x03; channel &= 0x03;
index = cy_card[card].bus_index; index = cy_card[card].bus_index;
base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); base_addr =
cy_card[card].base_addr + (cy_chip_offset[chip] << index);
info->cor3 &= ~CyREC_FIFO; info->cor3 &= ~CyREC_FIFO;
info->cor3 |= value & CyREC_FIFO; info->cor3 |= value & CyREC_FIFO;
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writeb(base_addr+(CyCOR3<<index), info->cor3); cy_writeb(base_addr + (CyCOR3 << index), info->cor3);
cyy_issue_cmd(base_addr,CyCOR_CHANGE|CyCOR3ch,index); cyy_issue_cmd(base_addr, CyCOR_CHANGE | CyCOR3ch, index);
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
} else { } else {
// Nothing to do! // Nothing to do!
} }
return 0; return 0;
}/* set_threshold */ } /* set_threshold */
static int static int
get_threshold(struct cyclades_port * info, unsigned long __user *value) get_threshold(struct cyclades_port *info, unsigned long __user * value)
{ {
void __iomem *base_addr; void __iomem *base_addr;
int card,channel,chip,index; int card, channel, chip, index;
unsigned long tmp; unsigned long tmp;
card = info->card; card = info->card;
channel = info->line - cy_card[card].first_line; channel = info->line - cy_card[card].first_line;
if (!IS_CYC_Z(cy_card[card])) { if (!IS_CYC_Z(cy_card[card])) {
chip = channel>>2; chip = channel >> 2;
channel &= 0x03; channel &= 0x03;
index = cy_card[card].bus_index; index = cy_card[card].bus_index;
base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); base_addr =
cy_card[card].base_addr + (cy_chip_offset[chip] << index);
tmp = cy_readb(base_addr+(CyCOR3<<index)) & CyREC_FIFO; tmp = cy_readb(base_addr + (CyCOR3 << index)) & CyREC_FIFO;
return put_user(tmp,value); return put_user(tmp, value);
} else { } else {
// Nothing to do! // Nothing to do!
return 0; return 0;
} }
}/* get_threshold */ } /* get_threshold */
static int static int
set_default_threshold(struct cyclades_port * info, unsigned long value) set_default_threshold(struct cyclades_port *info, unsigned long value)
{ {
info->default_threshold = value & 0x0f; info->default_threshold = value & 0x0f;
return 0; return 0;
}/* set_default_threshold */ } /* set_default_threshold */
static int static int
get_default_threshold(struct cyclades_port * info, unsigned long __user *value) get_default_threshold(struct cyclades_port *info, unsigned long __user * value)
{ {
return put_user(info->default_threshold,value); return put_user(info->default_threshold, value);
}/* get_default_threshold */ } /* get_default_threshold */
static int static int set_timeout(struct cyclades_port *info, unsigned long value)
set_timeout(struct cyclades_port * info, unsigned long value)
{ {
void __iomem *base_addr; void __iomem *base_addr;
int card,channel,chip,index; int card, channel, chip, index;
unsigned long flags; unsigned long flags;
card = info->card; card = info->card;
channel = info->line - cy_card[card].first_line; channel = info->line - cy_card[card].first_line;
if (!IS_CYC_Z(cy_card[card])) { if (!IS_CYC_Z(cy_card[card])) {
chip = channel>>2; chip = channel >> 2;
channel &= 0x03; channel &= 0x03;
index = cy_card[card].bus_index; index = cy_card[card].bus_index;
base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); base_addr =
cy_card[card].base_addr + (cy_chip_offset[chip] << index);
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writeb(base_addr+(CyRTPR<<index), value & 0xff); cy_writeb(base_addr + (CyRTPR << index), value & 0xff);
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
} else { } else {
// Nothing to do! // Nothing to do!
} }
return 0; return 0;
}/* set_timeout */ } /* set_timeout */
static int static int get_timeout(struct cyclades_port *info, unsigned long __user * value)
get_timeout(struct cyclades_port * info, unsigned long __user *value)
{ {
void __iomem *base_addr; void __iomem *base_addr;
int card,channel,chip,index; int card, channel, chip, index;
unsigned long tmp; unsigned long tmp;
card = info->card; card = info->card;
channel = info->line - cy_card[card].first_line; channel = info->line - cy_card[card].first_line;
if (!IS_CYC_Z(cy_card[card])) { if (!IS_CYC_Z(cy_card[card])) {
chip = channel>>2; chip = channel >> 2;
channel &= 0x03; channel &= 0x03;
index = cy_card[card].bus_index; index = cy_card[card].bus_index;
base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); base_addr =
cy_card[card].base_addr + (cy_chip_offset[chip] << index);
tmp = cy_readb(base_addr+(CyRTPR<<index)); tmp = cy_readb(base_addr + (CyRTPR << index));
return put_user(tmp,value); return put_user(tmp, value);
} else { } else {
// Nothing to do! // Nothing to do!
return 0; return 0;
} }
}/* get_timeout */ } /* get_timeout */
static int static int set_default_timeout(struct cyclades_port *info, unsigned long value)
set_default_timeout(struct cyclades_port * info, unsigned long value)
{ {
info->default_timeout = value & 0xff; info->default_timeout = value & 0xff;
return 0; return 0;
}/* set_default_timeout */ } /* set_default_timeout */
static int static int
get_default_timeout(struct cyclades_port * info, unsigned long __user *value) get_default_timeout(struct cyclades_port *info, unsigned long __user * value)
{ {
return put_user(info->default_timeout,value); return put_user(info->default_timeout, value);
}/* get_default_timeout */ } /* get_default_timeout */
/* /*
* This routine allows the tty driver to implement device- * This routine allows the tty driver to implement device-
...@@ -3920,10 +4025,10 @@ get_default_timeout(struct cyclades_port * info, unsigned long __user *value) ...@@ -3920,10 +4025,10 @@ get_default_timeout(struct cyclades_port * info, unsigned long __user *value)
* not recognized by the driver, it should return ENOIOCTLCMD. * not recognized by the driver, it should return ENOIOCTLCMD.
*/ */
static int static int
cy_ioctl(struct tty_struct *tty, struct file * file, cy_ioctl(struct tty_struct *tty, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
struct cyclades_icount cprev, cnow; /* kernel counter temps */ struct cyclades_icount cprev, cnow; /* kernel counter temps */
struct serial_icounter_struct __user *p_cuser; /* user space */ struct serial_icounter_struct __user *p_cuser; /* user space */
int ret_val = 0; int ret_val = 0;
...@@ -3934,8 +4039,7 @@ cy_ioctl(struct tty_struct *tty, struct file * file, ...@@ -3934,8 +4039,7 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
return -ENODEV; return -ENODEV;
#ifdef CY_DEBUG_OTHER #ifdef CY_DEBUG_OTHER
printk("cyc:cy_ioctl ttyC%d, cmd = %x arg = %lx\n", printk("cyc:cy_ioctl ttyC%d, cmd = %x arg = %lx\n", info->line, cmd, arg); /* */
info->line, cmd, arg); /* */
#endif #endif
switch (cmd) { switch (cmd) {
...@@ -3982,7 +4086,7 @@ cy_ioctl(struct tty_struct *tty, struct file * file, ...@@ -3982,7 +4086,7 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
break; break;
case CYGETCARDINFO: case CYGETCARDINFO:
if (copy_to_user(argp, &cy_card[info->card], if (copy_to_user(argp, &cy_card[info->card],
sizeof (struct cyclades_card))) { sizeof(struct cyclades_card))) {
ret_val = -EFAULT; ret_val = -EFAULT;
break; break;
} }
...@@ -4001,11 +4105,11 @@ cy_ioctl(struct tty_struct *tty, struct file * file, ...@@ -4001,11 +4105,11 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
break; break;
#endif /* CONFIG_CYZ_INTR */ #endif /* CONFIG_CYZ_INTR */
case CYSETWAIT: case CYSETWAIT:
info->closing_wait = (unsigned short)arg * HZ/100; info->closing_wait = (unsigned short)arg *HZ / 100;
ret_val = 0; ret_val = 0;
break; break;
case CYGETWAIT: case CYGETWAIT:
ret_val = info->closing_wait / (HZ/100); ret_val = info->closing_wait / (HZ / 100);
break; break;
case TIOCGSERIAL: case TIOCGSERIAL:
ret_val = get_serial_info(info, argp); ret_val = get_serial_info(info, argp);
...@@ -4042,10 +4146,10 @@ cy_ioctl(struct tty_struct *tty, struct file * file, ...@@ -4042,10 +4146,10 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) { cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) {
return -EIO; /* no change => error */ return -EIO; /* no change => error */
} }
if ( ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) { ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) {
return 0; return 0;
} }
cprev = cnow; cprev = cnow;
...@@ -4064,27 +4168,38 @@ cy_ioctl(struct tty_struct *tty, struct file * file, ...@@ -4064,27 +4168,38 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
p_cuser = argp; p_cuser = argp;
ret_val = put_user(cnow.cts, &p_cuser->cts); ret_val = put_user(cnow.cts, &p_cuser->cts);
if (ret_val) return ret_val; if (ret_val)
return ret_val;
ret_val = put_user(cnow.dsr, &p_cuser->dsr); ret_val = put_user(cnow.dsr, &p_cuser->dsr);
if (ret_val) return ret_val; if (ret_val)
return ret_val;
ret_val = put_user(cnow.rng, &p_cuser->rng); ret_val = put_user(cnow.rng, &p_cuser->rng);
if (ret_val) return ret_val; if (ret_val)
return ret_val;
ret_val = put_user(cnow.dcd, &p_cuser->dcd); ret_val = put_user(cnow.dcd, &p_cuser->dcd);
if (ret_val) return ret_val; if (ret_val)
return ret_val;
ret_val = put_user(cnow.rx, &p_cuser->rx); ret_val = put_user(cnow.rx, &p_cuser->rx);
if (ret_val) return ret_val; if (ret_val)
return ret_val;
ret_val = put_user(cnow.tx, &p_cuser->tx); ret_val = put_user(cnow.tx, &p_cuser->tx);
if (ret_val) return ret_val; if (ret_val)
return ret_val;
ret_val = put_user(cnow.frame, &p_cuser->frame); ret_val = put_user(cnow.frame, &p_cuser->frame);
if (ret_val) return ret_val; if (ret_val)
return ret_val;
ret_val = put_user(cnow.overrun, &p_cuser->overrun); ret_val = put_user(cnow.overrun, &p_cuser->overrun);
if (ret_val) return ret_val; if (ret_val)
return ret_val;
ret_val = put_user(cnow.parity, &p_cuser->parity); ret_val = put_user(cnow.parity, &p_cuser->parity);
if (ret_val) return ret_val; if (ret_val)
return ret_val;
ret_val = put_user(cnow.brk, &p_cuser->brk); ret_val = put_user(cnow.brk, &p_cuser->brk);
if (ret_val) return ret_val; if (ret_val)
return ret_val;
ret_val = put_user(cnow.buf_overrun, &p_cuser->buf_overrun); ret_val = put_user(cnow.buf_overrun, &p_cuser->buf_overrun);
if (ret_val) return ret_val; if (ret_val)
return ret_val;
ret_val = 0; ret_val = 0;
break; break;
default: default:
...@@ -4098,15 +4213,13 @@ cy_ioctl(struct tty_struct *tty, struct file * file, ...@@ -4098,15 +4213,13 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
return ret_val; return ret_val;
} /* cy_ioctl */ } /* cy_ioctl */
/* /*
* This routine allows the tty driver to be notified when * This routine allows the tty driver to be notified when
* device's termios settings have changed. Note that a * device's termios settings have changed. Note that a
* well-designed tty driver should be prepared to accept the case * well-designed tty driver should be prepared to accept the case
* where old == NULL, and try to do something rational. * where old == NULL, and try to do something rational.
*/ */
static void static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
cy_set_termios(struct tty_struct *tty, struct ktermios * old_termios)
{ {
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
...@@ -4114,9 +4227,9 @@ cy_set_termios(struct tty_struct *tty, struct ktermios * old_termios) ...@@ -4114,9 +4227,9 @@ cy_set_termios(struct tty_struct *tty, struct ktermios * old_termios)
printk("cyc:cy_set_termios ttyC%d\n", info->line); printk("cyc:cy_set_termios ttyC%d\n", info->line);
#endif #endif
if ((tty->termios->c_cflag == old_termios->c_cflag) && if (tty->termios->c_cflag == old_termios->c_cflag &&
((tty->termios->c_iflag & (IXON|IXANY)) == (tty->termios->c_iflag & (IXON | IXANY)) ==
(old_termios->c_iflag & (IXON|IXANY)))) (old_termios->c_iflag & (IXON | IXANY)))
return; return;
set_line_char(info); set_line_char(info);
...@@ -4143,28 +4256,29 @@ cy_set_termios(struct tty_struct *tty, struct ktermios * old_termios) ...@@ -4143,28 +4256,29 @@ cy_set_termios(struct tty_struct *tty, struct ktermios * old_termios)
/* This function is used to send a high-priority XON/XOFF character to /* This function is used to send a high-priority XON/XOFF character to
the device. the device.
*/ */
static void static void cy_send_xchar(struct tty_struct *tty, char ch)
cy_send_xchar (struct tty_struct *tty, char ch)
{ {
struct cyclades_port *info = (struct cyclades_port *) tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
int card, channel; int card, channel;
if (serial_paranoia_check (info, tty->name, "cy_send_xchar")) if (serial_paranoia_check(info, tty->name, "cy_send_xchar"))
return; return;
info->x_char = ch; info->x_char = ch;
if (ch) if (ch)
cy_start (tty); cy_start(tty);
card = info->card; card = info->card;
channel = info->line - cy_card[card].first_line; channel = info->line - cy_card[card].first_line;
if (IS_CYC_Z (cy_card[card])) { if (IS_CYC_Z(cy_card[card])) {
if (ch == STOP_CHAR (tty)) if (ch == STOP_CHAR(tty))
cyz_issue_cmd (&cy_card[card], channel, C_CM_SENDXOFF, 0L); cyz_issue_cmd(&cy_card[card], channel, C_CM_SENDXOFF,
else if (ch == START_CHAR (tty)) 0L);
cyz_issue_cmd (&cy_card[card], channel, C_CM_SENDXON, 0L); else if (ch == START_CHAR(tty))
cyz_issue_cmd(&cy_card[card], channel, C_CM_SENDXON,
0L);
} }
} }
...@@ -4172,31 +4286,29 @@ cy_send_xchar (struct tty_struct *tty, char ch) ...@@ -4172,31 +4286,29 @@ cy_send_xchar (struct tty_struct *tty, char ch)
that incoming characters should be throttled because the input that incoming characters should be throttled because the input
buffers are close to full. buffers are close to full.
*/ */
static void static void cy_throttle(struct tty_struct *tty)
cy_throttle(struct tty_struct * tty)
{ {
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
unsigned long flags; unsigned long flags;
void __iomem *base_addr; void __iomem *base_addr;
int card,chip,channel,index; int card, chip, channel, index;
#ifdef CY_DEBUG_THROTTLE #ifdef CY_DEBUG_THROTTLE
char buf[64]; char buf[64];
printk("cyc:throttle %s: %d....ttyC%d\n", printk("cyc:throttle %s: %d....ttyC%d\n", tty_name(tty, buf),
tty_name(tty, buf),
tty->ldisc.chars_in_buffer(tty), info->line); tty->ldisc.chars_in_buffer(tty), info->line);
#endif #endif
if (serial_paranoia_check(info, tty->name, "cy_throttle")){ if (serial_paranoia_check(info, tty->name, "cy_throttle")) {
return; return;
} }
card = info->card; card = info->card;
if (I_IXOFF(tty)) { if (I_IXOFF(tty)) {
if (!IS_CYC_Z (cy_card[card])) if (!IS_CYC_Z(cy_card[card]))
cy_send_xchar (tty, STOP_CHAR (tty)); cy_send_xchar(tty, STOP_CHAR(tty));
else else
info->throttle = 1; info->throttle = 1;
} }
...@@ -4204,17 +4316,21 @@ cy_throttle(struct tty_struct * tty) ...@@ -4204,17 +4316,21 @@ cy_throttle(struct tty_struct * tty)
if (tty->termios->c_cflag & CRTSCTS) { if (tty->termios->c_cflag & CRTSCTS) {
channel = info->line - cy_card[card].first_line; channel = info->line - cy_card[card].first_line;
if (!IS_CYC_Z(cy_card[card])) { if (!IS_CYC_Z(cy_card[card])) {
chip = channel>>2; chip = channel >> 2;
channel &= 0x03; channel &= 0x03;
index = cy_card[card].bus_index; index = cy_card[card].bus_index;
base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); base_addr = cy_card[card].base_addr +
(cy_chip_offset[chip] << index);
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); cy_writeb(base_addr + (CyCAR << index),
(u_char) channel);
if (info->rtsdtr_inv) { if (info->rtsdtr_inv) {
cy_writeb(base_addr+(CyMSVR2<<index), ~CyDTR); cy_writeb(base_addr + (CyMSVR2 << index),
~CyDTR);
} else { } else {
cy_writeb(base_addr+(CyMSVR1<<index), ~CyRTS); cy_writeb(base_addr + (CyMSVR1 << index),
~CyRTS);
} }
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
} else { } else {
...@@ -4225,29 +4341,26 @@ cy_throttle(struct tty_struct * tty) ...@@ -4225,29 +4341,26 @@ cy_throttle(struct tty_struct * tty)
return; return;
} /* cy_throttle */ } /* cy_throttle */
/* /*
* This routine notifies the tty driver that it should signal * This routine notifies the tty driver that it should signal
* that characters can now be sent to the tty without fear of * that characters can now be sent to the tty without fear of
* overrunning the input buffers of the line disciplines. * overrunning the input buffers of the line disciplines.
*/ */
static void static void cy_unthrottle(struct tty_struct *tty)
cy_unthrottle(struct tty_struct * tty)
{ {
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
unsigned long flags; unsigned long flags;
void __iomem *base_addr; void __iomem *base_addr;
int card,chip,channel,index; int card, chip, channel, index;
#ifdef CY_DEBUG_THROTTLE #ifdef CY_DEBUG_THROTTLE
char buf[64]; char buf[64];
printk("cyc:unthrottle %s: %d....ttyC%d\n", printk("cyc:unthrottle %s: %d....ttyC%d\n", tty_name(tty, buf),
tty_name(tty, buf),
tty->ldisc.chars_in_buffer(tty), info->line); tty->ldisc.chars_in_buffer(tty), info->line);
#endif #endif
if (serial_paranoia_check(info, tty->name, "cy_unthrottle")){ if (serial_paranoia_check(info, tty->name, "cy_unthrottle")) {
return; return;
} }
...@@ -4255,24 +4368,28 @@ cy_unthrottle(struct tty_struct * tty) ...@@ -4255,24 +4368,28 @@ cy_unthrottle(struct tty_struct * tty)
if (info->x_char) if (info->x_char)
info->x_char = 0; info->x_char = 0;
else else
cy_send_xchar (tty, START_CHAR (tty)); cy_send_xchar(tty, START_CHAR(tty));
} }
if (tty->termios->c_cflag & CRTSCTS) { if (tty->termios->c_cflag & CRTSCTS) {
card = info->card; card = info->card;
channel = info->line - cy_card[card].first_line; channel = info->line - cy_card[card].first_line;
if (!IS_CYC_Z(cy_card[card])) { if (!IS_CYC_Z(cy_card[card])) {
chip = channel>>2; chip = channel >> 2;
channel &= 0x03; channel &= 0x03;
index = cy_card[card].bus_index; index = cy_card[card].bus_index;
base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); base_addr = cy_card[card].base_addr +
(cy_chip_offset[chip] << index);
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); cy_writeb(base_addr + (CyCAR << index),
(u_char) channel);
if (info->rtsdtr_inv) { if (info->rtsdtr_inv) {
cy_writeb(base_addr+(CyMSVR2<<index), CyDTR); cy_writeb(base_addr + (CyMSVR2 << index),
CyDTR);
} else { } else {
cy_writeb(base_addr+(CyMSVR1<<index), CyRTS); cy_writeb(base_addr + (CyMSVR1 << index),
CyRTS);
} }
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
} else { } else {
...@@ -4283,17 +4400,15 @@ cy_unthrottle(struct tty_struct * tty) ...@@ -4283,17 +4400,15 @@ cy_unthrottle(struct tty_struct * tty)
return; return;
} /* cy_unthrottle */ } /* cy_unthrottle */
/* cy_start and cy_stop provide software output flow control as a /* cy_start and cy_stop provide software output flow control as a
function of XON/XOFF, software CTS, and other such stuff. function of XON/XOFF, software CTS, and other such stuff.
*/ */
static void static void cy_stop(struct tty_struct *tty)
cy_stop(struct tty_struct *tty)
{ {
struct cyclades_card *cinfo; struct cyclades_card *cinfo;
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
void __iomem *base_addr; void __iomem *base_addr;
int chip,channel,index; int chip, channel, index;
unsigned long flags; unsigned long flags;
#ifdef CY_DEBUG_OTHER #ifdef CY_DEBUG_OTHER
...@@ -4307,15 +4422,16 @@ cy_stop(struct tty_struct *tty) ...@@ -4307,15 +4422,16 @@ cy_stop(struct tty_struct *tty)
channel = info->line - cinfo->first_line; channel = info->line - cinfo->first_line;
if (!IS_CYC_Z(*cinfo)) { if (!IS_CYC_Z(*cinfo)) {
index = cinfo->bus_index; index = cinfo->bus_index;
chip = channel>>2; chip = channel >> 2;
channel &= 0x03; channel &= 0x03;
base_addr = cy_card[info->card].base_addr + (cy_chip_offset[chip]<<index); base_addr = cy_card[info->card].base_addr +
(cy_chip_offset[chip] << index);
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writeb(base_addr+(CyCAR<<index), cy_writeb(base_addr + (CyCAR << index),
(u_char)(channel & 0x0003)); /* index channel */ (u_char)(channel & 0x0003)); /* index channel */
cy_writeb(base_addr+(CySRER<<index), cy_writeb(base_addr + (CySRER << index),
cy_readb(base_addr+(CySRER<<index)) & ~CyTxRdy); cy_readb(base_addr + (CySRER << index)) & ~CyTxRdy);
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
} else { } else {
// Nothing to do! // Nothing to do!
...@@ -4324,14 +4440,12 @@ cy_stop(struct tty_struct *tty) ...@@ -4324,14 +4440,12 @@ cy_stop(struct tty_struct *tty)
return; return;
} /* cy_stop */ } /* cy_stop */
static void cy_start(struct tty_struct *tty)
static void
cy_start(struct tty_struct *tty)
{ {
struct cyclades_card *cinfo; struct cyclades_card *cinfo;
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
void __iomem *base_addr; void __iomem *base_addr;
int chip,channel,index; int chip, channel, index;
unsigned long flags; unsigned long flags;
#ifdef CY_DEBUG_OTHER #ifdef CY_DEBUG_OTHER
...@@ -4345,15 +4459,15 @@ cy_start(struct tty_struct *tty) ...@@ -4345,15 +4459,15 @@ cy_start(struct tty_struct *tty)
channel = info->line - cinfo->first_line; channel = info->line - cinfo->first_line;
index = cinfo->bus_index; index = cinfo->bus_index;
if (!IS_CYC_Z(*cinfo)) { if (!IS_CYC_Z(*cinfo)) {
chip = channel>>2; chip = channel >> 2;
channel &= 0x03; channel &= 0x03;
base_addr = cy_card[info->card].base_addr + (cy_chip_offset[chip]<<index); base_addr = cy_card[info->card].base_addr +
(cy_chip_offset[chip] << index);
CY_LOCK(info, flags); CY_LOCK(info, flags);
cy_writeb(base_addr+(CyCAR<<index), cy_writeb(base_addr + (CyCAR << index), (u_char) (channel & 0x0003)); /* index channel */
(u_char)(channel & 0x0003)); /* index channel */ cy_writeb(base_addr + (CySRER << index),
cy_writeb(base_addr+(CySRER<<index), cy_readb(base_addr + (CySRER << index)) | CyTxRdy);
cy_readb(base_addr+(CySRER<<index)) | CyTxRdy);
CY_UNLOCK(info, flags); CY_UNLOCK(info, flags);
} else { } else {
// Nothing to do! // Nothing to do!
...@@ -4362,9 +4476,7 @@ cy_start(struct tty_struct *tty) ...@@ -4362,9 +4476,7 @@ cy_start(struct tty_struct *tty)
return; return;
} /* cy_start */ } /* cy_start */
static void cy_flush_buffer(struct tty_struct *tty)
static void
cy_flush_buffer(struct tty_struct *tty)
{ {
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
int card, channel, retval; int card, channel, retval;
...@@ -4387,7 +4499,8 @@ cy_flush_buffer(struct tty_struct *tty) ...@@ -4387,7 +4499,8 @@ cy_flush_buffer(struct tty_struct *tty)
if (IS_CYC_Z(cy_card[card])) { /* If it is a Z card, flush the on-board if (IS_CYC_Z(cy_card[card])) { /* If it is a Z card, flush the on-board
buffers as well */ buffers as well */
CY_LOCK(info, flags); CY_LOCK(info, flags);
retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_FLUSH_TX, 0L); retval =
cyz_issue_cmd(&cy_card[card], channel, C_CM_FLUSH_TX, 0L);
if (retval != 0) { if (retval != 0) {
printk("cyc: flush_buffer retval on ttyC%d was %x\n", printk("cyc: flush_buffer retval on ttyC%d was %x\n",
info->line, retval); info->line, retval);
...@@ -4398,14 +4511,12 @@ cy_flush_buffer(struct tty_struct *tty) ...@@ -4398,14 +4511,12 @@ cy_flush_buffer(struct tty_struct *tty)
wake_up_interruptible(&tty->write_wait); wake_up_interruptible(&tty->write_wait);
} /* cy_flush_buffer */ } /* cy_flush_buffer */
/* /*
* cy_hangup() --- called by tty_hangup() when a hangup is signaled. * cy_hangup() --- called by tty_hangup() when a hangup is signaled.
*/ */
static void static void cy_hangup(struct tty_struct *tty)
cy_hangup(struct tty_struct *tty)
{ {
struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
#ifdef CY_DEBUG_OTHER #ifdef CY_DEBUG_OTHER
printk("cyc:cy_hangup ttyC%d\n", info->line); /* */ printk("cyc:cy_hangup ttyC%d\n", info->line); /* */
...@@ -4426,7 +4537,6 @@ cy_hangup(struct tty_struct *tty) ...@@ -4426,7 +4537,6 @@ cy_hangup(struct tty_struct *tty)
wake_up_interruptible(&info->open_wait); wake_up_interruptible(&info->open_wait);
} /* cy_hangup */ } /* cy_hangup */
/* /*
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* cy_init() and friends * cy_init() and friends
...@@ -4438,21 +4548,22 @@ cy_hangup(struct tty_struct *tty) ...@@ -4438,21 +4548,22 @@ cy_hangup(struct tty_struct *tty)
/* initialize chips on Cyclom-Y card -- return number of valid /* initialize chips on Cyclom-Y card -- return number of valid
chips (which is number of ports/4) */ chips (which is number of ports/4) */
static unsigned short __init static unsigned short __init
cyy_init_card(void __iomem *true_base_addr,int index) cyy_init_card(void __iomem * true_base_addr, int index)
{ {
unsigned int chip_number; unsigned int chip_number;
void __iomem *base_addr; void __iomem *base_addr;
cy_writeb(true_base_addr+(Cy_HwReset<<index), 0); cy_writeb(true_base_addr + (Cy_HwReset << index), 0);
/* Cy_HwReset is 0x1400 */ /* Cy_HwReset is 0x1400 */
cy_writeb(true_base_addr+(Cy_ClrIntr<<index), 0); cy_writeb(true_base_addr + (Cy_ClrIntr << index), 0);
/* Cy_ClrIntr is 0x1800 */ /* Cy_ClrIntr is 0x1800 */
udelay(500L); udelay(500L);
for(chip_number=0; chip_number<CyMAX_CHIPS_PER_CARD; chip_number++){ for (chip_number = 0; chip_number < CyMAX_CHIPS_PER_CARD; chip_number++) {
base_addr = true_base_addr + (cy_chip_offset[chip_number]<<index); base_addr =
true_base_addr + (cy_chip_offset[chip_number] << index);
mdelay(1); mdelay(1);
if(cy_readb(base_addr+(CyCCR<<index)) != 0x00){ if (cy_readb(base_addr + (CyCCR << index)) != 0x00) {
/************* /*************
printk(" chip #%d at %#6lx is never idle (CCR != 0)\n", printk(" chip #%d at %#6lx is never idle (CCR != 0)\n",
chip_number, (unsigned long)base_addr); chip_number, (unsigned long)base_addr);
...@@ -4460,7 +4571,7 @@ cyy_init_card(void __iomem *true_base_addr,int index) ...@@ -4460,7 +4571,7 @@ cyy_init_card(void __iomem *true_base_addr,int index)
return chip_number; return chip_number;
} }
cy_writeb(base_addr+(CyGFRCR<<index), 0); cy_writeb(base_addr + (CyGFRCR << index), 0);
udelay(10L); udelay(10L);
/* The Cyclom-16Y does not decode address bit 9 and therefore /* The Cyclom-16Y does not decode address bit 9 and therefore
...@@ -4469,17 +4580,16 @@ cyy_init_card(void __iomem *true_base_addr,int index) ...@@ -4469,17 +4580,16 @@ cyy_init_card(void __iomem *true_base_addr,int index)
chip 4 GFRCR register appears at chip 0, there is no chip 4 chip 4 GFRCR register appears at chip 0, there is no chip 4
and this must be a Cyclom-16Y, not a Cyclom-32Ye. and this must be a Cyclom-16Y, not a Cyclom-32Ye.
*/ */
if (chip_number == 4 if (chip_number == 4 && cy_readb(true_base_addr +
&& cy_readb(true_base_addr (cy_chip_offset[0] << index) +
+ (cy_chip_offset[0]<<index) (CyGFRCR << index)) == 0) {
+ (CyGFRCR<<index)) == 0){
return chip_number; return chip_number;
} }
cy_writeb(base_addr+(CyCCR<<index), CyCHIP_RESET); cy_writeb(base_addr + (CyCCR << index), CyCHIP_RESET);
mdelay(1); mdelay(1);
if(cy_readb(base_addr+(CyGFRCR<<index)) == 0x00){ if (cy_readb(base_addr + (CyGFRCR << index)) == 0x00) {
/* /*
printk(" chip #%d at %#6lx is not responding ", printk(" chip #%d at %#6lx is not responding ",
chip_number, (unsigned long)base_addr); chip_number, (unsigned long)base_addr);
...@@ -4487,23 +4597,25 @@ cyy_init_card(void __iomem *true_base_addr,int index) ...@@ -4487,23 +4597,25 @@ cyy_init_card(void __iomem *true_base_addr,int index)
*/ */
return chip_number; return chip_number;
} }
if((0xf0 & (cy_readb(base_addr+(CyGFRCR<<index)))) != 0x40){ if ((0xf0 & (cy_readb(base_addr + (CyGFRCR << index)))) !=
0x40) {
/* /*
printk(" chip #%d at %#6lx is not valid (GFRCR == %#2x)\n", printk(" chip #%d at %#6lx is not valid (GFRCR == "
"%#2x)\n",
chip_number, (unsigned long)base_addr, chip_number, (unsigned long)base_addr,
base_addr[CyGFRCR<<index]); base_addr[CyGFRCR<<index]);
*/ */
return chip_number; return chip_number;
} }
cy_writeb(base_addr+(CyGCR<<index), CyCH0_SERIAL); cy_writeb(base_addr + (CyGCR << index), CyCH0_SERIAL);
if (cy_readb(base_addr+(CyGFRCR<<index)) >= CD1400_REV_J){ if (cy_readb(base_addr + (CyGFRCR << index)) >= CD1400_REV_J) {
/* It is a CD1400 rev. J or later */ /* It is a CD1400 rev. J or later */
/* Impossible to reach 5ms with this chip. /* Impossible to reach 5ms with this chip.
Changed to 2ms instead (f = 500 Hz). */ Changed to 2ms instead (f = 500 Hz). */
cy_writeb(base_addr+(CyPPR<<index), CyCLOCK_60_2MS); cy_writeb(base_addr + (CyPPR << index), CyCLOCK_60_2MS);
} else { } else {
/* f = 200 Hz */ /* f = 200 Hz */
cy_writeb(base_addr+(CyPPR<<index), CyCLOCK_25_5MS); cy_writeb(base_addr + (CyPPR << index), CyCLOCK_25_5MS);
} }
/* /*
...@@ -4521,13 +4633,12 @@ cyy_init_card(void __iomem *true_base_addr,int index) ...@@ -4521,13 +4633,12 @@ cyy_init_card(void __iomem *true_base_addr,int index)
* sets global variables and return the number of ISA boards found. * sets global variables and return the number of ISA boards found.
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
*/ */
static int __init static int __init cy_detect_isa(void)
cy_detect_isa(void)
{ {
#ifdef CONFIG_ISA #ifdef CONFIG_ISA
unsigned short cy_isa_irq,nboard; unsigned short cy_isa_irq, nboard;
void __iomem *cy_isa_address; void __iomem *cy_isa_address;
unsigned short i,j,cy_isa_nchan; unsigned short i, j, cy_isa_nchan;
#ifdef MODULE #ifdef MODULE
int isparam = 0; int isparam = 0;
#endif #endif
...@@ -4536,7 +4647,7 @@ cy_detect_isa(void) ...@@ -4536,7 +4647,7 @@ cy_detect_isa(void)
#ifdef MODULE #ifdef MODULE
/* Check for module parameters */ /* Check for module parameters */
for(i = 0 ; i < NR_CARDS; i++) { for (i = 0; i < NR_CARDS; i++) {
if (maddr[i] || i) { if (maddr[i] || i) {
isparam = 1; isparam = 1;
cy_isa_addresses[i] = maddr[i]; cy_isa_addresses[i] = maddr[i];
...@@ -4547,20 +4658,19 @@ cy_detect_isa(void) ...@@ -4547,20 +4658,19 @@ cy_detect_isa(void)
#endif #endif
/* scan the address table probing for Cyclom-Y/ISA boards */ /* scan the address table probing for Cyclom-Y/ISA boards */
for (i = 0 ; i < NR_ISA_ADDRS ; i++) { for (i = 0; i < NR_ISA_ADDRS; i++) {
unsigned int isa_address = cy_isa_addresses[i]; unsigned int isa_address = cy_isa_addresses[i];
if (isa_address == 0x0000) { if (isa_address == 0x0000) {
return(nboard); return (nboard);
} }
/* probe for CD1400... */ /* probe for CD1400... */
cy_isa_address = ioremap(isa_address, CyISA_Ywin); cy_isa_address = ioremap(isa_address, CyISA_Ywin);
cy_isa_nchan = CyPORTS_PER_CHIP * cy_isa_nchan = CyPORTS_PER_CHIP *
cyy_init_card(cy_isa_address,0); cyy_init_card(cy_isa_address, 0);
if (cy_isa_nchan == 0) { if (cy_isa_nchan == 0) {
continue; continue;
} }
#ifdef MODULE #ifdef MODULE
if (isparam && irq[i]) if (isparam && irq[i])
cy_isa_irq = irq[i]; cy_isa_irq = irq[i];
...@@ -4570,67 +4680,67 @@ cy_detect_isa(void) ...@@ -4570,67 +4680,67 @@ cy_detect_isa(void)
cy_isa_irq = detect_isa_irq(cy_isa_address); cy_isa_irq = detect_isa_irq(cy_isa_address);
if (cy_isa_irq == 0) { if (cy_isa_irq == 0) {
printk("Cyclom-Y/ISA found at 0x%lx ", printk("Cyclom-Y/ISA found at 0x%lx ",
(unsigned long) cy_isa_address); (unsigned long)cy_isa_address);
printk("but the IRQ could not be detected.\n"); printk("but the IRQ could not be detected.\n");
continue; continue;
} }
if((cy_next_channel+cy_isa_nchan) > NR_PORTS) { if ((cy_next_channel + cy_isa_nchan) > NR_PORTS) {
printk("Cyclom-Y/ISA found at 0x%lx ", printk("Cyclom-Y/ISA found at 0x%lx ",
(unsigned long) cy_isa_address); (unsigned long)cy_isa_address);
printk("but no more channels are available.\n"); printk("but no more channels are available.\n");
printk("Change NR_PORTS in cyclades.c and recompile kernel.\n"); printk("Change NR_PORTS in cyclades.c and recompile "
return(nboard); "kernel.\n");
return (nboard);
} }
/* fill the next cy_card structure available */ /* fill the next cy_card structure available */
for (j = 0 ; j < NR_CARDS ; j++) { for (j = 0; j < NR_CARDS; j++) {
if (cy_card[j].base_addr == 0) break; if (cy_card[j].base_addr == 0)
break;
} }
if (j == NR_CARDS) { /* no more cy_cards available */ if (j == NR_CARDS) { /* no more cy_cards available */
printk("Cyclom-Y/ISA found at 0x%lx ", printk("Cyclom-Y/ISA found at 0x%lx ",
(unsigned long) cy_isa_address); (unsigned long)cy_isa_address);
printk("but no more cards can be used .\n"); printk("but no more cards can be used .\n");
printk("Change NR_CARDS in cyclades.c and recompile kernel.\n"); printk("Change NR_CARDS in cyclades.c and recompile "
return(nboard); "kernel.\n");
return (nboard);
} }
/* allocate IRQ */ /* allocate IRQ */
if(request_irq(cy_isa_irq, cyy_interrupt, if (request_irq(cy_isa_irq, cyy_interrupt,
IRQF_DISABLED, "Cyclom-Y", &cy_card[j])) IRQF_DISABLED, "Cyclom-Y", &cy_card[j])) {
{
printk("Cyclom-Y/ISA found at 0x%lx ", printk("Cyclom-Y/ISA found at 0x%lx ",
(unsigned long) cy_isa_address); (unsigned long)cy_isa_address);
printk("but could not allocate IRQ#%d.\n", printk("but could not allocate IRQ#%d.\n", cy_isa_irq);
cy_isa_irq); return (nboard);
return(nboard);
} }
/* set cy_card */ /* set cy_card */
cy_card[j].base_addr = cy_isa_address; cy_card[j].base_addr = cy_isa_address;
cy_card[j].ctl_addr = NULL; cy_card[j].ctl_addr = NULL;
cy_card[j].irq = (int) cy_isa_irq; cy_card[j].irq = (int)cy_isa_irq;
cy_card[j].bus_index = 0; cy_card[j].bus_index = 0;
cy_card[j].first_line = cy_next_channel; cy_card[j].first_line = cy_next_channel;
cy_card[j].num_chips = cy_isa_nchan/4; cy_card[j].num_chips = cy_isa_nchan / 4;
nboard++; nboard++;
/* print message */ /* print message */
printk("Cyclom-Y/ISA #%d: 0x%lx-0x%lx, IRQ%d, ", printk("Cyclom-Y/ISA #%d: 0x%lx-0x%lx, IRQ%d, ",
j+1, (unsigned long) cy_isa_address, j + 1, (unsigned long)cy_isa_address,
(unsigned long)(cy_isa_address + (CyISA_Ywin - 1)), (unsigned long)(cy_isa_address + (CyISA_Ywin - 1)),
cy_isa_irq); cy_isa_irq);
printk("%d channels starting from port %d.\n", printk("%d channels starting from port %d.\n",
cy_isa_nchan, cy_next_channel); cy_isa_nchan, cy_next_channel);
cy_next_channel += cy_isa_nchan; cy_next_channel += cy_isa_nchan;
} }
return(nboard); return (nboard);
#else #else
return(0); return (0);
#endif /* CONFIG_ISA */ #endif /* CONFIG_ISA */
} /* cy_detect_isa */ } /* cy_detect_isa */
static void static void plx_init(void __iomem * addr, uclong initctl)
plx_init(void __iomem *addr, uclong initctl)
{ {
/* Reset PLX */ /* Reset PLX */
cy_writel(addr + initctl, cy_readl(addr + initctl) | 0x40000000); cy_writel(addr + initctl, cy_readl(addr + initctl) | 0x40000000);
...@@ -4649,8 +4759,7 @@ plx_init(void __iomem *addr, uclong initctl) ...@@ -4649,8 +4759,7 @@ plx_init(void __iomem *addr, uclong initctl)
* sets global variables and return the number of PCI boards found. * sets global variables and return the number of PCI boards found.
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
*/ */
static int __init static int __init cy_detect_pci(void)
cy_detect_pci(void)
{ {
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
...@@ -4659,8 +4768,8 @@ cy_detect_pci(void) ...@@ -4659,8 +4768,8 @@ cy_detect_pci(void)
unsigned char cy_pci_irq = 0; unsigned char cy_pci_irq = 0;
uclong cy_pci_phys0, cy_pci_phys2; uclong cy_pci_phys0, cy_pci_phys2;
void __iomem *cy_pci_addr0, *cy_pci_addr2; void __iomem *cy_pci_addr0, *cy_pci_addr2;
unsigned short i,j,cy_pci_nchan, plx_ver; unsigned short i, j, cy_pci_nchan, plx_ver;
unsigned short device_id,dev_index = 0; unsigned short device_id, dev_index = 0;
uclong mailbox; uclong mailbox;
uclong ZeIndex = 0; uclong ZeIndex = 0;
void __iomem *Ze_addr0[NR_CARDS], *Ze_addr2[NR_CARDS]; void __iomem *Ze_addr0[NR_CARDS], *Ze_addr2[NR_CARDS];
...@@ -4670,8 +4779,8 @@ cy_detect_pci(void) ...@@ -4670,8 +4779,8 @@ cy_detect_pci(void)
for (i = 0; i < NR_CARDS; i++) { for (i = 0; i < NR_CARDS; i++) {
/* look for a Cyclades card by vendor and device id */ /* look for a Cyclades card by vendor and device id */
while((device_id = cy_pci_dev_id[dev_index]) != 0) { while ((device_id = cy_pci_dev_id[dev_index]) != 0) {
if((pdev = pci_get_device(PCI_VENDOR_ID_CYCLADES, if ((pdev = pci_get_device(PCI_VENDOR_ID_CYCLADES,
device_id, pdev)) == NULL) { device_id, pdev)) == NULL) {
dev_index++; /* try next device id */ dev_index++; /* try next device id */
} else { } else {
...@@ -4693,20 +4802,21 @@ cy_detect_pci(void) ...@@ -4693,20 +4802,21 @@ cy_detect_pci(void)
device_id &= ~PCI_DEVICE_ID_MASK; device_id &= ~PCI_DEVICE_ID_MASK;
if ((device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo) if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo ||
|| (device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi)){ device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi) {
#ifdef CY_PCI_DEBUG #ifdef CY_PCI_DEBUG
printk("Cyclom-Y/PCI (bus=0x0%x, pci_id=0x%x, ", printk("Cyclom-Y/PCI (bus=0x0%x, pci_id=0x%x, ",
pdev->bus->number, pdev->devfn); pdev->bus->number, pdev->devfn);
printk("rev_id=%d) IRQ%d\n", printk("rev_id=%d) IRQ%d\n",
cyy_rev_id, (int)cy_pci_irq); cyy_rev_id, (int)cy_pci_irq);
printk("Cyclom-Y/PCI:found winaddr=0x%lx ctladdr=0x%lx\n", printk("Cyclom-Y/PCI:found winaddr=0x%lx "
"ctladdr=0x%lx\n",
(ulong)cy_pci_phys2, (ulong)cy_pci_phys0); (ulong)cy_pci_phys2, (ulong)cy_pci_phys0);
#endif #endif
if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) { if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) {
printk(" Warning: PCI I/O bit incorrectly set. " printk(" Warning: PCI I/O bit incorrectly "
"Ignoring it...\n"); "set. Ignoring it...\n");
pdev->resource[2].flags &= ~IORESOURCE_IO; pdev->resource[2].flags &= ~IORESOURCE_IO;
} }
...@@ -4714,20 +4824,22 @@ cy_detect_pci(void) ...@@ -4714,20 +4824,22 @@ cy_detect_pci(void)
request it from the kernel anyway, to avoid problems request it from the kernel anyway, to avoid problems
with other drivers accessing it. */ with other drivers accessing it. */
if (pci_request_regions(pdev, "Cyclom-Y") != 0) { if (pci_request_regions(pdev, "Cyclom-Y") != 0) {
printk(KERN_ERR "cyclades: failed to reserve PCI resources\n"); printk(KERN_ERR "cyclades: failed to reserve "
"PCI resources\n");
continue; continue;
} }
#if defined(__alpha__) #if defined(__alpha__)
if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo) { /* below 1M? */ if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo) { /* below 1M? */
printk("Cyclom-Y/PCI (bus=0x0%x, pci_id=0x%x, ", printk("Cyclom-Y/PCI (bus=0x0%x, pci_id=0x%x, ",
pdev->bus->number, pdev->devfn); pdev->bus->number, pdev->devfn);
printk("rev_id=%d) IRQ%d\n", printk("rev_id=%d) IRQ%d\n",
cyy_rev_id, (int)cy_pci_irq); cyy_rev_id, (int)cy_pci_irq);
printk("Cyclom-Y/PCI:found winaddr=0x%lx ctladdr=0x%lx\n", printk("Cyclom-Y/PCI:found winaddr=0x%lx "
(ulong)cy_pci_phys2, (ulong)cy_pci_phys0); "ctladdr=0x%lx\n",
printk("Cyclom-Y/PCI not supported for low addresses in " (ulong)cy_pci_phys2,
"Alpha systems.\n"); (ulong)cy_pci_phys0);
printk("Cyclom-Y/PCI not supported for low "
"addresses in Alpha systems.\n");
i--; i--;
continue; continue;
} }
...@@ -4736,57 +4848,60 @@ cy_detect_pci(void) ...@@ -4736,57 +4848,60 @@ cy_detect_pci(void)
cy_pci_addr2 = ioremap(cy_pci_phys2, CyPCI_Ywin); cy_pci_addr2 = ioremap(cy_pci_phys2, CyPCI_Ywin);
#ifdef CY_PCI_DEBUG #ifdef CY_PCI_DEBUG
printk("Cyclom-Y/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n", printk("Cyclom-Y/PCI: relocate winaddr=0x%lx "
"ctladdr=0x%lx\n",
(u_long)cy_pci_addr2, (u_long)cy_pci_addr0); (u_long)cy_pci_addr2, (u_long)cy_pci_addr0);
#endif #endif
cy_pci_nchan = (unsigned short)(CyPORTS_PER_CHIP * cy_pci_nchan = (unsigned short)(CyPORTS_PER_CHIP *
cyy_init_card(cy_pci_addr2, 1)); cyy_init_card(cy_pci_addr2, 1));
if(cy_pci_nchan == 0) { if (cy_pci_nchan == 0) {
printk("Cyclom-Y PCI host card with "); printk("Cyclom-Y PCI host card with ");
printk("no Serial-Modules at 0x%lx.\n", printk("no Serial-Modules at 0x%lx.\n",
(ulong) cy_pci_phys2); (ulong) cy_pci_phys2);
i--; i--;
continue; continue;
} }
if((cy_next_channel+cy_pci_nchan) > NR_PORTS) { if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) {
printk("Cyclom-Y/PCI found at 0x%lx ", printk("Cyclom-Y/PCI found at 0x%lx ",
(ulong) cy_pci_phys2); (ulong) cy_pci_phys2);
printk("but no channels are available.\n"); printk("but no channels are available.\n");
printk("Change NR_PORTS in cyclades.c and recompile kernel.\n"); printk("Change NR_PORTS in cyclades.c and "
return(i); "recompile kernel.\n");
return (i);
} }
/* fill the next cy_card structure available */ /* fill the next cy_card structure available */
for (j = 0 ; j < NR_CARDS ; j++) { for (j = 0; j < NR_CARDS; j++) {
if (cy_card[j].base_addr == 0) break; if (cy_card[j].base_addr == 0)
break;
} }
if (j == NR_CARDS) { /* no more cy_cards available */ if (j == NR_CARDS) { /* no more cy_cards available */
printk("Cyclom-Y/PCI found at 0x%lx ", printk("Cyclom-Y/PCI found at 0x%lx ",
(ulong) cy_pci_phys2); (ulong) cy_pci_phys2);
printk("but no more cards can be used.\n"); printk("but no more cards can be used.\n");
printk("Change NR_CARDS in cyclades.c and recompile kernel.\n"); printk("Change NR_CARDS in cyclades.c and "
return(i); "recompile kernel.\n");
return (i);
} }
/* allocate IRQ */ /* allocate IRQ */
if(request_irq(cy_pci_irq, cyy_interrupt, if (request_irq(cy_pci_irq, cyy_interrupt,
IRQF_SHARED, "Cyclom-Y", &cy_card[j])) IRQF_SHARED, "Cyclom-Y", &cy_card[j])) {
{
printk("Cyclom-Y/PCI found at 0x%lx ", printk("Cyclom-Y/PCI found at 0x%lx ",
(ulong) cy_pci_phys2); (ulong) cy_pci_phys2);
printk("but could not allocate IRQ%d.\n", printk("but could not allocate IRQ%d.\n",
cy_pci_irq); cy_pci_irq);
return(i); return (i);
} }
/* set cy_card */ /* set cy_card */
cy_card[j].base_phys = (ulong)cy_pci_phys2; cy_card[j].base_phys = (ulong) cy_pci_phys2;
cy_card[j].ctl_phys = (ulong)cy_pci_phys0; cy_card[j].ctl_phys = (ulong) cy_pci_phys0;
cy_card[j].base_addr = cy_pci_addr2; cy_card[j].base_addr = cy_pci_addr2;
cy_card[j].ctl_addr = cy_pci_addr0; cy_card[j].ctl_addr = cy_pci_addr0;
cy_card[j].irq = (int) cy_pci_irq; cy_card[j].irq = (int)cy_pci_irq;
cy_card[j].bus_index = 1; cy_card[j].bus_index = 1;
cy_card[j].first_line = cy_next_channel; cy_card[j].first_line = cy_next_channel;
cy_card[j].num_chips = cy_pci_nchan/4; cy_card[j].num_chips = cy_pci_nchan / 4;
cy_card[j].pdev = pdev; cy_card[j].pdev = pdev;
/* enable interrupts in the PCI interface */ /* enable interrupts in the PCI interface */
...@@ -4794,7 +4909,7 @@ cy_detect_pci(void) ...@@ -4794,7 +4909,7 @@ cy_detect_pci(void)
switch (plx_ver) { switch (plx_ver) {
case PLX_9050: case PLX_9050:
cy_writeb(cy_pci_addr0+0x4c, 0x43); cy_writeb(cy_pci_addr0 + 0x4c, 0x43);
break; break;
case PLX_9060: case PLX_9060:
...@@ -4805,62 +4920,70 @@ cy_detect_pci(void) ...@@ -4805,62 +4920,70 @@ cy_detect_pci(void)
/* For some yet unknown reason, once the PLX9060 reloads /* For some yet unknown reason, once the PLX9060 reloads
the EEPROM, the IRQ is lost and, thus, we have to the EEPROM, the IRQ is lost and, thus, we have to
re-write it to the PCI config. registers. re-write it to the PCI config. registers.
This will remain here until we find a permanent fix. */ This will remain here until we find a permanent
pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, cy_pci_irq); fix. */
pci_write_config_byte(pdev, PCI_INTERRUPT_LINE,
cy_pci_irq);
cy_writew(cy_pci_addr0+0x68, cy_writew(cy_pci_addr0 + 0x68,
cy_readw(cy_pci_addr0+0x68)|0x0900); cy_readw(cy_pci_addr0 +
0x68) | 0x0900);
break; break;
} }
/* print message */ /* print message */
printk("Cyclom-Y/PCI #%d: 0x%lx-0x%lx, IRQ%d, ", printk("Cyclom-Y/PCI #%d: 0x%lx-0x%lx, IRQ%d, ",
j+1, j + 1, (ulong)cy_pci_phys2,
(ulong)cy_pci_phys2, (ulong) (cy_pci_phys2 + CyPCI_Ywin - 1),
(ulong)(cy_pci_phys2 + CyPCI_Ywin - 1),
(int)cy_pci_irq); (int)cy_pci_irq);
printk("%d channels starting from port %d.\n", printk("%d channels starting from port %d.\n",
cy_pci_nchan, cy_next_channel); cy_pci_nchan, cy_next_channel);
cy_next_channel += cy_pci_nchan; cy_next_channel += cy_pci_nchan;
}else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Lo){ } else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Lo) {
/* print message */ /* print message */
printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ", printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ",
pdev->bus->number, pdev->devfn); pdev->bus->number, pdev->devfn);
printk("rev_id=%d) IRQ%d\n", printk("rev_id=%d) IRQ%d\n",
cyy_rev_id, (int)cy_pci_irq); cyy_rev_id, (int)cy_pci_irq);
printk("Cyclades-Z/PCI: found winaddr=0x%lx ctladdr=0x%lx\n", printk("Cyclades-Z/PCI: found winaddr=0x%lx "
"ctladdr=0x%lx\n",
(ulong)cy_pci_phys2, (ulong)cy_pci_phys0); (ulong)cy_pci_phys2, (ulong)cy_pci_phys0);
printk("Cyclades-Z/PCI not supported for low addresses\n"); printk("Cyclades-Z/PCI not supported for low "
"addresses\n");
break; break;
}else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Hi){ } else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Hi) {
#ifdef CY_PCI_DEBUG #ifdef CY_PCI_DEBUG
printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ", printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ",
pdev->bus->number, pdev->devfn); pdev->bus->number, pdev->devfn);
printk("rev_id=%d) IRQ%d\n", printk("rev_id=%d) IRQ%d\n",
cyy_rev_id, (int)cy_pci_irq); cyy_rev_id, (int)cy_pci_irq);
printk("Cyclades-Z/PCI: found winaddr=0x%lx ctladdr=0x%lx\n", printk("Cyclades-Z/PCI: found winaddr=0x%lx "
(ulong)cy_pci_phys2, (ulong)cy_pci_phys0); "ctladdr=0x%lx\n",
(ulong) cy_pci_phys2, (ulong) cy_pci_phys0);
#endif #endif
cy_pci_addr0 = ioremap(cy_pci_phys0, CyPCI_Zctl); cy_pci_addr0 = ioremap(cy_pci_phys0, CyPCI_Zctl);
/* Disable interrupts on the PLX before resetting it */ /* Disable interrupts on the PLX before resetting it */
cy_writew(cy_pci_addr0+0x68, cy_writew(cy_pci_addr0 + 0x68,
cy_readw(cy_pci_addr0+0x68) & ~0x0900); cy_readw(cy_pci_addr0 + 0x68) & ~0x0900);
plx_init(cy_pci_addr0, 0x6c); plx_init(cy_pci_addr0, 0x6c);
/* For some yet unknown reason, once the PLX9060 reloads /* For some yet unknown reason, once the PLX9060 reloads
the EEPROM, the IRQ is lost and, thus, we have to the EEPROM, the IRQ is lost and, thus, we have to
re-write it to the PCI config. registers. re-write it to the PCI config. registers.
This will remain here until we find a permanent fix. */ This will remain here until we find a permanent
pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, cy_pci_irq); fix. */
pci_write_config_byte(pdev, PCI_INTERRUPT_LINE,
cy_pci_irq);
mailbox = (uclong)cy_readl(&((struct RUNTIME_9060 __iomem *) mailbox =
(uclong)cy_readl(&((struct RUNTIME_9060 __iomem *)
cy_pci_addr0)->mail_box_0); cy_pci_addr0)->mail_box_0);
if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) { if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) {
printk(" Warning: PCI I/O bit incorrectly set. " printk(" Warning: PCI I/O bit incorrectly "
"Ignoring it...\n"); "set. Ignoring it...\n");
pdev->resource[2].flags &= ~IORESOURCE_IO; pdev->resource[2].flags &= ~IORESOURCE_IO;
} }
...@@ -4868,17 +4991,21 @@ cy_detect_pci(void) ...@@ -4868,17 +4991,21 @@ cy_detect_pci(void)
request it from the kernel anyway, to avoid problems request it from the kernel anyway, to avoid problems
with other drivers accessing it. */ with other drivers accessing it. */
if (pci_request_regions(pdev, "Cyclades-Z") != 0) { if (pci_request_regions(pdev, "Cyclades-Z") != 0) {
printk(KERN_ERR "cyclades: failed to reserve PCI resources\n"); printk(KERN_ERR "cyclades: failed to reserve "
"PCI resources\n");
continue; continue;
} }
if (mailbox == ZE_V1) { if (mailbox == ZE_V1) {
cy_pci_addr2 = ioremap(cy_pci_phys2, CyPCI_Ze_win); cy_pci_addr2 = ioremap(cy_pci_phys2,
CyPCI_Ze_win);
if (ZeIndex == NR_CARDS) { if (ZeIndex == NR_CARDS) {
printk("Cyclades-Ze/PCI found at 0x%lx ", printk("Cyclades-Ze/PCI found at "
"0x%lx but no more cards can "
"be used.\nChange NR_CARDS in "
"cyclades.c and recompile "
"kernel.\n",
(ulong)cy_pci_phys2); (ulong)cy_pci_phys2);
printk("but no more cards can be used.\n");
printk("Change NR_CARDS in cyclades.c and recompile kernel.\n");
} else { } else {
Ze_phys0[ZeIndex] = cy_pci_phys0; Ze_phys0[ZeIndex] = cy_pci_phys0;
Ze_phys2[ZeIndex] = cy_pci_phys2; Ze_phys2[ZeIndex] = cy_pci_phys2;
...@@ -4891,30 +5018,37 @@ cy_detect_pci(void) ...@@ -4891,30 +5018,37 @@ cy_detect_pci(void)
i--; i--;
continue; continue;
} else { } else {
cy_pci_addr2 = ioremap(cy_pci_phys2, CyPCI_Zwin); cy_pci_addr2 = ioremap(cy_pci_phys2,CyPCI_Zwin);
} }
#ifdef CY_PCI_DEBUG #ifdef CY_PCI_DEBUG
printk("Cyclades-Z/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n", printk("Cyclades-Z/PCI: relocate winaddr=0x%lx "
(ulong)cy_pci_addr2, (ulong)cy_pci_addr0); "ctladdr=0x%lx\n",
(ulong) cy_pci_addr2, (ulong) cy_pci_addr0);
if (mailbox == ZO_V1) { if (mailbox == ZO_V1) {
cy_writel(&((struct RUNTIME_9060 *) cy_writel(&((struct RUNTIME_9060 *)
(cy_pci_addr0))->loc_addr_base, WIN_CREG); (cy_pci_addr0))->loc_addr_base,
WIN_CREG);
PAUSE PAUSE
printk("Cyclades-8Zo/PCI: FPGA id %lx, ver %lx\n", printk("Cyclades-8Zo/PCI: FPGA id %lx, ver "
(ulong)(0xff & cy_readl(&((struct CUSTOM_REG *) "%lx\n", (ulong) (0xff &
cy_readl(&((struct CUSTOM_REG *)
(cy_pci_addr2))->fpga_id)), (cy_pci_addr2))->fpga_id)),
(ulong)(0xff & cy_readl(&((struct CUSTOM_REG *) (ulong)(0xff &
(cy_pci_addr2))->fpga_version))); cy_readl(&((struct CUSTOM_REG *)
(cy_pci_addr2))->
fpga_version)));
cy_writel(&((struct RUNTIME_9060 *) cy_writel(&((struct RUNTIME_9060 *)
(cy_pci_addr0))->loc_addr_base, WIN_RAM); (cy_pci_addr0))->loc_addr_base,
WIN_RAM);
} else { } else {
printk("Cyclades-Z/PCI: New Cyclades-Z board. FPGA not loaded\n"); printk("Cyclades-Z/PCI: New Cyclades-Z board. "
"FPGA not loaded\n");
} }
#endif #endif
/* The following clears the firmware id word. This ensures /* The following clears the firmware id word. This
that the driver will not attempt to talk to the board ensures that the driver will not attempt to talk to
until it has been properly initialized. the board until it has been properly initialized.
*/ */
PAUSE PAUSE
if ((mailbox == ZO_V1) || (mailbox == ZO_V2)) if ((mailbox == ZO_V1) || (mailbox == ZO_V2))
...@@ -4925,48 +5059,47 @@ cy_detect_pci(void) ...@@ -4925,48 +5059,47 @@ cy_detect_pci(void)
be allocated its maximum number of ports. */ be allocated its maximum number of ports. */
cy_pci_nchan = 8; cy_pci_nchan = 8;
if((cy_next_channel+cy_pci_nchan) > NR_PORTS) { if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) {
printk("Cyclades-8Zo/PCI found at 0x%lx ", printk("Cyclades-8Zo/PCI found at 0x%lx but"
(ulong)cy_pci_phys2); "no channels are available.\nChange "
printk("but no channels are available.\n"); "NR_PORTS in cyclades.c and recompile "
printk("Change NR_PORTS in cyclades.c and recompile kernel.\n"); "kernel.\n", (ulong)cy_pci_phys2);
return(i); return (i);
} }
/* fill the next cy_card structure available */ /* fill the next cy_card structure available */
for (j = 0 ; j < NR_CARDS ; j++) { for (j = 0; j < NR_CARDS; j++) {
if (cy_card[j].base_addr == 0) break; if (cy_card[j].base_addr == 0)
break;
} }
if (j == NR_CARDS) { /* no more cy_cards available */ if (j == NR_CARDS) { /* no more cy_cards available */
printk("Cyclades-8Zo/PCI found at 0x%lx ", printk("Cyclades-8Zo/PCI found at 0x%lx but"
(ulong)cy_pci_phys2); "no more cards can be used.\nChange "
printk("but no more cards can be used.\n"); "NR_CARDS in cyclades.c and recompile "
printk("Change NR_CARDS in cyclades.c and recompile kernel.\n"); "kernel.\n", (ulong)cy_pci_phys2);
return(i); return (i);
} }
#ifdef CONFIG_CYZ_INTR #ifdef CONFIG_CYZ_INTR
/* allocate IRQ only if board has an IRQ */ /* allocate IRQ only if board has an IRQ */
if( (cy_pci_irq != 0) && (cy_pci_irq != 255) ) { if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) {
if(request_irq(cy_pci_irq, cyz_interrupt, if (request_irq(cy_pci_irq, cyz_interrupt,
IRQF_SHARED, "Cyclades-Z", &cy_card[j])) IRQF_SHARED, "Cyclades-Z",
{ &cy_card[j])) {
printk("Cyclom-8Zo/PCI found at 0x%lx ", printk("Cyclom-8Zo/PCI found at 0x%lx "
(ulong) cy_pci_phys2); "but could not allocate "
printk("but could not allocate IRQ%d.\n", "IRQ%d.\n", (ulong)cy_pci_phys2,
cy_pci_irq); cy_pci_irq);
return(i); return (i);
} }
} }
#endif /* CONFIG_CYZ_INTR */ #endif /* CONFIG_CYZ_INTR */
/* set cy_card */ /* set cy_card */
cy_card[j].base_phys = cy_pci_phys2; cy_card[j].base_phys = cy_pci_phys2;
cy_card[j].ctl_phys = cy_pci_phys0; cy_card[j].ctl_phys = cy_pci_phys0;
cy_card[j].base_addr = cy_pci_addr2; cy_card[j].base_addr = cy_pci_addr2;
cy_card[j].ctl_addr = cy_pci_addr0; cy_card[j].ctl_addr = cy_pci_addr0;
cy_card[j].irq = (int) cy_pci_irq; cy_card[j].irq = (int)cy_pci_irq;
cy_card[j].bus_index = 1; cy_card[j].bus_index = 1;
cy_card[j].first_line = cy_next_channel; cy_card[j].first_line = cy_next_channel;
cy_card[j].num_chips = -1; cy_card[j].num_chips = -1;
...@@ -4975,19 +5108,19 @@ cy_detect_pci(void) ...@@ -4975,19 +5108,19 @@ cy_detect_pci(void)
/* print message */ /* print message */
#ifdef CONFIG_CYZ_INTR #ifdef CONFIG_CYZ_INTR
/* don't report IRQ if board is no IRQ */ /* don't report IRQ if board is no IRQ */
if( (cy_pci_irq != 0) && (cy_pci_irq != 255) ) if ((cy_pci_irq != 0) && (cy_pci_irq != 255))
printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, IRQ%d, ", printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, "
j+1,(ulong)cy_pci_phys2, "IRQ%d, ", j + 1, (ulong)cy_pci_phys2,
(ulong)(cy_pci_phys2 + CyPCI_Zwin - 1), (ulong) (cy_pci_phys2 + CyPCI_Zwin - 1),
(int)cy_pci_irq); (int)cy_pci_irq);
else else
#endif /* CONFIG_CYZ_INTR */ #endif /* CONFIG_CYZ_INTR */
printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, ", printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, ",
j+1,(ulong)cy_pci_phys2, j + 1, (ulong)cy_pci_phys2,
(ulong)(cy_pci_phys2 + CyPCI_Zwin - 1)); (ulong)(cy_pci_phys2 + CyPCI_Zwin - 1));
printk("%d channels starting from port %d.\n", printk("%d channels starting from port %d.\n",
cy_pci_nchan,cy_next_channel); cy_pci_nchan, cy_next_channel);
cy_next_channel += cy_pci_nchan; cy_next_channel += cy_pci_nchan;
} }
} }
...@@ -4999,13 +5132,13 @@ cy_detect_pci(void) ...@@ -4999,13 +5132,13 @@ cy_detect_pci(void)
cy_pci_addr2 = Ze_addr2[0]; cy_pci_addr2 = Ze_addr2[0];
cy_pci_irq = Ze_irq[0]; cy_pci_irq = Ze_irq[0];
pdev = Ze_pdev[0]; pdev = Ze_pdev[0];
for (j = 0 ; j < ZeIndex-1 ; j++) { for (j = 0; j < ZeIndex - 1; j++) {
Ze_phys0[j] = Ze_phys0[j+1]; Ze_phys0[j] = Ze_phys0[j + 1];
Ze_phys2[j] = Ze_phys2[j+1]; Ze_phys2[j] = Ze_phys2[j + 1];
Ze_addr0[j] = Ze_addr0[j+1]; Ze_addr0[j] = Ze_addr0[j + 1];
Ze_addr2[j] = Ze_addr2[j+1]; Ze_addr2[j] = Ze_addr2[j + 1];
Ze_irq[j] = Ze_irq[j+1]; Ze_irq[j] = Ze_irq[j + 1];
Ze_pdev[j] = Ze_pdev[j+1]; Ze_pdev[j] = Ze_pdev[j + 1];
} }
ZeIndex--; ZeIndex--;
mailbox = (uclong)cy_readl(&((struct RUNTIME_9060 __iomem *) mailbox = (uclong)cy_readl(&((struct RUNTIME_9060 __iomem *)
...@@ -5013,43 +5146,44 @@ cy_detect_pci(void) ...@@ -5013,43 +5146,44 @@ cy_detect_pci(void)
#ifdef CY_PCI_DEBUG #ifdef CY_PCI_DEBUG
printk("Cyclades-Z/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n", printk("Cyclades-Z/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n",
(ulong)cy_pci_addr2, (ulong)cy_pci_addr0); (ulong)cy_pci_addr2, (ulong)cy_pci_addr0);
printk("Cyclades-Z/PCI: New Cyclades-Z board. FPGA not loaded\n"); printk("Cyclades-Z/PCI: New Cyclades-Z board. FPGA not "
"loaded\n");
#endif #endif
PAUSE PAUSE
/* This must be the new Cyclades-Ze/PCI. */ /* This must be the new Cyclades-Ze/PCI. */
cy_pci_nchan = ZE_V1_NPORTS; cy_pci_nchan = ZE_V1_NPORTS;
if((cy_next_channel+cy_pci_nchan) > NR_PORTS) { if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) {
printk("Cyclades-Ze/PCI found at 0x%lx ", printk("Cyclades-Ze/PCI found at 0x%lx but no channels "
(ulong)cy_pci_phys2); "are available.\nChange NR_PORTS in cyclades.c "
printk("but no channels are available.\n"); "and recompile kernel.\n",
printk("Change NR_PORTS in cyclades.c and recompile kernel.\n"); (ulong) cy_pci_phys2);
return(i); return (i);
} }
/* fill the next cy_card structure available */ /* fill the next cy_card structure available */
for (j = 0 ; j < NR_CARDS ; j++) { for (j = 0; j < NR_CARDS; j++) {
if (cy_card[j].base_addr == 0) break; if (cy_card[j].base_addr == 0)
break;
} }
if (j == NR_CARDS) { /* no more cy_cards available */ if (j == NR_CARDS) { /* no more cy_cards available */
printk("Cyclades-Ze/PCI found at 0x%lx ", printk("Cyclades-Ze/PCI found at 0x%lx but no more "
(ulong)cy_pci_phys2); "cards can be used.\nChange NR_CARDS in "
printk("but no more cards can be used.\n"); "cyclades.c and recompile kernel.\n",
printk("Change NR_CARDS in cyclades.c and recompile kernel.\n"); (ulong) cy_pci_phys2);
return(i); return (i);
} }
#ifdef CONFIG_CYZ_INTR #ifdef CONFIG_CYZ_INTR
/* allocate IRQ only if board has an IRQ */ /* allocate IRQ only if board has an IRQ */
if( (cy_pci_irq != 0) && (cy_pci_irq != 255) ) { if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) {
if(request_irq(cy_pci_irq, cyz_interrupt, if (request_irq(cy_pci_irq, cyz_interrupt,
IRQF_SHARED, "Cyclades-Z", &cy_card[j])) IRQF_SHARED, "Cyclades-Z",
{ &cy_card[j])) {
printk("Cyclom-Ze/PCI found at 0x%lx ", printk("Cyclom-Ze/PCI found at 0x%lx ",
(ulong) cy_pci_phys2); (ulong) cy_pci_phys2);
printk("but could not allocate IRQ%d.\n", printk("but could not allocate IRQ%d.\n",
cy_pci_irq); cy_pci_irq);
return(i); return (i);
} }
} }
#endif /* CONFIG_CYZ_INTR */ #endif /* CONFIG_CYZ_INTR */
...@@ -5059,7 +5193,7 @@ cy_detect_pci(void) ...@@ -5059,7 +5193,7 @@ cy_detect_pci(void)
cy_card[j].ctl_phys = cy_pci_phys0; cy_card[j].ctl_phys = cy_pci_phys0;
cy_card[j].base_addr = cy_pci_addr2; cy_card[j].base_addr = cy_pci_addr2;
cy_card[j].ctl_addr = cy_pci_addr0; cy_card[j].ctl_addr = cy_pci_addr0;
cy_card[j].irq = (int) cy_pci_irq; cy_card[j].irq = (int)cy_pci_irq;
cy_card[j].bus_index = 1; cy_card[j].bus_index = 1;
cy_card[j].first_line = cy_next_channel; cy_card[j].first_line = cy_next_channel;
cy_card[j].num_chips = -1; cy_card[j].num_chips = -1;
...@@ -5068,50 +5202,49 @@ cy_detect_pci(void) ...@@ -5068,50 +5202,49 @@ cy_detect_pci(void)
/* print message */ /* print message */
#ifdef CONFIG_CYZ_INTR #ifdef CONFIG_CYZ_INTR
/* don't report IRQ if board is no IRQ */ /* don't report IRQ if board is no IRQ */
if( (cy_pci_irq != 0) && (cy_pci_irq != 255) ) if ((cy_pci_irq != 0) && (cy_pci_irq != 255))
printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, IRQ%d, ", printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, IRQ%d, ",
j+1,(ulong)cy_pci_phys2, j + 1, (ulong) cy_pci_phys2,
(ulong)(cy_pci_phys2 + CyPCI_Ze_win - 1), (ulong) (cy_pci_phys2 + CyPCI_Ze_win - 1),
(int)cy_pci_irq); (int)cy_pci_irq);
else else
#endif /* CONFIG_CYZ_INTR */ #endif /* CONFIG_CYZ_INTR */
printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, ", printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, ",
j+1,(ulong)cy_pci_phys2, j + 1, (ulong) cy_pci_phys2,
(ulong)(cy_pci_phys2 + CyPCI_Ze_win - 1)); (ulong) (cy_pci_phys2 + CyPCI_Ze_win - 1));
printk("%d channels starting from port %d.\n", printk("%d channels starting from port %d.\n",
cy_pci_nchan,cy_next_channel); cy_pci_nchan, cy_next_channel);
cy_next_channel += cy_pci_nchan; cy_next_channel += cy_pci_nchan;
} }
if (ZeIndex != 0) { if (ZeIndex != 0) {
printk("Cyclades-Ze/PCI found at 0x%x ", printk("Cyclades-Ze/PCI found at 0x%x but no more cards can be "
(unsigned int) Ze_phys2[0]); "used.\nChange NR_CARDS in cyclades.c and recompile "
printk("but no more cards can be used.\n"); "kernel.\n", (unsigned int)Ze_phys2[0]);
printk("Change NR_CARDS in cyclades.c and recompile kernel.\n");
} }
return(i); return (i);
#else #else
return(0); return (0);
#endif /* ifdef CONFIG_PCI */ #endif /* ifdef CONFIG_PCI */
} /* cy_detect_pci */ } /* cy_detect_pci */
/* /*
* This routine prints out the appropriate serial driver version number * This routine prints out the appropriate serial driver version number
* and identifies which options were configured into this driver. * and identifies which options were configured into this driver.
*/ */
static inline void static inline void show_version(void)
show_version(void)
{ {
char *rcsvers, *rcsdate, *tmp; char *rcsvers, *rcsdate, *tmp;
rcsvers = strchr(rcsid, ' '); rcsvers++; rcsvers = strchr(rcsid, ' ');
tmp = strchr(rcsvers, ' '); *tmp++ = '\0'; rcsvers++;
rcsdate = strchr(tmp, ' '); rcsdate++; tmp = strchr(rcsvers, ' ');
tmp = strrchr(rcsdate, ' '); *tmp = '\0'; *tmp++ = '\0';
printk("Cyclades driver %s %s\n", rcsdate = strchr(tmp, ' ');
rcsvers, rcsdate); rcsdate++;
printk(" built %s %s\n", tmp = strrchr(rcsdate, ' ');
__DATE__, __TIME__); *tmp = '\0';
printk("Cyclades driver %s %s\n", rcsvers, rcsdate);
printk(" built %s %s\n", __DATE__, __TIME__);
} /* show_version */ } /* show_version */
static int static int
...@@ -5120,13 +5253,14 @@ cyclades_get_proc_info(char *buf, char **start, off_t offset, int length, ...@@ -5120,13 +5253,14 @@ cyclades_get_proc_info(char *buf, char **start, off_t offset, int length,
{ {
struct cyclades_port *info; struct cyclades_port *info;
int i; int i;
int len=0; int len = 0;
off_t begin=0; off_t begin = 0;
off_t pos=0; off_t pos = 0;
int size; int size;
__u32 cur_jifs = jiffies; __u32 cur_jifs = jiffies;
size = sprintf(buf, "Dev TimeOpen BytesOut IdleOut BytesIn IdleIn Overruns Ldisc\n"); size = sprintf(buf, "Dev TimeOpen BytesOut IdleOut BytesIn "
"IdleIn Overruns Ldisc\n");
pos += size; pos += size;
len += size; len += size;
...@@ -5136,19 +5270,21 @@ cyclades_get_proc_info(char *buf, char **start, off_t offset, int length, ...@@ -5136,19 +5270,21 @@ cyclades_get_proc_info(char *buf, char **start, off_t offset, int length,
info = &cy_port[i]; info = &cy_port[i];
if (info->count) if (info->count)
size = sprintf(buf+len, size = sprintf(buf + len, "%3d %8lu %10lu %8lu %10lu "
"%3d %8lu %10lu %8lu %10lu %8lu %9lu %6ld\n", "%8lu %9lu %6ld\n", info->line,
info->line, JIFFIES_DIFF(info->idle_stats.in_use,
JIFFIES_DIFF(info->idle_stats.in_use, cur_jifs) / HZ, cur_jifs) / HZ,
info->idle_stats.xmit_bytes, info->idle_stats.xmit_bytes,
JIFFIES_DIFF(info->idle_stats.xmit_idle, cur_jifs) / HZ, JIFFIES_DIFF(info->idle_stats.xmit_idle,
cur_jifs) / HZ,
info->idle_stats.recv_bytes, info->idle_stats.recv_bytes,
JIFFIES_DIFF(info->idle_stats.recv_idle, cur_jifs) / HZ, JIFFIES_DIFF(info->idle_stats.recv_idle,
cur_jifs) / HZ,
info->idle_stats.overruns, info->idle_stats.overruns,
(long) info->tty->ldisc.num); (long)info->tty->ldisc.num);
else else
size = sprintf(buf+len, size = sprintf(buf + len, "%3d %8lu %10lu %8lu %10lu "
"%3d %8lu %10lu %8lu %10lu %8lu %9lu %6ld\n", "%8lu %9lu %6ld\n",
info->line, 0L, 0L, 0L, 0L, 0L, 0L, 0L); info->line, 0L, 0L, 0L, 0L, 0L, 0L, 0L);
len += size; len += size;
pos = begin + len; pos = begin + len;
...@@ -5212,13 +5348,12 @@ static const struct tty_operations cy_ops = { ...@@ -5212,13 +5348,12 @@ static const struct tty_operations cy_ops = {
.tiocmset = cy_tiocmset, .tiocmset = cy_tiocmset,
}; };
static int __init static int __init cy_init(void)
cy_init(void)
{ {
struct cyclades_port *info; struct cyclades_port *info;
struct cyclades_card *cinfo; struct cyclades_card *cinfo;
int number_z_boards = 0; int number_z_boards = 0;
int board,port,i,index; int board, port, i, index;
unsigned long mailbox; unsigned long mailbox;
unsigned short chip_number; unsigned short chip_number;
int nports; int nports;
...@@ -5267,7 +5402,7 @@ cy_init(void) ...@@ -5267,7 +5402,7 @@ cy_init(void)
cy_nboard = cy_isa_nboard + cy_pci_nboard; cy_nboard = cy_isa_nboard + cy_pci_nboard;
/* invalidate remaining cy_card structures */ /* invalidate remaining cy_card structures */
for (i = 0 ; i < NR_CARDS ; i++) { for (i = 0; i < NR_CARDS; i++) {
if (cy_card[i].base_addr == 0) { if (cy_card[i].base_addr == 0) {
cy_card[i].first_line = -1; cy_card[i].first_line = -1;
cy_card[i].ctl_addr = NULL; cy_card[i].ctl_addr = NULL;
...@@ -5278,27 +5413,26 @@ cy_init(void) ...@@ -5278,27 +5413,26 @@ cy_init(void)
} }
} }
/* invalidate remaining cy_port structures */ /* invalidate remaining cy_port structures */
for (i = cy_next_channel ; i < NR_PORTS ; i++) { for (i = cy_next_channel; i < NR_PORTS; i++) {
cy_port[i].line = -1; cy_port[i].line = -1;
cy_port[i].magic = -1; cy_port[i].magic = -1;
} }
/* initialize per-port data structures for each valid board found */ /* initialize per-port data structures for each valid board found */
for (board = 0 ; board < cy_nboard ; board++) { for (board = 0; board < cy_nboard; board++) {
cinfo = &cy_card[board]; cinfo = &cy_card[board];
if (cinfo->num_chips == -1) { /* Cyclades-Z */ if (cinfo->num_chips == -1) { /* Cyclades-Z */
number_z_boards++; number_z_boards++;
mailbox = cy_readl(&((struct RUNTIME_9060 __iomem *) mailbox = cy_readl(&((struct RUNTIME_9060 __iomem *)
cy_card[board].ctl_addr)->mail_box_0); cy_card[board].ctl_addr)->
mail_box_0);
nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8; nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8;
cinfo->intr_enabled = 0; cinfo->intr_enabled = 0;
cinfo->nports = 0; /* Will be correctly set later, after cinfo->nports = 0; /* Will be correctly set later, after
Z FW is loaded */ Z FW is loaded */
spin_lock_init(&cinfo->card_lock); spin_lock_init(&cinfo->card_lock);
for (port = cinfo->first_line ; for (port = cinfo->first_line;
port < cinfo->first_line + nports; port < cinfo->first_line + nports; port++) {
port++)
{
info = &cy_port[port]; info = &cy_port[port];
info->magic = CYCLADES_MAGIC; info->magic = CYCLADES_MAGIC;
info->type = PORT_STARTECH; info->type = PORT_STARTECH;
...@@ -5310,7 +5444,8 @@ cy_init(void) ...@@ -5310,7 +5444,8 @@ cy_init(void)
if (mailbox == ZO_V1) if (mailbox == ZO_V1)
info->xmit_fifo_size = CYZ_FIFO_SIZE; info->xmit_fifo_size = CYZ_FIFO_SIZE;
else else
info->xmit_fifo_size = 4 * CYZ_FIFO_SIZE; info->xmit_fifo_size =
4 * CYZ_FIFO_SIZE;
info->cor1 = 0; info->cor1 = 0;
info->cor2 = 0; info->cor2 = 0;
info->cor3 = 0; info->cor3 = 0;
...@@ -5321,7 +5456,7 @@ cy_init(void) ...@@ -5321,7 +5456,7 @@ cy_init(void)
info->rbpr = 0; info->rbpr = 0;
info->rco = 0; info->rco = 0;
info->custom_divisor = 0; info->custom_divisor = 0;
info->close_delay = 5*HZ/10; info->close_delay = 5 * HZ / 10;
info->closing_wait = CLOSING_WAIT_DELAY; info->closing_wait = CLOSING_WAIT_DELAY;
info->icount.cts = info->icount.dsr = info->icount.cts = info->icount.dsr =
info->icount.rng = info->icount.dcd = 0; info->icount.rng = info->icount.dcd = 0;
...@@ -5354,14 +5489,12 @@ cy_init(void) ...@@ -5354,14 +5489,12 @@ cy_init(void)
#endif #endif
} }
continue; continue;
}else{ /* Cyclom-Y of some kind*/ } else { /* Cyclom-Y of some kind */
index = cinfo->bus_index; index = cinfo->bus_index;
spin_lock_init(&cinfo->card_lock); spin_lock_init(&cinfo->card_lock);
cinfo->nports = CyPORTS_PER_CHIP * cinfo->num_chips; cinfo->nports = CyPORTS_PER_CHIP * cinfo->num_chips;
for (port = cinfo->first_line ; for (port = cinfo->first_line;
port < cinfo->first_line + cinfo->nports ; port < cinfo->first_line + cinfo->nports; port++) {
port++)
{
info = &cy_port[port]; info = &cy_port[port];
info->magic = CYCLADES_MAGIC; info->magic = CYCLADES_MAGIC;
info->type = PORT_CIRRUS; info->type = PORT_CIRRUS;
...@@ -5370,13 +5503,14 @@ cy_init(void) ...@@ -5370,13 +5503,14 @@ cy_init(void)
info->flags = STD_COM_FLAGS; info->flags = STD_COM_FLAGS;
info->tty = NULL; info->tty = NULL;
info->xmit_fifo_size = CyMAX_CHAR_FIFO; info->xmit_fifo_size = CyMAX_CHAR_FIFO;
info->cor1 = CyPARITY_NONE|Cy_1_STOP|Cy_8_BITS; info->cor1 =
CyPARITY_NONE | Cy_1_STOP | Cy_8_BITS;
info->cor2 = CyETC; info->cor2 = CyETC;
info->cor3 = 0x08; /* _very_ small rcv threshold */ info->cor3 = 0x08; /* _very_ small rcv threshold */
info->cor4 = 0; info->cor4 = 0;
info->cor5 = 0; info->cor5 = 0;
info->custom_divisor = 0; info->custom_divisor = 0;
info->close_delay = 5*HZ/10; info->close_delay = 5 * HZ / 10;
info->closing_wait = CLOSING_WAIT_DELAY; info->closing_wait = CLOSING_WAIT_DELAY;
info->icount.cts = info->icount.dsr = info->icount.cts = info->icount.dsr =
info->icount.rng = info->icount.dcd = 0; info->icount.rng = info->icount.dcd = 0;
...@@ -5386,8 +5520,9 @@ cy_init(void) ...@@ -5386,8 +5520,9 @@ cy_init(void)
chip_number = (port - cinfo->first_line) / 4; chip_number = (port - cinfo->first_line) / 4;
if ((info->chip_rev = if ((info->chip_rev =
cy_readb(cinfo->base_addr + cy_readb(cinfo->base_addr +
(cy_chip_offset[chip_number]<<index) + (cy_chip_offset[chip_number] <<
(CyGFRCR<<index))) >= CD1400_REV_J) { index) + (CyGFRCR << index))) >=
CD1400_REV_J) {
/* It is a CD1400 rev. J or later */ /* It is a CD1400 rev. J or later */
info->tbpr = baud_bpr_60[13]; /* Tx BPR */ info->tbpr = baud_bpr_60[13]; /* Tx BPR */
info->tco = baud_co_60[13]; /* Tx CO */ info->tco = baud_co_60[13]; /* Tx CO */
...@@ -5417,15 +5552,15 @@ cy_init(void) ...@@ -5417,15 +5552,15 @@ cy_init(void)
/* info->session */ /* info->session */
/* info->pgrp */ /* info->pgrp */
info->read_status_mask = info->read_status_mask =
CyTIMEOUT| CySPECHAR| CyBREAK CyTIMEOUT | CySPECHAR | CyBREAK
| CyPARITY| CyFRAME| CyOVERRUN; | CyPARITY | CyFRAME | CyOVERRUN;
/* info->timeout */ /* info->timeout */
} }
} }
} }
#ifndef CONFIG_CYZ_INTR #ifndef CONFIG_CYZ_INTR
if (number_z_boards && !cyz_timeron){ if (number_z_boards && !cyz_timeron) {
cyz_timeron++; cyz_timeron++;
cyz_timerlist.expires = jiffies + 1; cyz_timerlist.expires = jiffies + 1;
add_timer(&cyz_timerlist); add_timer(&cyz_timerlist);
...@@ -5439,8 +5574,7 @@ cy_init(void) ...@@ -5439,8 +5574,7 @@ cy_init(void)
} /* cy_init */ } /* cy_init */
static void __exit static void __exit cy_cleanup_module(void)
cy_cleanup_module(void)
{ {
int i, e1; int i, e1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册