28 #include <linux/tty.h>
32 #include <linux/pci.h>
33 #include <linux/slab.h>
41 static inline int jsm_get_mstat(
struct jsm_channel *ch)
84 result = jsm_get_mstat(channel);
99 static void jsm_tty_set_mctrl(
struct uart_port *port,
unsigned int mctrl)
115 channel->
ch_bd->bd_ops->assert_modem_signals(channel);
127 static void jsm_tty_write(
struct uart_port *port)
131 channel->
ch_bd->bd_ops->copy_data_from_queue_to_uart(channel);
134 static void jsm_tty_start_tx(
struct uart_port *port)
146 static void jsm_tty_stop_tx(
struct uart_port *port)
157 static void jsm_tty_send_xchar(
struct uart_port *port,
char ch)
164 termios = &port->
state->port.tty->termios;
166 channel->
ch_bd->bd_ops->send_start_character(channel);
169 channel->
ch_bd->bd_ops->send_stop_character(channel);
170 spin_unlock_irqrestore(&port->
lock, lock_flags);
173 static void jsm_tty_stop_rx(
struct uart_port *port)
177 channel->
ch_bd->bd_ops->disable_receiver(channel);
180 static void jsm_tty_enable_ms(
struct uart_port *port)
185 static void jsm_tty_break(
struct uart_port *port,
int break_state)
191 if (break_state == -1)
192 channel->
ch_bd->bd_ops->send_break(channel);
194 channel->
ch_bd->bd_ops->clear_break(channel, 0);
196 spin_unlock_irqrestore(&port->
lock, lock_flags);
199 static int jsm_tty_open(
struct uart_port *port)
206 brd = channel->
ch_bd;
220 "unable to allocate read queue buf");
228 "unable to allocate error queue buf");
238 "jsm_open: initializing channel in open...\n");
246 brd->
bd_ops->flush_uart_write(channel);
247 brd->
bd_ops->flush_uart_read(channel);
253 termios = &port->
state->port.tty->termios;
262 brd->
bd_ops->uart_init(channel);
267 brd->
bd_ops->param(channel);
269 jsm_carrier(channel);
277 static void jsm_tty_close(
struct uart_port *port)
286 ts = &port->
state->port.tty->termios;
297 "Close. HUPCL set, dropping DTR/RTS\n");
301 bd->
bd_ops->assert_modem_signals(channel);
305 channel->
ch_bd->bd_ops->uart_off(channel);
310 static void jsm_tty_set_termios(
struct uart_port *port,
325 channel->
ch_bd->bd_ops->param(channel);
326 jsm_carrier(channel);
327 spin_unlock_irqrestore(&port->
lock, lock_flags);
330 static const char *jsm_tty_type(
struct uart_port *port)
335 static void jsm_tty_release_port(
struct uart_port *port)
339 static int jsm_tty_request_port(
struct uart_port *port)
350 .tx_empty = jsm_tty_tx_empty,
351 .set_mctrl = jsm_tty_set_mctrl,
352 .get_mctrl = jsm_tty_get_mctrl,
353 .stop_tx = jsm_tty_stop_tx,
354 .start_tx = jsm_tty_start_tx,
355 .send_xchar = jsm_tty_send_xchar,
356 .stop_rx = jsm_tty_stop_rx,
357 .enable_ms = jsm_tty_enable_ms,
358 .break_ctl = jsm_tty_break,
359 .startup = jsm_tty_open,
360 .shutdown = jsm_tty_close,
361 .set_termios = jsm_tty_set_termios,
362 .type = jsm_tty_type,
363 .release_port = jsm_tty_release_port,
364 .request_port = jsm_tty_request_port,
365 .config_port = jsm_config_port,
395 for (i = 0; i < brd->
nasync; i++) {
405 "%s:%d Unable to allocate memory for channel struct\n",
429 ch->ch_close_delay = 250;
462 brd->
channels[
i]->uart_port.uartclk = 14745600;
466 brd->
channels[
i]->uart_port.fifosize = 16;
467 brd->
channels[
i]->uart_port.ops = &jsm_ops;
505 for (i = 0; i < brd->
nasync; i++) {
557 data_len = (head -
tail) & rmask;
559 spin_unlock_irqrestore(&ch->
ch_lock, lock_flags);
570 !(tp->termios.c_cflag &
CREAD) ) {
573 "input. dropping %d bytes on port %d...\n", data_len, ch->
ch_portnum);
579 spin_unlock_irqrestore(&ch->
ch_lock, lock_flags);
587 spin_unlock_irqrestore(&ch->
ch_lock, lock_flags);
589 "Port %d throttled, not reading any data. head: %x tail: %x\n",
597 spin_unlock_irqrestore(&ch->
ch_lock, lock_flags);
625 for (i = 0; i <
s; i++) {
640 tty_insert_flip_string(tp, ch->
ch_rqueue + tail, s) ;
651 spin_unlock_irqrestore(&ch->
ch_lock, lock_flags);
663 int virt_carrier = 0;
664 int phys_carrier = 0;
685 "DCD: physical: %d virt: %d\n", phys_carrier, virt_carrier);
698 "carrier: virt DCD rose\n");
715 "carrier: physical DCD rose\n");
731 && (phys_carrier == 0)) {
751 if (virt_carrier == 1)
756 if (phys_carrier == 1)
794 "Internal queue hit hilevel mark (%d)! Turning off interrupts.\n",
831 "Internal queue hit lowlevel mark (%d)! Turning on interrupts.\n",