Home | History | Annotate | Line # | Download | only in isa
cy_isa.c revision 1.1
      1 /*	$NetBSD: cy_isa.c,v 1.1 1996/09/24 17:45:54 christos 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 
     42 	memcpy(&sc.sc_dev, match, sizeof(struct device));
     43 
     44 	sc.sc_bc = ia->ia_bc;
     45 	sc.sc_bustype = CY_BUSTYPE_ISA;
     46 
     47 	if (ia->ia_irq == IRQUNK) {
     48 		printf("%s: interrupt not defined\n", sc.sc_dev.dv_xname);
     49 		return 0;
     50 	}
     51 
     52 	if (bus_mem_map(ia->ia_bc, ia->ia_maddr, CY_MEMSIZE, 0,
     53 	    &sc.sc_memh) != 0)
     54 		return 0;
     55 
     56 	if (cy_find(&sc) == 0)
     57 		return 0;
     58 
     59 	bus_mem_unmap(ia->ia_bc, sc.sc_memh, CY_MEMSIZE);
     60 
     61 	ia->ia_iosize = 0;
     62 	ia->ia_msize = CY_MEMSIZE;
     63 
     64 	return 1;
     65 }
     66 
     67 static void
     68 cy_attach_isa(parent, self, aux)
     69 	struct device  *parent, *self;
     70 	void *aux;
     71 {
     72 	struct cy_softc *sc = (void *) self;
     73 	struct isa_attach_args *ia = aux;
     74 
     75 	sc->sc_bc = ia->ia_bc;
     76 	sc->sc_bustype = CY_BUSTYPE_ISA;
     77 
     78 	if (bus_mem_map(ia->ia_bc, ia->ia_maddr, CY_MEMSIZE, 0,
     79 	    &sc->sc_memh) != 0)
     80 		panic("%s: Cannot map memory", sc->sc_dev.dv_xname);
     81 
     82 	if (cy_find(sc) == 0)
     83 		panic("%s: Cannot find card", sc->sc_dev.dv_xname);
     84 
     85 	cy_attach(parent, self, aux);
     86 
     87 	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq,
     88 	    IST_EDGE, IPL_TTY, cy_intr, sc);
     89 
     90 	if (sc->sc_ih == NULL)
     91 		printf("%s: couldn't establish interrupt", sc->sc_dev.dv_xname);
     92 }
     93