Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic Add support 16750 64Byte FIFO. But not test.



details:   https://anonhg.NetBSD.org/src/rev/802f8d58f801
branches:  trunk
changeset: 789670:802f8d58f801
user:      kiyohara <kiyohara%NetBSD.org@localhost>
date:      Sun Sep 01 04:58:15 2013 +0000

description:
Add support 16750 64Byte FIFO.  But not test.

diffstat:

 sys/dev/ic/com.c    |  40 ++++++++++++++++++++++++++++++++++++----
 sys/dev/ic/comreg.h |   4 +++-
 2 files changed, 39 insertions(+), 5 deletions(-)

diffs (101 lines):

diff -r 54e5503681c7 -r 802f8d58f801 sys/dev/ic/com.c
--- a/sys/dev/ic/com.c  Sun Sep 01 04:51:24 2013 +0000
+++ b/sys/dev/ic/com.c  Sun Sep 01 04:58:15 2013 +0000
@@ -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 @@
 {
        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 @@
 #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 @@
                                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";
diff -r 54e5503681c7 -r 802f8d58f801 sys/dev/ic/comreg.h
--- a/sys/dev/ic/comreg.h       Sun Sep 01 04:51:24 2013 +0000
+++ b/sys/dev/ic/comreg.h       Sun Sep 01 04:58:15 2013 +0000
@@ -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 */



Home | Main Index | Thread Index | Old Index