18 #if defined(CONFIG_SERIAL_NETX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
22 #include <linux/device.h>
23 #include <linux/module.h>
29 #include <linux/tty.h>
31 #include <linux/serial_core.h>
32 #include <linux/serial.h>
36 #include <mach/hardware.h>
40 #define SERIAL_NX_MAJOR 204
41 #define MINOR_START 170
67 #define LINE_CR_BRK (1<<0)
68 #define LINE_CR_PEN (1<<1)
69 #define LINE_CR_EPS (1<<2)
70 #define LINE_CR_STP2 (1<<3)
71 #define LINE_CR_FEN (1<<4)
72 #define LINE_CR_5BIT (0<<5)
73 #define LINE_CR_6BIT (1<<5)
74 #define LINE_CR_7BIT (2<<5)
75 #define LINE_CR_8BIT (3<<5)
76 #define LINE_CR_BITS_MASK (3<<5)
78 #define CR_UART_EN (1<<0)
79 #define CR_SIREN (1<<1)
80 #define CR_SIRLP (1<<2)
81 #define CR_MSIE (1<<3)
84 #define CR_RTIE (1<<6)
90 #define FR_BUSY (1<<3)
91 #define FR_RXFE (1<<4)
92 #define FR_TXFF (1<<5)
93 #define FR_RXFF (1<<6)
94 #define FR_TXFE (1<<7)
96 #define IIR_MIS (1<<0)
97 #define IIR_RIS (1<<1)
98 #define IIR_TIS (1<<2)
99 #define IIR_RTIS (1<<3)
102 #define RTS_CR_AUTO (1<<0)
103 #define RTS_CR_RTS (1<<1)
104 #define RTS_CR_COUNT (1<<2)
105 #define RTS_CR_MOD2 (1<<3)
106 #define RTS_CR_RTS_POL (1<<4)
107 #define RTS_CR_CTS_CTR (1<<5)
108 #define RTS_CR_CTS_POL (1<<6)
109 #define RTS_CR_STICK (1<<7)
111 #define UART_PORT_SIZE 0x40
112 #define DRIVER_NAME "netx-uart"
139 static inline void netx_transmit_buffer(
struct uart_port *
port)
170 static void netx_start_tx(
struct uart_port *port)
176 netx_transmit_buffer(port);
179 static unsigned int netx_tx_empty(
struct uart_port *port)
184 static void netx_txint(
struct uart_port *port)
193 netx_transmit_buffer(port);
199 static void netx_rxint(
struct uart_port *port)
209 if (status &
SR_BE) {
211 if (uart_handle_break(port))
219 else if (status &
SR_FE)
228 else if (status & SR_PE)
230 else if (status & SR_FE)
268 spin_unlock_irqrestore(&port->
lock,flags);
272 static unsigned int netx_get_mctrl(
struct uart_port *port)
282 static void netx_set_mctrl(
struct uart_port *port,
unsigned int mctrl)
293 static void netx_break_ctl(
struct uart_port *port,
int break_state)
295 unsigned int line_cr;
296 spin_lock_irq(&port->
lock);
299 if (break_state != 0)
305 spin_unlock_irq(&port->
lock);
308 static int netx_startup(
struct uart_port *port)
329 static void netx_shutdown(
struct uart_port *port)
340 unsigned int baud, quot;
341 unsigned char old_cr;
343 unsigned char rts_cr = 0;
378 spin_lock_irq(&port->
lock);
429 spin_unlock_irq(&port->
lock);
432 static const char *netx_type(
struct uart_port *port)
437 static void netx_release_port(
struct uart_port *port)
442 static int netx_request_port(
struct uart_port *port)
448 static void netx_config_port(
struct uart_port *port,
int flags)
465 static struct uart_ops netx_pops = {
466 .tx_empty = netx_tx_empty,
467 .set_mctrl = netx_set_mctrl,
468 .get_mctrl = netx_get_mctrl,
469 .stop_tx = netx_stop_tx,
470 .start_tx = netx_start_tx,
471 .stop_rx = netx_stop_rx,
472 .enable_ms = netx_enable_ms,
473 .break_ctl = netx_break_ctl,
474 .startup = netx_startup,
475 .shutdown = netx_shutdown,
476 .set_termios = netx_set_termios,
478 .release_port = netx_release_port,
479 .request_port = netx_request_port,
480 .config_port = netx_config_port,
481 .verify_port = netx_verify_port,
492 .uartclk = 100000000,
505 .uartclk = 100000000,
518 .uartclk = 100000000,
527 #ifdef CONFIG_SERIAL_NETX_CONSOLE
529 static void netx_console_putchar(
struct uart_port *port,
int ch)
536 netx_console_write(
struct console *co,
const char *
s,
unsigned int count)
539 unsigned char cr_save;
551 netx_console_get_options(
struct uart_port *port,
int *baud,
552 int *parity,
int *
bits,
int *flow)
554 unsigned char line_cr;
608 sport = &netx_ports[co->
index];
617 netx_console_get_options(&sport->
port, &baud,
618 &parity, &bits, &flow);
627 static struct console netx_console = {
629 .write = netx_console_write,
631 .setup = netx_console_setup,
637 static int __init netx_console_init(
void)
644 #define NETX_CONSOLE &netx_console
646 #define NETX_CONSOLE NULL
661 struct netx_port *sport = platform_get_drvdata(pdev);
671 struct netx_port *sport = platform_get_drvdata(pdev);
689 platform_set_drvdata(pdev, &netx_ports[pdev->
id]);
696 struct netx_port *sport = platform_get_drvdata(pdev);
698 platform_set_drvdata(pdev,
NULL);
707 .probe = serial_netx_probe,
708 .remove = serial_netx_remove,
710 .suspend = serial_netx_suspend,
711 .resume = serial_netx_resume,
719 static int __init netx_serial_init(
void)
736 static void __exit netx_serial_exit(
void)