diff options
Diffstat (limited to 'drivers/serial/bfin_5xx.c')
-rw-r--r-- | drivers/serial/bfin_5xx.c | 125 |
1 files changed, 78 insertions, 47 deletions
diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c index 408390f93db9..787dc7168f3e 100644 --- a/drivers/serial/bfin_5xx.c +++ b/drivers/serial/bfin_5xx.c | |||
@@ -6,8 +6,6 @@ | |||
6 | * Created: | 6 | * Created: |
7 | * Description: Driver for blackfin 5xx serial ports | 7 | * Description: Driver for blackfin 5xx serial ports |
8 | * | 8 | * |
9 | * Rev: $Id: bfin_5xx.c,v 1.19 2006/09/24 02:33:53 aubrey Exp $ | ||
10 | * | ||
11 | * Modified: | 9 | * Modified: |
12 | * Copyright 2006 Analog Devices Inc. | 10 | * Copyright 2006 Analog Devices Inc. |
13 | * | 11 | * |
@@ -152,7 +150,7 @@ static void local_put_char(struct bfin_serial_port *uart, char ch) | |||
152 | 150 | ||
153 | static void bfin_serial_rx_chars(struct bfin_serial_port *uart) | 151 | static void bfin_serial_rx_chars(struct bfin_serial_port *uart) |
154 | { | 152 | { |
155 | struct tty_struct *tty = uart->port.info?uart->port.info->tty:0; | 153 | struct tty_struct *tty = uart->port.info->tty; |
156 | unsigned int status, ch, flg; | 154 | unsigned int status, ch, flg; |
157 | #ifdef BF533_FAMILY | 155 | #ifdef BF533_FAMILY |
158 | static int in_break = 0; | 156 | static int in_break = 0; |
@@ -173,8 +171,10 @@ static void bfin_serial_rx_chars(struct bfin_serial_port *uart) | |||
173 | if (ch != 0) { | 171 | if (ch != 0) { |
174 | in_break = 0; | 172 | in_break = 0; |
175 | ch = UART_GET_CHAR(uart); | 173 | ch = UART_GET_CHAR(uart); |
176 | } | 174 | if (bfin_revid() < 5) |
177 | return; | 175 | return; |
176 | } else | ||
177 | return; | ||
178 | } | 178 | } |
179 | #endif | 179 | #endif |
180 | 180 | ||
@@ -185,27 +185,32 @@ static void bfin_serial_rx_chars(struct bfin_serial_port *uart) | |||
185 | uart->port.icount.brk++; | 185 | uart->port.icount.brk++; |
186 | if (uart_handle_break(&uart->port)) | 186 | if (uart_handle_break(&uart->port)) |
187 | goto ignore_char; | 187 | goto ignore_char; |
188 | flg = TTY_BREAK; | 188 | } |
189 | } else if (status & PE) { | 189 | if (status & PE) |
190 | flg = TTY_PARITY; | ||
191 | uart->port.icount.parity++; | 190 | uart->port.icount.parity++; |
192 | } else if (status & OE) { | 191 | if (status & OE) |
193 | flg = TTY_OVERRUN; | ||
194 | uart->port.icount.overrun++; | 192 | uart->port.icount.overrun++; |
195 | } else if (status & FE) { | 193 | if (status & FE) |
196 | flg = TTY_FRAME; | ||
197 | uart->port.icount.frame++; | 194 | uart->port.icount.frame++; |
198 | } else | 195 | |
196 | status &= uart->port.read_status_mask; | ||
197 | |||
198 | if (status & BI) | ||
199 | flg = TTY_BREAK; | ||
200 | else if (status & PE) | ||
201 | flg = TTY_PARITY; | ||
202 | else if (status & FE) | ||
203 | flg = TTY_FRAME; | ||
204 | else | ||
199 | flg = TTY_NORMAL; | 205 | flg = TTY_NORMAL; |
200 | 206 | ||
201 | if (uart_handle_sysrq_char(&uart->port, ch)) | 207 | if (uart_handle_sysrq_char(&uart->port, ch)) |
202 | goto ignore_char; | 208 | goto ignore_char; |
203 | if (tty) | ||
204 | uart_insert_char(&uart->port, status, 2, ch, flg); | ||
205 | 209 | ||
206 | ignore_char: | 210 | uart_insert_char(&uart->port, status, OE, ch, flg); |
207 | if (tty) | 211 | |
208 | tty_flip_buffer_push(tty); | 212 | ignore_char: |
213 | tty_flip_buffer_push(tty); | ||
209 | } | 214 | } |
210 | 215 | ||
211 | static void bfin_serial_tx_chars(struct bfin_serial_port *uart) | 216 | static void bfin_serial_tx_chars(struct bfin_serial_port *uart) |
@@ -240,24 +245,29 @@ static void bfin_serial_tx_chars(struct bfin_serial_port *uart) | |||
240 | bfin_serial_stop_tx(&uart->port); | 245 | bfin_serial_stop_tx(&uart->port); |
241 | } | 246 | } |
242 | 247 | ||
243 | static irqreturn_t bfin_serial_int(int irq, void *dev_id) | 248 | static irqreturn_t bfin_serial_rx_int(int irq, void *dev_id) |
244 | { | 249 | { |
245 | struct bfin_serial_port *uart = dev_id; | 250 | struct bfin_serial_port *uart = dev_id; |
246 | unsigned short status; | ||
247 | 251 | ||
248 | spin_lock(&uart->port.lock); | 252 | spin_lock(&uart->port.lock); |
249 | status = UART_GET_IIR(uart); | 253 | while ((UART_GET_IIR(uart) & IIR_STATUS) == IIR_RX_READY) |
250 | do { | 254 | bfin_serial_rx_chars(uart); |
251 | if ((status & IIR_STATUS) == IIR_TX_READY) | ||
252 | bfin_serial_tx_chars(uart); | ||
253 | if ((status & IIR_STATUS) == IIR_RX_READY) | ||
254 | bfin_serial_rx_chars(uart); | ||
255 | status = UART_GET_IIR(uart); | ||
256 | } while (status & (IIR_TX_READY | IIR_RX_READY)); | ||
257 | spin_unlock(&uart->port.lock); | 255 | spin_unlock(&uart->port.lock); |
258 | return IRQ_HANDLED; | 256 | return IRQ_HANDLED; |
259 | } | 257 | } |
260 | 258 | ||
259 | static irqreturn_t bfin_serial_tx_int(int irq, void *dev_id) | ||
260 | { | ||
261 | struct bfin_serial_port *uart = dev_id; | ||
262 | |||
263 | spin_lock(&uart->port.lock); | ||
264 | while ((UART_GET_IIR(uart) & IIR_STATUS) == IIR_TX_READY) | ||
265 | bfin_serial_tx_chars(uart); | ||
266 | spin_unlock(&uart->port.lock); | ||
267 | return IRQ_HANDLED; | ||
268 | } | ||
269 | |||
270 | |||
261 | static void bfin_serial_do_work(struct work_struct *work) | 271 | static void bfin_serial_do_work(struct work_struct *work) |
262 | { | 272 | { |
263 | struct bfin_serial_port *uart = container_of(work, struct bfin_serial_port, cts_workqueue); | 273 | struct bfin_serial_port *uart = container_of(work, struct bfin_serial_port, cts_workqueue); |
@@ -319,7 +329,7 @@ static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart) | |||
319 | spin_unlock_irqrestore(&uart->port.lock, flags); | 329 | spin_unlock_irqrestore(&uart->port.lock, flags); |
320 | } | 330 | } |
321 | 331 | ||
322 | static void bfin_serial_dma_rx_chars(struct bfin_serial_port * uart) | 332 | static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart) |
323 | { | 333 | { |
324 | struct tty_struct *tty = uart->port.info->tty; | 334 | struct tty_struct *tty = uart->port.info->tty; |
325 | int i, flg, status; | 335 | int i, flg, status; |
@@ -331,25 +341,32 @@ static void bfin_serial_dma_rx_chars(struct bfin_serial_port * uart) | |||
331 | uart->port.icount.brk++; | 341 | uart->port.icount.brk++; |
332 | if (uart_handle_break(&uart->port)) | 342 | if (uart_handle_break(&uart->port)) |
333 | goto dma_ignore_char; | 343 | goto dma_ignore_char; |
334 | flg = TTY_BREAK; | 344 | } |
335 | } else if (status & PE) { | 345 | if (status & PE) |
336 | flg = TTY_PARITY; | ||
337 | uart->port.icount.parity++; | 346 | uart->port.icount.parity++; |
338 | } else if (status & OE) { | 347 | if (status & OE) |
339 | flg = TTY_OVERRUN; | ||
340 | uart->port.icount.overrun++; | 348 | uart->port.icount.overrun++; |
341 | } else if (status & FE) { | 349 | if (status & FE) |
342 | flg = TTY_FRAME; | ||
343 | uart->port.icount.frame++; | 350 | uart->port.icount.frame++; |
344 | } else | 351 | |
352 | status &= uart->port.read_status_mask; | ||
353 | |||
354 | if (status & BI) | ||
355 | flg = TTY_BREAK; | ||
356 | else if (status & PE) | ||
357 | flg = TTY_PARITY; | ||
358 | else if (status & FE) | ||
359 | flg = TTY_FRAME; | ||
360 | else | ||
345 | flg = TTY_NORMAL; | 361 | flg = TTY_NORMAL; |
346 | 362 | ||
347 | for (i = uart->rx_dma_buf.head; i < uart->rx_dma_buf.tail; i++) { | 363 | for (i = uart->rx_dma_buf.head; i < uart->rx_dma_buf.tail; i++) { |
348 | if (uart_handle_sysrq_char(&uart->port, uart->rx_dma_buf.buf[i])) | 364 | if (uart_handle_sysrq_char(&uart->port, uart->rx_dma_buf.buf[i])) |
349 | goto dma_ignore_char; | 365 | goto dma_ignore_char; |
350 | uart_insert_char(&uart->port, status, 2, uart->rx_dma_buf.buf[i], flg); | 366 | uart_insert_char(&uart->port, status, OE, uart->rx_dma_buf.buf[i], flg); |
351 | } | 367 | } |
352 | dma_ignore_char: | 368 | |
369 | dma_ignore_char: | ||
353 | tty_flip_buffer_push(tty); | 370 | tty_flip_buffer_push(tty); |
354 | } | 371 | } |
355 | 372 | ||
@@ -545,14 +562,14 @@ static int bfin_serial_startup(struct uart_port *port) | |||
545 | add_timer(&(uart->rx_dma_timer)); | 562 | add_timer(&(uart->rx_dma_timer)); |
546 | #else | 563 | #else |
547 | if (request_irq | 564 | if (request_irq |
548 | (uart->port.irq, bfin_serial_int, IRQF_DISABLED, | 565 | (uart->port.irq, bfin_serial_rx_int, IRQF_DISABLED, |
549 | "BFIN_UART_RX", uart)) { | 566 | "BFIN_UART_RX", uart)) { |
550 | printk(KERN_NOTICE "Unable to attach BlackFin UART RX interrupt\n"); | 567 | printk(KERN_NOTICE "Unable to attach BlackFin UART RX interrupt\n"); |
551 | return -EBUSY; | 568 | return -EBUSY; |
552 | } | 569 | } |
553 | 570 | ||
554 | if (request_irq | 571 | if (request_irq |
555 | (uart->port.irq+1, bfin_serial_int, IRQF_DISABLED, | 572 | (uart->port.irq+1, bfin_serial_tx_int, IRQF_DISABLED, |
556 | "BFIN_UART_TX", uart)) { | 573 | "BFIN_UART_TX", uart)) { |
557 | printk(KERN_NOTICE "Unable to attach BlackFin UART TX interrupt\n"); | 574 | printk(KERN_NOTICE "Unable to attach BlackFin UART TX interrupt\n"); |
558 | free_irq(uart->port.irq, uart); | 575 | free_irq(uart->port.irq, uart); |
@@ -614,13 +631,27 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios, | |||
614 | lcr |= EPS; | 631 | lcr |= EPS; |
615 | } | 632 | } |
616 | 633 | ||
617 | /* These controls are not implemented for this port */ | 634 | port->read_status_mask = OE; |
618 | termios->c_iflag |= INPCK | BRKINT | PARMRK; | 635 | if (termios->c_iflag & INPCK) |
619 | termios->c_iflag &= ~(IGNPAR | IGNBRK); | 636 | port->read_status_mask |= (FE | PE); |
637 | if (termios->c_iflag & (BRKINT | PARMRK)) | ||
638 | port->read_status_mask |= BI; | ||
620 | 639 | ||
621 | /* These controls are not implemented for this port */ | 640 | /* |
622 | termios->c_iflag |= INPCK | BRKINT | PARMRK; | 641 | * Characters to ignore |
623 | termios->c_iflag &= ~(IGNPAR | IGNBRK); | 642 | */ |
643 | port->ignore_status_mask = 0; | ||
644 | if (termios->c_iflag & IGNPAR) | ||
645 | port->ignore_status_mask |= FE | PE; | ||
646 | if (termios->c_iflag & IGNBRK) { | ||
647 | port->ignore_status_mask |= BI; | ||
648 | /* | ||
649 | * If we're ignoring parity and break indicators, | ||
650 | * ignore overruns too (for real raw support). | ||
651 | */ | ||
652 | if (termios->c_iflag & IGNPAR) | ||
653 | port->ignore_status_mask |= OE; | ||
654 | } | ||
624 | 655 | ||
625 | baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); | 656 | baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); |
626 | quot = uart_get_divisor(port, baud); | 657 | quot = uart_get_divisor(port, baud); |