Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions drivers/tty/serial/jz_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ struct uart_jz47xx_port {
static inline void check_modem_status(struct uart_jz47xx_port *up);
static unsigned short *serial47xx_get_divisor(struct uart_port *port, unsigned int baud);
static inline void serial_dl_write(struct uart_port *up, int value);
static int uart_jz47xx_get_poll_char(struct uart_port *port);
static void uart_jz47xx_put_poll_char(struct uart_port *port, unsigned char c);

static inline unsigned int serial_in(struct uart_jz47xx_port *up, int offset)
{
Expand Down Expand Up @@ -994,6 +996,52 @@ static void serial_jz47xx_console_write(struct console *co, const char *s, unsig
spin_unlock(&up->port.lock);
}

#ifdef CONFIG_CONSOLE_POLL
static int uart_jz47xx_get_poll_char(struct uart_port *port)
{
struct uart_jz47xx_port *up =
container_of(port, struct uart_jz47xx_port, port);
unsigned char lsr = serial_in(up, UART_LSR);

if (!(lsr & UART_LSR_DR))
return NO_POLL_CHAR;

return serial_in(up, UART_RX);
}

static void uart_jz47xx_put_poll_char(struct uart_port *port,
unsigned char c)
{
unsigned int ier;
struct uart_jz47xx_port *up =
container_of(port, struct uart_jz47xx_port, port);

/*
* First save the IER then disable the interrupts
*/
ier = serial_in(up, UART_IER);
serial_out(up, UART_IER, 0);

wait_for_xmitr(up);
/*
* Send the character out.
* If a LF, also do CR...
*/
serial_out(up, UART_TX, c);
if (c == 10) {
wait_for_xmitr(up);
serial_out(up, UART_TX, 13);
}

/*
* Finally, wait for transmitter to become empty
* and restore the IER
*/
wait_for_xmitr(up);
serial_out(up, UART_IER, ier);
}
#endif

static int __init serial_jz47xx_console_setup(struct console *co, char *options)
{
struct uart_jz47xx_port *up;
Expand Down Expand Up @@ -1046,6 +1094,10 @@ struct uart_ops serial_jz47xx_pops = {
.request_port = serial_jz47xx_request_port,
.config_port = serial_jz47xx_config_port,
.verify_port = serial_jz47xx_verify_port,
#ifdef CONFIG_CONSOLE_POLL
.poll_get_char = uart_jz47xx_get_poll_char,
.poll_put_char = uart_jz47xx_put_poll_char,
#endif
};

static struct uart_driver serial_jz47xx_reg = {
Expand Down