summaryrefslogtreecommitdiff
path: root/sys/dev/usb/serial/uftdi.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/usb/serial/uftdi.c')
-rw-r--r--sys/dev/usb/serial/uftdi.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sys/dev/usb/serial/uftdi.c b/sys/dev/usb/serial/uftdi.c
index 8b7e620aaa0e..bdad31891390 100644
--- a/sys/dev/usb/serial/uftdi.c
+++ b/sys/dev/usb/serial/uftdi.c
@@ -1123,6 +1123,9 @@ uftdi_attach(device_t dev)
FTDI_SIO_SET_DATA_PARITY_NONE |
FTDI_SIO_SET_DATA_BITS(8));
+ /* Indicate tx bits in sc_lsr can be used to determine busy vs idle. */
+ ucom_use_lsr_txbits(&sc->sc_ucom);
+
error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
&uftdi_callback, &sc->sc_mtx);
if (error) {
@@ -1279,16 +1282,20 @@ uftdi_read_callback(struct usb_xfer *xfer, usb_error_t error)
offset = 0;
/*
* Extract packet headers and payload bytes from the buffer.
- * Feed payload bytes to ucom/tty layer; OR-accumulate header
- * status bits which are transient and could toggle with each
- * packet. After processing all packets in the buffer, process
- * the accumulated transient MSR and LSR values along with the
+ * Feed payload bytes to ucom/tty layer; OR-accumulate the
+ * receiver-related header status bits which are transient and
+ * could toggle with each packet, but for transmitter-related
+ * bits keep only the ones from the last packet.
+ *
+ * After processing all packets in the buffer, process the
+ * accumulated transient MSR and LSR values along with the
* non-transient bits from the last packet header.
*/
while (buflen >= UFTDI_IHDRSIZE) {
usbd_copy_out(pc, offset, buf, UFTDI_IHDRSIZE);
offset += UFTDI_IHDRSIZE;
buflen -= UFTDI_IHDRSIZE;
+ lsr &= ~(ULSR_TXRDY | ULSR_TSRE);
lsr |= FTDI_GET_LSR(buf);
if (FTDI_GET_MSR(buf) & FTDI_SIO_RI_MASK)
msr |= SER_RI;
@@ -1311,8 +1318,7 @@ uftdi_read_callback(struct usb_xfer *xfer, usb_error_t error)
if (ftdi_msr & FTDI_SIO_RLSD_MASK)
msr |= SER_DCD;
- if ((sc->sc_msr != msr) ||
- ((sc->sc_lsr & FTDI_LSR_MASK) != (lsr & FTDI_LSR_MASK))) {
+ if (sc->sc_msr != msr || sc->sc_lsr != lsr) {
DPRINTF("status change msr=0x%02x (0x%02x) "
"lsr=0x%02x (0x%02x)\n", msr, sc->sc_msr,
lsr, sc->sc_lsr);