Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Move the Marvell extension to com_mv.c.
details: https://anonhg.NetBSD.org/src/rev/54e5503681c7
branches: trunk
changeset: 789669:54e5503681c7
user: kiyohara <kiyohara%NetBSD.org@localhost>
date: Sun Sep 01 04:51:24 2013 +0000
description:
Move the Marvell extension to com_mv.c.
diffstat:
sys/dev/ic/com.c | 63 ++++++----------------------
sys/dev/ic/comreg.h | 7 +-
sys/dev/ic/comvar.h | 17 +------
sys/dev/ic/ns16550reg.h | 10 +----
sys/dev/marvell/com_mv.c | 102 ++++++++++++++++++++++++++++++++++++++++------
5 files changed, 109 insertions(+), 90 deletions(-)
diffs (truncated from 373 to 300 lines):
diff -r cee3b46fcc6c -r 54e5503681c7 sys/dev/ic/com.c
--- a/sys/dev/ic/com.c Sat Aug 31 15:01:08 2013 +0000
+++ b/sys/dev/ic/com.c Sun Sep 01 04:51:24 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: com.c,v 1.312 2013/07/27 06:54:35 kiyohara Exp $ */
+/* $NetBSD: com.c,v 1.313 2013/09/01 04:51:24 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.312 2013/07/27 06:54:35 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.313 2013/09/01 04:51:24 kiyohara Exp $");
#include "opt_com.h"
#include "opt_ddb.h"
@@ -246,17 +246,7 @@
#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
@@ -416,10 +406,7 @@
(u_long)comcons_info.regs.cr_iobase);
}
-#ifdef COM_16750
- /* Use in comintr(). */
sc->sc_lcr = cflag2lcr(comcons_info.cflag);
-#endif
/* Make sure the console is always "hardwired". */
delay(10000); /* wait for output to finish */
@@ -1479,19 +1466,19 @@
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
+ if (sc->sc_type == COM_TYPE_ARMADAXP) {
+ 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);
+ }
}
void
@@ -1919,26 +1906,6 @@
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 cee3b46fcc6c -r 54e5503681c7 sys/dev/ic/comreg.h
--- a/sys/dev/ic/comreg.h Sat Aug 31 15:01:08 2013 +0000
+++ b/sys/dev/ic/comreg.h Sun Sep 01 04:51:24 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: comreg.h,v 1.18 2013/04/20 11:52:41 rkujawa Exp $ */
+/* $NetBSD: comreg.h,v 1.19 2013/09/01 04:51:24 kiyohara Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@@ -56,15 +56,14 @@
/* interrupt identification register */
#define IIR_IMASK 0xf
#define IIR_RXTOUT 0xc
+/* ARMADAXP's ns16550 ports have extra value in this register */
+#define IIR_BUSY 0x7 /* Busy indicator */
#define IIR_RLS 0x6 /* Line status change */
#define IIR_RXRDY 0x4 /* Receiver ready */
#define IIR_TXRDY 0x2 /* Transmitter ready */
#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 cee3b46fcc6c -r 54e5503681c7 sys/dev/ic/comvar.h
--- a/sys/dev/ic/comvar.h Sat Aug 31 15:01:08 2013 +0000
+++ b/sys/dev/ic/comvar.h Sun Sep 01 04:51:24 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: comvar.h,v 1.75 2013/07/17 19:51:56 soren Exp $ */
+/* $NetBSD: comvar.h,v 1.76 2013/09/01 04:51:24 kiyohara Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@@ -91,27 +91,16 @@
#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 { \
@@ -138,9 +127,6 @@
#define COM_REG_TCR com_msr
#define COM_REG_TLR com_scratch
#define COM_REG_MDR1 8
-#ifdef COM_16750
-#define COM_REG_USR com_usr
-#endif
struct com_regs {
bus_space_tag_t cr_iot;
@@ -233,6 +219,7 @@
#define COM_TYPE_AU1x00 3 /* AMD/Alchemy Au1x000 proc. built-in */
#define COM_TYPE_OMAP 4 /* TI OMAP processor built-in */
#define COM_TYPE_16550_NOERS 5 /* like a 16550, no ERS */
+#define COM_TYPE_ARMADAXP 6 /* Marvell ARMADA XP proc. built-in */
/* power management hooks */
int (*enable)(struct com_softc *);
diff -r cee3b46fcc6c -r 54e5503681c7 sys/dev/ic/ns16550reg.h
--- a/sys/dev/ic/ns16550reg.h Sat Aug 31 15:01:08 2013 +0000
+++ b/sys/dev/ic/ns16550reg.h Sun Sep 01 04:51:24 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ns16550reg.h,v 1.8 2013/04/20 11:52:41 rkujawa Exp $ */
+/* $NetBSD: ns16550reg.h,v 1.9 2013/09/01 04:51:24 kiyohara Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@@ -47,11 +47,3 @@
#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
-
diff -r cee3b46fcc6c -r 54e5503681c7 sys/dev/marvell/com_mv.c
--- a/sys/dev/marvell/com_mv.c Sat Aug 31 15:01:08 2013 +0000
+++ b/sys/dev/marvell/com_mv.c Sun Sep 01 04:51:24 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: com_mv.c,v 1.5 2011/01/28 16:12:22 jakllsch Exp $ */
+/* $NetBSD: com_mv.c,v 1.6 2013/09/01 04:51:24 kiyohara Exp $ */
/*
* Copyright (c) 2007, 2010 KIYOHARA Takashi
* All rights reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: com_mv.c,v 1.5 2011/01/28 16:12:22 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com_mv.c,v 1.6 2013/09/01 04:51:24 kiyohara Exp $");
#include "opt_com.h"
@@ -34,6 +34,7 @@
#include <sys/bus.h>
#include <sys/device.h>
#include <sys/errno.h>
+#include <sys/mutex.h>
#include <sys/termios.h>
#include <dev/marvell/gtvar.h>
@@ -44,34 +45,56 @@
#include <prop/proplib.h>
-#define MVUART_SIZE 0x20
+#define MVUART_SIZE 0x80
+
+#define MVUART_REG_USR 0x7c /* XXXX: What is this??? */
static int mvuart_match(device_t, struct cfdata *, void *);
static void mvuart_attach(device_t, device_t, void *);
+static int mvuart_intr(void *);
+
CFATTACH_DECL_NEW(mvuart_gt, sizeof(struct com_softc),
mvuart_match, mvuart_attach, NULL, NULL);
CFATTACH_DECL_NEW(mvuart_mbus, sizeof(struct com_softc),
mvuart_match, mvuart_attach, NULL, NULL);
#ifdef COM_REGMAP
-#define MVUART_INIT_REGS(regs, tag, hdl, addr, size) \
- do { \
- int i; \
- \
- regs.cr_iot = tag; \
- regs.cr_ioh = hdl; \
- regs.cr_iobase = addr; \
- regs.cr_nports = size; \
- for (i = 0; i < __arraycount(regs.cr_map); i++) \
- regs.cr_map[i] = com_std_map[i] << 2; \
+#define MVUART_INIT_REGS(regs, tag, hdl, addr, size) \
+ do { \
+ int _i; \
+ \
+ regs.cr_iot = tag; \
+ regs.cr_ioh = hdl; \
+ regs.cr_iobase = addr; \
+ regs.cr_nports = size; \
+ for (_i = 0; _i < __arraycount(regs.cr_map); _i++) \
+ regs.cr_map[_i] = com_std_map[_i] << 2; \
} while (0)
+#define CSR_WRITE_1(r, o, v) \
+ bus_space_write_1((r)->cr_iot, (r)->cr_ioh, (r)->cr_map[o], v)
+#define CSR_READ_1(r, o) \
+ bus_space_read_1((r)->cr_iot, (r)->cr_ioh, (r)->cr_map[o])
#else
#define MVUART_INIT_REGS(regs, tag, hdl, addr, size) \
COM_INIT_REGS(regs, tag, hdl, addr)
+#define CSR_WRITE_1(r, o, v) \
+ bus_space_write_1((r)->cr_iot, (r)->cr_ioh, o, v)
+#define CSR_READ_1(r, o) \
+ bus_space_read_1((r)->cr_iot, (r)->cr_ioh, o)
#endif
+struct {
+ int model;
+ int type;
+} mvuart_extensions[] = {
+ { MARVELL_ARMADAXP_MV78130, COM_TYPE_ARMADAXP },
+ { MARVELL_ARMADAXP_MV78160, COM_TYPE_ARMADAXP },
+ { MARVELL_ARMADAXP_MV78230, COM_TYPE_ARMADAXP },
+ { MARVELL_ARMADAXP_MV78260, COM_TYPE_ARMADAXP },
+ { MARVELL_ARMADAXP_MV78460, COM_TYPE_ARMADAXP },
Home |
Main Index |
Thread Index |
Old Index