Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/mips/alchemy/dev Add a slightly modified dev/ic/com...



details:   https://anonhg.NetBSD.org/src/rev/b6914e701467
branches:  trunk
changeset: 534562:b6914e701467
user:      simonb <simonb%NetBSD.org@localhost>
date:      Mon Jul 29 15:42:41 2002 +0000

description:
Add a slightly modified dev/ic/com.c that supports the Alchemy
Semiconductor Au1x00 series on-chip UARTs.  Will be merged with
the original com.c driver once a few issues are tidied up.  Main
differences from a standard 16550 UART are:
 - separate rxdata and txdata registers
 - single 16-bit register for the clock divisor
 - "enable uart" register

diffstat:

 sys/arch/mips/alchemy/dev/aucom.c    |  2515 ++++++++++++++++++++++++++++++++++
 sys/arch/mips/alchemy/dev/aucomreg.h |    41 +
 sys/arch/mips/alchemy/dev/aucomvar.h |    29 +
 3 files changed, 2585 insertions(+), 0 deletions(-)

diffs (truncated from 2597 to 300 lines):

diff -r aa16f7780b38 -r b6914e701467 sys/arch/mips/alchemy/dev/aucom.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mips/alchemy/dev/aucom.c Mon Jul 29 15:42:41 2002 +0000
@@ -0,0 +1,2515 @@
+#define        AU1x00_UART     /* XXX */
+
+/*     $NetBSD: aucom.c,v 1.1 2002/07/29 15:42:41 simonb Exp $ */
+
+/*-
+ * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)com.c       7.5 (Berkeley) 5/16/91
+ */
+
+/*
+ * COM driver, uses National Semiconductor NS16450/NS16550AF UART
+ * Supports automatic hardware flow control on StarTech ST16C650A UART
+ *
+ * XXX: hacked to work with almost 16550-alike Alchemy Au1X00 on-chip uarts
+ */
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: aucom.c,v 1.1 2002/07/29 15:42:41 simonb Exp $");
+
+#include "opt_com.h"
+#include "opt_ddb.h"
+#include "opt_kgdb.h"
+
+#include "rnd.h"
+#if NRND > 0 && defined(RND_COM)
+#include <sys/rnd.h>
+#endif
+
+/*
+ * Override cnmagic(9) macro before including <sys/systm.h>.
+ * We need to know if cn_check_magic triggered debugger, so set a flag.
+ * Callers of cn_check_magic must declare int cn_trapped = 0;
+ * XXX: this is *ugly*!
+ */
+#define cn_trap()                              \
+       do {                                    \
+               console_debugger();             \
+               cn_trapped = 1;                 \
+       } while (/* CONSTCOND */ 0)
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/ioctl.h>
+#include <sys/select.h>
+#include <sys/tty.h>
+#include <sys/proc.h>
+#include <sys/user.h>
+#include <sys/conf.h>
+#include <sys/file.h>
+#include <sys/uio.h>
+#include <sys/kernel.h>
+#include <sys/syslog.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/timepps.h>
+#include <sys/vnode.h>
+
+#include <machine/intr.h>
+#include <machine/bus.h>
+
+#ifdef AU1x00_UART
+#include <mips/alchemy/include/aureg.h>
+#include <mips/alchemy/dev/aucomreg.h>
+#include <mips/alchemy/dev/aucomvar.h>
+#else  /* AU1x00_UART */
+#include <dev/ic/comreg.h>
+#include <dev/ic/comvar.h>
+#include <dev/ic/ns16550reg.h>
+#include <dev/ic/st16650reg.h>
+#ifdef COM_HAYESP
+#include <dev/ic/hayespreg.h>
+#endif
+#endif /* AU1x00_UART */
+
+#define        com_lcr com_cfcr
+#include <dev/cons.h>
+
+#ifdef AU1x00_UART
+/* Renamed local functions (from cdev_decl) */
+#define        comopen         aucomopen
+#define        comclose        aucomclose
+#define        comread         aucomread
+#define        comwrite        aucomwrite
+#define        comioctl        aucomioctl
+#define        comstop         aucomstop
+#define        comtty          aucomtty
+#define        compoll         aucompoll
+
+/* Renamed local functions (could be made static) */
+#define        com_config              aucom_config
+#define        com_shutdown            aucom_shutdown
+#define        comspeed                aucomspeed
+#define        cflag2lcr               aucflag2lcr
+#define        comparam                aucomparam
+#define        comstart                aucomstart
+#define        comhwiflow              aucomhwiflow
+#define        com_loadchannelregs     aucom_loadchannelregs
+#define        com_hwiflow             aucom_hwiflow
+#define        com_break               aucom_break
+#define        com_modem               aucom_modem
+#define        tiocm_to_com            autiocm_to_com
+#define        com_to_tiocm            aucom_to_tiocm
+#define        com_iflush              aucom_iflush
+#define        com_common_getc         aucom_common_getc
+#define        com_common_putc         aucom_common_putc
+#define        cominit                 aucominit
+#define        comcngetc               aucomcngetc
+#define        comcnputc               aucomcnputc
+#define        comcnpollc              aucomcnpollc
+#define        comsoft                 aucomsoft
+#define        comdiag                 aucomdiag
+#define        comstatus               aucomstatus
+#define        comprobeHAYESP          aucomprobeHAYESP
+
+/* Renamed local variables (could be made static) */
+#define        comsoft_callout aucomsoft_callout
+#endif /* AU1x00_UART */
+
+#ifdef COM_HAYESP
+int comprobeHAYESP(bus_space_handle_t hayespioh, struct com_softc *sc);
+#endif
+
+static void com_enable_debugport(struct com_softc *);
+
+void   com_config(struct com_softc *);
+void   com_shutdown(struct com_softc *);
+int    comspeed(long, long);
+static u_char  cflag2lcr(tcflag_t);
+int    comparam(struct tty *, struct termios *);
+void   comstart(struct tty *);
+int    comhwiflow(struct tty *, int);
+
+void   com_loadchannelregs(struct com_softc *);
+void   com_hwiflow(struct com_softc *);
+void   com_break(struct com_softc *, int);
+void   com_modem(struct com_softc *, int);
+void   tiocm_to_com(struct com_softc *, u_long, int);
+int    com_to_tiocm(struct com_softc *);
+void   com_iflush(struct com_softc *);
+
+int    com_common_getc(dev_t, bus_space_tag_t, bus_space_handle_t);
+void   com_common_putc(dev_t, bus_space_tag_t, bus_space_handle_t, int);
+
+int    cominit(bus_space_tag_t, bus_addr_t, int, int, tcflag_t,
+                                    bus_space_handle_t *);
+
+/* XXX: This belongs elsewhere */
+cdev_decl(com);
+
+int    comcngetc(dev_t);
+void   comcnputc(dev_t, int);
+void   comcnpollc(dev_t, int);
+
+#define        integrate       static inline
+#ifdef __HAVE_GENERIC_SOFT_INTERRUPTS
+void   comsoft(void *);
+#else
+#ifndef __NO_SOFT_SERIAL_INTERRUPT
+void   comsoft(void);
+#else
+void   comsoft(void *);
+struct callout comsoft_callout = CALLOUT_INITIALIZER;
+#endif
+#endif
+integrate void com_rxsoft(struct com_softc *, struct tty *);
+integrate void com_txsoft(struct com_softc *, struct tty *);
+integrate void com_stsoft(struct com_softc *, struct tty *);
+integrate void com_schedrx(struct com_softc *);
+void   comdiag(void *);
+
+extern struct cfdriver com_cd;
+
+/*
+ * Make this an option variable one can patch.
+ * But be warned:  this must be a power of 2!
+ */
+u_int com_rbuf_size = COM_RING_SIZE;
+
+/* Stop input when 3/4 of the ring is full; restart when only 1/4 is full. */
+u_int com_rbuf_hiwat = (COM_RING_SIZE * 1) / 4;
+u_int com_rbuf_lowat = (COM_RING_SIZE * 3) / 4;
+
+static bus_addr_t      comconsaddr;
+static bus_space_tag_t comconstag;
+static bus_space_handle_t comconsioh;
+static int     comconsattached;
+static int comconsrate;
+static tcflag_t comconscflag;
+static struct cnm_state com_cnm_state;
+
+static int ppscap =
+       PPS_TSFMT_TSPEC |
+       PPS_CAPTUREASSERT | 
+       PPS_CAPTURECLEAR |
+#ifdef  PPS_SYNC 
+       PPS_HARDPPSONASSERT | PPS_HARDPPSONCLEAR |
+#endif /* PPS_SYNC */
+       PPS_OFFSETASSERT | PPS_OFFSETCLEAR;
+
+#ifndef __HAVE_GENERIC_SOFT_INTERRUPTS
+#ifdef __NO_SOFT_SERIAL_INTERRUPT
+volatile int   com_softintr_scheduled;
+#endif
+#endif
+
+#ifdef KGDB
+#include <sys/kgdb.h>
+
+static bus_addr_t com_kgdb_addr;
+static bus_space_tag_t com_kgdb_iot;
+static bus_space_handle_t com_kgdb_ioh;
+static int com_kgdb_attached;
+
+int    com_kgdb_getc(void *);
+void   com_kgdb_putc(void *, int);
+#endif /* KGDB */
+
+#define        COMUNIT_MASK    0x7ffff
+#define        COMDIALOUT_MASK 0x80000
+
+#define        COMUNIT(x)      (minor(x) & COMUNIT_MASK)
+#define        COMDIALOUT(x)   (minor(x) & COMDIALOUT_MASK)
+
+#define        COM_ISALIVE(sc) ((sc)->enabled != 0 && \
+                        ISSET((sc)->sc_dev.dv_flags, DVF_ACTIVE))
+
+#define        BR      BUS_SPACE_BARRIER_READ
+#define        BW      BUS_SPACE_BARRIER_WRITE
+#define COM_BARRIER(t, h, f) bus_space_barrier((t), (h), 0, COM_NPORTS, (f))
+
+#if (defined(MULTIPROCESSOR) || defined(LOCKDEBUG)) && defined(COM_MPLOCK)



Home | Main Index | Thread Index | Old Index