aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <michael.frysinger@analog.com>2007-05-21 06:09:39 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-21 12:50:23 -0400
commit2ac5ee4738cbd9c146ccda53f02006eaf6a43352 (patch)
treebf676cf38fc0f34fa6249c62cf18841389e011e1
parent5c4e472b0af57553f9584e0b33c491b168ac1dff (diff)
Blackfin serial driver: implement support for ignoring parity/break errors
properly setting up and respecting the read_status_mask / ignore_status_mask fields of the serial core Signed-off-by: Mike Frysinger <michael.frysinger@analog.com> Signed-off-by: Bryan Wu <bryan.wu@analog.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/serial/bfin_5xx.c97
1 files changed, 61 insertions, 36 deletions
diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index a8271d9c6202..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
153static void bfin_serial_rx_chars(struct bfin_serial_port *uart) 151static 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
206ignore_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
211static void bfin_serial_tx_chars(struct bfin_serial_port *uart) 216static void bfin_serial_tx_chars(struct bfin_serial_port *uart)
@@ -254,7 +259,6 @@ static irqreturn_t bfin_serial_rx_int(int irq, void *dev_id)
254static irqreturn_t bfin_serial_tx_int(int irq, void *dev_id) 259static irqreturn_t bfin_serial_tx_int(int irq, void *dev_id)
255{ 260{
256 struct bfin_serial_port *uart = dev_id; 261 struct bfin_serial_port *uart = dev_id;
257 unsigned short status;
258 262
259 spin_lock(&uart->port.lock); 263 spin_lock(&uart->port.lock);
260 while ((UART_GET_IIR(uart) & IIR_STATUS) == IIR_TX_READY) 264 while ((UART_GET_IIR(uart) & IIR_STATUS) == IIR_TX_READY)
@@ -325,7 +329,7 @@ static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart)
325 spin_unlock_irqrestore(&uart->port.lock, flags); 329 spin_unlock_irqrestore(&uart->port.lock, flags);
326} 330}
327 331
328static void bfin_serial_dma_rx_chars(struct bfin_serial_port * uart) 332static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart)
329{ 333{
330 struct tty_struct *tty = uart->port.info->tty; 334 struct tty_struct *tty = uart->port.info->tty;
331 int i, flg, status; 335 int i, flg, status;
@@ -337,25 +341,32 @@ static void bfin_serial_dma_rx_chars(struct bfin_serial_port * uart)
337 uart->port.icount.brk++; 341 uart->port.icount.brk++;
338 if (uart_handle_break(&uart->port)) 342 if (uart_handle_break(&uart->port))
339 goto dma_ignore_char; 343 goto dma_ignore_char;
340 flg = TTY_BREAK; 344 }
341 } else if (status & PE) { 345 if (status & PE)
342 flg = TTY_PARITY;
343 uart->port.icount.parity++; 346 uart->port.icount.parity++;
344 } else if (status & OE) { 347 if (status & OE)
345 flg = TTY_OVERRUN;
346 uart->port.icount.overrun++; 348 uart->port.icount.overrun++;
347 } else if (status & FE) { 349 if (status & FE)
348 flg = TTY_FRAME;
349 uart->port.icount.frame++; 350 uart->port.icount.frame++;
350 } 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
351 flg = TTY_NORMAL; 361 flg = TTY_NORMAL;
352 362
353 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++) {
354 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]))
355 goto dma_ignore_char; 365 goto dma_ignore_char;
356 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);
357 } 367 }
358dma_ignore_char: 368
369 dma_ignore_char:
359 tty_flip_buffer_push(tty); 370 tty_flip_buffer_push(tty);
360} 371}
361 372
@@ -620,13 +631,27 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
620 lcr |= EPS; 631 lcr |= EPS;
621 } 632 }
622 633
623 /* These controls are not implemented for this port */ 634 port->read_status_mask = OE;
624 termios->c_iflag |= INPCK | BRKINT | PARMRK; 635 if (termios->c_iflag & INPCK)
625 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;
626 639
627 /* These controls are not implemented for this port */ 640 /*
628 termios->c_iflag |= INPCK | BRKINT | PARMRK; 641 * Characters to ignore
629 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 }
630 655
631 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);
632 quot = uart_get_divisor(port, baud); 657 quot = uart_get_divisor(port, baud);