summaryrefslogtreecommitdiff
path: root/sys/arch/mvme68k/dev/zs.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/mvme68k/dev/zs.c')
-rw-r--r--sys/arch/mvme68k/dev/zs.c193
1 files changed, 118 insertions, 75 deletions
diff --git a/sys/arch/mvme68k/dev/zs.c b/sys/arch/mvme68k/dev/zs.c
index 1d2dc73a241..693625179fa 100644
--- a/sys/arch/mvme68k/dev/zs.c
+++ b/sys/arch/mvme68k/dev/zs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: zs.c,v 1.10 2002/03/14 01:26:37 millert Exp $ */
+/* $OpenBSD: zs.c,v 1.11 2002/04/27 23:21:05 miod Exp $ */
/*
* Copyright (c) 2000 Steve Murphree, Jr.
@@ -36,7 +36,6 @@
* Serial I/O via an SCC,
*/
#include <sys/param.h>
-#include <sys/conf.h>
#include <sys/ioctl.h>
#include <sys/proc.h>
#include <sys/user.h>
@@ -47,8 +46,11 @@
#include <sys/syslog.h>
#include <sys/fcntl.h>
#include <sys/device.h>
-#include <machine/cpu.h>
+
#include <machine/autoconf.h>
+#include <machine/conf.h>
+#include <machine/cpu.h>
+
#include <dev/cons.h>
#include <mvme68k/dev/scc.h>
@@ -130,16 +132,15 @@ int zs_cons_unit = 0;
int zs_is_console = 0;
struct sccregs *zs_cons_scc;
-int zsopen(dev_t, int, int, struct proc *);
void zsstart(struct tty *);
int zsparam(struct tty *, struct termios *);
-int zsirq(int unit);
+int zsirq(void *);
int zsregs(void *va, int unit, volatile u_char **crp,
volatile u_char **drp);
int zspclk(void);
u_long sir_zs;
-void zs_softint(void);
+void zs_softint(void *);
#define zsunit(dev) (minor(dev) >> 1)
#define zsside(dev) (minor(dev) & 1)
@@ -158,12 +159,30 @@ struct cfdriver zs_cd = {
NULL, "zs", DV_TTY, 0
};
+void zs_ttydef(struct zs *);
+struct tty *zstty(dev_t);
+void zs_init(struct zs *);
+void zscc_init(struct zs *, struct termios *);
+int zscc_params(struct sccregs *, struct termios *);
+int zscc_mget(struct sccregs *);
+void zscc_mset(struct sccregs *, int);
+void zscc_mclr(struct sccregs *, int);
+void zs_drain(struct zs *);
+void zs_unblock(struct tty *);
+void zs_txint(struct zs *);
+void zs_rxint(struct zs *);
+void zs_extint(struct zs *);
+int zscnprobe(struct consdev *);
+void zscninit(void);
+int zscngetc(dev_t);
+void zscnputc(dev_t, int);
+void zs_cnsetup(int, struct termios *);
+
int
zsmatch(parent, vcf, args)
-struct device *parent;
-void *vcf, *args;
+ struct device *parent;
+ void *vcf, *args;
{
- struct cfdata *cf = vcf;
struct confargs *ca = args;
unsigned char *zstest = (unsigned char *)ca->ca_vaddr;
/*
@@ -172,7 +191,7 @@ void *vcf, *args;
* the second scc still checks valid and every byte contains 0xFF. So
* this is what we test with for now. XXX - smurph
*/
- if (!badvaddr(ca->ca_vaddr, 1))
+ if (!badvaddr((vaddr_t)ca->ca_vaddr, 1))
if (*zstest == 0xFF)
return (0);
else
@@ -183,8 +202,8 @@ void *vcf, *args;
void
zsattach(parent, self, args)
-struct device *parent, *self;
-void *args;
+ struct device *parent, *self;
+ void *args;
{
struct zssoftc *sc;
struct zs *zp, *zc;
@@ -300,7 +319,7 @@ void *args;
void
zs_ttydef(zp)
-struct zs *zp;
+ struct zs *zp;
{
struct tty *tp = zp->tty;
@@ -325,7 +344,7 @@ struct zs *zp;
struct tty *
zstty(dev)
-dev_t dev;
+ dev_t dev;
{
if (minor(dev) < NZSLINE)
return (zs_tty[minor(dev)]);
@@ -335,9 +354,9 @@ dev_t dev;
/* ARGSUSED */
int
zsopen(dev, flag, mode, p)
-dev_t dev;
-int flag, mode;
-struct proc *p;
+ dev_t dev;
+ int flag, mode;
+ struct proc *p;
{
register struct tty *tp;
int error;
@@ -376,9 +395,9 @@ struct proc *p;
int
zsclose(dev, flag, mode, p)
-dev_t dev;
-int flag, mode;
-struct proc *p;
+ dev_t dev;
+ int flag, mode;
+ struct proc *p;
{
struct zs *zp;
struct tty *tp;
@@ -405,9 +424,9 @@ struct proc *p;
/*ARGSUSED*/
int
zsread(dev, uio, flag)
-dev_t dev;
-struct uio *uio;
-int flag;
+ dev_t dev;
+ struct uio *uio;
+ int flag;
{
struct zssoftc *sc = (struct zssoftc *) zs_cd.cd_devs[zsunit(dev)];
struct zs *zp = &sc->sc_zs[zsside(dev)];
@@ -419,9 +438,9 @@ int flag;
/*ARGSUSED*/
int
zswrite(dev, uio, flag)
-dev_t dev;
-struct uio *uio;
-int flag;
+ dev_t dev;
+ struct uio *uio;
+ int flag;
{
struct zssoftc *sc = (struct zssoftc *) zs_cd.cd_devs[zsunit(dev)];
struct zs *zp = &sc->sc_zs[zsside(dev)];
@@ -432,10 +451,11 @@ int flag;
int
zsioctl(dev, cmd, data, flag, p)
-dev_t dev;
-caddr_t data;
-int cmd, flag;
-struct proc *p;
+ dev_t dev;
+ u_long cmd;
+ caddr_t data;
+ int flag;
+ struct proc *p;
{
struct zssoftc *sc = (struct zssoftc *) zs_cd.cd_devs[zsunit(dev)];
struct zs *zp = &sc->sc_zs[zsside(dev)];
@@ -491,8 +511,8 @@ struct proc *p;
int
zsparam(tp, t)
-struct tty *tp;
-struct termios *t;
+ struct tty *tp;
+ struct termios *t;
{
struct zssoftc *sc = (struct zssoftc *) zs_cd.cd_devs[zsunit(tp->t_dev)];
struct zs *zp = &sc->sc_zs[zsside(tp->t_dev)];
@@ -516,7 +536,7 @@ struct termios *t;
void
zsstart(tp)
-struct tty *tp;
+ struct tty *tp;
{
struct zssoftc *sc = (struct zssoftc *) zs_cd.cd_devs[zsunit(tp->t_dev)];
struct zs *zp = &sc->sc_zs[zsside(tp->t_dev)];
@@ -539,9 +559,10 @@ struct tty *tp;
splx(s);
}
+int
zsstop(tp, flag)
-struct tty *tp;
-int flag;
+ struct tty *tp;
+ int flag;
{
struct zssoftc *sc = (struct zssoftc *) zs_cd.cd_devs[zsunit(tp->t_dev)];
struct zs *zp = &sc->sc_zs[zsside(tp->t_dev)];
@@ -564,10 +585,12 @@ int flag;
}
}
splx(s);
+ return (0);
}
+void
zs_init(zp)
-struct zs *zp;
+ struct zs *zp;
{
register int s;
@@ -580,15 +603,16 @@ struct zs *zp;
splx(s);
}
+void
zscc_init(zp, par)
-struct zs *zp;
-struct termios *par;
+ struct zs *zp;
+ struct termios *par;
{
struct sccregs *scc;
scc = &zp->scc;
-#ifdef MVME162
- if (cputyp == CPU_162)
+#if defined(MVME162) || defined(MVME172)
+ if (cputyp == CPU_162 || cputyp == CPU_172)
ZWRITE(scc, 2, MC_VECBASE+MCV_ZS);
#endif
ZWRITE(scc, 10, 0);
@@ -601,8 +625,8 @@ struct termios *par;
int
zscc_params(scc, par)
-struct sccregs *scc;
-struct termios *par;
+ struct sccregs *scc;
+ struct termios *par;
{
unsigned divisor, speed;
int spd, imask, ints;
@@ -650,7 +674,7 @@ struct termios *par;
if ((par->c_cflag & CCTS_OFLOW) != 0)
ints |= SCC_CTS;
#if 0
- if (cputyp == CPU_162) {
+ if (cputyp == CPU_162 || cputyp == CPU_172) {
ZWRITE(scc, 15, ints | 1);
/*
* now.. register 7 has become register 7': disable all
@@ -663,8 +687,9 @@ struct termios *par;
return (imask);
}
+int
zscc_mget(scc)
-register struct sccregs *scc;
+ register struct sccregs *scc;
{
int bits = 0, rr0;
@@ -682,9 +707,10 @@ register struct sccregs *scc;
return (bits);
}
+void
zscc_mset(scc, bits)
-register struct sccregs *scc;
-int bits;
+ register struct sccregs *scc;
+ int bits;
{
if ((bits & TIOCM_LE) != 0)
ZBIS(scc, 3, SCC_RCVEN);
@@ -694,9 +720,10 @@ int bits;
ZBIS(scc, 5, SCC_RTS);
}
+void
zscc_mclr(scc, bits)
-register struct sccregs *scc;
-int bits;
+ register struct sccregs *scc;
+ int bits;
{
if ((bits & TIOCM_LE) != 0)
ZBIC(scc, 3, SCC_RCVEN);
@@ -706,8 +733,9 @@ int bits;
ZBIC(scc, 5, SCC_RTS);
}
+void
zs_drain(zp)
-register struct zs *zp;
+ register struct zs *zp;
{
register int s;
@@ -723,8 +751,9 @@ register struct zs *zp;
splx(s);
}
+void
zs_unblock(tp)
-register struct tty *tp;
+ register struct tty *tp;
{
tp->t_state &= ~TS_DRAIN;
if (tp->t_outq.c_cc != 0)
@@ -735,12 +764,13 @@ register struct tty *tp;
* Hardware interrupt from an SCC.
*/
int
-zsirq(unit)
-int unit;
+zsirq(arg)
+ void *arg;
{
+ int unit = (int)arg;
struct zssoftc *sc = (struct zssoftc *) zs_cd.cd_devs[unit];
- register struct zs *zp = &sc->sc_zs[0];
- register int ipend, x;
+ struct zs *zp = &sc->sc_zs[0];
+ int ipend;
ipend = ZREAD(&zp->scc, 3); /* read int pending from A side */
if (ipend == 0)
@@ -764,10 +794,10 @@ int unit;
return (1);
}
+void
zs_txint(zp)
-register struct zs *zp;
+ register struct zs *zp;
{
- struct tty *tp = zp->tty;
struct sccregs *scc;
int c;
u_char *get;
@@ -791,8 +821,9 @@ register struct zs *zp;
}
}
+void
zs_rxint(zp)
-register struct zs *zp;
+ register struct zs *zp;
{
register int stat, c, n, extra;
u_char *put;
@@ -838,8 +869,9 @@ register struct zs *zp;
}
/* Ext/status interrupt */
+void
zs_extint(zp)
-register struct zs *zp;
+ register struct zs *zp;
{
int rr0;
struct tty *tp = zp->tty;
@@ -861,10 +893,12 @@ register struct zs *zp;
setsoftint(sir_zs);
}
+/* ARGSUSED */
void
-zs_softint()
+zs_softint(arg)
+ void *arg;
{
- int s, n, n0, c, stat, rr0;
+ int s, c, stat, rr0;
struct zs *zp;
struct tty *tp;
u_char *get;
@@ -965,14 +999,16 @@ zs_softint()
*/
/* probe for the SCC; should check hardware */
+int
zscnprobe(cp)
-struct consdev *cp;
+ struct consdev *cp;
{
int maj;
switch (cputyp) {
case CPU_147:
case CPU_162:
+ case CPU_172:
break;
default:
cp->cn_pri = CN_DEAD;
@@ -1005,6 +1041,7 @@ struct termios zscn_termios = {
struct sccregs zs_cons_sccregs;
int zs_cons_imask;
+void
zscninit()
{
zs_cnsetup(0, &zscn_termios);
@@ -1013,7 +1050,7 @@ zscninit()
/* Polling routine for console input from a serial port. */
int
zscngetc(dev)
-dev_t dev;
+ dev_t dev;
{
register struct sccregs *scc = zs_cons_scc;
int c, s, stat;
@@ -1033,9 +1070,10 @@ dev_t dev;
return (c);
}
+void
zscnputc(dev, c)
-dev_t dev;
-int c;
+ dev_t dev;
+ int c;
{
register struct sccregs *scc = zs_cons_scc;
int s;
@@ -1047,9 +1085,10 @@ int c;
splx(s);
}
+void
zs_cnsetup(unit, tiop)
-int unit;
-struct termios *tiop;
+ int unit;
+ struct termios *tiop;
{
volatile u_char *scc_cr, *scc_dr;
struct sccregs *scc;
@@ -1076,8 +1115,8 @@ struct termios *tiop;
scc->s_cr = scc_cr;
scc->s_dr = scc_dr;
-#ifdef MVME162
- if (cputyp == CPU_162)
+#if defined(MVME162) || defined(MVME172)
+ if (cputyp == CPU_162 || cputyp == CPU_172)
ZWRITE(scc, 2, MC_VECBASE+MCV_ZS);
#endif
ZWRITE(scc, 10, 0);
@@ -1092,7 +1131,7 @@ struct termios *tiop;
#ifdef MVME147
u_long zs_cons_addrs_147[] = { ZS0_PHYS_147, ZS1_PHYS_147};
#endif
-#ifdef MVME162
+#if defined(MVME162) || defined(MVME172)
u_long zs_cons_addrs_162[] = { ZS0_PHYS_162, ZS1_PHYS_162};
#endif
@@ -1105,14 +1144,14 @@ u_long zs_cons_addrs_162[] = { ZS0_PHYS_162, ZS1_PHYS_162};
*/
int
zsregs(va, unit, crp, drp)
-void *va;
-int unit;
-volatile u_char **crp, **drp;
+ void *va;
+ int unit;
+ volatile u_char **crp, **drp;
{
#ifdef MVME147
volatile struct scc_147 *scc_adr_147;
#endif
-#ifdef MVME162
+#if defined(MVME162) || defined(MVME172)
volatile struct scc_162 *scc_adr_162;
#endif
volatile u_char *scc_cr, *scc_dr;
@@ -1129,8 +1168,9 @@ volatile u_char **crp, **drp;
size = sizeof(struct scc_147);
break;
#endif
-#ifdef MVME162
+#if defined(MVME162) || defined(MVME172)
case CPU_162:
+ case CPU_172:
if (!va)
va = (void *)IIOV(zs_cons_addrs_162[zsunit(unit)]);
scc_adr_162 = (volatile struct scc_162 *)va;
@@ -1154,9 +1194,12 @@ zspclk()
case CPU_147:
return (PCLK_FREQ_147);
#endif
-#ifdef MVME162
+#if defined(MVME162) || defined(MVME172)
case CPU_162:
+ case CPU_172:
return (PCLK_FREQ_162);
#endif
+ default:
+ return 0;
}
}