1 /* $NetBSD: cy_isa.c,v 1.10 1998/06/09 07:24:58 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 *, struct cfdata *, 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 struct cfdata *match; 38 void *aux; 39 { 40 struct isa_attach_args *ia = aux; 41 struct cy_softc sc; 42 int found; 43 44 memcpy(&sc.sc_dev, match, sizeof(struct device)); 45 46 sc.sc_memt = ia->ia_memt; 47 sc.sc_bustype = CY_BUSTYPE_ISA; 48 49 /* Disallow wildcarded memory address. */ 50 if (ia->ia_maddr == ISACF_IOMEM_DEFAULT) { 51 printf("%s: memory addr not defined\n", sc.sc_dev.dv_xname); 52 return (0); 53 } 54 55 if (ia->ia_irq == IRQUNK) { 56 printf("%s: interrupt not defined\n", sc.sc_dev.dv_xname); 57 return 0; 58 } 59 60 if (bus_space_map(ia->ia_memt, ia->ia_maddr, CY_MEMSIZE, 0, 61 &sc.sc_bsh) != 0) 62 return 0; 63 64 found = cy_find(&sc); 65 66 bus_space_unmap(ia->ia_memt, sc.sc_bsh, CY_MEMSIZE); 67 68 if (found) { 69 ia->ia_iosize = 0; 70 ia->ia_msize = CY_MEMSIZE; 71 } 72 73 return found; 74 } 75 76 static void 77 cy_attach_isa(parent, self, aux) 78 struct device *parent, *self; 79 void *aux; 80 { 81 struct cy_softc *sc = (void *) self; 82 struct isa_attach_args *ia = aux; 83 84 sc->sc_memt = ia->ia_memt; 85 sc->sc_bustype = CY_BUSTYPE_ISA; 86 87 if (bus_space_map(ia->ia_memt, ia->ia_maddr, CY_MEMSIZE, 0, 88 &sc->sc_bsh) != 0) { 89 printf(": cannot map mem space\n"); 90 return; 91 } 92 93 if (cy_find(sc) == 0) { 94 printf(": cy_find failed\n"); 95 return; 96 } 97 98 cy_attach(parent, self, aux); 99 100 sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, 101 IST_EDGE, IPL_TTY, cy_intr, sc); 102 103 if (sc->sc_ih == NULL) 104 printf("%s: couldn't establish interrupt", sc->sc_dev.dv_xname); 105 } 106