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