示例#1
0
int
wi_pcmcia_activate(struct device *dev, int act)
{
	struct wi_pcmcia_softc *psc = (struct wi_pcmcia_softc *)dev;
	struct wi_softc *sc = &psc->sc_wi;
	struct ifnet *ifp = &sc->sc_ic.ic_if;

	switch (act) {
	case DVACT_SUSPEND:
		ifp->if_timer = 0;
		if (ifp->if_flags & IFF_RUNNING)
			wi_stop(sc);
		sc->wi_flags &= ~WI_FLAGS_INITIALIZED;
		if (sc->sc_ih != NULL)
			pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih);
		sc->sc_ih = NULL;
		pcmcia_function_disable(psc->sc_pf);
		break;
	case DVACT_RESUME:
		pcmcia_function_enable(psc->sc_pf);
		sc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET,
		    wi_intr, sc, sc->sc_dev.dv_xname);
		break;
	case DVACT_WAKEUP:
		wi_pcmcia_wakeup(sc);
		break;
	case DVACT_DEACTIVATE:
		if (sc->sc_ih != NULL)
			pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih);
		sc->sc_ih = NULL;
		pcmcia_function_disable(psc->sc_pf);
		break;
	}
	return (0);
}
示例#2
0
int
spc_pcmcia_enable(device_t self, int onoff)
{
    struct spc_pcmcia_softc *sc = device_private(self);
    int error;

    if (onoff) {
        /* Establish the interrupt handler. */
        sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_BIO,
                                          spc_intr, &sc->sc_spc);
        if (!sc->sc_ih)
            return EIO;

        error = pcmcia_function_enable(sc->sc_pf);
        if (error) {
            pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
            sc->sc_ih = 0;
            return error;
        }

        /* Initialize only chip.  */
        spc_init(&sc->sc_spc, 0);
    } else {
        pcmcia_function_disable(sc->sc_pf);
        pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
        sc->sc_ih = 0;
    }

    return 0;
}
static int
wi_pcmcia_enable(device_t self, int onoff)
{
	struct wi_pcmcia_softc *psc = device_private(self);
	struct wi_softc *sc = &psc->sc_wi;
	struct pcmcia_function *pf = psc->sc_pf;
	int error;

	if (onoff) {
		/* establish the interrupt. */
		sc->sc_ih = pcmcia_intr_establish(pf, IPL_NET, wi_intr, sc);
		if (sc->sc_ih == NULL)
			return EIO;

		error = pcmcia_function_enable(pf);
		if (error) {
			pcmcia_intr_disestablish(pf, sc->sc_ih);
			sc->sc_ih = NULL;
			return EIO;
		}

		if (psc->sc_symbol_cf) {
#if WI_PCMCIA_SPECTRUM24T_FW
			if (wi_pcmcia_load_firm(sc,
			    spectrum24t_primsym, sizeof(spectrum24t_primsym),
			    spectrum24t_secsym, sizeof(spectrum24t_secsym))) {
				aprint_error_dev(sc->sc_dev,
				    "couldn't load firmware\n");
				wi_pcmcia_enable(self, 0);
				return EIO;
			}
#else
			aprint_error_dev(sc->sc_dev,
			    "firmware load not configured\n");
			return EIO;
#endif
		}
		DELAY(1000);
	} else {
		pcmcia_function_disable(psc->sc_pf);
		if (sc->sc_ih != NULL) {
			pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih);
			sc->sc_ih = NULL;
		}
	}

	return 0;
}
int
wi_pcmcia_activate(struct device *dev, enum devact act)
{
	struct wi_pcmcia_softc *psc = (struct wi_pcmcia_softc *)dev;
	struct wi_softc *sc = &psc->sc_wi;
	struct ifnet *ifp = &sc->sc_ic.ic_if;
	int s;

	s = splnet();
	switch (act) {
	case DVACT_ACTIVATE:
		pcmcia_function_enable(psc->sc_pf);
		sc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET,
		    wi_intr, sc, sc->sc_dev.dv_xname);
		wi_cor_reset(sc);
		wi_init(sc);
		break;

	case DVACT_DEACTIVATE:
		ifp->if_timer = 0;
		if (ifp->if_flags & IFF_RUNNING)
			wi_stop(sc);
		sc->wi_flags &= ~WI_FLAGS_INITIALIZED;
		if (sc->sc_ih != NULL)
			pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih);
		pcmcia_function_disable(psc->sc_pf);
		break;
	}
	splx(s);
	return (0);
}
示例#5
0
static void
tr_pcmcia_disable(struct tr_softc *sc)
{
	struct tr_pcmcia_softc *psc = (struct tr_pcmcia_softc *) sc;

	pcmcia_function_disable(psc->sc_pf);
	pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih);
}
static void
cs_pcmcia_disable(struct cs_softc *sc)
{
	struct cs_pcmcia_softc *psc = (void *)sc;

	pcmcia_function_disable(psc->sc_pf);
	pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih);
	sc->sc_ih = 0;
}
示例#7
0
文件: gpr.c 项目: ajinkya93/OpenBSD
int
gpr_activate(struct device *dev, int act)
{
	struct gpr_softc *sc = (struct gpr_softc *)dev;

	switch (act) {
	case DVACT_DEACTIVATE:
		if (sc->sc_ih)
			pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
		sc->sc_ih = NULL;
		pcmcia_function_disable(sc->sc_pf);
		break;
	}
	return (0);
}
示例#8
0
static void
cs_pcmcia_disable(struct cs_softc *sc)
{
	struct cs_pcmcia_softc *psc = (void *)sc;
	struct pcmcia_function *pf = psc->sc_pf;

	if (sc->sc_ih != 0) {
		pcmcia_intr_disestablish(pf, sc->sc_ih);
		sc->sc_ih = 0;
	}

	pcmcia_function_disable(pf);
	
	if (psc->sc_flags & CS_PCMCIA_FLAGS_IO_MAPPED) {
		pcmcia_io_unmap(pf, psc->sc_io_window);
		psc->sc_flags &= ~CS_PCMCIA_FLAGS_IO_MAPPED;
	}
}
static int
cs_pcmcia_enable(struct cs_softc *sc)
{
	struct cs_pcmcia_softc *psc = (void *)sc;
	int error;

	sc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, cs_intr, sc);
	if (!sc->sc_ih)
		return (EIO);

	error = pcmcia_function_enable(psc->sc_pf);
	if (error) {
		pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih);
		sc->sc_ih = 0;
	}

	return (error);
}
示例#10
0
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;
}
示例#11
0
int
an_pcmcia_activate(struct device *dev, int act)
{
	struct an_pcmcia_softc *psc = (struct an_pcmcia_softc *)dev;
	struct an_softc *sc = &psc->sc_an;
	struct ieee80211com	*ic = &sc->sc_ic;
	struct ifnet		*ifp = &ic->ic_if;

	switch (act) {
	case DVACT_DEACTIVATE:
		ifp->if_timer = 0;
		if (ifp->if_flags & IFF_RUNNING)
			an_stop(ifp, 1);
		if (sc->sc_ih)
			pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih);
		sc->sc_ih = NULL;
		pcmcia_function_disable(psc->sc_pf);
		break;
	}
	return (0);
}
示例#12
0
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;
	}
}
示例#13
0
void
wi_pcmcia_attach(struct device *parent, struct device *self, void *aux)
{
	struct wi_pcmcia_softc	*psc = (struct wi_pcmcia_softc *)self;
	struct wi_softc		*sc = &psc->sc_wi;
	struct pcmcia_attach_args *pa = aux;
	struct pcmcia_function	*pf = pa->pf;
	struct pcmcia_config_entry *cfe = SIMPLEQ_FIRST(&pf->cfe_head);
	const char		*intrstr;
	int			state = 0;

	psc->sc_pf = pf;

	/* Enable the card. */
	pcmcia_function_init(pf, cfe);
	if (pcmcia_function_enable(pf)) {
		printf(": function enable failed\n");
		goto bad;
	}
	state++;

	if (pcmcia_io_alloc(pf, 0, WI_IOSIZ, WI_IOSIZ, &psc->sc_pcioh)) {
		printf(": can't alloc i/o space\n");
		goto bad;
	}
	state++;

	if (pcmcia_io_map(pf, PCMCIA_WIDTH_IO16, 0, WI_IOSIZ,
	    &psc->sc_pcioh, &psc->sc_io_window)) {
		printf(": can't map io space\n");
		goto bad;
	}
	state++;

	printf(" port 0x%lx/%lu", psc->sc_pcioh.addr,
	    (u_long)psc->sc_pcioh.size);

	sc->wi_ltag = sc->wi_btag = psc->sc_pcioh.iot;
	sc->wi_lhandle = sc->wi_bhandle = psc->sc_pcioh.ioh;
	sc->wi_cor_offset = WI_COR_OFFSET;
	sc->wi_flags |= WI_FLAGS_BUS_PCMCIA;

	/* Make sure interrupts are disabled. */
	CSR_WRITE_2(sc, WI_INT_EN, 0);
	CSR_WRITE_2(sc, WI_EVENT_ACK, 0xffff);

	/* Establish the interrupt. */
	sc->sc_ih = pcmcia_intr_establish(pa->pf, IPL_NET, wi_intr, psc,
	    sc->sc_dev.dv_xname);
	if (sc->sc_ih == NULL) {
		printf("%s: couldn't establish interrupt\n",
		    sc->sc_dev.dv_xname);
		goto bad;
	}

	intrstr = pcmcia_intr_string(psc->sc_pf, sc->sc_ih);
	printf("%s%s\n", *intrstr ? ", " : "", intrstr);
	if (wi_attach(sc, &wi_func_io) == 0)
		return;

	/* wi_attach() failed, do some cleanup */
	pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih);
	sc->sc_ih = NULL;

bad:
	if (state > 2)
		pcmcia_io_unmap(pf, psc->sc_io_window);
	if (state > 1)
		pcmcia_io_free(pf, &psc->sc_pcioh);
	if (state > 0)
		pcmcia_function_disable(pf);
}