Source-Changes-HG archive

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

[src/trunk]: src/sys/arch attach/match separated from ixp12x0_com



details:   https://anonhg.NetBSD.org/src/rev/680099d43486
branches:  trunk
changeset: 534197:680099d43486
user:      ichiro <ichiro%NetBSD.org@localhost>
date:      Sat Jul 20 03:09:03 2002 +0000

description:
attach/match separated from ixp12x0_com
Some bug of com driver have been improved.

diffstat:

 sys/arch/arm/ixp12x0/files.ixp12x0      |    8 +-
 sys/arch/arm/ixp12x0/ixp12x0_com.c      |  740 ++++++++++++++++++++++++-------
 sys/arch/arm/ixp12x0/ixp12x0_comreg.h   |    4 +-
 sys/arch/arm/ixp12x0/ixp12x0_comvar.h   |    5 +-
 sys/arch/evbarm/conf/files.evbarm       |    7 +-
 sys/arch/evbarm/conf/files.ixm1200      |    7 +-
 sys/arch/evbarm/include/conf.h          |    3 +-
 sys/arch/evbarm/ixm1200/ixpcom_ixm.c    |  103 ++++
 sys/arch/evbarm/ixm1200/ixpcom_ixmvar.h |   41 +
 9 files changed, 743 insertions(+), 175 deletions(-)

diffs (truncated from 1261 to 300 lines):

diff -r aab79916ef0f -r 680099d43486 sys/arch/arm/ixp12x0/files.ixp12x0
--- a/sys/arch/arm/ixp12x0/files.ixp12x0        Sat Jul 20 02:41:15 2002 +0000
+++ b/sys/arch/arm/ixp12x0/files.ixp12x0        Sat Jul 20 03:09:03 2002 +0000
@@ -1,4 +1,4 @@
-#       $NetBSD: files.ixp12x0,v 1.1 2002/07/15 16:27:16 ichiro Exp $
+#       $NetBSD: files.ixp12x0,v 1.2 2002/07/20 03:09:03 ichiro Exp $
 #
 # Configuration info for Intel IXP12x0 CPU support
 #
@@ -23,9 +23,3 @@
 device ixpclk 
 attach ixpclk at ixpsip
 file   arch/arm/ixp12x0/ixp12x0_clk.c          ixpclk needs-flag
-
-# com
-device ixpcom: tty
-attach ixpcom at ixpsip
-file   arch/arm/ixp12x0/ixp12x0_com.c          ixpcom needs-flag
-file   arch/arm/ixp12x0/ixp12x0_com_io.c       ixpcom
diff -r aab79916ef0f -r 680099d43486 sys/arch/arm/ixp12x0/ixp12x0_com.c
--- a/sys/arch/arm/ixp12x0/ixp12x0_com.c        Sat Jul 20 02:41:15 2002 +0000
+++ b/sys/arch/arm/ixp12x0/ixp12x0_com.c        Sat Jul 20 03:09:03 2002 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: ixp12x0_com.c,v 1.1 2002/07/15 16:27:17 ichiro Exp $ */
-#define POLLING_COM
+/*     $NetBSD: ixp12x0_com.c,v 1.2 2002/07/20 03:09:03 ichiro Exp $ */
+#undef POLLING_COM
 /*
  * Copyright (c) 1998, 1999, 2001, 2002 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -99,8 +99,7 @@
 #include <sys/uio.h>
 #include <sys/vnode.h>
 
-#include <dev/cons.h>
-
+#include <machine/intr.h>
 #include <machine/bus.h>
 
 #include <arm/ixp12x0/ixp12x0_comreg.h>
@@ -110,8 +109,10 @@
 
 #include <arm/ixp12x0/ixpsipvar.h> 
 
+#include <dev/cons.h>
 #include "ixpcom.h"
 
+#if 0
 #ifdef POLLING_COM
 #undef CR_RIE
 #define CR_RIE 0
@@ -123,22 +124,17 @@
 #undef CR_XIE
 #define CR_XIE 0
 #endif
-
+#endif
 
 cdev_decl(ixpcom);
 
-static int     ixpcom_match(struct device *, struct cfdata *, void *);
-static void    ixpcom_attach(struct device *, struct device *, void *);
-static int     ixpcom_detach(struct device *, int);
-static int     ixpcom_activate(struct device *, enum devact);
-
 static int     ixpcomparam(struct tty *, struct termios *);
 static void    ixpcomstart(struct tty *);
 static int     ixpcomhwiflow(struct tty *, int);
 
-static void    ixpcom_attach_subr(struct ixpcom_softc *);
-
 static u_int   cflag2cr(tcflag_t);
+static void    ixpcom_iflush(struct ixpcom_softc *);
+static void    ixpcom_set_cr(struct ixpcom_softc *);
 
 int             ixpcomcngetc(dev_t);
 void            ixpcomcnputc(dev_t, int);
@@ -151,8 +147,6 @@
 void            ixpcomcnprobe(struct consdev *);
 void            ixpcomcninit(struct consdev *);
 
-static int     ixpcomintr(void* arg);
-
 u_int32_t      ixpcom_cr = 0;          /* tell cr to *_intr.c */
 u_int32_t      ixpcom_imask = 0;       /* intrrupt mask from *_intr.c */
 
@@ -163,11 +157,8 @@
 static int ixpcomconsattached;
 static int ixpcomconsrate;
 static tcflag_t ixpcomconscflag;
+static struct cnm_state ixpcom_cnm_state;
 
-struct cfattach ixpcom_ca = {
-       sizeof(struct ixpcom_softc), ixpcom_match, ixpcom_attach,
-       ixpcom_detach, ixpcom_activate
-};
 extern struct cfdriver ixpcom_cd;
 
 struct consdev ixpcomcons = {
@@ -197,45 +188,7 @@
 #define CLR(t, f)      (t) &= ~(f)
 #define ISSET(t, f)    ((t) & (f))
 
-static int
-ixpcom_match(parent, match, aux)
-       struct device *parent;
-       struct cfdata *match;
-       void *aux;
-{
-       return (1);
-}
-
-void
-ixpcom_attach(parent, self, aux)
-       struct device *parent;
-       struct device *self;
-       void *aux;
-{
-       struct ixpcom_softc *sc = (struct ixpcom_softc *)self;
-       struct ixpsip_attach_args *sa = aux;
-
-       printf("\n");
-
-        sc->sc_iot = sa->sa_iot;
-        sc->sc_baseaddr = sa->sa_addr;
-
-       if(bus_space_map(sa->sa_iot, sa->sa_addr, sa->sa_size, 0,
-                       &sc->sc_ioh)) {
-               printf("%s: unable to map registers\n", sc->sc_dev.dv_xname);
-               return;
-        }
-
-       printf("%s: IXP12x0 UART\n", sc->sc_dev.dv_xname);
-
-       ixpcom_attach_subr(sc);
-
-#ifdef POLLING_COM
-       { void* d; d = d = ixpcomintr; }
-#else
-       ixp12x0_intr_establish(IXP12X0_INTR_UART, IPL_SERIAL, ixpcomintr, sc);
-#endif
-}
+#define CFLAGS2CR_MASK (CR_PE | CR_OES | CR_SBS | CR_DSS | CR_BRD)
 
 void
 ixpcom_attach_subr(sc)
@@ -247,7 +200,7 @@
 
        if (iot == ixpcomconstag && iobase == ixpcomconsaddr) {
                ixpcomconsattached = 1;
-               sc->sc_speed = IXPCOMSPEED(ixpcomconsrate);
+               sc->sc_speed = IXPCOMSPEED2BRD(ixpcomconsrate);
 
                /* Make sure the console is always "hardwired". */
                delay(10000);   /* wait for output to finish */
@@ -311,75 +264,94 @@
        SET(sc->sc_hwflags, COM_HW_DEV_OK);
 }
 
-int
-ixpcom_detach(self, flags)
-       struct device *self;
-       int flags;
+static int
+ixpcomparam(tp, t)
+       struct tty *tp;
+       struct termios *t;
 {
-       struct ixpcom_softc *sc = (struct ixpcom_softc *)self;
-       int maj, mn;
+       struct ixpcom_softc *sc
+               = device_lookup(&ixpcom_cd, COMUNIT(tp->t_dev));
+       u_int32_t cr;
+       int s;
+
+       if (COM_ISALIVE(sc) == 0)
+               return (EIO);
+
+       cr = IXPCOMSPEED2BRD(t->c_ospeed);
+
+       if (t->c_ispeed && t->c_ispeed != t->c_ospeed)
+               return (EINVAL);
 
-       /* locate the major number */
-       for (maj = 0; maj < nchrdev; maj++)
-               if (cdevsw[maj].d_open == ixpcomopen)
-                       break;
+       /*
+        * For the console, always force CLOCAL and !HUPCL, so that the port
+        * is always active.
+        */
+       if (ISSET(sc->sc_swflags, TIOCFLAG_SOFTCAR) ||
+           ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) {
+               SET(t->c_cflag, CLOCAL);
+               CLR(t->c_cflag, HUPCL);
+       }
+
+       /*
+        * If there were no changes, don't do anything.  This avoids dropping
+        * input and improves performance when all we did was frob things like
+        * VMIN and VTIME.
+        */
+       if (tp->t_ospeed == t->c_ospeed &&
+           tp->t_cflag == t->c_cflag)
+               return (0);
+
+       cr |= cflag2cr(t->c_cflag);
 
-       /* Nuke the vnodes for any open instances. */
-       mn = self->dv_unit;
-       vdevgone(maj, mn, mn, VCHR);
+       s = splserial();
+       COM_LOCK(sc);   
+       
+       ixpcom_cr = (ixpcom_cr & ~CFLAGS2CR_MASK) | cr;
 
-       mn |= COMDIALOUT_MASK;
-       vdevgone(maj, mn, mn, VCHR);
+       /*
+        * ixpcom don't have any hardware flow control.
+        * we skip it.
+        */
+
+       /* And copy to tty. */
+       tp->t_ispeed = 0;
+       tp->t_ospeed = t->c_ospeed;
+       tp->t_cflag = t->c_cflag;
 
-       /* Free the receive buffer. */
-       free(sc->sc_rbuf, M_DEVBUF);
+       if (!sc->sc_heldchange) {
+               if (sc->sc_tx_busy) {
+                       sc->sc_heldtbc = sc->sc_tbc;
+                       sc->sc_tbc = 0;
+                       sc->sc_heldchange = 1;
+               } else
+                       ixpcom_set_cr(sc);
+       }
+
+       COM_UNLOCK(sc);
+       splx(s);
 
-       /* Detach and free the tty. */
-       tty_detach(sc->sc_tty);
-       ttyfree(sc->sc_tty);
+       /*
+        * Update the tty layer's idea of the carrier bit.
+        * We tell tty the carrier is always on.
+        */
+       (void) (*tp->t_linesw->l_modem)(tp, 1);
 
-#if NRND > 0 && defined(RND_COM)
-       /* Unhook the entropy source. */
-       rnd_detach_source(&sc->rnd_source);
+#ifdef COM_DEBUG
+       if (com_debug)
+               comstatus(sc, "comparam ");
 #endif
 
+       if (!ISSET(t->c_cflag, CHWFLOW)) {
+               if (sc->sc_tx_stopped) {
+                       sc->sc_tx_stopped = 0;
+                       ixpcomstart(tp);
+               }
+       }
+
        return (0);
 }
 
-int
-ixpcom_activate(self, act)
-       struct device *self;
-       enum devact act;
-{
-       struct ixpcom_softc *sc = (struct ixpcom_softc *)self;
-       int s, rv = 0;
-
-       s = splserial();
-       COM_LOCK(sc);
-       switch (act) {
-       case DVACT_ACTIVATE:
-               rv = EOPNOTSUPP;
-               break;
-       case DVACT_DEACTIVATE:
-               if (sc->sc_hwflags & (COM_HW_CONSOLE|COM_HW_KGDB))
-                       rv = EBUSY;
-               break;
-       }
-
-       COM_UNLOCK(sc); 
-       splx(s);
-       return (rv);
-}
-
-int
-ixpcomparam(tp, t)
-       struct tty *tp;
-       struct termios *t;
-{
-       return (0);



Home | Main Index | Thread Index | Old Index