23 #include <linux/pci.h>
25 #include <linux/serial_core.h>
26 #include <linux/tty.h>
28 #include <linux/kernel.h>
31 #include <linux/slab.h>
32 #include <linux/module.h>
44 static int baudrates[] = {9600, 19200, 38400, 57600, 115200, 230400, 460800,
45 921600, 1843200, 3250000};
71 tasklet_schedule(&uart->
tasklet);
81 static void timbuart_flush_buffer(
struct uart_port *port)
83 if (!timbuart_tx_empty(port)) {
92 static void timbuart_rx_chars(
struct uart_port *port)
102 spin_unlock(&port->
lock);
104 spin_lock(&port->
lock);
106 dev_dbg(port->
dev,
"%s - total read %d bytes\n",
107 __func__, port->
icount.rx);
110 static void timbuart_tx_chars(
struct uart_port *port)
123 "%s - total written %d bytes, CTL: %x, RTS: %x, baud: %x\n",
144 timbuart_tx_chars(port);
162 dev_dbg(port->
dev,
"%s - leaving\n", __func__);
174 }
else if (isr & (
RXDP))
175 timbuart_rx_chars(port);
184 dev_dbg(port->
dev,
"%s - leaving\n", __func__);
192 spin_lock(&uart->
port.lock);
195 dev_dbg(uart->
port.dev,
"%s ISR: %x\n", __func__, isr);
198 timbuart_handle_tx_port(&uart->
port, isr, &ier);
200 timbuart_mctrl_check(&uart->
port, isr, &ier);
207 spin_unlock(&uart->
port.lock);
211 static unsigned int timbuart_get_mctrl(
struct uart_port *port)
214 dev_dbg(port->
dev,
"%s - cts %x\n", __func__, cts);
222 static void timbuart_set_mctrl(
struct uart_port *port,
unsigned int mctrl)
224 dev_dbg(port->
dev,
"%s - %x\n", __func__, mctrl);
232 static void timbuart_mctrl_check(
struct uart_port *port,
u32 isr,
u32 *ier)
239 cts = timbuart_get_mctrl(port);
247 static void timbuart_enable_ms(
struct uart_port *port)
252 static void timbuart_break_ctl(
struct uart_port *port,
int ctl)
257 static int timbuart_startup(
struct uart_port *port)
274 static void timbuart_shutdown(
struct uart_port *port)
283 static int get_bindex(
int baud)
288 if (baud <= baudrates[i])
294 static void timbuart_set_termios(
struct uart_port *port,
303 bindex = get_bindex(baud);
304 dev_dbg(port->
dev,
"%s - bindex %d\n", __func__, bindex);
308 baud = baudrates[bindex];
319 spin_unlock_irqrestore(&port->
lock, flags);
322 static const char *timbuart_type(
struct uart_port *port)
330 static void timbuart_release_port(
struct uart_port *port)
344 static int timbuart_request_port(
struct uart_port *port)
375 tasklet_schedule(&uart->
tasklet);
385 static void timbuart_config_port(
struct uart_port *port,
int flags)
389 timbuart_request_port(port);
393 static int timbuart_verify_port(
struct uart_port *port,
400 static struct uart_ops timbuart_ops = {
401 .tx_empty = timbuart_tx_empty,
402 .set_mctrl = timbuart_set_mctrl,
403 .get_mctrl = timbuart_get_mctrl,
404 .stop_tx = timbuart_stop_tx,
405 .start_tx = timbuart_start_tx,
406 .flush_buffer = timbuart_flush_buffer,
407 .stop_rx = timbuart_stop_rx,
408 .enable_ms = timbuart_enable_ms,
409 .break_ctl = timbuart_break_ctl,
410 .startup = timbuart_startup,
411 .shutdown = timbuart_shutdown,
412 .set_termios = timbuart_set_termios,
413 .type = timbuart_type,
414 .release_port = timbuart_release_port,
415 .request_port = timbuart_request_port,
416 .config_port = timbuart_config_port,
417 .verify_port = timbuart_verify_port
422 .driver_name =
"timberdale_uart",
445 uart->
port.uartclk = 3250000 * 16;
447 uart->
port.regshift = 2;
449 uart->
port.ops = &timbuart_ops;
468 uart->
port.irq = irq;
480 platform_set_drvdata(dev, uart);
489 printk(
KERN_ERR "timberdale: Failed to register Timberdale UART: %d\n",
512 .probe = timbuart_probe,