23 #if defined(CONFIG_SERIAL_VR41XX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
28 #include <linux/errno.h>
32 #include <linux/module.h>
34 #include <linux/serial.h>
35 #include <linux/serial_core.h>
37 #include <linux/tty.h>
44 #define SIU_BAUD_BASE 1152000
46 #define SIU_MINOR_BASE 82
48 #define RX_MAX_COUNT 256
49 #define TX_MAX_COUNT 15
55 #define IRMSEL_HP 0x08
56 #define IRMSEL_TEMIC 0x04
57 #define IRMSEL_SHARP 0x00
68 #ifdef CONFIG_SERIAL_VR41XX_CONSOLE
72 #define siu_read(port, offset) readb((port)->membase + (offset))
73 #define siu_write(port, offset, value) writeb((value), (port)->membase + (offset))
81 port = &siu_uart_ports[0];
92 spin_unlock_irqrestore(&port->
lock, flags);
102 port = &siu_uart_ports[0];
113 spin_unlock_irqrestore(&port->
lock, flags);
123 port = &siu_uart_ports[0];
146 spin_unlock_irqrestore(&port->
lock, flags);
158 static inline unsigned long siu_port_size(
struct uart_port *
port)
160 switch (port->
type) {
170 static inline unsigned int siu_check_type(
struct uart_port *port)
174 if (port->
line == 1 && port->
irq)
180 static inline const char *siu_type_name(
struct uart_port *port)
182 switch (port->
type) {
192 static unsigned int siu_tx_empty(
struct uart_port *port)
203 static void siu_set_mctrl(
struct uart_port *port,
unsigned int mctrl)
221 static unsigned int siu_get_mctrl(
struct uart_port *port)
224 unsigned int mctrl = 0;
239 static void siu_stop_tx(
struct uart_port *port)
250 spin_unlock_irqrestore(&port->
lock, flags);
253 static void siu_start_tx(
struct uart_port *port)
264 spin_unlock_irqrestore(&port->
lock, flags);
267 static void siu_stop_rx(
struct uart_port *port)
280 spin_unlock_irqrestore(&port->
lock, flags);
283 static void siu_enable_ms(
struct uart_port *port)
294 spin_unlock_irqrestore(&port->
lock, flags);
297 static void siu_break_ctl(
struct uart_port *port,
int ctl)
311 spin_unlock_irqrestore(&port->
lock, flags);
321 tty = port->
state->port.tty;
329 #ifdef CONFIG_SERIAL_VR41XX_CONSOLE
330 lsr |= lsr_break_flag[port->
line];
331 lsr_break_flag[port->
line] = 0;
339 if (uart_handle_break(port))
351 if (lsr & UART_LSR_BI)
353 if (lsr & UART_LSR_FE)
355 if (lsr & UART_LSR_PE)
366 }
while ((lsr &
UART_LSR_DR) && (max_count-- > 0));
373 static inline void check_modem_status(
struct uart_port *port)
392 static inline void transmit_chars(
struct uart_port *port)
397 xmit = &port->
state->xmit;
417 }
while (max_count-- > 0);
438 if (lsr & UART_LSR_DR)
439 receive_chars(port, &lsr);
441 check_modem_status(port);
444 transmit_chars(port);
449 static int siu_startup(
struct uart_port *port)
456 siu_clear_fifo(port);
466 retval =
request_irq(port->
irq, siu_interrupt, 0, siu_type_name(port), port);
475 spin_lock_irq(&port->
lock);
476 siu_set_mctrl(port, port->
mctrl);
477 spin_unlock_irq(&port->
lock);
489 static void siu_shutdown(
struct uart_port *port)
498 port->
mctrl &= ~TIOCM_OUT2;
499 siu_set_mctrl(port, port->
mctrl);
501 spin_unlock_irqrestore(&port->
lock, flags);
507 siu_clear_fifo(port);
522 unsigned int baud, quot;
525 c_cflag =
new->c_cflag;
526 switch (c_cflag &
CSIZE) {
545 if ((c_cflag &
PARODD) != PARODD)
559 c_iflag =
new->c_iflag;
572 if (c_iflag & IGNPAR)
576 if ((c_cflag &
CREAD) == 0)
594 siu_set_mctrl(port, port->
mctrl);
596 spin_unlock_irqrestore(&port->
lock, flags);
599 static void siu_pm(
struct uart_port *port,
unsigned int state,
unsigned int oldstate)
603 switch (port->
type) {
613 switch (port->
type) {
625 static const char *siu_type(
struct uart_port *port)
627 return siu_type_name(port);
630 static void siu_release_port(
struct uart_port *port)
639 size = siu_port_size(port);
643 static int siu_request_port(
struct uart_port *port)
648 size = siu_port_size(port);
664 static void siu_config_port(
struct uart_port *port,
int flags)
667 port->
type = siu_check_type(port);
668 (
void)siu_request_port(port);
676 if (port->
irq != serial->
irq)
686 static struct uart_ops siu_uart_ops = {
687 .tx_empty = siu_tx_empty,
688 .set_mctrl = siu_set_mctrl,
689 .get_mctrl = siu_get_mctrl,
690 .stop_tx = siu_stop_tx,
691 .start_tx = siu_start_tx,
692 .stop_rx = siu_stop_rx,
693 .enable_ms = siu_enable_ms,
694 .break_ctl = siu_break_ctl,
695 .startup = siu_startup,
696 .shutdown = siu_shutdown,
697 .set_termios = siu_set_termios,
700 .release_port = siu_release_port,
701 .request_port = siu_request_port,
702 .config_port = siu_config_port,
703 .verify_port = siu_verify_port,
710 int *
type = pdev->
dev.platform_data;
716 port = siu_uart_ports;
718 port->
type = type[
i];
736 #ifdef CONFIG_SERIAL_VR41XX_CONSOLE
738 #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
747 if (lsr & UART_LSR_BI)
752 }
while (timeout-- > 0);
761 }
while (timeout-- > 0);
765 static void siu_console_putchar(
struct uart_port *port,
int ch)
771 static void siu_console_write(
struct console *
con,
const char *
s,
unsigned count)
776 port = &siu_uart_ports[con->
index];
795 if (con->
index >= SIU_PORTS_MAX)
798 port = &siu_uart_ports[con->
index];
816 static struct console siu_console = {
818 .write = siu_console_write,
820 .setup = siu_console_setup,
823 .data = &siu_uart_driver,
826 static int __devinit siu_console_init(
void)
832 port = &siu_uart_ports[
i];
833 port->
ops = &siu_uart_ops;
853 siu_uart_ports[port->
line].
ops = &siu_uart_ops;
856 #define SERIAL_VR41XX_CONSOLE &siu_console
858 #define SERIAL_VR41XX_CONSOLE NULL
863 .driver_name =
"SIU",
875 num = siu_init_ports(dev);
879 siu_uart_driver.
nr = num;
884 for (i = 0; i < num; i++) {
885 port = &siu_uart_ports[
i];
886 port->
ops = &siu_uart_ops;
896 if (i == 0 && retval < 0) {
909 for (i = 0; i < siu_uart_driver.
nr; i++) {
910 port = &siu_uart_ports[
i];
911 if (port->
dev == &dev->
dev) {
927 for (i = 0; i < siu_uart_driver.
nr; i++) {
928 port = &siu_uart_ports[
i];
943 for (i = 0; i < siu_uart_driver.
nr; i++) {
944 port = &siu_uart_ports[
i];
956 .suspend = siu_suspend,
957 .resume = siu_resume,