Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic more Ingenic support:
details: https://anonhg.NetBSD.org/src/rev/1ed370ef2e9e
branches: trunk
changeset: 336598:1ed370ef2e9e
user: macallan <macallan%NetBSD.org@localhost>
date: Sat Mar 07 15:49:20 2015 +0000
description:
more Ingenic support:
- make sure we always set FIFO_UART_ON
- deal with the absence of DCD support
- enable the TX FIFO timeout interrupt
- set COM_HW_NOIEN
- pretend the FIFO is only 16 bytes deep ( supposed to be 64 but I get
overruns with that )
now this works as CI20 console
diffstat:
sys/dev/ic/com.c | 57 ++++++++++++++++++++++++++++++++++++++++++----------
sys/dev/ic/comreg.h | 5 +++-
2 files changed, 50 insertions(+), 12 deletions(-)
diffs (190 lines):
diff -r 357f4161f273 -r 1ed370ef2e9e sys/dev/ic/com.c
--- a/sys/dev/ic/com.c Sat Mar 07 15:39:57 2015 +0000
+++ b/sys/dev/ic/com.c Sat Mar 07 15:49:20 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: com.c,v 1.329 2014/11/22 15:14:35 macallan Exp $ */
+/* $NetBSD: com.c,v 1.330 2015/03/07 15:49:20 macallan 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.329 2014/11/22 15:14:35 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.330 2015/03/07 15:49:20 macallan Exp $");
#include "opt_com.h"
#include "opt_ddb.h"
@@ -382,6 +382,8 @@
sc->sc_ier = IER_ERXRDY;
if (sc->sc_type == COM_TYPE_PXA2x0)
sc->sc_ier |= IER_EUART | IER_ERXTOUT;
+ if (sc->sc_type == COM_TYPE_INGENIC)
+ sc->sc_ier |= IER_ERXTOUT;
CSR_WRITE_1(&sc->sc_regs, COM_REG_IER, sc->sc_ier);
SET(sc->sc_mcr, MCR_DTR | MCR_RTS);
CSR_WRITE_1(&sc->sc_regs, COM_REG_MCR, sc->sc_mcr);
@@ -461,16 +463,22 @@
goto fifodelay;
case COM_TYPE_INGENIC:
- sc->sc_fifolen = 64;
+ sc->sc_fifolen = 16;
fifo_msg = "Ingenic UART, working fifo";
SET(sc->sc_hwflags, COM_HW_FIFO);
+ SET(sc->sc_hwflags, COM_HW_NOIEN);
goto fifodelay;
}
sc->sc_fifolen = 1;
/* look for a NS 16550AF UART with FIFOs */
- CSR_WRITE_1(regsp, COM_REG_FIFO,
- FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_14);
+ if(sc->sc_type == COM_TYPE_INGENIC) {
+ CSR_WRITE_1(regsp, COM_REG_FIFO,
+ FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST |
+ FIFO_TRIGGER_14 | FIFO_UART_ON);
+ } else
+ CSR_WRITE_1(regsp, COM_REG_FIFO,
+ FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_14);
delay(100);
if (ISSET(CSR_READ_1(regsp, COM_REG_IIR), IIR_FIFO_MASK)
== IIR_FIFO_MASK)
@@ -519,6 +527,9 @@
uint8_t iir1, iir2;
const uint8_t fcr = FIFO_ENABLE | FIFO_TRIGGER_14;
+ if(sc->sc_type == COM_TYPE_INGENIC)
+ fcr |= FIFO_UART_ON;
+
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);
@@ -557,7 +568,10 @@
fifo_msg = "ns16550, broken fifo";
else
fifo_msg = "ns8250 or ns16450, no fifo";
- CSR_WRITE_1(regsp, COM_REG_FIFO, 0);
+ if(sc->sc_type == COM_TYPE_INGENIC) {
+ CSR_WRITE_1(regsp, COM_REG_FIFO, FIFO_UART_ON);
+ } else
+ CSR_WRITE_1(regsp, COM_REG_FIFO, 0);
fifodelay:
/*
* Some chips will clear down both Tx and Rx FIFOs when zero is
@@ -800,7 +814,8 @@
/* Turn off interrupts. */
if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) {
sc->sc_ier = IER_ERXRDY; /* interrupt on break */
- if (sc->sc_type == COM_TYPE_PXA2x0)
+ if ((sc->sc_type == COM_TYPE_PXA2x0) ||
+ (sc->sc_type == COM_TYPE_INGENIC))
sc->sc_ier |= IER_ERXTOUT;
} else
sc->sc_ier = 0;
@@ -882,6 +897,8 @@
if (sc->sc_type == COM_TYPE_PXA2x0)
sc->sc_ier |= IER_EUART | IER_ERXTOUT;
+ else if (sc->sc_type == COM_TYPE_INGENIC)
+ sc->sc_ier |= IER_ERXTOUT;
CSR_WRITE_1(&sc->sc_regs, COM_REG_IER, sc->sc_ier);
/* Fetch the current modem control status, needed later. */
@@ -1266,8 +1283,12 @@
SET(ttybits, TIOCM_RTS);
combits = sc->sc_msr;
- if (ISSET(combits, MSR_DCD))
+ if (sc->sc_type == COM_TYPE_INGENIC) {
SET(ttybits, TIOCM_CD);
+ } else {
+ if (ISSET(combits, MSR_DCD))
+ SET(ttybits, TIOCM_CD);
+ }
if (ISSET(combits, MSR_CTS))
SET(ttybits, TIOCM_CTS);
if (ISSET(combits, MSR_DSR))
@@ -1458,6 +1479,9 @@
} else
sc->sc_fifo = 0;
+ if(sc->sc_type == COM_TYPE_INGENIC)
+ sc->sc_fifo |= FIFO_UART_ON;
+
/* And copy to tty. */
tp->t_ispeed = t->c_ospeed;
tp->t_ospeed = t->c_ospeed;
@@ -1496,7 +1520,11 @@
* CLOCAL or MDMBUF. We don't hang up here; we only do that by
* explicit request.
*/
- (void) (*tp->t_linesw->l_modem)(tp, ISSET(sc->sc_msr, MSR_DCD));
+ if (sc->sc_type == COM_TYPE_INGENIC) {
+ /* no DCD here */
+ (void) (*tp->t_linesw->l_modem)(tp, 1);
+ } else
+ (void) (*tp->t_linesw->l_modem)(tp, ISSET(sc->sc_msr, MSR_DCD));
#ifdef COM_DEBUG
if (com_debug)
@@ -1878,7 +1906,10 @@
if (sc->sc_type == COM_TYPE_PXA2x0)
SET(sc->sc_ier, IER_ERXTOUT);
#endif
- CSR_WRITE_1(&sc->sc_regs, COM_REG_IER, sc->sc_ier);
+ if (sc->sc_type == COM_TYPE_INGENIC)
+ sc->sc_ier |= IER_ERXTOUT;
+ CSR_WRITE_1(&sc->sc_regs, COM_REG_IER,
+ sc->sc_ier);
}
if (ISSET(sc->sc_rx_flags, RX_IBUF_BLOCKED)) {
CLR(sc->sc_rx_flags, RX_IBUF_BLOCKED);
@@ -2080,6 +2111,9 @@
CLR(sc->sc_ier, IER_ERXRDY|IER_ERXTOUT);
else
#endif
+ if (sc->sc_type == COM_TYPE_INGENIC)
+ sc->sc_ier |= IER_ERXRDY|IER_ERXTOUT;
+ else
CLR(sc->sc_ier, IER_ERXRDY);
CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier);
}
@@ -2296,7 +2330,8 @@
CSR_WRITE_2(regsp, COM_REG_DLBL, rate);
} else {
/* no EFR on alchemy */
- if (type != COM_TYPE_16550_NOERS) {
+ if ((type != COM_TYPE_16550_NOERS) &&
+ (type != COM_TYPE_INGENIC)) {
CSR_WRITE_1(regsp, COM_REG_LCR, LCR_EERS);
CSR_WRITE_1(regsp, COM_REG_EFR, 0);
}
diff -r 357f4161f273 -r 1ed370ef2e9e sys/dev/ic/comreg.h
--- a/sys/dev/ic/comreg.h Sat Mar 07 15:39:57 2015 +0000
+++ b/sys/dev/ic/comreg.h Sat Mar 07 15:49:20 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: comreg.h,v 1.23 2014/11/22 15:14:35 macallan Exp $ */
+/* $NetBSD: comreg.h,v 1.24 2015/03/07 15:49:20 macallan Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@@ -50,6 +50,7 @@
#define IER_ERTS 0x40 /* Enable RTS interrupt */
#define IER_ECTS 0x80 /* Enable CTS interrupt */
/* PXA2X0's ns16550 ports have extra bits in this register */
+/* Ingenic's got this one too */
#define IER_ERXTOUT 0x10 /* Enable rx timeout interrupt */
#define IER_EUART 0x40 /* Enable UART */
@@ -111,7 +112,9 @@
/* modem control register */
#define MCR_PRESCALE 0x80 /* 16650/16950: Baud rate prescaler select */
+#define MCR_MDCE 0x80 /* Ingenic: modem control enable */
#define MCR_TCR_TLR 0x40 /* OMAP: enables access to the TCR & TLR regs */
+#define MCR_FCM 0x40 /* Ingenic: 1 - hardware flow control */
#define MCR_XONENABLE 0x20 /* OMAP XON_EN */
#define MCR_AFE 0x20 /* tl16c750: Flow Control Enable */
#define MCR_LOOPBACK 0x10 /* Loop test: echos from TX to RX */
Home |
Main Index |
Thread Index |
Old Index