1997-06-07 23:16:23 +04:00
|
|
|
/* $NetBSD: obio.c,v 1.35 1997/06/07 19:16:23 pk Exp $ */
|
1994-08-24 13:16:46 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1993, 1994 Theo de Raadt
|
1997-05-19 01:26:22 +04:00
|
|
|
* Copyright (c) 1995, 1997 Paul Kranenburg
|
1994-08-24 13:16:46 +04:00
|
|
|
* 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 Theo de Raadt.
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
1996-03-14 22:44:30 +03:00
|
|
|
#include <sys/systm.h>
|
1994-08-24 13:16:46 +04:00
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <vm/vm.h>
|
|
|
|
|
|
|
|
#include <machine/autoconf.h>
|
|
|
|
#include <machine/pmap.h>
|
1994-09-18 03:49:58 +04:00
|
|
|
#include <machine/oldmon.h>
|
1994-10-26 10:09:41 +03:00
|
|
|
#include <machine/cpu.h>
|
1994-09-18 03:49:58 +04:00
|
|
|
#include <machine/ctlreg.h>
|
|
|
|
#include <sparc/sparc/asm.h>
|
|
|
|
#include <sparc/sparc/vaddrs.h>
|
1997-03-11 02:01:40 +03:00
|
|
|
#include <sparc/sparc/cpuvar.h>
|
1996-04-01 02:28:38 +04:00
|
|
|
#include <sparc/dev/sbusvar.h>
|
1997-05-18 23:37:37 +04:00
|
|
|
#include <sparc/dev/vmereg.h>
|
|
|
|
|
|
|
|
struct vmebus_softc {
|
|
|
|
struct device sc_dev; /* base device */
|
|
|
|
struct vmebusreg *sc_reg; /* VME control registers */
|
|
|
|
struct vmebusvec *sc_vec; /* VME interrupt vector */
|
|
|
|
struct rom_range *sc_range; /* ROM range property */
|
|
|
|
int sc_nrange;
|
|
|
|
};
|
|
|
|
struct vmebus_softc *vmebus_sc;/*XXX*/
|
1994-08-24 13:16:46 +04:00
|
|
|
|
1994-10-15 08:48:47 +03:00
|
|
|
struct bus_softc {
|
1996-04-01 02:28:38 +04:00
|
|
|
union {
|
|
|
|
struct device scu_dev; /* base device */
|
|
|
|
struct sbus_softc scu_sbus; /* obio is another sbus slot */
|
1997-05-18 23:37:37 +04:00
|
|
|
struct vmebus_softc scu_vme;
|
1996-04-01 02:28:38 +04:00
|
|
|
} bu;
|
1994-08-24 13:16:46 +04:00
|
|
|
};
|
|
|
|
|
1997-05-18 23:37:37 +04:00
|
|
|
|
1994-08-24 13:16:46 +04:00
|
|
|
/* autoconfiguration driver */
|
1996-12-11 01:54:46 +03:00
|
|
|
static int busmatch __P((struct device *, struct cfdata *, void *));
|
1994-11-23 10:02:02 +03:00
|
|
|
static void obioattach __P((struct device *, struct device *, void *));
|
|
|
|
static void vmesattach __P((struct device *, struct device *, void *));
|
|
|
|
static void vmelattach __P((struct device *, struct device *, void *));
|
1997-05-18 23:37:37 +04:00
|
|
|
static void vmeattach __P((struct device *, struct device *, void *));
|
1996-04-01 02:28:38 +04:00
|
|
|
|
1996-08-28 01:53:46 +04:00
|
|
|
int busprint __P((void *, const char *));
|
1997-05-18 23:37:37 +04:00
|
|
|
int vmeprint __P((void *, const char *));
|
1996-12-11 01:54:46 +03:00
|
|
|
static int busattach __P((struct device *, struct cfdata *, void *, int));
|
|
|
|
int obio_scan __P((struct device *, struct cfdata *, void *));
|
|
|
|
int vmes_scan __P((struct device *, struct cfdata *, void *));
|
|
|
|
int vmel_scan __P((struct device *, struct cfdata *, void *));
|
1997-06-07 23:16:23 +04:00
|
|
|
void vmebus_translate __P((struct device *, struct confargs *, int));
|
1996-03-14 22:44:30 +03:00
|
|
|
int vmeintr __P((void *));
|
1994-10-15 08:48:47 +03:00
|
|
|
|
1996-03-17 05:00:30 +03:00
|
|
|
struct cfattach obio_ca = {
|
|
|
|
sizeof(struct bus_softc), busmatch, obioattach
|
1994-10-15 08:48:47 +03:00
|
|
|
};
|
1996-03-17 05:00:30 +03:00
|
|
|
|
|
|
|
struct cfdriver obio_cd = {
|
|
|
|
NULL, "obio", DV_DULL
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cfattach vmel_ca = {
|
|
|
|
sizeof(struct bus_softc), busmatch, vmelattach
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cfdriver vmel_cd = {
|
|
|
|
NULL, "vmel", DV_DULL
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cfattach vmes_ca = {
|
|
|
|
sizeof(struct bus_softc), busmatch, vmesattach
|
1994-08-24 13:16:46 +04:00
|
|
|
};
|
1996-03-17 05:00:30 +03:00
|
|
|
|
|
|
|
struct cfdriver vmes_cd = {
|
|
|
|
NULL, "vmes", DV_DULL
|
1994-10-15 08:48:47 +03:00
|
|
|
};
|
1996-04-01 02:28:38 +04:00
|
|
|
|
1997-05-18 23:37:37 +04:00
|
|
|
struct cfattach vme_ca = {
|
|
|
|
sizeof(struct bus_softc), busmatch, vmeattach
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cfdriver vme_cd = {
|
|
|
|
NULL, "vme", DV_DULL
|
|
|
|
};
|
|
|
|
|
1996-04-01 02:28:38 +04:00
|
|
|
struct intrhand **vmeints;
|
1994-10-15 08:48:47 +03:00
|
|
|
|
1994-09-18 03:49:58 +04:00
|
|
|
|
1994-08-24 13:16:46 +04:00
|
|
|
int
|
1996-12-11 01:54:46 +03:00
|
|
|
busmatch(parent, cf, aux)
|
1994-08-24 13:16:46 +04:00
|
|
|
struct device *parent;
|
1996-12-11 01:54:46 +03:00
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
1994-08-24 13:16:46 +04:00
|
|
|
{
|
1994-10-03 00:59:56 +03:00
|
|
|
register struct confargs *ca = aux;
|
|
|
|
register struct romaux *ra = &ca->ca_ra;
|
|
|
|
|
1996-04-01 02:28:38 +04:00
|
|
|
if (CPU_ISSUN4M)
|
|
|
|
return (strcmp(cf->cf_driver->cd_name, ra->ra_name) == 0);
|
|
|
|
|
|
|
|
if (!CPU_ISSUN4)
|
1994-10-03 00:59:56 +03:00
|
|
|
return (0);
|
1996-04-01 02:28:38 +04:00
|
|
|
|
1994-10-03 00:59:56 +03:00
|
|
|
return (strcmp(cf->cf_driver->cd_name, ra->ra_name) == 0);
|
1994-08-24 13:16:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1994-10-15 08:48:47 +03:00
|
|
|
busprint(args, obio)
|
1994-08-24 13:16:46 +04:00
|
|
|
void *args;
|
1996-08-28 01:53:46 +04:00
|
|
|
const char *obio;
|
1994-08-24 13:16:46 +04:00
|
|
|
{
|
1994-09-18 03:49:58 +04:00
|
|
|
register struct confargs *ca = args;
|
|
|
|
|
|
|
|
if (ca->ca_ra.ra_name == NULL)
|
|
|
|
ca->ca_ra.ra_name = "<unknown>";
|
1996-04-01 02:28:38 +04:00
|
|
|
|
1994-09-18 03:49:58 +04:00
|
|
|
if (obio)
|
1996-10-13 06:59:55 +04:00
|
|
|
printf("[%s at %s]", ca->ca_ra.ra_name, obio);
|
1996-04-01 02:28:38 +04:00
|
|
|
|
1996-10-13 06:59:55 +04:00
|
|
|
printf(" addr %p", ca->ca_ra.ra_paddr);
|
1996-04-01 02:28:38 +04:00
|
|
|
|
|
|
|
if (CPU_ISSUN4 && ca->ca_ra.ra_intr[0].int_vec != -1)
|
1996-10-13 06:59:55 +04:00
|
|
|
printf(" vec 0x%x", ca->ca_ra.ra_intr[0].int_vec);
|
1996-04-01 02:28:38 +04:00
|
|
|
|
1994-08-24 13:16:46 +04:00
|
|
|
return (UNCONF);
|
|
|
|
}
|
|
|
|
|
1997-05-18 23:37:37 +04:00
|
|
|
int
|
|
|
|
vmeprint(args, name)
|
|
|
|
void *args;
|
|
|
|
const char *name;
|
|
|
|
{
|
|
|
|
register struct confargs *ca = args;
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
printf("%s at %s", ca->ca_ra.ra_name, name);
|
|
|
|
return (UNCONF);
|
|
|
|
}
|
1995-04-25 23:59:49 +04:00
|
|
|
|
1996-04-01 02:28:38 +04:00
|
|
|
void
|
|
|
|
obioattach(parent, self, args)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *args;
|
|
|
|
{
|
|
|
|
#if defined(SUN4M)
|
|
|
|
register struct bus_softc *sc = (struct bus_softc *)self;
|
|
|
|
struct confargs oca, *ca = args;
|
|
|
|
register struct romaux *ra = &ca->ca_ra;
|
|
|
|
register int node0, node;
|
|
|
|
register char *name;
|
|
|
|
register const char *sp;
|
|
|
|
const char *const *ssp;
|
1997-04-09 00:08:20 +04:00
|
|
|
int rlen;
|
1996-04-01 02:28:38 +04:00
|
|
|
extern int autoconf_nzs;
|
|
|
|
|
|
|
|
static const char *const special4m[] = {
|
|
|
|
/* find these first */
|
|
|
|
"eeprom",
|
|
|
|
"counter",
|
1996-12-11 02:24:56 +03:00
|
|
|
#if 0 /* Not all sun4m's have an `auxio' */
|
1996-04-01 02:28:38 +04:00
|
|
|
"auxio",
|
1996-12-11 02:24:56 +03:00
|
|
|
#endif
|
1996-04-01 02:28:38 +04:00
|
|
|
"",
|
|
|
|
/* place device to ignore here */
|
|
|
|
"interrupt",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (CPU_ISSUN4) {
|
|
|
|
if (self->dv_unit > 0) {
|
1996-10-13 06:59:55 +04:00
|
|
|
printf(" unsupported\n");
|
1996-04-01 02:28:38 +04:00
|
|
|
return;
|
|
|
|
}
|
1996-10-13 06:59:55 +04:00
|
|
|
printf("\n");
|
1996-04-01 02:28:38 +04:00
|
|
|
|
|
|
|
(void)config_search(obio_scan, self, args);
|
|
|
|
bus_untmp();
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(SUN4M)
|
|
|
|
if (!CPU_ISSUN4M)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* There is only one obio bus (it is in fact one of the Sbus slots)
|
|
|
|
* How about VME?
|
|
|
|
*/
|
1997-05-18 23:37:37 +04:00
|
|
|
if (self->dv_unit > 0) {
|
1996-10-13 06:59:55 +04:00
|
|
|
printf(" unsupported\n");
|
1996-04-01 02:28:38 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1996-10-13 06:59:55 +04:00
|
|
|
printf("\n");
|
1996-04-01 02:28:38 +04:00
|
|
|
|
|
|
|
if (ra->ra_bp != NULL && strcmp(ra->ra_bp->name, "obio") == 0)
|
|
|
|
oca.ca_ra.ra_bp = ra->ra_bp + 1;
|
|
|
|
else
|
|
|
|
oca.ca_ra.ra_bp = NULL;
|
|
|
|
|
1997-04-09 00:08:20 +04:00
|
|
|
node = ra->ra_node;
|
|
|
|
rlen = getproplen(node, "ranges");
|
|
|
|
if (rlen > 0) {
|
|
|
|
sc->bu.scu_sbus.sc_nrange = rlen / sizeof(struct rom_range);
|
|
|
|
sc->bu.scu_sbus.sc_range =
|
|
|
|
(struct rom_range *)malloc(rlen, M_DEVBUF, M_NOWAIT);
|
|
|
|
if (sc->bu.scu_sbus.sc_range == 0)
|
|
|
|
panic("obio: PROM ranges too large: %d", rlen);
|
|
|
|
(void)getprop(node, "ranges", sc->bu.scu_sbus.sc_range, rlen);
|
|
|
|
}
|
1996-04-01 02:28:38 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop through ROM children, fixing any relative addresses
|
|
|
|
* and then configuring each device.
|
|
|
|
* We first do the crucial ones, such as eeprom, etc.
|
|
|
|
*/
|
|
|
|
node0 = firstchild(ra->ra_node);
|
|
|
|
for (ssp = special4m ; *(sp = *ssp) != 0; ssp++) {
|
|
|
|
if ((node = findnode(node0, sp)) == 0) {
|
1996-10-13 06:59:55 +04:00
|
|
|
printf("could not find %s amongst obio devices\n", sp);
|
1996-04-01 02:28:38 +04:00
|
|
|
panic(sp);
|
|
|
|
}
|
|
|
|
if (!romprop(&oca.ca_ra, sp, node))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
sbus_translate(self, &oca);
|
|
|
|
oca.ca_bustype = BUS_OBIO;
|
1997-05-18 23:37:37 +04:00
|
|
|
(void) config_found(self, (void *)&oca, busprint);
|
1996-04-01 02:28:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
for (node = node0; node; node = nextsibling(node)) {
|
|
|
|
name = getpropstring(node, "name");
|
|
|
|
for (ssp = special4m ; (sp = *ssp) != NULL; ssp++)
|
|
|
|
if (strcmp(name, sp) == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (sp != NULL || !romprop(&oca.ca_ra, name, node))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (strcmp(name, "zs") == 0)
|
|
|
|
/* XXX - see autoconf.c for this hack */
|
|
|
|
autoconf_nzs++;
|
|
|
|
|
|
|
|
/* Translate into parent address spaces */
|
|
|
|
sbus_translate(self, &oca);
|
|
|
|
oca.ca_bustype = BUS_OBIO;
|
1997-05-18 23:37:37 +04:00
|
|
|
(void) config_found(self, (void *)&oca, busprint);
|
1996-04-01 02:28:38 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vmesattach(parent, self, args)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *args;
|
|
|
|
{
|
1997-05-18 23:37:37 +04:00
|
|
|
if (self->dv_unit > 0 ||
|
|
|
|
(CPU_ISSUN4M && strncmp(parent->dv_xname, "vme", 3) != 0)) {
|
1996-10-13 06:59:55 +04:00
|
|
|
printf(" unsupported\n");
|
1996-04-01 02:28:38 +04:00
|
|
|
return;
|
|
|
|
}
|
1996-10-13 06:59:55 +04:00
|
|
|
printf("\n");
|
1996-04-01 02:28:38 +04:00
|
|
|
|
|
|
|
if (vmeints == NULL) {
|
|
|
|
vmeints = (struct intrhand **)malloc(256 *
|
|
|
|
sizeof(struct intrhand *), M_TEMP, M_NOWAIT);
|
|
|
|
bzero(vmeints, 256 * sizeof(struct intrhand *));
|
|
|
|
}
|
|
|
|
(void)config_search(vmes_scan, self, args);
|
|
|
|
bus_untmp();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vmelattach(parent, self, args)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *args;
|
|
|
|
{
|
1997-05-18 23:37:37 +04:00
|
|
|
if (self->dv_unit > 0 ||
|
|
|
|
(CPU_ISSUN4M && strncmp(parent->dv_xname, "vme", 3) != 0)) {
|
1996-10-13 06:59:55 +04:00
|
|
|
printf(" unsupported\n");
|
1996-04-01 02:28:38 +04:00
|
|
|
return;
|
|
|
|
}
|
1996-10-13 06:59:55 +04:00
|
|
|
printf("\n");
|
1996-04-01 02:28:38 +04:00
|
|
|
|
|
|
|
if (vmeints == NULL) {
|
|
|
|
vmeints = (struct intrhand **)malloc(256 *
|
|
|
|
sizeof(struct intrhand *), M_TEMP, M_NOWAIT);
|
|
|
|
bzero(vmeints, 256 * sizeof(struct intrhand *));
|
|
|
|
}
|
|
|
|
(void)config_search(vmel_scan, self, args);
|
|
|
|
bus_untmp();
|
|
|
|
}
|
|
|
|
|
1997-05-18 23:37:37 +04:00
|
|
|
void
|
|
|
|
vmeattach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct vmebus_softc *sc = (struct vmebus_softc *)self;
|
|
|
|
struct confargs *ca = aux;
|
|
|
|
register struct romaux *ra = &ca->ca_ra;
|
|
|
|
int node, rlen;
|
|
|
|
struct confargs oca;
|
|
|
|
|
|
|
|
if (!CPU_ISSUN4M || self->dv_unit > 0) {
|
|
|
|
printf(" unsupported\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
node = ra->ra_node;
|
|
|
|
|
|
|
|
sc->sc_reg = (struct vmebusreg *)
|
1997-05-25 00:08:41 +04:00
|
|
|
mapdev(&ra->ra_reg[0], 0, 0, ra->ra_reg[0].rr_len);
|
1997-05-18 23:37:37 +04:00
|
|
|
sc->sc_vec = (struct vmebusvec *)
|
1997-05-25 00:08:41 +04:00
|
|
|
mapdev(&ra->ra_reg[1], 0, 0, ra->ra_reg[1].rr_len);
|
1997-05-18 23:37:37 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get "range" property, though we don't do anything with it yet.
|
|
|
|
*/
|
|
|
|
rlen = getproplen(node, "ranges");
|
|
|
|
if (rlen > 0) {
|
|
|
|
sc->sc_nrange = rlen / sizeof(struct rom_range);
|
|
|
|
sc->sc_range =
|
|
|
|
(struct rom_range *)malloc(rlen, M_DEVBUF, M_NOWAIT);
|
|
|
|
if (sc->sc_range == 0)
|
|
|
|
panic("vme: PROM ranges too large: %d", rlen);
|
|
|
|
(void)getprop(node, "ranges", sc->sc_range, rlen);
|
|
|
|
}
|
|
|
|
|
|
|
|
vmebus_sc = sc;
|
|
|
|
printf(": version %x\n",
|
|
|
|
sc->sc_reg->vmebus_cr & VMEBUS_CR_IMPL);
|
|
|
|
|
|
|
|
if (ra->ra_bp != NULL && strcmp(ra->ra_bp->name, "vme") == 0)
|
|
|
|
oca.ca_ra.ra_bp = ra->ra_bp + 1;
|
|
|
|
else
|
|
|
|
oca.ca_ra.ra_bp = NULL;
|
|
|
|
|
|
|
|
oca.ca_ra.ra_name = "vmes";
|
|
|
|
oca.ca_bustype = BUS_MAIN;
|
|
|
|
(void)config_found(self, (void *)&oca, vmeprint);
|
|
|
|
|
|
|
|
oca.ca_ra.ra_name = "vmel";
|
|
|
|
oca.ca_bustype = BUS_MAIN;
|
|
|
|
(void)config_found(self, (void *)&oca, vmeprint);
|
|
|
|
}
|
|
|
|
|
1997-06-07 23:16:23 +04:00
|
|
|
void
|
|
|
|
vmebus_translate(dev, ca, bustype)
|
|
|
|
struct device *dev;
|
|
|
|
struct confargs *ca;
|
|
|
|
int bustype;
|
|
|
|
{
|
|
|
|
struct vmebus_softc *sc = (struct vmebus_softc *)dev;
|
|
|
|
register int j;
|
|
|
|
int cspace;
|
|
|
|
|
|
|
|
if (sc->sc_nrange == 0)
|
|
|
|
panic("vmebus: no ranges");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find VMEbus modifier based on address space.
|
|
|
|
* XXX - should not be encoded in `ra_paddr'
|
|
|
|
*/
|
|
|
|
if (((u_long)ca->ca_ra.ra_paddr & 0xffff0000) == 0xffff0000)
|
|
|
|
cspace = VMEMOD_A16_D_S;
|
|
|
|
else if (((u_long)ca->ca_ra.ra_paddr & 0xff000000) == 0xff000000)
|
|
|
|
cspace = VMEMOD_A24_D_S;
|
|
|
|
else
|
|
|
|
cspace = VMEMOD_A32_D_S;
|
|
|
|
|
|
|
|
cspace |= (bustype == BUS_VME32) ? VMEMOD_D32 : 0;
|
|
|
|
|
|
|
|
/* Translate into parent address spaces */
|
|
|
|
for (j = 0; j < sc->sc_nrange; j++) {
|
|
|
|
if (sc->sc_range[j].cspace == cspace) {
|
|
|
|
#if notyet
|
|
|
|
(int)ca->ca_ra.ra_paddr +=
|
|
|
|
sc->sc_range[j].poffset;
|
|
|
|
#endif
|
|
|
|
(int)ca->ca_ra.ra_iospace =
|
|
|
|
sc->sc_range[j].pspace;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-05-25 00:08:41 +04:00
|
|
|
int bt2pmt[] = {
|
|
|
|
PMAP_OBIO,
|
|
|
|
PMAP_OBIO,
|
|
|
|
PMAP_VME16,
|
|
|
|
PMAP_VME32,
|
|
|
|
PMAP_OBIO
|
|
|
|
};
|
|
|
|
|
1995-04-25 23:59:49 +04:00
|
|
|
int
|
1996-12-11 01:54:46 +03:00
|
|
|
busattach(parent, cf, args, bustype)
|
1995-04-25 23:59:49 +04:00
|
|
|
struct device *parent;
|
1996-12-11 01:54:46 +03:00
|
|
|
struct cfdata *cf;
|
|
|
|
void *args;
|
1994-10-15 08:48:47 +03:00
|
|
|
int bustype;
|
1994-08-24 13:16:46 +04:00
|
|
|
{
|
1997-05-18 23:37:37 +04:00
|
|
|
#if defined(SUN4) || defined(SUN4M)
|
1994-10-03 00:59:56 +03:00
|
|
|
register struct confargs *ca = args;
|
|
|
|
struct confargs oca;
|
1994-10-15 08:48:47 +03:00
|
|
|
caddr_t tmp;
|
1994-08-24 13:16:46 +04:00
|
|
|
|
1996-04-01 02:28:38 +04:00
|
|
|
if (bustype == BUS_OBIO && CPU_ISSUN4) {
|
1996-04-06 01:50:05 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* avoid sun4m entries which don't have valid PA's.
|
|
|
|
* no point in even probing them.
|
|
|
|
*/
|
|
|
|
if (cf->cf_loc[0] == -1) return 0;
|
|
|
|
|
1995-04-25 23:59:49 +04:00
|
|
|
/*
|
|
|
|
* On the 4/100 obio addresses must be mapped at
|
|
|
|
* 0x0YYYYYYY, but alias higher up (we avoid the
|
|
|
|
* alias condition because it causes pmap difficulties)
|
|
|
|
* XXX: We also assume that 4/[23]00 obio addresses
|
|
|
|
* must be 0xZYYYYYYY, where (Z != 0)
|
|
|
|
*/
|
1997-03-11 02:01:40 +03:00
|
|
|
if (cpuinfo.cpu_type == CPUTYP_4_100 &&
|
|
|
|
(cf->cf_loc[0] & 0xf0000000))
|
1995-04-25 23:59:49 +04:00
|
|
|
return 0;
|
1997-03-11 02:01:40 +03:00
|
|
|
if (cpuinfo.cpu_type != CPUTYP_4_100 &&
|
|
|
|
!(cf->cf_loc[0] & 0xf0000000))
|
1995-04-25 23:59:49 +04:00
|
|
|
return 0;
|
1994-08-24 13:16:46 +04:00
|
|
|
}
|
|
|
|
|
1995-04-25 23:59:49 +04:00
|
|
|
oca.ca_ra.ra_paddr = (void *)cf->cf_loc[0];
|
|
|
|
oca.ca_ra.ra_len = 0;
|
|
|
|
oca.ca_ra.ra_nreg = 1;
|
1997-06-07 23:16:23 +04:00
|
|
|
if (CPU_ISSUN4M)
|
|
|
|
vmebus_translate(parent->dv_parent, &oca, bustype);
|
|
|
|
else
|
|
|
|
oca.ca_ra.ra_iospace = bt2pmt[bustype];
|
|
|
|
|
1995-04-25 23:59:49 +04:00
|
|
|
if (oca.ca_ra.ra_paddr)
|
1997-05-25 00:08:41 +04:00
|
|
|
tmp = (caddr_t)mapdev(oca.ca_ra.ra_reg, TMPMAP_VA, 0, NBPG);
|
1996-05-18 16:22:49 +04:00
|
|
|
else
|
|
|
|
tmp = NULL;
|
1995-04-25 23:59:49 +04:00
|
|
|
oca.ca_ra.ra_vaddr = tmp;
|
|
|
|
oca.ca_ra.ra_intr[0].int_pri = cf->cf_loc[1];
|
|
|
|
if (bustype == BUS_VME16 || bustype == BUS_VME32)
|
|
|
|
oca.ca_ra.ra_intr[0].int_vec = cf->cf_loc[2];
|
|
|
|
else
|
|
|
|
oca.ca_ra.ra_intr[0].int_vec = -1;
|
|
|
|
oca.ca_ra.ra_nintr = 1;
|
|
|
|
oca.ca_ra.ra_name = cf->cf_driver->cd_name;
|
1995-05-27 12:12:51 +04:00
|
|
|
if (ca->ca_ra.ra_bp != NULL &&
|
1995-08-18 12:20:26 +04:00
|
|
|
((bustype == BUS_VME16 && strcmp(ca->ca_ra.ra_bp->name,"vmes") ==0) ||
|
|
|
|
(bustype == BUS_VME32 && strcmp(ca->ca_ra.ra_bp->name,"vmel") ==0) ||
|
|
|
|
(bustype == BUS_OBIO && strcmp(ca->ca_ra.ra_bp->name,"obio") == 0)))
|
1995-05-27 12:12:51 +04:00
|
|
|
oca.ca_ra.ra_bp = ca->ca_ra.ra_bp + 1;
|
|
|
|
else
|
|
|
|
oca.ca_ra.ra_bp = NULL;
|
1995-04-25 23:59:49 +04:00
|
|
|
oca.ca_bustype = bustype;
|
|
|
|
|
1996-03-17 05:00:30 +03:00
|
|
|
if ((*cf->cf_attach->ca_match)(parent, cf, &oca) == 0)
|
1995-04-25 23:59:49 +04:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*
|
1996-04-01 02:28:38 +04:00
|
|
|
* check if XXmatch routine replaced the temporary mapping with
|
1996-01-13 00:44:16 +03:00
|
|
|
* a real mapping. If not, then make sure we don't pass the
|
|
|
|
* tmp mapping to the attach routine.
|
1995-04-25 23:59:49 +04:00
|
|
|
*/
|
1996-01-13 00:44:16 +03:00
|
|
|
if (oca.ca_ra.ra_vaddr == tmp)
|
|
|
|
oca.ca_ra.ra_vaddr = NULL; /* wipe out tmp address */
|
1995-04-25 23:59:49 +04:00
|
|
|
/*
|
1996-04-01 02:28:38 +04:00
|
|
|
* the match routine will set "ra_len" if it wants us to
|
1996-01-13 00:44:16 +03:00
|
|
|
* establish a mapping for it.
|
1995-04-25 23:59:49 +04:00
|
|
|
* (which won't be seen on future XXmatch calls,
|
|
|
|
* so not as useful as it seems.)
|
|
|
|
*/
|
1996-04-01 02:28:38 +04:00
|
|
|
if (oca.ca_ra.ra_len)
|
1995-04-25 23:59:49 +04:00
|
|
|
oca.ca_ra.ra_vaddr =
|
1997-05-25 00:08:41 +04:00
|
|
|
bus_map(oca.ca_ra.ra_reg, oca.ca_ra.ra_len);
|
1995-04-25 23:59:49 +04:00
|
|
|
|
|
|
|
config_attach(parent, cf, &oca, busprint);
|
|
|
|
return 1;
|
1996-04-01 02:28:38 +04:00
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
1995-04-25 23:59:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
obio_scan(parent, child, args)
|
|
|
|
struct device *parent;
|
1996-12-11 01:54:46 +03:00
|
|
|
struct cfdata *child;
|
|
|
|
void *args;
|
1995-04-25 23:59:49 +04:00
|
|
|
{
|
|
|
|
return busattach(parent, child, args, BUS_OBIO);
|
1994-10-15 08:48:47 +03:00
|
|
|
}
|
1994-10-26 10:09:41 +03:00
|
|
|
|
1995-04-25 23:59:49 +04:00
|
|
|
int
|
|
|
|
vmes_scan(parent, child, args)
|
|
|
|
struct device *parent;
|
1996-12-11 01:54:46 +03:00
|
|
|
struct cfdata *child;
|
|
|
|
void *args;
|
1995-04-25 23:59:49 +04:00
|
|
|
{
|
|
|
|
return busattach(parent, child, args, BUS_VME16);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
vmel_scan(parent, child, args)
|
|
|
|
struct device *parent;
|
1996-12-11 01:54:46 +03:00
|
|
|
struct cfdata *child;
|
|
|
|
void *args;
|
1995-04-25 23:59:49 +04:00
|
|
|
{
|
|
|
|
return busattach(parent, child, args, BUS_VME32);
|
1994-09-18 03:49:58 +04:00
|
|
|
}
|
|
|
|
|
1994-10-26 10:09:41 +03:00
|
|
|
int pil_to_vme[] = {
|
|
|
|
-1, /* pil 0 */
|
|
|
|
-1, /* pil 1 */
|
|
|
|
1, /* pil 2 */
|
|
|
|
2, /* pil 3 */
|
|
|
|
-1, /* pil 4 */
|
|
|
|
3, /* pil 5 */
|
|
|
|
-1, /* pil 6 */
|
|
|
|
4, /* pil 7 */
|
|
|
|
-1, /* pil 8 */
|
|
|
|
5, /* pil 9 */
|
|
|
|
-1, /* pil 10 */
|
|
|
|
6, /* pil 11 */
|
|
|
|
-1, /* pil 12 */
|
|
|
|
7, /* pil 13 */
|
|
|
|
-1, /* pil 14 */
|
|
|
|
-1, /* pil 15 */
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
vmeintr(arg)
|
|
|
|
void *arg;
|
|
|
|
{
|
1997-05-18 23:37:37 +04:00
|
|
|
int pil = (int)arg, level, vec;
|
1994-10-26 10:09:41 +03:00
|
|
|
struct intrhand *ih;
|
|
|
|
int i = 0;
|
|
|
|
|
1997-05-18 23:37:37 +04:00
|
|
|
level = (pil_to_vme[pil] << 1) | 1;
|
|
|
|
|
|
|
|
if (CPU_ISSUN4) {
|
|
|
|
vec = ldcontrolb((caddr_t)(AC_VMEINTVEC | level));
|
|
|
|
} else if (CPU_ISSUN4M) {
|
|
|
|
vec = vmebus_sc->sc_vec->vmebusvec[level];
|
|
|
|
} else
|
1996-04-01 02:28:38 +04:00
|
|
|
panic("vme: spurious interrupt");
|
|
|
|
|
1994-11-02 07:55:20 +03:00
|
|
|
if (vec == -1) {
|
1996-10-13 06:59:55 +04:00
|
|
|
printf("vme: spurious interrupt\n");
|
1994-11-02 07:55:20 +03:00
|
|
|
return 0;
|
|
|
|
}
|
1994-10-26 10:09:41 +03:00
|
|
|
|
|
|
|
for (ih = vmeints[vec]; ih; ih = ih->ih_next)
|
|
|
|
if (ih->ih_fun)
|
|
|
|
i += (ih->ih_fun)(ih->ih_arg);
|
|
|
|
return (i);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vmeintr_establish(vec, level, ih)
|
|
|
|
int vec, level;
|
|
|
|
struct intrhand *ih;
|
1996-04-01 02:28:38 +04:00
|
|
|
{
|
1994-10-26 10:09:41 +03:00
|
|
|
struct intrhand *ihs;
|
|
|
|
|
1996-04-01 02:28:38 +04:00
|
|
|
if (!CPU_ISSUN4) {
|
|
|
|
panic("vmeintr_establish: not supported on cpu-type %d",
|
|
|
|
cputyp);
|
|
|
|
}
|
|
|
|
|
1994-11-05 12:28:06 +03:00
|
|
|
if (vec == -1)
|
|
|
|
panic("vmeintr_establish: uninitialized vec\n");
|
|
|
|
|
1994-10-26 10:09:41 +03:00
|
|
|
if (vmeints[vec] == NULL)
|
|
|
|
vmeints[vec] = ih;
|
|
|
|
else {
|
|
|
|
for (ihs = vmeints[vec]; ihs->ih_next; ihs = ihs->ih_next)
|
|
|
|
;
|
|
|
|
ihs->ih_next = ih;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ensure the interrupt subsystem will call us at this level */
|
|
|
|
for (ihs = intrhand[level]; ihs; ihs = ihs->ih_next)
|
|
|
|
if (ihs->ih_fun == vmeintr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ihs = (struct intrhand *)malloc(sizeof(struct intrhand),
|
|
|
|
M_TEMP, M_NOWAIT);
|
|
|
|
if (ihs == NULL)
|
|
|
|
panic("vme_addirq");
|
|
|
|
bzero(ihs, sizeof *ihs);
|
|
|
|
ihs->ih_fun = vmeintr;
|
|
|
|
ihs->ih_arg = (void *)level;
|
|
|
|
intr_establish(level, ihs);
|
|
|
|
}
|
1994-10-15 08:48:47 +03:00
|
|
|
|
1994-09-18 03:49:58 +04:00
|
|
|
#define getpte(va) lda(va, ASI_PTE)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we can find a mapping that was established by the rom, use it.
|
|
|
|
* Else, create a new mapping.
|
|
|
|
*/
|
|
|
|
void *
|
1997-05-25 00:08:41 +04:00
|
|
|
bus_map(pa, len)
|
1995-12-11 15:43:14 +03:00
|
|
|
struct rom_reg *pa;
|
1994-09-18 03:49:58 +04:00
|
|
|
int len;
|
|
|
|
{
|
|
|
|
|
1997-05-18 23:37:37 +04:00
|
|
|
if (CPU_ISSUN4 && len <= NBPG) {
|
|
|
|
u_long pf = (u_long)(pa->rr_paddr) >> PGSHIFT;
|
1997-05-25 00:08:41 +04:00
|
|
|
int pgtype = PMAP_T2PTE_4(pa->rr_iospace);
|
1997-05-18 23:37:37 +04:00
|
|
|
u_long va, pte;
|
|
|
|
|
1994-10-03 00:59:56 +03:00
|
|
|
for (va = OLDMON_STARTVADDR; va < OLDMON_ENDVADDR; va += NBPG) {
|
|
|
|
pte = getpte(va);
|
1994-10-15 08:48:47 +03:00
|
|
|
if ((pte & PG_V) != 0 && (pte & PG_TYPE) == pgtype &&
|
1994-10-03 00:59:56 +03:00
|
|
|
(pte & PG_PFNUM) == pf)
|
1996-01-13 00:44:16 +03:00
|
|
|
return ((void *)
|
|
|
|
(va | ((u_long)pa->rr_paddr & PGOFSET)) );
|
|
|
|
/* note: preserve page offset */
|
1994-10-03 00:59:56 +03:00
|
|
|
}
|
1994-09-18 03:49:58 +04:00
|
|
|
}
|
1997-05-18 23:37:37 +04:00
|
|
|
|
1997-05-25 00:08:41 +04:00
|
|
|
return mapiodev(pa, 0, len);
|
1994-09-18 03:49:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1994-10-15 08:48:47 +03:00
|
|
|
bus_untmp()
|
1994-09-18 03:49:58 +04:00
|
|
|
{
|
1995-04-10 20:48:27 +04:00
|
|
|
pmap_remove(pmap_kernel(), TMPMAP_VA, TMPMAP_VA+NBPG);
|
1994-08-24 13:16:46 +04:00
|
|
|
}
|