Source-Changes-HG archive

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

[src/netbsd-1-5]: src/sys/arch/news68k/dev Pull up revision 1.5 (requested by...



details:   https://anonhg.NetBSD.org/src/rev/1d7e78c3ef8b
branches:  netbsd-1-5
changeset: 490373:1d7e78c3ef8b
user:      he <he%NetBSD.org@localhost>
date:      Fri Dec 15 04:20:27 2000 +0000

description:
Pull up revision 1.5 (requested by tsutsui):
  Initialize zs chip in zscninit() so that the kernel can use serial
  console even if the PROM uses bitmap console.  Remove some dead
  code.  Use BPS_TO_TCONST() to initialize baudrate.

diffstat:

 sys/arch/news68k/dev/zs.c |  159 ++++++++++++++++++++++-----------------------
 1 files changed, 78 insertions(+), 81 deletions(-)

diffs (truncated from 332 to 300 lines):

diff -r 5097a60d5236 -r 1d7e78c3ef8b sys/arch/news68k/dev/zs.c
--- a/sys/arch/news68k/dev/zs.c Fri Dec 15 04:11:25 2000 +0000
+++ b/sys/arch/news68k/dev/zs.c Fri Dec 15 04:20:27 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zs.c,v 1.4 2000/03/06 21:36:10 thorpej Exp $   */
+/*     $NetBSD: zs.c,v 1.4.4.1 2000/12/15 04:20:27 he Exp $    */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -63,17 +63,6 @@
 
 #include <news68k/dev/hbvar.h>
 
-#include "zsc.h"       /* NZSC */
-#define NZS NZSC
-
-/* Make life easier for the initialized arrays here. */
-#if NZS < 2
-#undef  NZS
-#define NZS 2
-#endif
-
-struct zschan *zs_get_chan_addr __P((int, int));
-
 int zs_getc __P((void *));
 void zs_putc __P((void *, int));
 
@@ -120,15 +109,16 @@
        struct  zschan zs_chan_a;
 };
 
-static struct zsdevice *zsaddr[NZS];
 static u_char zs_sir;
 
-/* Flags from cninit() */
-static int zs_hwflags[NZS][2];
-
 /* Default speed for all channels */
 static int zs_defspeed = 9600;
 
+/* console status from cninit */
+static struct zs_chanstate zs_conschan_store;
+static struct zs_chanstate *zs_conschan;
+static struct zschan *zc_cons;
+
 static u_char zs_init_reg[16] = {
        0,      /* 0: CMD (reset, etc.) */
        0,      /* 1: No interrupts yet. */
@@ -142,32 +132,12 @@
        ZSWR9_MASTER_IE,
        0,      /*10: Misc. TX/RX control bits */
        ZSWR11_TXCLK_BAUD | ZSWR11_RXCLK_BAUD,
-       ((PCLK0/32)/9600)-2,    /*12: BAUDLO (default=9600) */
+       BPS_TO_TCONST((PCLK0/16), 9600), /*12: BAUDLO (default=9600) */
        0,                      /*13: BAUDHI (default=9600) */
        ZSWR14_BAUD_ENA | ZSWR14_BAUD_FROM_PCLK,
        ZSWR15_BREAK_IE,
 };
 
-struct zschan *
-zs_get_chan_addr(zs_unit, channel)
-       int zs_unit, channel;
-{
-       struct zsdevice *addr;
-       struct zschan *zc;
-
-       if (zs_unit >= NZS)
-               return NULL;
-       addr = zsaddr[zs_unit];
-       if (addr == NULL)
-               return NULL;
-       if (channel == 0) {
-               zc = &addr->zs_chan_a;
-       } else {
-               zc = &addr->zs_chan_b;
-       }
-       return (zc);
-}
-
 
 /****************************************************************
  * Autoconfig
@@ -185,8 +155,10 @@
 extern struct cfdriver zsc_cd;
 
 static int zshard __P((void *));
-int zssoft __P((void *));
+void zssoft __P((void *));
+#if 0
 static int zs_get_speed __P((struct zs_chanstate *));
+#endif
 
 /*
  * Is the zs chip present?
@@ -217,9 +189,6 @@
 
 /*
  * Attach a found zs.
- *
- * Match slave number to zs unit number, so that misconfiguration will
- * not set up the keyboard as ttya, etc.
  */
 static void
 zs_attach(parent, self, aux)
@@ -231,12 +200,12 @@
        struct cfdata *cf = self->dv_cfdata;
        struct hb_attach_args *ha = aux;
        struct zsc_attach_args zsc_args;
-       volatile struct zschan *zc;
+       struct zsdevice *zs;
+       struct zschan *zc;
        struct zs_chanstate *cs;
-       int s, zs_unit, channel, clk;
+       int s, channel, clk;
 
-       zs_unit = zsc->zsc_dev.dv_unit;
-       zsaddr[zs_unit] = (void *)IIOV(ha->ha_address);
+       zs = (void *)IIOV(ha->ha_address);
 
        clk = cf->cf_flags;
        if (clk < 0 || clk >= NPCLK)
@@ -249,32 +218,33 @@
         */
        for (channel = 0; channel < 2; channel++) {
                zsc_args.channel = channel;
-               zsc_args.hwflags = zs_hwflags[zs_unit][channel];
                cs = &zsc->zsc_cs_store[channel];
                zsc->zsc_cs[channel] = cs;
+               zc = (channel == 0) ? &zs->zs_chan_a : &zs->zs_chan_b;
+
+               if (ha->ha_vect != -1)
+                       zs_init_reg[2] = ha->ha_vect;
+
+               if (zc == zc_cons) {
+                       bcopy(zs_conschan, cs, sizeof(struct zs_chanstate));
+                       zs_conschan = cs;
+                       zsc_args.hwflags = ZS_HWFLAG_CONSOLE;
+               } else {
+                       cs->cs_reg_csr  = &zc->zc_csr;
+                       cs->cs_reg_data = &zc->zc_data;
+                       bcopy(zs_init_reg, cs->cs_creg, 16);
+                       bcopy(zs_init_reg, cs->cs_preg, 16);
+                       cs->cs_defspeed = zs_defspeed;
+                       zsc_args.hwflags = 0;
+               }
+
+               cs->cs_defcflag = zs_def_cflag;
 
                cs->cs_channel = channel;
                cs->cs_private = NULL;
                cs->cs_ops = &zsops_null;
                cs->cs_brg_clk = pclk[clk] / 16;
 
-               zc = zs_get_chan_addr(zs_unit, channel);
-               cs->cs_reg_csr  = &zc->zc_csr;
-               cs->cs_reg_data = &zc->zc_data;
-
-               if (ha->ha_vect != -1)
-                       zs_init_reg[2] = ha->ha_vect;
-               bcopy(zs_init_reg, cs->cs_creg, 16);
-               bcopy(zs_init_reg, cs->cs_preg, 16);
-
-               /* XXX: Get these from the EEPROM instead? */
-               /* XXX: See the mvme167 code.  Better. */
-               if (zsc_args.hwflags & ZS_HWFLAG_CONSOLE)
-                       cs->cs_defspeed = zs_get_speed(cs);
-               else
-                       cs->cs_defspeed = zs_defspeed;
-               cs->cs_defcflag = zs_def_cflag;
-
                /* Make these correspond to cs_defcflag (-crtscts) */
                cs->cs_rr0_dcd = ZSRR0_DCD;
                cs->cs_rr0_cts = 0;
@@ -324,7 +294,7 @@
        splx(s);
 
        if (zs_sir == 0)
-               zs_sir = allocate_sir((void (*) __P((void *)))zssoft, zsc);
+               zs_sir = allocate_sir(zssoft, zsc);
 }
 
 static int
@@ -367,7 +337,7 @@
 /*
  * Shared among the all chips. We have to look at all of them.
  */
-int
+void
 zssoft(arg)
        void *arg;
 {
@@ -383,13 +353,12 @@
                (void) zsc_intr_soft(zsc);
        }
        splx(s);
-
-       return 1;
 }
 
 /*
  * Compute the current baud rate given a ZS channel.
  */
+#if 0
 static int
 zs_get_speed(cs)
        struct zs_chanstate *cs;
@@ -400,6 +369,7 @@
        tconst |= zs_read_reg(cs, 13) << 8;
        return (TCONST_TO_BPS(cs->cs_brg_clk, tconst));
 }
+#endif
 
 /*
  * MD functions for setting the baud rate and control modes.
@@ -564,17 +534,17 @@
 zs_getc(arg)
        void *arg;
 {
-       volatile struct zschan *zc = arg;
+       struct zs_chanstate *cs = arg;
        int s, c, rr0;
 
        s = splhigh();
        /* Wait for a character to arrive. */
        do {
-               rr0 = zc->zc_csr;
+               rr0 = *cs->cs_reg_csr;
                ZS_DELAY();
        } while ((rr0 & ZSRR0_RX_READY) == 0);
 
-       c = zc->zc_data;
+       c = *cs->cs_reg_data;
        ZS_DELAY();
        splx(s);
 
@@ -589,17 +559,17 @@
        void *arg;
        int c;
 {
-       volatile struct zschan *zc = arg;
+       struct zs_chanstate *cs = arg;
        int s, rr0;
 
        s = splhigh();
        /* Wait for transmitter to become ready. */
        do {
-               rr0 = zc->zc_csr;
+               rr0 = *cs->cs_reg_csr;
                ZS_DELAY();
        } while ((rr0 & ZSRR0_TX_READY) == 0);
 
-       zc->zc_data = c;
+       *cs->cs_reg_data = c;
        ZS_DELAY();
        splx(s);
 }
@@ -611,8 +581,6 @@
 static int  zscngetc __P((dev_t));
 static void zscnputc __P((dev_t, int));
 
-static void *zs_conschan;
-
 struct consdev consdev_zs = {
        zscnprobe,
        zscninit,
@@ -626,25 +594,54 @@
 zscnprobe(cn)
        struct consdev *cn;
 {
+       extern int tty00_is_console;
+
+       cn->cn_dev = makedev(zs_major, 0);
+       if (tty00_is_console)
+               cn->cn_pri = CN_REMOTE;
+       else
+               cn->cn_pri = CN_NORMAL;
 }
 
 static void
 zscninit(cn)
        struct consdev *cn;
 {
+       struct zs_chanstate *cs;
+
        extern volatile u_char *sccport0a;
 
-       cn->cn_dev = makedev(zs_major, 0);
-       cn->cn_pri = CN_REMOTE;
-       zs_hwflags[0][0] = ZS_HWFLAG_CONSOLE;
-       zs_conschan = (void *)sccport0a; /* XXX */
+       zc_cons = (struct zschan *)sccport0a; /* XXX */
+
+       zs_conschan = cs = &zs_conschan_store;
+
+       /* Setup temporary chanstate. */
+       cs->cs_reg_csr  = &zc_cons->zc_csr;
+       cs->cs_reg_data = &zc_cons->zc_data;
+
+       /* Initialize the pending registers. */
+       bcopy(zs_init_reg, cs->cs_preg, 16);



Home | Main Index | Thread Index | Old Index