use a global variable to ensure that only one instance is configured

rather than requiring that its unit number be zero.
simplify by not pretending that powermacs can have more than 1 zsc.
This commit is contained in:
chs 2005-01-10 16:38:06 +00:00
parent 35cacfdeb8
commit d65ac815a8
1 changed files with 16 additions and 29 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: zs.c,v 1.30 2005/01/10 16:34:46 chs Exp $ */ /* $NetBSD: zs.c,v 1.31 2005/01/10 16:38:06 chs Exp $ */
/* /*
* Copyright (c) 1996, 1998 Bill Studenmund * Copyright (c) 1996, 1998 Bill Studenmund
@ -54,7 +54,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.30 2005/01/10 16:34:46 chs Exp $"); __KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.31 2005/01/10 16:38:06 chs Exp $");
#include "opt_ddb.h" #include "opt_ddb.h"
#include "opt_kgdb.h" #include "opt_kgdb.h"
@ -88,8 +88,6 @@ __KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.30 2005/01/10 16:34:46 chs Exp $");
#define ZSMAC_RAW 0x01 #define ZSMAC_RAW 0x01
#define ZSMAC_LOCALTALK 0x02 #define ZSMAC_LOCALTALK 0x02
#include "zsc.h" /* get the # of zs chips defined */
/* /*
* Some warts needed by z8530tty.c - * Some warts needed by z8530tty.c -
*/ */
@ -108,16 +106,14 @@ struct zsdevice {
struct zschan zs_chan_a; struct zschan zs_chan_a;
}; };
/* Flags from cninit() */ static int zs_defspeed[2] = {
static int zs_hwflags[NZSC][2]; 38400, /* ttyZ0 */
/* Default speed for each channel */ 38400, /* ttyZ1 */
static int zs_defspeed[NZSC][2] = {
{ 38400, /* tty00 */
38400 }, /* tty01 */
}; };
/* console stuff */ /* console stuff */
void *zs_conschan = 0; void *zs_conschan = 0;
int zs_conschannel;
#ifdef ZS_CONSOLE_ABORT #ifdef ZS_CONSOLE_ABORT
int zs_cons_canabort = 1; int zs_cons_canabort = 1;
#else #else
@ -169,6 +165,8 @@ CFATTACH_DECL(zsc, sizeof(struct zsc_softc),
extern struct cfdriver zsc_cd; extern struct cfdriver zsc_cd;
int zsc_attached;
int zshard(void *); int zshard(void *);
int zssoft(void *); int zssoft(void *);
#ifdef ZS_TXDMA #ifdef ZS_TXDMA
@ -188,12 +186,11 @@ static int
zsc_match(struct device *parent, struct cfdata *cf, void *aux) zsc_match(struct device *parent, struct cfdata *cf, void *aux)
{ {
struct confargs *ca = aux; struct confargs *ca = aux;
int unit = cf->cf_unit;
if (strcmp(ca->ca_name, "escc") != 0) if (strcmp(ca->ca_name, "escc") != 0)
return 0; return 0;
if (unit > 1) if (zsc_attached)
return 0; return 0;
return 1; return 1;
@ -215,14 +212,14 @@ zsc_attach(struct device *parent, struct device *self, void *aux)
struct xzs_chanstate *xcs; struct xzs_chanstate *xcs;
struct zs_chanstate *cs; struct zs_chanstate *cs;
struct zsdevice *zsd; struct zsdevice *zsd;
int zsc_unit, channel; int channel;
int s, chip, theflags; int s, chip, theflags;
int node, intr[2][3]; int node, intr[2][3];
u_int regs[6]; u_int regs[6];
chip = 0; zsc_attached = 1;
zsc_unit = zsc->zsc_dev.dv_unit;
chip = 0;
ca->ca_reg[0] += ca->ca_baseaddr; ca->ca_reg[0] += ca->ca_baseaddr;
zsd = mapiodev(ca->ca_reg[0], ca->ca_reg[1]); zsd = mapiodev(ca->ca_reg[0], ca->ca_reg[1]);
@ -261,7 +258,8 @@ zsc_attach(struct device *parent, struct device *self, void *aux)
*/ */
for (channel = 0; channel < 2; channel++) { for (channel = 0; channel < 2; channel++) {
zsc_args.channel = channel; zsc_args.channel = channel;
zsc_args.hwflags = zs_hwflags[zsc_unit][channel]; zsc_args.hwflags = (channel == zs_conschannel ?
ZS_HWFLAG_CONSOLE : 0);
xcs = &zsc->xzsc_xcs_store[channel]; xcs = &zsc->xzsc_xcs_store[channel];
cs = &xcs->xzs_cs; cs = &xcs->xzs_cs;
zsc->zsc_cs[channel] = cs; zsc->zsc_cs[channel] = cs;
@ -284,7 +282,7 @@ zsc_attach(struct device *parent, struct device *self, void *aux)
if (zsc_args.hwflags & ZS_HWFLAG_CONSOLE) if (zsc_args.hwflags & ZS_HWFLAG_CONSOLE)
cs->cs_defspeed = zs_get_speed(cs); cs->cs_defspeed = zs_get_speed(cs);
else else
cs->cs_defspeed = zs_defspeed[zsc_unit][channel]; cs->cs_defspeed = zs_defspeed[channel];
cs->cs_defcflag = zs_def_cflag; cs->cs_defcflag = zs_def_cflag;
/* Make these correspond to cs_defcflag (-crtscts) */ /* Make these correspond to cs_defcflag (-crtscts) */
@ -1038,16 +1036,13 @@ struct consdev consdev_zs = {
zscngetc, zscngetc,
zscnputc, zscnputc,
zscnpollc, zscnpollc,
NULL,
}; };
void void
zscnprobe(struct consdev *cp) zscnprobe(struct consdev *cp)
{ {
int chosen, pkg; int chosen, pkg;
int unit = 0;
char name[16]; char name[16];
extern const struct cdevsw zstty_cdevsw;
if ((chosen = OF_finddevice("/chosen")) == -1) if ((chosen = OF_finddevice("/chosen")) == -1)
return; return;
@ -1071,10 +1066,6 @@ zscnprobe(struct consdev *cp)
if (OF_getprop(pkg, "name", name, sizeof(name)) == -1) if (OF_getprop(pkg, "name", name, sizeof(name)) == -1)
return; return;
if (strcmp(name, "ch-b") == 0)
unit = 1;
cp->cn_dev = makedev(cdevsw_lookup_major(&zstty_cdevsw), unit);
cp->cn_pri = CN_REMOTE; cp->cn_pri = CN_REMOTE;
} }
@ -1082,7 +1073,6 @@ void
zscninit(struct consdev *cp) zscninit(struct consdev *cp)
{ {
int escc, escc_ch, obio, zs_offset; int escc, escc_ch, obio, zs_offset;
int ch = 0;
u_int32_t reg[5]; u_int32_t reg[5];
char name[16]; char name[16];
@ -1093,8 +1083,7 @@ zscninit(struct consdev *cp)
if (OF_getprop(escc_ch, "name", name, sizeof(name)) == -1) if (OF_getprop(escc_ch, "name", name, sizeof(name)) == -1)
return; return;
if (strcmp(name, "ch-b") == 0) zs_conschannel = strcmp(name, "ch-b") == 0;
ch = 1;
if (OF_getprop(escc_ch, "reg", reg, sizeof(reg)) < 4) if (OF_getprop(escc_ch, "reg", reg, sizeof(reg)) < 4)
return; return;
@ -1106,6 +1095,4 @@ zscninit(struct consdev *cp)
if (OF_getprop(obio, "assigned-addresses", reg, sizeof(reg)) < 12) if (OF_getprop(obio, "assigned-addresses", reg, sizeof(reg)) < 12)
return; return;
zs_conschan = (void *)(reg[2] + zs_offset); zs_conschan = (void *)(reg[2] + zs_offset);
zs_hwflags[0][ch] = ZS_HWFLAG_CONSOLE;
} }