Module Name: src Committed By: kiyohara Date: Sun Sep 1 04:58:15 UTC 2013
Modified Files: src/sys/dev/ic: com.c comreg.h Log Message: Add support 16750 64Byte FIFO. But not test. To generate a diff of this commit: cvs rdiff -u -r1.313 -r1.314 src/sys/dev/ic/com.c cvs rdiff -u -r1.19 -r1.20 src/sys/dev/ic/comreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/ic/com.c diff -u src/sys/dev/ic/com.c:1.313 src/sys/dev/ic/com.c:1.314 --- src/sys/dev/ic/com.c:1.313 Sun Sep 1 04:51:24 2013 +++ src/sys/dev/ic/com.c Sun Sep 1 04:58:15 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: com.c,v 1.313 2013/09/01 04:51:24 kiyohara Exp $ */ +/* $NetBSD: com.c,v 1.314 2013/09/01 04:58:15 kiyohara Exp $ */ /*- * Copyright (c) 1998, 1999, 2004, 2008 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.313 2013/09/01 04:51:24 kiyohara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.314 2013/09/01 04:58:15 kiyohara Exp $"); #include "opt_com.h" #include "opt_ddb.h" @@ -374,9 +374,7 @@ com_attach_subr(struct com_softc *sc) { struct com_regs *regsp = &sc->sc_regs; struct tty *tp; -#ifdef COM_16650 u_int8_t lcr; -#endif const char *fifo_msg = NULL; prop_dictionary_t dict; bool is_console = true; @@ -480,6 +478,37 @@ com_attach_subr(struct com_softc *sc) #endif sc->sc_fifolen = 16; + /* + * TL16C750 can enable 64byte FIFO, only when DLAB + * is 1. However, some 16750 may always enable. For + * example, restrictions according to DLAB in a data + * sheet for SC16C750 were not described. + * Please enable 'options COM_16650', supposing you + * use SC16C750. Probably 32 bytes of FIFO and HW FLOW + * should become effective. + */ + uint8_t iir1, iir2; + const uint8_t fcr = FIFO_ENABLE | FIFO_TRIGGER_14; + + lcr = CSR_READ_1(regsp, COM_REG_LCR); + CSR_WRITE_1(regsp, COM_REG_LCR, lcr & ~LCR_DLAB); + CSR_WRITE_1(regsp, COM_REG_FIFO, fcr | FIFO_64B_ENABLE); + iir1 = CSR_READ_1(regsp, COM_REG_IIR); + CSR_WRITE_1(regsp, COM_REG_FIFO, fcr); + CSR_WRITE_1(regsp, COM_REG_LCR, lcr | LCR_DLAB); + CSR_WRITE_1(regsp, COM_REG_FIFO, fcr | FIFO_64B_ENABLE); + iir2 = CSR_READ_1(regsp, COM_REG_IIR); + + CSR_WRITE_1(regsp, COM_REG_LCR, lcr); + + if (!ISSET(iir1, IIR_64B_FIFO) && + ISSET(iir2, IIR_64B_FIFO)) { + /* It is TL16C750. */ + sc->sc_fifolen = 64; + SET(sc->sc_hwflags, COM_HW_FLOW); + } else + CSR_WRITE_1(regsp, COM_REG_FIFO, fcr); + #ifdef COM_16650 CSR_WRITE_1(regsp, COM_REG_LCR, lcr); if (sc->sc_fifolen == 0) @@ -488,6 +517,9 @@ com_attach_subr(struct com_softc *sc) fifo_msg = "st16650a, working fifo"; else #endif + if (sc->sc_fifolen == 64) + fifo_msg = "tl16c750, working fifo"; + else fifo_msg = "ns16550a, working fifo"; } else fifo_msg = "ns16550, broken fifo"; Index: src/sys/dev/ic/comreg.h diff -u src/sys/dev/ic/comreg.h:1.19 src/sys/dev/ic/comreg.h:1.20 --- src/sys/dev/ic/comreg.h:1.19 Sun Sep 1 04:51:24 2013 +++ src/sys/dev/ic/comreg.h Sun Sep 1 04:58:15 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: comreg.h,v 1.19 2013/09/01 04:51:24 kiyohara Exp $ */ +/* $NetBSD: comreg.h,v 1.20 2013/09/01 04:58:15 kiyohara Exp $ */ /*- * Copyright (c) 1991 The Regents of the University of California. @@ -63,6 +63,7 @@ #define IIR_TXRDY 0x2 /* Transmitter ready */ #define IIR_MLSC 0x0 /* Modem status */ #define IIR_NOPEND 0x1 /* No pending interrupts */ +#define IIR_64B_FIFO 0x20 /* 64byte FIFO Enabled (16750) */ #define IIR_FIFO_MASK 0xc0 /* set if FIFOs are enabled */ /* fifo control register */ @@ -70,6 +71,7 @@ #define FIFO_RCV_RST 0x02 /* Reset RX FIFO */ #define FIFO_XMT_RST 0x04 /* Reset TX FIFO */ #define FIFO_DMA_MODE 0x08 +#define FIFO_64B_ENABLE 0x20 /* 64byte FIFO Enable (16750) */ #define FIFO_TRIGGER_1 0x00 /* Trigger RXRDY intr on 1 character */ #define FIFO_TRIGGER_4 0x40 /* ibid 4 */ #define FIFO_TRIGGER_8 0x80 /* ibid 8 */