Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/macppc/dev * Access hardware directly in zscn* inst...



details:   https://anonhg.NetBSD.org/src/rev/af9db338eb2e
branches:  trunk
changeset: 487424:af9db338eb2e
user:      tsubai <tsubai%NetBSD.org@localhost>
date:      Wed Jun 07 17:37:07 2000 +0000

description:
* Access hardware directly in zscn* instead of calling OF.
* Clean up.

diffstat:

 sys/arch/macppc/dev/zs.c |  70 +++++++++++++++++------------------------------
 1 files changed, 25 insertions(+), 45 deletions(-)

diffs (150 lines):

diff -r c508f1c660fd -r af9db338eb2e sys/arch/macppc/dev/zs.c
--- a/sys/arch/macppc/dev/zs.c  Wed Jun 07 17:28:52 2000 +0000
+++ b/sys/arch/macppc/dev/zs.c  Wed Jun 07 17:37:07 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zs.c,v 1.14 2000/03/06 21:36:09 thorpej Exp $  */
+/*     $NetBSD: zs.c,v 1.15 2000/06/07 17:37:07 tsubai Exp $   */
 
 /*
  * Copyright (c) 1996, 1998 Bill Studenmund
@@ -111,9 +111,6 @@
        struct  zschan zs_chan_a;
 };
 
-/* Saved PROM mappings */
-static struct zsdevice *zsaddr[2];
-
 /* Flags from cninit() */
 static int zs_hwflags[NZSC][2];
 /* Default speed for each channel */
@@ -121,9 +118,9 @@
        { 38400,        /* tty00 */
          38400 },      /* tty01 */
 };
+
 /* console stuff */
 void   *zs_conschan = 0;
-int    zs_consunit;
 #ifdef ZS_CONSOLE_ABORT
 int    zs_cons_canabort = 1;
 #else
@@ -133,7 +130,6 @@
 /* device to which the console is attached--if serial. */
 /* Mac stuff */
 
-static struct zschan *zs_get_chan_addr __P((int zsc_unit, int channel));
 static int zs_get_speed __P((struct zs_chanstate *));
 
 /*
@@ -162,27 +158,6 @@
        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 >= 1)
-               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
  ****************************************************************/
@@ -249,15 +224,17 @@
        volatile struct zschan *zc;
        struct xzs_chanstate *xcs;
        struct zs_chanstate *cs;
+       struct zsdevice *zsd;
        int zsc_unit, channel;
        int s, chip, theflags;
        int node, intr[2][3];
        u_int regs[6];
 
+       chip = 0;
        zsc_unit = zsc->zsc_dev.dv_unit;
 
        ca->ca_reg[0] += ca->ca_baseaddr;
-       zsaddr[0] = mapiodev(ca->ca_reg[0], ca->ca_reg[1]);
+       zsd = mapiodev(ca->ca_reg[0], ca->ca_reg[1]);
 
        node = OF_child(ca->ca_node);   /* ch-a */
 
@@ -288,16 +265,6 @@
 
        printf(": irq %d,%d\n", intr[0][0], intr[1][0]);
 
-       /* Make sure everything's inited ok. */
-       if (zsaddr[zsc_unit] == NULL)
-               panic("zs_attach: zs%d not mapped\n", zsc_unit);
-
-       if ((zs_hwflags[zsc_unit][0] | zs_hwflags[zsc_unit][1]) &
-               ZS_HWFLAG_CONSOLE) {
-
-               zs_conschan = zs_get_chan_addr(zsc_unit, minor(cn_tab->cn_dev));
-       }
-
        /*
         * Initialize software state for each channel.
         */
@@ -312,7 +279,8 @@
                cs->cs_private = NULL;
                cs->cs_ops = &zsops_null;
 
-               zc = zs_get_chan_addr(zsc_unit, channel);
+               zc = (channel == 0) ? &zsd->zs_chan_a : &zsd->zs_chan_b;
+
                cs->cs_reg_csr  = &zc->zc_csr;
                cs->cs_reg_data = &zc->zc_data;
 
@@ -1134,19 +1102,31 @@
 zscninit(cp)
        struct consdev *cp;
 {
-       int pkg;
-       int unit = 0;
+       int escc, escc_ch, obio, zs_offset;
+       int ch = 0;
+       u_int32_t reg[5];
        char name[16];
 
-       if ((pkg = OF_instance_to_package(stdin)) == -1)
+       if ((escc_ch = OF_instance_to_package(stdin)) == -1)
                return;
 
        bzero(name, sizeof(name));
-       if (OF_getprop(pkg, "name", name, sizeof(name)) == -1)
+       if (OF_getprop(escc_ch, "name", name, sizeof(name)) == -1)
                return;
 
        if (strcmp(name, "ch-b") == 0)
-               unit = 1;
+               ch = 1;
+
+       if (OF_getprop(escc_ch, "reg", reg, sizeof(reg)) < 4)
+               return;
+       zs_offset = reg[0];
 
-       zs_hwflags[0][unit] = ZS_HWFLAG_CONSOLE;
+       escc = OF_parent(escc_ch);
+       obio = OF_parent(escc);
+
+       if (OF_getprop(obio, "assigned-addresses", reg, sizeof(reg)) < 12)
+               return;
+       zs_conschan = (void *)(reg[2] + zs_offset);
+
+       zs_hwflags[0][ch] = ZS_HWFLAG_CONSOLE;
 }



Home | Main Index | Thread Index | Old Index