17 #if defined(CONFIG_SERIAL_PNX8XXX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
21 #include <linux/module.h>
26 #include <linux/device.h>
28 #include <linux/tty.h>
30 #include <linux/serial_core.h>
31 #include <linux/serial.h>
38 #define SERIAL_PNX8XXX_MAJOR 204
43 #define PNX8XXX_ISR_PASS_LIMIT 256
49 #define SM_TO_FIFO(x) ((x) >> 10)
50 #define SM_TO_ISTAT(x) ((x) & 0x000001ff)
51 #define FIFO_TO_SM(x) ((x) << 10)
52 #define ISTAT_TO_SM(x) ((x) & 0x000001ff)
57 #define UART_PORT_SIZE 0x1000
65 #define MCTRL_TIMEOUT (250*HZ/1000)
82 static void pnx8xxx_mctrl_check(
struct pnx8xxx_port *sport)
86 status = sport->
port.ops->get_mctrl(&sport->
port);
95 sport->
port.icount.rng++;
97 sport->
port.icount.dsr++;
110 static void pnx8xxx_timeout(
unsigned long data)
115 if (sport->
port.state) {
117 pnx8xxx_mctrl_check(sport);
118 spin_unlock_irqrestore(&sport->
port.lock, flags);
182 static void pnx8xxx_rx_chars(
struct pnx8xxx_port *sport)
185 unsigned int status, ch, flg;
192 sport->
port.icount.rx++;
207 sport->
port.icount.brk++;
208 if (uart_handle_break(&sport->
port))
211 sport->
port.icount.parity++;
213 sport->
port.icount.frame++;
215 sport->
port.icount.overrun++;
217 status &= sport->
port.read_status_mask;
225 sport->
port.sysrq = 0;
244 static void pnx8xxx_tx_chars(
struct pnx8xxx_port *sport)
248 if (sport->
port.x_char) {
250 sport->
port.icount.tx++;
251 sport->
port.x_char = 0;
259 pnx8xxx_mctrl_check(sport);
262 pnx8xxx_stop_tx(&sport->
port);
273 sport->
port.icount.tx++;
282 pnx8xxx_stop_tx(&sport->
port);
290 spin_lock(&sport->
port.lock);
296 pnx8xxx_rx_chars(sport);
300 pnx8xxx_tx_chars(sport);
305 spin_unlock(&sport->
port.lock);
319 static unsigned int pnx8xxx_get_mctrl(
struct uart_port *
port)
335 static void pnx8xxx_set_mctrl(
struct uart_port *
port,
unsigned int mctrl)
346 static void pnx8xxx_break_ctl(
struct uart_port *
port,
int break_state)
354 if (break_state == -1)
359 spin_unlock_irqrestore(&sport->
port.lock, flags);
362 static int pnx8xxx_startup(
struct uart_port *port)
371 "pnx8xxx-uart", sport);
389 spin_lock_irq(&sport->
port.lock);
390 pnx8xxx_enable_ms(&sport->
port);
391 spin_unlock_irq(&sport->
port.lock);
396 static void pnx8xxx_shutdown(
struct uart_port *port)
437 unsigned int lcr_fcr, old_ien,
baud, quot;
475 sport->
port.read_status_mask |=
479 sport->
port.read_status_mask |=
485 sport->
port.ignore_status_mask = 0;
487 sport->
port.ignore_status_mask |=
491 sport->
port.ignore_status_mask |=
498 sport->
port.ignore_status_mask |=
506 sport->
port.ignore_status_mask |=
545 pnx8xxx_enable_ms(&sport->
port);
547 spin_unlock_irqrestore(&sport->
port.lock, flags);
550 static const char *pnx8xxx_type(
struct uart_port *port)
560 static void pnx8xxx_release_port(
struct uart_port *port)
570 static int pnx8xxx_request_port(
struct uart_port *port)
580 static void pnx8xxx_config_port(
struct uart_port *port,
int flags)
585 pnx8xxx_request_port(&sport->
port) == 0)
602 if (sport->
port.irq != ser->
irq)
610 if (sport->
port.iobase != ser->
port)
617 static struct uart_ops pnx8xxx_pops = {
618 .tx_empty = pnx8xxx_tx_empty,
619 .set_mctrl = pnx8xxx_set_mctrl,
620 .get_mctrl = pnx8xxx_get_mctrl,
621 .stop_tx = pnx8xxx_stop_tx,
622 .start_tx = pnx8xxx_start_tx,
623 .stop_rx = pnx8xxx_stop_rx,
624 .enable_ms = pnx8xxx_enable_ms,
625 .break_ctl = pnx8xxx_break_ctl,
626 .startup = pnx8xxx_startup,
627 .shutdown = pnx8xxx_shutdown,
628 .set_termios = pnx8xxx_set_termios,
629 .type = pnx8xxx_type,
630 .release_port = pnx8xxx_release_port,
631 .request_port = pnx8xxx_request_port,
632 .config_port = pnx8xxx_config_port,
633 .verify_port = pnx8xxx_verify_port,
642 static void __init pnx8xxx_init_ports(
void)
644 static int first = 1;
659 #ifdef CONFIG_SERIAL_PNX8XXX_CONSOLE
661 static void pnx8xxx_console_putchar(
struct uart_port *port,
int ch)
669 }
while (status & PNX8XXX_UART_FIFO_TXFIFO);
676 pnx8xxx_console_write(
struct console *co,
const char *
s,
unsigned int count)
679 unsigned int old_ien,
status;
697 }
while (status & PNX8XXX_UART_FIFO_TXFIFO);
731 static struct console pnx8xxx_console = {
733 .write = pnx8xxx_console_write,
735 .setup = pnx8xxx_console_setup,
738 .data = &pnx8xxx_reg,
741 static int __init pnx8xxx_rs_console_init(
void)
743 pnx8xxx_init_ports();
749 #define PNX8XXX_CONSOLE &pnx8xxx_console
751 #define PNX8XXX_CONSOLE NULL
756 .driver_name =
"ttyS",
766 struct pnx8xxx_port *sport = platform_get_drvdata(pdev);
773 struct pnx8xxx_port *sport = platform_get_drvdata(pdev);
803 struct pnx8xxx_port *sport = platform_get_drvdata(pdev);
805 platform_set_drvdata(pdev,
NULL);
815 .name =
"pnx8xxx-uart",
818 .probe = pnx8xxx_serial_probe,
819 .remove = pnx8xxx_serial_remove,
820 .suspend = pnx8xxx_serial_suspend,
821 .resume = pnx8xxx_serial_resume,
824 static int __init pnx8xxx_serial_init(
void)
830 pnx8xxx_init_ports();
841 static void __exit pnx8xxx_serial_exit(
void)