Add support for automatic hardware flow control for 16[679]50 UARTs.

We simply use the detected FIFO size to determine whether we have
a post 16550 UART or not. The support lacks proper serialization of
hardware access for now.
This commit is contained in:
Marcel Moolenaar 2003-09-13 06:25:04 +00:00
parent 58abfe0051
commit 84c7b427f5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=120022

View file

@ -461,7 +461,7 @@ static int
ns8250_bus_ioctl(struct uart_softc *sc, int request, intptr_t data)
{
struct uart_bas *bas;
uint8_t lcr;
uint8_t efr, lcr;
bas = &sc->sc_bas;
switch (request) {
@ -474,6 +474,36 @@ ns8250_bus_ioctl(struct uart_softc *sc, int request, intptr_t data)
uart_setreg(bas, REG_LCR, lcr);
uart_barrier(bas);
break;
case UART_IOCTL_IFLOW:
lcr = uart_getreg(bas, REG_LCR);
uart_barrier(bas);
uart_setreg(bas, REG_LCR, 0xbf);
uart_barrier(bas);
efr = uart_getreg(bas, REG_EFR);
if (data)
efr |= EFR_RTS;
else
efr &= ~EFR_RTS;
uart_setreg(bas, REG_EFR, efr);
uart_barrier(bas);
uart_setreg(bas, REG_LCR, lcr);
uart_barrier(bas);
break;
case UART_IOCTL_OFLOW:
lcr = uart_getreg(bas, REG_LCR);
uart_barrier(bas);
uart_setreg(bas, REG_LCR, 0xbf);
uart_barrier(bas);
efr = uart_getreg(bas, REG_EFR);
if (data)
efr |= EFR_CTS;
else
efr &= ~EFR_CTS;
uart_setreg(bas, REG_EFR, efr);
uart_barrier(bas);
uart_setreg(bas, REG_LCR, lcr);
uart_barrier(bas);
break;
default:
return (EINVAL);
}
@ -650,6 +680,12 @@ ns8250_bus_probe(struct uart_softc *sc)
*/
sc->sc_txfifosz = 16;
/* 16650s or higher have automatic flow control. */
if (sc->sc_rxfifosz > 16) {
sc->sc_hwiflow = 1;
sc->sc_hwoflow = 1;
}
return (0);
}