From 823c77d78b6b67798c45cd09ead36c11555d883d Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Wed, 12 Mar 2008 19:09:20 +0000 Subject: [PATCH] add device hints to control the rx FIFO interrupt level on 16550A parts PR: kern/121421 Submitted by: UEMURA Tetsuya Reviewed by: marcel MFC after: 2 weeks --- sys/dev/uart/uart.h | 4 ++++ sys/dev/uart/uart_dev_ns8250.c | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/sys/dev/uart/uart.h b/sys/dev/uart/uart.h index bcb8cd89aa6d..ed980eb38932 100644 --- a/sys/dev/uart/uart.h +++ b/sys/dev/uart/uart.h @@ -74,6 +74,10 @@ extern struct uart_class uart_z8530_class __attribute__((weak)); */ #define UART_FLAGS_CONSOLE(f) ((f) & 0x10) #define UART_FLAGS_DBGPORT(f) ((f) & 0x80) +#define UART_FLAGS_FCR_RX_LOW(f) ((f) & 0x100) +#define UART_FLAGS_FCR_RX_MEDL(f) ((f) & 0x200) +#define UART_FLAGS_FCR_RX_MEDH(f) ((f) & 0x400) +#define UART_FLAGS_FCR_RX_HIGH(f) ((f) & 0x800) /* * Data parity values (magical numbers related to ns8250). diff --git a/sys/dev/uart/uart_dev_ns8250.c b/sys/dev/uart/uart_dev_ns8250.c index abe141b705ac..d2a3dcf229fd 100644 --- a/sys/dev/uart/uart_dev_ns8250.c +++ b/sys/dev/uart/uart_dev_ns8250.c @@ -382,11 +382,24 @@ ns8250_bus_attach(struct uart_softc *sc) { struct ns8250_softc *ns8250 = (struct ns8250_softc*)sc; struct uart_bas *bas; + unsigned int ivar; bas = &sc->sc_bas; ns8250->mcr = uart_getreg(bas, REG_MCR); - ns8250->fcr = FCR_ENABLE | FCR_RX_MEDH; + ns8250->fcr = FCR_ENABLE; + if (!resource_int_value("uart", device_get_unit(sc->sc_dev), "flags", + &ivar)) { + if (UART_FLAGS_FCR_RX_LOW(ivar)) + ns8250->fcr |= FCR_RX_LOW; + else if (UART_FLAGS_FCR_RX_MEDL(ivar)) + ns8250->fcr |= FCR_RX_MEDL; + else if (UART_FLAGS_FCR_RX_HIGH(ivar)) + ns8250->fcr |= FCR_RX_HIGH; + else + ns8250->fcr |= FCR_RX_MEDH; + } else + ns8250->fcr |= FCR_RX_MEDH; uart_setreg(bas, REG_FCR, ns8250->fcr); uart_barrier(bas); ns8250_bus_flush(sc, UART_FLUSH_RECEIVER|UART_FLUSH_TRANSMITTER);