13 #include <linux/export.h>
15 #include <linux/serial.h>
17 #include <linux/serial_core.h>
18 #include <linux/tty.h>
28 #define NWPSERIAL_NR 2
30 #define NWPSERIAL_STATUS_RXVALID 0x1
31 #define NWPSERIAL_STATUS_TXFULL 0x2
45 unsigned int status, tmout = 10000;
54 }
while ((status & bits) != bits);
57 #ifdef CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL_CONSOLE
58 static void nwpserial_console_putchar(
struct uart_port *
port,
int c)
69 nwpserial_console_write(
struct console *co,
const char *
s,
unsigned int count)
94 spin_unlock_irqrestore(&up->
port.lock, flags);
98 static struct console nwpserial_console = {
100 .write = nwpserial_console_write,
104 .data = &nwpserial_reg,
106 #define NWPSERIAL_CONSOLE (&nwpserial_console)
108 #define NWPSERIAL_CONSOLE NULL
123 static void nwpserial_config_port(
struct uart_port *
port,
int flags)
136 spin_lock(&up->
port.lock);
146 up->
port.icount.rx++;
158 spin_unlock(&up->
port.lock);
189 static void nwpserial_shutdown(
struct uart_port *port)
205 static int nwpserial_verify_port(
struct uart_port *port,
211 static const char *nwpserial_type(
struct uart_port *port)
216 static void nwpserial_set_termios(
struct uart_port *port,
225 up->
port.ignore_status_mask = 0;
235 static void nwpserial_break_ctl(
struct uart_port *port,
int ctl)
240 static void nwpserial_enable_ms(
struct uart_port *port)
245 static void nwpserial_stop_rx(
struct uart_port *port)
253 static void nwpserial_putchar(
struct nwpserial_port *up,
unsigned char c)
256 wait_for_bits(up, UART_LSR_THRE);
258 up->
port.icount.tx++;
261 static void nwpserial_start_tx(
struct uart_port *port)
266 xmit = &up->
port.state->xmit;
269 nwpserial_putchar(up, up->
port.x_char);
274 nwpserial_putchar(up, xmit->
buf[xmit->
tail]);
279 static unsigned int nwpserial_get_mctrl(
struct uart_port *port)
284 static void nwpserial_set_mctrl(
struct uart_port *port,
unsigned int mctrl)
289 static void nwpserial_stop_tx(
struct uart_port *port)
294 static unsigned int nwpserial_tx_empty(
struct uart_port *port)
303 spin_unlock_irqrestore(&up->
port.lock, flags);
308 static struct uart_ops nwpserial_pops = {
309 .tx_empty = nwpserial_tx_empty,
310 .set_mctrl = nwpserial_set_mctrl,
311 .get_mctrl = nwpserial_get_mctrl,
312 .stop_tx = nwpserial_stop_tx,
313 .start_tx = nwpserial_start_tx,
314 .stop_rx = nwpserial_stop_rx,
315 .enable_ms = nwpserial_enable_ms,
316 .break_ctl = nwpserial_break_ctl,
317 .startup = nwpserial_startup,
318 .shutdown = nwpserial_shutdown,
319 .set_termios = nwpserial_set_termios,
320 .type = nwpserial_type,
321 .release_port = nwpserial_release_port,
322 .request_port = nwpserial_request_port,
323 .config_port = nwpserial_config_port,
324 .verify_port = nwpserial_verify_port,
329 .driver_name =
"nwpserial",
342 static int first = 1;
349 dn = port->
dev->of_node;
358 if (nwpserial_ports[i].port.
iobase == dcr_base) {
359 up = &nwpserial_ports[
i];
367 nwpserial_ports[i].port.iobase == 0) {
368 up = &nwpserial_ports[
i];
394 if (up->
port.iobase != dcr_base) {
395 up->
port.ops = &nwpserial_pops;
396 up->
port.fifosize = 16;
400 up->
port.iobase = dcr_base;
403 up->
dcr_host = dcr_map(dn, dcr_base, dcr_len);
433 #ifdef CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL_CONSOLE
434 static int __init nwpserial_console_init(
void)
446 up = &nwpserial_ports[
i];
462 up->
port.ops = &nwpserial_pops;
464 up->
port.fifosize = 16;
468 up->
port.iobase = dcr_base;
470 up->
dcr_host = dcr_map(dn, dcr_base, dcr_len);
472 printk(
"Cannot map DCR resources for SERIAL");