From owner-p4-projects@FreeBSD.ORG Sat Aug 23 18:23:49 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1FBCF16A4C1; Sat, 23 Aug 2003 18:23:49 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D844D16A4BF for ; Sat, 23 Aug 2003 18:23:48 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 23CFD43FE1 for ; Sat, 23 Aug 2003 18:23:48 -0700 (PDT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h7O1Nl0U081720 for ; Sat, 23 Aug 2003 18:23:47 -0700 (PDT) (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h7O1Nlk3081717 for perforce@freebsd.org; Sat, 23 Aug 2003 18:23:47 -0700 (PDT) Date: Sat, 23 Aug 2003 18:23:47 -0700 (PDT) Message-Id: <200308240123.h7O1Nlk3081717@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Subject: PERFORCE change 36807 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Aug 2003 01:23:49 -0000 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;