aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHaavard Skinnemoen <hskinnemoen@atmel.com>2007-07-16 02:40:36 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-16 12:05:45 -0400
commit9e6077bd84a7bffa73b59d9704682aeab5781fa0 (patch)
tree801caf5ef431f6cceb67078c1d67599f58432ee0 /drivers
parentcc1ed7542c8c26af0f501da8006b9fce03e9aaca (diff)
atmel_serial: fix break handling
The RXBRK field in the AT91/AT32 USART status register has the following definition according to e.g. the AT32AP7000 data sheet: RXBRK: Break Received/End of Break 0: No Break received or End of Break detected since the last RSTSTA. 1: Break Received or End of Break detected since the last RSTSTA. Thus, for each break, the USART sets the RXBRK bit twice. This patch modifies the driver to report the break event to the serial core only once by keeping track of whether a break condition is currently active. The break_active flag is reset as soon as a character is received, so even if we miss the start-of-break interrupt this should do the right thing. Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com> Cc: Andrew Victor <andrew@sanpeople.com> Cc: Russell King <rmk@arm.linux.org.uk> Cc: Ivan Kuten <ivan.kuten@promwad.com> Cc: Nicolas Ferre <nicolas.ferre@rfo.atmel.com> Cc: Patrice Vilchez <patrice.vilchez@rfo.atmel.com> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/serial/atmel_serial.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c
index 3320bcd92c0a..4d6b3c56d20e 100644
--- a/drivers/serial/atmel_serial.c
+++ b/drivers/serial/atmel_serial.c
@@ -114,6 +114,7 @@ struct atmel_uart_port {
114 struct uart_port uart; /* uart */ 114 struct uart_port uart; /* uart */
115 struct clk *clk; /* uart clock */ 115 struct clk *clk; /* uart clock */
116 unsigned short suspended; /* is port suspended? */ 116 unsigned short suspended; /* is port suspended? */
117 int break_active; /* break being received */
117}; 118};
118 119
119static struct atmel_uart_port atmel_ports[ATMEL_MAX_UART]; 120static struct atmel_uart_port atmel_ports[ATMEL_MAX_UART];
@@ -252,6 +253,7 @@ static void atmel_break_ctl(struct uart_port *port, int break_state)
252 */ 253 */
253static void atmel_rx_chars(struct uart_port *port) 254static void atmel_rx_chars(struct uart_port *port)
254{ 255{
256 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *) port;
255 struct tty_struct *tty = port->info->tty; 257 struct tty_struct *tty = port->info->tty;
256 unsigned int status, ch, flg; 258 unsigned int status, ch, flg;
257 259
@@ -267,13 +269,29 @@ static void atmel_rx_chars(struct uart_port *port)
267 * note that the error handling code is 269 * note that the error handling code is
268 * out of the main execution path 270 * out of the main execution path
269 */ 271 */
270 if (unlikely(status & (ATMEL_US_PARE | ATMEL_US_FRAME | ATMEL_US_OVRE | ATMEL_US_RXBRK))) { 272 if (unlikely(status & (ATMEL_US_PARE | ATMEL_US_FRAME
273 | ATMEL_US_OVRE | ATMEL_US_RXBRK)
274 || atmel_port->break_active)) {
271 UART_PUT_CR(port, ATMEL_US_RSTSTA); /* clear error */ 275 UART_PUT_CR(port, ATMEL_US_RSTSTA); /* clear error */
272 if (status & ATMEL_US_RXBRK) { 276 if (status & ATMEL_US_RXBRK
277 && !atmel_port->break_active) {
273 status &= ~(ATMEL_US_PARE | ATMEL_US_FRAME); /* ignore side-effect */ 278 status &= ~(ATMEL_US_PARE | ATMEL_US_FRAME); /* ignore side-effect */
274 port->icount.brk++; 279 port->icount.brk++;
280 atmel_port->break_active = 1;
281 UART_PUT_IER(port, ATMEL_US_RXBRK);
275 if (uart_handle_break(port)) 282 if (uart_handle_break(port))
276 goto ignore_char; 283 goto ignore_char;
284 } else {
285 /*
286 * This is either the end-of-break
287 * condition or we've received at
288 * least one character without RXBRK
289 * being set. In both cases, the next
290 * RXBRK will indicate start-of-break.
291 */
292 UART_PUT_IDR(port, ATMEL_US_RXBRK);
293 status &= ~ATMEL_US_RXBRK;
294 atmel_port->break_active = 0;
277 } 295 }
278 if (status & ATMEL_US_PARE) 296 if (status & ATMEL_US_PARE)
279 port->icount.parity++; 297 port->icount.parity++;
@@ -352,6 +370,16 @@ static irqreturn_t atmel_interrupt(int irq, void *dev_id)
352 /* Interrupt receive */ 370 /* Interrupt receive */
353 if (pending & ATMEL_US_RXRDY) 371 if (pending & ATMEL_US_RXRDY)
354 atmel_rx_chars(port); 372 atmel_rx_chars(port);
373 else if (pending & ATMEL_US_RXBRK) {
374 /*
375 * End of break detected. If it came along
376 * with a character, atmel_rx_chars will
377 * handle it.
378 */
379 UART_PUT_CR(port, ATMEL_US_RSTSTA);
380 UART_PUT_IDR(port, ATMEL_US_RXBRK);
381 atmel_port->break_active = 0;
382 }
355 383
356 // TODO: All reads to CSR will clear these interrupts! 384 // TODO: All reads to CSR will clear these interrupts!
357 if (pending & ATMEL_US_RIIC) port->icount.rng++; 385 if (pending & ATMEL_US_RIIC) port->icount.rng++;