PERFORCE change 36807 for review
Marcel Moolenaar
marcel at FreeBSD.org
Sat Aug 23 18:23:49 PDT 2003
http://perforce.freebsd.org/chv.cgi?CH=36807
Change 36807 by marcel at 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;
More information about the p4-projects
mailing list