aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2008-12-16 05:29:38 -0500
committerPaul Mundt <lethal@linux-sh.org>2008-12-22 04:44:43 -0500
commitd830fa4584a4015989b9b396a80779f28f277baa (patch)
tree0adfcdde0b697d72adc8f0d88c1ce0a4c3efedce
parent762c69e3cad67a5cc5a01ba74e0b552ae4615258 (diff)
serial: sh-sci: Tidy up fifo overrun error handling.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r--drivers/serial/sh-sci.c45
-rw-r--r--drivers/serial/sh-sci.h11
2 files changed, 29 insertions, 27 deletions
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 0251077693d1..b0feea493985 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -625,6 +625,27 @@ static inline int sci_handle_errors(struct uart_port *port)
625 return copied; 625 return copied;
626} 626}
627 627
628static inline int sci_handle_fifo_overrun(struct uart_port *port)
629{
630 struct tty_struct *tty = port->info->port.tty;
631 int copied = 0;
632
633 if (port->type != PORT_SCIF)
634 return 0;
635
636 if ((sci_in(port, SCLSR) & SCIF_ORER) != 0) {
637 sci_out(port, SCLSR, 0);
638
639 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
640 tty_flip_buffer_push(tty);
641
642 dev_notice(port->dev, "overrun error\n");
643 copied++;
644 }
645
646 return copied;
647}
648
628static inline int sci_handle_breaks(struct uart_port *port) 649static inline int sci_handle_breaks(struct uart_port *port)
629{ 650{
630 int copied = 0; 651 int copied = 0;
@@ -647,20 +668,11 @@ static inline int sci_handle_breaks(struct uart_port *port)
647 dev_dbg(port->dev, "BREAK detected\n"); 668 dev_dbg(port->dev, "BREAK detected\n");
648 } 669 }
649 670
650#if defined(SCIF_ORER)
651 /* XXX: Handle SCIF overrun error */
652 if (port->type != PORT_SCI && (sci_in(port, SCLSR) & SCIF_ORER) != 0) {
653 sci_out(port, SCLSR, 0);
654 if (tty_insert_flip_char(tty, 0, TTY_OVERRUN)) {
655 copied++;
656 dev_notice(port->dev, "overrun error\n");
657 }
658 }
659#endif
660
661 if (copied) 671 if (copied)
662 tty_flip_buffer_push(tty); 672 tty_flip_buffer_push(tty);
663 673
674 copied += sci_handle_fifo_overrun(port);
675
664 return copied; 676 return copied;
665} 677}
666 678
@@ -698,16 +710,7 @@ static irqreturn_t sci_er_interrupt(int irq, void *ptr)
698 sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port)); 710 sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
699 } 711 }
700 } else { 712 } else {
701#if defined(SCIF_ORER) 713 sci_handle_fifo_overrun(port);
702 if ((sci_in(port, SCLSR) & SCIF_ORER) != 0) {
703 struct tty_struct *tty = port->info->port.tty;
704
705 sci_out(port, SCLSR, 0);
706 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
707 tty_flip_buffer_push(tty);
708 dev_notice(port->dev, "overrun error\n");
709 }
710#endif
711 sci_rx_interrupt(irq, ptr); 714 sci_rx_interrupt(irq, ptr);
712 } 715 }
713 716
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index 6da755d63529..4479a91e2479 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -232,6 +232,10 @@
232# define SCIF_TXROOM_MAX 16 232# define SCIF_TXROOM_MAX 16
233#endif 233#endif
234 234
235#ifndef SCIF_ORER
236#define SCIF_ORER 0x0000
237#endif
238
235#define SCxSR_TEND(port) (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND) 239#define SCxSR_TEND(port) (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND)
236#define SCxSR_ERRORS(port) (((port)->type == PORT_SCI) ? SCI_ERRORS : SCIF_ERRORS) 240#define SCxSR_ERRORS(port) (((port)->type == PORT_SCI) ? SCI_ERRORS : SCIF_ERRORS)
237#define SCxSR_RDxF(port) (((port)->type == PORT_SCI) ? SCI_RDRF : SCIF_RDF) 241#define SCxSR_RDxF(port) (((port)->type == PORT_SCI) ? SCI_RDRF : SCIF_RDF)
@@ -239,12 +243,7 @@
239#define SCxSR_FER(port) (((port)->type == PORT_SCI) ? SCI_FER : SCIF_FER) 243#define SCxSR_FER(port) (((port)->type == PORT_SCI) ? SCI_FER : SCIF_FER)
240#define SCxSR_PER(port) (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER) 244#define SCxSR_PER(port) (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER)
241#define SCxSR_BRK(port) (((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK) 245#define SCxSR_BRK(port) (((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK)
242 246#define SCxSR_ORER(port) (((port)->type == PORT_SCI) ? SCI_ORER : SCIF_ORER)
243#if defined(CONFIG_CPU_SUBTYPE_SH7705)
244# define SCxSR_ORER(port) (((port)->type == PORT_SCI) ? SCI_ORER : SCIF_ORER)
245#else
246# define SCxSR_ORER(port) (((port)->type == PORT_SCI) ? SCI_ORER : 0x0000)
247#endif
248 247
249#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ 248#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
250 defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 249 defined(CONFIG_CPU_SUBTYPE_SH7720) || \