28 #include <linux/tty.h>
29 #include <linux/pci.h>
34 static u32 jsm_offset_table[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
44 static inline void neo_pci_posting_flush(
struct jsm_board *bd)
49 static void neo_set_cts_flow_control(
struct jsm_channel *ch)
80 static void neo_set_rts_flow_control(
struct jsm_channel *ch)
120 static void neo_set_ixon_flow_control(
struct jsm_channel *ch)
157 static void neo_set_ixoff_flow_control(
struct jsm_channel *ch)
195 static void neo_set_no_input_flow_control(
struct jsm_channel *ch)
234 static void neo_set_no_output_flow_control(
struct jsm_channel *ch)
272 static inline void neo_set_new_start_stop_chars(
struct jsm_channel *ch)
289 static void neo_copy_data_from_uart_to_queue(
struct jsm_channel *ch)
311 if ((qleft = tail - head - 1) < 0)
343 total =
min(total, qleft);
427 linestatus &= ~UART_LSR_DR;
442 if (linestatus & error_mask) {
459 "Queue full, dropping DATA:%x LSR:%x\n",
491 static void neo_copy_data_from_queue_to_uart(
struct jsm_channel *ch)
525 "Tx data: %x\n", circ->
buf[circ->
tail]);
558 tail = (tail +
s) & (UART_XMIT_SIZE - 1);
565 circ->
tail = tail & (UART_XMIT_SIZE - 1);
579 "neo_parse_modem: port: %d msignals: %x\n", ch->
ch_portnum, msignals);
610 "Port: %d DTR: %d RTS: %d CTS: %d DSR: %d " "RI: %d CD: %d\n",
621 static void neo_assert_modem_signals(
struct jsm_channel *ch)
629 neo_pci_posting_flush(ch->
ch_bd);
637 static void neo_flush_uart_write(
struct jsm_channel *ch)
647 for (i = 0; i < 10; i++) {
653 "Still flushing TX UART... i: %d\n", i);
669 static void neo_flush_uart_read(
struct jsm_channel *ch)
679 for (i = 0; i < 10; i++) {
685 "Still flushing RX UART... i: %d\n", i);
709 "clear break Finishing UART_LCR_SBC! finished: %lx\n", jiffies);
712 neo_pci_posting_flush(ch->
ch_bd);
714 spin_unlock_irqrestore(&ch->
ch_lock, lock_flags);
752 "%s:%d isr: %x\n", __FILE__, __LINE__, isr);
756 neo_copy_data_from_uart_to_queue(ch);
761 spin_unlock_irqrestore(&ch->
ch_lock, lock_flags);
768 spin_unlock_irqrestore(&ch->
ch_lock, lock_flags);
769 neo_copy_data_from_queue_to_uart(ch);
776 "Port %d. Got ISR_XONXOFF: cause:%x\n", port, cause);
790 "Port %d. XON detected in incoming data\n", port);
796 "Setting CH_STOP\n");
799 "Port: %d. XOFF detected in incoming data\n", port);
801 spin_unlock_irqrestore(&ch->
ch_lock, lock_flags);
813 if ((cause & 0x4) == 0) {
824 spin_unlock_irqrestore(&ch->
ch_lock, lock_flags);
829 "MOD_STAT: sending to parse_modem_sigs\n");
834 static inline void neo_parse_lsr(
struct jsm_board *brd,
u32 port)
853 "%s:%d port: %d linestatus: %x\n", __FILE__, __LINE__, port, linestatus);
859 neo_copy_data_from_uart_to_queue(ch);
862 spin_unlock_irqrestore(&ch->
ch_lock, lock_flags);
871 if (linestatus & UART_17158_RX_FIFO_DATA_ERROR)
873 "%s:%d Port: %d Got an RX error, need to parse LSR\n",
874 __FILE__, __LINE__, port);
884 "%s:%d Port: %d. PAR ERR!\n", __FILE__, __LINE__, port);
890 "%s:%d Port: %d. FRM ERR!\n", __FILE__, __LINE__, port);
896 "%s:%d Port: %d. BRK INTR!\n", __FILE__, __LINE__, port);
908 "%s:%d Port: %d. Rx Overrun!\n", __FILE__, __LINE__, port);
914 spin_unlock_irqrestore(&ch->
ch_lock, lock_flags);
917 neo_copy_data_from_queue_to_uart(ch);
922 spin_unlock_irqrestore(&ch->
ch_lock, lock_flags);
925 neo_copy_data_from_queue_to_uart(ch);
952 neo_flush_uart_write(ch);
953 neo_flush_uart_read(ch);
957 neo_assert_modem_signals(ch);
990 for (i = 0; i <
ARRAY_SIZE(baud_rates); i++) {
991 if (baud_rates[i].cflag == cflag) {
992 baud = baud_rates[
i].rate;
1050 if (uart_lcr != lcr)
1061 neo_set_new_start_stop_chars(ch);
1064 neo_set_cts_flow_control(ch);
1068 neo_set_no_output_flow_control(ch);
1070 neo_set_ixon_flow_control(ch);
1073 neo_set_no_output_flow_control(ch);
1076 neo_set_rts_flow_control(ch);
1080 neo_set_no_input_flow_control(ch);
1082 neo_set_ixoff_flow_control(ch);
1085 neo_set_no_input_flow_control(ch);
1096 neo_assert_modem_signals(ch);
1108 static irqreturn_t neo_intr(
int irq,
void *voidbrd)
1118 unsigned long lock_flags2;
1119 int outofloop_count = 0;
1132 "%s:%d uart_poll: %x\n", __FILE__, __LINE__, uart_poll);
1136 "Kernel interrupted to me, but no pending interrupts...\n");
1137 spin_unlock_irqrestore(&brd->
bd_intr_lock, lock_flags);
1146 while (((uart_poll & 0xff) != 0) && (outofloop_count < 0xff)){
1152 if ((tmp & jsm_offset_table[current_port]) != 0) {
1153 port = current_port;
1154 type = tmp >> (8 + (port * 3));
1162 "%s:%d port: %x type: %x\n", __FILE__, __LINE__, port, type);
1165 uart_poll &= ~(jsm_offset_table[
port]);
1170 "Interrupt with no type! port: %d\n", port);
1188 neo_copy_data_from_uart_to_queue(ch);
1193 spin_unlock_irqrestore(&ch->
ch_lock, lock_flags2);
1201 neo_parse_lsr(brd, port);
1217 neo_parse_isr(brd, port);
1224 neo_parse_isr(brd, port);
1235 "%s:%d Unknown Interrupt type: %x\n", __FILE__, __LINE__, type);
1240 spin_unlock_irqrestore(&brd->
bd_intr_lock, lock_flags);
1251 static void neo_disable_receiver(
struct jsm_channel *ch)
1258 neo_pci_posting_flush(ch->
ch_bd);
1267 static void neo_enable_receiver(
struct jsm_channel *ch)
1274 neo_pci_posting_flush(ch->
ch_bd);
1277 static void neo_send_start_character(
struct jsm_channel *ch)
1287 neo_pci_posting_flush(ch->
ch_bd);
1291 static void neo_send_stop_character(
struct jsm_channel *ch)
1301 neo_pci_posting_flush(ch->
ch_bd);
1358 static void neo_send_break(
struct jsm_channel *ch)
1373 neo_pci_posting_flush(ch->
ch_bd);
1385 static void neo_send_immediate_char(
struct jsm_channel *ch,
unsigned char c)
1393 neo_pci_posting_flush(ch->
ch_bd);
1398 .uart_init = neo_uart_init,
1399 .uart_off = neo_uart_off,
1401 .assert_modem_signals = neo_assert_modem_signals,
1402 .flush_uart_write = neo_flush_uart_write,
1403 .flush_uart_read = neo_flush_uart_read,
1404 .disable_receiver = neo_disable_receiver,
1405 .enable_receiver = neo_enable_receiver,
1406 .send_break = neo_send_break,
1407 .clear_break = neo_clear_break,
1408 .send_start_character = neo_send_start_character,
1409 .send_stop_character = neo_send_stop_character,
1410 .copy_data_from_queue_to_uart = neo_copy_data_from_queue_to_uart,
1411 .get_uart_bytes_left = neo_get_uart_bytes_left,
1412 .send_immediate_char = neo_send_immediate_char