Date: Sat, 23 Aug 2003 01:20:13 -0700 (PDT) From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 36744 for review Message-ID: <200308230820.h7N8KDcn099957@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=36744 Change 36744 by marcel@marcel_nfs on 2003/08/23 01:20:05 Implement getsig() and setsig(). There's still something wrong with the signals. DTR is not being set and DCD is not being detected. I doubt DSR and RTS will be any better. Ah well, can't have it all... Affected files ... .. //depot/projects/uart/dev/uart/uart_dev_sab82532.c#11 edit Differences ... ==== //depot/projects/uart/dev/uart/uart_dev_sab82532.c#11 (text+ko) ==== @@ -318,7 +318,6 @@ */ struct sab82532_softc { struct uart_softc base; - uint8_t ipc; }; static int sab82532_bus_attach(struct uart_softc *); @@ -354,6 +353,13 @@ .uc_rclk = DEFAULT_RCLK }; +#define SIGCHG(c, i, s, d) \ + if (c) { \ + i |= (i & s) ? s : s | d; \ + } else { \ + i = (i & s) ? (i & ~s) | d : i; \ + } + static int sab82532_bus_attach(struct uart_softc *sc) { @@ -400,8 +406,21 @@ static int sab82532_bus_getsig(struct uart_softc *sc) { + struct uart_bas *bas; + int sig; + uint8_t pvr, star, vstr; - return (0); + bas = &sc->sc_bas; + sig = sc->sc_hwsig; + star = uart_getreg(bas, SAB_STAR); + SIGCHG(star & SAB_STAR_CTS, sig, UART_SIG_CTS, UART_SIG_DCTS); + vstr = uart_getreg(bas, SAB_VSTR); + SIGCHG(vstr & SAB_VSTR_CD, sig, UART_SIG_DCD, UART_SIG_DDCD); + pvr = uart_getreg(bas, SAB_PVR); + pvr &= (IS_CHANNEL_A(bas)) ? SAB_PVR_DSR_A : SAB_PVR_DSR_B; + SIGCHG(pvr, sig, UART_SIG_DSR, UART_SIG_DDSR); + sc->sc_hwsig = sig & ~UART_SIGMASK_DELTA; + return (sig); } static int @@ -513,7 +532,39 @@ static int sab82532_bus_setsig(struct uart_softc *sc, int sig) { + struct uart_bas *bas; + uint8_t dafo, mode, pvr; + bas = &sc->sc_bas; + if (sig & UART_SIG_DDTR) { + SIGCHG(sig & UART_SIG_DTR, sc->sc_hwsig, UART_SIG_DTR, + UART_SIG_DDTR); + } + if (sig & UART_SIG_DRTS) { + SIGCHG(sig & UART_SIG_RTS, sc->sc_hwsig, UART_SIG_RTS, + UART_SIG_DRTS); + } + pvr = uart_getreg(bas, SAB_PVR); + if (sc->sc_hwsig & UART_SIG_DTR) + pvr |= (IS_CHANNEL_A(bas)) ? SAB_PVR_DTR_A : SAB_PVR_DTR_B; + else + pvr &= (IS_CHANNEL_A(bas)) ? ~SAB_PVR_DTR_A : ~SAB_PVR_DTR_B; + uart_setreg(bas, SAB_PVR, pvr); + mode = uart_getreg(bas, SAB_MODE); + if (sc->sc_hwsig & UART_SIG_RTS) + mode |= SAB_MODE_RTS; + else + mode &= ~SAB_MODE_RTS; + uart_setreg(bas, SAB_MODE, mode); + uart_barrier(bas); + if (sig & UART_SIG_DBREAK) { + dafo = uart_getreg(bas, SAB_DAFO); + if (sig & UART_SIG_BREAK) + dafo |= SAB_DAFO_XBRK; + else + dafo &= ~SAB_DAFO_XBRK; + uart_setreg(bas, SAB_DAFO, dafo); + } return (0); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200308230820.h7N8KDcn099957>