Home | History | Annotate | Line # | Download | only in isa
cy_isa.c revision 1.17.6.2
      1  1.17.6.1     skrll /*	$NetBSD: cy_isa.c,v 1.17.6.2 2004/09/21 13:29:43 skrll Exp $	*/
      2       1.1  christos 
      3       1.1  christos /*
      4       1.1  christos  * cy.c
      5       1.1  christos  *
      6       1.1  christos  * Driver for Cyclades Cyclom-8/16/32 multiport serial cards
      7       1.1  christos  * (currently not tested with Cyclom-32 cards)
      8       1.1  christos  *
      9       1.1  christos  * Timo Rossi, 1996
     10       1.1  christos  */
     11      1.13     lukem 
     12      1.13     lukem #include <sys/cdefs.h>
     13  1.17.6.1     skrll __KERNEL_RCSID(0, "$NetBSD: cy_isa.c,v 1.17.6.2 2004/09/21 13:29:43 skrll Exp $");
     14       1.1  christos 
     15       1.1  christos #include <sys/param.h>
     16       1.1  christos #include <sys/systm.h>
     17       1.1  christos #include <sys/device.h>
     18       1.1  christos 
     19       1.1  christos #include <machine/bus.h>
     20       1.1  christos #include <machine/intr.h>
     21       1.1  christos 
     22       1.1  christos #include <dev/isa/isavar.h>
     23       1.1  christos #include <dev/isa/isareg.h>
     24       1.1  christos 
     25       1.1  christos #include <dev/ic/cd1400reg.h>
     26       1.1  christos #include <dev/ic/cyreg.h>
     27       1.1  christos #include <dev/ic/cyvar.h>
     28       1.1  christos 
     29      1.11   thorpej int	cy_isa_probe(struct device *, struct cfdata *, void *);
     30      1.11   thorpej void	cy_isa_attach(struct device *, struct device *, void *);
     31       1.1  christos 
     32      1.17   thorpej CFATTACH_DECL(cy_isa, sizeof(struct cy_softc),
     33      1.17   thorpej     cy_isa_probe, cy_isa_attach, NULL, NULL);
     34       1.1  christos 
     35      1.11   thorpej int
     36      1.11   thorpej cy_isa_probe(struct device *parent, struct cfdata *match, void *aux)
     37       1.1  christos {
     38       1.1  christos 	struct isa_attach_args *ia = aux;
     39       1.1  christos 	struct cy_softc sc;
     40       1.2   thorpej 	int found;
     41       1.1  christos 
     42      1.14   thorpej 	if (ia->ia_niomem < 1)
     43      1.14   thorpej 		return (0);
     44      1.14   thorpej 	if (ia->ia_nirq < 1)
     45      1.14   thorpej 		return (0);
     46      1.14   thorpej 
     47       1.1  christos 	memcpy(&sc.sc_dev, match, sizeof(struct device));
     48       1.1  christos 
     49       1.5   thorpej 	sc.sc_memt = ia->ia_memt;
     50       1.1  christos 	sc.sc_bustype = CY_BUSTYPE_ISA;
     51       1.6   thorpej 
     52       1.9  christos 	/* Disallow wildcarded memory address. */
     53  1.17.6.1     skrll 	if (ia->ia_iomem[0].ir_addr == ISA_UNKNOWN_IOMEM)
     54      1.14   thorpej 		return 0;
     55  1.17.6.1     skrll 	if (ia->ia_irq[0].ir_irq == ISA_UNKNOWN_IRQ)
     56       1.1  christos 		return 0;
     57       1.1  christos 
     58      1.14   thorpej 	if (bus_space_map(ia->ia_memt, ia->ia_iomem[0].ir_addr, CY_MEMSIZE, 0,
     59       1.5   thorpej 	    &sc.sc_bsh) != 0)
     60       1.1  christos 		return 0;
     61       1.1  christos 
     62       1.2   thorpej 	found = cy_find(&sc);
     63       1.1  christos 
     64       1.5   thorpej 	bus_space_unmap(ia->ia_memt, sc.sc_bsh, CY_MEMSIZE);
     65       1.1  christos 
     66       1.2   thorpej 	if (found) {
     67      1.14   thorpej 		ia->ia_niomem = 1;
     68      1.14   thorpej 		ia->ia_iomem[0].ir_size = CY_MEMSIZE;
     69      1.14   thorpej 
     70      1.14   thorpej 		ia->ia_nirq = 1;
     71      1.14   thorpej 
     72      1.14   thorpej 		ia->ia_nio = 0;
     73      1.14   thorpej 		ia->ia_ndrq = 0;
     74       1.2   thorpej 	}
     75      1.11   thorpej 	return (found);
     76       1.1  christos }
     77       1.1  christos 
     78      1.11   thorpej void
     79      1.11   thorpej cy_isa_attach(struct device *parent, struct device *self, void *aux)
     80       1.1  christos {
     81       1.1  christos 	struct cy_softc *sc = (void *) self;
     82       1.1  christos 	struct isa_attach_args *ia = aux;
     83       1.1  christos 
     84       1.5   thorpej 	sc->sc_memt = ia->ia_memt;
     85       1.1  christos 	sc->sc_bustype = CY_BUSTYPE_ISA;
     86       1.1  christos 
     87      1.11   thorpej 	printf(": Cyclades-Y multiport serial\n");
     88      1.11   thorpej 
     89      1.14   thorpej 	if (bus_space_map(ia->ia_memt, ia->ia_iomem[0].ir_addr, CY_MEMSIZE, 0,
     90       1.7   thorpej 	    &sc->sc_bsh) != 0) {
     91      1.11   thorpej 		printf("%s: unable to map device registers\n",
     92      1.11   thorpej 		    sc->sc_dev.dv_xname);
     93       1.7   thorpej 		return;
     94       1.7   thorpej 	}
     95       1.1  christos 
     96       1.7   thorpej 	if (cy_find(sc) == 0) {
     97      1.11   thorpej 		printf("%s: unable to find CD1400s\n", sc->sc_dev.dv_xname);
     98       1.7   thorpej 		return;
     99       1.7   thorpej 	}
    100       1.1  christos 
    101      1.12   thorpej 	cy_attach(sc);
    102       1.1  christos 
    103      1.14   thorpej 	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
    104       1.1  christos 	    IST_EDGE, IPL_TTY, cy_intr, sc);
    105       1.1  christos 	if (sc->sc_ih == NULL)
    106      1.11   thorpej 		printf("%s: unable to establish interrupt",
    107      1.11   thorpej 		    sc->sc_dev.dv_xname);
    108       1.1  christos }
    109