initial implementation of OFW ISA bus code and attachments for a few

devices.  Still a bit rough, but works well enough.  Requires a bunch of
machine-dependent glue (since this is, in effect, a MI bus bridge).
This commit is contained in:
cgd 1998-02-07 00:46:45 +00:00
parent 26d7b63bd3
commit 5942e0ff3d
6 changed files with 879 additions and 0 deletions

162
sys/dev/ofisa/com_ofisa.c Normal file
View File

@ -0,0 +1,162 @@
/* $NetBSD: com_ofisa.c,v 1.1 1998/02/07 00:46:45 cgd Exp $ */
/*
* Copyright 1997, 1998
* Digital Equipment Corporation. All rights reserved.
*
* This software is furnished under license and may be used and
* copied only in accordance with the following terms and conditions.
* Subject to these conditions, you may download, copy, install,
* use, modify and distribute this software in source and/or binary
* form. No title or ownership is transferred hereby.
*
* 1) Any source code used, modified or distributed must reproduce
* and retain this copyright notice and list of conditions as
* they appear in the source file.
*
* 2) No right is granted to use any trade name, trademark, or logo of
* Digital Equipment Corporation. Neither the "Digital Equipment
* Corporation" name nor any trademark or logo of Digital Equipment
* Corporation may be used to endorse or promote products derived
* from this software without the prior written permission of
* Digital Equipment Corporation.
*
* 3) This software is provided "AS-IS" and any express or implied
* warranties, including but not limited to, any implied warranties
* of merchantability, fitness for a particular purpose, or
* non-infringement are disclaimed. In no event shall DIGITAL be
* liable for any damages whatsoever, and in particular, DIGITAL
* shall not be liable for special, indirect, consequential, or
* incidental damages or damages for lost profits, loss of
* revenue or loss of use, whether such damages arise in contract,
* negligence, tort, under statute, in equity, at law or otherwise,
* even if advised of the possibility of such damage.
*/
/*
* OFW Attachment for 'com' serial driver
*/
#include <sys/param.h>
#include <sys/device.h>
#include <sys/socket.h>
#include <sys/tty.h>
#include <machine/intr.h>
#include <machine/bus.h>
#include <dev/ofw/openfirm.h>
#include <dev/isa/isavar.h>
#include <dev/ofisa/ofisavar.h>
#include <dev/ic/comreg.h>
#include <dev/ic/comvar.h>
struct com_ofisa_softc {
struct com_softc sc_com; /* real "com" softc */
/* OFW ISA-specific goo. */
void *sc_ih; /* interrupt handler */
};
int com_ofisa_probe __P((struct device *, struct cfdata *, void *));
void com_ofisa_attach __P((struct device *, struct device *, void *));
struct cfattach com_ofisa_ca = {
sizeof(struct com_ofisa_softc), com_ofisa_probe, com_ofisa_attach
};
int
com_ofisa_probe(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{
struct ofisa_attach_args *aa = aux;
const char *compatible_strings[] = { "pnpPNP,501", NULL };
int rv = 0;
if (of_compatible(aa->ofp.phandle, compatible_strings) != -1)
rv = 5;
#ifdef _COM_OFISA_MD_MATCH
if (!rv)
rv = com_ofisa_md_match(parent, cf, aux);
#endif
return (rv);
}
void
com_ofisa_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct com_ofisa_softc *osc = (void *)self;
struct com_softc *sc = &osc->sc_com;
struct ofisa_attach_args *aa = aux;
struct ofisa_reg_desc reg;
struct ofisa_intr_desc intr;
int freq;
char freqbuf[4];
int n;
/*
* We're living on an ofw. We have to ask the OFW what our
* registers and interrupts properties look like.
*
* We expect exactly one register region and one interrupt.
*/
n = ofisa_reg_get(aa->ofp.phandle, &reg, 1);
#ifdef _COM_OFISA_MD_REG_FIXUP
n = com_ofisa_md_reg_fixup(parent, self, aux, &reg, 1, n);
#endif
if (n != 1) {
printf(": error getting register data\n");
return;
}
if (reg.len != 8) {
printf(": weird register size (%d, expected 8)\n", reg.len);
return;
}
n = ofisa_intr_get(aa->ofp.phandle, &intr, 1);
#ifdef _COM_OFISA_MD_INTR_FIXUP
n = com_ofisa_md_intr_fixup(parent, self, aux, &intr, 1, n);
#endif
if (n != 1) {
printf(": error getting interrupt data\n");
return;
}
if (OF_getproplen(aa->ofp.phandle, "clock-frequency") != 4 ||
OF_getprop(aa->ofp.phandle, "clock-frequency", freqbuf,
sizeof freqbuf) != 4)
freq = COM_FREQ;
else
freq = of_decode_int(&freqbuf[0]);
sc->sc_iot = (reg.type == OFISA_REG_TYPE_IO) ? aa->iot : aa->memt;
sc->sc_iobase = reg.addr;
sc->sc_frequency = freq;
if (!com_is_console(sc->sc_iot, sc->sc_iobase, &sc->sc_ioh) &&
bus_space_map(sc->sc_iot, sc->sc_iobase, reg.len, 0,
&sc->sc_ioh)) {
printf(": can't map register space\n");
return;
}
osc->sc_ih = isa_intr_establish(aa->ic, intr.irq, intr.share,
IPL_SERIAL, comintr, sc);
com_attach_subr(sc);
#if 0
printf("%s: registers: ", sc->sc_dev.dv_xname);
ofisa_reg_print(&reg, 1);
printf("\n");
printf("%s: interrupts: ", sc->sc_dev.dv_xname);
ofisa_intr_print(&intr, 1);
printf("\n");
#endif
}

20
sys/dev/ofisa/files.ofisa Normal file
View File

@ -0,0 +1,20 @@
# $NetBSD: files.ofisa,v 1.1 1998/02/07 00:46:48 cgd Exp $
# OFW ISA bus support
# XXX eventually we should do something with these locators
define ofisa { [i = -1], [it = -1], [iv = -1], [m = -1] }
device ofisa: ofisa, openfirm
attach ofisa at openfirm
file dev/ofisa/ofisa.c ofisa
# attachment for MI com driver
attach com at ofisa with com_ofisa
file dev/ofisa/com_ofisa.c com_ofisa
# attachment for MI lpt driver
attach lpt at ofisa with lpt_ofisa
file dev/ofisa/lpt_ofisa.c lpt_ofisa
# attachment for MI wdc driver
attach wdc at ofisa with wdc_ofisa
file dev/ofisa/wdc_ofisa.c wdc_ofisa

151
sys/dev/ofisa/lpt_ofisa.c Normal file
View File

@ -0,0 +1,151 @@
/* $NetBSD: lpt_ofisa.c,v 1.1 1998/02/07 00:46:50 cgd Exp $ */
/*
* Copyright 1997, 1998
* Digital Equipment Corporation. All rights reserved.
*
* This software is furnished under license and may be used and
* copied only in accordance with the following terms and conditions.
* Subject to these conditions, you may download, copy, install,
* use, modify and distribute this software in source and/or binary
* form. No title or ownership is transferred hereby.
*
* 1) Any source code used, modified or distributed must reproduce
* and retain this copyright notice and list of conditions as
* they appear in the source file.
*
* 2) No right is granted to use any trade name, trademark, or logo of
* Digital Equipment Corporation. Neither the "Digital Equipment
* Corporation" name nor any trademark or logo of Digital Equipment
* Corporation may be used to endorse or promote products derived
* from this software without the prior written permission of
* Digital Equipment Corporation.
*
* 3) This software is provided "AS-IS" and any express or implied
* warranties, including but not limited to, any implied warranties
* of merchantability, fitness for a particular purpose, or
* non-infringement are disclaimed. In no event shall DIGITAL be
* liable for any damages whatsoever, and in particular, DIGITAL
* shall not be liable for special, indirect, consequential, or
* incidental damages or damages for lost profits, loss of
* revenue or loss of use, whether such damages arise in contract,
* negligence, tort, under statute, in equity, at law or otherwise,
* even if advised of the possibility of such damage.
*/
/*
* OFW Attachment for 'lpt' parallel port driver
*/
#include <sys/param.h>
#include <sys/device.h>
#include <sys/socket.h>
#include <sys/tty.h>
#include <machine/intr.h>
#include <machine/bus.h>
#include <dev/ofw/openfirm.h>
#include <dev/isa/isavar.h>
#include <dev/ofisa/ofisavar.h>
#include <dev/ic/lptreg.h>
#include <dev/ic/lptvar.h>
struct lpt_ofisa_softc {
struct lpt_softc sc_lpt; /* real "lpt" softc */
/* OFW ISA-specific goo. */
void *sc_ih; /* interrupt handler */
};
int lpt_ofisa_probe __P((struct device *, struct cfdata *, void *));
void lpt_ofisa_attach __P((struct device *, struct device *, void *));
struct cfattach lpt_ofisa_ca = {
sizeof(struct lpt_ofisa_softc), lpt_ofisa_probe, lpt_ofisa_attach
};
int
lpt_ofisa_probe(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{
struct ofisa_attach_args *aa = aux;
const char *compatible_strings[] = { "pnpPNP,401", NULL };
int rv = 0;
if (of_compatible(aa->ofp.phandle, compatible_strings) != -1)
rv = 5;
#ifdef _LPT_OFISA_MD_MATCH
if (!rv)
rv = lpt_ofisa_md_match(parent, cf, aux);
#endif
return (rv);
}
void
lpt_ofisa_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct lpt_ofisa_softc *osc = (void *)self;
struct lpt_softc *sc = &osc->sc_lpt;
struct ofisa_attach_args *aa = aux;
struct ofisa_reg_desc reg;
struct ofisa_intr_desc intr;
int n;
/*
* We're living on an ofw. We have to ask the OFW what our
* registers and interrupts properties look like.
*
* We expect exactly one register region and one interrupt.
*/
n = ofisa_reg_get(aa->ofp.phandle, &reg, 1);
#ifdef _LPT_OFISA_MD_REG_FIXUP
n = lpt_ofisa_md_reg_fixup(parent, self, aux, &reg, 1, n);
#endif
if (n != 1) {
printf(": error getting register data\n");
return;
}
if (reg.len != 4 && reg.len != 8) {
printf(": weird register size (%d, expected 4 or 8)\n",
reg.len);
return;
}
n = ofisa_intr_get(aa->ofp.phandle, &intr, 1);
#ifdef _LPT_OFISA_MD_INTR_FIXUP
n = lpt_ofisa_md_intr_fixup(parent, self, aux, &intr, 1, n);
#endif
if (n != 1) {
printf(": error getting interrupt data\n");
return;
}
sc->sc_iot = (reg.type == OFISA_REG_TYPE_IO) ? aa->iot : aa->memt;
if (bus_space_map(sc->sc_iot, reg.addr, reg.len, 0, &sc->sc_ioh)) {
printf(": can't map register space\n");
return;
}
osc->sc_ih = isa_intr_establish(aa->ic, intr.irq, intr.share,
IPL_TTY, lptintr, sc);
printf("\n");
lpt_attach_subr(sc);
#if 0
printf("%s: registers: ", sc->sc_dev.dv_xname);
ofisa_reg_print(&reg, 1);
printf("\n");
printf("%s: interrupts: ", sc->sc_dev.dv_xname);
ofisa_intr_print(&intr, 1);
printf("\n");
#endif
}

298
sys/dev/ofisa/ofisa.c Normal file
View File

@ -0,0 +1,298 @@
/* $NetBSD: ofisa.c,v 1.1 1998/02/07 00:46:52 cgd Exp $ */
/*
* Copyright 1997, 1998
* Digital Equipment Corporation. All rights reserved.
*
* This software is furnished under license and may be used and
* copied only in accordance with the following terms and conditions.
* Subject to these conditions, you may download, copy, install,
* use, modify and distribute this software in source and/or binary
* form. No title or ownership is transferred hereby.
*
* 1) Any source code used, modified or distributed must reproduce
* and retain this copyright notice and list of conditions as
* they appear in the source file.
*
* 2) No right is granted to use any trade name, trademark, or logo of
* Digital Equipment Corporation. Neither the "Digital Equipment
* Corporation" name nor any trademark or logo of Digital Equipment
* Corporation may be used to endorse or promote products derived
* from this software without the prior written permission of
* Digital Equipment Corporation.
*
* 3) This software is provided "AS-IS" and any express or implied
* warranties, including but not limited to, any implied warranties
* of merchantability, fitness for a particular purpose, or
* non-infringement are disclaimed. In no event shall DIGITAL be
* liable for any damages whatsoever, and in particular, DIGITAL
* shall not be liable for special, indirect, consequential, or
* incidental damages or damages for lost profits, loss of
* revenue or loss of use, whether such damages arise in contract,
* negligence, tort, under statute, in equity, at law or otherwise,
* even if advised of the possibility of such damage.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <machine/bus.h>
#include <machine/intr.h>
#include <dev/ofw/openfirm.h>
#include <dev/isa/isavar.h>
#include <dev/ofisa/ofisavar.h>
#define OFW_MAX_STACK_BUF_SIZE 256
static int ofisamatch __P((struct device *, struct cfdata *, void *));
static void ofisaattach __P((struct device *, struct device *, void *));
struct cfattach ofisa_ca = {
sizeof(struct device), ofisamatch, ofisaattach
};
struct cfdriver ofisa_cd = {
NULL, "ofisa", DV_DULL
};
static int ofisaprint __P((void *, const char *));
static int
ofisaprint(aux, pnp)
void *aux;
const char *pnp;
{
struct ofprobe *ofp = aux;
char name[64];
(void)of_packagename(ofp->phandle, name, sizeof name);
if (pnp)
printf("%s at %s", name, pnp);
else
printf(" (%s)", name);
return UNCONF;
}
int
ofisamatch(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{
struct ofprobe *ofp = aux;
const char *compatible_strings[] = { "pnpPNP,a00", NULL };
int rv = 0;
if (of_compatible(ofp->phandle, compatible_strings) != -1)
rv = 5;
#ifdef _OFISA_MD_MATCH
if (!rv)
rv = ofisa_md_match(parent, cf, aux);
#endif
return (rv);
}
void
ofisaattach(parent, dev, aux)
struct device *parent, *dev;
void *aux;
{
struct ofprobe *ofp = aux;
struct isabus_attach_args iba;
struct ofisa_attach_args aa;
int child;
if (ofisa_get_isabus_data(ofp->phandle, &iba) < 0) {
printf(": couldn't get essential bus data\n");
return;
}
printf("\n");
for (child = OF_child(ofp->phandle); child;
child = OF_peer(child)) {
if (ofisa_ignore_child(ofp->phandle, child))
continue;
bzero(&aa, sizeof aa);
aa.ofp.phandle = child;
aa.iot = iba.iba_iot;
aa.memt = iba.iba_memt;
aa.dmat = iba.iba_dmat;
aa.ic = iba.iba_ic;
config_found(dev, &aa, ofisaprint);
}
}
int
ofisa_reg_count(phandle)
int phandle;
{
int len;
len = OF_getproplen(phandle, "reg");
/* nonexistant or obviously malformed "reg" property */
if (len < 0 || (len % 12) != 0)
return (-1);
return (len / 12);
}
int
ofisa_reg_get(phandle, descp, ndescs)
int phandle;
struct ofisa_reg_desc *descp;
int ndescs;
{
char *buf, *bp;
int i, allocated, rv;
i = ofisa_reg_count(phandle);
if (i < 0)
return (-1);
ndescs = min(ndescs, i);
i = ndescs * 12;
if (i > OFW_MAX_STACK_BUF_SIZE) {
buf = malloc(i, M_TEMP, M_WAITOK);
allocated = 1;
} else {
buf = alloca(i);
allocated = 0;
}
if (OF_getprop(phandle, "reg", buf, i) != i) {
rv = -1;
goto out;
}
for (i = 0, bp = buf; i < ndescs; i++, bp += 12) {
if (of_decode_int(&bp[0]) & 1)
descp[i].type = OFISA_REG_TYPE_IO;
else
descp[i].type = OFISA_REG_TYPE_MEM;
descp[i].addr = of_decode_int(&bp[4]);
descp[i].len = of_decode_int(&bp[8]);
}
rv = i; /* number of descriptors processed (== ndescs) */
out:
if (allocated)
free(buf, M_TEMP);
return (rv);
}
void
ofisa_reg_print(descp, ndescs)
struct ofisa_reg_desc *descp;
int ndescs;
{
int i;
if (ndescs == 0) {
printf("none");
return;
}
for (i = 0; i < ndescs; i++) {
printf("%s%s 0x%lx/%ld", i ? ", " : "",
descp[i].type == OFISA_REG_TYPE_IO ? "io" : "mem",
(long)descp[i].addr, (long)descp[i].len);
}
}
int
ofisa_intr_count(phandle)
int phandle;
{
int len;
len = OF_getproplen(phandle, "interrupts");
/* nonexistant or obviously malformed "reg" property */
if (len < 0 || (len % 8) != 0)
return (-1);
return (len / 8);
}
int
ofisa_intr_get(phandle, descp, ndescs)
int phandle;
struct ofisa_intr_desc *descp;
int ndescs;
{
char *buf, *bp;
int i, allocated, rv;
i = ofisa_intr_count(phandle);
if (i < 0)
return (-1);
ndescs = min(ndescs, i);
i = ndescs * 8;
if (i > OFW_MAX_STACK_BUF_SIZE) {
buf = malloc(i, M_TEMP, M_WAITOK);
allocated = 1;
} else {
buf = alloca(i);
allocated = 0;
}
if (OF_getprop(phandle, "interrupts", buf, i) != i) {
rv = -1;
goto out;
}
for (i = 0, bp = buf; i < ndescs; i++, bp += 8) {
descp[i].irq = of_decode_int(&bp[0]);
switch (of_decode_int(&bp[4])) {
case 0:
case 1:
descp[i].share = IST_LEVEL;
break;
case 2:
case 3:
descp[i].share = IST_EDGE;
break;
#ifdef DIAGNOSTIC
default:
/* Dunno what to do, so fail. */
printf("ofisa_intr_get: unknown intrerrupt type %d\n",
of_decode_int(&bp[4]));
rv = -1;
goto out;
#endif
}
}
rv = i; /* number of descriptors processed (== ndescs) */
out:
if (allocated)
free(buf, M_TEMP);
return (rv);
}
void
ofisa_intr_print(descp, ndescs)
struct ofisa_intr_desc *descp;
int ndescs;
{
int i;
if (ndescs == 0) {
printf("none");
return;
}
for (i = 0; i < ndescs; i++) {
printf("%s%d (%s)", i ? ", " : "", descp[i].irq,
descp[i].share == IST_LEVEL ? "level" : "edge");
}
}

90
sys/dev/ofisa/ofisavar.h Normal file
View File

@ -0,0 +1,90 @@
/* $NetBSD: ofisavar.h,v 1.1 1998/02/07 00:46:54 cgd Exp $ */
/*
* Copyright 1998
* Digital Equipment Corporation. All rights reserved.
*
* This software is furnished under license and may be used and
* copied only in accordance with the following terms and conditions.
* Subject to these conditions, you may download, copy, install,
* use, modify and distribute this software in source and/or binary
* form. No title or ownership is transferred hereby.
*
* 1) Any source code used, modified or distributed must reproduce
* and retain this copyright notice and list of conditions as
* they appear in the source file.
*
* 2) No right is granted to use any trade name, trademark, or logo of
* Digital Equipment Corporation. Neither the "Digital Equipment
* Corporation" name nor any trademark or logo of Digital Equipment
* Corporation may be used to endorse or promote products derived
* from this software without the prior written permission of
* Digital Equipment Corporation.
*
* 3) This software is provided "AS-IS" and any express or implied
* warranties, including but not limited to, any implied warranties
* of merchantability, fitness for a particular purpose, or
* non-infringement are disclaimed. In no event shall DIGITAL be
* liable for any damages whatsoever, and in particular, DIGITAL
* shall not be liable for special, indirect, consequential, or
* incidental damages or damages for lost profits, loss of
* revenue or loss of use, whether such damages arise in contract,
* negligence, tort, under statute, in equity, at law or otherwise,
* even if advised of the possibility of such damage.
*/
#ifndef _DEV_OFISA_OFISAVAR_H_
#define _DEV_OFISA_OFISAVAR_H_
struct ofisa_attach_args {
struct ofprobe ofp; /* common */
bus_space_tag_t iot; /* i/o space tag */
bus_space_tag_t memt; /* mem space tag */
bus_dma_tag_t dmat; /* DMA tag */
isa_chipset_tag_t ic; /* chipset tag (for intr, etc.) */
};
struct ofisa_reg_desc {
int type; /* type. XXX aliasing modifiers? */
bus_addr_t addr; /* base address. */
bus_size_t len; /* length. */
};
#define OFISA_REG_TYPE_MEM 0 /* memory space */
#define OFISA_REG_TYPE_IO 1 /* I/O space */
struct ofisa_intr_desc {
int share; /* sharing type: IST_*. */
int irq; /* IRQ. */
};
/*
* Machine-dependent function/macro definitions.
*
* Machine-dependent code must implement at least:
*
* int ofisa_get_isabus_data(int phandle,
* struct isabus_attach_args *iba);
*
* int ofisa_ignore_child(int pphandle, int cphandle);
*
* Individual ofisa attachments may want addition functions or
* macros from this (or other) headers. See those attachments'
* files for more details.
*/
#if (arm32 != 1)
ERROR: COMPILING FOR UNSUPPORTED MACHINE, OR MORE THAN ONE.
#endif
#if arm32
#include <arm32/ofw/ofisa_machdep.h>
#endif
int ofisa_reg_count __P((int));
int ofisa_reg_get __P((int, struct ofisa_reg_desc *, int));
void ofisa_reg_print __P((struct ofisa_reg_desc *, int));
int ofisa_intr_count __P((int));
int ofisa_intr_get __P((int, struct ofisa_intr_desc *, int));
void ofisa_intr_print __P((struct ofisa_intr_desc *, int));
#endif /* _DEV_OFISA_OFISAVAR_H_ */

158
sys/dev/ofisa/wdc_ofisa.c Normal file
View File

@ -0,0 +1,158 @@
/* $NetBSD: wdc_ofisa.c,v 1.1 1998/02/07 00:46:56 cgd Exp $ */
/*
* Copyright 1997, 1998
* Digital Equipment Corporation. All rights reserved.
*
* This software is furnished under license and may be used and
* copied only in accordance with the following terms and conditions.
* Subject to these conditions, you may download, copy, install,
* use, modify and distribute this software in source and/or binary
* form. No title or ownership is transferred hereby.
*
* 1) Any source code used, modified or distributed must reproduce
* and retain this copyright notice and list of conditions as
* they appear in the source file.
*
* 2) No right is granted to use any trade name, trademark, or logo of
* Digital Equipment Corporation. Neither the "Digital Equipment
* Corporation" name nor any trademark or logo of Digital Equipment
* Corporation may be used to endorse or promote products derived
* from this software without the prior written permission of
* Digital Equipment Corporation.
*
* 3) This software is provided "AS-IS" and any express or implied
* warranties, including but not limited to, any implied warranties
* of merchantability, fitness for a particular purpose, or
* non-infringement are disclaimed. In no event shall DIGITAL be
* liable for any damages whatsoever, and in particular, DIGITAL
* shall not be liable for special, indirect, consequential, or
* incidental damages or damages for lost profits, loss of
* revenue or loss of use, whether such damages arise in contract,
* negligence, tort, under statute, in equity, at law or otherwise,
* even if advised of the possibility of such damage.
*/
/*
* OFW Attachment for 'wdc' disk controller driver
*/
#include <sys/param.h>
#include <sys/device.h>
#include <sys/socket.h>
#include <sys/tty.h>
#include <machine/intr.h>
#include <machine/bus.h>
#include <dev/ofw/openfirm.h>
#include <dev/isa/isavar.h>
#include <dev/ofisa/ofisavar.h>
#include <dev/ic/wdcreg.h> /* ??? */
#include <dev/ic/wdcvar.h>
struct wdc_ofisa_softc {
struct wdc_softc sc_wdc;
struct wdc_attachment_data sc_ad;
void *sc_ih;
};
int wdc_ofisa_probe __P((struct device *, struct cfdata *, void *));
void wdc_ofisa_attach __P((struct device *, struct device *, void *));
struct cfattach wdc_ofisa_ca = {
sizeof(struct wdc_ofisa_softc), wdc_ofisa_probe, wdc_ofisa_attach
};
int
wdc_ofisa_probe(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{
struct ofisa_attach_args *aa = aux;
const char *compatible_strings[] = { "pnpPNP,600", NULL };
int rv = 0;
if (of_compatible(aa->ofp.phandle, compatible_strings) != -1)
rv = 5;
#ifdef _WDC_OFISA_MD_MATCH
if (!rv)
rv = wdc_ofisa_md_match(parent, cf, aux);
#endif
return (rv);
}
void
wdc_ofisa_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct wdc_ofisa_softc *osc = (void *)self;
struct wdc_softc *sc = &osc->sc_wdc;
struct ofisa_attach_args *aa = aux;
struct ofisa_reg_desc reg[2];
struct ofisa_intr_desc intr;
int n;
/*
* We're living on an ofw. We have to ask the OFW what our
* registers and interrupts properties look like.
*
* We expect exactly two register regions and one interrupt.
*/
n = ofisa_reg_get(aa->ofp.phandle, reg, 2);
#ifdef _WDC_OFISA_MD_REG_FIXUP
n = wdc_ofisa_md_reg_fixup(parent, self, aux, reg, 2, n);
#endif
if (n != 2) {
printf(": error getting register data\n");
return;
}
if (reg[0].len != 8 || reg[1].len != 2) {
printf(": weird register size (%d/%d, expected 8/2)\n",
reg[0].len, reg[1].len);
return;
}
n = ofisa_intr_get(aa->ofp.phandle, &intr, 1);
#ifdef _WDC_OFISA_MD_INTR_FIXUP
n = wdc_ofisa_md_intr_fixup(parent, self, aux, &intr, 1, n);
#endif
if (n != 1) {
printf(": error getting interrupt data\n");
return;
}
bzero(&osc->sc_ad, sizeof osc->sc_ad);
osc->sc_ad.iot =
(reg[0].type == OFISA_REG_TYPE_IO) ? aa->iot : aa->memt;
osc->sc_ad.auxiot =
(reg[1].type == OFISA_REG_TYPE_IO) ? aa->iot : aa->memt;
if (bus_space_map(osc->sc_ad.iot, reg[0].addr, 8, 0,
&osc->sc_ad.ioh) ||
bus_space_map(osc->sc_ad.auxiot, reg[1].addr, 1, 0,
&osc->sc_ad.auxioh)) {
printf(": can't map register spaces\n");
return;
}
osc->sc_ih = isa_intr_establish(aa->ic, intr.irq, intr.share,
IPL_BIO, wdcintr, sc);
printf("\n");
wdcattach(sc, &osc->sc_ad);
#if 0
printf("%s: registers: ", sc->sc_dev.dv_xname);
ofisa_reg_print(reg, 2);
printf("\n");
printf("%s: interrupts: ", sc->sc_dev.dv_xname);
ofisa_intr_print(&intr, 1);
printf("\n");
#endif
}