Commit 44bafdf3 authored by Jiri Slaby's avatar Jiri Slaby Committed by Linus Torvalds

[PATCH] Char: serial167, cleanup

serial167, cleanup

- Lindent the code
- remove 3 pointers from paranoia_check
Signed-off-by: default avatarJiri Slaby <jirislaby@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 30a063a9
...@@ -112,11 +112,12 @@ u_char initial_console_speed; ...@@ -112,11 +112,12 @@ u_char initial_console_speed;
/* This is the per-port data structure */ /* This is the per-port data structure */
struct cyclades_port cy_port[] = { struct cyclades_port cy_port[] = {
/* CARD# */ /* CARD# */
{-1 }, /* ttyS0 */ {-1}, /* ttyS0 */
{-1 }, /* ttyS1 */ {-1}, /* ttyS1 */
{-1 }, /* ttyS2 */ {-1}, /* ttyS2 */
{-1 }, /* ttyS3 */ {-1}, /* ttyS3 */
}; };
#define NR_PORTS ARRAY_SIZE(cy_port) #define NR_PORTS ARRAY_SIZE(cy_port)
/* /*
...@@ -129,19 +130,22 @@ struct cyclades_port cy_port[] = { ...@@ -129,19 +130,22 @@ struct cyclades_port cy_port[] = {
*/ */
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,
0}; 0
};
#if 0 #if 0
static char baud_co[] = { /* 25 MHz clock option table */ static char baud_co[] = { /* 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 MHz baud rate period table */ static char baud_bpr[] = { /* 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
};
#endif #endif
/* I think 166 brd clocks 2401 at 20MHz.... */ /* I think 166 brd clocks 2401 at 20MHz.... */
...@@ -149,21 +153,22 @@ static char baud_bpr[] = { /* 25 MHz baud rate period table */ ...@@ -149,21 +153,22 @@ static char baud_bpr[] = { /* 25 MHz baud rate period table */
/* These values are written directly to tcor, and >> 5 for writing to rcor */ /* These values are written directly to tcor, and >> 5 for writing to rcor */
static u_char baud_co[] = { /* 20 MHz clock option table */ static u_char baud_co[] = { /* 20 MHz clock option table */
0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x60, 0x60, 0x40, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x60, 0x60, 0x40,
0x40, 0x40, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 0x40, 0x40, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/* These values written directly to tbpr/rbpr */ /* These values written directly to tbpr/rbpr */
static u_char baud_bpr[] = { /* 20 MHz baud rate period table */ static u_char baud_bpr[] = { /* 20 MHz baud rate period table */
0x00, 0xc0, 0x80, 0x58, 0x6c, 0x40, 0xc0, 0x81, 0x40, 0x81, 0x00, 0xc0, 0x80, 0x58, 0x6c, 0x40, 0xc0, 0x81, 0x40, 0x81,
0x57, 0x40, 0x81, 0x40, 0x81, 0x40, 0x2b, 0x20, 0x15, 0x10}; 0x57, 0x40, 0x81, 0x40, 0x81, 0x40, 0x2b, 0x20, 0x15, 0x10
};
static u_char baud_cor4[] = { /* receive threshold */ static u_char baud_cor4[] = { /* 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
};
static void shutdown(struct cyclades_port *); static void shutdown(struct cyclades_port *);
static int startup (struct cyclades_port *); static int startup(struct cyclades_port *);
static void cy_throttle(struct tty_struct *); static void cy_throttle(struct tty_struct *);
static void cy_unthrottle(struct tty_struct *); static void cy_unthrottle(struct tty_struct *);
static void config_setup(struct cyclades_port *); static void config_setup(struct cyclades_port *);
...@@ -174,7 +179,7 @@ static void show_status(int); ...@@ -174,7 +179,7 @@ static void show_status(int);
#ifdef CONFIG_REMOTE_DEBUG #ifdef CONFIG_REMOTE_DEBUG
static void debug_setup(void); static void debug_setup(void);
void queueDebugChar (int c); void queueDebugChar(int c);
int getDebugChar(void); int getDebugChar(void);
#define DEBUG_PORT 1 #define DEBUG_PORT 1
...@@ -196,7 +201,7 @@ debugq debugiq; ...@@ -196,7 +201,7 @@ debugq debugiq;
* delay, but this wild guess will do for now. * delay, but this wild guess will do for now.
*/ */
void my_udelay (long us) void my_udelay(long us)
{ {
u_char x; u_char x;
volatile u_char *p = &x; volatile u_char *p = &x;
...@@ -207,31 +212,26 @@ void my_udelay (long us) ...@@ -207,31 +212,26 @@ void my_udelay (long us)
x |= *p; x |= *p;
} }
static inline int static inline int serial_paranoia_check(struct cyclades_port *info, char *name,
serial_paranoia_check(struct cyclades_port *info, char *name,
const char *routine) const char *routine)
{ {
#ifdef SERIAL_PARANOIA_CHECK #ifdef SERIAL_PARANOIA_CHECK
static const char *badmagic =
"Warning: bad magic number for serial struct (%s) in %s\n";
static const char *badinfo =
"Warning: null cyclades_port for (%s) in %s\n";
static const char *badrange =
"Warning: cyclades_port out of range for (%s) in %s\n";
if (!info) { if (!info) {
printk(badinfo, name, routine); printk("Warning: null cyclades_port for (%s) in %s\n", name,
routine);
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("Warning: cyclades_port out of range for (%s) in %s\n",
name, routine);
return 1; return 1;
} }
if (info->magic != CYCLADES_MAGIC) { if (info->magic != CYCLADES_MAGIC) {
printk(badmagic, name, routine); printk("Warning: bad magic number for serial struct (%s) in "
"%s\n", name, routine);
return 1; return 1;
} }
#endif #endif
...@@ -242,27 +242,43 @@ serial_paranoia_check(struct cyclades_port *info, char *name, ...@@ -242,27 +242,43 @@ serial_paranoia_check(struct cyclades_port *info, char *name,
/* The following diagnostic routines allow the driver to spew /* The following diagnostic routines allow the driver to spew
information on the screen, even (especially!) during interrupts. information on the screen, even (especially!) during interrupts.
*/ */
void void SP(char *data)
SP(char *data){ {
unsigned long flags; unsigned long flags;
local_irq_save(flags); local_irq_save(flags);
console_print(data); console_print(data);
local_irq_restore(flags); local_irq_restore(flags);
} }
char scrn[2]; char scrn[2];
void void CP(char data)
CP(char data){ {
unsigned long flags; unsigned long flags;
local_irq_save(flags); local_irq_save(flags);
scrn[0] = data; scrn[0] = data;
console_print(scrn); console_print(scrn);
local_irq_restore(flags); local_irq_restore(flags);
}/* CP */ } /* CP */
void CP1(int data) { (data<10)? CP(data+'0'): CP(data+'A'-10); }/* CP1 */ void CP1(int data)
void CP2(int data) { CP1((data>>4) & 0x0f); CP1( data & 0x0f); }/* CP2 */ {
void CP4(int data) { CP2((data>>8) & 0xff); CP2(data & 0xff); }/* CP4 */ (data < 10) ? CP(data + '0') : CP(data + 'A' - 10);
void CP8(long data) { CP4((data>>16) & 0xffff); CP4(data & 0xffff); }/* CP8 */ } /* CP1 */
void CP2(int data)
{
CP1((data >> 4) & 0x0f);
CP1(data & 0x0f);
} /* CP2 */
void CP4(int data)
{
CP2((data >> 8) & 0xff);
CP2(data & 0xff);
} /* CP4 */
void CP8(long data)
{
CP4((data >> 16) & 0xffff);
CP4(data & 0xffff);
} /* CP8 */
#endif #endif
/* This routine waits up to 1000 micro-seconds for the previous /* This routine waits up to 1000 micro-seconds for the previous
...@@ -270,23 +286,22 @@ void CP8(long data) { CP4((data>>16) & 0xffff); CP4(data & 0xffff); }/* CP8 */ ...@@ -270,23 +286,22 @@ void CP8(long data) { CP4((data>>16) & 0xffff); CP4(data & 0xffff); }/* CP8 */
new command. An error is returned if the previous command new command. An error is returned if the previous command
didn't finish within the time limit. didn't finish within the time limit.
*/ */
u_short u_short write_cy_cmd(volatile u_char * base_addr, u_char cmd)
write_cy_cmd(volatile u_char *base_addr, u_char cmd)
{ {
unsigned long flags; unsigned long flags;
volatile int i; volatile int i;
local_irq_save(flags); local_irq_save(flags);
/* 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 (base_addr[CyCCR] == 0){ if (base_addr[CyCCR] == 0) {
break; break;
} }
my_udelay(10L); my_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 == 10 ) { if (i == 10) {
local_irq_restore(flags); local_irq_restore(flags);
return (-1); return (-1);
} }
...@@ -294,15 +309,13 @@ write_cy_cmd(volatile u_char *base_addr, u_char cmd) ...@@ -294,15 +309,13 @@ write_cy_cmd(volatile u_char *base_addr, u_char cmd)
/* Issue the new command */ /* Issue the new command */
base_addr[CyCCR] = cmd; base_addr[CyCCR] = cmd;
local_irq_restore(flags); local_irq_restore(flags);
return(0); return (0);
} /* write_cy_cmd */ } /* write_cy_cmd */
/* 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_port *info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
...@@ -319,15 +332,12 @@ cy_stop(struct tty_struct *tty) ...@@ -319,15 +332,12 @@ cy_stop(struct tty_struct *tty)
channel = info->line; channel = info->line;
local_irq_save(flags); local_irq_save(flags);
base_addr[CyCAR] = (u_char)(channel); /* index channel */ base_addr[CyCAR] = (u_char) (channel); /* index channel */
base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy); base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
local_irq_restore(flags); local_irq_restore(flags);
return;
} /* cy_stop */ } /* cy_stop */
static void static void cy_start(struct tty_struct *tty)
cy_start(struct tty_struct *tty)
{ {
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
...@@ -344,34 +354,28 @@ cy_start(struct tty_struct *tty) ...@@ -344,34 +354,28 @@ cy_start(struct tty_struct *tty)
channel = info->line; channel = info->line;
local_irq_save(flags); local_irq_save(flags);
base_addr[CyCAR] = (u_char)(channel); base_addr[CyCAR] = (u_char) (channel);
base_addr[CyIER] |= CyTxMpty; base_addr[CyIER] |= CyTxMpty;
local_irq_restore(flags); local_irq_restore(flags);
return;
} /* cy_start */ } /* cy_start */
/* /*
* This routine is used by the interrupt handler to schedule * This routine is used by the interrupt handler to schedule
* processing in the software interrupt portion of the driver * processing in the software interrupt portion of the driver
* (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 */
/* The real interrupt service routines are called /* The real interrupt service routines are called
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 cd2401_rxerr_interrupt(int irq, void *dev_id)
cd2401_rxerr_interrupt(int irq, void *dev_id)
{ {
struct tty_struct *tty; struct tty_struct *tty;
struct cyclades_port *info; struct cyclades_port *info;
...@@ -381,7 +385,7 @@ cd2401_rxerr_interrupt(int irq, void *dev_id) ...@@ -381,7 +385,7 @@ cd2401_rxerr_interrupt(int irq, void *dev_id)
char data; char data;
/* determine the channel and change to that context */ /* determine the channel and change to that context */
channel = (u_short ) (base_addr[CyLICR] >> 2); channel = (u_short) (base_addr[CyLICR] >> 2);
info = &cy_port[channel]; info = &cy_port[channel];
info->last_active = jiffies; info->last_active = jiffies;
...@@ -400,48 +404,54 @@ cd2401_rxerr_interrupt(int irq, void *dev_id) ...@@ -400,48 +404,54 @@ cd2401_rxerr_interrupt(int irq, void *dev_id)
data = 0; data = 0;
/* 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) {
base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS; base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
return IRQ_HANDLED; return IRQ_HANDLED;
} } else { /* there is an open port for this data */
else { /* there is an open port for this data */
tty = info->tty; tty = info->tty;
if(err & info->ignore_status_mask){ if (err & info->ignore_status_mask) {
base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS; base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
return IRQ_HANDLED; return IRQ_HANDLED;
} }
if (tty_buffer_request_room(tty, 1) != 0){ if (tty_buffer_request_room(tty, 1) != 0) {
if (err & info->read_status_mask){ if (err & info->read_status_mask) {
if(err & CyBREAK){ if (err & CyBREAK) {
tty_insert_flip_char(tty, data, TTY_BREAK); tty_insert_flip_char(tty, data,
if (info->flags & ASYNC_SAK){ TTY_BREAK);
if (info->flags & ASYNC_SAK) {
do_SAK(tty); do_SAK(tty);
} }
}else if(err & CyFRAME){ } else if (err & CyFRAME) {
tty_insert_flip_char(tty, data, TTY_FRAME); tty_insert_flip_char(tty, data,
}else if(err & CyPARITY){ TTY_FRAME);
tty_insert_flip_char(tty, data, TTY_PARITY); } else if (err & CyPARITY) {
}else if(err & CyOVERRUN){ tty_insert_flip_char(tty, data,
tty_insert_flip_char(tty, 0, TTY_OVERRUN); TTY_PARITY);
} else if (err & CyOVERRUN) {
tty_insert_flip_char(tty, 0,
TTY_OVERRUN);
/* /*
If the flip buffer itself is If the flip buffer itself is
overflowing, we still loose overflowing, we still loose
the next incoming character. the next incoming character.
*/ */
if (tty_buffer_request_room(tty, 1) != 0){ if (tty_buffer_request_room(tty, 1) !=
tty_insert_flip_char(tty, data, TTY_FRAME); 0) {
tty_insert_flip_char(tty, data,
TTY_FRAME);
} }
/* 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);
} }
}else{ } else {
tty_insert_flip_char(tty, data, TTY_NORMAL); tty_insert_flip_char(tty, data, TTY_NORMAL);
} }
}else{ } else {
/* there was a software buffer overrun /* there was a software buffer overrun
and nothing could be done about it!!! */ and nothing could be done about it!!! */
} }
...@@ -452,8 +462,7 @@ cd2401_rxerr_interrupt(int irq, void *dev_id) ...@@ -452,8 +462,7 @@ cd2401_rxerr_interrupt(int irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} /* cy_rxerr_interrupt */ } /* cy_rxerr_interrupt */
static irqreturn_t static irqreturn_t cd2401_modem_interrupt(int irq, void *dev_id)
cd2401_modem_interrupt(int irq, void *dev_id)
{ {
struct cyclades_port *info; struct cyclades_port *info;
volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
...@@ -461,21 +470,20 @@ cd2401_modem_interrupt(int irq, void *dev_id) ...@@ -461,21 +470,20 @@ cd2401_modem_interrupt(int irq, void *dev_id)
int mdm_change; int mdm_change;
int mdm_status; int mdm_status;
/* determine the channel and change to that context */ /* determine the channel and change to that context */
channel = (u_short ) (base_addr[CyLICR] >> 2); channel = (u_short) (base_addr[CyLICR] >> 2);
info = &cy_port[channel]; info = &cy_port[channel];
info->last_active = jiffies; info->last_active = jiffies;
mdm_change = base_addr[CyMISR]; mdm_change = base_addr[CyMISR];
mdm_status = base_addr[CyMSVR1]; mdm_status = base_addr[CyMSVR1];
if(info->tty == 0){ /* nowhere to put the data, ignore it */ if (info->tty == 0) { /* nowhere to put the data, ignore it */
; ;
}else{ } else {
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) {
/* CP('!'); */ /* CP('!'); */
cy_sched_event(info, Cy_EVENT_OPEN_WAKEUP); cy_sched_event(info, Cy_EVENT_OPEN_WAKEUP);
} else { } else {
...@@ -483,32 +491,33 @@ cd2401_modem_interrupt(int irq, void *dev_id) ...@@ -483,32 +491,33 @@ cd2401_modem_interrupt(int irq, void *dev_id)
cy_sched_event(info, Cy_EVENT_HANGUP); cy_sched_event(info, Cy_EVENT_HANGUP);
} }
} }
if((mdm_change & CyCTS) if ((mdm_change & CyCTS)
&& (info->flags & ASYNC_CTS_FLOW)){ && (info->flags & ASYNC_CTS_FLOW)) {
if(info->tty->stopped){ if (info->tty->stopped) {
if(mdm_status & CyCTS){ if (mdm_status & CyCTS) {
/* !!! cy_start isn't used because... */ /* !!! cy_start isn't used because... */
info->tty->stopped = 0; info->tty->stopped = 0;
base_addr[CyIER] |= CyTxMpty; base_addr[CyIER] |= CyTxMpty;
cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP); cy_sched_event(info,
Cy_EVENT_WRITE_WAKEUP);
} }
}else{ } else {
if(!(mdm_status & CyCTS)){ if (!(mdm_status & CyCTS)) {
/* !!! cy_stop isn't used because... */ /* !!! cy_stop isn't used because... */
info->tty->stopped = 1; info->tty->stopped = 1;
base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy); base_addr[CyIER] &=
~(CyTxMpty | CyTxRdy);
} }
} }
} }
if(mdm_status & CyDSR){ if (mdm_status & CyDSR) {
} }
} }
base_addr[CyMEOIR] = 0; base_addr[CyMEOIR] = 0;
return IRQ_HANDLED; return IRQ_HANDLED;
} /* cy_modem_interrupt */ } /* cy_modem_interrupt */
static irqreturn_t static irqreturn_t cd2401_tx_interrupt(int irq, void *dev_id)
cd2401_tx_interrupt(int irq, void *dev_id)
{ {
struct cyclades_port *info; struct cyclades_port *info;
volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
...@@ -517,25 +526,25 @@ cd2401_tx_interrupt(int irq, void *dev_id) ...@@ -517,25 +526,25 @@ cd2401_tx_interrupt(int irq, void *dev_id)
int outch; int outch;
/* determine the channel and change to that context */ /* determine the channel and change to that context */
channel = (u_short ) (base_addr[CyLICR] >> 2); channel = (u_short) (base_addr[CyLICR] >> 2);
#ifdef CONFIG_REMOTE_DEBUG #ifdef CONFIG_REMOTE_DEBUG
if (channel == DEBUG_PORT) { if (channel == DEBUG_PORT) {
panic ("TxInt on debug port!!!"); panic("TxInt on debug port!!!");
} }
#endif #endif
info = &cy_port[channel]; info = &cy_port[channel];
/* validate the port number (as configured and open) */ /* validate the port number (as configured and open) */
if( (channel < 0) || (NR_PORTS <= channel) ){ if ((channel < 0) || (NR_PORTS <= channel)) {
base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy); base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
base_addr[CyTEOIR] = CyNOTRANS; base_addr[CyTEOIR] = CyNOTRANS;
return IRQ_HANDLED; return IRQ_HANDLED;
} }
info->last_active = jiffies; info->last_active = jiffies;
if(info->tty == 0){ if (info->tty == 0) {
base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy); base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
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);
} }
...@@ -546,14 +555,14 @@ cd2401_tx_interrupt(int irq, void *dev_id) ...@@ -546,14 +555,14 @@ cd2401_tx_interrupt(int irq, void *dev_id)
/* load the on-chip space available for outbound data */ /* load the on-chip space available for outbound data */
saved_cnt = char_count = base_addr[CyTFTC]; saved_cnt = char_count = base_addr[CyTFTC];
if(info->x_char) { /* send special char */ if (info->x_char) { /* send special char */
outch = info->x_char; outch = info->x_char;
base_addr[CyTDR] = outch; base_addr[CyTDR] = outch;
char_count--; char_count--;
info->x_char = 0; info->x_char = 0;
} }
if (info->x_break){ if (info->x_break) {
/* The Cirrus chip requires the "Embedded Transmit /* The Cirrus chip requires the "Embedded Transmit
Commands" of start break, delay, and end break Commands" of start break, delay, and end break
sequences to be sent. The duration of the sequences to be sent. The duration of the
...@@ -567,24 +576,24 @@ cd2401_tx_interrupt(int irq, void *dev_id) ...@@ -567,24 +576,24 @@ cd2401_tx_interrupt(int irq, void *dev_id)
base_addr[CyTDR] = 0x81; base_addr[CyTDR] = 0x81;
base_addr[CyTDR] = 0; /* delay a bit */ base_addr[CyTDR] = 0; /* delay a bit */
base_addr[CyTDR] = 0x82; base_addr[CyTDR] = 0x82;
base_addr[CyTDR] = info->x_break*200/HZ; base_addr[CyTDR] = info->x_break * 200 / HZ;
base_addr[CyTDR] = 0; /* terminate break */ base_addr[CyTDR] = 0; /* terminate break */
base_addr[CyTDR] = 0x83; base_addr[CyTDR] = 0x83;
char_count -= 7; char_count -= 7;
info->x_break = 0; info->x_break = 0;
} }
while (char_count > 0){ while (char_count > 0) {
if (!info->xmit_cnt){ if (!info->xmit_cnt) {
base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy); base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
break; break;
} }
if (info->xmit_buf == 0){ if (info->xmit_buf == 0) {
base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy); base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
break; break;
} }
if (info->tty->stopped || info->tty->hw_stopped){ if (info->tty->stopped || info->tty->hw_stopped) {
base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy); base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
break; break;
} }
/* Because the Embedded Transmit Commands have been /* Because the Embedded Transmit Commands have been
...@@ -599,14 +608,14 @@ cd2401_tx_interrupt(int irq, void *dev_id) ...@@ -599,14 +608,14 @@ cd2401_tx_interrupt(int irq, void *dev_id)
needed to send a NULL. 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)
& (PAGE_SIZE - 1); & (PAGE_SIZE - 1);
base_addr[CyTDR] = outch; base_addr[CyTDR] = outch;
char_count--; char_count--;
}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)
& (PAGE_SIZE - 1); & (PAGE_SIZE - 1);
...@@ -614,7 +623,7 @@ cd2401_tx_interrupt(int irq, void *dev_id) ...@@ -614,7 +623,7 @@ cd2401_tx_interrupt(int irq, void *dev_id)
base_addr[CyTDR] = 0; base_addr[CyTDR] = 0;
char_count--; char_count--;
char_count--; char_count--;
}else{ } else {
break; break;
} }
} }
...@@ -627,8 +636,7 @@ cd2401_tx_interrupt(int irq, void *dev_id) ...@@ -627,8 +636,7 @@ cd2401_tx_interrupt(int irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} /* cy_tx_interrupt */ } /* cy_tx_interrupt */
static irqreturn_t static irqreturn_t cd2401_rx_interrupt(int irq, void *dev_id)
cd2401_rx_interrupt(int irq, void *dev_id)
{ {
struct tty_struct *tty; struct tty_struct *tty;
struct cyclades_port *info; struct cyclades_port *info;
...@@ -640,7 +648,7 @@ cd2401_rx_interrupt(int irq, void *dev_id) ...@@ -640,7 +648,7 @@ cd2401_rx_interrupt(int irq, void *dev_id)
int len; int len;
/* determine the channel and change to that context */ /* determine the channel and change to that context */
channel = (u_short ) (base_addr[CyLICR] >> 2); channel = (u_short) (base_addr[CyLICR] >> 2);
info = &cy_port[channel]; info = &cy_port[channel];
info->last_active = jiffies; info->last_active = jiffies;
save_cnt = char_count = base_addr[CyRFOC]; save_cnt = char_count = base_addr[CyRFOC];
...@@ -651,15 +659,14 @@ cd2401_rx_interrupt(int irq, void *dev_id) ...@@ -651,15 +659,14 @@ cd2401_rx_interrupt(int irq, void *dev_id)
data = base_addr[CyRDR]; data = base_addr[CyRDR];
queueDebugChar(data); queueDebugChar(data);
} }
} } else
else
#endif #endif
/* 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) {
while(char_count--){ while (char_count--) {
data = base_addr[CyRDR]; data = base_addr[CyRDR];
} }
}else{ /* there is an open port for this data */ } else { /* there is an open port for this data */
tty = info->tty; tty = info->tty;
/* load # characters available from the chip */ /* load # characters available from the chip */
...@@ -671,7 +678,7 @@ cd2401_rx_interrupt(int irq, void *dev_id) ...@@ -671,7 +678,7 @@ cd2401_rx_interrupt(int irq, void *dev_id)
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 = base_addr[CyRDR]; data = base_addr[CyRDR];
tty_insert_flip_char(tty, data, TTY_NORMAL); tty_insert_flip_char(tty, data, TTY_NORMAL);
#ifdef CYCLOM_16Y_HACK #ifdef CYCLOM_16Y_HACK
...@@ -705,10 +712,10 @@ cd2401_rx_interrupt(int irq, void *dev_id) ...@@ -705,10 +712,10 @@ cd2401_rx_interrupt(int irq, void *dev_id)
* structure) to the bottom half of the driver. Previous kernels * structure) to the bottom half of the driver. Previous kernels
* had to poll every port to see if that port needed servicing. * had to poll every port to see if that port needed servicing.
*/ */
static void static void do_softint(struct work_struct *ugly_api)
do_softint(struct work_struct *ugly_api)
{ {
struct cyclades_port *info = container_of(ugly_api, struct cyclades_port, tqueue); struct cyclades_port *info =
container_of(ugly_api, struct cyclades_port, tqueue);
struct tty_struct *tty; struct tty_struct *tty;
tty = info->tty; tty = info->tty;
...@@ -728,30 +735,28 @@ do_softint(struct work_struct *ugly_api) ...@@ -728,30 +735,28 @@ do_softint(struct work_struct *ugly_api)
} }
} /* do_softint */ } /* do_softint */
/* 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;
volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
int channel; int channel;
if (info->flags & ASYNC_INITIALIZED){ if (info->flags & ASYNC_INITIALIZED) {
return 0; return 0;
} }
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);
} }
return 0; return 0;
} }
if (!info->xmit_buf){ if (!info->xmit_buf) {
info->xmit_buf = (unsigned char *) get_zeroed_page (GFP_KERNEL); info->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL);
if (!info->xmit_buf){ if (!info->xmit_buf) {
return -ENOMEM; return -ENOMEM;
} }
} }
...@@ -765,23 +770,24 @@ startup(struct cyclades_port * info) ...@@ -765,23 +770,24 @@ startup(struct cyclades_port * info)
#endif #endif
local_irq_save(flags); local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel; base_addr[CyCAR] = (u_char) channel;
write_cy_cmd(base_addr,CyENB_RCVR|CyENB_XMTR); write_cy_cmd(base_addr, CyENB_RCVR | CyENB_XMTR);
base_addr[CyCAR] = (u_char)channel; /* !!! Is this needed? */ base_addr[CyCAR] = (u_char) channel; /* !!! Is this needed? */
base_addr[CyMSVR1] = CyRTS; base_addr[CyMSVR1] = CyRTS;
/* CP('S');CP('1'); */ /* CP('S');CP('1'); */
base_addr[CyMSVR2] = CyDTR; base_addr[CyMSVR2] = CyDTR;
#ifdef SERIAL_DEBUG_DTR #ifdef SERIAL_DEBUG_DTR
printk("cyc: %d: raising DTR\n", __LINE__); printk("cyc: %d: raising DTR\n", __LINE__);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
base_addr[CyMSVR2]);
#endif #endif
base_addr[CyIER] |= CyRxData; base_addr[CyIER] |= 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;
...@@ -794,11 +800,10 @@ startup(struct cyclades_port * info) ...@@ -794,11 +800,10 @@ startup(struct cyclades_port * info)
return 0; return 0;
} /* startup */ } /* startup */
void void start_xmit(struct cyclades_port *info)
start_xmit( struct cyclades_port *info )
{ {
unsigned long flags; unsigned long flags;
volatile unsigned char *base_addr = (u_char *)BASE_ADDR; volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel; int channel;
channel = info->line; channel = info->line;
...@@ -812,14 +817,13 @@ start_xmit( struct cyclades_port *info ) ...@@ -812,14 +817,13 @@ 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;
volatile unsigned char *base_addr = (u_char *)BASE_ADDR; volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel; int channel;
if (!(info->flags & ASYNC_INITIALIZED)){ if (!(info->flags & ASYNC_INITIALIZED)) {
/* CP('$'); */ /* CP('$'); */
return; return;
} }
...@@ -837,26 +841,27 @@ shutdown(struct cyclades_port * info) ...@@ -837,26 +841,27 @@ shutdown(struct cyclades_port * info)
or schedule some later processing. or schedule some later processing.
*/ */
local_irq_save(flags); local_irq_save(flags);
if (info->xmit_buf){ if (info->xmit_buf) {
free_page((unsigned long) info->xmit_buf); free_page((unsigned long)info->xmit_buf);
info->xmit_buf = NULL; info->xmit_buf = NULL;
} }
base_addr[CyCAR] = (u_char)channel; base_addr[CyCAR] = (u_char) channel;
if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) { if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
base_addr[CyMSVR1] = 0; base_addr[CyMSVR1] = 0;
/* CP('C');CP('1'); */ /* CP('C');CP('1'); */
base_addr[CyMSVR2] = 0; base_addr[CyMSVR2] = 0;
#ifdef SERIAL_DEBUG_DTR #ifdef SERIAL_DEBUG_DTR
printk("cyc: %d: dropping DTR\n", __LINE__); printk("cyc: %d: dropping DTR\n", __LINE__);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
base_addr[CyMSVR2]);
#endif #endif
} }
write_cy_cmd(base_addr,CyDIS_RCVR); write_cy_cmd(base_addr, CyDIS_RCVR);
/* 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;
...@@ -865,26 +870,24 @@ shutdown(struct cyclades_port * info) ...@@ -865,26 +870,24 @@ shutdown(struct cyclades_port * info)
#ifdef SERIAL_DEBUG_OPEN #ifdef SERIAL_DEBUG_OPEN
printk(" done\n"); printk(" done\n");
#endif #endif
return;
} /* shutdown */ } /* shutdown */
/* /*
* This routine finds or computes the various line characteristics. * This routine finds or computes the various line characteristics.
*/ */
static void static void config_setup(struct cyclades_port *info)
config_setup(struct cyclades_port * info)
{ {
unsigned long flags; unsigned long flags;
volatile unsigned char *base_addr = (u_char *)BASE_ADDR; volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel; int channel;
unsigned cflag; unsigned cflag;
int i; int i;
unsigned char ti, need_init_chan = 0; unsigned char ti, need_init_chan = 0;
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;
...@@ -903,10 +906,10 @@ config_setup(struct cyclades_port * info) ...@@ -903,10 +906,10 @@ config_setup(struct cyclades_port * info)
if (i & CBAUDEX) { if (i & CBAUDEX) {
if (i == B57600) if (i == B57600)
i = 16; i = 16;
else if(i == B115200) else if (i == B115200)
i = 18; i = 18;
#ifdef B78600 #ifdef B78600
else if(i == B78600) else if (i == B78600)
i = 17; i = 17;
#endif #endif
else else
...@@ -929,10 +932,13 @@ config_setup(struct cyclades_port * info) ...@@ -929,10 +932,13 @@ config_setup(struct cyclades_port * info)
info->rbpr = baud_bpr[i]; /* Rx BPR */ info->rbpr = baud_bpr[i]; /* Rx BPR */
info->rco = baud_co[i] >> 5; /* Rx CO */ info->rco = baud_co[i] >> 5; /* Rx CO */
if (baud_table[i] == 134) { if (baud_table[i] == 134) {
info->timeout = (info->xmit_fifo_size*HZ*30/269) + 2; info->timeout =
(info->xmit_fifo_size * HZ * 30 / 269) + 2;
/* get it right for 134.5 baud */ /* get it right for 134.5 baud */
} 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;
...@@ -946,36 +952,36 @@ config_setup(struct cyclades_port * info) ...@@ -946,36 +952,36 @@ config_setup(struct cyclades_port * info)
info->cor7 = 0; info->cor7 = 0;
info->cor6 = 0; info->cor6 = 0;
info->cor5 = 0; info->cor5 = 0;
info->cor4 = (info->default_threshold info->cor4 = (info->default_threshold ? info->default_threshold : baud_cor4[i]); /* receive threshold */
? info->default_threshold
: baud_cor4[i]); /* receive threshold */
/* Following two lines added 101295, RGH. */ /* Following two lines added 101295, RGH. */
/* It is obviously wrong to access CyCORx, and not info->corx here, /* It is obviously wrong to access CyCORx, and not info->corx here,
* try and remember to fix it later! */ * try and remember to fix it later! */
channel = info->line; channel = info->line;
base_addr[CyCAR] = (u_char)channel; base_addr[CyCAR] = (u_char) channel;
if (C_CLOCAL(info->tty)) { if (C_CLOCAL(info->tty)) {
if (base_addr[CyIER] & CyMdmCh) if (base_addr[CyIER] & CyMdmCh)
base_addr[CyIER] &= ~CyMdmCh; /* without modem intr */ base_addr[CyIER] &= ~CyMdmCh; /* without modem intr */
/* ignore 1->0 modem transitions */ /* ignore 1->0 modem transitions */
if (base_addr[CyCOR4] & (CyDSR|CyCTS|CyDCD)) if (base_addr[CyCOR4] & (CyDSR | CyCTS | CyDCD))
base_addr[CyCOR4] &= ~(CyDSR|CyCTS|CyDCD); base_addr[CyCOR4] &= ~(CyDSR | CyCTS | CyDCD);
/* ignore 0->1 modem transitions */ /* ignore 0->1 modem transitions */
if (base_addr[CyCOR5] & (CyDSR|CyCTS|CyDCD)) if (base_addr[CyCOR5] & (CyDSR | CyCTS | CyDCD))
base_addr[CyCOR5] &= ~(CyDSR|CyCTS|CyDCD); base_addr[CyCOR5] &= ~(CyDSR | CyCTS | CyDCD);
} else { } else {
if ((base_addr[CyIER] & CyMdmCh) != CyMdmCh) if ((base_addr[CyIER] & CyMdmCh) != CyMdmCh)
base_addr[CyIER] |= CyMdmCh; /* with modem intr */ base_addr[CyIER] |= CyMdmCh; /* with modem intr */
/* act on 1->0 modem transitions */ /* act on 1->0 modem transitions */
if ((base_addr[CyCOR4] & (CyDSR|CyCTS|CyDCD)) != (CyDSR|CyCTS|CyDCD)) if ((base_addr[CyCOR4] & (CyDSR | CyCTS | CyDCD)) !=
base_addr[CyCOR4] |= CyDSR|CyCTS|CyDCD; (CyDSR | CyCTS | CyDCD))
base_addr[CyCOR4] |= CyDSR | CyCTS | CyDCD;
/* act on 0->1 modem transitions */ /* act on 0->1 modem transitions */
if ((base_addr[CyCOR5] & (CyDSR|CyCTS|CyDCD)) != (CyDSR|CyCTS|CyDCD)) if ((base_addr[CyCOR5] & (CyDSR | CyCTS | CyDCD)) !=
base_addr[CyCOR5] |= CyDSR|CyCTS|CyDCD; (CyDSR | CyCTS | CyDCD))
base_addr[CyCOR5] |= CyDSR | CyCTS | CyDCD;
} }
info->cor3 = (cflag & CSTOPB) ? Cy_2_STOP : Cy_1_STOP; info->cor3 = (cflag & CSTOPB) ? Cy_2_STOP : Cy_1_STOP;
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;
...@@ -989,23 +995,23 @@ config_setup(struct cyclades_port * info) ...@@ -989,23 +995,23 @@ config_setup(struct cyclades_port * info)
info->cor1 = Cy_8_BITS; info->cor1 = Cy_8_BITS;
break; break;
} }
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 0 #if 0
/* Don't complcate matters for now! RGH 141095 */ /* Don't complcate matters for now! RGH 141095 */
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;
} }
...@@ -1028,7 +1034,7 @@ config_setup(struct cyclades_port * info) ...@@ -1028,7 +1034,7 @@ config_setup(struct cyclades_port * info)
channel = info->line; channel = info->line;
local_irq_save(flags); local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel; base_addr[CyCAR] = (u_char) channel;
/* CyCMR set once only in mvme167_init_serial() */ /* CyCMR set once only in mvme167_init_serial() */
if (base_addr[CyLICR] != channel << 2) if (base_addr[CyLICR] != channel << 2)
...@@ -1075,9 +1081,9 @@ config_setup(struct cyclades_port * info) ...@@ -1075,9 +1081,9 @@ config_setup(struct cyclades_port * info)
base_addr[CyCOR7] = info->cor7; base_addr[CyCOR7] = info->cor7;
if (need_init_chan) if (need_init_chan)
write_cy_cmd(base_addr,CyINIT_CHAN); write_cy_cmd(base_addr, CyINIT_CHAN);
base_addr[CyCAR] = (u_char)channel; /* !!! Is this needed? */ base_addr[CyCAR] = (u_char) channel; /* !!! Is this needed? */
/* 2ms default rx timeout */ /* 2ms default rx timeout */
ti = info->default_timeout ? info->default_timeout : 0x02; ti = info->default_timeout ? info->default_timeout : 0x02;
...@@ -1087,23 +1093,25 @@ config_setup(struct cyclades_port * info) ...@@ -1087,23 +1093,25 @@ config_setup(struct cyclades_port * info)
base_addr[CyRTPRH] = 0; base_addr[CyRTPRH] = 0;
/* Set up RTS here also ????? RGH 141095 */ /* Set up RTS here also ????? RGH 141095 */
if(i == 0){ /* baud rate is zero, turn off line */ if (i == 0) { /* baud rate is zero, turn off line */
if ((base_addr[CyMSVR2] & CyDTR) == CyDTR) if ((base_addr[CyMSVR2] & CyDTR) == CyDTR)
base_addr[CyMSVR2] = 0; base_addr[CyMSVR2] = 0;
#ifdef SERIAL_DEBUG_DTR #ifdef SERIAL_DEBUG_DTR
printk("cyc: %d: dropping DTR\n", __LINE__); printk("cyc: %d: dropping DTR\n", __LINE__);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
base_addr[CyMSVR2]);
#endif #endif
}else{ } else {
if ((base_addr[CyMSVR2] & CyDTR) != CyDTR) if ((base_addr[CyMSVR2] & CyDTR) != CyDTR)
base_addr[CyMSVR2] = CyDTR; base_addr[CyMSVR2] = CyDTR;
#ifdef SERIAL_DEBUG_DTR #ifdef SERIAL_DEBUG_DTR
printk("cyc: %d: raising DTR\n", __LINE__); printk("cyc: %d: raising DTR\n", __LINE__);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
base_addr[CyMSVR2]);
#endif #endif
} }
if (info->tty){ if (info->tty) {
clear_bit(TTY_IO_ERROR, &info->tty->flags); clear_bit(TTY_IO_ERROR, &info->tty->flags);
} }
...@@ -1111,9 +1119,7 @@ config_setup(struct cyclades_port * info) ...@@ -1111,9 +1119,7 @@ config_setup(struct cyclades_port * info)
} /* config_setup */ } /* config_setup */
static void cy_put_char(struct tty_struct *tty, unsigned char ch)
static void
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;
...@@ -1140,13 +1146,11 @@ cy_put_char(struct tty_struct *tty, unsigned char ch) ...@@ -1140,13 +1146,11 @@ cy_put_char(struct tty_struct *tty, unsigned char ch)
local_irq_restore(flags); local_irq_restore(flags);
} /* cy_put_char */ } /* cy_put_char */
static void cy_flush_chars(struct tty_struct *tty)
static void
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;
unsigned long flags; unsigned long flags;
volatile unsigned char *base_addr = (u_char *)BASE_ADDR; volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel; int channel;
#ifdef SERIAL_DEBUG_IO #ifdef SERIAL_DEBUG_IO
...@@ -1168,16 +1172,13 @@ cy_flush_chars(struct tty_struct *tty) ...@@ -1168,16 +1172,13 @@ cy_flush_chars(struct tty_struct *tty)
local_irq_restore(flags); local_irq_restore(flags);
} /* cy_flush_chars */ } /* cy_flush_chars */
/* 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. If the port is not already transmitting stuff, the write_queue. If the port is not already transmitting stuff,
start it off by enabling interrupts. The interrupt service start it off by enabling interrupts. The interrupt service
routine will then ensure that the characters are sent. If the routine will then ensure that the characters are sent. If the
port is already active, there is no need to kick it. 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;
...@@ -1187,11 +1188,11 @@ cy_write(struct tty_struct * tty, ...@@ -1187,11 +1188,11 @@ cy_write(struct tty_struct * tty,
printk("cy_write %s\n", tty->name); /* */ printk("cy_write %s\n", tty->name); /* */
#endif #endif
if (serial_paranoia_check(info, tty->name, "cy_write")){ if (serial_paranoia_check(info, tty->name, "cy_write")) {
return 0; return 0;
} }
if (!info->xmit_buf){ if (!info->xmit_buf) {
return 0; return 0;
} }
...@@ -1205,7 +1206,8 @@ cy_write(struct tty_struct * tty, ...@@ -1205,7 +1206,8 @@ cy_write(struct tty_struct * tty,
} }
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;
local_irq_restore(flags); local_irq_restore(flags);
...@@ -1214,17 +1216,13 @@ cy_write(struct tty_struct * tty, ...@@ -1214,17 +1216,13 @@ cy_write(struct tty_struct * tty,
total += c; total += c;
} }
if (info->xmit_cnt if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) {
&& !tty->stopped
&& !tty->hw_stopped ) {
start_xmit(info); start_xmit(info);
} }
return total; return total;
} /* cy_write */ } /* cy_write */
static int cy_write_room(struct tty_struct *tty)
static int
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;
...@@ -1241,9 +1239,7 @@ cy_write_room(struct tty_struct *tty) ...@@ -1241,9 +1239,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;
...@@ -1257,9 +1253,7 @@ cy_chars_in_buffer(struct tty_struct *tty) ...@@ -1257,9 +1253,7 @@ cy_chars_in_buffer(struct tty_struct *tty)
return info->xmit_cnt; return info->xmit_cnt;
} /* cy_chars_in_buffer */ } /* cy_chars_in_buffer */
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;
unsigned long flags; unsigned long flags;
...@@ -1276,17 +1270,15 @@ cy_flush_buffer(struct tty_struct *tty) ...@@ -1276,17 +1270,15 @@ cy_flush_buffer(struct tty_struct *tty)
tty_wakeup(tty); tty_wakeup(tty);
} /* cy_flush_buffer */ } /* cy_flush_buffer */
/* This routine is called by the upper-layer tty layer to signal /* This routine is called by the upper-layer tty layer to signal
that incoming characters should be throttled or that the that incoming characters should be throttled or that the
throttle should be released. throttle should be released.
*/ */
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;
volatile unsigned char *base_addr = (u_char *)BASE_ADDR; volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel; int channel;
#ifdef SERIAL_DEBUG_THROTTLE #ifdef SERIAL_DEBUG_THROTTLE
...@@ -1297,7 +1289,7 @@ cy_throttle(struct tty_struct * tty) ...@@ -1297,7 +1289,7 @@ cy_throttle(struct tty_struct * tty)
printk("cy_throttle %s\n", tty->name); printk("cy_throttle %s\n", tty->name);
#endif #endif
if (serial_paranoia_check(info, tty->name, "cy_nthrottle")){ if (serial_paranoia_check(info, tty->name, "cy_nthrottle")) {
return; return;
} }
...@@ -1309,20 +1301,16 @@ cy_throttle(struct tty_struct * tty) ...@@ -1309,20 +1301,16 @@ cy_throttle(struct tty_struct * tty)
channel = info->line; channel = info->line;
local_irq_save(flags); local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel; base_addr[CyCAR] = (u_char) channel;
base_addr[CyMSVR1] = 0; base_addr[CyMSVR1] = 0;
local_irq_restore(flags); local_irq_restore(flags);
return;
} /* cy_throttle */ } /* cy_throttle */
static void cy_unthrottle(struct tty_struct *tty)
static void
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;
volatile unsigned char *base_addr = (u_char *)BASE_ADDR; volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel; int channel;
#ifdef SERIAL_DEBUG_THROTTLE #ifdef SERIAL_DEBUG_THROTTLE
...@@ -1333,7 +1321,7 @@ cy_unthrottle(struct tty_struct * tty) ...@@ -1333,7 +1321,7 @@ cy_unthrottle(struct tty_struct * tty)
printk("cy_unthrottle %s\n", tty->name); printk("cy_unthrottle %s\n", tty->name);
#endif #endif
if (serial_paranoia_check(info, tty->name, "cy_nthrottle")){ if (serial_paranoia_check(info, tty->name, "cy_nthrottle")) {
return; return;
} }
...@@ -1345,15 +1333,13 @@ cy_unthrottle(struct tty_struct * tty) ...@@ -1345,15 +1333,13 @@ cy_unthrottle(struct tty_struct * tty)
channel = info->line; channel = info->line;
local_irq_save(flags); local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel; base_addr[CyCAR] = (u_char) channel;
base_addr[CyMSVR1] = CyRTS; base_addr[CyMSVR1] = CyRTS;
local_irq_restore(flags); local_irq_restore(flags);
return;
} /* cy_unthrottle */ } /* cy_unthrottle */
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;
...@@ -1367,15 +1353,15 @@ get_serial_info(struct cyclades_port * info, ...@@ -1367,15 +1353,15 @@ get_serial_info(struct cyclades_port * info,
tmp.port = info->line; tmp.port = info->line;
tmp.irq = 0; tmp.irq = 0;
tmp.flags = info->flags; tmp.flags = info->flags;
tmp.baud_base = 0; /*!!!*/ tmp.baud_base = 0; /*!!! */
tmp.close_delay = info->close_delay; tmp.close_delay = info->close_delay;
tmp.custom_divisor = 0; /*!!!*/ tmp.custom_divisor = 0; /*!!! */
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;
...@@ -1384,7 +1370,7 @@ set_serial_info(struct cyclades_port * info, ...@@ -1384,7 +1370,7 @@ set_serial_info(struct cyclades_port * info,
/* CP('s'); */ /* CP('s'); */
if (!new_info) if (!new_info)
return -EFAULT; return -EFAULT;
if (copy_from_user(&new_serial,new_info,sizeof(new_serial))) if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
return -EFAULT; return -EFAULT;
old_info = *info; old_info = *info;
...@@ -1398,7 +1384,6 @@ set_serial_info(struct cyclades_port * info, ...@@ -1398,7 +1384,6 @@ set_serial_info(struct cyclades_port * info,
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.....
...@@ -1408,29 +1393,26 @@ set_serial_info(struct cyclades_port * info, ...@@ -1408,29 +1393,26 @@ set_serial_info(struct cyclades_port * info,
(new_serial.flags & ASYNC_FLAGS)); (new_serial.flags & ASYNC_FLAGS));
info->close_delay = new_serial.close_delay; info->close_delay = new_serial.close_delay;
check_and_exit: check_and_exit:
if (info->flags & ASYNC_INITIALIZED){ if (info->flags & ASYNC_INITIALIZED) {
config_setup(info); config_setup(info);
return 0; return 0;
}else{
return startup(info);
} }
return startup(info);
} /* set_serial_info */ } /* set_serial_info */
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 channel; int channel;
volatile unsigned char *base_addr = (u_char *)BASE_ADDR; volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
unsigned long flags; unsigned long flags;
unsigned char status; unsigned char status;
channel = info->line; channel = info->line;
local_irq_save(flags); local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel; base_addr[CyCAR] = (u_char) channel;
status = base_addr[CyMSVR1] | base_addr[CyMSVR2]; status = base_addr[CyMSVR1] | base_addr[CyMSVR2];
local_irq_restore(flags); local_irq_restore(flags);
...@@ -1445,45 +1427,47 @@ static int ...@@ -1445,45 +1427,47 @@ 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 channel; int channel;
volatile unsigned char *base_addr = (u_char *)BASE_ADDR; volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
unsigned long flags; unsigned long flags;
channel = info->line; channel = info->line;
if (set & TIOCM_RTS){ if (set & TIOCM_RTS) {
local_irq_save(flags); local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel; base_addr[CyCAR] = (u_char) channel;
base_addr[CyMSVR1] = CyRTS; base_addr[CyMSVR1] = CyRTS;
local_irq_restore(flags); local_irq_restore(flags);
} }
if (set & TIOCM_DTR){ if (set & TIOCM_DTR) {
local_irq_save(flags); local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel; base_addr[CyCAR] = (u_char) channel;
/* CP('S');CP('2'); */ /* CP('S');CP('2'); */
base_addr[CyMSVR2] = CyDTR; base_addr[CyMSVR2] = CyDTR;
#ifdef SERIAL_DEBUG_DTR #ifdef SERIAL_DEBUG_DTR
printk("cyc: %d: raising DTR\n", __LINE__); printk("cyc: %d: raising DTR\n", __LINE__);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
base_addr[CyMSVR2]);
#endif #endif
local_irq_restore(flags); local_irq_restore(flags);
} }
if (clear & TIOCM_RTS){ if (clear & TIOCM_RTS) {
local_irq_save(flags); local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel; base_addr[CyCAR] = (u_char) channel;
base_addr[CyMSVR1] = 0; base_addr[CyMSVR1] = 0;
local_irq_restore(flags); local_irq_restore(flags);
} }
if (clear & TIOCM_DTR){ if (clear & TIOCM_DTR) {
local_irq_save(flags); local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel; base_addr[CyCAR] = (u_char) channel;
/* CP('C');CP('2'); */ /* CP('C');CP('2'); */
base_addr[CyMSVR2] = 0; base_addr[CyMSVR2] = 0;
#ifdef SERIAL_DEBUG_DTR #ifdef SERIAL_DEBUG_DTR
printk("cyc: %d: dropping DTR\n", __LINE__); printk("cyc: %d: dropping DTR\n", __LINE__);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
base_addr[CyMSVR2]);
#endif #endif
local_irq_restore(flags); local_irq_restore(flags);
} }
...@@ -1491,19 +1475,18 @@ cy_tiocmset(struct tty_struct *tty, struct file *file, ...@@ -1491,19 +1475,18 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
return 0; return 0;
} /* set_modem_info */ } /* set_modem_info */
static void static void send_break(struct cyclades_port *info, int duration)
send_break( struct cyclades_port * info, int duration)
{ /* Let the transmit ISR take care of this (since it { /* Let the transmit ISR take care of this (since it
requires stuffing characters into the output stream). requires stuffing characters into the output stream).
*/ */
info->x_break = duration; info->x_break = duration;
if (!info->xmit_cnt ) { if (!info->xmit_cnt) {
start_xmit(info); start_xmit(info);
} }
} /* send_break */ } /* send_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)))
...@@ -1515,10 +1498,9 @@ get_mon_info(struct cyclades_port * info, struct cyclades_monitor __user * mon) ...@@ -1515,10 +1498,9 @@ get_mon_info(struct cyclades_port * info, struct cyclades_monitor __user * mon)
return 0; return 0;
} }
static int static int set_threshold(struct cyclades_port *info, unsigned long __user * arg)
set_threshold(struct cyclades_port * info, unsigned long __user *arg)
{ {
volatile unsigned char *base_addr = (u_char *)BASE_ADDR; volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
unsigned long value; unsigned long value;
int channel; int channel;
...@@ -1533,20 +1515,20 @@ set_threshold(struct cyclades_port * info, unsigned long __user *arg) ...@@ -1533,20 +1515,20 @@ set_threshold(struct cyclades_port * info, unsigned long __user *arg)
} }
static int static int
get_threshold(struct cyclades_port * info, unsigned long __user *value) get_threshold(struct cyclades_port *info, unsigned long __user * value)
{ {
volatile unsigned char *base_addr = (u_char *)BASE_ADDR; volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel; int channel;
unsigned long tmp; unsigned long tmp;
channel = info->line; channel = info->line;
tmp = base_addr[CyCOR4] & CyREC_FIFO; tmp = base_addr[CyCOR4] & CyREC_FIFO;
return put_user(tmp,value); return put_user(tmp, value);
} }
static int static int
set_default_threshold(struct cyclades_port * info, unsigned long __user *arg) set_default_threshold(struct cyclades_port *info, unsigned long __user * arg)
{ {
unsigned long value; unsigned long value;
...@@ -1558,15 +1540,14 @@ set_default_threshold(struct cyclades_port * info, unsigned long __user *arg) ...@@ -1558,15 +1540,14 @@ set_default_threshold(struct cyclades_port * info, unsigned long __user *arg)
} }
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);
} }
static int static int set_timeout(struct cyclades_port *info, unsigned long __user * arg)
set_timeout(struct cyclades_port * info, unsigned long __user *arg)
{ {
volatile unsigned char *base_addr = (u_char *)BASE_ADDR; volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel; int channel;
unsigned long value; unsigned long value;
...@@ -1580,38 +1561,36 @@ set_timeout(struct cyclades_port * info, unsigned long __user *arg) ...@@ -1580,38 +1561,36 @@ set_timeout(struct cyclades_port * info, unsigned long __user *arg)
return 0; return 0;
} }
static int static int get_timeout(struct cyclades_port *info, unsigned long __user * value)
get_timeout(struct cyclades_port * info, unsigned long __user *value)
{ {
volatile unsigned char *base_addr = (u_char *)BASE_ADDR; volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel; int channel;
unsigned long tmp; unsigned long tmp;
channel = info->line; channel = info->line;
tmp = base_addr[CyRTPRL]; tmp = base_addr[CyRTPRL];
return put_user(tmp,value); return put_user(tmp, value);
} }
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;
} }
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);
} }
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)
{ {
unsigned long val; unsigned long val;
struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
int ret_val = 0; int ret_val = 0;
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
...@@ -1651,24 +1630,26 @@ cy_ioctl(struct tty_struct *tty, struct file * file, ...@@ -1651,24 +1630,26 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
ret_val = tty_check_change(tty); ret_val = tty_check_change(tty);
if (ret_val) if (ret_val)
break; break;
tty_wait_until_sent(tty,0); tty_wait_until_sent(tty, 0);
if (!arg) if (!arg)
send_break(info, HZ/4); /* 1/4 second */ send_break(info, HZ / 4); /* 1/4 second */
break; break;
case TCSBRKP: /* support for POSIX tcsendbreak() */ case TCSBRKP: /* support for POSIX tcsendbreak() */
ret_val = tty_check_change(tty); ret_val = tty_check_change(tty);
if (ret_val) if (ret_val)
break; break;
tty_wait_until_sent(tty,0); tty_wait_until_sent(tty, 0);
send_break(info, arg ? arg*(HZ/10) : HZ/4); send_break(info, arg ? arg * (HZ / 10) : HZ / 4);
break; break;
/* The following commands are incompletely implemented!!! */ /* The following commands are incompletely implemented!!! */
case TIOCGSOFTCAR: case TIOCGSOFTCAR:
ret_val = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) argp); ret_val =
put_user(C_CLOCAL(tty) ? 1 : 0,
(unsigned long __user *)argp);
break; break;
case TIOCSSOFTCAR: case TIOCSSOFTCAR:
ret_val = get_user(val, (unsigned long __user *) argp); ret_val = get_user(val, (unsigned long __user *)argp);
if (ret_val) if (ret_val)
break; break;
tty->termios->c_cflag = tty->termios->c_cflag =
...@@ -1691,11 +1672,7 @@ cy_ioctl(struct tty_struct *tty, struct file * file, ...@@ -1691,11 +1672,7 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
return ret_val; return ret_val;
} /* cy_ioctl */ } /* cy_ioctl */
static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
static void
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;
...@@ -1717,23 +1694,18 @@ cy_set_termios(struct tty_struct *tty, struct ktermios * old_termios) ...@@ -1717,23 +1694,18 @@ cy_set_termios(struct tty_struct *tty, struct ktermios * old_termios)
(tty->termios->c_cflag & CLOCAL)) (tty->termios->c_cflag & CLOCAL))
wake_up_interruptible(&info->open_wait); wake_up_interruptible(&info->open_wait);
#endif #endif
return;
} /* cy_set_termios */ } /* cy_set_termios */
static void cy_close(struct tty_struct *tty, struct file *filp)
static void
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;
/* CP('C'); */ /* CP('C'); */
#ifdef SERIAL_DEBUG_OTHER #ifdef SERIAL_DEBUG_OTHER
printk("cy_close %s\n", tty->name); printk("cy_close %s\n", tty->name);
#endif #endif
if (!info if (!info || serial_paranoia_check(info, tty->name, "cy_close")) {
|| serial_paranoia_check(info, tty->name, "cy_close")){
return; return;
} }
#ifdef SERIAL_DEBUG_OPEN #ifdef SERIAL_DEBUG_OPEN
...@@ -1753,7 +1725,8 @@ cy_close(struct tty_struct * tty, struct file * filp) ...@@ -1753,7 +1725,8 @@ cy_close(struct tty_struct * tty, struct file * filp)
info->count = 1; info->count = 1;
} }
#ifdef SERIAL_DEBUG_COUNT #ifdef SERIAL_DEBUG_COUNT
printk("cyc: %d: decrementing count to %d\n", __LINE__, info->count - 1); printk("cyc: %d: decrementing count to %d\n", __LINE__,
info->count - 1);
#endif #endif
if (--info->count < 0) { if (--info->count < 0) {
printk("cy_close: bad serial port count for ttys%d: %d\n", printk("cy_close: bad serial port count for ttys%d: %d\n",
...@@ -1776,27 +1749,25 @@ cy_close(struct tty_struct * tty, struct file * filp) ...@@ -1776,27 +1749,25 @@ cy_close(struct tty_struct * tty, struct file * filp)
info->tty = NULL; info->tty = NULL;
if (info->blocked_open) { if (info->blocked_open) {
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);
} }
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 SERIAL_DEBUG_OTHER #ifdef SERIAL_DEBUG_OTHER
printk("cy_close done\n"); printk("cy_close done\n");
#endif #endif
return;
} /* cy_close */ } /* cy_close */
/* /*
* cy_hangup() --- called by tty_hangup() when a hangup is signaled. * cy_hangup() --- called by tty_hangup() when a hangup is signaled.
*/ */
void 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 SERIAL_DEBUG_OTHER #ifdef SERIAL_DEBUG_OTHER
printk("cy_hangup %s\n", tty->name); /* */ printk("cy_hangup %s\n", tty->name); /* */
...@@ -1818,8 +1789,6 @@ cy_hangup(struct tty_struct *tty) ...@@ -1818,8 +1789,6 @@ cy_hangup(struct tty_struct *tty)
wake_up_interruptible(&info->open_wait); wake_up_interruptible(&info->open_wait);
} /* cy_hangup */ } /* cy_hangup */
/* /*
* ------------------------------------------------------------ * ------------------------------------------------------------
* cy_open() and friends * cy_open() and friends
...@@ -1827,14 +1796,14 @@ cy_hangup(struct tty_struct *tty) ...@@ -1827,14 +1796,14 @@ cy_hangup(struct tty_struct *tty)
*/ */
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);
unsigned long flags; unsigned long flags;
int channel; int channel;
int retval; int retval;
volatile u_char *base_addr = (u_char *)BASE_ADDR; volatile u_char *base_addr = (u_char *) BASE_ADDR;
/* /*
* If the device is in the middle of being closed, then block * If the device is in the middle of being closed, then block
...@@ -1842,9 +1811,9 @@ block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -1842,9 +1811,9 @@ 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);
if (info->flags & ASYNC_HUP_NOTIFY){ if (info->flags & ASYNC_HUP_NOTIFY) {
return -EAGAIN; return -EAGAIN;
}else{ } else {
return -ERESTARTSYS; return -ERESTARTSYS;
} }
} }
...@@ -1869,7 +1838,8 @@ block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -1869,7 +1838,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 SERIAL_DEBUG_OPEN #ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready before block: %s, count = %d\n", printk("block_til_ready before block: %s, count = %d\n",
tty->name, info->count);/**/ tty->name, info->count);
/**/
#endif #endif
info->count--; info->count--;
#ifdef SERIAL_DEBUG_COUNT #ifdef SERIAL_DEBUG_COUNT
...@@ -1881,27 +1851,28 @@ block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -1881,27 +1851,28 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
while (1) { while (1) {
local_irq_save(flags); local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel; base_addr[CyCAR] = (u_char) channel;
base_addr[CyMSVR1] = CyRTS; base_addr[CyMSVR1] = CyRTS;
/* CP('S');CP('4'); */ /* CP('S');CP('4'); */
base_addr[CyMSVR2] = CyDTR; base_addr[CyMSVR2] = CyDTR;
#ifdef SERIAL_DEBUG_DTR #ifdef SERIAL_DEBUG_DTR
printk("cyc: %d: raising DTR\n", __LINE__); printk("cyc: %d: raising DTR\n", __LINE__);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
base_addr[CyMSVR2]);
#endif #endif
local_irq_restore(flags); local_irq_restore(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)) {
if (info->flags & ASYNC_HUP_NOTIFY) { if (info->flags & ASYNC_HUP_NOTIFY) {
retval = -EAGAIN; retval = -EAGAIN;
}else{ } else {
retval = -ERESTARTSYS; retval = -ERESTARTSYS;
} }
break; break;
} }
local_irq_save(flags); local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel; base_addr[CyCAR] = (u_char) channel;
/* CP('L');CP1(1 && C_CLOCAL(tty)); CP1(1 && (base_addr[CyMSVR1] & CyDCD) ); */ /* CP('L');CP1(1 && C_CLOCAL(tty)); CP1(1 && (base_addr[CyMSVR1] & CyDCD) ); */
if (!(info->flags & ASYNC_CLOSING) if (!(info->flags & ASYNC_CLOSING)
&& (C_CLOCAL(tty) && (C_CLOCAL(tty)
...@@ -1916,22 +1887,25 @@ block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -1916,22 +1887,25 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
} }
#ifdef SERIAL_DEBUG_OPEN #ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready blocking: %s, count = %d\n", printk("block_til_ready blocking: %s, count = %d\n",
tty->name, info->count);/**/ tty->name, 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 SERIAL_DEBUG_COUNT #ifdef SERIAL_DEBUG_COUNT
printk("cyc: %d: incrementing count to %d\n", __LINE__, info->count); printk("cyc: %d: incrementing count to %d\n", __LINE__,
info->count);
#endif #endif
} }
info->blocked_open--; info->blocked_open--;
#ifdef SERIAL_DEBUG_OPEN #ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready after blocking: %s, count = %d\n", printk("block_til_ready after blocking: %s, count = %d\n",
tty->name, info->count);/**/ tty->name, info->count);
/**/
#endif #endif
if (retval) if (retval)
return retval; return retval;
...@@ -1943,29 +1917,29 @@ block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -1943,29 +1917,29 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
* 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.
*/ */
int 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;
/* CP('O'); */ /* CP('O'); */
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;
} }
#ifdef SERIAL_DEBUG_OTHER #ifdef SERIAL_DEBUG_OTHER
printk("cy_open %s\n", tty->name); /* */ printk("cy_open %s\n", tty->name); /* */
#endif #endif
if (serial_paranoia_check(info, tty->name, "cy_open")){ if (serial_paranoia_check(info, tty->name, "cy_open")) {
return -ENODEV; return -ENODEV;
} }
#ifdef SERIAL_DEBUG_OPEN #ifdef SERIAL_DEBUG_OPEN
printk("cy_open %s, count = %d\n", tty->name, info->count);/**/ printk("cy_open %s, count = %d\n", tty->name, info->count);
/**/
#endif #endif
info->count++; info->count++;
#ifdef SERIAL_DEBUG_COUNT #ifdef SERIAL_DEBUG_COUNT
...@@ -1978,7 +1952,7 @@ cy_open(struct tty_struct *tty, struct file * filp) ...@@ -1978,7 +1952,7 @@ cy_open(struct tty_struct *tty, struct file * filp)
* Start up serial port * Start up serial port
*/ */
retval = startup(info); retval = startup(info);
if (retval){ if (retval) {
return retval; return retval;
} }
...@@ -1990,15 +1964,13 @@ cy_open(struct tty_struct *tty, struct file * filp) ...@@ -1990,15 +1964,13 @@ cy_open(struct tty_struct *tty, struct file * filp)
#endif #endif
return retval; return retval;
} }
#ifdef SERIAL_DEBUG_OPEN #ifdef SERIAL_DEBUG_OPEN
printk("cy_open done\n");/**/ printk("cy_open done\n");
/**/
#endif #endif
return 0; return 0;
} /* cy_open */ } /* cy_open */
/* /*
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* serial167_init() and friends * serial167_init() and friends
...@@ -2012,8 +1984,7 @@ cy_open(struct tty_struct *tty, struct file * filp) ...@@ -2012,8 +1984,7 @@ cy_open(struct tty_struct *tty, struct file * filp)
* number, and identifies which options were configured into this * number, and identifies which options were configured into this
* driver. * driver.
*/ */
static void static void show_version(void)
show_version(void)
{ {
printk("MVME166/167 cd2401 driver\n"); printk("MVME166/167 cd2401 driver\n");
} /* show_version */ } /* show_version */
...@@ -2030,10 +2001,9 @@ show_version(void) ...@@ -2030,10 +2001,9 @@ show_version(void)
* ... I wonder what I should do if this fails ... * ... I wonder what I should do if this fails ...
*/ */
void void mvme167_serial_console_setup(int cflag)
mvme167_serial_console_setup(int cflag)
{ {
volatile unsigned char* base_addr = (u_char *)BASE_ADDR; volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int ch; int ch;
u_char spd; u_char spd;
u_char rcor, rbpr, badspeed = 0; u_char rcor, rbpr, badspeed = 0;
...@@ -2063,7 +2033,7 @@ mvme167_serial_console_setup(int cflag) ...@@ -2063,7 +2033,7 @@ mvme167_serial_console_setup(int cflag)
/* OK, we have chosen a speed, now reset and reinitialise */ /* OK, we have chosen a speed, now reset and reinitialise */
my_udelay(20000L); /* Allow time for any active o/p to complete */ my_udelay(20000L); /* Allow time for any active o/p to complete */
if(base_addr[CyCCR] != 0x00){ if (base_addr[CyCCR] != 0x00) {
local_irq_restore(flags); local_irq_restore(flags);
/* printk(" chip is never idle (CCR != 0)\n"); */ /* printk(" chip is never idle (CCR != 0)\n"); */
return; return;
...@@ -2072,7 +2042,7 @@ mvme167_serial_console_setup(int cflag) ...@@ -2072,7 +2042,7 @@ mvme167_serial_console_setup(int cflag)
base_addr[CyCCR] = CyCHIP_RESET; /* Reset the chip */ base_addr[CyCCR] = CyCHIP_RESET; /* Reset the chip */
my_udelay(1000L); my_udelay(1000L);
if(base_addr[CyGFRCR] == 0x00){ if (base_addr[CyGFRCR] == 0x00) {
local_irq_restore(flags); local_irq_restore(flags);
/* printk(" chip is not responding (GFRCR stayed 0)\n"); */ /* printk(" chip is not responding (GFRCR stayed 0)\n"); */
return; return;
...@@ -2095,11 +2065,11 @@ mvme167_serial_console_setup(int cflag) ...@@ -2095,11 +2065,11 @@ mvme167_serial_console_setup(int cflag)
* the ammount of fiddling we have to do in normal running. * the ammount of fiddling we have to do in normal running.
*/ */
for (ch = 3; ch >= 0 ; ch--) { for (ch = 3; ch >= 0; ch--) {
base_addr[CyCAR] = (u_char)ch; base_addr[CyCAR] = (u_char) ch;
base_addr[CyIER] = 0; base_addr[CyIER] = 0;
base_addr[CyCMR] = CyASYNC; base_addr[CyCMR] = CyASYNC;
base_addr[CyLICR] = (u_char)ch << 2; base_addr[CyLICR] = (u_char) ch << 2;
base_addr[CyLIVR] = 0x5c; base_addr[CyLIVR] = 0x5c;
base_addr[CyTCOR] = baud_co[spd]; base_addr[CyTCOR] = baud_co[spd];
base_addr[CyTBPR] = baud_bpr[spd]; base_addr[CyTBPR] = baud_bpr[spd];
...@@ -2120,7 +2090,7 @@ mvme167_serial_console_setup(int cflag) ...@@ -2120,7 +2090,7 @@ mvme167_serial_console_setup(int cflag)
base_addr[CyRTPRH] = 0; base_addr[CyRTPRH] = 0;
base_addr[CyMSVR1] = 0; base_addr[CyMSVR1] = 0;
base_addr[CyMSVR2] = 0; base_addr[CyMSVR2] = 0;
write_cy_cmd(base_addr,CyINIT_CHAN|CyDIS_RCVR|CyDIS_XMTR); write_cy_cmd(base_addr, CyINIT_CHAN | CyDIS_RCVR | CyDIS_XMTR);
} }
/* /*
...@@ -2130,7 +2100,7 @@ mvme167_serial_console_setup(int cflag) ...@@ -2130,7 +2100,7 @@ mvme167_serial_console_setup(int cflag)
base_addr[CyMSVR1] = CyRTS; base_addr[CyMSVR1] = CyRTS;
base_addr[CyMSVR2] = CyDTR; base_addr[CyMSVR2] = CyDTR;
base_addr[CyIER] = CyRxData; base_addr[CyIER] = CyRxData;
write_cy_cmd(base_addr,CyENB_RCVR|CyENB_XMTR); write_cy_cmd(base_addr, CyENB_RCVR | CyENB_XMTR);
local_irq_restore(flags); local_irq_restore(flags);
...@@ -2138,7 +2108,8 @@ mvme167_serial_console_setup(int cflag) ...@@ -2138,7 +2108,8 @@ mvme167_serial_console_setup(int cflag)
printk("CD2401 initialised, chip is rev 0x%02x\n", base_addr[CyGFRCR]); printk("CD2401 initialised, chip is rev 0x%02x\n", base_addr[CyGFRCR]);
if (badspeed) if (badspeed)
printk(" WARNING: Failed to identify line speed, rcor=%02x,rbpr=%02x\n", printk
(" WARNING: Failed to identify line speed, rcor=%02x,rbpr=%02x\n",
rcor >> 5, rbpr); rcor >> 5, rbpr);
} /* serial_console_init */ } /* serial_console_init */
...@@ -2161,6 +2132,7 @@ static const struct tty_operations cy_ops = { ...@@ -2161,6 +2132,7 @@ static const struct tty_operations cy_ops = {
.tiocmget = cy_tiocmget, .tiocmget = cy_tiocmget,
.tiocmset = cy_tiocmset, .tiocmset = cy_tiocmset,
}; };
/* The serial driver boot-time initialization code! /* The serial driver boot-time initialization code!
Hardware I/O ports are mapped to character special devices on a Hardware I/O ports are mapped to character special devices on a
first found, first allocated manner. That is, this code searches first found, first allocated manner. That is, this code searches
...@@ -2177,8 +2149,7 @@ static const struct tty_operations cy_ops = { ...@@ -2177,8 +2149,7 @@ static const struct tty_operations cy_ops = {
If there are more cards with more ports than have been statically If there are more cards with more ports than have been statically
allocated above, a warning is printed and the extra ports are ignored. allocated above, a warning is printed and the extra ports are ignored.
*/ */
static int __init static int __init serial167_init(void)
serial167_init(void)
{ {
struct cyclades_port *info; struct cyclades_port *info;
int ret = 0; int ret = 0;
...@@ -2190,7 +2161,7 @@ serial167_init(void) ...@@ -2190,7 +2161,7 @@ serial167_init(void)
struct sigaction sa; struct sigaction sa;
#endif #endif
if (!(mvme16x_config &MVME16x_CONFIG_GOT_CD2401)) if (!(mvme16x_config & MVME16x_CONFIG_GOT_CD2401))
return 0; return 0;
cy_serial_driver = alloc_tty_driver(NR_PORTS); cy_serial_driver = alloc_tty_driver(NR_PORTS);
...@@ -2198,7 +2169,7 @@ serial167_init(void) ...@@ -2198,7 +2169,7 @@ serial167_init(void)
return -ENOMEM; return -ENOMEM;
#if 0 #if 0
scrn[1] = '\0'; scrn[1] = '\0';
#endif #endif
show_version(); show_version();
...@@ -2211,7 +2182,7 @@ scrn[1] = '\0'; ...@@ -2211,7 +2182,7 @@ scrn[1] = '\0';
serial_console_info = &cy_port[0]; serial_console_info = &cy_port[0];
serial_console_cflag = DefSpeed | CS8; serial_console_cflag = DefSpeed | CS8;
#if 0 #if 0
serial_console = 64; /*callout_driver.minor_start*/ serial_console = 64; /*callout_driver.minor_start */
#endif #endif
} }
...@@ -2242,8 +2213,8 @@ scrn[1] = '\0'; ...@@ -2242,8 +2213,8 @@ scrn[1] = '\0';
good_ports = 4; good_ports = 4;
if(port_num < NR_PORTS){ if (port_num < NR_PORTS) {
while( good_ports-- && port_num < NR_PORTS){ while (good_ports-- && port_num < NR_PORTS) {
/*** initialize port ***/ /*** initialize port ***/
info->magic = CYCLADES_MAGIC; info->magic = CYCLADES_MAGIC;
info->type = PORT_CIRRUS; info->type = PORT_CIRRUS;
...@@ -2252,7 +2223,7 @@ scrn[1] = '\0'; ...@@ -2252,7 +2223,7 @@ scrn[1] = '\0';
info->flags = STD_COM_FLAGS; info->flags = STD_COM_FLAGS;
info->tty = NULL; info->tty = NULL;
info->xmit_fifo_size = 12; info->xmit_fifo_size = 12;
info->cor1 = CyPARITY_NONE|Cy_8_BITS; info->cor1 = CyPARITY_NONE | Cy_8_BITS;
info->cor2 = CyETC; info->cor2 = CyETC;
info->cor3 = Cy_1_STOP; info->cor3 = Cy_1_STOP;
info->cor4 = 0x08; /* _very_ small receive threshold */ info->cor4 = 0x08; /* _very_ small receive threshold */
...@@ -2268,7 +2239,8 @@ scrn[1] = '\0'; ...@@ -2268,7 +2239,8 @@ scrn[1] = '\0';
info->event = 0; info->event = 0;
info->count = 0; info->count = 0;
#ifdef SERIAL_DEBUG_COUNT #ifdef SERIAL_DEBUG_COUNT
printk("cyc: %d: setting count to 0\n", __LINE__); printk("cyc: %d: setting count to 0\n",
__LINE__);
#endif #endif
info->blocked_open = 0; info->blocked_open = 0;
info->default_threshold = 0; info->default_threshold = 0;
...@@ -2279,22 +2251,25 @@ scrn[1] = '\0'; ...@@ -2279,22 +2251,25 @@ scrn[1] = '\0';
/* info->session */ /* info->session */
/* info->pgrp */ /* info->pgrp */
/*** !!!!!!!! this may expose new bugs !!!!!!!!! *********/ /*** !!!!!!!! this may expose new bugs !!!!!!!!! *********/
info->read_status_mask = CyTIMEOUT| CySPECHAR| CyBREAK info->read_status_mask =
| CyPARITY| CyFRAME| CyOVERRUN; CyTIMEOUT | CySPECHAR | CyBREAK | CyPARITY |
CyFRAME | CyOVERRUN;
/* info->timeout */ /* info->timeout */
printk("ttyS%d ", info->line); printk("ttyS%d ", info->line);
port_num++;info++; port_num++;
if(!(port_num & 7)){ info++;
if (!(port_num & 7)) {
printk("\n "); printk("\n ");
} }
} }
} }
printk("\n"); printk("\n");
} }
while( port_num < NR_PORTS){ while (port_num < NR_PORTS) {
info->line = -1; info->line = -1;
port_num++;info++; port_num++;
info++;
} }
#ifdef CONFIG_REMOTE_DEBUG #ifdef CONFIG_REMOTE_DEBUG
debug_setup(); debug_setup();
...@@ -2344,45 +2319,42 @@ scrn[1] = '\0'; ...@@ -2344,45 +2319,42 @@ scrn[1] = '\0';
free_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt); free_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt);
cleanup_serial_driver: cleanup_serial_driver:
if (tty_unregister_driver(cy_serial_driver)) if (tty_unregister_driver(cy_serial_driver))
printk(KERN_ERR "Couldn't unregister MVME166/7 serial driver\n"); printk(KERN_ERR
"Couldn't unregister MVME166/7 serial driver\n");
put_tty_driver(cy_serial_driver); put_tty_driver(cy_serial_driver);
return ret; return ret;
} /* serial167_init */ } /* serial167_init */
module_init(serial167_init); module_init(serial167_init);
#ifdef CYCLOM_SHOW_STATUS #ifdef CYCLOM_SHOW_STATUS
static void static void show_status(int line_num)
show_status(int line_num)
{ {
volatile unsigned char *base_addr = (u_char *)BASE_ADDR; volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel; int channel;
struct cyclades_port * info; struct cyclades_port *info;
unsigned long flags; unsigned long flags;
info = &cy_port[line_num]; info = &cy_port[line_num];
channel = info->line; channel = info->line;
printk(" channel %d\n", channel);/**/ printk(" channel %d\n", channel);
/**/ printk(" cy_port\n");
printk(" cy_port\n");
printk(" card line flags = %d %d %x\n", printk(" card line flags = %d %d %x\n",
info->card, info->line, info->flags); info->card, info->line, info->flags);
printk(" *tty read_status_mask timeout xmit_fifo_size = %lx %x %x %x\n", printk
(long)info->tty, info->read_status_mask, (" *tty read_status_mask timeout xmit_fifo_size = %lx %x %x %x\n",
info->timeout, info->xmit_fifo_size); (long)info->tty, info->read_status_mask, info->timeout,
info->xmit_fifo_size);
printk(" cor1,cor2,cor3,cor4,cor5,cor6,cor7 = %x %x %x %x %x %x %x\n", printk(" cor1,cor2,cor3,cor4,cor5,cor6,cor7 = %x %x %x %x %x %x %x\n",
info->cor1, info->cor2, info->cor3, info->cor4, info->cor5, info->cor1, info->cor2, info->cor3, info->cor4, info->cor5,
info->cor6, info->cor7); info->cor6, info->cor7);
printk(" tbpr,tco,rbpr,rco = %d %d %d %d\n", printk(" tbpr,tco,rbpr,rco = %d %d %d %d\n", info->tbpr, info->tco,
info->tbpr, info->tco, info->rbpr, info->rco); info->rbpr, info->rco);
printk(" close_delay event count = %d %d %d\n", printk(" close_delay event count = %d %d %d\n", info->close_delay,
info->close_delay, info->event, info->count); info->event, info->count);
printk(" x_char blocked_open = %x %x\n", printk(" x_char blocked_open = %x %x\n", info->x_char,
info->x_char, info->blocked_open); info->blocked_open);
printk(" open_wait = %lx %lx %lx\n", printk(" open_wait = %lx %lx %lx\n", (long)info->open_wait);
(long)info->open_wait);
local_irq_save(flags); local_irq_save(flags);
...@@ -2398,7 +2370,7 @@ show_status(int line_num) ...@@ -2398,7 +2370,7 @@ show_status(int line_num)
printk(" CyMIR %x\n", base_addr[CyMIR]); printk(" CyMIR %x\n", base_addr[CyMIR]);
printk(" CyTPR %x\n", base_addr[CyTPR]); printk(" CyTPR %x\n", base_addr[CyTPR]);
base_addr[CyCAR] = (u_char)channel; base_addr[CyCAR] = (u_char) channel;
/* Virtual Registers */ /* Virtual Registers */
...@@ -2446,7 +2418,6 @@ show_status(int line_num) ...@@ -2446,7 +2418,6 @@ show_status(int line_num)
} /* show_status */ } /* show_status */
#endif #endif
#if 0 #if 0
/* Dummy routine in mvme16x/config.c for now */ /* Dummy routine in mvme16x/config.c for now */
...@@ -2459,23 +2430,27 @@ void console_setup(char *str, int *ints) ...@@ -2459,23 +2430,27 @@ void console_setup(char *str, int *ints)
int cflag = 0; int cflag = 0;
/* Sanity check. */ /* Sanity check. */
if (ints[0] > 3 || ints[1] > 3) return; if (ints[0] > 3 || ints[1] > 3)
return;
/* Get baud, bits and parity */ /* Get baud, bits and parity */
baud = 2400; baud = 2400;
bits = 8; bits = 8;
parity = 'n'; parity = 'n';
if (ints[2]) baud = ints[2]; if (ints[2])
baud = ints[2];
if ((s = strchr(str, ','))) { if ((s = strchr(str, ','))) {
do { do {
s++; s++;
} while(*s >= '0' && *s <= '9'); } while (*s >= '0' && *s <= '9');
if (*s) parity = *s++; if (*s)
if (*s) bits = *s - '0'; parity = *s++;
if (*s)
bits = *s - '0';
} }
/* Now construct a cflag setting. */ /* Now construct a cflag setting. */
switch(baud) { switch (baud) {
case 1200: case 1200:
cflag |= B1200; cflag |= B1200;
break; break;
...@@ -2493,7 +2468,7 @@ void console_setup(char *str, int *ints) ...@@ -2493,7 +2468,7 @@ void console_setup(char *str, int *ints)
cflag |= B2400; cflag |= B2400;
break; break;
} }
switch(bits) { switch (bits) {
case 7: case 7:
cflag |= CS7; cflag |= CS7;
break; break;
...@@ -2502,18 +2477,20 @@ void console_setup(char *str, int *ints) ...@@ -2502,18 +2477,20 @@ void console_setup(char *str, int *ints)
cflag |= CS8; cflag |= CS8;
break; break;
} }
switch(parity) { switch (parity) {
case 'o': case 'O': case 'o':
case 'O':
cflag |= PARODD; cflag |= PARODD;
break; break;
case 'e': case 'E': case 'e':
case 'E':
cflag |= PARENB; cflag |= PARENB;
break; break;
} }
serial_console_info = &cy_port[ints[1]]; serial_console_info = &cy_port[ints[1]];
serial_console_cflag = cflag; serial_console_cflag = cflag;
serial_console = ints[1] + 64; /*callout_driver.minor_start*/ serial_console = ints[1] + 64; /*callout_driver.minor_start */
} }
#endif #endif
...@@ -2532,9 +2509,10 @@ void console_setup(char *str, int *ints) ...@@ -2532,9 +2509,10 @@ void console_setup(char *str, int *ints)
* The console must be locked when we get here. * The console must be locked when we get here.
*/ */
void serial167_console_write(struct console *co, const char *str, unsigned count) void serial167_console_write(struct console *co, const char *str,
unsigned count)
{ {
volatile unsigned char *base_addr = (u_char *)BASE_ADDR; volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
unsigned long flags; unsigned long flags;
volatile u_char sink; volatile u_char sink;
u_char ier; u_char ier;
...@@ -2547,7 +2525,7 @@ void serial167_console_write(struct console *co, const char *str, unsigned count ...@@ -2547,7 +2525,7 @@ void serial167_console_write(struct console *co, const char *str, unsigned count
/* Ensure transmitter is enabled! */ /* Ensure transmitter is enabled! */
port = 0; port = 0;
base_addr[CyCAR] = (u_char)port; base_addr[CyCAR] = (u_char) port;
while (base_addr[CyCCR]) while (base_addr[CyCCR])
; ;
base_addr[CyCCR] = CyENB_XMTR; base_addr[CyCCR] = CyENB_XMTR;
...@@ -2556,8 +2534,7 @@ void serial167_console_write(struct console *co, const char *str, unsigned count ...@@ -2556,8 +2534,7 @@ void serial167_console_write(struct console *co, const char *str, unsigned count
base_addr[CyIER] = CyTxMpty; base_addr[CyIER] = CyTxMpty;
while (1) { while (1) {
if (pcc2chip[PccSCCTICR] & 0x20) if (pcc2chip[PccSCCTICR] & 0x20) {
{
/* We have a Tx int. Acknowledge it */ /* We have a Tx int. Acknowledge it */
sink = pcc2chip[PccTPIACKR]; sink = pcc2chip[PccTPIACKR];
if ((base_addr[CyLICR] >> 2) == port) { if ((base_addr[CyLICR] >> 2) == port) {
...@@ -2571,18 +2548,15 @@ void serial167_console_write(struct console *co, const char *str, unsigned count ...@@ -2571,18 +2548,15 @@ void serial167_console_write(struct console *co, const char *str, unsigned count
str++; str++;
i++; i++;
do_lf = 0; do_lf = 0;
} } else if (*str == '\n') {
else if (*str == '\n') {
base_addr[CyTDR] = '\r'; base_addr[CyTDR] = '\r';
do_lf = 1; do_lf = 1;
} } else {
else {
base_addr[CyTDR] = *str++; base_addr[CyTDR] = *str++;
i++; i++;
} }
base_addr[CyTEOIR] = 0; base_addr[CyTEOIR] = 0;
} } else
else
base_addr[CyTEOIR] = CyNOTRANS; base_addr[CyTEOIR] = CyNOTRANS;
} }
} }
...@@ -2592,19 +2566,18 @@ void serial167_console_write(struct console *co, const char *str, unsigned count ...@@ -2592,19 +2566,18 @@ void serial167_console_write(struct console *co, const char *str, unsigned count
local_irq_restore(flags); local_irq_restore(flags);
} }
static struct tty_driver *serial167_console_device(struct console *c, int *index) static struct tty_driver *serial167_console_device(struct console *c,
int *index)
{ {
*index = c->index; *index = c->index;
return cy_serial_driver; return cy_serial_driver;
} }
static int __init serial167_console_setup(struct console *co, char *options) static int __init serial167_console_setup(struct console *co, char *options)
{ {
return 0; return 0;
} }
static struct console sercons = { static struct console sercons = {
.name = "ttyS", .name = "ttyS",
.write = serial167_console_write, .write = serial167_console_write,
...@@ -2614,7 +2587,6 @@ static struct console sercons = { ...@@ -2614,7 +2587,6 @@ static struct console sercons = {
.index = -1, .index = -1,
}; };
static int __init serial167_console_init(void) static int __init serial167_console_init(void)
{ {
if (vme_brdtype == VME_TYPE_MVME166 || if (vme_brdtype == VME_TYPE_MVME166 ||
...@@ -2625,12 +2597,13 @@ static int __init serial167_console_init(void) ...@@ -2625,12 +2597,13 @@ static int __init serial167_console_init(void)
} }
return 0; return 0;
} }
console_initcall(serial167_console_init); console_initcall(serial167_console_init);
#ifdef CONFIG_REMOTE_DEBUG #ifdef CONFIG_REMOTE_DEBUG
void putDebugChar (int c) void putDebugChar(int c)
{ {
volatile unsigned char *base_addr = (u_char *)BASE_ADDR; volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
unsigned long flags; unsigned long flags;
volatile u_char sink; volatile u_char sink;
u_char ier; u_char ier;
...@@ -2641,7 +2614,7 @@ void putDebugChar (int c) ...@@ -2641,7 +2614,7 @@ void putDebugChar (int c)
/* Ensure transmitter is enabled! */ /* Ensure transmitter is enabled! */
port = DEBUG_PORT; port = DEBUG_PORT;
base_addr[CyCAR] = (u_char)port; base_addr[CyCAR] = (u_char) port;
while (base_addr[CyCCR]) while (base_addr[CyCCR])
; ;
base_addr[CyCCR] = CyENB_XMTR; base_addr[CyCCR] = CyENB_XMTR;
...@@ -2650,16 +2623,14 @@ void putDebugChar (int c) ...@@ -2650,16 +2623,14 @@ void putDebugChar (int c)
base_addr[CyIER] = CyTxMpty; base_addr[CyIER] = CyTxMpty;
while (1) { while (1) {
if (pcc2chip[PccSCCTICR] & 0x20) if (pcc2chip[PccSCCTICR] & 0x20) {
{
/* We have a Tx int. Acknowledge it */ /* We have a Tx int. Acknowledge it */
sink = pcc2chip[PccTPIACKR]; sink = pcc2chip[PccTPIACKR];
if ((base_addr[CyLICR] >> 2) == port) { if ((base_addr[CyLICR] >> 2) == port) {
base_addr[CyTDR] = c; base_addr[CyTDR] = c;
base_addr[CyTEOIR] = 0; base_addr[CyTEOIR] = 0;
break; break;
} } else
else
base_addr[CyTEOIR] = CyNOTRANS; base_addr[CyTEOIR] = CyNOTRANS;
} }
} }
...@@ -2671,7 +2642,7 @@ void putDebugChar (int c) ...@@ -2671,7 +2642,7 @@ void putDebugChar (int c)
int getDebugChar() int getDebugChar()
{ {
volatile unsigned char *base_addr = (u_char *)BASE_ADDR; volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
unsigned long flags; unsigned long flags;
volatile u_char sink; volatile u_char sink;
u_char ier; u_char ier;
...@@ -2693,7 +2664,7 @@ int getDebugChar() ...@@ -2693,7 +2664,7 @@ int getDebugChar()
/* Ensure receiver is enabled! */ /* Ensure receiver is enabled! */
port = DEBUG_PORT; port = DEBUG_PORT;
base_addr[CyCAR] = (u_char)port; base_addr[CyCAR] = (u_char) port;
#if 0 #if 0
while (base_addr[CyCCR]) while (base_addr[CyCCR])
; ;
...@@ -2703,31 +2674,30 @@ int getDebugChar() ...@@ -2703,31 +2674,30 @@ int getDebugChar()
base_addr[CyIER] = CyRxData; base_addr[CyIER] = CyRxData;
while (1) { while (1) {
if (pcc2chip[PccSCCRICR] & 0x20) if (pcc2chip[PccSCCRICR] & 0x20) {
{
/* We have a Rx int. Acknowledge it */ /* We have a Rx int. Acknowledge it */
sink = pcc2chip[PccRPIACKR]; sink = pcc2chip[PccRPIACKR];
if ((base_addr[CyLICR] >> 2) == port) { if ((base_addr[CyLICR] >> 2) == port) {
int cnt = base_addr[CyRFOC]; int cnt = base_addr[CyRFOC];
while (cnt-- > 0) while (cnt-- > 0) {
{
c = base_addr[CyRDR]; c = base_addr[CyRDR];
if (c == 0) if (c == 0)
printk ("!! debug char is null (cnt=%d) !!", cnt); printk
("!! debug char is null (cnt=%d) !!",
cnt);
else else
queueDebugChar (c); queueDebugChar(c);
} }
base_addr[CyREOIR] = 0; base_addr[CyREOIR] = 0;
i = debugiq.out; i = debugiq.out;
if (i == debugiq.in) if (i == debugiq.in)
panic ("Debug input queue empty!"); panic("Debug input queue empty!");
c = debugiq.buf[i]; c = debugiq.buf[i];
if (++i == DEBUG_LEN) if (++i == DEBUG_LEN)
i = 0; i = 0;
debugiq.out = i; debugiq.out = i;
break; break;
} } else
else
base_addr[CyREOIR] = CyNOTRANS; base_addr[CyREOIR] = CyNOTRANS;
} }
} }
...@@ -2739,7 +2709,7 @@ int getDebugChar() ...@@ -2739,7 +2709,7 @@ int getDebugChar()
return (c); return (c);
} }
void queueDebugChar (int c) void queueDebugChar(int c)
{ {
int i; int i;
...@@ -2751,19 +2721,17 @@ void queueDebugChar (int c) ...@@ -2751,19 +2721,17 @@ void queueDebugChar (int c)
debugiq.in = i; debugiq.in = i;
} }
static void static void debug_setup()
debug_setup()
{ {
unsigned long flags; unsigned long flags;
volatile unsigned char *base_addr = (u_char *)BASE_ADDR; volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int i, cflag; int i, cflag;
cflag = B19200; cflag = B19200;
local_irq_save(flags); local_irq_save(flags);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++) {
{
base_addr[CyCAR] = i; base_addr[CyCAR] = i;
base_addr[CyLICR] = i << 2; base_addr[CyLICR] = i << 2;
} }
...@@ -2802,8 +2770,8 @@ debug_setup() ...@@ -2802,8 +2770,8 @@ debug_setup()
base_addr[CyCOR6] = 0; base_addr[CyCOR6] = 0;
base_addr[CyCOR7] = 0; base_addr[CyCOR7] = 0;
write_cy_cmd(base_addr,CyINIT_CHAN); write_cy_cmd(base_addr, CyINIT_CHAN);
write_cy_cmd(base_addr,CyENB_RCVR); write_cy_cmd(base_addr, CyENB_RCVR);
base_addr[CyCAR] = DEBUG_PORT; /* !!! Is this needed? */ base_addr[CyCAR] = DEBUG_PORT; /* !!! Is this needed? */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment