Home | History | Annotate | Line # | Download | only in isa
cy_isa.c revision 1.13
      1 /*	$NetBSD: cy_isa.c,v 1.13 2001/11/13 08:01:11 lukem 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 #include <sys/cdefs.h>
     13 __KERNEL_RCSID(0, "$NetBSD: cy_isa.c,v 1.13 2001/11/13 08:01:11 lukem Exp $");
     14 
     15 #include <sys/param.h>
     16 #include <sys/systm.h>
     17 #include <sys/device.h>
     18 
     19 #include <machine/bus.h>
     20 #include <machine/intr.h>
     21 
     22 #include <dev/isa/isavar.h>
     23 #include <dev/isa/isareg.h>
     24 
     25 #include <dev/ic/cd1400reg.h>
     26 #include <dev/ic/cyreg.h>
     27 #include <dev/ic/cyvar.h>
     28 
     29 int	cy_isa_probe(struct device *, struct cfdata *, void *);
     30 void	cy_isa_attach(struct device *, struct device *, void *);
     31 
     32 struct cfattach cy_isa_ca = {
     33 	sizeof(struct cy_softc), cy_isa_probe, cy_isa_attach
     34 };
     35 
     36 int
     37 cy_isa_probe(struct device *parent, struct cfdata *match, void *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 	/* Disallow wildcarded memory address. */
     49 	if (ia->ia_maddr == ISACF_IOMEM_DEFAULT)
     50 		return (0);
     51 
     52 	if (ia->ia_irq == IRQUNK)
     53 		return 0;
     54 
     55 	if (bus_space_map(ia->ia_memt, ia->ia_maddr, CY_MEMSIZE, 0,
     56 	    &sc.sc_bsh) != 0)
     57 		return 0;
     58 
     59 	found = cy_find(&sc);
     60 
     61 	bus_space_unmap(ia->ia_memt, sc.sc_bsh, CY_MEMSIZE);
     62 
     63 	if (found) {
     64 		ia->ia_iosize = 0;
     65 		ia->ia_msize = CY_MEMSIZE;
     66 	}
     67 
     68 	return (found);
     69 }
     70 
     71 void
     72 cy_isa_attach(struct device *parent, struct device *self, 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 	printf(": Cyclades-Y multiport serial\n");
     81 
     82 	if (bus_space_map(ia->ia_memt, ia->ia_maddr, CY_MEMSIZE, 0,
     83 	    &sc->sc_bsh) != 0) {
     84 		printf("%s: unable to map device registers\n",
     85 		    sc->sc_dev.dv_xname);
     86 		return;
     87 	}
     88 
     89 	if (cy_find(sc) == 0) {
     90 		printf("%s: unable to find CD1400s\n", sc->sc_dev.dv_xname);
     91 		return;
     92 	}
     93 
     94 	cy_attach(sc);
     95 
     96 	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq,
     97 	    IST_EDGE, IPL_TTY, cy_intr, sc);
     98 	if (sc->sc_ih == NULL)
     99 		printf("%s: unable to establish interrupt",
    100 		    sc->sc_dev.dv_xname);
    101 }
    102