1 /* $NetBSD: cy_isa.c,v 1.5 1996/10/21 22:40:36 thorpej Exp $ */ 2 3 /* 4 * cy.c 5 * 6 * Driver for Cyclades Cyclom-8/16/32 multiport serial cards 7 * (currently not tested with Cyclom-32 cards) 8 * 9 * Timo Rossi, 1996 10 * 11 */ 12 13 #include <sys/param.h> 14 #include <sys/systm.h> 15 #include <sys/device.h> 16 17 #include <machine/bus.h> 18 #include <machine/intr.h> 19 20 #include <dev/isa/isavar.h> 21 #include <dev/isa/isareg.h> 22 23 #include <dev/ic/cd1400reg.h> 24 #include <dev/ic/cyreg.h> 25 #include <dev/ic/cyvar.h> 26 27 static int cy_probe_isa __P((struct device *, void *, void *)); 28 static void cy_attach_isa __P((struct device *, struct device *, void *)); 29 30 struct cfattach cy_isa_ca = { 31 sizeof(struct cy_softc), cy_probe_isa, cy_attach_isa 32 }; 33 34 static int 35 cy_probe_isa(parent, match, aux) 36 struct device *parent; 37 void *match, *aux; 38 { 39 struct isa_attach_args *ia = aux; 40 struct cy_softc sc; 41 int found; 42 43 memcpy(&sc.sc_dev, match, sizeof(struct device)); 44 45 sc.sc_memt = ia->ia_memt; 46 sc.sc_bustype = CY_BUSTYPE_ISA; 47 48 if (ia->ia_irq == IRQUNK) { 49 printf("%s: interrupt not defined\n", sc.sc_dev.dv_xname); 50 return 0; 51 } 52 53 if (bus_space_map(ia->ia_memt, ia->ia_maddr, CY_MEMSIZE, 0, 54 &sc.sc_bsh) != 0) 55 return 0; 56 57 found = cy_find(&sc); 58 59 bus_space_unmap(ia->ia_memt, sc.sc_bsh, CY_MEMSIZE); 60 61 if (found) { 62 ia->ia_iosize = 0; 63 ia->ia_msize = CY_MEMSIZE; 64 } 65 66 return found; 67 } 68 69 static void 70 cy_attach_isa(parent, self, aux) 71 struct device *parent, *self; 72 void *aux; 73 { 74 struct cy_softc *sc = (void *) self; 75 struct isa_attach_args *ia = aux; 76 77 sc->sc_memt = ia->ia_memt; 78 sc->sc_bustype = CY_BUSTYPE_ISA; 79 80 if (bus_space_map(ia->ia_memt, ia->ia_maddr, CY_MEMSIZE, 0, 81 &sc->sc_bsh) != 0) 82 panic("%s: Cannot map memory", sc->sc_dev.dv_xname); 83 84 if (cy_find(sc) == 0) 85 panic("%s: Cannot find card", sc->sc_dev.dv_xname); 86 87 cy_attach(parent, self, aux); 88 89 sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, 90 IST_EDGE, IPL_TTY, cy_intr, sc); 91 92 if (sc->sc_ih == NULL) 93 printf("%s: couldn't establish interrupt", sc->sc_dev.dv_xname); 94 } 95