14 #include <linux/module.h>
15 #include <linux/tty.h>
19 #include <linux/serial.h>
22 #include <linux/device.h>
28 #include <mach/regs-uart.h>
29 #include <mach/regs-irq.h>
31 #if defined(CONFIG_SERIAL_KS8695_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
35 #include <linux/serial_core.h>
38 #define SERIAL_KS8695_MAJOR 204
39 #define SERIAL_KS8695_MINOR 16
40 #define SERIAL_KS8695_DEVNAME "ttyAM"
42 #define SERIAL_KS8695_NR 1
47 #define UART_GET_CHAR(p) (__raw_readl((p)->membase + KS8695_URRB) & 0xFF)
48 #define UART_PUT_CHAR(p, c) __raw_writel((c), (p)->membase + KS8695_URTH)
49 #define UART_GET_FCR(p) __raw_readl((p)->membase + KS8695_URFC)
50 #define UART_PUT_FCR(p, c) __raw_writel((c), (p)->membase + KS8695_URFC)
51 #define UART_GET_MSR(p) __raw_readl((p)->membase + KS8695_URMS)
52 #define UART_GET_LSR(p) __raw_readl((p)->membase + KS8695_URLS)
53 #define UART_GET_LCR(p) __raw_readl((p)->membase + KS8695_URLC)
54 #define UART_PUT_LCR(p, c) __raw_writel((c), (p)->membase + KS8695_URLC)
55 #define UART_GET_MCR(p) __raw_readl((p)->membase + KS8695_URMC)
56 #define UART_PUT_MCR(p, c) __raw_writel((c), (p)->membase + KS8695_URMC)
57 #define UART_GET_BRDR(p) __raw_readl((p)->membase + KS8695_URBD)
58 #define UART_PUT_BRDR(p, c) __raw_writel((c), (p)->membase + KS8695_URBD)
60 #define KS8695_CLR_TX_INT() __raw_writel(1 << KS8695_IRQ_UART_TX, KS8695_IRQ_VA + KS8695_INTST)
62 #define UART_DUMMY_LSR_RX 0x100
63 #define UART_PORT_SIZE (KS8695_USR - KS8695_URRB + 4)
67 return port->
unused[0] & 1;
72 return port->
unused[0] & 2;
77 return port->
unused[0] & 4;
88 static inline void rx_enable(
struct uart_port *port,
int enabled)
96 static inline void tx_enable(
struct uart_port *port,
int enabled)
106 static struct console ks8695_console;
109 static void ks8695uart_stop_tx(
struct uart_port *port)
121 static void ks8695uart_start_tx(
struct uart_port *port)
129 static void ks8695uart_stop_rx(
struct uart_port *port)
137 static void ks8695uart_enable_ms(
struct uart_port *port)
139 if (!ms_enabled(port)) {
145 static void ks8695uart_disable_ms(
struct uart_port *port)
147 if (ms_enabled(port)) {
160 while ((status &
URLS_URDR) && max_count--) {
175 if (uart_handle_break(port))
189 else if (lsr & URLS_URPE)
191 else if (lsr & URLS_URFE)
209 static irqreturn_t ks8695uart_tx_chars(
int irq,
void *dev_id)
224 ks8695uart_stop_tx(port);
241 ks8695uart_stop_tx(port);
246 static irqreturn_t ks8695uart_modem_status(
int irq,
void *dev_id)
273 static unsigned int ks8695uart_tx_empty(
struct uart_port *port)
278 static unsigned int ks8695uart_get_mctrl(
struct uart_port *port)
314 static void ks8695uart_break_ctl(
struct uart_port *port,
int break_state)
320 if (break_state == -1)
328 static int ks8695uart_startup(
struct uart_port *port)
368 static void ks8695uart_shutdown(
struct uart_port *port)
385 unsigned int lcr,
fcr = 0;
387 unsigned int baud, quot;
468 ks8695uart_enable_ms(port);
470 ks8695uart_disable_ms(port);
478 spin_unlock_irqrestore(&port->
lock, flags);
481 static const char *ks8695uart_type(
struct uart_port *port)
489 static void ks8695uart_release_port(
struct uart_port *port)
497 static int ks8695uart_request_port(
struct uart_port *port)
506 static void ks8695uart_config_port(
struct uart_port *port,
int flags)
510 ks8695uart_request_port(port);
523 if (ser->
irq != port->
irq)
530 static struct uart_ops ks8695uart_pops = {
531 .tx_empty = ks8695uart_tx_empty,
532 .set_mctrl = ks8695uart_set_mctrl,
533 .get_mctrl = ks8695uart_get_mctrl,
534 .stop_tx = ks8695uart_stop_tx,
535 .start_tx = ks8695uart_start_tx,
536 .stop_rx = ks8695uart_stop_rx,
537 .enable_ms = ks8695uart_enable_ms,
538 .break_ctl = ks8695uart_break_ctl,
539 .startup = ks8695uart_startup,
540 .shutdown = ks8695uart_shutdown,
541 .set_termios = ks8695uart_set_termios,
542 .type = ks8695uart_type,
543 .release_port = ks8695uart_release_port,
544 .request_port = ks8695uart_request_port,
545 .config_port = ks8695uart_config_port,
546 .verify_port = ks8695uart_verify_port,
557 .ops = &ks8695uart_pops,
563 #ifdef CONFIG_SERIAL_KS8695_CONSOLE
564 static void ks8695_console_putchar(
struct uart_port *port,
int ch)
572 static void ks8695_console_write(
struct console *co,
const char *
s,
u_int count)
579 static void __init ks8695_console_get_options(
struct uart_port *port,
int *baud,
int *parity,
int *
bits)
633 ks8695_console_get_options(port, &baud, &parity, &bits);
640 static struct console ks8695_console = {
642 .write = ks8695_console_write,
644 .setup = ks8695_console_setup,
650 static int __init ks8695_console_init(
void)
659 #define KS8695_CONSOLE &ks8695_console
661 #define KS8695_CONSOLE NULL
666 .driver_name =
"serial_ks8695",
674 static int __init ks8695uart_init(
void)
690 static void __exit ks8695uart_exit(
void)