static void fxp_cardbus_attach(struct device *parent, struct device *self, void *aux) { struct fxp_cardbus_softc *csc = device_private(self); struct fxp_softc *sc = &csc->sc; struct cardbus_attach_args *ca = aux; bus_space_tag_t iot, memt; bus_space_handle_t ioh, memh; bus_addr_t adr; bus_size_t size; sc->sc_dev = self; csc->ct = ca->ca_ct; /* * Map control/status registers. */ if (Cardbus_mapreg_map(csc->ct, CARDBUS_BASE1_REG, PCI_MAPREG_TYPE_IO, 0, &iot, &ioh, &adr, &size) == 0) { csc->base1_reg = adr | 1; sc->sc_st = iot; sc->sc_sh = ioh; csc->size = size; } else if (Cardbus_mapreg_map(csc->ct, CARDBUS_BASE0_REG, PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0, &memt, &memh, &adr, &size) == 0) { csc->base0_reg = adr; sc->sc_st = memt; sc->sc_sh = memh; csc->size = size; } else panic("%s: failed to allocate mem and io space", __func__); if (ca->ca_cis.cis1_info[0] && ca->ca_cis.cis1_info[1]) printf(": %s %s\n", ca->ca_cis.cis1_info[0], ca->ca_cis.cis1_info[1]); else printf("\n"); sc->sc_dmat = ca->ca_dmat; sc->sc_enable = fxp_cardbus_enable; sc->sc_disable = fxp_cardbus_disable; sc->sc_enabled = 0; fxp_enable(sc); fxp_attach(sc); fxp_disable(sc); if (!pmf_device_register(self, NULL, NULL)) aprint_error_dev(self, "couldn't establish power handler\n"); else pmf_class_network_register(self, &sc->sc_ethercom.ec_if); }
void fxp_pci_attach(struct device *parent, struct device *self, void *aux) { struct fxp_softc *sc = (struct fxp_softc *)self; struct pci_attach_args *pa = aux; pci_chipset_tag_t pc = pa->pa_pc; pci_intr_handle_t ih; const char *chipname = NULL; const char *intrstr = NULL; bus_size_t iosize; if (pci_mapreg_map(pa, FXP_PCI_IOBA, PCI_MAPREG_TYPE_IO, 0, &sc->sc_st, &sc->sc_sh, NULL, &iosize, 0)) { printf(": can't map i/o space\n"); return; } sc->sc_dmat = pa->pa_dmat; sc->sc_revision = PCI_REVISION(pa->pa_class); /* * Allocate our interrupt. */ if (pci_intr_map(pa, &ih)) { printf(": couldn't map interrupt\n"); bus_space_unmap(sc->sc_st, sc->sc_sh, iosize); return; } intrstr = pci_intr_string(pc, ih); sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, fxp_intr, sc, self->dv_xname); if (sc->sc_ih == NULL) { printf(": couldn't establish interrupt"); if (intrstr != NULL) printf(" at %s", intrstr); printf("\n"); bus_space_unmap(sc->sc_st, sc->sc_sh, iosize); return; } switch (PCI_PRODUCT(pa->pa_id)) { case PCI_PRODUCT_INTEL_8255x: case PCI_PRODUCT_INTEL_82559: case PCI_PRODUCT_INTEL_82559ER: { chipname = "i82557"; if (sc->sc_revision >= FXP_REV_82558_A4) chipname = "i82558"; if (sc->sc_revision >= FXP_REV_82559_A0) chipname = "i82559"; if (sc->sc_revision >= FXP_REV_82559S_A) chipname = "i82559S"; if (sc->sc_revision >= FXP_REV_82550) chipname = "i82550"; if (sc->sc_revision >= FXP_REV_82551_E) chipname = "i82551"; break; } break; default: chipname = "i82562"; break; } if (chipname != NULL) printf(", %s", chipname); /* * Cards for which we should WRITE TO THE EEPROM * to turn off dynamic standby mode to avoid * a problem where the card will fail to resume when * entering the IDLE state. We use this nasty if statement * and corresponding pci dev numbers directly so that people * know not to add new cards to this unless you are really * certain what you are doing and are not going to end up * killing people's eeproms. */ if ((PCI_VENDOR(pa->pa_id) == PCI_VENDOR_INTEL) && (PCI_PRODUCT(pa->pa_id) == 0x2449 || (PCI_PRODUCT(pa->pa_id) > 0x1030 && PCI_PRODUCT(pa->pa_id) < 0x1039) || (PCI_PRODUCT(pa->pa_id) == 0x1229 && (sc->sc_revision >= 8 && sc->sc_revision <= 16)))) sc->sc_flags |= FXPF_DISABLE_STANDBY; /* * enable PCI Memory Write and Invalidate command */ if (sc->sc_revision >= FXP_REV_82558_A4) if (PCI_CACHELINE(pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG))) { pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, PCI_COMMAND_INVALIDATE_ENABLE | pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG)); sc->sc_flags |= FXPF_MWI_ENABLE; } /* Do generic parts of attach. */ if (fxp_attach(sc, intrstr)) { /* Failed! */ pci_intr_disestablish(pc, sc->sc_ih); bus_space_unmap(sc->sc_st, sc->sc_sh, iosize); return; } }