summaryrefslogtreecommitdiffstats
path: root/sys/dev/uart/uart_dev_ns8250.c
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2014-05-14 16:32:27 +0000
committerian <ian@FreeBSD.org>2014-05-14 16:32:27 +0000
commit13afdc288fd9e982249ab19116c195578ff90fa1 (patch)
treea7f1a8aa7e8f1518d3c62bbfe659e0a16f4cb25a /sys/dev/uart/uart_dev_ns8250.c
parentbb1ce472d77ae881d92bd8dbbc84cf2c24edb5e4 (diff)
downloadFreeBSD-src-13afdc288fd9e982249ab19116c195578ff90fa1.zip
FreeBSD-src-13afdc288fd9e982249ab19116c195578ff90fa1.tar.gz
MFC r257170, r257171, r257172, r257240, r257278, r257279, r257280, r257281,
r257282, r257332 Wait for DesignWare UART transfers completion before accessing line control Enable UART busy detection handling for Armada XP - based board Enable SATA interface on Armada XP Run mvs SATA driver on Armada XP instead of old mv_sata Retire arm_remap_nocache() and the data and constants associated with it. Remove hard-coded mappings related to Armada XP support Fix-up DTB for Armada XP registers' base according to the actual settings Change Armada XP kernel load address to the u-boot's end address Remove not working and deprecated PJ4Bv6 support Switch off explicit broadcasting of the TLB flush operations for PJ4B CPU Add missing ARMv6 CPU functions to ARM Makefile
Diffstat (limited to 'sys/dev/uart/uart_dev_ns8250.c')
-rw-r--r--sys/dev/uart/uart_dev_ns8250.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/sys/dev/uart/uart_dev_ns8250.c b/sys/dev/uart/uart_dev_ns8250.c
index 31b1aba..47a61bf 100644
--- a/sys/dev/uart/uart_dev_ns8250.c
+++ b/sys/dev/uart/uart_dev_ns8250.c
@@ -649,11 +649,35 @@ int
ns8250_bus_param(struct uart_softc *sc, int baudrate, int databits,
int stopbits, int parity)
{
+ struct ns8250_softc *ns8250;
struct uart_bas *bas;
- int error;
+ int error, limit;
+ ns8250 = (struct ns8250_softc*)sc;
bas = &sc->sc_bas;
uart_lock(sc->sc_hwmtx);
+ /*
+ * When using DW UART with BUSY detection it is necessary to wait
+ * until all serial transfers are finished before manipulating the
+ * line control. LCR will not be affected when UART is busy.
+ */
+ if (ns8250->busy_detect != 0) {
+ /*
+ * Pick an arbitrary high limit to avoid getting stuck in
+ * an infinite loop in case when the hardware is broken.
+ */
+ limit = 10 * 1024;
+ while (((uart_getreg(bas, DW_REG_USR) & USR_BUSY) != 0) &&
+ --limit)
+ DELAY(4);
+
+ if (limit <= 0) {
+ /* UART appears to be stuck */
+ uart_unlock(sc->sc_hwmtx);
+ return (EIO);
+ }
+ }
+
error = ns8250_param(bas, baudrate, databits, stopbits, parity);
uart_unlock(sc->sc_hwmtx);
return (error);
OpenPOWER on IntegriCloud