6 #include <linux/module.h>
11 #include <linux/device.h>
13 #include <linux/serial_core.h>
14 #include <linux/serial.h>
21 #include <mach/hardware.h>
23 #define BAUD_BASE (mem_fclk_21285/64)
25 #define SERIAL_21285_NAME "ttyFB"
26 #define SERIAL_21285_MAJOR 204
27 #define SERIAL_21285_MINOR 4
29 #define RXSTAT_DUMMY_READ 0x80000000
30 #define RXSTAT_FRAME (1 << 0)
31 #define RXSTAT_PARITY (1 << 1)
32 #define RXSTAT_OVERRUN (1 << 2)
33 #define RXSTAT_ANYERR (RXSTAT_FRAME|RXSTAT_PARITY|RXSTAT_OVERRUN)
35 #define H_UBRLCR_BREAK (1 << 0)
36 #define H_UBRLCR_PARENB (1 << 1)
37 #define H_UBRLCR_PAREVN (1 << 2)
38 #define H_UBRLCR_STOPB (1 << 3)
39 #define H_UBRLCR_FIFO (1 << 4)
41 static const char serial21285_name[] =
"Footbridge UART";
43 #define tx_enabled(port) ((port)->unused[0])
44 #define rx_enabled(port) ((port)->unused[1])
73 static void serial21285_stop_rx(
struct uart_port *port)
81 static void serial21285_enable_ms(
struct uart_port *port)
92 while (!(status & 0x10) && max_count--) {
108 if (rxs & RXSTAT_PARITY)
110 else if (rxs & RXSTAT_FRAME)
123 static irqreturn_t serial21285_tx_chars(
int irq,
void *dev_id)
136 serial21285_stop_tx(port);
152 serial21285_stop_tx(port);
158 static unsigned int serial21285_tx_empty(
struct uart_port *port)
164 static unsigned int serial21285_get_mctrl(
struct uart_port *port)
169 static void serial21285_set_mctrl(
struct uart_port *port,
unsigned int mctrl)
173 static void serial21285_break_ctl(
struct uart_port *port,
int break_state)
185 spin_unlock_irqrestore(&port->
lock, flags);
188 static int serial21285_startup(
struct uart_port *port)
196 serial21285_name, port);
199 serial21285_name, port);
207 static void serial21285_shutdown(
struct uart_port *port)
218 unsigned int baud, quot, h_lcr,
b;
236 b = port->
uartclk / (16 * quot);
302 spin_unlock_irqrestore(&port->
lock, flags);
305 static const char *serial21285_type(
struct uart_port *port)
310 static void serial21285_release_port(
struct uart_port *port)
315 static int serial21285_request_port(
struct uart_port *port)
321 static void serial21285_config_port(
struct uart_port *port,
int flags)
342 static struct uart_ops serial21285_ops = {
343 .tx_empty = serial21285_tx_empty,
344 .get_mctrl = serial21285_get_mctrl,
345 .set_mctrl = serial21285_set_mctrl,
346 .stop_tx = serial21285_stop_tx,
347 .start_tx = serial21285_start_tx,
348 .stop_rx = serial21285_stop_rx,
349 .enable_ms = serial21285_enable_ms,
350 .break_ctl = serial21285_break_ctl,
351 .startup = serial21285_startup,
352 .shutdown = serial21285_shutdown,
353 .set_termios = serial21285_set_termios,
354 .type = serial21285_type,
355 .release_port = serial21285_release_port,
356 .request_port = serial21285_request_port,
357 .config_port = serial21285_config_port,
358 .verify_port = serial21285_verify_port,
361 static struct uart_port serial21285_port = {
362 .mapbase = 0x42000160,
366 .ops = &serial21285_ops,
370 static void serial21285_setup_ports(
void)
375 #ifdef CONFIG_SERIAL_21285_CONSOLE
376 static void serial21285_console_putchar(
struct uart_port *port,
int ch)
384 serial21285_console_write(
struct console *co,
const char *
s,
391 serial21285_get_options(
struct uart_port *port,
int *baud,
392 int *parity,
int *
bits)
398 switch (tmp & 0x60) {
422 *baud = port->
uartclk / (16 * (tmp + 1));
428 struct uart_port *port = &serial21285_port;
434 if (machine_is_personal_server())
445 serial21285_get_options(port, &baud, &parity, &bits);
452 static struct console serial21285_console =
455 .write = serial21285_console_write,
457 .setup = serial21285_console_setup,
460 .data = &serial21285_reg,
463 static int __init rs285_console_init(
void)
465 serial21285_setup_ports();
471 #define SERIAL_21285_CONSOLE &serial21285_console
473 #define SERIAL_21285_CONSOLE NULL
478 .driver_name =
"ttyFB",
486 static int __init serial21285_init(
void)
492 serial21285_setup_ports();
501 static void __exit serial21285_exit(
void)