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 for 16750 style UARTs. Activated by d...
details: https://anonhg.NetBSD.org/src/rev/cb9d63ab8856
branches: trunk
changeset: 786227:cb9d63ab8856
user: rkujawa <rkujawa%NetBSD.org@localhost>
date: Sat Apr 20 11:52:40 2013 +0000
description:
Add support for 16750 style UARTs. Activated by defining COM_16750.
Obtained from Marvell, Semihalf.
diffstat:
sys/dev/ic/com.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++--
sys/dev/ic/comreg.h | 5 +++-
sys/dev/ic/comvar.h | 13 +++++++++++-
sys/dev/ic/ns16550reg.h | 10 ++++++++-
4 files changed, 72 insertions(+), 6 deletions(-)
diffs (163 lines):
diff -r 377ec9148aae -r cb9d63ab8856 sys/dev/ic/com.c
--- a/sys/dev/ic/com.c Sat Apr 20 11:41:51 2013 +0000
+++ b/sys/dev/ic/com.c Sat Apr 20 11:52:40 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: com.c,v 1.308 2013/02/24 06:21:36 matt Exp $ */
+/* $NetBSD: com.c,v 1.309 2013/04/20 11:52:40 rkujawa 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.308 2013/02/24 06:21:36 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.309 2013/04/20 11:52:40 rkujawa Exp $");
#include "opt_com.h"
#include "opt_ddb.h"
@@ -246,8 +246,17 @@
#define COM_REG_16550 { \
com_data, com_data, com_dlbl, com_dlbh, com_ier, com_iir, com_fifo, \
com_efr, com_lcr, com_mcr, com_lsr, com_msr }
-
+/* 16750-specific register set, additional UART status register */
+#define COM_REG_16750 { \
+ com_data, com_data, com_dlbl, com_dlbh, com_ier, com_iir, com_fifo, \
+ com_efr, com_lcr, com_mcr, com_lsr, com_msr, 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, com_usr }
+
+#ifdef COM_16750
+const bus_size_t com_std_map[32] = COM_REG_16750;
+#else
const bus_size_t com_std_map[16] = COM_REG_16550;
+#endif /* COM_16750 */
#endif /* COM_REGMAP */
#define COMUNIT_MASK 0x7ffff
@@ -1466,6 +1475,20 @@
if (!timo)
aprint_error_dev(sc->sc_dev, "com_iflush timeout %02x\n", reg);
#endif
+
+#ifdef COM_16750
+ uint8_t fifo;
+ /*
+ * Reset all Rx/Tx FIFO, preserve current FIFO length.
+ * This should prevent triggering busy interrupt while
+ * manipulating divisors.
+ */
+ fifo = CSR_READ_1(regsp, COM_REG_FIFO) & (FIFO_TRIGGER_1 |
+ FIFO_TRIGGER_4 | FIFO_TRIGGER_8 | FIFO_TRIGGER_14);
+ CSR_WRITE_1(regsp, COM_REG_FIFO, fifo | FIFO_ENABLE | FIFO_RCV_RST |
+ FIFO_XMT_RST);
+ delay(100);
+#endif
}
void
@@ -1892,6 +1915,27 @@
mutex_spin_enter(&sc->sc_lock);
iir = CSR_READ_1(regsp, COM_REG_IIR);
+
+ /* Handle ns16750-specific busy interrupt. */
+#ifdef COM_16750
+ int timeout;
+ if ((iir & IIR_BUSY) == IIR_BUSY) {
+ for (timeout = 10000;
+ (CSR_READ_1(regsp, COM_REG_USR) & 0x1) != 0; timeout--)
+ if (timeout <= 0) {
+ aprint_error_dev(sc->sc_dev,
+ "timeout while waiting for BUSY interrupt "
+ "acknowledge\n");
+ mutex_spin_exit(&sc->sc_lock);
+ return (0);
+ }
+
+ CSR_WRITE_1(regsp, COM_REG_LCR, sc->sc_lcr);
+ iir = CSR_READ_1(regsp, COM_REG_IIR);
+ }
+#endif /* COM_16750 */
+
+
if (ISSET(iir, IIR_NOPEND)) {
mutex_spin_exit(&sc->sc_lock);
return (0);
diff -r 377ec9148aae -r cb9d63ab8856 sys/dev/ic/comreg.h
--- a/sys/dev/ic/comreg.h Sat Apr 20 11:41:51 2013 +0000
+++ b/sys/dev/ic/comreg.h Sat Apr 20 11:52:40 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: comreg.h,v 1.17 2011/05/28 19:30:19 matt Exp $ */
+/* $NetBSD: comreg.h,v 1.18 2013/04/20 11:52:41 rkujawa Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@@ -62,6 +62,9 @@
#define IIR_MLSC 0x0 /* Modem status */
#define IIR_NOPEND 0x1 /* No pending interrupts */
#define IIR_FIFO_MASK 0xc0 /* set if FIFOs are enabled */
+#ifdef COM_16750
+#define IIR_BUSY 0x7 /* Busy indicator */
+#endif
/* fifo control register */
#define FIFO_ENABLE 0x01 /* Turn the FIFO on */
diff -r 377ec9148aae -r cb9d63ab8856 sys/dev/ic/comvar.h
--- a/sys/dev/ic/comvar.h Sat Apr 20 11:41:51 2013 +0000
+++ b/sys/dev/ic/comvar.h Sat Apr 20 11:52:40 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: comvar.h,v 1.73 2012/02/02 19:43:03 tls Exp $ */
+/* $NetBSD: comvar.h,v 1.74 2013/04/20 11:52:41 rkujawa Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@@ -91,16 +91,27 @@
#define COM_REG_MCR 9
#define COM_REG_LSR 10
#define COM_REG_MSR 11
+#ifdef COM_16750
+#define COM_REG_USR 31
+#endif
struct com_regs {
bus_space_tag_t cr_iot;
bus_space_handle_t cr_ioh;
bus_addr_t cr_iobase;
bus_size_t cr_nports;
+#ifdef COM_16750
+ bus_size_t cr_map[32];
+#else
bus_size_t cr_map[16];
+#endif
};
+#ifdef COM_16750
+extern const bus_size_t com_std_map[32];
+#else
extern const bus_size_t com_std_map[16];
+#endif
#define COM_INIT_REGS(regs, tag, hdl, addr) \
do { \
diff -r 377ec9148aae -r cb9d63ab8856 sys/dev/ic/ns16550reg.h
--- a/sys/dev/ic/ns16550reg.h Sat Apr 20 11:41:51 2013 +0000
+++ b/sys/dev/ic/ns16550reg.h Sat Apr 20 11:52:40 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ns16550reg.h,v 1.7 2005/12/11 12:21:28 christos Exp $ */
+/* $NetBSD: ns16550reg.h,v 1.8 2013/04/20 11:52:41 rkujawa Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@@ -47,3 +47,11 @@
#define com_lsr 5 /* line status register (R/W) */
#define com_msr 6 /* modem status register (R/W) */
#define com_scratch 7 /* scratch register (R/W) */
+
+/*
+ * Additional register present in NS16750
+ */
+#ifdef COM_16750
+#define com_usr 31 /* status register (R) */
+#endif
+
Home |
Main Index |
Thread Index |
Old Index