Lines Matching refs:ch
52 static void cls_set_cts_flow_control(struct jsm_channel *ch) in cls_set_cts_flow_control() argument
54 u8 lcrb = readb(&ch->ch_cls_uart->lcr); in cls_set_cts_flow_control()
55 u8 ier = readb(&ch->ch_cls_uart->ier); in cls_set_cts_flow_control()
62 writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); in cls_set_cts_flow_control()
64 isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); in cls_set_cts_flow_control()
70 writeb(isr_fcr, &ch->ch_cls_uart->isr_fcr); in cls_set_cts_flow_control()
73 writeb(lcrb, &ch->ch_cls_uart->lcr); in cls_set_cts_flow_control()
81 writeb(ier, &ch->ch_cls_uart->ier); in cls_set_cts_flow_control()
84 writeb((UART_FCR_ENABLE_FIFO), &ch->ch_cls_uart->isr_fcr); in cls_set_cts_flow_control()
88 &ch->ch_cls_uart->isr_fcr); in cls_set_cts_flow_control()
90 ch->ch_t_tlevel = 16; in cls_set_cts_flow_control()
93 static void cls_set_ixon_flow_control(struct jsm_channel *ch) in cls_set_ixon_flow_control() argument
95 u8 lcrb = readb(&ch->ch_cls_uart->lcr); in cls_set_ixon_flow_control()
96 u8 ier = readb(&ch->ch_cls_uart->ier); in cls_set_ixon_flow_control()
103 writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); in cls_set_ixon_flow_control()
105 isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); in cls_set_ixon_flow_control()
111 writeb(isr_fcr, &ch->ch_cls_uart->isr_fcr); in cls_set_ixon_flow_control()
114 writeb(ch->ch_startc, &ch->ch_cls_uart->mcr); in cls_set_ixon_flow_control()
115 writeb(0, &ch->ch_cls_uart->lsr); in cls_set_ixon_flow_control()
116 writeb(ch->ch_stopc, &ch->ch_cls_uart->msr); in cls_set_ixon_flow_control()
117 writeb(0, &ch->ch_cls_uart->spr); in cls_set_ixon_flow_control()
120 writeb(lcrb, &ch->ch_cls_uart->lcr); in cls_set_ixon_flow_control()
128 writeb(ier, &ch->ch_cls_uart->ier); in cls_set_ixon_flow_control()
131 writeb((UART_FCR_ENABLE_FIFO), &ch->ch_cls_uart->isr_fcr); in cls_set_ixon_flow_control()
135 &ch->ch_cls_uart->isr_fcr); in cls_set_ixon_flow_control()
138 static void cls_set_no_output_flow_control(struct jsm_channel *ch) in cls_set_no_output_flow_control() argument
140 u8 lcrb = readb(&ch->ch_cls_uart->lcr); in cls_set_no_output_flow_control()
141 u8 ier = readb(&ch->ch_cls_uart->ier); in cls_set_no_output_flow_control()
148 writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); in cls_set_no_output_flow_control()
150 isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); in cls_set_no_output_flow_control()
156 writeb(isr_fcr, &ch->ch_cls_uart->isr_fcr); in cls_set_no_output_flow_control()
159 writeb(lcrb, &ch->ch_cls_uart->lcr); in cls_set_no_output_flow_control()
167 writeb(ier, &ch->ch_cls_uart->ier); in cls_set_no_output_flow_control()
170 writeb((UART_FCR_ENABLE_FIFO), &ch->ch_cls_uart->isr_fcr); in cls_set_no_output_flow_control()
174 &ch->ch_cls_uart->isr_fcr); in cls_set_no_output_flow_control()
176 ch->ch_r_watermark = 0; in cls_set_no_output_flow_control()
177 ch->ch_t_tlevel = 16; in cls_set_no_output_flow_control()
178 ch->ch_r_tlevel = 16; in cls_set_no_output_flow_control()
181 static void cls_set_rts_flow_control(struct jsm_channel *ch) in cls_set_rts_flow_control() argument
183 u8 lcrb = readb(&ch->ch_cls_uart->lcr); in cls_set_rts_flow_control()
184 u8 ier = readb(&ch->ch_cls_uart->ier); in cls_set_rts_flow_control()
191 writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); in cls_set_rts_flow_control()
193 isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); in cls_set_rts_flow_control()
199 writeb(isr_fcr, &ch->ch_cls_uart->isr_fcr); in cls_set_rts_flow_control()
202 writeb(lcrb, &ch->ch_cls_uart->lcr); in cls_set_rts_flow_control()
206 writeb(ier, &ch->ch_cls_uart->ier); in cls_set_rts_flow_control()
209 writeb((UART_FCR_ENABLE_FIFO), &ch->ch_cls_uart->isr_fcr); in cls_set_rts_flow_control()
213 &ch->ch_cls_uart->isr_fcr); in cls_set_rts_flow_control()
215 ch->ch_r_watermark = 4; in cls_set_rts_flow_control()
216 ch->ch_r_tlevel = 8; in cls_set_rts_flow_control()
219 static void cls_set_ixoff_flow_control(struct jsm_channel *ch) in cls_set_ixoff_flow_control() argument
221 u8 lcrb = readb(&ch->ch_cls_uart->lcr); in cls_set_ixoff_flow_control()
222 u8 ier = readb(&ch->ch_cls_uart->ier); in cls_set_ixoff_flow_control()
229 writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); in cls_set_ixoff_flow_control()
231 isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); in cls_set_ixoff_flow_control()
237 writeb(isr_fcr, &ch->ch_cls_uart->isr_fcr); in cls_set_ixoff_flow_control()
240 writeb(ch->ch_startc, &ch->ch_cls_uart->mcr); in cls_set_ixoff_flow_control()
241 writeb(0, &ch->ch_cls_uart->lsr); in cls_set_ixoff_flow_control()
242 writeb(ch->ch_stopc, &ch->ch_cls_uart->msr); in cls_set_ixoff_flow_control()
243 writeb(0, &ch->ch_cls_uart->spr); in cls_set_ixoff_flow_control()
246 writeb(lcrb, &ch->ch_cls_uart->lcr); in cls_set_ixoff_flow_control()
250 writeb(ier, &ch->ch_cls_uart->ier); in cls_set_ixoff_flow_control()
253 writeb((UART_FCR_ENABLE_FIFO), &ch->ch_cls_uart->isr_fcr); in cls_set_ixoff_flow_control()
257 &ch->ch_cls_uart->isr_fcr); in cls_set_ixoff_flow_control()
260 static void cls_set_no_input_flow_control(struct jsm_channel *ch) in cls_set_no_input_flow_control() argument
262 u8 lcrb = readb(&ch->ch_cls_uart->lcr); in cls_set_no_input_flow_control()
263 u8 ier = readb(&ch->ch_cls_uart->ier); in cls_set_no_input_flow_control()
270 writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); in cls_set_no_input_flow_control()
272 isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); in cls_set_no_input_flow_control()
278 writeb(isr_fcr, &ch->ch_cls_uart->isr_fcr); in cls_set_no_input_flow_control()
281 writeb(lcrb, &ch->ch_cls_uart->lcr); in cls_set_no_input_flow_control()
285 writeb(ier, &ch->ch_cls_uart->ier); in cls_set_no_input_flow_control()
288 writeb((UART_FCR_ENABLE_FIFO), &ch->ch_cls_uart->isr_fcr); in cls_set_no_input_flow_control()
292 &ch->ch_cls_uart->isr_fcr); in cls_set_no_input_flow_control()
294 ch->ch_t_tlevel = 16; in cls_set_no_input_flow_control()
295 ch->ch_r_tlevel = 16; in cls_set_no_input_flow_control()
305 static void cls_clear_break(struct jsm_channel *ch) in cls_clear_break() argument
309 spin_lock_irqsave(&ch->ch_lock, lock_flags); in cls_clear_break()
312 if (ch->ch_flags & CH_BREAK_SENDING) { in cls_clear_break()
313 u8 temp = readb(&ch->ch_cls_uart->lcr); in cls_clear_break()
315 writeb((temp & ~UART_LCR_SBC), &ch->ch_cls_uart->lcr); in cls_clear_break()
317 ch->ch_flags &= ~(CH_BREAK_SENDING); in cls_clear_break()
318 jsm_dbg(IOCTL, &ch->ch_bd->pci_dev, in cls_clear_break()
322 spin_unlock_irqrestore(&ch->ch_lock, lock_flags); in cls_clear_break()
325 static void cls_disable_receiver(struct jsm_channel *ch) in cls_disable_receiver() argument
327 u8 tmp = readb(&ch->ch_cls_uart->ier); in cls_disable_receiver()
330 writeb(tmp, &ch->ch_cls_uart->ier); in cls_disable_receiver()
333 static void cls_enable_receiver(struct jsm_channel *ch) in cls_enable_receiver() argument
335 u8 tmp = readb(&ch->ch_cls_uart->ier); in cls_enable_receiver()
338 writeb(tmp, &ch->ch_cls_uart->ier); in cls_enable_receiver()
342 static void cls_assert_modem_signals(struct jsm_channel *ch) in cls_assert_modem_signals() argument
344 if (!ch) in cls_assert_modem_signals()
347 writeb(ch->ch_mostat, &ch->ch_cls_uart->mcr); in cls_assert_modem_signals()
350 static void cls_copy_data_from_uart_to_queue(struct jsm_channel *ch) in cls_copy_data_from_uart_to_queue() argument
359 if (!ch) in cls_copy_data_from_uart_to_queue()
362 spin_lock_irqsave(&ch->ch_lock, flags); in cls_copy_data_from_uart_to_queue()
365 head = ch->ch_r_head & RQUEUEMASK; in cls_copy_data_from_uart_to_queue()
366 tail = ch->ch_r_tail & RQUEUEMASK; in cls_copy_data_from_uart_to_queue()
368 ch->ch_cached_lsr = 0; in cls_copy_data_from_uart_to_queue()
379 if (ch->ch_c_iflag & IGNBRK) in cls_copy_data_from_uart_to_queue()
387 linestatus = readb(&ch->ch_cls_uart->lsr); in cls_copy_data_from_uart_to_queue()
399 readb(&ch->ch_cls_uart->txrx); in cls_copy_data_from_uart_to_queue()
413 ch->ch_r_tail = tail; in cls_copy_data_from_uart_to_queue()
414 ch->ch_err_overrun++; in cls_copy_data_from_uart_to_queue()
418 ch->ch_equeue[head] = linestatus & (UART_LSR_BI | UART_LSR_PE in cls_copy_data_from_uart_to_queue()
420 ch->ch_rqueue[head] = readb(&ch->ch_cls_uart->txrx); in cls_copy_data_from_uart_to_queue()
424 if (ch->ch_equeue[head] & UART_LSR_PE) in cls_copy_data_from_uart_to_queue()
425 ch->ch_err_parity++; in cls_copy_data_from_uart_to_queue()
426 if (ch->ch_equeue[head] & UART_LSR_BI) in cls_copy_data_from_uart_to_queue()
427 ch->ch_err_break++; in cls_copy_data_from_uart_to_queue()
428 if (ch->ch_equeue[head] & UART_LSR_FE) in cls_copy_data_from_uart_to_queue()
429 ch->ch_err_frame++; in cls_copy_data_from_uart_to_queue()
433 ch->ch_rxcount++; in cls_copy_data_from_uart_to_queue()
439 ch->ch_r_head = head & RQUEUEMASK; in cls_copy_data_from_uart_to_queue()
440 ch->ch_e_head = head & EQUEUEMASK; in cls_copy_data_from_uart_to_queue()
442 spin_unlock_irqrestore(&ch->ch_lock, flags); in cls_copy_data_from_uart_to_queue()
445 static void cls_copy_data_from_queue_to_uart(struct jsm_channel *ch) in cls_copy_data_from_queue_to_uart() argument
453 if (!ch) in cls_copy_data_from_queue_to_uart()
456 circ = &ch->uart_port.state->xmit; in cls_copy_data_from_queue_to_uart()
463 if ((ch->ch_flags & CH_STOP) || (ch->ch_flags & CH_BREAK_SENDING)) in cls_copy_data_from_queue_to_uart()
467 if (!(ch->ch_flags & (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM))) in cls_copy_data_from_queue_to_uart()
480 writeb(circ->buf[tail], &ch->ch_cls_uart->txrx); in cls_copy_data_from_queue_to_uart()
483 ch->ch_txcount++; in cls_copy_data_from_queue_to_uart()
490 if (len_written > ch->ch_t_tlevel) in cls_copy_data_from_queue_to_uart()
491 ch->ch_flags &= ~(CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); in cls_copy_data_from_queue_to_uart()
494 uart_write_wakeup(&ch->uart_port); in cls_copy_data_from_queue_to_uart()
497 static void cls_parse_modem(struct jsm_channel *ch, u8 signals) in cls_parse_modem() argument
501 jsm_dbg(MSIGS, &ch->ch_bd->pci_dev, in cls_parse_modem()
503 ch->ch_portnum, msignals); in cls_parse_modem()
513 uart_handle_dcd_change(&ch->uart_port, msignals & UART_MSR_DCD); in cls_parse_modem()
515 uart_handle_dcd_change(&ch->uart_port, msignals & UART_MSR_CTS); in cls_parse_modem()
518 ch->ch_mistat |= UART_MSR_DCD; in cls_parse_modem()
520 ch->ch_mistat &= ~UART_MSR_DCD; in cls_parse_modem()
523 ch->ch_mistat |= UART_MSR_DSR; in cls_parse_modem()
525 ch->ch_mistat &= ~UART_MSR_DSR; in cls_parse_modem()
528 ch->ch_mistat |= UART_MSR_RI; in cls_parse_modem()
530 ch->ch_mistat &= ~UART_MSR_RI; in cls_parse_modem()
533 ch->ch_mistat |= UART_MSR_CTS; in cls_parse_modem()
535 ch->ch_mistat &= ~UART_MSR_CTS; in cls_parse_modem()
537 jsm_dbg(MSIGS, &ch->ch_bd->pci_dev, in cls_parse_modem()
539 ch->ch_portnum, in cls_parse_modem()
540 !!((ch->ch_mistat | ch->ch_mostat) & UART_MCR_DTR), in cls_parse_modem()
541 !!((ch->ch_mistat | ch->ch_mostat) & UART_MCR_RTS), in cls_parse_modem()
542 !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_CTS), in cls_parse_modem()
543 !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_DSR), in cls_parse_modem()
544 !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_RI), in cls_parse_modem()
545 !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_DCD)); in cls_parse_modem()
551 struct jsm_channel *ch; in cls_parse_isr() local
563 ch = brd->channels[port]; in cls_parse_isr()
564 if (!ch) in cls_parse_isr()
569 isr = readb(&ch->ch_cls_uart->isr_fcr); in cls_parse_isr()
578 cls_copy_data_from_uart_to_queue(ch); in cls_parse_isr()
579 jsm_check_queue_flow_control(ch); in cls_parse_isr()
585 spin_lock_irqsave(&ch->ch_lock, flags); in cls_parse_isr()
586 ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); in cls_parse_isr()
587 spin_unlock_irqrestore(&ch->ch_lock, flags); in cls_parse_isr()
588 cls_copy_data_from_queue_to_uart(ch); in cls_parse_isr()
598 cls_parse_modem(ch, readb(&ch->ch_cls_uart->msr)); in cls_parse_isr()
603 static void cls_flush_uart_write(struct jsm_channel *ch) in cls_flush_uart_write() argument
608 if (!ch) in cls_flush_uart_write()
612 &ch->ch_cls_uart->isr_fcr); in cls_flush_uart_write()
616 tmp = readb(&ch->ch_cls_uart->isr_fcr); in cls_flush_uart_write()
618 jsm_dbg(IOCTL, &ch->ch_bd->pci_dev, in cls_flush_uart_write()
625 ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); in cls_flush_uart_write()
629 static void cls_flush_uart_read(struct jsm_channel *ch) in cls_flush_uart_read() argument
631 if (!ch) in cls_flush_uart_read()
648 static void cls_send_start_character(struct jsm_channel *ch) in cls_send_start_character() argument
650 if (!ch) in cls_send_start_character()
653 if (ch->ch_startc != __DISABLED_CHAR) { in cls_send_start_character()
654 ch->ch_xon_sends++; in cls_send_start_character()
655 writeb(ch->ch_startc, &ch->ch_cls_uart->txrx); in cls_send_start_character()
659 static void cls_send_stop_character(struct jsm_channel *ch) in cls_send_stop_character() argument
661 if (!ch) in cls_send_stop_character()
664 if (ch->ch_stopc != __DISABLED_CHAR) { in cls_send_stop_character()
665 ch->ch_xoff_sends++; in cls_send_stop_character()
666 writeb(ch->ch_stopc, &ch->ch_cls_uart->txrx); in cls_send_stop_character()
674 static void cls_param(struct jsm_channel *ch) in cls_param() argument
685 bd = ch->ch_bd; in cls_param()
692 if ((ch->ch_c_cflag & CBAUD) == B0) { in cls_param()
693 ch->ch_r_head = 0; in cls_param()
694 ch->ch_r_tail = 0; in cls_param()
695 ch->ch_e_head = 0; in cls_param()
696 ch->ch_e_tail = 0; in cls_param()
698 cls_flush_uart_write(ch); in cls_param()
699 cls_flush_uart_read(ch); in cls_param()
702 ch->ch_flags |= (CH_BAUD0); in cls_param()
703 ch->ch_mostat &= ~(UART_MCR_RTS | UART_MCR_DTR); in cls_param()
704 cls_assert_modem_signals(ch); in cls_param()
708 cflag = C_BAUD(ch->uart_port.state->port.tty); in cls_param()
717 if (ch->ch_flags & CH_BAUD0) in cls_param()
718 ch->ch_flags &= ~(CH_BAUD0); in cls_param()
720 if (ch->ch_c_cflag & PARENB) in cls_param()
723 if (!(ch->ch_c_cflag & PARODD)) in cls_param()
726 if (ch->ch_c_cflag & CMSPAR) in cls_param()
729 if (ch->ch_c_cflag & CSTOPB) in cls_param()
732 lcr |= UART_LCR_WLEN(tty_get_char_size(ch->ch_c_cflag)); in cls_param()
734 ier = readb(&ch->ch_cls_uart->ier); in cls_param()
735 uart_lcr = readb(&ch->ch_cls_uart->lcr); in cls_param()
737 quot = ch->ch_bd->bd_dividend / baud; in cls_param()
740 writeb(UART_LCR_DLAB, &ch->ch_cls_uart->lcr); in cls_param()
741 writeb((quot & 0xff), &ch->ch_cls_uart->txrx); in cls_param()
742 writeb((quot >> 8), &ch->ch_cls_uart->ier); in cls_param()
743 writeb(lcr, &ch->ch_cls_uart->lcr); in cls_param()
747 writeb(lcr, &ch->ch_cls_uart->lcr); in cls_param()
749 if (ch->ch_c_cflag & CREAD) in cls_param()
754 writeb(ier, &ch->ch_cls_uart->ier); in cls_param()
756 if (ch->ch_c_cflag & CRTSCTS) in cls_param()
757 cls_set_cts_flow_control(ch); in cls_param()
758 else if (ch->ch_c_iflag & IXON) { in cls_param()
763 if ((ch->ch_startc == __DISABLED_CHAR) || in cls_param()
764 (ch->ch_stopc == __DISABLED_CHAR)) in cls_param()
765 cls_set_no_output_flow_control(ch); in cls_param()
767 cls_set_ixon_flow_control(ch); in cls_param()
769 cls_set_no_output_flow_control(ch); in cls_param()
771 if (ch->ch_c_cflag & CRTSCTS) in cls_param()
772 cls_set_rts_flow_control(ch); in cls_param()
773 else if (ch->ch_c_iflag & IXOFF) { in cls_param()
778 if ((ch->ch_startc == __DISABLED_CHAR) || in cls_param()
779 (ch->ch_stopc == __DISABLED_CHAR)) in cls_param()
780 cls_set_no_input_flow_control(ch); in cls_param()
782 cls_set_ixoff_flow_control(ch); in cls_param()
784 cls_set_no_input_flow_control(ch); in cls_param()
786 cls_assert_modem_signals(ch); in cls_param()
789 cls_parse_modem(ch, readb(&ch->ch_cls_uart->msr)); in cls_param()
835 static void cls_uart_init(struct jsm_channel *ch) in cls_uart_init() argument
837 unsigned char lcrb = readb(&ch->ch_cls_uart->lcr); in cls_uart_init()
840 writeb(0, &ch->ch_cls_uart->ier); in cls_uart_init()
846 writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); in cls_uart_init()
848 isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); in cls_uart_init()
853 writeb(isr_fcr, &ch->ch_cls_uart->isr_fcr); in cls_uart_init()
856 writeb(lcrb, &ch->ch_cls_uart->lcr); in cls_uart_init()
859 readb(&ch->ch_cls_uart->txrx); in cls_uart_init()
862 &ch->ch_cls_uart->isr_fcr); in cls_uart_init()
865 ch->ch_flags |= (CH_FIFO_ENABLED | CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); in cls_uart_init()
867 readb(&ch->ch_cls_uart->lsr); in cls_uart_init()
868 readb(&ch->ch_cls_uart->msr); in cls_uart_init()
874 static void cls_uart_off(struct jsm_channel *ch) in cls_uart_off() argument
877 writeb(0, &ch->ch_cls_uart->ier); in cls_uart_off()
886 static u32 cls_get_uart_bytes_left(struct jsm_channel *ch) in cls_get_uart_bytes_left() argument
889 u8 lsr = readb(&ch->ch_cls_uart->lsr); in cls_get_uart_bytes_left()
895 ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); in cls_get_uart_bytes_left()
908 static void cls_send_break(struct jsm_channel *ch) in cls_send_break() argument
911 if (!(ch->ch_flags & CH_BREAK_SENDING)) { in cls_send_break()
912 u8 temp = readb(&ch->ch_cls_uart->lcr); in cls_send_break()
914 writeb((temp | UART_LCR_SBC), &ch->ch_cls_uart->lcr); in cls_send_break()
915 ch->ch_flags |= (CH_BREAK_SENDING); in cls_send_break()
926 static void cls_send_immediate_char(struct jsm_channel *ch, unsigned char c) in cls_send_immediate_char() argument
928 writeb(c, &ch->ch_cls_uart->txrx); in cls_send_immediate_char()