Date: Sat, 23 Aug 2003 18:23:47 -0700 (PDT) From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 36807 for review Message-ID: <200308240123.h7O1Nlk3081717@repoman.freebsd.org>
index | next in thread | raw e-mail
http://perforce.freebsd.org/chv.cgi?CH=36807 Change 36807 by marcel@marcel_nfs on 2003/08/23 18:23:15 Implement UART_FLUSH(). Note that we get a XPR interrupt when we reset the transmitter. Since we cannot detect a bogus XPR from a real one by only looking at the RBCL register, we now first check SAB_STAR_RFNE. If it indicates that there's at least 1 character in the RFIFO, we read RBCL, and then read the data from the RFIFO. Affected files ... .. //depot/projects/uart/dev/uart/uart_dev_sab82532.c#14 edit Differences ... ==== //depot/projects/uart/dev/uart/uart_dev_sab82532.c#14 (text+ko) ==== @@ -102,6 +102,24 @@ return (0); } +static void +sab82532_flush(struct uart_bas *bas, int what) +{ + + if (what & UART_FLUSH_TRANSMITTER) { + while (uart_getreg(bas, SAB_STAR) & SAB_STAR_CEC) + ; + uart_setreg(bas, SAB_CMDR, SAB_CMDR_XRES); + uart_barrier(bas); + } + if (what & UART_FLUSH_RECEIVER) { + while (uart_getreg(bas, SAB_STAR) & SAB_STAR_CEC) + ; + uart_setreg(bas, SAB_CMDR, SAB_CMDR_RRES); + uart_barrier(bas); + } +} + static int sab82532_param(struct uart_bas *bas, int baudrate, int databits, int stopbits, int parity) @@ -227,16 +245,8 @@ SAB_RFC_RFTH_32CHAR); uart_barrier(bas); - while (uart_getreg(bas, SAB_STAR) & SAB_STAR_CEC) - ; - uart_setreg(bas, SAB_CMDR, SAB_CMDR_XRES); - uart_barrier(bas); - while (uart_getreg(bas, SAB_STAR) & SAB_STAR_CEC) - ; - uart_setreg(bas, SAB_CMDR, SAB_CMDR_RRES); - uart_barrier(bas); - sab82532_param(bas, baudrate, databits, stopbits, parity); + sab82532_flush(bas, UART_FLUSH_TRANSMITTER|UART_FLUSH_RECEIVER); /* Clear interrupts. */ uart_setreg(bas, SAB_IMR0, 0xff); @@ -298,9 +308,9 @@ while (!(uart_getreg(bas, SAB_STAR) & SAB_STAR_RFNE)) DELAY(delay); + while (uart_getreg(bas, SAB_STAR) & SAB_STAR_CEC) ; - uart_setreg(bas, SAB_CMDR, SAB_CMDR_RFRD); uart_barrier(bas); @@ -405,6 +415,7 @@ sab82532_bus_flush(struct uart_softc *sc, int what) { + sab82532_flush(&sc->sc_bas, what); return (0); } @@ -503,9 +514,12 @@ { struct uart_bas *bas; int count, xc; - uint8_t s; + uint8_t s, star; bas = &sc->sc_bas; + star = uart_getreg(bas, SAB_STAR); + if (!(star & SAB_STAR_RFNE)) + return (0); count = uart_getreg(bas, SAB_RBCL) & 31; if (count == 0) count = 32;home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200308240123.h7O1Nlk3081717>
