cyclades: introduce cyy_readb/writeb
Add helpers for io operations, so that we can eliminate huge amount of supporting code. It is now centralized in those helpers and used values are precomputed in the init phase. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
0d3487294e
commit
3aeea5b922
|
@ -90,7 +90,6 @@
|
||||||
#include <linux/proc_fs.h>
|
#include <linux/proc_fs.h>
|
||||||
#include <linux/seq_file.h>
|
#include <linux/seq_file.h>
|
||||||
|
|
||||||
static void cy_throttle(struct tty_struct *tty);
|
|
||||||
static void cy_send_xchar(struct tty_struct *tty, char ch);
|
static void cy_send_xchar(struct tty_struct *tty, char ch);
|
||||||
|
|
||||||
#ifndef SERIAL_XMIT_SIZE
|
#ifndef SERIAL_XMIT_SIZE
|
||||||
|
@ -298,6 +297,20 @@ static void cyz_rx_restart(unsigned long);
|
||||||
static struct timer_list cyz_rx_full_timer[NR_PORTS];
|
static struct timer_list cyz_rx_full_timer[NR_PORTS];
|
||||||
#endif /* CONFIG_CYZ_INTR */
|
#endif /* CONFIG_CYZ_INTR */
|
||||||
|
|
||||||
|
static inline void cyy_writeb(struct cyclades_port *port, u32 reg, u8 val)
|
||||||
|
{
|
||||||
|
struct cyclades_card *card = port->card;
|
||||||
|
|
||||||
|
cy_writeb(port->u.cyy.base_addr + (reg << card->bus_index), val);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline u8 cyy_readb(struct cyclades_port *port, u32 reg)
|
||||||
|
{
|
||||||
|
struct cyclades_card *card = port->card;
|
||||||
|
|
||||||
|
return readb(port->u.cyy.base_addr + (reg << card->bus_index));
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool cy_is_Z(struct cyclades_card *card)
|
static inline bool cy_is_Z(struct cyclades_card *card)
|
||||||
{
|
{
|
||||||
return card->num_chips == (unsigned int)-1;
|
return card->num_chips == (unsigned int)-1;
|
||||||
|
@ -350,13 +363,14 @@ static inline int serial_paranoia_check(struct cyclades_port *info,
|
||||||
|
|
||||||
This function is only called from inside spinlock-protected code.
|
This function is only called from inside spinlock-protected code.
|
||||||
*/
|
*/
|
||||||
static int cyy_issue_cmd(void __iomem *base_addr, u_char cmd, int index)
|
static int __cyy_issue_cmd(void __iomem *base_addr, u8 cmd, int index)
|
||||||
{
|
{
|
||||||
|
void __iomem *ccr = base_addr + (CyCCR << index);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
/* Check to see that the previous command has completed */
|
/* Check to see that the previous command has completed */
|
||||||
for (i = 0; i < 100; i++) {
|
for (i = 0; i < 100; i++) {
|
||||||
if (readb(base_addr + (CyCCR << index)) == 0)
|
if (readb(ccr) == 0)
|
||||||
break;
|
break;
|
||||||
udelay(10L);
|
udelay(10L);
|
||||||
}
|
}
|
||||||
|
@ -366,10 +380,16 @@ static int cyy_issue_cmd(void __iomem *base_addr, u_char cmd, int index)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Issue the new command */
|
/* Issue the new command */
|
||||||
cy_writeb(base_addr + (CyCCR << index), cmd);
|
cy_writeb(ccr, cmd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} /* cyy_issue_cmd */
|
}
|
||||||
|
|
||||||
|
static inline int cyy_issue_cmd(struct cyclades_port *port, u8 cmd)
|
||||||
|
{
|
||||||
|
return __cyy_issue_cmd(port->u.cyy.base_addr, cmd,
|
||||||
|
port->card->bus_index);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_ISA
|
#ifdef CONFIG_ISA
|
||||||
/* ISA interrupt detection code */
|
/* ISA interrupt detection code */
|
||||||
|
@ -394,7 +414,7 @@ static unsigned detect_isa_irq(void __iomem *address)
|
||||||
/* Enable the Tx interrupts on the CD1400 */
|
/* Enable the Tx interrupts on the CD1400 */
|
||||||
local_irq_save(flags);
|
local_irq_save(flags);
|
||||||
cy_writeb(address + (CyCAR << index), 0);
|
cy_writeb(address + (CyCAR << index), 0);
|
||||||
cyy_issue_cmd(address, CyCHAN_CTL | CyENB_XMTR, index);
|
__cyy_issue_cmd(address, CyCHAN_CTL | CyENB_XMTR, index);
|
||||||
|
|
||||||
cy_writeb(address + (CyCAR << index), 0);
|
cy_writeb(address + (CyCAR << index), 0);
|
||||||
cy_writeb(address + (CySRER << index),
|
cy_writeb(address + (CySRER << index),
|
||||||
|
@ -428,7 +448,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
|
||||||
struct cyclades_port *info;
|
struct cyclades_port *info;
|
||||||
struct tty_struct *tty;
|
struct tty_struct *tty;
|
||||||
int len, index = cinfo->bus_index;
|
int len, index = cinfo->bus_index;
|
||||||
u8 save_xir, channel, save_car, data, char_count;
|
u8 ivr, save_xir, channel, save_car, data, char_count;
|
||||||
|
|
||||||
#ifdef CY_DEBUG_INTERRUPTS
|
#ifdef CY_DEBUG_INTERRUPTS
|
||||||
printk(KERN_DEBUG "cyy_interrupt: rcvd intr, chip %d\n", chip);
|
printk(KERN_DEBUG "cyy_interrupt: rcvd intr, chip %d\n", chip);
|
||||||
|
@ -437,26 +457,25 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
|
||||||
save_xir = readb(base_addr + (CyRIR << index));
|
save_xir = readb(base_addr + (CyRIR << index));
|
||||||
channel = save_xir & CyIRChannel;
|
channel = save_xir & CyIRChannel;
|
||||||
info = &cinfo->ports[channel + chip * 4];
|
info = &cinfo->ports[channel + chip * 4];
|
||||||
save_car = readb(base_addr + (CyCAR << index));
|
save_car = cyy_readb(info, CyCAR);
|
||||||
cy_writeb(base_addr + (CyCAR << index), save_xir);
|
cyy_writeb(info, CyCAR, save_xir);
|
||||||
|
ivr = cyy_readb(info, CyRIVR) & CyIVRMask;
|
||||||
|
|
||||||
tty = tty_port_tty_get(&info->port);
|
tty = tty_port_tty_get(&info->port);
|
||||||
/* if there is nowhere to put the data, discard it */
|
/* if there is nowhere to put the data, discard it */
|
||||||
if (tty == NULL) {
|
if (tty == NULL) {
|
||||||
if ((readb(base_addr + (CyRIVR << index)) & CyIVRMask) ==
|
if (ivr == CyIVRRxEx) { /* exception */
|
||||||
CyIVRRxEx) { /* exception */
|
data = cyy_readb(info, CyRDSR);
|
||||||
data = readb(base_addr + (CyRDSR << index));
|
|
||||||
} else { /* normal character reception */
|
} else { /* normal character reception */
|
||||||
char_count = readb(base_addr + (CyRDCR << index));
|
char_count = cyy_readb(info, CyRDCR);
|
||||||
while (char_count--)
|
while (char_count--)
|
||||||
data = readb(base_addr + (CyRDSR << index));
|
data = cyy_readb(info, CyRDSR);
|
||||||
}
|
}
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
/* there is an open port for this data */
|
/* there is an open port for this data */
|
||||||
if ((readb(base_addr + (CyRIVR << index)) & CyIVRMask) ==
|
if (ivr == CyIVRRxEx) { /* exception */
|
||||||
CyIVRRxEx) { /* exception */
|
data = cyy_readb(info, CyRDSR);
|
||||||
data = readb(base_addr + (CyRDSR << index));
|
|
||||||
|
|
||||||
/* For statistics only */
|
/* For statistics only */
|
||||||
if (data & CyBREAK)
|
if (data & CyBREAK)
|
||||||
|
@ -477,22 +496,22 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
|
||||||
if (data & info->read_status_mask) {
|
if (data & info->read_status_mask) {
|
||||||
if (data & CyBREAK) {
|
if (data & CyBREAK) {
|
||||||
tty_insert_flip_char(tty,
|
tty_insert_flip_char(tty,
|
||||||
readb(base_addr + (CyRDSR <<
|
cyy_readb(info, CyRDSR),
|
||||||
index)), TTY_BREAK);
|
TTY_BREAK);
|
||||||
info->icount.rx++;
|
info->icount.rx++;
|
||||||
if (info->port.flags & ASYNC_SAK)
|
if (info->port.flags & ASYNC_SAK)
|
||||||
do_SAK(tty);
|
do_SAK(tty);
|
||||||
} else if (data & CyFRAME) {
|
} else if (data & CyFRAME) {
|
||||||
tty_insert_flip_char(tty,
|
tty_insert_flip_char(tty,
|
||||||
readb(base_addr + (CyRDSR <<
|
cyy_readb(info, CyRDSR),
|
||||||
index)), TTY_FRAME);
|
TTY_FRAME);
|
||||||
info->icount.rx++;
|
info->icount.rx++;
|
||||||
info->idle_stats.frame_errs++;
|
info->idle_stats.frame_errs++;
|
||||||
} else if (data & CyPARITY) {
|
} else if (data & CyPARITY) {
|
||||||
/* Pieces of seven... */
|
/* Pieces of seven... */
|
||||||
tty_insert_flip_char(tty,
|
tty_insert_flip_char(tty,
|
||||||
readb(base_addr + (CyRDSR <<
|
cyy_readb(info, CyRDSR),
|
||||||
index)), TTY_PARITY);
|
TTY_PARITY);
|
||||||
info->icount.rx++;
|
info->icount.rx++;
|
||||||
info->idle_stats.parity_errs++;
|
info->idle_stats.parity_errs++;
|
||||||
} else if (data & CyOVERRUN) {
|
} else if (data & CyOVERRUN) {
|
||||||
|
@ -504,8 +523,8 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
|
||||||
the next incoming character.
|
the next incoming character.
|
||||||
*/
|
*/
|
||||||
tty_insert_flip_char(tty,
|
tty_insert_flip_char(tty,
|
||||||
readb(base_addr + (CyRDSR <<
|
cyy_readb(info, CyRDSR),
|
||||||
index)), TTY_FRAME);
|
TTY_FRAME);
|
||||||
info->icount.rx++;
|
info->icount.rx++;
|
||||||
info->idle_stats.overruns++;
|
info->idle_stats.overruns++;
|
||||||
/* These two conditions may imply */
|
/* These two conditions may imply */
|
||||||
|
@ -529,7 +548,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
|
||||||
}
|
}
|
||||||
} else { /* normal character reception */
|
} else { /* normal character reception */
|
||||||
/* load # chars available from the chip */
|
/* load # chars available from the chip */
|
||||||
char_count = readb(base_addr + (CyRDCR << index));
|
char_count = cyy_readb(info, CyRDCR);
|
||||||
|
|
||||||
#ifdef CY_ENABLE_MONITORING
|
#ifdef CY_ENABLE_MONITORING
|
||||||
++info->mon.int_count;
|
++info->mon.int_count;
|
||||||
|
@ -540,7 +559,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
|
||||||
#endif
|
#endif
|
||||||
len = tty_buffer_request_room(tty, char_count);
|
len = tty_buffer_request_room(tty, char_count);
|
||||||
while (len--) {
|
while (len--) {
|
||||||
data = readb(base_addr + (CyRDSR << index));
|
data = cyy_readb(info, CyRDSR);
|
||||||
tty_insert_flip_char(tty, data, TTY_NORMAL);
|
tty_insert_flip_char(tty, data, TTY_NORMAL);
|
||||||
info->idle_stats.recv_bytes++;
|
info->idle_stats.recv_bytes++;
|
||||||
info->icount.rx++;
|
info->icount.rx++;
|
||||||
|
@ -554,8 +573,8 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
|
||||||
tty_kref_put(tty);
|
tty_kref_put(tty);
|
||||||
end:
|
end:
|
||||||
/* end of service */
|
/* end of service */
|
||||||
cy_writeb(base_addr + (CyRIR << index), save_xir & 0x3f);
|
cyy_writeb(info, CyRIR, save_xir & 0x3f);
|
||||||
cy_writeb(base_addr + (CyCAR << index), save_car);
|
cyy_writeb(info, CyCAR, save_car);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip,
|
static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip,
|
||||||
|
@ -588,8 +607,7 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip,
|
||||||
info = &cinfo->ports[channel + chip * 4];
|
info = &cinfo->ports[channel + chip * 4];
|
||||||
tty = tty_port_tty_get(&info->port);
|
tty = tty_port_tty_get(&info->port);
|
||||||
if (tty == NULL) {
|
if (tty == NULL) {
|
||||||
cy_writeb(base_addr + (CySRER << index),
|
cyy_writeb(info, CySRER, cyy_readb(info, CySRER) & ~CyTxRdy);
|
||||||
readb(base_addr + (CySRER << index)) & ~CyTxRdy);
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,7 +616,7 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip,
|
||||||
|
|
||||||
if (info->x_char) { /* send special char */
|
if (info->x_char) { /* send special char */
|
||||||
outch = info->x_char;
|
outch = info->x_char;
|
||||||
cy_writeb(base_addr + (CyTDR << index), outch);
|
cyy_writeb(info, CyTDR, outch);
|
||||||
char_count--;
|
char_count--;
|
||||||
info->icount.tx++;
|
info->icount.tx++;
|
||||||
info->x_char = 0;
|
info->x_char = 0;
|
||||||
|
@ -606,14 +624,14 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip,
|
||||||
|
|
||||||
if (info->breakon || info->breakoff) {
|
if (info->breakon || info->breakoff) {
|
||||||
if (info->breakon) {
|
if (info->breakon) {
|
||||||
cy_writeb(base_addr + (CyTDR << index), 0);
|
cyy_writeb(info, CyTDR, 0);
|
||||||
cy_writeb(base_addr + (CyTDR << index), 0x81);
|
cyy_writeb(info, CyTDR, 0x81);
|
||||||
info->breakon = 0;
|
info->breakon = 0;
|
||||||
char_count -= 2;
|
char_count -= 2;
|
||||||
}
|
}
|
||||||
if (info->breakoff) {
|
if (info->breakoff) {
|
||||||
cy_writeb(base_addr + (CyTDR << index), 0);
|
cyy_writeb(info, CyTDR, 0);
|
||||||
cy_writeb(base_addr + (CyTDR << index), 0x83);
|
cyy_writeb(info, CyTDR, 0x83);
|
||||||
info->breakoff = 0;
|
info->breakoff = 0;
|
||||||
char_count -= 2;
|
char_count -= 2;
|
||||||
}
|
}
|
||||||
|
@ -621,27 +639,23 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip,
|
||||||
|
|
||||||
while (char_count-- > 0) {
|
while (char_count-- > 0) {
|
||||||
if (!info->xmit_cnt) {
|
if (!info->xmit_cnt) {
|
||||||
if (readb(base_addr + (CySRER << index)) & CyTxMpty) {
|
if (cyy_readb(info, CySRER) & CyTxMpty) {
|
||||||
cy_writeb(base_addr + (CySRER << index),
|
cyy_writeb(info, CySRER,
|
||||||
readb(base_addr + (CySRER << index)) &
|
cyy_readb(info, CySRER) & ~CyTxMpty);
|
||||||
~CyTxMpty);
|
|
||||||
} else {
|
} else {
|
||||||
cy_writeb(base_addr + (CySRER << index),
|
cyy_writeb(info, CySRER, CyTxMpty |
|
||||||
(readb(base_addr + (CySRER << index)) &
|
(cyy_readb(info, CySRER) & ~CyTxRdy));
|
||||||
~CyTxRdy) | CyTxMpty);
|
|
||||||
}
|
}
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (info->port.xmit_buf == NULL) {
|
if (info->port.xmit_buf == NULL) {
|
||||||
cy_writeb(base_addr + (CySRER << index),
|
cyy_writeb(info, CySRER,
|
||||||
readb(base_addr + (CySRER << index)) &
|
cyy_readb(info, CySRER) & ~CyTxRdy);
|
||||||
~CyTxRdy);
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (tty->stopped || tty->hw_stopped) {
|
if (tty->stopped || tty->hw_stopped) {
|
||||||
cy_writeb(base_addr + (CySRER << index),
|
cyy_writeb(info, CySRER,
|
||||||
readb(base_addr + (CySRER << index)) &
|
cyy_readb(info, CySRER) & ~CyTxRdy);
|
||||||
~CyTxRdy);
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
/* Because the Embedded Transmit Commands have been enabled,
|
/* Because the Embedded Transmit Commands have been enabled,
|
||||||
|
@ -658,15 +672,15 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip,
|
||||||
info->xmit_cnt--;
|
info->xmit_cnt--;
|
||||||
info->xmit_tail = (info->xmit_tail + 1) &
|
info->xmit_tail = (info->xmit_tail + 1) &
|
||||||
(SERIAL_XMIT_SIZE - 1);
|
(SERIAL_XMIT_SIZE - 1);
|
||||||
cy_writeb(base_addr + (CyTDR << index), outch);
|
cyy_writeb(info, CyTDR, outch);
|
||||||
info->icount.tx++;
|
info->icount.tx++;
|
||||||
} else {
|
} else {
|
||||||
if (char_count > 1) {
|
if (char_count > 1) {
|
||||||
info->xmit_cnt--;
|
info->xmit_cnt--;
|
||||||
info->xmit_tail = (info->xmit_tail + 1) &
|
info->xmit_tail = (info->xmit_tail + 1) &
|
||||||
(SERIAL_XMIT_SIZE - 1);
|
(SERIAL_XMIT_SIZE - 1);
|
||||||
cy_writeb(base_addr + (CyTDR << index), outch);
|
cyy_writeb(info, CyTDR, outch);
|
||||||
cy_writeb(base_addr + (CyTDR << index), 0);
|
cyy_writeb(info, CyTDR, 0);
|
||||||
info->icount.tx++;
|
info->icount.tx++;
|
||||||
char_count--;
|
char_count--;
|
||||||
}
|
}
|
||||||
|
@ -678,8 +692,8 @@ done:
|
||||||
tty_kref_put(tty);
|
tty_kref_put(tty);
|
||||||
end:
|
end:
|
||||||
/* end of service */
|
/* end of service */
|
||||||
cy_writeb(base_addr + (CyTIR << index), save_xir & 0x3f);
|
cyy_writeb(info, CyTIR, save_xir & 0x3f);
|
||||||
cy_writeb(base_addr + (CyCAR << index), save_car);
|
cyy_writeb(info, CyCAR, save_car);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,
|
static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,
|
||||||
|
@ -694,11 +708,11 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,
|
||||||
save_xir = readb(base_addr + (CyMIR << index));
|
save_xir = readb(base_addr + (CyMIR << index));
|
||||||
channel = save_xir & CyIRChannel;
|
channel = save_xir & CyIRChannel;
|
||||||
info = &cinfo->ports[channel + chip * 4];
|
info = &cinfo->ports[channel + chip * 4];
|
||||||
save_car = readb(base_addr + (CyCAR << index));
|
save_car = cyy_readb(info, CyCAR);
|
||||||
cy_writeb(base_addr + (CyCAR << index), save_xir);
|
cyy_writeb(info, CyCAR, save_xir);
|
||||||
|
|
||||||
mdm_change = readb(base_addr + (CyMISR << index));
|
mdm_change = cyy_readb(info, CyMISR);
|
||||||
mdm_status = readb(base_addr + (CyMSVR1 << index));
|
mdm_status = cyy_readb(info, CyMSVR1);
|
||||||
|
|
||||||
tty = tty_port_tty_get(&info->port);
|
tty = tty_port_tty_get(&info->port);
|
||||||
if (!tty)
|
if (!tty)
|
||||||
|
@ -730,9 +744,8 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,
|
||||||
/* cy_start isn't used
|
/* cy_start isn't used
|
||||||
because... !!! */
|
because... !!! */
|
||||||
tty->hw_stopped = 0;
|
tty->hw_stopped = 0;
|
||||||
cy_writeb(base_addr + (CySRER << index),
|
cyy_writeb(info, CySRER,
|
||||||
readb(base_addr + (CySRER << index)) |
|
cyy_readb(info, CySRER) | CyTxRdy);
|
||||||
CyTxRdy);
|
|
||||||
tty_wakeup(tty);
|
tty_wakeup(tty);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -740,9 +753,8 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,
|
||||||
/* cy_stop isn't used
|
/* cy_stop isn't used
|
||||||
because ... !!! */
|
because ... !!! */
|
||||||
tty->hw_stopped = 1;
|
tty->hw_stopped = 1;
|
||||||
cy_writeb(base_addr + (CySRER << index),
|
cyy_writeb(info, CySRER,
|
||||||
readb(base_addr + (CySRER << index)) &
|
cyy_readb(info, CySRER) & ~CyTxRdy);
|
||||||
~CyTxRdy);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -753,8 +765,8 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,
|
||||||
tty_kref_put(tty);
|
tty_kref_put(tty);
|
||||||
end:
|
end:
|
||||||
/* end of service */
|
/* end of service */
|
||||||
cy_writeb(base_addr + (CyMIR << index), save_xir & 0x3f);
|
cyy_writeb(info, CyMIR, save_xir & 0x3f);
|
||||||
cy_writeb(base_addr + (CyCAR << index), save_car);
|
cyy_writeb(info, CyCAR, save_car);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The real interrupt service routine is called
|
/* The real interrupt service routine is called
|
||||||
|
@ -829,15 +841,10 @@ static void cyy_change_rts_dtr(struct cyclades_port *info, unsigned int set,
|
||||||
unsigned int clear)
|
unsigned int clear)
|
||||||
{
|
{
|
||||||
struct cyclades_card *card = info->card;
|
struct cyclades_card *card = info->card;
|
||||||
void __iomem *base_addr;
|
int channel = info->line - card->first_line;
|
||||||
int chip, channel, index;
|
|
||||||
u32 rts, dtr, msvrr, msvrd;
|
u32 rts, dtr, msvrr, msvrd;
|
||||||
|
|
||||||
channel = info->line - card->first_line;
|
|
||||||
chip = channel >> 2;
|
|
||||||
channel &= 0x03;
|
channel &= 0x03;
|
||||||
index = card->bus_index;
|
|
||||||
base_addr = card->base_addr + (cy_chip_offset[chip] << index);
|
|
||||||
|
|
||||||
if (info->rtsdtr_inv) {
|
if (info->rtsdtr_inv) {
|
||||||
msvrr = CyMSVR2;
|
msvrr = CyMSVR2;
|
||||||
|
@ -851,31 +858,31 @@ static void cyy_change_rts_dtr(struct cyclades_port *info, unsigned int set,
|
||||||
dtr = CyDTR;
|
dtr = CyDTR;
|
||||||
}
|
}
|
||||||
if (set & TIOCM_RTS) {
|
if (set & TIOCM_RTS) {
|
||||||
cy_writeb(base_addr + (CyCAR << index), (u8)channel);
|
cyy_writeb(info, CyCAR, channel);
|
||||||
cy_writeb(base_addr + (msvrr << index), rts);
|
cyy_writeb(info, msvrr, rts);
|
||||||
}
|
}
|
||||||
if (clear & TIOCM_RTS) {
|
if (clear & TIOCM_RTS) {
|
||||||
cy_writeb(base_addr + (CyCAR << index), (u8)channel);
|
cyy_writeb(info, CyCAR, channel);
|
||||||
cy_writeb(base_addr + (msvrr << index), ~rts);
|
cyy_writeb(info, msvrr, ~rts);
|
||||||
}
|
}
|
||||||
if (set & TIOCM_DTR) {
|
if (set & TIOCM_DTR) {
|
||||||
cy_writeb(base_addr + (CyCAR << index), (u8)channel);
|
cyy_writeb(info, CyCAR, channel);
|
||||||
cy_writeb(base_addr + (msvrd << index), dtr);
|
cyy_writeb(info, msvrd, dtr);
|
||||||
#ifdef CY_DEBUG_DTR
|
#ifdef CY_DEBUG_DTR
|
||||||
printk(KERN_DEBUG "cyc:set_modem_info raising DTR\n");
|
printk(KERN_DEBUG "cyc:set_modem_info raising DTR\n");
|
||||||
printk(KERN_DEBUG " status: 0x%x, 0x%x\n",
|
printk(KERN_DEBUG " status: 0x%x, 0x%x\n",
|
||||||
readb(base_addr + (CyMSVR1 << index)),
|
cyy_readb(info, CyMSVR1),
|
||||||
readb(base_addr + (CyMSVR2 << index)));
|
cyy_readb(info, CyMSVR2));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (clear & TIOCM_DTR) {
|
if (clear & TIOCM_DTR) {
|
||||||
cy_writeb(base_addr + (CyCAR << index), (u8)channel);
|
cyy_writeb(info, CyCAR, channel);
|
||||||
cy_writeb(base_addr + (msvrd << index), ~dtr);
|
cyy_writeb(info, msvrd, ~dtr);
|
||||||
#ifdef CY_DEBUG_DTR
|
#ifdef CY_DEBUG_DTR
|
||||||
printk(KERN_DEBUG "cyc:set_modem_info dropping DTR\n");
|
printk(KERN_DEBUG "cyc:set_modem_info dropping DTR\n");
|
||||||
printk(KERN_DEBUG " status: 0x%x, 0x%x\n",
|
printk(KERN_DEBUG " status: 0x%x, 0x%x\n",
|
||||||
readb(base_addr + (CyMSVR1 << index)),
|
cyy_readb(info, CyMSVR1),
|
||||||
readb(base_addr + (CyMSVR2 << index)));
|
cyy_readb(info, CyMSVR2));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1290,7 +1297,6 @@ static int cy_startup(struct cyclades_port *info, struct tty_struct *tty)
|
||||||
struct cyclades_card *card;
|
struct cyclades_card *card;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
void __iomem *base_addr;
|
|
||||||
int channel;
|
int channel;
|
||||||
unsigned long page;
|
unsigned long page;
|
||||||
|
|
||||||
|
@ -1321,31 +1327,21 @@ static int cy_startup(struct cyclades_port *info, struct tty_struct *tty)
|
||||||
cy_set_line_char(info, tty);
|
cy_set_line_char(info, tty);
|
||||||
|
|
||||||
if (!cy_is_Z(card)) {
|
if (!cy_is_Z(card)) {
|
||||||
int chip = channel >> 2;
|
|
||||||
int index = card->bus_index;
|
|
||||||
channel &= 0x03;
|
channel &= 0x03;
|
||||||
base_addr = card->base_addr + (cy_chip_offset[chip] << index);
|
|
||||||
|
|
||||||
#ifdef CY_DEBUG_OPEN
|
|
||||||
printk(KERN_DEBUG "cyc startup card %d, chip %d, channel %d, "
|
|
||||||
"base_addr %p\n",
|
|
||||||
card, chip, channel, base_addr);
|
|
||||||
#endif
|
|
||||||
spin_lock_irqsave(&card->card_lock, flags);
|
spin_lock_irqsave(&card->card_lock, flags);
|
||||||
|
|
||||||
cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
|
cyy_writeb(info, CyCAR, channel);
|
||||||
|
|
||||||
cy_writeb(base_addr + (CyRTPR << index),
|
cyy_writeb(info, CyRTPR,
|
||||||
(info->default_timeout ? info->default_timeout : 0x02));
|
(info->default_timeout ? info->default_timeout : 0x02));
|
||||||
/* 10ms rx timeout */
|
/* 10ms rx timeout */
|
||||||
|
|
||||||
cyy_issue_cmd(base_addr, CyCHAN_CTL | CyENB_RCVR | CyENB_XMTR,
|
cyy_issue_cmd(info, CyCHAN_CTL | CyENB_RCVR | CyENB_XMTR);
|
||||||
index);
|
|
||||||
|
|
||||||
cyy_change_rts_dtr(info, TIOCM_RTS | TIOCM_DTR, 0);
|
cyy_change_rts_dtr(info, TIOCM_RTS | TIOCM_DTR, 0);
|
||||||
|
|
||||||
cy_writeb(base_addr + (CySRER << index),
|
cyy_writeb(info, CySRER, cyy_readb(info, CySRER) | CyRxData);
|
||||||
readb(base_addr + (CySRER << index)) | CyRxData);
|
|
||||||
} else {
|
} else {
|
||||||
struct CH_CTRL __iomem *ch_ctrl = info->u.cyz.ch_ctrl;
|
struct CH_CTRL __iomem *ch_ctrl = info->u.cyz.ch_ctrl;
|
||||||
|
|
||||||
|
@ -1423,23 +1419,14 @@ errout:
|
||||||
|
|
||||||
static void start_xmit(struct cyclades_port *info)
|
static void start_xmit(struct cyclades_port *info)
|
||||||
{
|
{
|
||||||
struct cyclades_card *card;
|
struct cyclades_card *card = info->card;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
void __iomem *base_addr;
|
int channel = info->line - card->first_line;
|
||||||
int chip, channel, index;
|
|
||||||
|
|
||||||
card = info->card;
|
|
||||||
channel = info->line - card->first_line;
|
|
||||||
if (!cy_is_Z(card)) {
|
if (!cy_is_Z(card)) {
|
||||||
chip = channel >> 2;
|
|
||||||
channel &= 0x03;
|
|
||||||
index = card->bus_index;
|
|
||||||
base_addr = card->base_addr + (cy_chip_offset[chip] << index);
|
|
||||||
|
|
||||||
spin_lock_irqsave(&card->card_lock, flags);
|
spin_lock_irqsave(&card->card_lock, flags);
|
||||||
cy_writeb(base_addr + (CyCAR << index), channel);
|
cyy_writeb(info, CyCAR, channel & 0x03);
|
||||||
cy_writeb(base_addr + (CySRER << index),
|
cyy_writeb(info, CySRER, cyy_readb(info, CySRER) | CyTxRdy);
|
||||||
readb(base_addr + (CySRER << index)) | CyTxRdy);
|
|
||||||
spin_unlock_irqrestore(&card->card_lock, flags);
|
spin_unlock_irqrestore(&card->card_lock, flags);
|
||||||
} else {
|
} else {
|
||||||
#ifdef CONFIG_CYZ_INTR
|
#ifdef CONFIG_CYZ_INTR
|
||||||
|
@ -1466,8 +1453,7 @@ static void cy_shutdown(struct cyclades_port *info, struct tty_struct *tty)
|
||||||
{
|
{
|
||||||
struct cyclades_card *card;
|
struct cyclades_card *card;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
void __iomem *base_addr;
|
int channel;
|
||||||
int chip, channel, index;
|
|
||||||
|
|
||||||
if (!(info->port.flags & ASYNC_INITIALIZED))
|
if (!(info->port.flags & ASYNC_INITIALIZED))
|
||||||
return;
|
return;
|
||||||
|
@ -1475,17 +1461,6 @@ static void cy_shutdown(struct cyclades_port *info, struct tty_struct *tty)
|
||||||
card = info->card;
|
card = info->card;
|
||||||
channel = info->line - card->first_line;
|
channel = info->line - card->first_line;
|
||||||
if (!cy_is_Z(card)) {
|
if (!cy_is_Z(card)) {
|
||||||
chip = channel >> 2;
|
|
||||||
channel &= 0x03;
|
|
||||||
index = card->bus_index;
|
|
||||||
base_addr = card->base_addr + (cy_chip_offset[chip] << index);
|
|
||||||
|
|
||||||
#ifdef CY_DEBUG_OPEN
|
|
||||||
printk(KERN_DEBUG "cyc shutdown Y card %d, chip %d, "
|
|
||||||
"channel %d, base_addr %p\n",
|
|
||||||
card, chip, channel, base_addr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
spin_lock_irqsave(&card->card_lock, flags);
|
spin_lock_irqsave(&card->card_lock, flags);
|
||||||
|
|
||||||
/* Clear delta_msr_wait queue to avoid mem leaks. */
|
/* Clear delta_msr_wait queue to avoid mem leaks. */
|
||||||
|
@ -1500,7 +1475,7 @@ static void cy_shutdown(struct cyclades_port *info, struct tty_struct *tty)
|
||||||
if (tty->termios->c_cflag & HUPCL)
|
if (tty->termios->c_cflag & HUPCL)
|
||||||
cyy_change_rts_dtr(info, 0, TIOCM_RTS | TIOCM_DTR);
|
cyy_change_rts_dtr(info, 0, TIOCM_RTS | TIOCM_DTR);
|
||||||
|
|
||||||
cyy_issue_cmd(base_addr, CyCHAN_CTL | CyDIS_RCVR, index);
|
cyy_issue_cmd(info, CyCHAN_CTL | 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)!!! */
|
||||||
|
|
||||||
|
@ -1677,8 +1652,6 @@ static void cy_wait_until_sent(struct tty_struct *tty, int timeout)
|
||||||
{
|
{
|
||||||
struct cyclades_card *card;
|
struct cyclades_card *card;
|
||||||
struct cyclades_port *info = tty->driver_data;
|
struct cyclades_port *info = tty->driver_data;
|
||||||
void __iomem *base_addr;
|
|
||||||
int chip, channel, index;
|
|
||||||
unsigned long orig_jiffies;
|
unsigned long orig_jiffies;
|
||||||
int char_time;
|
int char_time;
|
||||||
|
|
||||||
|
@ -1722,13 +1695,8 @@ static void cy_wait_until_sent(struct tty_struct *tty, int timeout)
|
||||||
timeout, char_time, jiffies);
|
timeout, char_time, jiffies);
|
||||||
#endif
|
#endif
|
||||||
card = info->card;
|
card = info->card;
|
||||||
channel = (info->line) - (card->first_line);
|
|
||||||
if (!cy_is_Z(card)) {
|
if (!cy_is_Z(card)) {
|
||||||
chip = channel >> 2;
|
while (cyy_readb(info, CySRER) & CyTxRdy) {
|
||||||
channel &= 0x03;
|
|
||||||
index = card->bus_index;
|
|
||||||
base_addr = card->base_addr + (cy_chip_offset[chip] << index);
|
|
||||||
while (readb(base_addr + (CySRER << index)) & CyTxRdy) {
|
|
||||||
#ifdef CY_DEBUG_WAIT_UNTIL_SENT
|
#ifdef CY_DEBUG_WAIT_UNTIL_SENT
|
||||||
printk(KERN_DEBUG "Not clean (jiff=%lu)...", jiffies);
|
printk(KERN_DEBUG "Not clean (jiff=%lu)...", jiffies);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1790,6 +1758,7 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
|
||||||
struct cyclades_port *info = tty->driver_data;
|
struct cyclades_port *info = tty->driver_data;
|
||||||
struct cyclades_card *card;
|
struct cyclades_card *card;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
int channel;
|
||||||
|
|
||||||
if (!info || serial_paranoia_check(info, tty->name, "cy_close"))
|
if (!info || serial_paranoia_check(info, tty->name, "cy_close"))
|
||||||
return;
|
return;
|
||||||
|
@ -1799,18 +1768,13 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
|
||||||
if (!tty_port_close_start(&info->port, tty, filp))
|
if (!tty_port_close_start(&info->port, tty, filp))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
channel = info->line - card->first_line;
|
||||||
spin_lock_irqsave(&card->card_lock, flags);
|
spin_lock_irqsave(&card->card_lock, flags);
|
||||||
|
|
||||||
if (!cy_is_Z(card)) {
|
if (!cy_is_Z(card)) {
|
||||||
int channel = info->line - card->first_line;
|
|
||||||
int index = card->bus_index;
|
|
||||||
void __iomem *base_addr = card->base_addr +
|
|
||||||
(cy_chip_offset[channel >> 2] << index);
|
|
||||||
/* Stop accepting input */
|
/* Stop accepting input */
|
||||||
channel &= 0x03;
|
cyy_writeb(info, CyCAR, channel & 0x03);
|
||||||
cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
|
cyy_writeb(info, CySRER, cyy_readb(info, CySRER) & ~CyRxData);
|
||||||
cy_writeb(base_addr + (CySRER << index),
|
|
||||||
readb(base_addr + (CySRER << index)) & ~CyRxData);
|
|
||||||
if (info->port.flags & ASYNC_INITIALIZED) {
|
if (info->port.flags & ASYNC_INITIALIZED) {
|
||||||
/* Waiting for on-board buffers to be empty before
|
/* Waiting for on-board buffers to be empty before
|
||||||
closing the port */
|
closing the port */
|
||||||
|
@ -1823,7 +1787,6 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
|
||||||
/* Waiting for on-board buffers to be empty before closing
|
/* Waiting for on-board buffers to be empty before closing
|
||||||
the port */
|
the port */
|
||||||
struct CH_CTRL __iomem *ch_ctrl = info->u.cyz.ch_ctrl;
|
struct CH_CTRL __iomem *ch_ctrl = info->u.cyz.ch_ctrl;
|
||||||
int channel = info->line - card->first_line;
|
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (readl(&ch_ctrl->flow_status) != C_FS_TXIDLE) {
|
if (readl(&ch_ctrl->flow_status) != C_FS_TXIDLE) {
|
||||||
|
@ -2064,8 +2027,7 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
|
||||||
{
|
{
|
||||||
struct cyclades_card *card;
|
struct cyclades_card *card;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
void __iomem *base_addr;
|
int channel;
|
||||||
int chip, channel, index;
|
|
||||||
unsigned cflag, iflag;
|
unsigned cflag, iflag;
|
||||||
int baud, baud_rate = 0;
|
int baud, baud_rate = 0;
|
||||||
int i;
|
int i;
|
||||||
|
@ -2095,9 +2057,6 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
|
||||||
channel = info->line - card->first_line;
|
channel = info->line - card->first_line;
|
||||||
|
|
||||||
if (!cy_is_Z(card)) {
|
if (!cy_is_Z(card)) {
|
||||||
|
|
||||||
index = card->bus_index;
|
|
||||||
|
|
||||||
/* baud rate */
|
/* baud rate */
|
||||||
baud = tty_get_baud_rate(tty);
|
baud = tty_get_baud_rate(tty);
|
||||||
if (baud == 38400 && (info->port.flags & ASYNC_SPD_MASK) ==
|
if (baud == 38400 && (info->port.flags & ASYNC_SPD_MASK) ==
|
||||||
|
@ -2208,70 +2167,67 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
|
||||||
cable. Contact Marcio Saito for details.
|
cable. Contact Marcio Saito for details.
|
||||||
***********************************************/
|
***********************************************/
|
||||||
|
|
||||||
chip = channel >> 2;
|
|
||||||
channel &= 0x03;
|
channel &= 0x03;
|
||||||
base_addr = card->base_addr + (cy_chip_offset[chip] << index);
|
|
||||||
|
|
||||||
spin_lock_irqsave(&card->card_lock, flags);
|
spin_lock_irqsave(&card->card_lock, flags);
|
||||||
cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
|
cyy_writeb(info, CyCAR, channel);
|
||||||
|
|
||||||
/* tx and rx baud rate */
|
/* tx and rx baud rate */
|
||||||
|
|
||||||
cy_writeb(base_addr + (CyTCOR << index), info->tco);
|
cyy_writeb(info, CyTCOR, info->tco);
|
||||||
cy_writeb(base_addr + (CyTBPR << index), info->tbpr);
|
cyy_writeb(info, CyTBPR, info->tbpr);
|
||||||
cy_writeb(base_addr + (CyRCOR << index), info->rco);
|
cyy_writeb(info, CyRCOR, info->rco);
|
||||||
cy_writeb(base_addr + (CyRBPR << index), info->rbpr);
|
cyy_writeb(info, CyRBPR, info->rbpr);
|
||||||
|
|
||||||
/* set line characteristics according configuration */
|
/* set line characteristics according configuration */
|
||||||
|
|
||||||
cy_writeb(base_addr + (CySCHR1 << index), START_CHAR(tty));
|
cyy_writeb(info, CySCHR1, START_CHAR(tty));
|
||||||
cy_writeb(base_addr + (CySCHR2 << index), STOP_CHAR(tty));
|
cyy_writeb(info, CySCHR2, STOP_CHAR(tty));
|
||||||
cy_writeb(base_addr + (CyCOR1 << index), info->cor1);
|
cyy_writeb(info, CyCOR1, info->cor1);
|
||||||
cy_writeb(base_addr + (CyCOR2 << index), info->cor2);
|
cyy_writeb(info, CyCOR2, info->cor2);
|
||||||
cy_writeb(base_addr + (CyCOR3 << index), info->cor3);
|
cyy_writeb(info, CyCOR3, info->cor3);
|
||||||
cy_writeb(base_addr + (CyCOR4 << index), info->cor4);
|
cyy_writeb(info, CyCOR4, info->cor4);
|
||||||
cy_writeb(base_addr + (CyCOR5 << index), info->cor5);
|
cyy_writeb(info, CyCOR5, info->cor5);
|
||||||
|
|
||||||
cyy_issue_cmd(base_addr, CyCOR_CHANGE | CyCOR1ch | CyCOR2ch |
|
cyy_issue_cmd(info, CyCOR_CHANGE | CyCOR1ch | CyCOR2ch |
|
||||||
CyCOR3ch, index);
|
CyCOR3ch);
|
||||||
|
|
||||||
/* !!! Is this needed? */
|
/* !!! Is this needed? */
|
||||||
cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
|
cyy_writeb(info, CyCAR, channel);
|
||||||
cy_writeb(base_addr + (CyRTPR << index),
|
cyy_writeb(info, CyRTPR,
|
||||||
(info->default_timeout ? info->default_timeout : 0x02));
|
(info->default_timeout ? info->default_timeout : 0x02));
|
||||||
/* 10ms rx timeout */
|
/* 10ms rx timeout */
|
||||||
|
|
||||||
if (C_CLOCAL(tty)) {
|
if (C_CLOCAL(tty)) {
|
||||||
/* without modem intr */
|
/* without modem intr */
|
||||||
cy_writeb(base_addr + (CySRER << index),
|
cyy_writeb(info, CySRER,
|
||||||
readb(base_addr + (CySRER << index)) | CyMdmCh);
|
cyy_readb(info, CySRER) | CyMdmCh);
|
||||||
/* act on 1->0 modem transitions */
|
/* act on 1->0 modem transitions */
|
||||||
if ((cflag & CRTSCTS) && info->rflow) {
|
if ((cflag & CRTSCTS) && info->rflow) {
|
||||||
cy_writeb(base_addr + (CyMCOR1 << index),
|
cyy_writeb(info, CyMCOR1,
|
||||||
(CyCTS | rflow_thr[i]));
|
(CyCTS | rflow_thr[i]));
|
||||||
} else {
|
} else {
|
||||||
cy_writeb(base_addr + (CyMCOR1 << index),
|
cyy_writeb(info, CyMCOR1,
|
||||||
CyCTS);
|
CyCTS);
|
||||||
}
|
}
|
||||||
/* act on 0->1 modem transitions */
|
/* act on 0->1 modem transitions */
|
||||||
cy_writeb(base_addr + (CyMCOR2 << index), CyCTS);
|
cyy_writeb(info, CyMCOR2, CyCTS);
|
||||||
} else {
|
} else {
|
||||||
/* without modem intr */
|
/* without modem intr */
|
||||||
cy_writeb(base_addr + (CySRER << index),
|
cyy_writeb(info, CySRER,
|
||||||
readb(base_addr +
|
cyy_readb(info, CySRER) | CyMdmCh);
|
||||||
(CySRER << index)) | CyMdmCh);
|
|
||||||
/* act on 1->0 modem transitions */
|
/* act on 1->0 modem transitions */
|
||||||
if ((cflag & CRTSCTS) && info->rflow) {
|
if ((cflag & CRTSCTS) && info->rflow) {
|
||||||
cy_writeb(base_addr + (CyMCOR1 << index),
|
cyy_writeb(info, CyMCOR1,
|
||||||
(CyDSR | CyCTS | CyRI | CyDCD |
|
(CyDSR | CyCTS | CyRI | CyDCD |
|
||||||
rflow_thr[i]));
|
rflow_thr[i]));
|
||||||
} else {
|
} else {
|
||||||
cy_writeb(base_addr + (CyMCOR1 << index),
|
cyy_writeb(info, CyMCOR1,
|
||||||
CyDSR | CyCTS | CyRI | CyDCD);
|
CyDSR | CyCTS | CyRI | CyDCD);
|
||||||
}
|
}
|
||||||
/* act on 0->1 modem transitions */
|
/* act on 0->1 modem transitions */
|
||||||
cy_writeb(base_addr + (CyMCOR2 << index),
|
cyy_writeb(info, CyMCOR2,
|
||||||
CyDSR | CyCTS | CyRI | CyDCD);
|
CyDSR | CyCTS | CyRI | CyDCD);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 0) /* baud rate is zero, turn off line */
|
if (i == 0) /* baud rate is zero, turn off line */
|
||||||
|
@ -2482,24 +2438,14 @@ check_and_exit:
|
||||||
*/
|
*/
|
||||||
static int get_lsr_info(struct cyclades_port *info, unsigned int __user *value)
|
static int get_lsr_info(struct cyclades_port *info, unsigned int __user *value)
|
||||||
{
|
{
|
||||||
struct cyclades_card *card;
|
struct cyclades_card *card = info->card;
|
||||||
int chip, channel, index;
|
|
||||||
unsigned char status;
|
|
||||||
unsigned int result;
|
unsigned int result;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
void __iomem *base_addr;
|
u8 status;
|
||||||
|
|
||||||
card = info->card;
|
|
||||||
channel = (info->line) - (card->first_line);
|
|
||||||
if (!cy_is_Z(card)) {
|
if (!cy_is_Z(card)) {
|
||||||
chip = channel >> 2;
|
|
||||||
channel &= 0x03;
|
|
||||||
index = card->bus_index;
|
|
||||||
base_addr = card->base_addr + (cy_chip_offset[chip] << index);
|
|
||||||
|
|
||||||
spin_lock_irqsave(&card->card_lock, flags);
|
spin_lock_irqsave(&card->card_lock, flags);
|
||||||
status = readb(base_addr + (CySRER << index)) &
|
status = cyy_readb(info, CySRER) & (CyTxRdy | CyTxMpty);
|
||||||
(CyTxRdy | CyTxMpty);
|
|
||||||
spin_unlock_irqrestore(&card->card_lock, flags);
|
spin_unlock_irqrestore(&card->card_lock, flags);
|
||||||
result = (status ? 0 : TIOCSER_TEMT);
|
result = (status ? 0 : TIOCSER_TEMT);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2513,29 +2459,23 @@ static int cy_tiocmget(struct tty_struct *tty, struct file *file)
|
||||||
{
|
{
|
||||||
struct cyclades_port *info = tty->driver_data;
|
struct cyclades_port *info = tty->driver_data;
|
||||||
struct cyclades_card *card;
|
struct cyclades_card *card;
|
||||||
void __iomem *base_addr;
|
int result;
|
||||||
int result, channel;
|
|
||||||
|
|
||||||
if (serial_paranoia_check(info, tty->name, __func__))
|
if (serial_paranoia_check(info, tty->name, __func__))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
card = info->card;
|
card = info->card;
|
||||||
channel = info->line - card->first_line;
|
|
||||||
|
|
||||||
lock_kernel();
|
lock_kernel();
|
||||||
if (!cy_is_Z(card)) {
|
if (!cy_is_Z(card)) {
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
unsigned char status;
|
int channel = info->line - card->first_line;
|
||||||
int chip = channel >> 2;
|
u8 status;
|
||||||
int index = card->bus_index;
|
|
||||||
|
|
||||||
channel &= 0x03;
|
|
||||||
base_addr = card->base_addr + (cy_chip_offset[chip] << index);
|
|
||||||
|
|
||||||
spin_lock_irqsave(&card->card_lock, flags);
|
spin_lock_irqsave(&card->card_lock, flags);
|
||||||
cy_writeb(base_addr + (CyCAR << index), (u8)channel);
|
cyy_writeb(info, CyCAR, channel & 0x03);
|
||||||
status = readb(base_addr + (CyMSVR1 << index));
|
status = cyy_readb(info, CyMSVR1);
|
||||||
status |= readb(base_addr + (CyMSVR2 << index));
|
status |= cyy_readb(info, CyMSVR2);
|
||||||
spin_unlock_irqrestore(&card->card_lock, flags);
|
spin_unlock_irqrestore(&card->card_lock, flags);
|
||||||
|
|
||||||
if (info->rtsdtr_inv) {
|
if (info->rtsdtr_inv) {
|
||||||
|
@ -2689,26 +2629,16 @@ static int cy_break(struct tty_struct *tty, int break_state)
|
||||||
|
|
||||||
static int set_threshold(struct cyclades_port *info, unsigned long value)
|
static int set_threshold(struct cyclades_port *info, unsigned long value)
|
||||||
{
|
{
|
||||||
struct cyclades_card *card;
|
struct cyclades_card *card = info->card;
|
||||||
void __iomem *base_addr;
|
|
||||||
int channel, chip, index;
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
card = info->card;
|
|
||||||
channel = info->line - card->first_line;
|
|
||||||
if (!cy_is_Z(card)) {
|
if (!cy_is_Z(card)) {
|
||||||
chip = channel >> 2;
|
|
||||||
channel &= 0x03;
|
|
||||||
index = card->bus_index;
|
|
||||||
base_addr =
|
|
||||||
card->base_addr + (cy_chip_offset[chip] << index);
|
|
||||||
|
|
||||||
info->cor3 &= ~CyREC_FIFO;
|
info->cor3 &= ~CyREC_FIFO;
|
||||||
info->cor3 |= value & CyREC_FIFO;
|
info->cor3 |= value & CyREC_FIFO;
|
||||||
|
|
||||||
spin_lock_irqsave(&card->card_lock, flags);
|
spin_lock_irqsave(&card->card_lock, flags);
|
||||||
cy_writeb(base_addr + (CyCOR3 << index), info->cor3);
|
cyy_writeb(info, CyCOR3, info->cor3);
|
||||||
cyy_issue_cmd(base_addr, CyCOR_CHANGE | CyCOR3ch, index);
|
cyy_issue_cmd(info, CyCOR_CHANGE | CyCOR3ch);
|
||||||
spin_unlock_irqrestore(&card->card_lock, flags);
|
spin_unlock_irqrestore(&card->card_lock, flags);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2717,20 +2647,10 @@ static int set_threshold(struct cyclades_port *info, unsigned long value)
|
||||||
static int get_threshold(struct cyclades_port *info,
|
static int get_threshold(struct cyclades_port *info,
|
||||||
unsigned long __user *value)
|
unsigned long __user *value)
|
||||||
{
|
{
|
||||||
struct cyclades_card *card;
|
struct cyclades_card *card = info->card;
|
||||||
void __iomem *base_addr;
|
|
||||||
int channel, chip, index;
|
|
||||||
unsigned long tmp;
|
|
||||||
|
|
||||||
card = info->card;
|
|
||||||
channel = info->line - card->first_line;
|
|
||||||
if (!cy_is_Z(card)) {
|
if (!cy_is_Z(card)) {
|
||||||
chip = channel >> 2;
|
u8 tmp = cyy_readb(info, CyCOR3) & CyREC_FIFO;
|
||||||
channel &= 0x03;
|
|
||||||
index = card->bus_index;
|
|
||||||
base_addr = card->base_addr + (cy_chip_offset[chip] << index);
|
|
||||||
|
|
||||||
tmp = readb(base_addr + (CyCOR3 << index)) & CyREC_FIFO;
|
|
||||||
return put_user(tmp, value);
|
return put_user(tmp, value);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2738,21 +2658,12 @@ static int get_threshold(struct cyclades_port *info,
|
||||||
|
|
||||||
static int set_timeout(struct cyclades_port *info, unsigned long value)
|
static int set_timeout(struct cyclades_port *info, unsigned long value)
|
||||||
{
|
{
|
||||||
struct cyclades_card *card;
|
struct cyclades_card *card = info->card;
|
||||||
void __iomem *base_addr;
|
|
||||||
int channel, chip, index;
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
card = info->card;
|
|
||||||
channel = info->line - card->first_line;
|
|
||||||
if (!cy_is_Z(card)) {
|
if (!cy_is_Z(card)) {
|
||||||
chip = channel >> 2;
|
|
||||||
channel &= 0x03;
|
|
||||||
index = card->bus_index;
|
|
||||||
base_addr = card->base_addr + (cy_chip_offset[chip] << index);
|
|
||||||
|
|
||||||
spin_lock_irqsave(&card->card_lock, flags);
|
spin_lock_irqsave(&card->card_lock, flags);
|
||||||
cy_writeb(base_addr + (CyRTPR << index), value & 0xff);
|
cyy_writeb(info, CyRTPR, value & 0xff);
|
||||||
spin_unlock_irqrestore(&card->card_lock, flags);
|
spin_unlock_irqrestore(&card->card_lock, flags);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2761,20 +2672,10 @@ static int set_timeout(struct cyclades_port *info, unsigned long value)
|
||||||
static int get_timeout(struct cyclades_port *info,
|
static int get_timeout(struct cyclades_port *info,
|
||||||
unsigned long __user *value)
|
unsigned long __user *value)
|
||||||
{
|
{
|
||||||
struct cyclades_card *card;
|
struct cyclades_card *card = info->card;
|
||||||
void __iomem *base_addr;
|
|
||||||
int channel, chip, index;
|
|
||||||
unsigned long tmp;
|
|
||||||
|
|
||||||
card = info->card;
|
|
||||||
channel = info->line - card->first_line;
|
|
||||||
if (!cy_is_Z(card)) {
|
if (!cy_is_Z(card)) {
|
||||||
chip = channel >> 2;
|
u8 tmp = cyy_readb(info, CyRTPR);
|
||||||
channel &= 0x03;
|
|
||||||
index = card->bus_index;
|
|
||||||
base_addr = card->base_addr + (cy_chip_offset[chip] << index);
|
|
||||||
|
|
||||||
tmp = readb(base_addr + (CyRTPR << index));
|
|
||||||
return put_user(tmp, value);
|
return put_user(tmp, value);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -3101,8 +3002,7 @@ static void cy_stop(struct tty_struct *tty)
|
||||||
{
|
{
|
||||||
struct cyclades_card *cinfo;
|
struct cyclades_card *cinfo;
|
||||||
struct cyclades_port *info = tty->driver_data;
|
struct cyclades_port *info = tty->driver_data;
|
||||||
void __iomem *base_addr;
|
int channel;
|
||||||
int chip, channel, index;
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
#ifdef CY_DEBUG_OTHER
|
#ifdef CY_DEBUG_OTHER
|
||||||
|
@ -3115,16 +3015,9 @@ static void cy_stop(struct tty_struct *tty)
|
||||||
cinfo = info->card;
|
cinfo = info->card;
|
||||||
channel = info->line - cinfo->first_line;
|
channel = info->line - cinfo->first_line;
|
||||||
if (!cy_is_Z(cinfo)) {
|
if (!cy_is_Z(cinfo)) {
|
||||||
index = cinfo->bus_index;
|
|
||||||
chip = channel >> 2;
|
|
||||||
channel &= 0x03;
|
|
||||||
base_addr = cinfo->base_addr + (cy_chip_offset[chip] << index);
|
|
||||||
|
|
||||||
spin_lock_irqsave(&cinfo->card_lock, flags);
|
spin_lock_irqsave(&cinfo->card_lock, flags);
|
||||||
cy_writeb(base_addr + (CyCAR << index),
|
cyy_writeb(info, CyCAR, channel & 0x03);
|
||||||
(u_char)(channel & 0x0003)); /* index channel */
|
cyy_writeb(info, CySRER, cyy_readb(info, CySRER) & ~CyTxRdy);
|
||||||
cy_writeb(base_addr + (CySRER << index),
|
|
||||||
readb(base_addr + (CySRER << index)) & ~CyTxRdy);
|
|
||||||
spin_unlock_irqrestore(&cinfo->card_lock, flags);
|
spin_unlock_irqrestore(&cinfo->card_lock, flags);
|
||||||
}
|
}
|
||||||
} /* cy_stop */
|
} /* cy_stop */
|
||||||
|
@ -3133,8 +3026,7 @@ static void cy_start(struct tty_struct *tty)
|
||||||
{
|
{
|
||||||
struct cyclades_card *cinfo;
|
struct cyclades_card *cinfo;
|
||||||
struct cyclades_port *info = tty->driver_data;
|
struct cyclades_port *info = tty->driver_data;
|
||||||
void __iomem *base_addr;
|
int channel;
|
||||||
int chip, channel, index;
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
#ifdef CY_DEBUG_OTHER
|
#ifdef CY_DEBUG_OTHER
|
||||||
|
@ -3146,17 +3038,10 @@ static void cy_start(struct tty_struct *tty)
|
||||||
|
|
||||||
cinfo = info->card;
|
cinfo = info->card;
|
||||||
channel = info->line - cinfo->first_line;
|
channel = info->line - cinfo->first_line;
|
||||||
index = cinfo->bus_index;
|
|
||||||
if (!cy_is_Z(cinfo)) {
|
if (!cy_is_Z(cinfo)) {
|
||||||
chip = channel >> 2;
|
|
||||||
channel &= 0x03;
|
|
||||||
base_addr = cinfo->base_addr + (cy_chip_offset[chip] << index);
|
|
||||||
|
|
||||||
spin_lock_irqsave(&cinfo->card_lock, flags);
|
spin_lock_irqsave(&cinfo->card_lock, flags);
|
||||||
cy_writeb(base_addr + (CyCAR << index),
|
cyy_writeb(info, CyCAR, channel & 0x03);
|
||||||
(u_char) (channel & 0x0003)); /* index channel */
|
cyy_writeb(info, CySRER, cyy_readb(info, CySRER) | CyTxRdy);
|
||||||
cy_writeb(base_addr + (CySRER << index),
|
|
||||||
readb(base_addr + (CySRER << index)) | CyTxRdy);
|
|
||||||
spin_unlock_irqrestore(&cinfo->card_lock, flags);
|
spin_unlock_irqrestore(&cinfo->card_lock, flags);
|
||||||
}
|
}
|
||||||
} /* cy_start */
|
} /* cy_start */
|
||||||
|
@ -3185,18 +3070,13 @@ static int cyy_carrier_raised(struct tty_port *port)
|
||||||
struct cyclades_port *info = container_of(port, struct cyclades_port,
|
struct cyclades_port *info = container_of(port, struct cyclades_port,
|
||||||
port);
|
port);
|
||||||
struct cyclades_card *cinfo = info->card;
|
struct cyclades_card *cinfo = info->card;
|
||||||
void __iomem *base = cinfo->base_addr;
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int channel = info->line - cinfo->first_line;
|
int channel = info->line - cinfo->first_line;
|
||||||
int chip = channel >> 2, index = cinfo->bus_index;
|
|
||||||
u32 cd;
|
u32 cd;
|
||||||
|
|
||||||
channel &= 0x03;
|
|
||||||
base += cy_chip_offset[chip] << index;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&cinfo->card_lock, flags);
|
spin_lock_irqsave(&cinfo->card_lock, flags);
|
||||||
cy_writeb(base + (CyCAR << index), (u8)channel);
|
cyy_writeb(info, CyCAR, channel & 0x03);
|
||||||
cd = readb(base + (CyMSVR1 << index)) & CyDCD;
|
cd = cyy_readb(info, CyMSVR1) & CyDCD;
|
||||||
spin_unlock_irqrestore(&cinfo->card_lock, flags);
|
spin_unlock_irqrestore(&cinfo->card_lock, flags);
|
||||||
|
|
||||||
return cd;
|
return cd;
|
||||||
|
@ -3326,9 +3206,9 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo)
|
||||||
info->cor3 = 0x08; /* _very_ small rcv threshold */
|
info->cor3 = 0x08; /* _very_ small rcv threshold */
|
||||||
|
|
||||||
chip_number = channel / CyPORTS_PER_CHIP;
|
chip_number = channel / CyPORTS_PER_CHIP;
|
||||||
info->chip_rev = readb(cinfo->base_addr +
|
info->u.cyy.base_addr = cinfo->base_addr +
|
||||||
(cy_chip_offset[chip_number] << index) +
|
(cy_chip_offset[chip_number] << index);
|
||||||
(CyGFRCR << index));
|
info->chip_rev = cyy_readb(info, CyGFRCR);
|
||||||
|
|
||||||
if (info->chip_rev >= CD1400_REV_J) {
|
if (info->chip_rev >= CD1400_REV_J) {
|
||||||
/* It is a CD1400 rev. J or later */
|
/* It is a CD1400 rev. J or later */
|
||||||
|
|
|
@ -544,7 +544,7 @@ struct cyclades_port {
|
||||||
struct cyclades_card *card;
|
struct cyclades_card *card;
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
int filler;
|
void __iomem *base_addr;
|
||||||
} cyy;
|
} cyy;
|
||||||
struct {
|
struct {
|
||||||
struct CH_CTRL __iomem *ch_ctrl;
|
struct CH_CTRL __iomem *ch_ctrl;
|
||||||
|
|
Loading…
Reference in a new issue