void mfi_pci_attach(struct device *parent, struct device *self, void *aux) { struct mfi_softc *sc = (struct mfi_softc *)self; struct pci_attach_args *pa = aux; const struct mfi_pci_device *mpd; pci_intr_handle_t ih; bus_size_t size; pcireg_t reg; int regbar; mpd = mfi_pci_find_device(pa); if (mpd == NULL) { printf(": can't find matching pci device\n"); return; } if (mpd->mpd_iop == MFI_IOP_GEN2 || mpd->mpd_iop == MFI_IOP_SKINNY) regbar = MFI_BAR_GEN2; else regbar = MFI_BAR; reg = pci_mapreg_type(pa->pa_pc, pa->pa_tag, regbar); if (pci_mapreg_map(pa, regbar, reg, 0, &sc->sc_iot, &sc->sc_ioh, NULL, &size, MFI_PCI_MEMSIZE)) { printf(": can't map controller pci space\n"); return; } sc->sc_dmat = pa->pa_dmat; if (pci_intr_map(pa, &ih) != 0) { printf(": can't map interrupt\n"); goto unmap; } printf(": %s\n", pci_intr_string(pa->pa_pc, ih)); sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO, mfi_intr, sc, sc->sc_dev.dv_xname); if (!sc->sc_ih) { printf("%s: can't establish interrupt\n", DEVNAME(sc)); goto unmap; } if (mfi_attach(sc, mpd->mpd_iop)) { printf("%s: can't attach\n", DEVNAME(sc)); goto unintr; } return; unintr: pci_intr_disestablish(pa->pa_pc, sc->sc_ih); sc->sc_ih = NULL; unmap: bus_space_unmap(sc->sc_iot, sc->sc_ioh, size); }
int mfi_pci_match(struct device *parent, void *match, void *aux) { int i; if ((i = mfi_pci_find_device(aux)) != -1) { DNPRINTF(MFI_D_MISC, "mfi_pci_match: vendor: %04x product: %04x\n", mfi_pci_devices[i].mpd_vendor, mfi_pci_devices[i].mpd_product); return (1); } return (0); }
void mfi_pci_attach(struct device *parent, struct device *self, void *aux) { struct mfi_softc *sc = (struct mfi_softc *)self; struct pci_attach_args *pa = aux; const struct mfi_pci_device *mpd; const struct mfi_pci_subtype *st; const char *intrstr; pci_intr_handle_t ih; bus_size_t size; pcireg_t reg; const char *subtype = NULL; char subid[32]; mpd = mfi_pci_find_device(pa); reg = pci_mapreg_type(pa->pa_pc, pa->pa_tag, MFI_BAR); if (pci_mapreg_map(pa, MFI_BAR, reg, 0, &sc->sc_iot, &sc->sc_ioh, NULL, &size, MFI_PCI_MEMSIZE)) { printf(": can't map controller pci space\n"); return; } sc->sc_dmat = pa->pa_dmat; if (pci_intr_map(pa, &ih)) { printf(": can't map interrupt\n"); bus_space_unmap(sc->sc_iot, sc->sc_ioh, size); return; } intrstr = pci_intr_string(pa->pa_pc, ih); sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO, mfi_intr, sc, sc->sc_dev.dv_xname); if (!sc->sc_ih) { printf(": can't establish interrupt"); if (intrstr) printf(" at %s", intrstr); printf("\n"); bus_space_unmap(sc->sc_iot, sc->sc_ioh, size); return; } reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBSYS_ID_REG); if (mpd->mpd_subtype != NULL) { st = mpd->mpd_subtype; while (st->st_id != 0x0) { if (st->st_id == reg) { subtype = st->st_string; break; } st++; } } if (subtype == NULL) { snprintf(subid, sizeof(subid), "0x%08x", reg); subtype = subid; } printf(": %s, %s\n", intrstr, subtype); if (mfi_attach(sc, mpd->mpd_iop)) { printf("%s: can't attach\n", DEVNAME(sc)); pci_intr_disestablish(pa->pa_pc, sc->sc_ih); sc->sc_ih = NULL; bus_space_unmap(sc->sc_iot, sc->sc_ioh, size); } }
int mfi_pci_match(struct device *parent, void *match, void *aux) { return ((mfi_pci_find_device(aux) != NULL) ? 1 : 0); }