void fdc_pcmcia_attach(device_t parent, device_t self, void *aux) { struct fdc_pcmcia_softc *psc = device_private(self); struct fdc_softc *fdc = &psc->sc_fdc; struct pcmcia_attach_args *pa = aux; struct pcmcia_config_entry *cfe; struct pcmcia_function *pf = pa->pf; struct fdc_attach_args fa; int error; fdc->sc_dev = self; psc->sc_pf = pf; error = pcmcia_function_configure(pf, fdc_pcmcia_validate_config); if (error) { aprint_error_dev(self, "configure failed, error=%d\n", error); return; } cfe = pf->cfe; fdc->sc_iot = cfe->iospace[0].handle.iot; fdc->sc_iot = cfe->iospace[0].handle.ioh; if (pcmcia_function_enable(pf)) goto fail; fdc->sc_flags = FDC_HEADSETTLE; fdc->sc_state = DEVIDLE; TAILQ_INIT(&fdc->sc_drives); if (!fdcfind(fdc->sc_iot, fdc->sc_ioh, 1)) aprint_error_dev(self, "coundn't find fdc\n"); fdc_conf(fdc); /* Establish the interrupt handler. */ fdc->sc_ih = pcmcia_intr_establish(pa->pf, IPL_BIO, fdchwintr, fdc); if (!fdc->sc_ih) goto fail; /* physical limit: four drives per controller. */ for (fa.fa_drive = 0; fa.fa_drive < 4; fa.fa_drive++) { if (fa.fa_drive < 2) fa.fa_deftype = &fd_types[0]; else fa.fa_deftype = NULL; /* unknown */ (void)config_found(self, (void *)&fa, fdprint); } return; fail: pcmcia_function_unconfigure(pf); }
static void cs_pcmcia_attach(device_t parent, device_t self, void *aux) { struct cs_pcmcia_softc *psc = device_private(self); struct cs_softc *sc = &psc->sc_cs; struct pcmcia_attach_args *pa = aux; struct pcmcia_config_entry *cfe; struct pcmcia_function *pf; int error; sc->sc_dev = self; pf = psc->sc_pf = pa->pf; error = pcmcia_function_configure(pa->pf, cs_pcmcia_validate_config); if (error) { aprint_error_dev(self, "configure failed, error=%d\n", error); return; } cfe = pf->cfe; sc->sc_iot = cfe->iospace[0].handle.iot; sc->sc_ioh = cfe->iospace[0].handle.ioh; sc->sc_irq = -1; #define CS_PCMCIA_HACK_FOR_CARDBUS #ifdef CS_PCMCIA_HACK_FOR_CARDBUS /* * XXX is there a generic way to know if it's a cardbus or not? */ sc->sc_cfgflags |= CFGFLG_CARDBUS_HACK; #endif error = cs_pcmcia_enable(sc); if (error) goto fail; sc->sc_enable = cs_pcmcia_enable; sc->sc_disable = cs_pcmcia_disable; /* chip attach */ error = cs_attach(sc, 0, 0, 0, 0); if (error) goto fail2; cs_pcmcia_disable(sc); psc->sc_state = CS_PCMCIA_ATTACHED; return; fail2: cs_pcmcia_disable(sc); fail: pcmcia_function_unconfigure(pf); }
void sm_pcmcia_attach(device_t parent, device_t self, void *aux) { struct sm_pcmcia_softc *psc = device_private(self); struct smc91cxx_softc *sc = &psc->sc_smc; struct pcmcia_attach_args *pa = aux; struct pcmcia_config_entry *cfe; u_int8_t enaddr[ETHER_ADDR_LEN]; int error; sc->sc_dev = self; psc->sc_pf = pa->pf; error = pcmcia_function_configure(pa->pf, sm_pcmcia_validate_config); if (error) { aprint_error_dev(self, "configure failed, error=%d\n", error); return; } cfe = pa->pf->cfe; sc->sc_bst = cfe->iospace[0].handle.iot; sc->sc_bsh = cfe->iospace[0].handle.ioh; error = sm_pcmcia_enable(sc); if (error) goto fail; sc->sc_enable = sm_pcmcia_enable; sc->sc_disable = sm_pcmcia_disable; /* * First try to get the Ethernet address from FUNCE/LANNID tuple. * If that fails, try one of the CIS info strings. */ if (pa->pf->pf_funce_lan_nidlen == ETHER_ADDR_LEN) { memcpy(enaddr, pa->pf->pf_funce_lan_nid, ETHER_ADDR_LEN); } else { if (!sm_pcmcia_ascii_enaddr(pa->pf->sc->card.cis1_info[3], enaddr) && !sm_pcmcia_ascii_enaddr(pa->pf->sc->card.cis1_info[2], enaddr)) aprint_error_dev(self, "unable to get Ethernet address\n"); } /* Perform generic intialization. */ smc91cxx_attach(sc, enaddr); psc->sc_state = SM_PCMCIA_ATTACHED; sm_pcmcia_disable(sc); return; fail: pcmcia_function_unconfigure(pa->pf); }
int spc_pcmcia_detach(device_t self, int flags) { struct spc_pcmcia_softc *sc = device_private(self); int error; if (sc->sc_state != SPC_PCMCIA_ATTACHED) return 0; error = spc_detach(self, flags); if (error) return error; pcmcia_function_unconfigure(sc->sc_pf); return 0; }
int sm_pcmcia_detach(device_t self, int flags) { struct sm_pcmcia_softc *psc = device_private(self); int error; if (psc->sc_state != SM_PCMCIA_ATTACHED) return (0); error = smc91cxx_detach((device_t)&psc->sc_smc, flags); if (error) return (error); pcmcia_function_unconfigure(psc->sc_pf); return (0); }
static int cs_pcmcia_detach(device_t self, int flags) { struct cs_pcmcia_softc *psc = device_private(self); struct cs_softc *sc = &psc->sc_cs; int error; if (psc->sc_state != CS_PCMCIA_ATTACHED) return (0); error = cs_detach(sc); if (error) return (error); pcmcia_function_unconfigure(psc->sc_pf); return (0); }
void spc_pcmcia_attach(device_t parent, device_t self, void *aux) { struct spc_pcmcia_softc *sc = device_private(self); struct spc_softc *spc = &sc->sc_spc; struct pcmcia_attach_args *pa = aux; struct pcmcia_config_entry *cfe; struct pcmcia_function *pf = pa->pf; int error; spc->sc_dev = self; sc->sc_pf = pf; error = pcmcia_function_configure(pf, spc_pcmcia_validate_config); if (error) { aprint_error_dev(self, "configure failed, error=%d\n", error); return; } cfe = pf->cfe; spc->sc_iot = cfe->iospace[0].handle.iot; spc->sc_ioh = cfe->iospace[0].handle.ioh; error = spc_pcmcia_enable(self, 1); if (error) goto fail; spc->sc_initiator = 7; /* XXX */ spc->sc_adapter.adapt_enable = spc_pcmcia_enable; spc->sc_adapter.adapt_refcnt = 1; /* * Initialize nca board itself. */ spc_attach(spc); scsipi_adapter_delref(&spc->sc_adapter); sc->sc_state = SPC_PCMCIA_ATTACHED; return; fail: pcmcia_function_unconfigure(pf); }
/* ARGSUSED */ static int btbc_detach(device_t self, int flags) { struct btbc_softc *sc = device_private(self); int err = 0; pmf_device_deregister(self); btbc_disable(sc->sc_dev); callout_stop(&sc->sc_ledch); callout_destroy(&sc->sc_ledch); if (sc->sc_unit) { hci_detach(sc->sc_unit); sc->sc_unit = NULL; } pcmcia_function_unconfigure(sc->sc_pf); return err; }
static int wi_pcmcia_detach(device_t self, int flags) { struct wi_pcmcia_softc *psc = device_private(self); struct wi_softc *sc = &psc->sc_wi; int error; if (psc->sc_state != WI_PCMCIA_ATTACHED) return 0; error = wi_detach(&psc->sc_wi); if (error != 0) return error; if (sc->sc_ih != NULL) pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih); pcmcia_function_unconfigure(psc->sc_pf); return 0; }
static void wi_pcmcia_attach(device_t parent, device_t self, void *aux) { struct wi_pcmcia_softc *psc = device_private(self); struct wi_softc *sc = &psc->sc_wi; struct pcmcia_attach_args *pa = aux; struct pcmcia_config_entry *cfe; int haveaddr; int error; aprint_naive("\n"); sc->sc_dev = self; psc->sc_pf = pa->pf; error = pcmcia_function_configure(pa->pf, wi_pcmcia_validate_config); if (error) { aprint_error_dev(self, "configure failed, error=%d\n", error); return; } cfe = pa->pf->cfe; sc->sc_iot = cfe->iospace[0].handle.iot; sc->sc_ioh = cfe->iospace[0].handle.ioh; if (pa->manufacturer == PCMCIA_VENDOR_SYMBOL && pa->product == PCMCIA_PRODUCT_SYMBOL_LA4100) psc->sc_symbol_cf = 1; /* * XXX: Sony PEGA-WL100 CF card has a same vendor/product id as * Intel PCMCIA card. It may be incorrect to detect by the * initial value of COR register. */ if (pa->manufacturer == PCMCIA_VENDOR_INTEL && pa->product == PCMCIA_PRODUCT_INTEL_PRO_WLAN_2011 && CSR_READ_2(sc, WI_COR) == WI_COR_IOMODE) psc->sc_symbol_cf = 1; error = wi_pcmcia_enable(self, 1); if (error) goto fail; sc->sc_pci = 0; sc->sc_enable = wi_pcmcia_enable; printf("%s:", device_xname(self)); haveaddr = pa->pf->pf_funce_lan_nidlen == IEEE80211_ADDR_LEN; if (wi_attach(sc, haveaddr ? pa->pf->pf_funce_lan_nid : 0) != 0) { aprint_error_dev(self, "failed to attach controller\n"); goto fail2; } if (pmf_device_register(self, NULL, NULL)) pmf_class_network_register(self, &sc->sc_if); else aprint_error_dev(self, "couldn't establish power handler\n"); wi_pcmcia_enable(self, 0); psc->sc_state = WI_PCMCIA_ATTACHED; return; fail2: wi_pcmcia_enable(self, 0); fail: pcmcia_function_unconfigure(pa->pf); }
int slhci_pcmcia_enable(struct slhci_pcmcia_softc *psc, int enable) { struct pcmcia_function *pf; struct pcmcia_io_handle *pioh; struct slhci_softc *sc; int error; pf = psc->sc_pf; sc = &psc->sc_slhci; if (enable) { if (psc->sc_flags & PFL_ENABLED) return 0; error = pcmcia_function_configure(pf, slhci_pcmcia_validate_config); if (error) { printf("%s: configure failed, error=%d\n", SC_NAME(sc), error); return 1; } pioh = &pf->cfe->iospace[0].handle; /* The data port is repeated three times; using a stride of * 2 prevents read/write errors on a Clio C-1000 hpcmips * system. */ slhci_preinit(sc, NULL, pioh->iot, pioh->ioh, 100, 2); psc->sc_ih = pcmcia_intr_establish(pf, IPL_USB, slhci_intr, sc); if (psc->sc_ih == NULL) { printf("%s: unable to establish interrupt\n", SC_NAME(sc)); goto fail1; } if (pcmcia_function_enable(pf)) { printf("%s: function enable failed\n", SC_NAME(sc)); goto fail2; } if (slhci_attach(sc)) { printf("%s: slhci_attach failed\n", SC_NAME(sc)); goto fail3; } psc->sc_flags |= PFL_ENABLED; return 0; } else { if (!(psc->sc_flags & PFL_ENABLED)) return 1; psc->sc_flags &= ~PFL_ENABLED; fail3: pcmcia_function_disable(pf); fail2: pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih); fail1: pcmcia_function_unconfigure(pf); return 1; } }