19 #include <linux/module.h>
22 #include <linux/serial.h>
23 #include <linux/tty.h>
27 #include <linux/device.h>
32 #ifdef CONFIG_MAGIC_SYSRQ
37 #include <linux/serial_core.h>
39 #define MUX_OFFSET 0x800
40 #define MUX_LINE_OFFSET 0x80
42 #define MUX_FIFO_SIZE 255
43 #define MUX_POLL_DELAY (30 * HZ / 1000)
45 #define IO_DATA_REG_OFFSET 0x3c
46 #define IO_DCOUNT_REG_OFFSET 0x40
48 #define MUX_EOFIFO(status) ((status & 0xF000) == 0xF000)
49 #define MUX_STATUS(status) ((status & 0xF000) == 0x8000)
50 #define MUX_BREAK(status) ((status & 0xF000) == 0x2000)
62 .driver_name =
"ttyB",
71 #define UART_PUT_CHAR(p, c) __raw_writel((c), (p)->membase + IO_DATA_REG_OFFSET)
72 #define UART_GET_FIFO_CNT(p) __raw_readl((p)->membase + IO_DCOUNT_REG_OFFSET)
94 if(dev->
id.hversion == 0x15)
101 return ((((iodc_data)[4] & 0xf0) >> 4) * 8) + 8;
125 static void mux_set_mctrl(
struct uart_port *
port,
unsigned int mctrl)
188 static void mux_break_ctl(
struct uart_port *
port,
int break_state)
224 }
while(--count > 0);
243 static void mux_read(
struct uart_port *port)
262 if(uart_handle_break(port))
269 tty_insert_flip_char(tty, data & 0xFF,
TTY_NORMAL);
272 if (start_count != port->
icount.rx) {
284 static int mux_startup(
struct uart_port *port)
286 mux_ports[port->
line].enabled = 1;
296 static void mux_shutdown(
struct uart_port *port)
298 mux_ports[port->
line].enabled = 0;
322 static const char *mux_type(
struct uart_port *port)
334 static void mux_release_port(
struct uart_port *port)
346 static int mux_request_port(
struct uart_port *port)
362 static void mux_config_port(
struct uart_port *port,
int type)
389 static void mux_poll(
unsigned long unused)
393 for(i = 0; i < port_cnt; ++
i) {
397 mux_read(&mux_ports[i].port);
398 mux_write(&mux_ports[i].port);
405 #ifdef CONFIG_SERIAL_MUX_CONSOLE
406 static void mux_console_write(
struct console *co,
const char *
s,
unsigned count)
432 static struct console mux_console = {
434 .write = mux_console_write,
435 .device = mux_console_device,
436 .setup = mux_console_setup,
441 #define MUX_CONSOLE &mux_console
443 #define MUX_CONSOLE NULL
447 .tx_empty = mux_tx_empty,
448 .set_mctrl = mux_set_mctrl,
449 .get_mctrl = mux_get_mctrl,
450 .stop_tx = mux_stop_tx,
451 .start_tx = mux_start_tx,
452 .stop_rx = mux_stop_rx,
453 .enable_ms = mux_enable_ms,
454 .break_ctl = mux_break_ctl,
455 .startup = mux_startup,
456 .shutdown = mux_shutdown,
457 .set_termios = mux_set_termios,
459 .release_port = mux_release_port,
460 .request_port = mux_request_port,
461 .config_port = mux_config_port,
462 .verify_port = mux_verify_port,
477 printk(
KERN_INFO "Serial mux driver (%d ports) Revision: 0.6\n", port_count);
494 struct uart_port *port = &mux_ports[port_cnt].port;
504 port->
ops = &mux_pops;
506 port->
line = port_cnt;
529 for(i = 0; i < port_cnt; ++
i) {
533 BUG_ON(i + port_count > port_cnt);
571 .name =
"builtin_serial_mux",
572 .id_table = builtin_mux_tbl,
578 .name =
"serial_mux",
589 static int __init mux_init(
void)
597 mux_timer.function = mux_poll;
600 #ifdef CONFIG_SERIAL_MUX_CONSOLE
613 static void __exit mux_exit(
void)
618 #ifdef CONFIG_SERIAL_MUX_CONSOLE