- zs: switch to MI driver

- clock, le, pcc, wdsc, zs: convert to new autoconfig scheme
 - vme: add vme support

Contributed by: Jason R. Thorpe <thorpej@og.org>
This commit is contained in:
chuck 1996-04-26 18:59:58 +00:00
parent 34c1e309b6
commit d80422cd46
13 changed files with 1950 additions and 990 deletions

View File

@ -0,0 +1,133 @@
/* $NetBSD: clock_pcc.c,v 1.1 1996/04/26 18:59:58 chuck Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Glue for the Peripheral Channel Controller timers and the
* Mostek clock chip found on the MVME-147.
*/
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <machine/psl.h>
#include <machine/cpu.h>
#include <mvme68k/mvme68k/clockreg.h>
#include <mvme68k/mvme68k/clockvar.h>
#include <mvme68k/dev/pccreg.h>
#include <mvme68k/dev/pccvar.h>
int clock_pcc_match __P((struct device *, void *, void *));
void clock_pcc_attach __P((struct device *, struct device *, void *));
int clock_pcc_intr __P((void *));
void clock_pcc_initclocks __P((void));
u_char clock_pcc_lvl;
struct cfattach clock_pcc_ca = {
sizeof(struct device), clock_pcc_match, clock_pcc_attach
};
int
clock_pcc_match(parent, match, aux)
struct device *parent;
void *match, *aux;
{
struct cfdata *cf = match;
struct pcc_attach_args *pa = aux;
static int clock_pcc_matched;
/* Only one clock, please. */
if (clock_pcc_matched)
return (0);
if (strcmp(pa->pa_name, clock_cd.cd_name))
return (0);
clock_pcc_matched = 1;
pa->pa_ipl = cf->pcccf_ipl;
return (1);
}
void
clock_pcc_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct pcc_attach_args *pa = aux;
caddr_t nvram, clockregs;
if (pa->pa_ipl != CLOCK_LEVEL)
panic("clock_pcc_attach: wrong interrupt level");
nvram = PCC_VADDR(pa->pa_offset);
clockregs = PCC_VADDR(pa->pa_offset + PCC_RTC_OFF);
/* Do common portions of clock config. */
clock_config(self, clockregs, nvram, MK48T02_SIZE,
clock_pcc_initclocks);
/* Attach the interrupt handler. */
pccintr_establish(PCCV_TIMER1, clock_pcc_intr, pa->pa_ipl, NULL);
/* XXX timer2 */
clock_pcc_lvl = pa->pa_ipl | PCC_IENABLE | PCC_TIMERACK;
}
void
clock_pcc_initclocks()
{
sys_pcc->t1_pload = PCC_TIMER100HZ;
sys_pcc->t1_cr = PCC_TIMERCLEAR;
sys_pcc->t1_cr = PCC_TIMERSTART;
sys_pcc->t1_int = clock_pcc_lvl;
}
int
clock_pcc_intr(frame)
void *frame;
{
sys_pcc->t1_int = clock_pcc_lvl;
hardclock(frame);
return (1);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_le.c,v 1.6 1996/04/22 02:28:34 christos Exp $ */
/* $NetBSD: if_le.c,v 1.7 1996/04/26 19:00:00 chuck Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
@ -60,10 +60,12 @@
#include <machine/cpu.h>
#include <machine/pmap.h>
#include <mvme68k/dev/iio.h>
#include <mvme68k/dev/pccreg.h>
#include <mvme68k/dev/pccvar.h>
#include <mvme68k/dev/if_lereg.h>
#include <mvme68k/dev/if_levar.h>
#include <dev/ic/am7990reg.h>
#define LE_NEED_BUF_CONTIG
#include <dev/ic/am7990var.h>
@ -71,12 +73,12 @@
#define LE_SOFTC(unit) le_cd.cd_devs[unit]
#define LE_DELAY(x) DELAY(x)
int lematch __P((struct device *, void *, void *));
void leattach __P((struct device *, struct device *, void *));
int le_pcc_match __P((struct device *, void *, void *));
void le_pcc_attach __P((struct device *, struct device *, void *));
int leintr __P((void *));
struct cfattach le_ca = {
sizeof(struct le_softc), lematch, leattach
struct cfattach le_pcc_ca = {
sizeof(struct le_softc), le_pcc_match, le_pcc_attach
};
struct cfdriver le_cd = {
@ -116,30 +118,34 @@ lerdcsr(sc, port)
}
int
lematch(parent, match, aux)
le_pcc_match(parent, match, aux)
struct device *parent;
void *match, *aux;
{
struct cfdata *cf = match;
struct pcc_attach_args *pa = aux;
return !badbaddr((caddr_t) IIO_CFLOC_ADDR(cf));
if (strcmp(pa->pa_name, le_cd.cd_name))
return (0);
pa->pa_ipl = cf->pcccf_ipl;
return (1);
}
void
leattach(parent, self, aux)
le_pcc_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct le_softc *sc = (void *)self;
struct cfdata *cf = self->dv_cfdata;
int pri = IIO_CFLOC_LEVEL(cf);
struct pcc_attach_args *pa = aux;
/* XXX the following declarations should be elsewhere */
extern void myetheraddr __P((u_char *));
iio_print(cf);
/* Map control registers. */
sc->sc_r1 = (struct lereg1 *)PCC_VADDR(pa->pa_offset);
sc->sc_r1 = (struct lereg1 *)IIO_CFLOC_ADDR(cf);
sc->sc_mem = ledatabuf; /* XXX */
sc->sc_conf3 = LE_C3_BSWP;
sc->sc_addr = (u_long)sc->sc_mem;
@ -156,8 +162,8 @@ leattach(parent, self, aux)
sc->sc_arpcom.ac_if.if_name = le_cd.cd_name;
leconfig(sc);
pccintr_establish(PCCV_LE, leintr, pri, sc);
sys_pcc->le_int = pri | PCC_IENABLE;
pccintr_establish(PCCV_LE, leintr, pa->pa_ipl, sc);
sys_pcc->le_int = pa->pa_ipl | PCC_IENABLE;
}
#include <dev/ic/am7990.c>

View File

@ -1,7 +1,7 @@
/* $Id: pcc.c,v 1.2 1996/03/17 01:35:03 thorpej Exp $ */
/* $Id: pcc.c,v 1.3 1996/04/26 19:00:06 chuck Exp $ */
/*
*
* Copyright (c) 1996 Jason R. Thorpe
* Copyright (c) 1995 Charles D. Cranor
* All rights reserved.
*
@ -50,9 +50,11 @@
#include <sys/device.h>
#include <machine/cpu.h>
#include <dev/cons.h>
#include <mvme68k/mvme68k/isr.h>
#include <mvme68k/dev/iio.h>
#include <mvme68k/dev/pccreg.h>
#include <mvme68k/dev/pccvar.h>
/*
* Autoconfiguration stuff.
@ -63,9 +65,9 @@ struct pccsoftc {
struct pcc *sc_pcc;
};
void pccattach __P((struct device *, struct device *, void *));
int pccmatch __P((struct device *, void *, void *));
void pccattach __P((struct device *, struct device *, void *));
int pccmatch __P((struct device *, void *, void *));
int pccprint __P((void *, char *));
struct cfattach pcc_ca = {
sizeof(struct pccsoftc), pccmatch, pccattach
@ -75,26 +77,40 @@ struct cfdriver pcc_cd = {
NULL, "pcc", DV_DULL, 0
};
int pccintr __P((void *));
/*
* globals
*/
struct pcc *sys_pcc = NULL;
struct {
int (*pcc_fn)();
void *arg;
int lvl;
} pcc_vecs[PCC_NVEC];
/*
* Devices that live on the PCC, attached in this order.
*/
struct pcc_device pcc_devices[] = {
{ "clock", PCC_CLOCK_OFF, 1 },
{ "zsc", PCC_ZS0_OFF, 1 },
{ "zsc", PCC_ZS1_OFF, 1 },
{ "le", PCC_LE_OFF, 2 },
{ "wdsc", PCC_WDSC_OFF, 1 },
{ "lpt", PCC_LPT_OFF, 1 },
{ "vmechip", PCC_VME_OFF, 2 },
{ NULL, 0, 0 },
};
int
pccmatch(parent, vcf, args)
struct device *parent;
void *vcf, *args;
{
struct cfdata *cf = vcf;
char *ma_name = args;
return !badbaddr((caddr_t) IIO_CFLOC_ADDR(cf));
/* Only attach one PCC. */
if (sys_pcc)
return (0);
return (strcmp(ma_name, pcc_cd.cd_name) == 0);
}
void
@ -103,72 +119,140 @@ pccattach(parent, self, args)
void *args;
{
struct pccsoftc *pccsc;
struct pcc_attach_args npa;
caddr_t kva;
int i, error;
if (sys_pcc)
panic("pcc already attached!");
panic("pccattach: pcc already attached!");
iio_print(self->dv_cfdata);
sys_pcc = (struct pcc *)PCC_VADDR(PCC_REG_OFF);
/*
* link into softc and set up interrupt vector base
* link into softc and set up interrupt vector base,
* and initialize the chip.
*/
pccsc = (struct pccsoftc *) self;
sys_pcc = pccsc->sc_pcc = (struct pcc *)IIO_CFLOC_ADDR(self->dv_cfdata);
pccsc->sc_pcc = sys_pcc;
pccsc->sc_pcc->int_vectr = PCC_VECBASE;
bzero(pcc_vecs, sizeof(pcc_vecs));
printf(" rev %d intbvr 0x%x\n", pccsc->sc_pcc->pcc_rev,
printf(": Peripheral Channel Controller, "
"rev %d, vecbase 0x%x\n", pccsc->sc_pcc->pcc_rev,
pccsc->sc_pcc->int_vectr);
/* Hook up interrupt handler for abort button. */
pccintr_establish(PCCV_ABORT, pccintr, 7, NULL);
/*
* Now that the interrupt handler has been established,
* enable the ABORT switch interrupt.
*/
pccsc->sc_pcc->abrt_int = PCC_ABORT_IEN | PCC_ABORT_ACK;
/* Make sure the global interrupt line is hot. */
pccsc->sc_pcc->gen_cr |= PCC_GENCR_IEN;
/*
* Attach configured children.
*/
for (i = 0; pcc_devices[i].pcc_name != NULL; ++i) {
/*
* Note that IPL is filled in by match function.
*/
npa.pa_name = pcc_devices[i].pcc_name;
npa.pa_offset = pcc_devices[i].pcc_offset;
npa.pa_ipl = -1;
/* Check for hardware. (XXX is this really necessary?) */
kva = PCC_VADDR(npa.pa_offset);
/* XXX should change interface to badaddr() */
switch (pcc_devices[i].pcc_bytes) {
case 1:
error = badbaddr(kva);
break;
case 2:
error = badaddr(kva);
break;
default:
panic("pccattach: bad probe size");
}
if (error) {
/*
* Hardware not present.
*/
continue;
}
/* Attach the device if configured. */
(void)config_found(self, &npa, pccprint);
}
}
/*
* pccintr: called from locore with the PC and evec from the trap frame.
*/
int
pccintr(pc, evec, frame)
int pc;
int evec;
void *frame;
pccprint(aux, cp)
void *aux;
char *cp;
{
int vec = (evec & 0xfff) >> 2; /* XXX should be m68k macro? */
extern u_long intrcnt[]; /* XXX from locore */
struct pcc_attach_args *pa = aux;
vec = vec & 0xf; /* XXX mask out */
if (vec >= PCC_NVEC || pcc_vecs[vec].pcc_fn == NULL)
return(straytrap(pc, evec));
if (cp)
printf("%s at %s", pa->pa_name, cp);
cnt.v_intr++;
intrcnt[pcc_vecs[vec].lvl]++;
/* arg override? only timer1 gets access to frame */
if (vec != PCCV_TIMER1)
frame = pcc_vecs[vec].arg;
return((*pcc_vecs[vec].pcc_fn)(frame));
printf(" offset 0x%lx", pa->pa_offset);
if (pa->pa_ipl != -1)
printf(" ipl %d", pa->pa_ipl);
return (UNCONF);
}
/*
* pccintr_establish: establish pcc interrupt
*/
int
pccintr_establish(vec, hand, lvl, arg)
u_long vec;
int (*hand)(), lvl;
void
pccintr_establish(pccvec, hand, lvl, arg)
int pccvec;
int (*hand) __P((void *)), lvl;
void *arg;
{
if (vec >= PCC_NVEC) {
printf("pcc: illegal vector: 0x%x\n", vec);
if ((pccvec < 0) || (pccvec >= PCC_NVEC)) {
printf("pcc: illegal vector offset: 0x%x\n", pccvec);
panic("pccintr_establish");
}
if (pcc_vecs[vec].pcc_fn) {
printf("pcc: vector 0x%x in use: (0x%x,0x%x) (0x%x,0x%x)\n",
hand, arg, pcc_vecs[vec].pcc_fn, pcc_vecs[vec].arg);
if ((lvl < 1) || (lvl > 7)) {
printf("pcc: illegal interrupt level: %d\n", lvl);
panic("pccintr_establish");
}
pcc_vecs[vec].pcc_fn = hand;
pcc_vecs[vec].lvl = lvl;
pcc_vecs[vec].arg = arg;
isrlink_vectored(hand, arg, lvl, pccvec + PCC_VECBASE);
}
void
pccintr_disestablish(pccvec)
int pccvec;
{
if ((pccvec < 0) || (pccvec >= PCC_NVEC)) {
printf("pcc: illegal vector offset: 0x%x\n", pccvec);
panic("pccintr_establish");
}
isrunlink_vectored(pccvec + PCC_VECBASE);
}
/*
* Handle NMI from abort switch.
*/
int
pccintr(frame)
void *frame;
{
/* XXX wait until button pops out */
sys_pcc->abrt_int = PCC_ABORT_IEN | PCC_ABORT_ACK;
nmihand((struct frame *)frame);
return (1);
}

View File

@ -1,4 +1,4 @@
/* $Id: pccreg.h,v 1.2 1996/04/18 18:07:08 chuck Exp $ */
/* $Id: pccreg.h,v 1.3 1996/04/26 19:00:08 chuck Exp $ */
/*
*
@ -32,9 +32,28 @@
*/
/*
* peripheral channel controller (at pa fffe1000)
* peripheral channel controller (at pa fffe0000)
*/
#define PCC_BASE 0xfffe0000 /* PA of PCC chip space */
#define PCC_CLOCK_OFF 0x0000 /* offset of Mostek clock chip */
#define PCC_RTC_OFF 0x07f8 /* offset of clock registers in MK */
#define PCC_REG_OFF 0x1000 /* offset of PCC chip registers */
#define PCC_LE_OFF 0x1800 /* offset of LANCE ethernet chip */
#define PCC_VME_OFF 0x2000 /* offset of VME chip */
#define PCC_LPT_OFF 0x2800 /* offset of parallel port register */
#define PCC_ZS0_OFF 0x3000 /* offset of first 8530 UART */
#define PCC_ZS1_OFF 0x3800 /* offset of second 8530 UART */
#define PCC_WDSC_OFF 0x4000 /* offset of 33c93 SCSI chip */
#define PCC_PADDR(off) ((void *)(PCC_BASE + (off)))
/*
* The PCC space is permanently mapped by pmap_bootstrap(). This
* macro translates PCC offsets into the corresponding KVA.
*/
#define PCC_VADDR(off) ((void *)IIOV(PCC_BASE + (off)))
struct pcc {
volatile u_long dma_taddr; /* dma table address */
volatile u_long dma_daddr; /* dma data address */
@ -122,6 +141,7 @@ extern struct pcc *sys_pcc;
#define PCC_TIMERACK 0x80 /* ack intr */
#define PCC_TIMER100HZ 63936 /* load value for 100Hz */
#define PCC_TIMERCLEAR 0x0 /* reset and clear timer */
#define PCC_TIMERSTOP 0x1 /* stop clock, but don't clear it */
#define PCC_TIMERSTART 0x3 /* start timer */
/*
@ -129,3 +149,17 @@ extern struct pcc *sys_pcc;
*/
#define PCC_ZSEXTERN 0x10 /* let PCC supply vector */
/*
* abort switch
*/
#define PCC_ABORT_IEN 0x08 /* enable interrupt */
#define PCC_ABORT_ABS 0x40 /* current state of switch */
#define PCC_ABORT_ACK 0x80 /* interrupt active; write to ack */
/*
* general control register
*/
#define PCC_GENCR_IEN 0x10 /* global interrupt enable */

View File

@ -0,0 +1,66 @@
/* $NetBSD: pccvar.h,v 1.1 1996/04/26 19:00:11 chuck Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Autoconfiguration definitions for the MVME-147 Peripheral Channel
* Controller.
*/
/*
* Structure used to describe a device for autoconfiguration purposes.
*/
struct pcc_device {
char *pcc_name; /* name of device (e.g. "clock") */
u_long pcc_offset; /* offset from PCC base */
int pcc_bytes; /* size of badaddr check */
};
/*
* Structure used to attach PCC devices.
*/
struct pcc_attach_args {
char *pa_name; /* name of device */
u_long pa_offset; /* offset from PCC base */
int pa_ipl; /* interrupt level */
};
/* Shorthand for locators. */
#define pcccf_ipl cf_loc[0]
void pccintr_establish __P((int, int (*)(void *), int, void *));
void pccintr_disestablish __P((int));

324
sys/arch/mvme68k/dev/vme.c Normal file
View File

@ -0,0 +1,324 @@
/* $NetBSD: vme.c,v 1.1 1996/04/26 19:00:12 chuck Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe
* Copyright (c) 1994 Gordon W. Ross
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Gordon Ross
* 4. The name of the Author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Generic VME support for the Motorola MVME series of computers.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <machine/cpu.h>
#include <mvme68k/dev/vmevar.h>
int vmes_match __P((struct device *, void *, void *));
int vmel_match __P((struct device *, void *, void *));
void vme_attach __P((struct device *, struct device *, void *));
int vme_search __P((struct device *, void *, void *));
int vme_print __P((void *, char *));
int vmechip_print __P((void *, char *));
struct cfdriver vmechip_cd = {
NULL, "vmechip", DV_DULL
};
struct cfattach vmes_ca = {
sizeof(struct device), vmes_match, vme_attach
};
struct cfdriver vmes_cd = {
NULL, "vmes", DV_DULL
};
struct cfattach vmel_ca = {
sizeof(struct device), vmel_match, vme_attach
};
struct cfdriver vmel_cd = {
NULL, "vmel", DV_DULL
};
/* Pointer to the system vmechip softc. */
struct vmechip_softc *sys_vmechip;
void
vme_config(sc)
struct vmechip_softc *sc;
{
struct vme_attach_args va;
/* We can only do this once. */
if (sys_vmechip)
panic("vme_config: more than one VME bus?");
sys_vmechip = sc;
/* Attach D16 space. */
bzero(&va, sizeof(va));
va.va_bustype = VME_D16;
(void)config_found(&sc->sc_dev, &va, vmechip_print);
/* Attach D32 space. */
bzero(&va, sizeof(va));
va.va_bustype = VME_D32;
(void)config_found(&sc->sc_dev, &va, vmechip_print);
}
int
vmechip_print(aux, cp)
void *aux;
char *cp;
{
struct vme_attach_args *va = aux;
char *busname;
if (cp) {
switch (va->va_bustype) {
case VME_D16:
busname = vmes_cd.cd_name;
break;
case VME_D32:
busname = vmel_cd.cd_name;
break;
default:
panic("vmechip_print: impossible bustype");
}
printf("%s at %s", busname, cp);
}
return (UNCONF);
}
int
vmes_match(parent, vcf, aux)
struct device *parent;
void *vcf, *aux;
{
struct vme_attach_args *va = aux;
if (va->va_bustype != VME_D16)
return (0);
return (1);
}
int
vmel_match(parent, vcf, aux)
struct device *parent;
void *vcf, *aux;
{
struct vme_attach_args *va = aux;
if (va->va_bustype != VME_D32)
return (0);
return (1);
}
void
vme_attach(parent, self, args)
struct device *parent;
struct device *self;
void *args;
{
printf("\n");
/* We know va_bustype == VME_Dxx */
(void) config_search(vme_search, self, args);
}
int
vme_search(parent, match, aux)
struct device *parent;
void *match, *aux;
{
struct cfdata *cf = match;
struct vme_attach_args *va = aux;
char *name;
int unit, reject = 0;
name = cf->cf_driver->cd_name;
unit = cf->cf_unit;
/* Send in the clones. */
if (cf->cf_fstate == FSTATE_STAR) {
printf("vme_search: device `%s' is cloned\n", name);
panic("clone devices not allowed on VME");
}
/* Fill in vme_attach_args */
va->va_atype = cf->vmecf_atype;
va->va_addr = cf->vmecf_addr;
va->va_ipl = cf->vmecf_ipl;
va->va_vec = cf->vmecf_vec;
/*
* No wildcards allowed.
* XXX Should check for a wildcard on addr, too, but we don't
* XXX in (u_int32_t)-1 isn't 0xffffffff on some weird machine.
*/
/* atype checked later */
if (va->va_ipl == -1) {
printf("vme_search: device `%s%d' has wildcarded ipl\n",
name, unit);
reject = 1;
}
if (va->va_vec == -1) {
printf("vme_search: device `%s%d' has wildcarded vec\n",
name, unit);
reject = 1;
}
/* Sanity check the atype locator. */
if (reject == 0)
switch (va->va_atype) {
case VME_A16:
case VME_A24:
case VME_A32:
break; /* Just fine. */
case -1: /* wildcarded */
printf("vme_search: device `%s%d' has wildcarded atype\n",
name, unit);
reject = 1;
break;
default:
printf("vme_search: device `%s%d' has invalid atype `%d'\n",
name, unit, va->va_atype);
reject = 1;
break;
}
if (reject) {
printf("vme_search: rejecting device `%s%d'\n", name, unit);
return (0);
}
/* Attempt to match. If we win, attach the device. */
if ((*cf->cf_attach->ca_match)(parent, cf, va) > 0) {
config_attach(parent, cf, va, vme_print);
return (1);
}
return (0);
}
int
vme_print(aux, cp)
void *aux;
char *cp;
{
struct vme_attach_args *va = aux;
if (cp)
printf("device at %s", cp);
printf(" atype %d addr 0x%lx ipl %d vec 0x%x", va->va_atype,
va->va_addr, va->va_ipl, va->va_vec);
return (UNCONF);
}
void
vmeintr_establish(func, arg, ipl, vec)
int (*func) __P((void *));
void *arg;
int ipl, vec;
{
isrlink_vectored(func, arg, ipl, vec);
/* Enable VME IRQ. */
sys_vmechip->sc_irqref[ipl]++;
(*sys_vmechip->sc_chip->vme_intrline_enable)(ipl);
}
void
vmeintr_disestablish(ipl, vec)
int ipl, vec;
{
isrunlink_vectored(vec);
/* Disable VME IRQ if possible. */
switch (sys_vmechip->sc_irqref[ipl]) {
case 0:
printf("vmeintr_disestablish: nothing using IRQ %d\n", ipl);
panic("vmeintr_disestablish");
/* NOTREACHED */
case 1:
(*sys_vmechip->sc_chip->vme_intrline_disable)(ipl);
/* FALLTHROUGH */
default:
sys_vmechip->sc_irqref[ipl]--;
}
}
void *
vmemap(bpa, size, bustype, atype)
u_long bpa;
size_t size;
int bustype, atype;
{
u_long pa;
void *rval;
/* Translate address. */
if ((*sys_vmechip->sc_chip->vme_translate_addr)(bpa, size,
bustype, atype, &pa))
return (NULL);
return (iomap(pa, size));
}
void
vmeunmap(kva, size)
void *kva;
size_t size;
{
iounmap(kva, size);
}

View File

@ -0,0 +1,221 @@
/* $NetBSD: vme_pcc.c,v 1.1 1996/04/26 19:00:14 chuck Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* VME support specific to the Type 1 VMEchip found on the
* MVME-147.
*
* For a manual on the MVME-147, call: 408.991.8634. (Yes, this
* is the Sunnyvale sales office.)
*/
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <machine/psl.h>
#include <machine/cpu.h>
#include <mvme68k/dev/pccreg.h>
#include <mvme68k/dev/pccvar.h>
#include <mvme68k/dev/vme_pccreg.h>
#include <mvme68k/dev/vmevar.h>
int vmechip_pcc_match __P((struct device *, void *, void *));
void vmechip_pcc_attach __P((struct device *, struct device *, void *));
struct cfattach vmechip_pcc_ca = {
sizeof(struct vmechip_softc), vmechip_pcc_match, vmechip_pcc_attach
};
int vmechip_pcc_translate_addr __P((u_long, size_t, int, int, u_long *));
void vmechip_pcc_intrline_enable __P((int));
void vmechip_pcc_intrline_disable __P((int));
struct vme_chip vme_pcc_switch = {
vmechip_pcc_translate_addr,
vmechip_pcc_intrline_enable,
vmechip_pcc_intrline_disable
};
struct vme_pcc *sys_vme_pcc;
extern int physmem;
int
vmechip_pcc_match(parent, match, aux)
struct device *parent;
void *match, *aux;
{
struct cfdata *cf = match;
struct pcc_attach_args *pa = aux;
/* Only one VME chip, please. */
if (sys_vme_pcc)
return (0);
if (strcmp(pa->pa_name, vmechip_cd.cd_name))
return (0);
return (1);
}
void
vmechip_pcc_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct vmechip_softc *sc = (struct vmechip_softc *)self;
struct pcc_attach_args *pa = aux;
struct vme_pcc *vme;
/* Glue into generic VME code. */
sc->sc_reg = PCC_VADDR(pa->pa_offset);
sc->sc_chip = &vme_pcc_switch;
/* Initialize the chip. */
vme = (struct vme_pcc *)sc->sc_reg;
vme->vme_scon &= ~VME1_SCON_SYSFAIL; /* XXX doesn't work */
sys_vme_pcc = vme;
printf(": Type 1 VMEchip, scon jumper %s\n",
(vme->vme_scon & VME1_SCON_SWITCH) ? "enabled" : "disabled");
/* Attach children. */
vme_config(sc);
}
int
vmechip_pcc_translate_addr(start, len, bustype, atype, addrp)
u_long start;
size_t len;
int bustype, atype;
u_long *addrp; /* result */
{
u_long end = (start + len) - 1;
switch (bustype) {
case VME_D16:
switch (atype) {
case VME_A16:
if (end < VME1_A16D16_LEN) {
*addrp = VME1_A16D16_START + start;
return (0);
}
break;
case VME_A24:
if (((end & 0x00ffffff) == end) &&
(end < VME1_A32D16_LEN)) {
*addrp = VME1_A32D16_START + start;
return (0);
}
break;
case VME_A32:
if (end < VME1_A32D16_LEN) {
*addrp = VME1_A32D16_START + start;
return (0);
}
break;
default:
printf("vmechip: impossible atype `%d'\n", atype);
panic("vmechip_pcc_translate_addr");
}
printf("vmechip: can't map %s atype %d addr 0x%lx len 0x%x\n",
vmes_cd.cd_name, atype, start, len);
break;
case VME_D32:
switch (atype) {
case VME_A16:
/* Can't map A16D32 */
break;
case VME_A24:
if (((u_long)physmem < 0x1000000) && /* 16MB */
(start >= (u_long)physmem) &&
(end < VME1_A32D32_LEN)) {
*addrp = start;
return (0);
}
break;
case VME_A32:
if ((start >= (u_long)physmem) &&
(end < VME1_A32D32_LEN)) {
*addrp = start;
return (0);
}
break;
default:
printf("vmechip: impossible atype `%d'\n", atype);
panic("vmechip_pcc_translate_addr");
}
printf("vmechip: can't map %s atype %d addr 0x%lx len 0x%x\n",
vmel_cd.cd_name, atype, start, len);
break;
default:
panic("vmechip_pcc_translate_addr: bad bustype");
}
return (1);
}
void
vmechip_pcc_intrline_enable(ipl)
int ipl;
{
sys_vme_pcc->vme_irqen |= VME1_IRQ_VME(ipl);
}
void
vmechip_pcc_intrline_disable(ipl)
int ipl;
{
sys_vme_pcc->vme_irqen &= ~VME1_IRQ_VME(ipl);
}

View File

@ -0,0 +1,201 @@
/* $NetBSD: vme_pccreg.h,v 1.1 1996/04/26 19:00:16 chuck Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Based IN PART on a 147 VME driver by Theo de Raadt.
*/
/*
* Register map of the Type 1 VMEchip found on the MVME-147
* Peripheral Channel Controller.
*/
struct vme_pcc {
/*
* Local VME control registers.
*/
int8_t pad0;
volatile u_int8_t vme_scon;
#define VME1_SCON_SWITCH 0x01 /* SCON jumper is set */
#define VME1_SCON_SRESET 0x02 /* assert SRESET on bus */
#define VME1_SCON_SYSFAIL 0x04 /* assert SYSFAIL on bus */
#define VME1_SCON_ROBIN 0x08 /* round robin bus requests */
int8_t pad1;
volatile u_int8_t vme_reqconf;
#define VME1_REQ_IPLMASK 0x03 /* interrupt level for requester */
#define VME1_REQ_RNEVER 0x08
#define VME1_REQ_RWD 0x10
#define VME1_REQ_DHB 0x40
#define VME1_REQ_DWB 0x80
int8_t pad2;
volatile u_int8_t vme_masconf;
#define VME1_MAS_D16 0x01 /* force d8/16 accesses only */
#define VME1_MAS_MASA24 0x02 /* send address mod for A24 access */
#define VME1_MAS_MASA16 0x04 /* send address mod for A16 access */
#define VME1_MAS_MASUAT 0x08 /* handle unaligned VME cycles */
#define VME1_MAS_CFILL 0x10 /* DO NOT USE */
#define VME1_MAS_MASWP 0x20 /* VME fast mode (DO NOT USE) */
int8_t pad3;
volatile u_int8_t vme_slconf;
#define VME1_SLAVE_SLVD16 0x01 /* DO NOT USE */
#define VME1_SLAVE_SLVWP 0x20 /* DO NOT USE */
#define VME1_SLAVE_SLVEN 0x80 /* allow access to onboard DRAM */
int8_t pad4;
volatile u_int8_t vme_timerconf;
#define VME1_TIMER_LOCAL_MASK 0x03
#define VME1_TIMER_LOCAL_T0 0x00 /* local timeout 102 microsec */
#define VME1_TIMER_LOCAL_T1 0x01 /* local timeout 205 microsec */
#define VME1_TIMER_LOCAL_T2 0x02 /* local timeout 410 microsec */
#define VME1_TIMER_LOCAL_T3 0x03 /* local timeout disabled */
#define VME1_TIMER_VMEACC_MASK 0x0c
#define VME1_TIMER_VMEACC_T0 0x00 /* VME access timeout 102 microsec */
#define VME1_TIMER_VMEACC_T1 0x04 /* VME access timeout 1.6 millisec */
#define VME1_TIMER_VMEACC_T2 0x08 /* VME access timeout 51 millisec */
#define VME1_TIMER_VMEACC_T3 0x0c /* VME access timeout disabled */
#define VME1_TIMER_VMEGLO_MASK 0x30
#define VME1_TIMER_VMEGLO_T0 0x00 /* VME glob timeout 102 microsec */
#define VME1_TIMER_VMEGLO_T1 0x10 /* VME glob timeout 205 microsec */
#define VME1_TIMER_VMEGLO_T2 0x20 /* VME glob timeout 410 microsec */
#define VME1_TIMER_VMEGLO_T3 0x30 /* VME glob timeout disabled */
#define VME1_TIMER_ARBTO 0x40 /* enable VME arbitration timer */
int8_t pad5;
volatile u_int8_t vme_sladdrmod;
#define VME1_SLMOD_DATA 0x01
#define VME1_SLMOD_PRGRM 0x02
#define VME1_SLMOD_BLOCK 0x04
#define VME1_SLMOD_SHORT 0x08
#define VME1_SLMOD_STND 0x10
#define VME1_SLMOD_EXTED 0x20
#define VME1_SLMOD_USER 0x40
#define VME1_SLMOD_SUPER 0x80
int8_t pad6;
volatile u_int8_t vme_msaddrmod;
#define VME1_MSMOD_AM_MASK 0x3f
#define VME1_MSMOD_AMSEL 0x80
int8_t pad7;
volatile u_int8_t vme_irqen;
#define VME1_IRQ_VME(x) (1 << (x))
int8_t pad8;
volatile u_int8_t vme_uireqen;
int8_t pad9;
volatile u_int8_t vme_uirq;
int8_t pad10;
volatile u_int8_t vme_irq;
int8_t pad11;
volatile u_int8_t vme_vmeid;
int8_t pad12;
volatile u_int8_t vme_buserr;
int8_t pad13;
volatile u_int8_t vme_gcsr;
int8_t pad14[4];
/*
* Global Status and Control registers.
*/
int8_t pad15;
volatile u_int8_t vme_gcsr_gr0;
int8_t pad16;
volatile u_int8_t vme_gcsr_gr1;
int8_t pad17;
volatile u_int8_t vme_gcsr_boardid;
int8_t pad18;
volatile u_int8_t vme_gcsr_gpr0;
int8_t pad19;
volatile u_int8_t vme_gcsr_gpr1;
int8_t pad20;
volatile u_int8_t vme_gcsr_gpr2;
int8_t pad21;
volatile u_int8_t vme_gcsr_gpr3;
int8_t pad22;
volatile u_int8_t vme_gcsr_gpr4;
};
/*
* The Type 1 VMEchip decoder maps VME address space to system addresses
* like this:
*
* A24/32D32: end of RAM - 0xefffffff
* A32D16: 0xf0000000 - 0xff7fffff
* A16D16: 0xffff0000 - 0xffffffff
*
* Note that an A24D32 access on a machine with 16MB of RAM will lose,
* since you'll be out of address bits.
*/
#define VME1_A32D32_START (0x00000000)
#define VME1_A32D32_END (0xefffffff)
#define VME1_A32D32_LEN ((VME1_A32D32_END - VME1_A32D32_START) + 1)
#define VME1_A32D16_START (0xf0000000)
#define VME1_A32D16_END (0xff7fffff)
#define VME1_A32D16_LEN ((VME1_A32D16_END - VME1_A32D16_START) + 1)
#define VME1_A16D16_START (0xffff0000)
#define VME1_A16D16_END (0xffffffff)
#define VME1_A16D16_LEN ((VME1_A16D16_END - VME1_A16D16_START) + 1)

View File

@ -0,0 +1,92 @@
/* $NetBSD: vmevar.h,v 1.1 1996/04/26 19:00:19 chuck Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Autoconfiguration and glue definitions for VME support on the
* Motorola MVME series of computers.
*/
struct vmechip_softc {
struct device sc_dev; /* generic device info */
caddr_t sc_reg; /* chip registers */
struct vme_chip *sc_chip; /* controller vector */
u_long sc_irqref[8]; /* ipl reference count */
};
/*
* Structure used to describe VME controller chips.
*/
struct vme_chip {
int (*vme_translate_addr) __P((u_long, size_t, int, int, u_long *));
void (*vme_intrline_enable) __P((int));
void (*vme_intrline_disable) __P((int));
};
/*
* Structure used to attach childres to the VME busses and controller.
*/
struct vme_attach_args {
int va_bustype; /* VME_D16 or VME_D32 */
int va_atype; /* VME_A16, VME_A24, or VME_A32 */
u_long va_addr; /* address of card in bus space */
int va_ipl; /* card interrupt level */
int va_vec; /* card interrupt vector */
};
#define VME_D16 0 /* D16 */
#define VME_D32 1 /* D32 */
#define VME_A16 16 /* A16 */
#define VME_A24 24 /* A24 */
#define VME_A32 32 /* A32 */
/* Shorthand for locators. */
#define vmecf_atype cf_loc[0]
#define vmecf_addr cf_loc[1]
#define vmecf_ipl cf_loc[2]
#define vmecf_vec cf_loc[3]
extern struct cfdriver vmechip_cd;
extern struct cfdriver vmes_cd;
extern struct cfdriver vmel_cd;
void vme_config __P((struct vmechip_softc *));
void *vmemap __P((u_long, size_t, int, int));
void vmeunmap __P((void *, size_t));
void vmeintr_establish __P((int (*)(void *), void *, int, int));
void vmeintr_disestablish __P((int, int));

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdsc.c,v 1.1 1996/04/18 18:30:54 chuck Exp $ */
/* $NetBSD: wdsc.c,v 1.2 1996/04/26 19:00:20 chuck Exp $ */
/*
* Copyright (c) 1996 Steve Woodford
@ -35,30 +35,32 @@
*
* @(#)wdsc.c
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <scsi/scsi_all.h>
#include <scsi/scsiconf.h>
#include <mvme68k/mvme68k/isr.h>
#include <mvme68k/dev/iio.h>
#include <mvme68k/dev/pccreg.h>
#include <mvme68k/dev/dmavar.h>
#include <mvme68k/dev/pccreg.h>
#include <mvme68k/dev/pccvar.h>
#include <mvme68k/dev/sbicreg.h>
#include <mvme68k/dev/sbicvar.h>
#include <mvme68k/dev/wdscreg.h>
int wdscprint __P((void *auxp, char *));
void wdscattach __P((struct device *, struct device *, void *));
int wdscmatch __P((struct device *, struct cfdata *, void *));
void wdsc_pcc_attach __P((struct device *, struct device *, void *));
int wdsc_pcc_match __P((struct device *, void *, void *));
void wdsc_enintr __P((struct sbic_softc *));
int wdsc_dmago __P((struct sbic_softc *, char *, int, int));
int wdsc_dmanext __P((struct sbic_softc *));
void wdsc_dmastop __P((struct sbic_softc *));
int wdsc_dmaintr __P((struct sbic_softc *));
int wdsc_scsiintr __P((struct sbic_softc *));
int wdsc_dmaintr __P((void *));
int wdsc_scsiintr __P((void *));
struct scsi_adapter wdsc_scsiswitch = {
sbic_scsicmd,
@ -74,8 +76,8 @@ struct scsi_device wdsc_scsidev = {
NULL, /* Use default done routine */
};
struct cfattach wdsc_ca = {
sizeof(struct sbic_softc), (cfmatch_t)wdscmatch, wdscattach
struct cfattach wdsc_pcc_ca = {
sizeof(struct sbic_softc), wdsc_pcc_match, wdsc_pcc_attach
};
struct cfdriver wdsc_cd = {
@ -93,28 +95,30 @@ int shift_nosync = 0;
* Match for SCSI devices on the onboard WD33C93 chip
*/
int
wdscmatch(pdp, cdp, auxp)
wdsc_pcc_match(pdp, match, auxp)
struct device *pdp;
struct cfdata *cdp;
void *auxp;
void *match, *auxp;
{
/*
* Match everything
*/
return(1);
}
struct cfdata *cf = match;
struct pcc_attach_args *pa = auxp;
if (strcmp(pa->pa_name, wdsc_cd.cd_name))
return (0);
pa->pa_ipl = cf->pcccf_ipl;
return (1);
}
/*
* Attach the wdsc driver
*/
void
wdscattach(pdp, dp, auxp)
wdsc_pcc_attach(pdp, dp, auxp)
struct device *pdp, *dp;
void *auxp;
{
struct sbic_softc *sc = (struct sbic_softc *)dp;
int ipl;
struct pcc_attach_args *pa = auxp;
static int attached = 0;
if ( attached )
@ -122,8 +126,6 @@ wdscattach(pdp, dp, auxp)
attached = 1;
iio_print(dp->dv_cfdata);
sc->sc_enintr = wdsc_enintr;
sc->sc_dmago = wdsc_dmago;
sc->sc_dmanext = wdsc_dmanext;
@ -136,14 +138,13 @@ wdscattach(pdp, dp, auxp)
sc->sc_link.device = &wdsc_scsidev;
sc->sc_link.openings = 2;
printf(": target %d\n", sc->sc_link.adapter_target);
printf(": WD33C93 SCSI, target %d\n", sc->sc_link.adapter_target);
sc->sc_cregs = (volatile void *)sys_pcc;
sc->sc_sbicp = (sbic_regmap_p) IIO_CFLOC_ADDR(dp->dv_cfdata);
sc->sc_sbicp = (sbic_regmap_p) PCC_VADDR(pa->pa_offset);
/*
* Eveything is a valid dma address.
*
*/
sc->sc_dmamask = 0;
@ -161,7 +162,7 @@ wdscattach(pdp, dp, auxp)
/*
* Fix up the interrupts
*/
sc->sc_ipl = IIO_CFLOC_LEVEL(dp->dv_cfdata) & PCC_IMASK;
sc->sc_ipl = pa->pa_ipl & PCC_IMASK;
sys_pcc->scsi_int = sc->sc_ipl | PCC_ICLEAR;
sys_pcc->dma_int = sc->sc_ipl | PCC_ICLEAR;
@ -175,7 +176,7 @@ wdscattach(pdp, dp, auxp)
/*
* Attach all scsi units on us
*/
config_found(dp, &sc->sc_link, wdscprint);
(void)config_found(dp, &sc->sc_link, wdscprint);
}
/*
@ -186,9 +187,12 @@ wdscprint(auxp, pnp)
void *auxp;
char *pnp;
{
if (pnp == NULL)
return(UNCONF);
return(QUIET);
/* Only scsibusses can attach to wdscs...easy. */
if (pnp)
printf("scsibus at %s", pnp);
return (UNCONF);
}
@ -296,9 +300,10 @@ wdsc_dmastop(dev)
* Come here following a DMA interrupt
*/
int
wdsc_dmaintr(dev)
struct sbic_softc *dev;
wdsc_dmaintr(arg)
void *arg;
{
struct sbic_softc *dev = arg;
volatile struct pcc *pc = dev->sc_cregs;
int found = 0;
@ -325,9 +330,10 @@ wdsc_dmaintr(dev)
* Come here for SCSI interrupts
*/
int
wdsc_scsiintr(dev)
struct sbic_softc *dev;
wdsc_scsiintr(arg)
void *arg;
{
struct sbic_softc *dev = arg;
volatile struct pcc *pc = dev->sc_cregs;
int found;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,214 @@
/* $NetBSD: zs_pcc.c,v 1.1 1996/04/26 19:00:24 chuck Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe
* Copyright (c) 1995 Gordon W. Ross
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* 4. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Gordon Ross
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Zilog Z8530 Dual UART driver (machine-dependent part)
*
* Runs two serial lines per chip using slave drivers.
* Plain tty/async lines use the zs_async slave.
*
* Modified for NetBSD/mvme68k by Jason R. Thorpe <thorpej@NetBSD.ORG>
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/device.h>
#include <sys/conf.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/tty.h>
#include <sys/time.h>
#include <sys/kernel.h>
#include <sys/syslog.h>
#include <dev/cons.h>
#include <dev/ic/z8530reg.h>
#include <machine/z8530var.h>
#include <machine/cpu.h>
#include <mvme68k/dev/pccreg.h>
#include <mvme68k/dev/pccvar.h>
#include <mvme68k/dev/zsvar.h>
/*
* PCC offsets.
*/
static int zs_pcc_offsets[NZS] = { PCC_ZS0_OFF, PCC_ZS1_OFF };
struct zschan *
zs_pcc_get_chan_addr(zsc_unit, channel)
int zsc_unit, channel;
{
struct zsdevice *addr;
struct zschan *zc;
if (zsc_unit >= NZS)
return NULL;
addr = (struct zsdevice *)PCC_VADDR(zs_pcc_offsets[zsc_unit]);
if (addr == NULL)
return NULL;
if (channel == 0) {
zc = &addr->zs_chan_a;
} else {
zc = &addr->zs_chan_b;
}
return (zc);
}
/****************************************************************
* Autoconfig
****************************************************************/
/* Definition of the driver for autoconfig. */
static int zsc_pcc_match __P((struct device *, void *, void *));
static void zsc_pcc_attach __P((struct device *, struct device *, void *));
struct cfattach zsc_pcc_ca = {
sizeof(struct zsc_softc), zsc_pcc_match, zsc_pcc_attach
};
/*
* Is the zs chip present?
*/
static int
zsc_pcc_match(parent, vcf, aux)
struct device *parent;
void *vcf, *aux;
{
struct cfdata *cf = vcf;
struct pcc_attach_args *pa = aux;
int unit;
/* XXX This is bogus; should fix this. */
unit = cf->cf_unit;
if (unit < 0 || unit >= NZS)
return (0);
if (strcmp(pa->pa_name, zsc_cd.cd_name))
return (0);
pa->pa_ipl = cf->pcccf_ipl;
if (pa->pa_ipl == -1)
pa->pa_ipl = ZSHARD_PRI;
return (1);
}
/*
* 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
zsc_pcc_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
{
struct zsc_softc *zsc = (void *) self;
struct pcc_attach_args *pa = aux;
int zs_level, ir;
static int didintr;
zs_level = pa->pa_ipl;
/* Do common parts of SCC configuration. */
zs_config(zsc, zs_pcc_get_chan_addr);
/*
* Now safe to install interrupt handlers. Note the arguments
* to the interrupt handlers aren't used. Note, we only do this
* once since both SCCs interrupt at the same level and vector.
*/
if (didintr == 0) {
didintr = 1;
pccintr_establish(PCCV_ZS, zshard, zs_level, zsc);
}
/* Sanity check the interrupt levels. */
ir = sys_pcc->zs_int;
if (((ir & PCC_IMASK) != 0) &&
((ir & PCC_IMASK) != zs_level))
panic("zs_pcc_attach: zs configured at different IPLs");
/*
* Set master interrupt enable. Vector is programmed into
* the SCC by the PCC.
*/
sys_pcc->zs_int = zs_level | PCC_IENABLE | PCC_ZSEXTERN;
zs_write_reg(&zsc->zsc_cs[0], 9, zs_init_reg[9]);
}
/****************************************************************
* Console support functions (MVME PCC specific!)
****************************************************************/
/*
* Check for SCC console. The MVME-147 always uses unit 0 chan 0.
*/
void
zsc_pcccnprobe(cp)
struct consdev *cp;
{
#ifdef notyet
if (cputyp != CPU_147) {
cp->cn_pri = CN_DEAD;
return;
}
#endif
/* XXX Shouldn't hardcode the minor number... */
/* Initialize required fields. */
cp->cn_dev = makedev(ZSTTY_MAJOR, 0);
cp->cn_pri = CN_NORMAL;
}
void
zsc_pcccninit(cp)
struct consdev *cp;
{
int unit, chan;
struct zschan *zc;
unit = 0; /* XXX */
chan = 0; /* XXX */
zc = zs_pcc_get_chan_addr(unit, chan);
/* Do common parts of console init. */
zs_cnconfig(unit, chan, zc);
}

View File

@ -0,0 +1,86 @@
/* $NetBSD: zsvar.h,v 1.1 1996/04/26 19:00:25 chuck Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Non-exported definitons common to the different attachment
* types for the SCC on the Motorola MVME series of computers.
*/
/*
* The MVME provides a 4.9152 MHz clock to the SCC chips.
*/
#define PCLK (9600 * 512) /* PCLK pin input clock rate */
/*
* SCC should interrupt host at level 4.
*/
#define ZSHARD_PRI 4
/*
* No delay needed when writing SCC registers.
*/
#define ZS_DELAY()
/*
* XXX Make cnprobe a little easier.
*/
#define NZS 2
/*
* The layout of this is hardware-dependent (padding, order).
*/
struct zschan {
volatile u_char zc_csr; /* ctrl,status, and indirect access */
volatile u_char zc_data; /* data */
};
struct zsdevice {
/* Yes, they are backwards. */
struct zschan zs_chan_b;
struct zschan zs_chan_a;
};
/* Globals exported from zs.c */
extern u_char zs_init_reg[];
extern struct cfdriver zsc_cd;
/* Functions exported to ASIC-specific drivers. */
void zs_config __P((struct zsc_softc *, struct zschan *(*)(int, int)));
void zs_cnconfig __P((int, int, struct zschan *));
int zshard __P((void *));
int zssoft __P((void *));