Home | History | Annotate | Line # | Download | only in isa
bha_isa.c revision 1.1
      1  1.1  mycroft #include <sys/types.h>
      2  1.1  mycroft #include <sys/param.h>
      3  1.1  mycroft #include <sys/device.h>
      4  1.1  mycroft 
      5  1.1  mycroft #include <machine/bus.h>
      6  1.1  mycroft #include <machine/intr.h>
      7  1.1  mycroft 
      8  1.1  mycroft #include <scsi/scsi_all.h>
      9  1.1  mycroft #include <scsi/scsiconf.h>
     10  1.1  mycroft 
     11  1.1  mycroft #include <dev/isa/isavar.h>
     12  1.1  mycroft #include <dev/isa/isadmavar.h>
     13  1.1  mycroft 
     14  1.1  mycroft #include <dev/ic/bhareg.h>
     15  1.1  mycroft #include <dev/ic/bhavar.h>
     16  1.1  mycroft 
     17  1.1  mycroft #define	BHA_ISA_IOSIZE	4
     18  1.1  mycroft 
     19  1.1  mycroft int	bha_isa_probe __P((struct device *, void *, void *));
     20  1.1  mycroft void	bha_isa_attach __P((struct device *, struct device *, void *));
     21  1.1  mycroft 
     22  1.1  mycroft struct cfattach bha_isa_ca = {
     23  1.1  mycroft 	sizeof(struct bha_softc), bha_isa_probe, bha_isa_attach
     24  1.1  mycroft };
     25  1.1  mycroft 
     26  1.1  mycroft /*
     27  1.1  mycroft  * Check the slots looking for a board we recognise
     28  1.1  mycroft  * If we find one, note it's address (slot) and call
     29  1.1  mycroft  * the actual probe routine to check it out.
     30  1.1  mycroft  */
     31  1.1  mycroft int
     32  1.1  mycroft bha_isa_probe(parent, match, aux)
     33  1.1  mycroft 	struct device *parent;
     34  1.1  mycroft 	void *match, *aux;
     35  1.1  mycroft {
     36  1.1  mycroft 	struct isa_attach_args *ia = aux;
     37  1.1  mycroft 	struct bha_softc sc;
     38  1.1  mycroft 	bus_chipset_tag_t bc = ia->ia_bc;
     39  1.1  mycroft 	bus_io_handle_t ioh;
     40  1.1  mycroft 	isa_chipset_tag_t ic = ia->ia_ic;
     41  1.1  mycroft 	int rv;
     42  1.1  mycroft 
     43  1.1  mycroft 	if (bus_io_map(bc, ia->ia_iobase, BHA_ISA_IOSIZE, &ioh))
     44  1.1  mycroft 		return (0);
     45  1.1  mycroft 
     46  1.1  mycroft 	rv = bha_find(bc, ioh, &sc);
     47  1.1  mycroft 
     48  1.1  mycroft 	bus_io_unmap(bc, ioh, BHA_ISA_IOSIZE);
     49  1.1  mycroft 
     50  1.1  mycroft 	if (rv) {
     51  1.1  mycroft 		if (ia->ia_irq != -1 && ia->ia_irq != sc.sc_irq)
     52  1.1  mycroft 			return (0);
     53  1.1  mycroft 		if (ia->ia_drq != -1 && ia->ia_drq != sc.sc_drq)
     54  1.1  mycroft 			return (0);
     55  1.1  mycroft 		ia->ia_irq = sc.sc_irq;
     56  1.1  mycroft 		ia->ia_drq = sc.sc_drq;
     57  1.1  mycroft 		ia->ia_msize = 0;
     58  1.1  mycroft 		ia->ia_iosize = BHA_ISA_IOSIZE;
     59  1.1  mycroft 	}
     60  1.1  mycroft 	return (rv);
     61  1.1  mycroft }
     62  1.1  mycroft 
     63  1.1  mycroft /*
     64  1.1  mycroft  * Attach all the sub-devices we can find
     65  1.1  mycroft  */
     66  1.1  mycroft void
     67  1.1  mycroft bha_isa_attach(parent, self, aux)
     68  1.1  mycroft 	struct device *parent, *self;
     69  1.1  mycroft 	void *aux;
     70  1.1  mycroft {
     71  1.1  mycroft 	struct isa_attach_args *ia = aux;
     72  1.1  mycroft 	struct bha_softc *sc = (void *)self;
     73  1.1  mycroft 	bus_chipset_tag_t bc = ia->ia_bc;
     74  1.1  mycroft 	bus_io_handle_t ioh;
     75  1.1  mycroft 	isa_chipset_tag_t ic = ia->ia_ic;
     76  1.1  mycroft 
     77  1.1  mycroft 	printf("\n");
     78  1.1  mycroft 
     79  1.1  mycroft 	if (bus_io_map(bc, ia->ia_iobase, BHA_ISA_IOSIZE, &ioh))
     80  1.1  mycroft 		panic("bha_attach: bus_io_map failed!");
     81  1.1  mycroft 
     82  1.1  mycroft 	sc->sc_bc = bc;
     83  1.1  mycroft 	sc->sc_ioh = ioh;
     84  1.1  mycroft 	if (!bha_find(bc, ioh, sc))
     85  1.1  mycroft 		panic("bha_attach: bha_find failed!");
     86  1.1  mycroft 
     87  1.1  mycroft 	if (sc->sc_drq != -1)
     88  1.1  mycroft 		isa_dmacascade(sc->sc_drq);
     89  1.1  mycroft 
     90  1.1  mycroft 	sc->sc_ih = isa_intr_establish(ic, sc->sc_irq, IST_EDGE, IPL_BIO,
     91  1.1  mycroft 	    bha_intr, sc);
     92  1.1  mycroft 	if (sc->sc_ih == NULL) {
     93  1.1  mycroft 		printf("%s: couldn't establish interrupt\n",
     94  1.1  mycroft 		    sc->sc_dev.dv_xname);
     95  1.1  mycroft 		return;
     96  1.1  mycroft 	}
     97  1.1  mycroft 
     98  1.1  mycroft 	bha_attach(sc);
     99  1.1  mycroft }
    100