1998-06-09 11:24:55 +04:00
|
|
|
/* $NetBSD: cy_isa.c,v 1.10 1998/06/09 07:24:58 thorpej Exp $ */
|
1996-09-24 21:45:14 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* cy.c
|
|
|
|
*
|
|
|
|
* Driver for Cyclades Cyclom-8/16/32 multiport serial cards
|
|
|
|
* (currently not tested with Cyclom-32 cards)
|
|
|
|
*
|
|
|
|
* Timo Rossi, 1996
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/intr.h>
|
|
|
|
|
|
|
|
#include <dev/isa/isavar.h>
|
|
|
|
#include <dev/isa/isareg.h>
|
|
|
|
|
|
|
|
#include <dev/ic/cd1400reg.h>
|
|
|
|
#include <dev/ic/cyreg.h>
|
|
|
|
#include <dev/ic/cyvar.h>
|
|
|
|
|
1998-01-14 15:14:41 +03:00
|
|
|
static int cy_probe_isa __P((struct device *, struct cfdata *, void *));
|
1996-09-24 21:45:14 +04:00
|
|
|
static void cy_attach_isa __P((struct device *, struct device *, void *));
|
|
|
|
|
|
|
|
struct cfattach cy_isa_ca = {
|
|
|
|
sizeof(struct cy_softc), cy_probe_isa, cy_attach_isa
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
cy_probe_isa(parent, match, aux)
|
|
|
|
struct device *parent;
|
1998-01-14 15:14:41 +03:00
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
1996-09-24 21:45:14 +04:00
|
|
|
{
|
|
|
|
struct isa_attach_args *ia = aux;
|
|
|
|
struct cy_softc sc;
|
1996-09-26 23:24:04 +04:00
|
|
|
int found;
|
1996-09-24 21:45:14 +04:00
|
|
|
|
|
|
|
memcpy(&sc.sc_dev, match, sizeof(struct device));
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
sc.sc_memt = ia->ia_memt;
|
1996-09-24 21:45:14 +04:00
|
|
|
sc.sc_bustype = CY_BUSTYPE_ISA;
|
|
|
|
|
1998-01-31 14:23:35 +03:00
|
|
|
/* Disallow wildcarded memory address. */
|
|
|
|
if (ia->ia_maddr == ISACF_IOMEM_DEFAULT) {
|
|
|
|
printf("%s: memory addr not defined\n", sc.sc_dev.dv_xname);
|
1997-10-19 22:56:39 +04:00
|
|
|
return (0);
|
1998-01-31 14:23:35 +03:00
|
|
|
}
|
1997-10-19 22:56:39 +04:00
|
|
|
|
1996-09-24 21:45:14 +04:00
|
|
|
if (ia->ia_irq == IRQUNK) {
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s: interrupt not defined\n", sc.sc_dev.dv_xname);
|
1996-09-24 21:45:14 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
if (bus_space_map(ia->ia_memt, ia->ia_maddr, CY_MEMSIZE, 0,
|
|
|
|
&sc.sc_bsh) != 0)
|
1996-09-24 21:45:14 +04:00
|
|
|
return 0;
|
|
|
|
|
1996-09-26 23:24:04 +04:00
|
|
|
found = cy_find(&sc);
|
1996-09-24 21:45:14 +04:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_unmap(ia->ia_memt, sc.sc_bsh, CY_MEMSIZE);
|
1996-09-24 21:45:14 +04:00
|
|
|
|
1996-09-26 23:24:04 +04:00
|
|
|
if (found) {
|
|
|
|
ia->ia_iosize = 0;
|
|
|
|
ia->ia_msize = CY_MEMSIZE;
|
|
|
|
}
|
1996-09-24 21:45:14 +04:00
|
|
|
|
1996-09-26 23:24:04 +04:00
|
|
|
return found;
|
1996-09-24 21:45:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cy_attach_isa(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct cy_softc *sc = (void *) self;
|
|
|
|
struct isa_attach_args *ia = aux;
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
sc->sc_memt = ia->ia_memt;
|
1996-09-24 21:45:14 +04:00
|
|
|
sc->sc_bustype = CY_BUSTYPE_ISA;
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
if (bus_space_map(ia->ia_memt, ia->ia_maddr, CY_MEMSIZE, 0,
|
1997-10-20 22:43:03 +04:00
|
|
|
&sc->sc_bsh) != 0) {
|
|
|
|
printf(": cannot map mem space\n");
|
|
|
|
return;
|
|
|
|
}
|
1996-09-24 21:45:14 +04:00
|
|
|
|
1997-10-20 22:43:03 +04:00
|
|
|
if (cy_find(sc) == 0) {
|
|
|
|
printf(": cy_find failed\n");
|
|
|
|
return;
|
|
|
|
}
|
1996-09-24 21:45:14 +04:00
|
|
|
|
|
|
|
cy_attach(parent, self, aux);
|
|
|
|
|
|
|
|
sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq,
|
|
|
|
IST_EDGE, IPL_TTY, cy_intr, sc);
|
|
|
|
|
|
|
|
if (sc->sc_ih == NULL)
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s: couldn't establish interrupt", sc->sc_dev.dv_xname);
|
1996-09-24 21:45:14 +04:00
|
|
|
}
|