Handle sun4m `obio' devices.
Cleanup `#if defined(SUN4*)' mess.
This commit is contained in:
parent
96f175d477
commit
25aa56ae29
|
@ -1,7 +1,8 @@
|
||||||
/* $NetBSD: obio.c,v 1.21 1996/03/17 02:01:12 thorpej Exp $ */
|
/* $NetBSD: obio.c,v 1.22 1996/03/31 22:28:38 pk Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1993, 1994 Theo de Raadt
|
* Copyright (c) 1993, 1994 Theo de Raadt
|
||||||
|
* Copyright (c) 1995 Paul Kranenburg
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -49,26 +50,29 @@
|
||||||
#include <machine/ctlreg.h>
|
#include <machine/ctlreg.h>
|
||||||
#include <sparc/sparc/asm.h>
|
#include <sparc/sparc/asm.h>
|
||||||
#include <sparc/sparc/vaddrs.h>
|
#include <sparc/sparc/vaddrs.h>
|
||||||
|
#include <sparc/dev/sbusvar.h>
|
||||||
|
|
||||||
struct bus_softc {
|
struct bus_softc {
|
||||||
struct device sc_dev; /* base device */
|
union {
|
||||||
int nothing;
|
struct device scu_dev; /* base device */
|
||||||
|
struct sbus_softc scu_sbus; /* obio is another sbus slot */
|
||||||
|
} bu;
|
||||||
|
#define sc_dev bu.scu_dev
|
||||||
};
|
};
|
||||||
|
|
||||||
/* autoconfiguration driver */
|
/* autoconfiguration driver */
|
||||||
static int busmatch __P((struct device *, void *, void *));
|
static int busmatch __P((struct device *, void *, void *));
|
||||||
static void obioattach __P((struct device *, struct device *, void *));
|
static void obioattach __P((struct device *, struct device *, void *));
|
||||||
int busprint __P((void *, char *));
|
|
||||||
#if defined(SUN4)
|
|
||||||
static void vmesattach __P((struct device *, struct device *, void *));
|
static void vmesattach __P((struct device *, struct device *, void *));
|
||||||
static void vmelattach __P((struct device *, struct device *, void *));
|
static void vmelattach __P((struct device *, struct device *, void *));
|
||||||
|
|
||||||
|
int busprint __P((void *, char *));
|
||||||
static int busattach __P((struct device *, void *, void *, int));
|
static int busattach __P((struct device *, void *, void *, int));
|
||||||
void * bus_map __P((struct rom_reg *, int, int));
|
void * bus_map __P((struct rom_reg *, int, int));
|
||||||
int obio_scan __P((struct device *, void *, void *));
|
int obio_scan __P((struct device *, void *, void *));
|
||||||
int vmes_scan __P((struct device *, void *, void *));
|
int vmes_scan __P((struct device *, void *, void *));
|
||||||
int vmel_scan __P((struct device *, void *, void *));
|
int vmel_scan __P((struct device *, void *, void *));
|
||||||
int vmeintr __P((void *));
|
int vmeintr __P((void *));
|
||||||
#endif
|
|
||||||
|
|
||||||
struct cfattach obio_ca = {
|
struct cfattach obio_ca = {
|
||||||
sizeof(struct bus_softc), busmatch, obioattach
|
sizeof(struct bus_softc), busmatch, obioattach
|
||||||
|
@ -78,7 +82,6 @@ struct cfdriver obio_cd = {
|
||||||
NULL, "obio", DV_DULL
|
NULL, "obio", DV_DULL
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(SUN4)
|
|
||||||
struct cfattach vmel_ca = {
|
struct cfattach vmel_ca = {
|
||||||
sizeof(struct bus_softc), busmatch, vmelattach
|
sizeof(struct bus_softc), busmatch, vmelattach
|
||||||
};
|
};
|
||||||
|
@ -94,7 +97,8 @@ struct cfattach vmes_ca = {
|
||||||
struct cfdriver vmes_cd = {
|
struct cfdriver vmes_cd = {
|
||||||
NULL, "vmes", DV_DULL
|
NULL, "vmes", DV_DULL
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
struct intrhand **vmeints;
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -106,8 +110,12 @@ busmatch(parent, vcf, aux)
|
||||||
register struct confargs *ca = aux;
|
register struct confargs *ca = aux;
|
||||||
register struct romaux *ra = &ca->ca_ra;
|
register struct romaux *ra = &ca->ca_ra;
|
||||||
|
|
||||||
if (cputyp != CPU_SUN4)
|
if (CPU_ISSUN4M)
|
||||||
|
return (strcmp(cf->cf_driver->cd_name, ra->ra_name) == 0);
|
||||||
|
|
||||||
|
if (!CPU_ISSUN4)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
return (strcmp(cf->cf_driver->cd_name, ra->ra_name) == 0);
|
return (strcmp(cf->cf_driver->cd_name, ra->ra_name) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,27 +128,173 @@ busprint(args, obio)
|
||||||
|
|
||||||
if (ca->ca_ra.ra_name == NULL)
|
if (ca->ca_ra.ra_name == NULL)
|
||||||
ca->ca_ra.ra_name = "<unknown>";
|
ca->ca_ra.ra_name = "<unknown>";
|
||||||
|
|
||||||
if (obio)
|
if (obio)
|
||||||
printf("[%s at %s]", ca->ca_ra.ra_name, obio);
|
printf("[%s at %s]", ca->ca_ra.ra_name, obio);
|
||||||
|
|
||||||
printf(" addr %p", ca->ca_ra.ra_paddr);
|
printf(" addr %p", ca->ca_ra.ra_paddr);
|
||||||
if (ca->ca_ra.ra_intr[0].int_vec != -1)
|
|
||||||
|
if (CPU_ISSUN4 && ca->ca_ra.ra_intr[0].int_vec != -1)
|
||||||
printf(" vec 0x%x", ca->ca_ra.ra_intr[0].int_vec);
|
printf(" vec 0x%x", ca->ca_ra.ra_intr[0].int_vec);
|
||||||
|
|
||||||
return (UNCONF);
|
return (UNCONF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
extern int autoconf_nzs;
|
||||||
|
|
||||||
|
static const char *const special4m[] = {
|
||||||
|
/* find these first */
|
||||||
|
"eeprom",
|
||||||
|
"counter",
|
||||||
|
"auxio",
|
||||||
|
"",
|
||||||
|
/* place device to ignore here */
|
||||||
|
"interrupt",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (CPU_ISSUN4) {
|
||||||
|
if (self->dv_unit > 0) {
|
||||||
|
printf(" unsupported\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
(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?
|
||||||
|
*/
|
||||||
|
if (sc->sc_dev.dv_unit > 0) {
|
||||||
|
printf(" unsupported\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
sc->bu.scu_sbus.sc_range = ra->ra_range;
|
||||||
|
sc->bu.scu_sbus.sc_nrange = ra->ra_nrange;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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) {
|
||||||
|
printf("could not find %s amongst obio devices\n", sp);
|
||||||
|
panic(sp);
|
||||||
|
}
|
||||||
|
if (!romprop(&oca.ca_ra, sp, node))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
sbus_translate(self, &oca);
|
||||||
|
oca.ca_bustype = BUS_OBIO;
|
||||||
|
(void) config_found(&sc->sc_dev, (void *)&oca, busprint);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
(void) config_found(&sc->sc_dev, (void *)&oca, busprint);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
vmesattach(parent, self, args)
|
||||||
|
struct device *parent, *self;
|
||||||
|
void *args;
|
||||||
|
{
|
||||||
|
if (CPU_ISSUN4M || self->dv_unit > 0) {
|
||||||
|
printf(" unsupported\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
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;
|
||||||
|
{
|
||||||
|
if (CPU_ISSUN4M || self->dv_unit > 0) {
|
||||||
|
printf(" unsupported\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
busattach(parent, child, args, bustype)
|
busattach(parent, child, args, bustype)
|
||||||
struct device *parent;
|
struct device *parent;
|
||||||
void *args, *child;
|
void *args, *child;
|
||||||
int bustype;
|
int bustype;
|
||||||
{
|
{
|
||||||
|
#if defined(SUN4)
|
||||||
struct cfdata *cf = child;
|
struct cfdata *cf = child;
|
||||||
register struct confargs *ca = args;
|
register struct confargs *ca = args;
|
||||||
struct confargs oca;
|
struct confargs oca;
|
||||||
caddr_t tmp;
|
caddr_t tmp;
|
||||||
|
|
||||||
if (bustype == BUS_OBIO && cputyp == CPU_SUN4) {
|
if (bustype == BUS_OBIO && CPU_ISSUN4) {
|
||||||
/*
|
/*
|
||||||
* On the 4/100 obio addresses must be mapped at
|
* On the 4/100 obio addresses must be mapped at
|
||||||
* 0x0YYYYYYY, but alias higher up (we avoid the
|
* 0x0YYYYYYY, but alias higher up (we avoid the
|
||||||
|
@ -148,9 +302,9 @@ busattach(parent, child, args, bustype)
|
||||||
* XXX: We also assume that 4/[23]00 obio addresses
|
* XXX: We also assume that 4/[23]00 obio addresses
|
||||||
* must be 0xZYYYYYYY, where (Z != 0)
|
* must be 0xZYYYYYYY, where (Z != 0)
|
||||||
*/
|
*/
|
||||||
if (cpumod==SUN4_100 && (cf->cf_loc[0] & 0xf0000000))
|
if (cpumod == SUN4_100 && (cf->cf_loc[0] & 0xf0000000))
|
||||||
return 0;
|
return 0;
|
||||||
if (cpumod!=SUN4_100 && !(cf->cf_loc[0] & 0xf0000000))
|
if (cpumod != SUN4_100 && !(cf->cf_loc[0] & 0xf0000000))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,28 +342,30 @@ busattach(parent, child, args, bustype)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check if XXmatch routine replaced the temporary mapping with
|
* check if XXmatch routine replaced the temporary mapping with
|
||||||
* a real mapping. If not, then make sure we don't pass the
|
* a real mapping. If not, then make sure we don't pass the
|
||||||
* tmp mapping to the attach routine.
|
* tmp mapping to the attach routine.
|
||||||
*/
|
*/
|
||||||
if (oca.ca_ra.ra_vaddr == tmp)
|
if (oca.ca_ra.ra_vaddr == tmp)
|
||||||
oca.ca_ra.ra_vaddr = NULL; /* wipe out tmp address */
|
oca.ca_ra.ra_vaddr = NULL; /* wipe out tmp address */
|
||||||
/*
|
/*
|
||||||
* the match routine will set "ra_len" if it wants us to
|
* the match routine will set "ra_len" if it wants us to
|
||||||
* establish a mapping for it.
|
* establish a mapping for it.
|
||||||
* (which won't be seen on future XXmatch calls,
|
* (which won't be seen on future XXmatch calls,
|
||||||
* so not as useful as it seems.)
|
* so not as useful as it seems.)
|
||||||
*/
|
*/
|
||||||
if (oca.ca_ra.ra_len)
|
if (oca.ca_ra.ra_len)
|
||||||
oca.ca_ra.ra_vaddr =
|
oca.ca_ra.ra_vaddr =
|
||||||
bus_map(oca.ca_ra.ra_reg,
|
bus_map(oca.ca_ra.ra_reg,
|
||||||
oca.ca_ra.ra_len, oca.ca_bustype);
|
oca.ca_ra.ra_len, oca.ca_bustype);
|
||||||
|
|
||||||
config_attach(parent, cf, &oca, busprint);
|
config_attach(parent, cf, &oca, busprint);
|
||||||
return 1;
|
return 1;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(SUN4)
|
|
||||||
int
|
int
|
||||||
obio_scan(parent, child, args)
|
obio_scan(parent, child, args)
|
||||||
struct device *parent;
|
struct device *parent;
|
||||||
|
@ -217,29 +373,6 @@ obio_scan(parent, child, args)
|
||||||
{
|
{
|
||||||
return busattach(parent, child, args, BUS_OBIO);
|
return busattach(parent, child, args, BUS_OBIO);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
|
||||||
obioattach(parent, self, args)
|
|
||||||
struct device *parent, *self;
|
|
||||||
void *args;
|
|
||||||
{
|
|
||||||
#if defined(SUN4)
|
|
||||||
if (cputyp == CPU_SUN4) {
|
|
||||||
if (self->dv_unit > 0) {
|
|
||||||
printf(" unsupported\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
(void)config_search(obio_scan, self, args);
|
|
||||||
bus_untmp();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(SUN4)
|
|
||||||
struct intrhand **vmeints;
|
|
||||||
|
|
||||||
int
|
int
|
||||||
vmes_scan(parent, child, args)
|
vmes_scan(parent, child, args)
|
||||||
|
@ -249,26 +382,6 @@ vmes_scan(parent, child, args)
|
||||||
return busattach(parent, child, args, BUS_VME16);
|
return busattach(parent, child, args, BUS_VME16);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
vmesattach(parent, self, args)
|
|
||||||
struct device *parent, *self;
|
|
||||||
void *args;
|
|
||||||
{
|
|
||||||
if (self->dv_unit > 0) {
|
|
||||||
printf(" unsupported\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
vmel_scan(parent, child, args)
|
vmel_scan(parent, child, args)
|
||||||
struct device *parent;
|
struct device *parent;
|
||||||
|
@ -277,26 +390,6 @@ vmel_scan(parent, child, args)
|
||||||
return busattach(parent, child, args, BUS_VME32);
|
return busattach(parent, child, args, BUS_VME32);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
vmelattach(parent, self, args)
|
|
||||||
struct device *parent, *self;
|
|
||||||
void *args;
|
|
||||||
{
|
|
||||||
if (self->dv_unit > 0) {
|
|
||||||
printf(" unsupported\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
int pil_to_vme[] = {
|
int pil_to_vme[] = {
|
||||||
-1, /* pil 0 */
|
-1, /* pil 0 */
|
||||||
-1, /* pil 1 */
|
-1, /* pil 1 */
|
||||||
|
@ -324,6 +417,12 @@ vmeintr(arg)
|
||||||
struct intrhand *ih;
|
struct intrhand *ih;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
#ifdef DIAGNOSTIC
|
||||||
|
if (!CPU_ISSUN4) {
|
||||||
|
panic("vme: spurious interrupt");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
vec = ldcontrolb((caddr_t)
|
vec = ldcontrolb((caddr_t)
|
||||||
(AC_VMEINTVEC | (pil_to_vme[level] << 1) | 1));
|
(AC_VMEINTVEC | (pil_to_vme[level] << 1) | 1));
|
||||||
if (vec == -1) {
|
if (vec == -1) {
|
||||||
|
@ -341,9 +440,14 @@ void
|
||||||
vmeintr_establish(vec, level, ih)
|
vmeintr_establish(vec, level, ih)
|
||||||
int vec, level;
|
int vec, level;
|
||||||
struct intrhand *ih;
|
struct intrhand *ih;
|
||||||
{
|
{
|
||||||
struct intrhand *ihs;
|
struct intrhand *ihs;
|
||||||
|
|
||||||
|
if (!CPU_ISSUN4) {
|
||||||
|
panic("vmeintr_establish: not supported on cpu-type %d",
|
||||||
|
cputyp);
|
||||||
|
}
|
||||||
|
|
||||||
if (vec == -1)
|
if (vec == -1)
|
||||||
panic("vmeintr_establish: uninitialized vec\n");
|
panic("vmeintr_establish: uninitialized vec\n");
|
||||||
|
|
||||||
|
@ -420,8 +524,8 @@ bus_tmp(pa, bustype)
|
||||||
int pmtype = bt2pmt[bustype];
|
int pmtype = bt2pmt[bustype];
|
||||||
|
|
||||||
pmap_enter(pmap_kernel(), TMPMAP_VA,
|
pmap_enter(pmap_kernel(), TMPMAP_VA,
|
||||||
addr | pmtype | PMAP_NC,
|
addr | pmtype | PMAP_NC,
|
||||||
VM_PROT_READ | VM_PROT_WRITE, 1);
|
VM_PROT_READ | VM_PROT_WRITE, 1);
|
||||||
return ((void *)(TMPMAP_VA | ((u_long) pa & PGOFSET)) );
|
return ((void *)(TMPMAP_VA | ((u_long) pa & PGOFSET)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,4 +534,3 @@ bus_untmp()
|
||||||
{
|
{
|
||||||
pmap_remove(pmap_kernel(), TMPMAP_VA, TMPMAP_VA+NBPG);
|
pmap_remove(pmap_kernel(), TMPMAP_VA, TMPMAP_VA+NBPG);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
Loading…
Reference in New Issue