int ahc_isa_match(struct isa_attach_args *ia, bus_addr_t iobase) { bus_space_tag_t iot = ia->ia_iot; bus_space_handle_t ioh; int irq; char idstring[EISA_IDSTRINGLEN]; /* * Get a mapping for the while slot-specific address * space. If we can't, assume nothing's there, but * warn about it. */ if (bus_space_map(iot, iobase, AHC_ISA_IOSIZE, 0, &ioh)) { #if 0 /* * Don't print anything out here, since this could * be common on machines configured to look for * ahc_eisa and ahc_isa. */ aprint_error("ahc_isa_match: can't map I/O space for 0x%x\n", iobase); #endif return (0); } if (!ahc_isa_idstring(iot, ioh, idstring)) irq = -1; /* cannot get the ID string */ else if (strcmp(idstring, "ADP7756") && strcmp(idstring, "ADP7757")) irq = -1; /* unknown ID strings */ else irq = ahc_aic77xx_irq(iot, ioh); bus_space_unmap(iot, ioh, AHC_ISA_IOSIZE); if (irq < 0) return (0); if (ia->ia_irq[0].ir_irq != ISA_UNKNOWN_IRQ && ia->ia_irq[0].ir_irq != irq) { aprint_error("ahc_isa_match: irq mismatch (kernel %d, card %d)\n", ia->ia_irq[0].ir_irq, irq); return (0); } /* We have a match */ ia->ia_nio = 1; ia->ia_io[0].ir_addr = iobase; ia->ia_io[0].ir_size = AHC_ISA_IOSIZE; ia->ia_nirq = 1; ia->ia_irq[0].ir_irq = irq; ia->ia_ndrq = 0; ia->ia_niomem = 0; return (1); }
/* * Check the slots looking for a board we recognise * If we find one, note its address (slot) and call * the actual probe routine to check it out. */ static int ahc_eisa_match(device_t parent, cfdata_t match, void *aux) { struct eisa_attach_args *ea = aux; bus_space_tag_t iot = ea->ea_iot; bus_space_handle_t ioh; int irq; /* must match one of our known ID strings */ if (strcmp(ea->ea_idstring, "ADP7770") && strcmp(ea->ea_idstring, "ADP7771")) return (0); if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) + AHC_EISA_SLOT_OFFSET, AHC_EISA_IOSIZE, 0, &ioh)) return (0); irq = ahc_aic77xx_irq(iot, ioh); bus_space_unmap(iot, ioh, AHC_EISA_IOSIZE); return (irq >= 0); }
void ahc_isa_attach(device_t parent, device_t self, void *aux) { struct ahc_softc *ahc = device_private(self); struct isa_attach_args *ia = aux; bus_space_tag_t iot = ia->ia_iot; bus_space_handle_t ioh; int irq, intrtype; const char *intrtypestr; char idstring[EISA_IDSTRINGLEN]; u_char intdef; ahc->sc_dev = self; aprint_naive(": SCSI controller\n"); if (bus_space_map(iot, ia->ia_io[0].ir_addr, ia->ia_io[0].ir_size, 0, &ioh)) { aprint_error(": can't map i/o space\n"); return; } if (!ahc_isa_idstring(iot, ioh, idstring)) { aprint_error(": can't read ID string\n"); goto free_io; } if ((irq = ahc_aic77xx_irq(iot, ioh)) < 0) { aprint_error(": ahc_aic77xx_irq failed\n"); goto free_io; } if (strcmp(idstring, "ADP7756") == 0) { aprint_normal(": %s\n", EISA_PRODUCT_ADP7756); } else if (strcmp(idstring, "ADP7757") == 0) { aprint_normal(": %s\n", EISA_PRODUCT_ADP7757); } else { aprint_error(": unknown device type %s\n", idstring); goto free_io; } /* * Tell the bus-DMA interface that we can do 32bit DMA * NOTE: this variable is first referenced in ahc_init(). */ ahc->sc_dmaflags = ISABUS_DMA_32BIT; ahc_set_name(ahc, device_xname(ahc->sc_dev)); ahc->parent_dmat = ia->ia_dmat; ahc->channel = 'A'; ahc->chip = AHC_AIC7770|AHC_VL; ahc->features = AHC_AIC7770_FE; ahc->bugs |= AHC_TMODE_WIDEODD_BUG; ahc->flags |= AHC_PAGESCBS; ahc->tag = iot; ahc->bsh = ioh; if (ahc_softc_init(ahc) != 0) goto free_io; ahc_intr_enable(ahc, false); if (ahc_reset(ahc) != 0) goto free_io; intdef = bus_space_read_1(iot, ioh, INTDEF); if (intdef & EDGE_TRIG) { intrtype = IST_EDGE; intrtypestr = "edge triggered"; } else { intrtype = IST_LEVEL; intrtypestr = "level sensitive"; } ahc->ih = isa_intr_establish(ia->ia_ic, irq, intrtype, IPL_BIO, ahc_intr, ahc); if (ahc->ih == NULL) { aprint_error_dev(ahc->sc_dev, "couldn't establish %s interrupt\n", intrtypestr); goto free_io; } /* * Tell the user what type of interrupts we're using. * useful for debugging irq problems */ if (bootverbose) { aprint_verbose_dev(ahc->sc_dev, "Using %s interrupts\n", intrtypestr); } /* * Now that we know we own the resources we need, do the * card initialization. */ aha2840_load_seeprom(ahc); /* Attach sub-devices */ if (ahc_aic77xx_attach(ahc) == 0) return; /* succeed */ /* failed */ isa_intr_disestablish(ia->ia_ic, ahc->ih); free_io: bus_space_unmap(iot, ioh, ia->ia_io[0].ir_size); }
static void ahc_eisa_attach(device_t parent, device_t self, void *aux) { struct ahc_softc *ahc = device_private(self); struct eisa_attach_args *ea = aux; eisa_chipset_tag_t ec = ea->ea_ec; eisa_intr_handle_t ih; bus_space_tag_t iot = ea->ea_iot; bus_space_handle_t ioh; int irq, intrtype; const char *intrstr, *intrtypestr; u_int biosctrl; u_int scsiconf; u_int scsiconf1; u_char intdef; #ifdef AHC_DEBUG int i; #endif char intrbuf[EISA_INTRSTR_LEN]; ahc->sc_dev = self; if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) + AHC_EISA_SLOT_OFFSET, AHC_EISA_IOSIZE, 0, &ioh)) { aprint_error_dev(ahc->sc_dev, "could not map I/O addresses"); return; } if ((irq = ahc_aic77xx_irq(iot, ioh)) < 0) { aprint_error_dev(ahc->sc_dev, "ahc_aic77xx_irq failed!"); goto free_io; } if (strcmp(ea->ea_idstring, "ADP7770") == 0) { printf(": %s\n", EISA_PRODUCT_ADP7770); } else if (strcmp(ea->ea_idstring, "ADP7771") == 0) { printf(": %s\n", EISA_PRODUCT_ADP7771); } else { printf(": Unknown device type %s", ea->ea_idstring); goto free_io; } ahc_set_name(ahc, device_xname(ahc->sc_dev)); ahc->parent_dmat = ea->ea_dmat; ahc->chip = AHC_AIC7770|AHC_EISA; ahc->features = AHC_AIC7770_FE; ahc->flags = AHC_PAGESCBS; ahc->bugs = AHC_TMODE_WIDEODD_BUG; ahc->tag = iot; ahc->bsh = ioh; ahc->channel = 'A'; if (ahc_softc_init(ahc) != 0) goto free_io; ahc_intr_enable(ahc, FALSE); if (ahc_reset(ahc) != 0) goto free_io; if (eisa_intr_map(ec, irq, &ih)) { aprint_error_dev(ahc->sc_dev, "couldn't map interrupt (%d)\n", irq); goto free_io; } intdef = bus_space_read_1(iot, ioh, INTDEF); if (intdef & EDGE_TRIG) { intrtype = IST_EDGE; intrtypestr = "edge triggered"; } else { intrtype = IST_LEVEL; intrtypestr = "level sensitive"; } intrstr = eisa_intr_string(ec, ih, intrbuf, sizeof(intrbuf)); ahc->ih = eisa_intr_establish(ec, ih, intrtype, IPL_BIO, ahc_intr, ahc); if (ahc->ih == NULL) { aprint_error_dev(ahc->sc_dev, "couldn't establish %s interrupt", intrtypestr); if (intrstr != NULL) aprint_error(" at %s", intrstr); aprint_error("\n"); goto free_io; } if (intrstr != NULL) aprint_normal_dev(ahc->sc_dev, "%s interrupting at %s\n", intrtypestr, intrstr); /* * Now that we know we own the resources we need, do the * card initialization. * * First, the aic7770 card specific setup. */ biosctrl = ahc_inb(ahc, HA_274_BIOSCTRL); scsiconf = ahc_inb(ahc, SCSICONF); scsiconf1 = ahc_inb(ahc, SCSICONF + 1); #ifdef AHC_DEBUG for (i = TARG_SCSIRATE; i <= HA_274_BIOSCTRL; i+=8) { printf("0x%x, 0x%x, 0x%x, 0x%x, " "0x%x, 0x%x, 0x%x, 0x%x\n", ahc_inb(ahc, i), ahc_inb(ahc, i+1), ahc_inb(ahc, i+2), ahc_inb(ahc, i+3), ahc_inb(ahc, i+4), ahc_inb(ahc, i+5), ahc_inb(ahc, i+6), ahc_inb(ahc, i+7)); } #endif /* Get the primary channel information */ if ((biosctrl & CHANNEL_B_PRIMARY) != 0) ahc->flags |= AHC_PRIMARY_CHANNEL; if ((biosctrl & BIOSMODE) == BIOSDISABLED) { ahc->flags |= AHC_USEDEFAULTS; } else if ((ahc->features & AHC_WIDE) != 0) { ahc->our_id = scsiconf1 & HWSCSIID; if (scsiconf & TERM_ENB) ahc->flags |= AHC_TERM_ENB_A; } else { ahc->our_id = scsiconf & HSCSIID; ahc->our_id_b = scsiconf1 & HSCSIID; if (scsiconf & TERM_ENB) ahc->flags |= AHC_TERM_ENB_A; if (scsiconf1 & TERM_ENB) ahc->flags |= AHC_TERM_ENB_B; } if ((ahc_inb(ahc, HA_274_BIOSGLOBAL) & HA_274_EXTENDED_TRANS)) ahc->flags |= AHC_EXTENDED_TRANS_A|AHC_EXTENDED_TRANS_B; /* Attach sub-devices */ if (ahc_aic77xx_attach(ahc) == 0) return; /* succeed */ /* failed */ eisa_intr_disestablish(ec, ahc->ih); free_io: bus_space_unmap(iot, ioh, AHC_EISA_IOSIZE); }