Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1 | /* |
Mike Frysinger | 1ba7a3e | 2008-01-11 15:56:26 +0800 | [diff] [blame] | 2 | * Blackfin On-Chip Serial Driver |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 3 | * |
Mike Frysinger | d273e201 | 2008-10-13 10:33:06 +0100 | [diff] [blame] | 4 | * Copyright 2006-2008 Analog Devices Inc. |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 5 | * |
Mike Frysinger | 1ba7a3e | 2008-01-11 15:56:26 +0800 | [diff] [blame] | 6 | * Enter bugs at http://blackfin.uclinux.org/ |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 7 | * |
Mike Frysinger | 1ba7a3e | 2008-01-11 15:56:26 +0800 | [diff] [blame] | 8 | * Licensed under the GPL-2 or later. |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #if defined(CONFIG_SERIAL_BFIN_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) |
| 12 | #define SUPPORT_SYSRQ |
| 13 | #endif |
| 14 | |
| 15 | #include <linux/module.h> |
| 16 | #include <linux/ioport.h> |
| 17 | #include <linux/init.h> |
| 18 | #include <linux/console.h> |
| 19 | #include <linux/sysrq.h> |
| 20 | #include <linux/platform_device.h> |
| 21 | #include <linux/tty.h> |
| 22 | #include <linux/tty_flip.h> |
| 23 | #include <linux/serial_core.h> |
| 24 | |
Sonic Zhang | 52e15f0e | 2009-01-02 13:40:14 +0000 | [diff] [blame] | 25 | #if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \ |
| 26 | defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE) |
Sonic Zhang | 474f1a6 | 2007-06-29 16:35:17 +0800 | [diff] [blame] | 27 | #include <linux/kgdb.h> |
| 28 | #include <asm/irq_regs.h> |
| 29 | #endif |
| 30 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 31 | #include <asm/gpio.h> |
Bryan Wu | 639f657 | 2008-08-27 10:51:02 +0800 | [diff] [blame] | 32 | #include <mach/bfin_serial_5xx.h> |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 33 | |
| 34 | #ifdef CONFIG_SERIAL_BFIN_DMA |
| 35 | #include <linux/dma-mapping.h> |
| 36 | #include <asm/io.h> |
| 37 | #include <asm/irq.h> |
| 38 | #include <asm/cacheflush.h> |
| 39 | #endif |
| 40 | |
| 41 | /* UART name and device definitions */ |
| 42 | #define BFIN_SERIAL_NAME "ttyBF" |
| 43 | #define BFIN_SERIAL_MAJOR 204 |
| 44 | #define BFIN_SERIAL_MINOR 64 |
| 45 | |
Mike Frysinger | c9607ec | 2008-10-13 10:33:16 +0100 | [diff] [blame] | 46 | static struct bfin_serial_port bfin_serial_ports[BFIN_UART_NR_PORTS]; |
| 47 | static int nr_active_ports = ARRAY_SIZE(bfin_serial_resource); |
| 48 | |
Sonic Zhang | 52e15f0e | 2009-01-02 13:40:14 +0000 | [diff] [blame] | 49 | #if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \ |
| 50 | defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE) |
| 51 | |
| 52 | # ifndef CONFIG_SERIAL_BFIN_PIO |
| 53 | # error KGDB only support UART in PIO mode. |
| 54 | # endif |
| 55 | |
| 56 | static int kgdboc_port_line; |
| 57 | static int kgdboc_break_enabled; |
| 58 | #endif |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 59 | /* |
| 60 | * Setup for console. Argument comes from the menuconfig |
| 61 | */ |
| 62 | #define DMA_RX_XCOUNT 512 |
| 63 | #define DMA_RX_YCOUNT (PAGE_SIZE / DMA_RX_XCOUNT) |
| 64 | |
Sonic Zhang | 0aef456 | 2008-02-29 12:08:42 +0800 | [diff] [blame] | 65 | #define DMA_RX_FLUSH_JIFFIES (HZ / 50) |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 66 | |
| 67 | #ifdef CONFIG_SERIAL_BFIN_DMA |
| 68 | static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart); |
| 69 | #else |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 70 | static void bfin_serial_tx_chars(struct bfin_serial_port *uart); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 71 | #endif |
| 72 | |
Graf Yang | 80d5c47 | 2009-01-02 13:40:22 +0000 | [diff] [blame] | 73 | static void bfin_serial_reset_irda(struct uart_port *port); |
| 74 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 75 | /* |
| 76 | * interrupts are disabled on entry |
| 77 | */ |
| 78 | static void bfin_serial_stop_tx(struct uart_port *port) |
| 79 | { |
| 80 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
Sonic Zhang | 68a784c | 2009-01-02 13:40:38 +0000 | [diff] [blame] | 81 | #ifdef CONFIG_SERIAL_BFIN_DMA |
Sonic Zhang | 0711d85 | 2008-02-25 15:16:50 +0800 | [diff] [blame] | 82 | struct circ_buf *xmit = &uart->port.info->xmit; |
Sonic Zhang | 68a784c | 2009-01-02 13:40:38 +0000 | [diff] [blame] | 83 | #endif |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 84 | |
Roy Huang | f4d640c9 | 2007-07-12 16:43:46 +0800 | [diff] [blame] | 85 | while (!(UART_GET_LSR(uart) & TEMT)) |
Sonic Zhang | 0711d85 | 2008-02-25 15:16:50 +0800 | [diff] [blame] | 86 | cpu_relax(); |
Roy Huang | f4d640c9 | 2007-07-12 16:43:46 +0800 | [diff] [blame] | 87 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 88 | #ifdef CONFIG_SERIAL_BFIN_DMA |
| 89 | disable_dma(uart->tx_dma_channel); |
Sonic Zhang | 0711d85 | 2008-02-25 15:16:50 +0800 | [diff] [blame] | 90 | xmit->tail = (xmit->tail + uart->tx_count) & (UART_XMIT_SIZE - 1); |
| 91 | uart->port.icount.tx += uart->tx_count; |
| 92 | uart->tx_count = 0; |
| 93 | uart->tx_done = 1; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 94 | #else |
Roy Huang | f4d640c9 | 2007-07-12 16:43:46 +0800 | [diff] [blame] | 95 | #ifdef CONFIG_BF54x |
Roy Huang | f4d640c9 | 2007-07-12 16:43:46 +0800 | [diff] [blame] | 96 | /* Clear TFI bit */ |
| 97 | UART_PUT_LSR(uart, TFI); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 98 | #endif |
Mike Frysinger | 89bf6dc5 | 2008-05-07 11:41:26 +0800 | [diff] [blame] | 99 | UART_CLEAR_IER(uart, ETBEI); |
Roy Huang | f4d640c9 | 2007-07-12 16:43:46 +0800 | [diff] [blame] | 100 | #endif |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | /* |
| 104 | * port is locked and interrupts are disabled |
| 105 | */ |
| 106 | static void bfin_serial_start_tx(struct uart_port *port) |
| 107 | { |
| 108 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
Graf Yang | 80d5c47 | 2009-01-02 13:40:22 +0000 | [diff] [blame] | 109 | struct tty_struct *tty = uart->port.info->port.tty; |
| 110 | |
| 111 | /* |
| 112 | * To avoid losting RX interrupt, we reset IR function |
| 113 | * before sending data. |
| 114 | */ |
| 115 | if (tty->termios->c_line == N_IRDA) |
| 116 | bfin_serial_reset_irda(port); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 117 | |
| 118 | #ifdef CONFIG_SERIAL_BFIN_DMA |
Sonic Zhang | 0711d85 | 2008-02-25 15:16:50 +0800 | [diff] [blame] | 119 | if (uart->tx_done) |
| 120 | bfin_serial_dma_tx_chars(uart); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 121 | #else |
Roy Huang | f4d640c9 | 2007-07-12 16:43:46 +0800 | [diff] [blame] | 122 | UART_SET_IER(uart, ETBEI); |
Sonic Zhang | a359cca | 2007-10-10 16:47:58 +0800 | [diff] [blame] | 123 | bfin_serial_tx_chars(uart); |
Roy Huang | f4d640c9 | 2007-07-12 16:43:46 +0800 | [diff] [blame] | 124 | #endif |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | /* |
| 128 | * Interrupts are enabled |
| 129 | */ |
| 130 | static void bfin_serial_stop_rx(struct uart_port *port) |
| 131 | { |
| 132 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
Sonic Zhang | 52e15f0e | 2009-01-02 13:40:14 +0000 | [diff] [blame] | 133 | |
Roy Huang | f4d640c9 | 2007-07-12 16:43:46 +0800 | [diff] [blame] | 134 | UART_CLEAR_IER(uart, ERBFI); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | /* |
| 138 | * Set the modem control timer to fire immediately. |
| 139 | */ |
| 140 | static void bfin_serial_enable_ms(struct uart_port *port) |
| 141 | { |
| 142 | } |
| 143 | |
Sonic Zhang | 474f1a6 | 2007-06-29 16:35:17 +0800 | [diff] [blame] | 144 | |
Mike Frysinger | 50e2e15 | 2008-04-25 03:03:03 +0800 | [diff] [blame] | 145 | #if ANOMALY_05000363 && defined(CONFIG_SERIAL_BFIN_PIO) |
Mike Frysinger | 8851c71 | 2007-12-24 19:48:04 +0800 | [diff] [blame] | 146 | # define UART_GET_ANOMALY_THRESHOLD(uart) ((uart)->anomaly_threshold) |
| 147 | # define UART_SET_ANOMALY_THRESHOLD(uart, v) ((uart)->anomaly_threshold = (v)) |
| 148 | #else |
| 149 | # define UART_GET_ANOMALY_THRESHOLD(uart) 0 |
| 150 | # define UART_SET_ANOMALY_THRESHOLD(uart, v) |
| 151 | #endif |
| 152 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 153 | #ifdef CONFIG_SERIAL_BFIN_PIO |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 154 | static void bfin_serial_rx_chars(struct bfin_serial_port *uart) |
| 155 | { |
Sonic Zhang | 52e15f0e | 2009-01-02 13:40:14 +0000 | [diff] [blame] | 156 | struct tty_struct *tty = NULL; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 157 | unsigned int status, ch, flg; |
Mike Frysinger | 8851c71 | 2007-12-24 19:48:04 +0800 | [diff] [blame] | 158 | static struct timeval anomaly_start = { .tv_sec = 0 }; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 159 | |
Sonic Zhang | 759eb04 | 2007-11-21 17:00:32 +0800 | [diff] [blame] | 160 | status = UART_GET_LSR(uart); |
Mike Frysinger | 0bcfd70 | 2007-12-24 19:40:05 +0800 | [diff] [blame] | 161 | UART_CLEAR_LSR(uart); |
| 162 | |
| 163 | ch = UART_GET_CHAR(uart); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 164 | uart->port.icount.rx++; |
| 165 | |
Sonic Zhang | 52e15f0e | 2009-01-02 13:40:14 +0000 | [diff] [blame] | 166 | #if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \ |
| 167 | defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE) |
| 168 | if (kgdb_connected && kgdboc_port_line == uart->port.line) |
| 169 | if (ch == 0x3) {/* Ctrl + C */ |
| 170 | kgdb_breakpoint(); |
Sonic Zhang | 474f1a6 | 2007-06-29 16:35:17 +0800 | [diff] [blame] | 171 | return; |
Sonic Zhang | 474f1a6 | 2007-06-29 16:35:17 +0800 | [diff] [blame] | 172 | } |
Sonic Zhang | 52e15f0e | 2009-01-02 13:40:14 +0000 | [diff] [blame] | 173 | |
Sonic Zhang | df04baf | 2009-04-06 17:32:35 +0100 | [diff] [blame] | 174 | if (!uart->port.info || !uart->port.info->port.tty) |
Sonic Zhang | 52e15f0e | 2009-01-02 13:40:14 +0000 | [diff] [blame] | 175 | return; |
Sonic Zhang | 474f1a6 | 2007-06-29 16:35:17 +0800 | [diff] [blame] | 176 | #endif |
Sonic Zhang | df04baf | 2009-04-06 17:32:35 +0100 | [diff] [blame] | 177 | tty = uart->port.info->port.tty; |
Mike Frysinger | bbf275f | 2007-08-05 16:48:08 +0800 | [diff] [blame] | 178 | |
Mike Frysinger | 50e2e15 | 2008-04-25 03:03:03 +0800 | [diff] [blame] | 179 | if (ANOMALY_05000363) { |
Mike Frysinger | 8851c71 | 2007-12-24 19:48:04 +0800 | [diff] [blame] | 180 | /* The BF533 (and BF561) family of processors have a nice anomaly |
| 181 | * where they continuously generate characters for a "single" break. |
Mike Frysinger | bbf275f | 2007-08-05 16:48:08 +0800 | [diff] [blame] | 182 | * We have to basically ignore this flood until the "next" valid |
Mike Frysinger | 8851c71 | 2007-12-24 19:48:04 +0800 | [diff] [blame] | 183 | * character comes across. Due to the nature of the flood, it is |
| 184 | * not possible to reliably catch bytes that are sent too quickly |
| 185 | * after this break. So application code talking to the Blackfin |
| 186 | * which sends a break signal must allow at least 1.5 character |
| 187 | * times after the end of the break for things to stabilize. This |
| 188 | * timeout was picked as it must absolutely be larger than 1 |
| 189 | * character time +/- some percent. So 1.5 sounds good. All other |
| 190 | * Blackfin families operate properly. Woo. |
Mike Frysinger | bbf275f | 2007-08-05 16:48:08 +0800 | [diff] [blame] | 191 | */ |
Mike Frysinger | 8851c71 | 2007-12-24 19:48:04 +0800 | [diff] [blame] | 192 | if (anomaly_start.tv_sec) { |
| 193 | struct timeval curr; |
| 194 | suseconds_t usecs; |
| 195 | |
| 196 | if ((~ch & (~ch + 1)) & 0xff) |
| 197 | goto known_good_char; |
| 198 | |
| 199 | do_gettimeofday(&curr); |
| 200 | if (curr.tv_sec - anomaly_start.tv_sec > 1) |
| 201 | goto known_good_char; |
| 202 | |
| 203 | usecs = 0; |
| 204 | if (curr.tv_sec != anomaly_start.tv_sec) |
| 205 | usecs += USEC_PER_SEC; |
| 206 | usecs += curr.tv_usec - anomaly_start.tv_usec; |
| 207 | |
| 208 | if (usecs > UART_GET_ANOMALY_THRESHOLD(uart)) |
| 209 | goto known_good_char; |
| 210 | |
| 211 | if (ch) |
| 212 | anomaly_start.tv_sec = 0; |
| 213 | else |
| 214 | anomaly_start = curr; |
| 215 | |
| 216 | return; |
| 217 | |
| 218 | known_good_char: |
Sonic Zhang | e482a23 | 2009-01-02 13:40:45 +0000 | [diff] [blame] | 219 | status &= ~BI; |
Mike Frysinger | 8851c71 | 2007-12-24 19:48:04 +0800 | [diff] [blame] | 220 | anomaly_start.tv_sec = 0; |
Mike Frysinger | bbf275f | 2007-08-05 16:48:08 +0800 | [diff] [blame] | 221 | } |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 222 | } |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 223 | |
| 224 | if (status & BI) { |
Mike Frysinger | 50e2e15 | 2008-04-25 03:03:03 +0800 | [diff] [blame] | 225 | if (ANOMALY_05000363) |
Mike Frysinger | 8851c71 | 2007-12-24 19:48:04 +0800 | [diff] [blame] | 226 | if (bfin_revid() < 5) |
| 227 | do_gettimeofday(&anomaly_start); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 228 | uart->port.icount.brk++; |
| 229 | if (uart_handle_break(&uart->port)) |
| 230 | goto ignore_char; |
Mike Frysinger | 9808901 | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 231 | status &= ~(PE | FE); |
Mike Frysinger | 2ac5ee4 | 2007-05-21 18:09:39 +0800 | [diff] [blame] | 232 | } |
| 233 | if (status & PE) |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 234 | uart->port.icount.parity++; |
Mike Frysinger | 2ac5ee4 | 2007-05-21 18:09:39 +0800 | [diff] [blame] | 235 | if (status & OE) |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 236 | uart->port.icount.overrun++; |
Mike Frysinger | 2ac5ee4 | 2007-05-21 18:09:39 +0800 | [diff] [blame] | 237 | if (status & FE) |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 238 | uart->port.icount.frame++; |
Mike Frysinger | 2ac5ee4 | 2007-05-21 18:09:39 +0800 | [diff] [blame] | 239 | |
| 240 | status &= uart->port.read_status_mask; |
| 241 | |
| 242 | if (status & BI) |
| 243 | flg = TTY_BREAK; |
| 244 | else if (status & PE) |
| 245 | flg = TTY_PARITY; |
| 246 | else if (status & FE) |
| 247 | flg = TTY_FRAME; |
| 248 | else |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 249 | flg = TTY_NORMAL; |
| 250 | |
| 251 | if (uart_handle_sysrq_char(&uart->port, ch)) |
| 252 | goto ignore_char; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 253 | |
Mike Frysinger | 2ac5ee4 | 2007-05-21 18:09:39 +0800 | [diff] [blame] | 254 | uart_insert_char(&uart->port, status, OE, ch, flg); |
| 255 | |
| 256 | ignore_char: |
| 257 | tty_flip_buffer_push(tty); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | static void bfin_serial_tx_chars(struct bfin_serial_port *uart) |
| 261 | { |
| 262 | struct circ_buf *xmit = &uart->port.info->xmit; |
| 263 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 264 | if (uart_circ_empty(xmit) || uart_tx_stopped(&uart->port)) { |
Sonic Zhang | 5ffdeea2 | 2008-10-13 10:33:33 +0100 | [diff] [blame] | 265 | #ifdef CONFIG_BF54x |
| 266 | /* Clear TFI bit */ |
| 267 | UART_PUT_LSR(uart, TFI); |
| 268 | #endif |
| 269 | UART_CLEAR_IER(uart, ETBEI); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 270 | return; |
| 271 | } |
| 272 | |
Sonic Zhang | f30ac0c | 2008-06-19 17:46:39 +0800 | [diff] [blame] | 273 | if (uart->port.x_char) { |
| 274 | UART_PUT_CHAR(uart, uart->port.x_char); |
| 275 | uart->port.icount.tx++; |
| 276 | uart->port.x_char = 0; |
| 277 | } |
| 278 | |
Sonic Zhang | 759eb04 | 2007-11-21 17:00:32 +0800 | [diff] [blame] | 279 | while ((UART_GET_LSR(uart) & THRE) && xmit->tail != xmit->head) { |
| 280 | UART_PUT_CHAR(uart, xmit->buf[xmit->tail]); |
| 281 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); |
| 282 | uart->port.icount.tx++; |
| 283 | SSYNC(); |
| 284 | } |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 285 | |
| 286 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) |
| 287 | uart_write_wakeup(&uart->port); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 288 | } |
| 289 | |
Aubrey Li | 5c4e472 | 2007-05-21 18:09:38 +0800 | [diff] [blame] | 290 | static irqreturn_t bfin_serial_rx_int(int irq, void *dev_id) |
| 291 | { |
| 292 | struct bfin_serial_port *uart = dev_id; |
| 293 | |
Roy Huang | f4d640c9 | 2007-07-12 16:43:46 +0800 | [diff] [blame] | 294 | spin_lock(&uart->port.lock); |
Mike Frysinger | 0bcfd70 | 2007-12-24 19:40:05 +0800 | [diff] [blame] | 295 | while (UART_GET_LSR(uart) & DR) |
Aubrey Li | 5c4e472 | 2007-05-21 18:09:38 +0800 | [diff] [blame] | 296 | bfin_serial_rx_chars(uart); |
| 297 | spin_unlock(&uart->port.lock); |
Sonic Zhang | 759eb04 | 2007-11-21 17:00:32 +0800 | [diff] [blame] | 298 | |
Aubrey Li | 5c4e472 | 2007-05-21 18:09:38 +0800 | [diff] [blame] | 299 | return IRQ_HANDLED; |
| 300 | } |
| 301 | |
| 302 | static irqreturn_t bfin_serial_tx_int(int irq, void *dev_id) |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 303 | { |
| 304 | struct bfin_serial_port *uart = dev_id; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 305 | |
Roy Huang | f4d640c9 | 2007-07-12 16:43:46 +0800 | [diff] [blame] | 306 | spin_lock(&uart->port.lock); |
Mike Frysinger | 0bcfd70 | 2007-12-24 19:40:05 +0800 | [diff] [blame] | 307 | if (UART_GET_LSR(uart) & THRE) |
Aubrey Li | 5c4e472 | 2007-05-21 18:09:38 +0800 | [diff] [blame] | 308 | bfin_serial_tx_chars(uart); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 309 | spin_unlock(&uart->port.lock); |
Sonic Zhang | 759eb04 | 2007-11-21 17:00:32 +0800 | [diff] [blame] | 310 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 311 | return IRQ_HANDLED; |
| 312 | } |
Sonic Zhang | 4cb4f22 | 2008-02-02 14:29:25 +0800 | [diff] [blame] | 313 | #endif |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 314 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 315 | #ifdef CONFIG_SERIAL_BFIN_DMA |
| 316 | static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart) |
| 317 | { |
| 318 | struct circ_buf *xmit = &uart->port.info->xmit; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 319 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 320 | uart->tx_done = 0; |
| 321 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 322 | if (uart_circ_empty(xmit) || uart_tx_stopped(&uart->port)) { |
Sonic Zhang | 0711d85 | 2008-02-25 15:16:50 +0800 | [diff] [blame] | 323 | uart->tx_count = 0; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 324 | uart->tx_done = 1; |
| 325 | return; |
| 326 | } |
| 327 | |
Sonic Zhang | 1b73351 | 2007-12-21 16:45:12 +0800 | [diff] [blame] | 328 | if (uart->port.x_char) { |
| 329 | UART_PUT_CHAR(uart, uart->port.x_char); |
| 330 | uart->port.icount.tx++; |
| 331 | uart->port.x_char = 0; |
| 332 | } |
| 333 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 334 | uart->tx_count = CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE); |
| 335 | if (uart->tx_count > (UART_XMIT_SIZE - xmit->tail)) |
| 336 | uart->tx_count = UART_XMIT_SIZE - xmit->tail; |
| 337 | blackfin_dcache_flush_range((unsigned long)(xmit->buf+xmit->tail), |
| 338 | (unsigned long)(xmit->buf+xmit->tail+uart->tx_count)); |
| 339 | set_dma_config(uart->tx_dma_channel, |
| 340 | set_bfin_dma_config(DIR_READ, DMA_FLOW_STOP, |
| 341 | INTR_ON_BUF, |
| 342 | DIMENSION_LINEAR, |
Michael Hennerich | 2047e40 | 2008-01-22 15:29:18 +0800 | [diff] [blame] | 343 | DATA_SIZE_8, |
| 344 | DMA_SYNC_RESTART)); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 345 | set_dma_start_addr(uart->tx_dma_channel, (unsigned long)(xmit->buf+xmit->tail)); |
| 346 | set_dma_x_count(uart->tx_dma_channel, uart->tx_count); |
| 347 | set_dma_x_modify(uart->tx_dma_channel, 1); |
| 348 | enable_dma(uart->tx_dma_channel); |
Sonic Zhang | 99ee7b5 | 2007-12-21 17:12:55 +0800 | [diff] [blame] | 349 | |
Roy Huang | f4d640c9 | 2007-07-12 16:43:46 +0800 | [diff] [blame] | 350 | UART_SET_IER(uart, ETBEI); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 351 | } |
| 352 | |
Mike Frysinger | 2ac5ee4 | 2007-05-21 18:09:39 +0800 | [diff] [blame] | 353 | static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart) |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 354 | { |
Takashi Iwai | a88487c | 2008-07-16 21:54:42 +0100 | [diff] [blame] | 355 | struct tty_struct *tty = uart->port.info->port.tty; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 356 | int i, flg, status; |
| 357 | |
| 358 | status = UART_GET_LSR(uart); |
Mike Frysinger | 0bcfd70 | 2007-12-24 19:40:05 +0800 | [diff] [blame] | 359 | UART_CLEAR_LSR(uart); |
| 360 | |
Sonic Zhang | 56f5de8 | 2008-02-25 15:19:09 +0800 | [diff] [blame] | 361 | uart->port.icount.rx += |
| 362 | CIRC_CNT(uart->rx_dma_buf.head, uart->rx_dma_buf.tail, |
| 363 | UART_XMIT_SIZE); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 364 | |
| 365 | if (status & BI) { |
| 366 | uart->port.icount.brk++; |
| 367 | if (uart_handle_break(&uart->port)) |
| 368 | goto dma_ignore_char; |
Mike Frysinger | 9808901 | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 369 | status &= ~(PE | FE); |
Mike Frysinger | 2ac5ee4 | 2007-05-21 18:09:39 +0800 | [diff] [blame] | 370 | } |
| 371 | if (status & PE) |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 372 | uart->port.icount.parity++; |
Mike Frysinger | 2ac5ee4 | 2007-05-21 18:09:39 +0800 | [diff] [blame] | 373 | if (status & OE) |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 374 | uart->port.icount.overrun++; |
Mike Frysinger | 2ac5ee4 | 2007-05-21 18:09:39 +0800 | [diff] [blame] | 375 | if (status & FE) |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 376 | uart->port.icount.frame++; |
Mike Frysinger | 2ac5ee4 | 2007-05-21 18:09:39 +0800 | [diff] [blame] | 377 | |
| 378 | status &= uart->port.read_status_mask; |
| 379 | |
| 380 | if (status & BI) |
| 381 | flg = TTY_BREAK; |
| 382 | else if (status & PE) |
| 383 | flg = TTY_PARITY; |
| 384 | else if (status & FE) |
| 385 | flg = TTY_FRAME; |
| 386 | else |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 387 | flg = TTY_NORMAL; |
| 388 | |
Sonic Zhang | 8c4210e | 2009-04-06 17:32:42 +0100 | [diff] [blame] | 389 | for (i = uart->rx_dma_buf.tail; ; i++) { |
Sonic Zhang | 56f5de8 | 2008-02-25 15:19:09 +0800 | [diff] [blame] | 390 | if (i >= UART_XMIT_SIZE) |
| 391 | i = 0; |
Sonic Zhang | 8c4210e | 2009-04-06 17:32:42 +0100 | [diff] [blame] | 392 | if (i == uart->rx_dma_buf.head) |
| 393 | break; |
Sonic Zhang | 56f5de8 | 2008-02-25 15:19:09 +0800 | [diff] [blame] | 394 | if (!uart_handle_sysrq_char(&uart->port, uart->rx_dma_buf.buf[i])) |
| 395 | uart_insert_char(&uart->port, status, OE, |
| 396 | uart->rx_dma_buf.buf[i], flg); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 397 | } |
Mike Frysinger | 2ac5ee4 | 2007-05-21 18:09:39 +0800 | [diff] [blame] | 398 | |
| 399 | dma_ignore_char: |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 400 | tty_flip_buffer_push(tty); |
| 401 | } |
| 402 | |
| 403 | void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart) |
| 404 | { |
Mike Frysinger | 59e4e3e | 2009-04-06 17:32:28 +0100 | [diff] [blame] | 405 | int x_pos, pos; |
| 406 | unsigned long flags; |
Sonic Zhang | 68a784c | 2009-01-02 13:40:38 +0000 | [diff] [blame] | 407 | |
| 408 | spin_lock_irqsave(&uart->port.lock, flags); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 409 | |
Sonic Zhang | 56f5de8 | 2008-02-25 15:19:09 +0800 | [diff] [blame] | 410 | uart->rx_dma_nrows = get_dma_curr_ycount(uart->rx_dma_channel); |
| 411 | x_pos = get_dma_curr_xcount(uart->rx_dma_channel); |
| 412 | uart->rx_dma_nrows = DMA_RX_YCOUNT - uart->rx_dma_nrows; |
| 413 | if (uart->rx_dma_nrows == DMA_RX_YCOUNT) |
| 414 | uart->rx_dma_nrows = 0; |
| 415 | x_pos = DMA_RX_XCOUNT - x_pos; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 416 | if (x_pos == DMA_RX_XCOUNT) |
| 417 | x_pos = 0; |
| 418 | |
| 419 | pos = uart->rx_dma_nrows * DMA_RX_XCOUNT + x_pos; |
Sonic Zhang | 56f5de8 | 2008-02-25 15:19:09 +0800 | [diff] [blame] | 420 | if (pos != uart->rx_dma_buf.tail) { |
| 421 | uart->rx_dma_buf.head = pos; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 422 | bfin_serial_dma_rx_chars(uart); |
Sonic Zhang | 56f5de8 | 2008-02-25 15:19:09 +0800 | [diff] [blame] | 423 | uart->rx_dma_buf.tail = uart->rx_dma_buf.head; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 424 | } |
Sonic Zhang | 0aef456 | 2008-02-29 12:08:42 +0800 | [diff] [blame] | 425 | |
Sonic Zhang | 68a784c | 2009-01-02 13:40:38 +0000 | [diff] [blame] | 426 | spin_unlock_irqrestore(&uart->port.lock, flags); |
| 427 | |
Sonic Zhang | 0a27842 | 2008-04-25 04:36:47 +0800 | [diff] [blame] | 428 | mod_timer(&(uart->rx_dma_timer), jiffies + DMA_RX_FLUSH_JIFFIES); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | static irqreturn_t bfin_serial_dma_tx_int(int irq, void *dev_id) |
| 432 | { |
| 433 | struct bfin_serial_port *uart = dev_id; |
| 434 | struct circ_buf *xmit = &uart->port.info->xmit; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 435 | |
| 436 | spin_lock(&uart->port.lock); |
| 437 | if (!(get_dma_curr_irqstat(uart->tx_dma_channel)&DMA_RUN)) { |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 438 | disable_dma(uart->tx_dma_channel); |
Sonic Zhang | 0711d85 | 2008-02-25 15:16:50 +0800 | [diff] [blame] | 439 | clear_dma_irqstat(uart->tx_dma_channel); |
Roy Huang | f4d640c9 | 2007-07-12 16:43:46 +0800 | [diff] [blame] | 440 | UART_CLEAR_IER(uart, ETBEI); |
Sonic Zhang | 0711d85 | 2008-02-25 15:16:50 +0800 | [diff] [blame] | 441 | xmit->tail = (xmit->tail + uart->tx_count) & (UART_XMIT_SIZE - 1); |
| 442 | uart->port.icount.tx += uart->tx_count; |
Sonic Zhang | 1b73351 | 2007-12-21 16:45:12 +0800 | [diff] [blame] | 443 | |
Sonic Zhang | 56f5de8 | 2008-02-25 15:19:09 +0800 | [diff] [blame] | 444 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) |
| 445 | uart_write_wakeup(&uart->port); |
| 446 | |
Sonic Zhang | 1b73351 | 2007-12-21 16:45:12 +0800 | [diff] [blame] | 447 | bfin_serial_dma_tx_chars(uart); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | spin_unlock(&uart->port.lock); |
| 451 | return IRQ_HANDLED; |
| 452 | } |
| 453 | |
| 454 | static irqreturn_t bfin_serial_dma_rx_int(int irq, void *dev_id) |
| 455 | { |
| 456 | struct bfin_serial_port *uart = dev_id; |
| 457 | unsigned short irqstat; |
Sonic Zhang | 0711d85 | 2008-02-25 15:16:50 +0800 | [diff] [blame] | 458 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 459 | spin_lock(&uart->port.lock); |
| 460 | irqstat = get_dma_curr_irqstat(uart->rx_dma_channel); |
| 461 | clear_dma_irqstat(uart->rx_dma_channel); |
Sonic Zhang | 68a784c | 2009-01-02 13:40:38 +0000 | [diff] [blame] | 462 | bfin_serial_dma_rx_chars(uart); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 463 | spin_unlock(&uart->port.lock); |
Sonic Zhang | 0aef456 | 2008-02-29 12:08:42 +0800 | [diff] [blame] | 464 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 465 | return IRQ_HANDLED; |
| 466 | } |
| 467 | #endif |
| 468 | |
| 469 | /* |
| 470 | * Return TIOCSER_TEMT when transmitter is not busy. |
| 471 | */ |
| 472 | static unsigned int bfin_serial_tx_empty(struct uart_port *port) |
| 473 | { |
| 474 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
| 475 | unsigned short lsr; |
| 476 | |
| 477 | lsr = UART_GET_LSR(uart); |
| 478 | if (lsr & TEMT) |
| 479 | return TIOCSER_TEMT; |
| 480 | else |
| 481 | return 0; |
| 482 | } |
| 483 | |
| 484 | static unsigned int bfin_serial_get_mctrl(struct uart_port *port) |
| 485 | { |
| 486 | #ifdef CONFIG_SERIAL_BFIN_CTSRTS |
| 487 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
| 488 | if (uart->cts_pin < 0) |
| 489 | return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR; |
| 490 | |
Sonic Zhang | 1feaa51 | 2008-06-03 12:19:45 +0800 | [diff] [blame] | 491 | if (UART_GET_CTS(uart)) |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 492 | return TIOCM_DSR | TIOCM_CAR; |
| 493 | else |
| 494 | #endif |
| 495 | return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR; |
| 496 | } |
| 497 | |
| 498 | static void bfin_serial_set_mctrl(struct uart_port *port, unsigned int mctrl) |
| 499 | { |
| 500 | #ifdef CONFIG_SERIAL_BFIN_CTSRTS |
| 501 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
| 502 | if (uart->rts_pin < 0) |
| 503 | return; |
| 504 | |
| 505 | if (mctrl & TIOCM_RTS) |
Sonic Zhang | 1feaa51 | 2008-06-03 12:19:45 +0800 | [diff] [blame] | 506 | UART_CLEAR_RTS(uart); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 507 | else |
Sonic Zhang | 1feaa51 | 2008-06-03 12:19:45 +0800 | [diff] [blame] | 508 | UART_SET_RTS(uart); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 509 | #endif |
| 510 | } |
| 511 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 512 | #ifdef CONFIG_SERIAL_BFIN_CTSRTS |
Sonic Zhang | 6f95570 | 2009-04-07 16:51:15 +0100 | [diff] [blame^] | 513 | /* |
| 514 | * Handle any change of modem status signal. |
| 515 | */ |
| 516 | static irqreturn_t bfin_serial_mctrl_cts_int(int irq, void *dev_id) |
| 517 | { |
| 518 | struct bfin_serial_port *uart = dev_id; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 519 | unsigned int status; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 520 | |
| 521 | status = bfin_serial_get_mctrl(&uart->port); |
Sonic Zhang | 4cb4f22 | 2008-02-02 14:29:25 +0800 | [diff] [blame] | 522 | uart_handle_cts_change(&uart->port, status & TIOCM_CTS); |
Sonic Zhang | 6f95570 | 2009-04-07 16:51:15 +0100 | [diff] [blame^] | 523 | |
| 524 | return IRQ_HANDLED; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 525 | } |
Sonic Zhang | 6f95570 | 2009-04-07 16:51:15 +0100 | [diff] [blame^] | 526 | #endif |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 527 | |
| 528 | /* |
| 529 | * Interrupts are always disabled. |
| 530 | */ |
| 531 | static void bfin_serial_break_ctl(struct uart_port *port, int break_state) |
| 532 | { |
Mike Frysinger | cf68676 | 2007-06-11 16:12:49 +0800 | [diff] [blame] | 533 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
| 534 | u16 lcr = UART_GET_LCR(uart); |
| 535 | if (break_state) |
| 536 | lcr |= SB; |
| 537 | else |
| 538 | lcr &= ~SB; |
| 539 | UART_PUT_LCR(uart, lcr); |
| 540 | SSYNC(); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | static int bfin_serial_startup(struct uart_port *port) |
| 544 | { |
| 545 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
| 546 | |
| 547 | #ifdef CONFIG_SERIAL_BFIN_DMA |
| 548 | dma_addr_t dma_handle; |
| 549 | |
| 550 | if (request_dma(uart->rx_dma_channel, "BFIN_UART_RX") < 0) { |
| 551 | printk(KERN_NOTICE "Unable to attach Blackfin UART RX DMA channel\n"); |
| 552 | return -EBUSY; |
| 553 | } |
| 554 | |
| 555 | if (request_dma(uart->tx_dma_channel, "BFIN_UART_TX") < 0) { |
| 556 | printk(KERN_NOTICE "Unable to attach Blackfin UART TX DMA channel\n"); |
| 557 | free_dma(uart->rx_dma_channel); |
| 558 | return -EBUSY; |
| 559 | } |
| 560 | |
| 561 | set_dma_callback(uart->rx_dma_channel, bfin_serial_dma_rx_int, uart); |
| 562 | set_dma_callback(uart->tx_dma_channel, bfin_serial_dma_tx_int, uart); |
| 563 | |
| 564 | uart->rx_dma_buf.buf = (unsigned char *)dma_alloc_coherent(NULL, PAGE_SIZE, &dma_handle, GFP_DMA); |
| 565 | uart->rx_dma_buf.head = 0; |
| 566 | uart->rx_dma_buf.tail = 0; |
| 567 | uart->rx_dma_nrows = 0; |
| 568 | |
| 569 | set_dma_config(uart->rx_dma_channel, |
| 570 | set_bfin_dma_config(DIR_WRITE, DMA_FLOW_AUTO, |
| 571 | INTR_ON_ROW, DIMENSION_2D, |
Michael Hennerich | 2047e40 | 2008-01-22 15:29:18 +0800 | [diff] [blame] | 572 | DATA_SIZE_8, |
| 573 | DMA_SYNC_RESTART)); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 574 | set_dma_x_count(uart->rx_dma_channel, DMA_RX_XCOUNT); |
| 575 | set_dma_x_modify(uart->rx_dma_channel, 1); |
| 576 | set_dma_y_count(uart->rx_dma_channel, DMA_RX_YCOUNT); |
| 577 | set_dma_y_modify(uart->rx_dma_channel, 1); |
| 578 | set_dma_start_addr(uart->rx_dma_channel, (unsigned long)uart->rx_dma_buf.buf); |
| 579 | enable_dma(uart->rx_dma_channel); |
| 580 | |
| 581 | uart->rx_dma_timer.data = (unsigned long)(uart); |
| 582 | uart->rx_dma_timer.function = (void *)bfin_serial_rx_dma_timeout; |
| 583 | uart->rx_dma_timer.expires = jiffies + DMA_RX_FLUSH_JIFFIES; |
| 584 | add_timer(&(uart->rx_dma_timer)); |
| 585 | #else |
Sonic Zhang | 6f95570 | 2009-04-07 16:51:15 +0100 | [diff] [blame^] | 586 | # if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \ |
Sonic Zhang | 52e15f0e | 2009-01-02 13:40:14 +0000 | [diff] [blame] | 587 | defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE) |
| 588 | if (kgdboc_port_line == uart->port.line && kgdboc_break_enabled) |
| 589 | kgdboc_break_enabled = 0; |
| 590 | else { |
| 591 | # endif |
Sonic Zhang | a359cca | 2007-10-10 16:47:58 +0800 | [diff] [blame] | 592 | if (request_irq(uart->port.irq, bfin_serial_rx_int, IRQF_DISABLED, |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 593 | "BFIN_UART_RX", uart)) { |
| 594 | printk(KERN_NOTICE "Unable to attach BlackFin UART RX interrupt\n"); |
| 595 | return -EBUSY; |
| 596 | } |
| 597 | |
| 598 | if (request_irq |
Aubrey Li | 5c4e472 | 2007-05-21 18:09:38 +0800 | [diff] [blame] | 599 | (uart->port.irq+1, bfin_serial_tx_int, IRQF_DISABLED, |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 600 | "BFIN_UART_TX", uart)) { |
| 601 | printk(KERN_NOTICE "Unable to attach BlackFin UART TX interrupt\n"); |
| 602 | free_irq(uart->port.irq, uart); |
| 603 | return -EBUSY; |
| 604 | } |
Sonic Zhang | ab2375f | 2008-10-13 10:33:51 +0100 | [diff] [blame] | 605 | |
| 606 | # ifdef CONFIG_BF54x |
| 607 | { |
| 608 | unsigned uart_dma_ch_rx, uart_dma_ch_tx; |
| 609 | |
| 610 | switch (uart->port.irq) { |
| 611 | case IRQ_UART3_RX: |
| 612 | uart_dma_ch_rx = CH_UART3_RX; |
| 613 | uart_dma_ch_tx = CH_UART3_TX; |
| 614 | break; |
| 615 | case IRQ_UART2_RX: |
| 616 | uart_dma_ch_rx = CH_UART2_RX; |
| 617 | uart_dma_ch_tx = CH_UART2_TX; |
| 618 | break; |
| 619 | default: |
| 620 | uart_dma_ch_rx = uart_dma_ch_tx = 0; |
| 621 | break; |
| 622 | }; |
| 623 | |
| 624 | if (uart_dma_ch_rx && |
| 625 | request_dma(uart_dma_ch_rx, "BFIN_UART_RX") < 0) { |
| 626 | printk(KERN_NOTICE"Fail to attach UART interrupt\n"); |
| 627 | free_irq(uart->port.irq, uart); |
| 628 | free_irq(uart->port.irq + 1, uart); |
| 629 | return -EBUSY; |
| 630 | } |
| 631 | if (uart_dma_ch_tx && |
| 632 | request_dma(uart_dma_ch_tx, "BFIN_UART_TX") < 0) { |
| 633 | printk(KERN_NOTICE "Fail to attach UART interrupt\n"); |
| 634 | free_dma(uart_dma_ch_rx); |
| 635 | free_irq(uart->port.irq, uart); |
| 636 | free_irq(uart->port.irq + 1, uart); |
| 637 | return -EBUSY; |
| 638 | } |
| 639 | } |
| 640 | # endif |
Sonic Zhang | 6f95570 | 2009-04-07 16:51:15 +0100 | [diff] [blame^] | 641 | # if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \ |
Sonic Zhang | 52e15f0e | 2009-01-02 13:40:14 +0000 | [diff] [blame] | 642 | defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE) |
| 643 | } |
| 644 | # endif |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 645 | #endif |
Sonic Zhang | 6f95570 | 2009-04-07 16:51:15 +0100 | [diff] [blame^] | 646 | |
| 647 | #ifdef CONFIG_SERIAL_BFIN_CTSRTS |
| 648 | if (uart->cts_pin >= 0) { |
| 649 | if (request_irq(gpio_to_irq(uart->cts_pin), |
| 650 | bfin_serial_mctrl_cts_int, |
| 651 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | |
| 652 | IRQF_DISABLED, "BFIN_UART_CTS", uart)) { |
| 653 | uart->cts_pin = -1; |
| 654 | pr_info("Unable to attach BlackFin UART CTS interrupt.\ |
| 655 | So, disable it.\n"); |
| 656 | } |
| 657 | } |
| 658 | if (uart->rts_pin >= 0) { |
| 659 | gpio_request(uart->rts_pin, DRIVER_NAME); |
| 660 | gpio_direction_output(uart->rts_pin, 0); |
| 661 | } |
| 662 | #endif |
Roy Huang | f4d640c9 | 2007-07-12 16:43:46 +0800 | [diff] [blame] | 663 | UART_SET_IER(uart, ERBFI); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 664 | return 0; |
| 665 | } |
| 666 | |
| 667 | static void bfin_serial_shutdown(struct uart_port *port) |
| 668 | { |
| 669 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
| 670 | |
| 671 | #ifdef CONFIG_SERIAL_BFIN_DMA |
| 672 | disable_dma(uart->tx_dma_channel); |
| 673 | free_dma(uart->tx_dma_channel); |
| 674 | disable_dma(uart->rx_dma_channel); |
| 675 | free_dma(uart->rx_dma_channel); |
| 676 | del_timer(&(uart->rx_dma_timer)); |
Sonic Zhang | 75b780b | 2007-12-21 17:03:39 +0800 | [diff] [blame] | 677 | dma_free_coherent(NULL, PAGE_SIZE, uart->rx_dma_buf.buf, 0); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 678 | #else |
Sonic Zhang | ab2375f | 2008-10-13 10:33:51 +0100 | [diff] [blame] | 679 | #ifdef CONFIG_BF54x |
| 680 | switch (uart->port.irq) { |
| 681 | case IRQ_UART3_RX: |
| 682 | free_dma(CH_UART3_RX); |
| 683 | free_dma(CH_UART3_TX); |
| 684 | break; |
| 685 | case IRQ_UART2_RX: |
| 686 | free_dma(CH_UART2_RX); |
| 687 | free_dma(CH_UART2_TX); |
| 688 | break; |
| 689 | default: |
| 690 | break; |
| 691 | }; |
| 692 | #endif |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 693 | free_irq(uart->port.irq, uart); |
| 694 | free_irq(uart->port.irq+1, uart); |
| 695 | #endif |
Sonic Zhang | 6f95570 | 2009-04-07 16:51:15 +0100 | [diff] [blame^] | 696 | |
| 697 | # ifdef CONFIG_SERIAL_BFIN_CTSRTS |
| 698 | if (uart->cts_pin >= 0) |
| 699 | free_irq(gpio_to_irq(uart->cts_pin), uart); |
| 700 | if (uart->rts_pin >= 0) |
| 701 | gpio_free(uart->rts_pin); |
| 702 | # endif |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | static void |
| 706 | bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios, |
| 707 | struct ktermios *old) |
| 708 | { |
| 709 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
| 710 | unsigned long flags; |
| 711 | unsigned int baud, quot; |
Mike Frysinger | 0c44a86 | 2008-04-24 04:56:02 +0800 | [diff] [blame] | 712 | unsigned short val, ier, lcr = 0; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 713 | |
| 714 | switch (termios->c_cflag & CSIZE) { |
| 715 | case CS8: |
| 716 | lcr = WLS(8); |
| 717 | break; |
| 718 | case CS7: |
| 719 | lcr = WLS(7); |
| 720 | break; |
| 721 | case CS6: |
| 722 | lcr = WLS(6); |
| 723 | break; |
| 724 | case CS5: |
| 725 | lcr = WLS(5); |
| 726 | break; |
| 727 | default: |
| 728 | printk(KERN_ERR "%s: word lengh not supported\n", |
Harvey Harrison | 71cc2c2 | 2008-04-30 00:55:10 -0700 | [diff] [blame] | 729 | __func__); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 730 | } |
| 731 | |
| 732 | if (termios->c_cflag & CSTOPB) |
| 733 | lcr |= STB; |
Mike Frysinger | 19aa638 | 2007-06-11 16:16:45 +0800 | [diff] [blame] | 734 | if (termios->c_cflag & PARENB) |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 735 | lcr |= PEN; |
Mike Frysinger | 19aa638 | 2007-06-11 16:16:45 +0800 | [diff] [blame] | 736 | if (!(termios->c_cflag & PARODD)) |
| 737 | lcr |= EPS; |
| 738 | if (termios->c_cflag & CMSPAR) |
| 739 | lcr |= STP; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 740 | |
Mike Frysinger | 2ac5ee4 | 2007-05-21 18:09:39 +0800 | [diff] [blame] | 741 | port->read_status_mask = OE; |
| 742 | if (termios->c_iflag & INPCK) |
| 743 | port->read_status_mask |= (FE | PE); |
| 744 | if (termios->c_iflag & (BRKINT | PARMRK)) |
| 745 | port->read_status_mask |= BI; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 746 | |
Mike Frysinger | 2ac5ee4 | 2007-05-21 18:09:39 +0800 | [diff] [blame] | 747 | /* |
| 748 | * Characters to ignore |
| 749 | */ |
| 750 | port->ignore_status_mask = 0; |
| 751 | if (termios->c_iflag & IGNPAR) |
| 752 | port->ignore_status_mask |= FE | PE; |
| 753 | if (termios->c_iflag & IGNBRK) { |
| 754 | port->ignore_status_mask |= BI; |
| 755 | /* |
| 756 | * If we're ignoring parity and break indicators, |
| 757 | * ignore overruns too (for real raw support). |
| 758 | */ |
| 759 | if (termios->c_iflag & IGNPAR) |
| 760 | port->ignore_status_mask |= OE; |
| 761 | } |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 762 | |
| 763 | baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); |
Graf Yang | f448710 | 2009-04-06 17:32:49 +0100 | [diff] [blame] | 764 | quot = uart_get_divisor(port, baud) - ANOMALY_05000230; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 765 | spin_lock_irqsave(&uart->port.lock, flags); |
| 766 | |
Mike Frysinger | 8851c71 | 2007-12-24 19:48:04 +0800 | [diff] [blame] | 767 | UART_SET_ANOMALY_THRESHOLD(uart, USEC_PER_SEC / baud * 15); |
| 768 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 769 | /* Disable UART */ |
| 770 | ier = UART_GET_IER(uart); |
Sonic Zhang | 1feaa51 | 2008-06-03 12:19:45 +0800 | [diff] [blame] | 771 | UART_DISABLE_INTS(uart); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 772 | |
| 773 | /* Set DLAB in LCR to Access DLL and DLH */ |
Mike Frysinger | 45828b8 | 2008-05-07 11:41:26 +0800 | [diff] [blame] | 774 | UART_SET_DLAB(uart); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 775 | |
| 776 | UART_PUT_DLL(uart, quot & 0xFF); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 777 | UART_PUT_DLH(uart, (quot >> 8) & 0xFF); |
| 778 | SSYNC(); |
| 779 | |
| 780 | /* Clear DLAB in LCR to Access THR RBR IER */ |
Mike Frysinger | 45828b8 | 2008-05-07 11:41:26 +0800 | [diff] [blame] | 781 | UART_CLEAR_DLAB(uart); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 782 | |
| 783 | UART_PUT_LCR(uart, lcr); |
| 784 | |
| 785 | /* Enable UART */ |
Sonic Zhang | 1feaa51 | 2008-06-03 12:19:45 +0800 | [diff] [blame] | 786 | UART_ENABLE_INTS(uart, ier); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 787 | |
| 788 | val = UART_GET_GCTL(uart); |
| 789 | val |= UCEN; |
| 790 | UART_PUT_GCTL(uart, val); |
| 791 | |
Graf Yang | b3ef5ab | 2008-10-13 10:33:42 +0100 | [diff] [blame] | 792 | /* Port speed changed, update the per-port timeout. */ |
| 793 | uart_update_timeout(port, termios->c_cflag, baud); |
| 794 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 795 | spin_unlock_irqrestore(&uart->port.lock, flags); |
| 796 | } |
| 797 | |
| 798 | static const char *bfin_serial_type(struct uart_port *port) |
| 799 | { |
| 800 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
| 801 | |
| 802 | return uart->port.type == PORT_BFIN ? "BFIN-UART" : NULL; |
| 803 | } |
| 804 | |
| 805 | /* |
| 806 | * Release the memory region(s) being used by 'port'. |
| 807 | */ |
| 808 | static void bfin_serial_release_port(struct uart_port *port) |
| 809 | { |
| 810 | } |
| 811 | |
| 812 | /* |
| 813 | * Request the memory region(s) being used by 'port'. |
| 814 | */ |
| 815 | static int bfin_serial_request_port(struct uart_port *port) |
| 816 | { |
| 817 | return 0; |
| 818 | } |
| 819 | |
| 820 | /* |
| 821 | * Configure/autoconfigure the port. |
| 822 | */ |
| 823 | static void bfin_serial_config_port(struct uart_port *port, int flags) |
| 824 | { |
| 825 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
| 826 | |
| 827 | if (flags & UART_CONFIG_TYPE && |
| 828 | bfin_serial_request_port(&uart->port) == 0) |
| 829 | uart->port.type = PORT_BFIN; |
| 830 | } |
| 831 | |
| 832 | /* |
| 833 | * Verify the new serial_struct (for TIOCSSERIAL). |
| 834 | * The only change we allow are to the flags and type, and |
| 835 | * even then only between PORT_BFIN and PORT_UNKNOWN |
| 836 | */ |
| 837 | static int |
| 838 | bfin_serial_verify_port(struct uart_port *port, struct serial_struct *ser) |
| 839 | { |
| 840 | return 0; |
| 841 | } |
| 842 | |
Graf Yang | 7d01b47 | 2008-02-29 11:31:08 +0800 | [diff] [blame] | 843 | /* |
| 844 | * Enable the IrDA function if tty->ldisc.num is N_IRDA. |
| 845 | * In other cases, disable IrDA function. |
| 846 | */ |
Graf Yang | 3b8458a | 2008-06-07 15:36:33 +0800 | [diff] [blame] | 847 | static void bfin_serial_set_ldisc(struct uart_port *port) |
Graf Yang | 7d01b47 | 2008-02-29 11:31:08 +0800 | [diff] [blame] | 848 | { |
Graf Yang | 3b8458a | 2008-06-07 15:36:33 +0800 | [diff] [blame] | 849 | int line = port->line; |
Graf Yang | 7d01b47 | 2008-02-29 11:31:08 +0800 | [diff] [blame] | 850 | unsigned short val; |
| 851 | |
Takashi Iwai | a88487c | 2008-07-16 21:54:42 +0100 | [diff] [blame] | 852 | if (line >= port->info->port.tty->driver->num) |
Graf Yang | 7d01b47 | 2008-02-29 11:31:08 +0800 | [diff] [blame] | 853 | return; |
| 854 | |
Alan Cox | b1cbefe | 2008-08-04 17:22:11 +0100 | [diff] [blame] | 855 | switch (port->info->port.tty->termios->c_line) { |
Graf Yang | 7d01b47 | 2008-02-29 11:31:08 +0800 | [diff] [blame] | 856 | case N_IRDA: |
| 857 | val = UART_GET_GCTL(&bfin_serial_ports[line]); |
| 858 | val |= (IREN | RPOLC); |
| 859 | UART_PUT_GCTL(&bfin_serial_ports[line], val); |
| 860 | break; |
| 861 | default: |
| 862 | val = UART_GET_GCTL(&bfin_serial_ports[line]); |
| 863 | val &= ~(IREN | RPOLC); |
| 864 | UART_PUT_GCTL(&bfin_serial_ports[line], val); |
| 865 | } |
| 866 | } |
| 867 | |
Sonic Zhang | 6f95570 | 2009-04-07 16:51:15 +0100 | [diff] [blame^] | 868 | static void bfin_serial_reset_irda(struct uart_port *port) |
| 869 | { |
| 870 | int line = port->line; |
| 871 | unsigned short val; |
| 872 | |
| 873 | val = UART_GET_GCTL(&bfin_serial_ports[line]); |
| 874 | val &= ~(IREN | RPOLC); |
| 875 | UART_PUT_GCTL(&bfin_serial_ports[line], val); |
| 876 | SSYNC(); |
| 877 | val |= (IREN | RPOLC); |
| 878 | UART_PUT_GCTL(&bfin_serial_ports[line], val); |
| 879 | SSYNC(); |
| 880 | } |
| 881 | |
Sonic Zhang | 52e15f0e | 2009-01-02 13:40:14 +0000 | [diff] [blame] | 882 | #ifdef CONFIG_CONSOLE_POLL |
| 883 | static void bfin_serial_poll_put_char(struct uart_port *port, unsigned char chr) |
| 884 | { |
| 885 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
| 886 | |
| 887 | while (!(UART_GET_LSR(uart) & THRE)) |
| 888 | cpu_relax(); |
| 889 | |
| 890 | UART_CLEAR_DLAB(uart); |
| 891 | UART_PUT_CHAR(uart, (unsigned char)chr); |
| 892 | } |
| 893 | |
| 894 | static int bfin_serial_poll_get_char(struct uart_port *port) |
| 895 | { |
| 896 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
| 897 | unsigned char chr; |
| 898 | |
| 899 | while (!(UART_GET_LSR(uart) & DR)) |
| 900 | cpu_relax(); |
| 901 | |
| 902 | UART_CLEAR_DLAB(uart); |
| 903 | chr = UART_GET_CHAR(uart); |
| 904 | |
| 905 | return chr; |
| 906 | } |
| 907 | #endif |
| 908 | |
| 909 | #if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \ |
| 910 | defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE) |
| 911 | static void bfin_kgdboc_port_shutdown(struct uart_port *port) |
| 912 | { |
| 913 | if (kgdboc_break_enabled) { |
| 914 | kgdboc_break_enabled = 0; |
| 915 | bfin_serial_shutdown(port); |
| 916 | } |
| 917 | } |
| 918 | |
| 919 | static int bfin_kgdboc_port_startup(struct uart_port *port) |
| 920 | { |
| 921 | kgdboc_port_line = port->line; |
| 922 | kgdboc_break_enabled = !bfin_serial_startup(port); |
| 923 | return 0; |
| 924 | } |
| 925 | #endif |
| 926 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 927 | static struct uart_ops bfin_serial_pops = { |
| 928 | .tx_empty = bfin_serial_tx_empty, |
| 929 | .set_mctrl = bfin_serial_set_mctrl, |
| 930 | .get_mctrl = bfin_serial_get_mctrl, |
| 931 | .stop_tx = bfin_serial_stop_tx, |
| 932 | .start_tx = bfin_serial_start_tx, |
| 933 | .stop_rx = bfin_serial_stop_rx, |
| 934 | .enable_ms = bfin_serial_enable_ms, |
| 935 | .break_ctl = bfin_serial_break_ctl, |
| 936 | .startup = bfin_serial_startup, |
| 937 | .shutdown = bfin_serial_shutdown, |
| 938 | .set_termios = bfin_serial_set_termios, |
Graf Yang | 3b8458a | 2008-06-07 15:36:33 +0800 | [diff] [blame] | 939 | .set_ldisc = bfin_serial_set_ldisc, |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 940 | .type = bfin_serial_type, |
| 941 | .release_port = bfin_serial_release_port, |
| 942 | .request_port = bfin_serial_request_port, |
| 943 | .config_port = bfin_serial_config_port, |
| 944 | .verify_port = bfin_serial_verify_port, |
Sonic Zhang | 52e15f0e | 2009-01-02 13:40:14 +0000 | [diff] [blame] | 945 | #if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \ |
| 946 | defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE) |
| 947 | .kgdboc_port_startup = bfin_kgdboc_port_startup, |
| 948 | .kgdboc_port_shutdown = bfin_kgdboc_port_shutdown, |
| 949 | #endif |
| 950 | #ifdef CONFIG_CONSOLE_POLL |
| 951 | .poll_put_char = bfin_serial_poll_put_char, |
| 952 | .poll_get_char = bfin_serial_poll_get_char, |
| 953 | #endif |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 954 | }; |
| 955 | |
Sonic Zhang | 6f95570 | 2009-04-07 16:51:15 +0100 | [diff] [blame^] | 956 | static void __init bfin_serial_hw_init(void) |
| 957 | { |
| 958 | #ifdef CONFIG_SERIAL_BFIN_UART0 |
| 959 | peripheral_request(P_UART0_TX, DRIVER_NAME); |
| 960 | peripheral_request(P_UART0_RX, DRIVER_NAME); |
| 961 | #endif |
| 962 | |
| 963 | #ifdef CONFIG_SERIAL_BFIN_UART1 |
| 964 | peripheral_request(P_UART1_TX, DRIVER_NAME); |
| 965 | peripheral_request(P_UART1_RX, DRIVER_NAME); |
| 966 | |
| 967 | # if defined(CONFIG_BFIN_UART1_CTSRTS) && defined(CONFIG_BF54x) |
| 968 | peripheral_request(P_UART1_RTS, DRIVER_NAME); |
| 969 | peripheral_request(P_UART1_CTS, DRIVER_NAME); |
| 970 | # endif |
| 971 | #endif |
| 972 | |
| 973 | #ifdef CONFIG_SERIAL_BFIN_UART2 |
| 974 | peripheral_request(P_UART2_TX, DRIVER_NAME); |
| 975 | peripheral_request(P_UART2_RX, DRIVER_NAME); |
| 976 | #endif |
| 977 | |
| 978 | #ifdef CONFIG_SERIAL_BFIN_UART3 |
| 979 | peripheral_request(P_UART3_TX, DRIVER_NAME); |
| 980 | peripheral_request(P_UART3_RX, DRIVER_NAME); |
| 981 | |
| 982 | # if defined(CONFIG_BFIN_UART3_CTSRTS) && defined(CONFIG_BF54x) |
| 983 | peripheral_request(P_UART3_RTS, DRIVER_NAME); |
| 984 | peripheral_request(P_UART3_CTS, DRIVER_NAME); |
| 985 | # endif |
| 986 | #endif |
| 987 | } |
| 988 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 989 | static void __init bfin_serial_init_ports(void) |
| 990 | { |
| 991 | static int first = 1; |
| 992 | int i; |
| 993 | |
| 994 | if (!first) |
| 995 | return; |
| 996 | first = 0; |
| 997 | |
Sonic Zhang | 6f95570 | 2009-04-07 16:51:15 +0100 | [diff] [blame^] | 998 | bfin_serial_hw_init(); |
| 999 | |
Mike Frysinger | c9607ec | 2008-10-13 10:33:16 +0100 | [diff] [blame] | 1000 | for (i = 0; i < nr_active_ports; i++) { |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1001 | bfin_serial_ports[i].port.uartclk = get_sclk(); |
Graf Yang | b3ef5ab | 2008-10-13 10:33:42 +0100 | [diff] [blame] | 1002 | bfin_serial_ports[i].port.fifosize = BFIN_UART_TX_FIFO_SIZE; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1003 | bfin_serial_ports[i].port.ops = &bfin_serial_pops; |
| 1004 | bfin_serial_ports[i].port.line = i; |
| 1005 | bfin_serial_ports[i].port.iotype = UPIO_MEM; |
| 1006 | bfin_serial_ports[i].port.membase = |
| 1007 | (void __iomem *)bfin_serial_resource[i].uart_base_addr; |
| 1008 | bfin_serial_ports[i].port.mapbase = |
| 1009 | bfin_serial_resource[i].uart_base_addr; |
| 1010 | bfin_serial_ports[i].port.irq = |
| 1011 | bfin_serial_resource[i].uart_irq; |
| 1012 | bfin_serial_ports[i].port.flags = UPF_BOOT_AUTOCONF; |
| 1013 | #ifdef CONFIG_SERIAL_BFIN_DMA |
| 1014 | bfin_serial_ports[i].tx_done = 1; |
| 1015 | bfin_serial_ports[i].tx_count = 0; |
| 1016 | bfin_serial_ports[i].tx_dma_channel = |
| 1017 | bfin_serial_resource[i].uart_tx_dma_channel; |
| 1018 | bfin_serial_ports[i].rx_dma_channel = |
| 1019 | bfin_serial_resource[i].uart_rx_dma_channel; |
| 1020 | init_timer(&(bfin_serial_ports[i].rx_dma_timer)); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1021 | #endif |
| 1022 | #ifdef CONFIG_SERIAL_BFIN_CTSRTS |
| 1023 | bfin_serial_ports[i].cts_pin = |
| 1024 | bfin_serial_resource[i].uart_cts_pin; |
| 1025 | bfin_serial_ports[i].rts_pin = |
| 1026 | bfin_serial_resource[i].uart_rts_pin; |
| 1027 | #endif |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1028 | } |
| 1029 | } |
| 1030 | |
Sonic Zhang | b6efa1e | 2009-01-02 13:40:31 +0000 | [diff] [blame] | 1031 | #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK) |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1032 | /* |
| 1033 | * If the port was already initialised (eg, by a boot loader), |
| 1034 | * try to determine the current setup. |
| 1035 | */ |
| 1036 | static void __init |
| 1037 | bfin_serial_console_get_options(struct bfin_serial_port *uart, int *baud, |
| 1038 | int *parity, int *bits) |
| 1039 | { |
| 1040 | unsigned short status; |
| 1041 | |
| 1042 | status = UART_GET_IER(uart) & (ERBFI | ETBEI); |
| 1043 | if (status == (ERBFI | ETBEI)) { |
| 1044 | /* ok, the port was enabled */ |
Mike Frysinger | 45828b8 | 2008-05-07 11:41:26 +0800 | [diff] [blame] | 1045 | u16 lcr, dlh, dll; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1046 | |
| 1047 | lcr = UART_GET_LCR(uart); |
| 1048 | |
| 1049 | *parity = 'n'; |
| 1050 | if (lcr & PEN) { |
| 1051 | if (lcr & EPS) |
| 1052 | *parity = 'e'; |
| 1053 | else |
| 1054 | *parity = 'o'; |
| 1055 | } |
| 1056 | switch (lcr & 0x03) { |
| 1057 | case 0: *bits = 5; break; |
| 1058 | case 1: *bits = 6; break; |
| 1059 | case 2: *bits = 7; break; |
| 1060 | case 3: *bits = 8; break; |
| 1061 | } |
| 1062 | /* Set DLAB in LCR to Access DLL and DLH */ |
Mike Frysinger | 45828b8 | 2008-05-07 11:41:26 +0800 | [diff] [blame] | 1063 | UART_SET_DLAB(uart); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1064 | |
| 1065 | dll = UART_GET_DLL(uart); |
| 1066 | dlh = UART_GET_DLH(uart); |
| 1067 | |
| 1068 | /* Clear DLAB in LCR to Access THR RBR IER */ |
Mike Frysinger | 45828b8 | 2008-05-07 11:41:26 +0800 | [diff] [blame] | 1069 | UART_CLEAR_DLAB(uart); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1070 | |
| 1071 | *baud = get_sclk() / (16*(dll | dlh << 8)); |
| 1072 | } |
Harvey Harrison | 71cc2c2 | 2008-04-30 00:55:10 -0700 | [diff] [blame] | 1073 | pr_debug("%s:baud = %d, parity = %c, bits= %d\n", __func__, *baud, *parity, *bits); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1074 | } |
Robin Getz | 0ae5364 | 2007-10-09 17:24:49 +0800 | [diff] [blame] | 1075 | |
Robin Getz | 0ae5364 | 2007-10-09 17:24:49 +0800 | [diff] [blame] | 1076 | static struct uart_driver bfin_serial_reg; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1077 | |
| 1078 | static int __init |
| 1079 | bfin_serial_console_setup(struct console *co, char *options) |
| 1080 | { |
| 1081 | struct bfin_serial_port *uart; |
| 1082 | int baud = 57600; |
| 1083 | int bits = 8; |
| 1084 | int parity = 'n'; |
Sonic Zhang | b6efa1e | 2009-01-02 13:40:31 +0000 | [diff] [blame] | 1085 | # ifdef CONFIG_SERIAL_BFIN_CTSRTS |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1086 | int flow = 'r'; |
Sonic Zhang | b6efa1e | 2009-01-02 13:40:31 +0000 | [diff] [blame] | 1087 | # else |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1088 | int flow = 'n'; |
Robin Getz | 0ae5364 | 2007-10-09 17:24:49 +0800 | [diff] [blame] | 1089 | # endif |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1090 | |
| 1091 | /* |
| 1092 | * Check whether an invalid uart number has been specified, and |
| 1093 | * if so, search for the first available port that does have |
| 1094 | * console support. |
| 1095 | */ |
Mike Frysinger | c9607ec | 2008-10-13 10:33:16 +0100 | [diff] [blame] | 1096 | if (co->index == -1 || co->index >= nr_active_ports) |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1097 | co->index = 0; |
| 1098 | uart = &bfin_serial_ports[co->index]; |
| 1099 | |
| 1100 | if (options) |
| 1101 | uart_parse_options(options, &baud, &parity, &bits, &flow); |
| 1102 | else |
| 1103 | bfin_serial_console_get_options(uart, &baud, &parity, &bits); |
| 1104 | |
| 1105 | return uart_set_options(&uart->port, co, baud, parity, bits, flow); |
Robin Getz | 0ae5364 | 2007-10-09 17:24:49 +0800 | [diff] [blame] | 1106 | } |
| 1107 | #endif /* defined (CONFIG_SERIAL_BFIN_CONSOLE) || |
| 1108 | defined (CONFIG_EARLY_PRINTK) */ |
| 1109 | |
| 1110 | #ifdef CONFIG_SERIAL_BFIN_CONSOLE |
| 1111 | static void bfin_serial_console_putchar(struct uart_port *port, int ch) |
| 1112 | { |
| 1113 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
| 1114 | while (!(UART_GET_LSR(uart) & THRE)) |
| 1115 | barrier(); |
| 1116 | UART_PUT_CHAR(uart, ch); |
| 1117 | SSYNC(); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1118 | } |
| 1119 | |
Robin Getz | 0ae5364 | 2007-10-09 17:24:49 +0800 | [diff] [blame] | 1120 | /* |
| 1121 | * Interrupts are disabled on entering |
| 1122 | */ |
| 1123 | static void |
| 1124 | bfin_serial_console_write(struct console *co, const char *s, unsigned int count) |
| 1125 | { |
| 1126 | struct bfin_serial_port *uart = &bfin_serial_ports[co->index]; |
Mike Frysinger | 59e4e3e | 2009-04-06 17:32:28 +0100 | [diff] [blame] | 1127 | unsigned long flags; |
Robin Getz | 0ae5364 | 2007-10-09 17:24:49 +0800 | [diff] [blame] | 1128 | |
| 1129 | spin_lock_irqsave(&uart->port.lock, flags); |
| 1130 | uart_console_write(&uart->port, s, count, bfin_serial_console_putchar); |
| 1131 | spin_unlock_irqrestore(&uart->port.lock, flags); |
| 1132 | |
| 1133 | } |
| 1134 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1135 | static struct console bfin_serial_console = { |
| 1136 | .name = BFIN_SERIAL_NAME, |
| 1137 | .write = bfin_serial_console_write, |
| 1138 | .device = uart_console_device, |
| 1139 | .setup = bfin_serial_console_setup, |
| 1140 | .flags = CON_PRINTBUFFER, |
| 1141 | .index = -1, |
| 1142 | .data = &bfin_serial_reg, |
| 1143 | }; |
| 1144 | |
| 1145 | static int __init bfin_serial_rs_console_init(void) |
| 1146 | { |
| 1147 | bfin_serial_init_ports(); |
| 1148 | register_console(&bfin_serial_console); |
Sonic Zhang | 52e15f0e | 2009-01-02 13:40:14 +0000 | [diff] [blame] | 1149 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1150 | return 0; |
| 1151 | } |
| 1152 | console_initcall(bfin_serial_rs_console_init); |
| 1153 | |
| 1154 | #define BFIN_SERIAL_CONSOLE &bfin_serial_console |
| 1155 | #else |
| 1156 | #define BFIN_SERIAL_CONSOLE NULL |
Robin Getz | 0ae5364 | 2007-10-09 17:24:49 +0800 | [diff] [blame] | 1157 | #endif /* CONFIG_SERIAL_BFIN_CONSOLE */ |
| 1158 | |
| 1159 | |
| 1160 | #ifdef CONFIG_EARLY_PRINTK |
| 1161 | static __init void early_serial_putc(struct uart_port *port, int ch) |
| 1162 | { |
| 1163 | unsigned timeout = 0xffff; |
| 1164 | struct bfin_serial_port *uart = (struct bfin_serial_port *)port; |
| 1165 | |
| 1166 | while ((!(UART_GET_LSR(uart) & THRE)) && --timeout) |
| 1167 | cpu_relax(); |
| 1168 | UART_PUT_CHAR(uart, ch); |
| 1169 | } |
| 1170 | |
| 1171 | static __init void early_serial_write(struct console *con, const char *s, |
| 1172 | unsigned int n) |
| 1173 | { |
| 1174 | struct bfin_serial_port *uart = &bfin_serial_ports[con->index]; |
| 1175 | unsigned int i; |
| 1176 | |
| 1177 | for (i = 0; i < n; i++, s++) { |
| 1178 | if (*s == '\n') |
| 1179 | early_serial_putc(&uart->port, '\r'); |
| 1180 | early_serial_putc(&uart->port, *s); |
| 1181 | } |
| 1182 | } |
| 1183 | |
Mike Frysinger | c111340 | 2008-10-13 10:32:35 +0100 | [diff] [blame] | 1184 | static struct __initdata console bfin_early_serial_console = { |
Robin Getz | 0ae5364 | 2007-10-09 17:24:49 +0800 | [diff] [blame] | 1185 | .name = "early_BFuart", |
| 1186 | .write = early_serial_write, |
| 1187 | .device = uart_console_device, |
| 1188 | .flags = CON_PRINTBUFFER, |
| 1189 | .setup = bfin_serial_console_setup, |
| 1190 | .index = -1, |
| 1191 | .data = &bfin_serial_reg, |
| 1192 | }; |
| 1193 | |
| 1194 | struct console __init *bfin_earlyserial_init(unsigned int port, |
| 1195 | unsigned int cflag) |
| 1196 | { |
| 1197 | struct bfin_serial_port *uart; |
| 1198 | struct ktermios t; |
| 1199 | |
Mike Frysinger | c9607ec | 2008-10-13 10:33:16 +0100 | [diff] [blame] | 1200 | if (port == -1 || port >= nr_active_ports) |
Robin Getz | 0ae5364 | 2007-10-09 17:24:49 +0800 | [diff] [blame] | 1201 | port = 0; |
| 1202 | bfin_serial_init_ports(); |
| 1203 | bfin_early_serial_console.index = port; |
Robin Getz | 0ae5364 | 2007-10-09 17:24:49 +0800 | [diff] [blame] | 1204 | uart = &bfin_serial_ports[port]; |
| 1205 | t.c_cflag = cflag; |
| 1206 | t.c_iflag = 0; |
| 1207 | t.c_oflag = 0; |
| 1208 | t.c_lflag = ICANON; |
| 1209 | t.c_line = port; |
| 1210 | bfin_serial_set_termios(&uart->port, &t, &t); |
| 1211 | return &bfin_early_serial_console; |
| 1212 | } |
| 1213 | |
Sonic Zhang | b6efa1e | 2009-01-02 13:40:31 +0000 | [diff] [blame] | 1214 | #endif /* CONFIG_EARLY_PRINTK */ |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1215 | |
| 1216 | static struct uart_driver bfin_serial_reg = { |
| 1217 | .owner = THIS_MODULE, |
| 1218 | .driver_name = "bfin-uart", |
| 1219 | .dev_name = BFIN_SERIAL_NAME, |
| 1220 | .major = BFIN_SERIAL_MAJOR, |
| 1221 | .minor = BFIN_SERIAL_MINOR, |
Graf Yang | 2ade972 | 2008-04-25 02:55:49 +0800 | [diff] [blame] | 1222 | .nr = BFIN_UART_NR_PORTS, |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1223 | .cons = BFIN_SERIAL_CONSOLE, |
| 1224 | }; |
| 1225 | |
| 1226 | static int bfin_serial_suspend(struct platform_device *dev, pm_message_t state) |
| 1227 | { |
Sonic Zhang | ccfbc3e | 2008-10-13 10:32:44 +0100 | [diff] [blame] | 1228 | int i; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1229 | |
Mike Frysinger | c9607ec | 2008-10-13 10:33:16 +0100 | [diff] [blame] | 1230 | for (i = 0; i < nr_active_ports; i++) { |
Sonic Zhang | ccfbc3e | 2008-10-13 10:32:44 +0100 | [diff] [blame] | 1231 | if (bfin_serial_ports[i].port.dev != &dev->dev) |
| 1232 | continue; |
| 1233 | uart_suspend_port(&bfin_serial_reg, &bfin_serial_ports[i].port); |
| 1234 | } |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1235 | |
| 1236 | return 0; |
| 1237 | } |
| 1238 | |
| 1239 | static int bfin_serial_resume(struct platform_device *dev) |
| 1240 | { |
Sonic Zhang | ccfbc3e | 2008-10-13 10:32:44 +0100 | [diff] [blame] | 1241 | int i; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1242 | |
Mike Frysinger | c9607ec | 2008-10-13 10:33:16 +0100 | [diff] [blame] | 1243 | for (i = 0; i < nr_active_ports; i++) { |
Sonic Zhang | ccfbc3e | 2008-10-13 10:32:44 +0100 | [diff] [blame] | 1244 | if (bfin_serial_ports[i].port.dev != &dev->dev) |
| 1245 | continue; |
| 1246 | uart_resume_port(&bfin_serial_reg, &bfin_serial_ports[i].port); |
| 1247 | } |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1248 | |
| 1249 | return 0; |
| 1250 | } |
| 1251 | |
| 1252 | static int bfin_serial_probe(struct platform_device *dev) |
| 1253 | { |
| 1254 | struct resource *res = dev->resource; |
| 1255 | int i; |
| 1256 | |
| 1257 | for (i = 0; i < dev->num_resources; i++, res++) |
| 1258 | if (res->flags & IORESOURCE_MEM) |
| 1259 | break; |
| 1260 | |
| 1261 | if (i < dev->num_resources) { |
Mike Frysinger | c9607ec | 2008-10-13 10:33:16 +0100 | [diff] [blame] | 1262 | for (i = 0; i < nr_active_ports; i++, res++) { |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1263 | if (bfin_serial_ports[i].port.mapbase != res->start) |
| 1264 | continue; |
| 1265 | bfin_serial_ports[i].port.dev = &dev->dev; |
| 1266 | uart_add_one_port(&bfin_serial_reg, &bfin_serial_ports[i].port); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1267 | } |
| 1268 | } |
| 1269 | |
| 1270 | return 0; |
| 1271 | } |
| 1272 | |
Sonic Zhang | ccfbc3e | 2008-10-13 10:32:44 +0100 | [diff] [blame] | 1273 | static int bfin_serial_remove(struct platform_device *dev) |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1274 | { |
Sonic Zhang | ccfbc3e | 2008-10-13 10:32:44 +0100 | [diff] [blame] | 1275 | int i; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1276 | |
Mike Frysinger | c9607ec | 2008-10-13 10:33:16 +0100 | [diff] [blame] | 1277 | for (i = 0; i < nr_active_ports; i++) { |
Sonic Zhang | ccfbc3e | 2008-10-13 10:32:44 +0100 | [diff] [blame] | 1278 | if (bfin_serial_ports[i].port.dev != &dev->dev) |
| 1279 | continue; |
| 1280 | uart_remove_one_port(&bfin_serial_reg, &bfin_serial_ports[i].port); |
| 1281 | bfin_serial_ports[i].port.dev = NULL; |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1282 | #ifdef CONFIG_SERIAL_BFIN_CTSRTS |
Sonic Zhang | ccfbc3e | 2008-10-13 10:32:44 +0100 | [diff] [blame] | 1283 | gpio_free(bfin_serial_ports[i].cts_pin); |
| 1284 | gpio_free(bfin_serial_ports[i].rts_pin); |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1285 | #endif |
Sonic Zhang | ccfbc3e | 2008-10-13 10:32:44 +0100 | [diff] [blame] | 1286 | } |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1287 | |
| 1288 | return 0; |
| 1289 | } |
| 1290 | |
| 1291 | static struct platform_driver bfin_serial_driver = { |
| 1292 | .probe = bfin_serial_probe, |
| 1293 | .remove = bfin_serial_remove, |
| 1294 | .suspend = bfin_serial_suspend, |
| 1295 | .resume = bfin_serial_resume, |
| 1296 | .driver = { |
| 1297 | .name = "bfin-uart", |
Kay Sievers | e169c13 | 2008-04-15 14:34:35 -0700 | [diff] [blame] | 1298 | .owner = THIS_MODULE, |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1299 | }, |
| 1300 | }; |
| 1301 | |
| 1302 | static int __init bfin_serial_init(void) |
| 1303 | { |
| 1304 | int ret; |
| 1305 | |
| 1306 | pr_info("Serial: Blackfin serial driver\n"); |
| 1307 | |
| 1308 | bfin_serial_init_ports(); |
| 1309 | |
| 1310 | ret = uart_register_driver(&bfin_serial_reg); |
| 1311 | if (ret == 0) { |
| 1312 | ret = platform_driver_register(&bfin_serial_driver); |
| 1313 | if (ret) { |
| 1314 | pr_debug("uart register failed\n"); |
| 1315 | uart_unregister_driver(&bfin_serial_reg); |
| 1316 | } |
| 1317 | } |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1318 | return ret; |
| 1319 | } |
| 1320 | |
| 1321 | static void __exit bfin_serial_exit(void) |
| 1322 | { |
| 1323 | platform_driver_unregister(&bfin_serial_driver); |
| 1324 | uart_unregister_driver(&bfin_serial_reg); |
| 1325 | } |
| 1326 | |
Sonic Zhang | 52e15f0e | 2009-01-02 13:40:14 +0000 | [diff] [blame] | 1327 | |
Bryan Wu | 194de56 | 2007-05-06 14:50:30 -0700 | [diff] [blame] | 1328 | module_init(bfin_serial_init); |
| 1329 | module_exit(bfin_serial_exit); |
| 1330 | |
| 1331 | MODULE_AUTHOR("Aubrey.Li <aubrey.li@analog.com>"); |
| 1332 | MODULE_DESCRIPTION("Blackfin generic serial port driver"); |
| 1333 | MODULE_LICENSE("GPL"); |
| 1334 | MODULE_ALIAS_CHARDEV_MAJOR(BFIN_SERIAL_MAJOR); |
Kay Sievers | e169c13 | 2008-04-15 14:34:35 -0700 | [diff] [blame] | 1335 | MODULE_ALIAS("platform:bfin-uart"); |