* PURPOSE. See the GNU General Public License for more details.
*/
-
#include <linux/kernel.h>
#include <linux/sched.h> /* For jiffies, task states */
#include <linux/interrupt.h> /* For tasklet and interrupt structs/defines */
static void neo_send_immediate_char(struct channel_t *ch, unsigned char c);
static irqreturn_t neo_intr(int irq, void *voidbrd);
-
struct board_ops dgnc_neo_ops = {
.tasklet = neo_tasklet,
.intr = neo_intr,
static uint dgnc_offset_table[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
-
/*
* This function allows calls to ensure that all outstanding
* PCI writes have been completed, by doing a PCI read against
unsigned char ier = readb(&ch->ch_neo_uart->ier);
unsigned char efr = readb(&ch->ch_neo_uart->efr);
-
/* Turn on auto CTS flow control */
#if 1
ier |= UART_17158_IER_CTSDSR;
neo_pci_posting_flush(ch->ch_bd);
}
-
static inline void neo_set_rts_flow_control(struct channel_t *ch)
{
unsigned char ier = readb(&ch->ch_neo_uart->ier);
neo_pci_posting_flush(ch->ch_bd);
}
-
static inline void neo_set_ixon_flow_control(struct channel_t *ch)
{
unsigned char ier = readb(&ch->ch_neo_uart->ier);
neo_pci_posting_flush(ch->ch_bd);
}
-
static inline void neo_set_ixoff_flow_control(struct channel_t *ch)
{
unsigned char ier = readb(&ch->ch_neo_uart->ier);
neo_pci_posting_flush(ch->ch_bd);
}
-
static inline void neo_set_no_input_flow_control(struct channel_t *ch)
{
unsigned char ier = readb(&ch->ch_neo_uart->ier);
else
efr &= ~(UART_17158_EFR_ECB | UART_17158_EFR_IXOFF);
-
/* Why? Becuz Exar's spec says we have to zero it out before setting it */
writeb(0, &ch->ch_neo_uart->efr);
neo_pci_posting_flush(ch->ch_bd);
}
-
static inline void neo_set_no_output_flow_control(struct channel_t *ch)
{
unsigned char ier = readb(&ch->ch_neo_uart->ier);
neo_pci_posting_flush(ch->ch_bd);
}
-
/* change UARTs start/stop chars */
static inline void neo_set_new_start_stop_chars(struct channel_t *ch)
{
-
/* if hardware flow control is set, then skip this whole thing */
if (ch->ch_digi.digi_flags & (CTSPACE | RTSPACE) || ch->ch_c_cflag & CRTSCTS)
return;
neo_pci_posting_flush(ch->ch_bd);
}
-
/*
* No locks are assumed to be held when calling this function.
*/
spin_unlock_irqrestore(&ch->ch_lock, flags);
}
-
/*
* Parse the ISR register.
*/
return;
ch = brd->channels[port];
- if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
+ if (ch->magic != DGNC_CHANNEL_MAGIC)
return;
/* Here we try to figure out what caused the interrupt to happen */
while (1) {
-
isr = readb(&ch->ch_neo_uart->isr_fcr);
/* Bail if no pending interrupt */
}
}
-
static inline void neo_parse_lsr(struct dgnc_board *brd, uint port)
{
struct channel_t *ch;
}
}
-
/*
* neo_param()
* Send any/all changes to the line to the UART.
if (!tty || tty->magic != TTY_MAGIC)
return;
- un = (struct un_t *) tty->driver_data;
+ un = (struct un_t *)tty->driver_data;
if (!un || un->magic != DGNC_UNIT_MAGIC)
return;
return;
} else if (ch->ch_custom_speed) {
-
baud = ch->ch_custom_speed;
/* Handle transition from B0 */
if (ch->ch_flags & CH_BAUD0) {
neo_parse_modem(ch, readb(&ch->ch_neo_uart->msr));
}
-
/*
* Our board poller function.
*/
static void neo_tasklet(unsigned long data)
{
- struct dgnc_board *bd = (struct dgnc_board *) data;
+ struct dgnc_board *bd = (struct dgnc_board *)data;
struct channel_t *ch;
unsigned long flags;
int i;
/* Allow interrupt routine to access the interrupt register again */
spin_unlock_irqrestore(&bd->bd_intr_lock, flags);
-
}
-
/*
* dgnc_neo_intr()
*
/* Loop on each port */
while ((uart_poll & 0xff) != 0) {
-
tmp = uart_poll;
/* Check current port to see if it has interrupt pending */
/* Switch on type of interrupt we have */
switch (type) {
-
case UART_17158_RXRDY_TIMEOUT:
/*
* RXRDY Time-out is cleared by reading data in the
return IRQ_HANDLED;
}
-
/*
* Neo specific way of turning off the receiver.
* Used as a way to enforce queue flow control when in
neo_pci_posting_flush(ch->ch_bd);
}
-
/*
* Neo specific way of turning on the receiver.
* Used as a way to un-enforce queue flow control when in
neo_pci_posting_flush(ch->ch_bd);
}
-
static void neo_copy_data_from_uart_to_queue(struct channel_t *ch)
{
int qleft = 0;
total -= 3;
}
-
/*
* Finally, bound the copy to make sure we don't overflow
* our own queue...
total = min(total, qleft);
while (total > 0) {
-
/*
* Grab the linestatus register, we need to check
* to see if there are any errors in the FIFO.
break;
/* Make sure we don't go over the end of our queue */
- n = min(((uint) total), (RQUEUESIZE - (uint) head));
+ n = min(((uint)total), (RQUEUESIZE - (uint)head));
/*
* Cut down n even further if needed, this is to fix
memcpy_fromio(ch->ch_rqueue + head, &ch->ch_neo_uart->txrxburst, n);
/*
- * Since RX_FIFO_DATA_ERROR was 0, we are guarenteed
+ * Since RX_FIFO_DATA_ERROR was 0, we are guaranteed
* that all the data currently in the FIFO is free of
* breaks and parity/frame/orun errors.
*/
* Also deal with any possible queue overflow here as well.
*/
while (1) {
-
/*
* Its possible we have a linestatus from the loop above
* this, so we "OR" on any extra bits.
}
memcpy_fromio(ch->ch_rqueue + head, &ch->ch_neo_uart->txrxburst, 1);
- ch->ch_equeue[head] = (unsigned char) linestatus;
+ ch->ch_equeue[head] = (unsigned char)linestatus;
/* Ditch any remaining linestatus value. */
linestatus = 0;
spin_unlock_irqrestore(&ch->ch_lock, flags);
}
-
/*
* This function basically goes to sleep for secs, or until
* it gets signalled that the port has fully drained.
if (!tty || tty->magic != TTY_MAGIC)
return -ENXIO;
- un = (struct un_t *) tty->driver_data;
+ un = (struct un_t *)tty->driver_data;
if (!un || un->magic != DGNC_UNIT_MAGIC)
return -ENXIO;
return rc;
}
-
/*
* Flush the WRITE FIFO on the Neo.
*
neo_pci_posting_flush(ch->ch_bd);
for (i = 0; i < 10; i++) {
-
/* Check to see if the UART feels it completely flushed the FIFO. */
tmp = readb(&ch->ch_neo_uart->isr_fcr);
if (tmp & 4)
ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM);
}
-
/*
* Flush the READ FIFO on the Neo.
*
neo_pci_posting_flush(ch->ch_bd);
for (i = 0; i < 10; i++) {
-
/* Check to see if the UART feels it completely flushed the FIFO. */
tmp = readb(&ch->ch_neo_uart->isr_fcr);
if (tmp & 2)
}
}
-
static void neo_copy_data_from_queue_to_uart(struct channel_t *ch)
{
ushort head;
/* If port is "stopped", don't send any data to the UART */
if ((ch->ch_flags & CH_FORCED_STOP) ||
- (ch->ch_flags & CH_BREAK_SENDING))
+ (ch->ch_flags & CH_BREAK_SENDING))
goto exit_unlock;
/*
n = readb(&ch->ch_neo_uart->tfifo);
- if ((unsigned int) n > ch->ch_t_tlevel)
+ if ((unsigned int)n > ch->ch_t_tlevel)
goto exit_unlock;
n = UART_17158_TX_FIFOSIZE - ch->ch_t_tlevel;
n = min(n, qlen);
while (n > 0) {
-
s = ((head >= tail) ? head : WQUEUESIZE) - tail;
s = min(s, n);
spin_unlock_irqrestore(&ch->ch_lock, flags);
}
-
static void neo_parse_modem(struct channel_t *ch, unsigned char signals)
{
unsigned char msignals = signals;
ch->ch_mistat &= ~UART_MSR_CTS;
}
-
/* Make the UART raise any of the output signals we want up */
static void neo_assert_modem_signals(struct channel_t *ch)
{
udelay(10);
}
-
static void neo_send_start_character(struct channel_t *ch)
{
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
}
}
-
static void neo_send_stop_character(struct channel_t *ch)
{
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
}
}
-
/*
* neo_uart_init
*/
static void neo_uart_init(struct channel_t *ch)
{
-
writeb(0, &ch->ch_neo_uart->ier);
writeb(0, &ch->ch_neo_uart->efr);
writeb(UART_EFR_ECB, &ch->ch_neo_uart->efr);
-
/* Clear out UART and FIFO */
readb(&ch->ch_neo_uart->txrx);
writeb((UART_FCR_ENABLE_FIFO|UART_FCR_CLEAR_RCVR|UART_FCR_CLEAR_XMIT), &ch->ch_neo_uart->isr_fcr);
neo_pci_posting_flush(ch->ch_bd);
}
-
/*
* Make the UART completely turn off.
*/
neo_pci_posting_flush(ch->ch_bd);
}
-
static uint neo_get_uart_bytes_left(struct channel_t *ch)
{
unsigned char left = 0;
return left;
}
-
/* Channel lock MUST be held by the calling function! */
static void neo_send_break(struct channel_t *ch, int msecs)
{
}
}
-
/*
* neo_send_immediate_char.
*
neo_pci_posting_flush(ch->ch_bd);
}
-
static unsigned int neo_read_eeprom(unsigned char __iomem *base, unsigned int address)
{
unsigned int enable;
return val;
}
-
static void neo_vpd(struct dgnc_board *brd)
{
unsigned int i = 0;
/* Search for the serial number */
for (i = 0; i < NEO_VPD_IMAGEBYTES - 3; i++)
if (brd->vpd[i] == 'S' && brd->vpd[i + 1] == 'N')
- strncpy(brd->serial_num, &(brd->vpd[i + 3]), 9);
+ strncpy(brd->serial_num, &brd->vpd[i + 3], 9);
}
}