diff options
author | Damien Bergamini <damien@cvs.openbsd.org> | 2004-12-21 17:29:55 +0000 |
---|---|---|
committer | Damien Bergamini <damien@cvs.openbsd.org> | 2004-12-21 17:29:55 +0000 |
commit | b97728a5730a19a71786f817fc4950b7d6e67374 (patch) | |
tree | c7f1c94155ba1b245945fddc38a69e32c0be8e16 /sys | |
parent | 55565429b0dcafb36b7f61b73b42830a48582ed1 (diff) |
add powerhooks
OK claudio@ kevlo@ deraadt@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/if_ipw.c | 38 | ||||
-rw-r--r-- | sys/dev/pci/if_ipwvar.h | 5 | ||||
-rw-r--r-- | sys/dev/pci/if_iwi.c | 38 | ||||
-rw-r--r-- | sys/dev/pci/if_iwivar.h | 5 |
4 files changed, 74 insertions, 12 deletions
diff --git a/sys/dev/pci/if_ipw.c b/sys/dev/pci/if_ipw.c index 6222a590273..1225bb7f304 100644 --- a/sys/dev/pci/if_ipw.c +++ b/sys/dev/pci/if_ipw.c @@ -1,4 +1,4 @@ -/* $Id: if_ipw.c,v 1.36 2004/12/10 21:25:52 damien Exp $ */ +/* $Id: if_ipw.c,v 1.37 2004/12/21 17:29:53 damien Exp $ */ /*- * Copyright (c) 2004 @@ -80,6 +80,7 @@ static const struct ieee80211_rateset ipw_rateset_11b = int ipw_match(struct device *, void *, void *); void ipw_attach(struct device *, struct device *, void *); int ipw_detach(struct device *, int); +void ipw_power(int, void *); int ipw_dma_alloc(struct ipw_softc *); void ipw_release(struct ipw_softc *); int ipw_media_change(struct ifnet *); @@ -174,15 +175,17 @@ ipw_attach(struct device *parent, struct device *self, void *aux) int error, i; sc->sc_pct = pa->pa_pc; + sc->sc_pcitag = pa->pa_tag, - data = pci_conf_read(sc->sc_pct, pa->pa_tag, 0x40); + /* clear device specific PCI configuration register 0x41 */ + data = pci_conf_read(sc->sc_pct, sc->sc_pcitag, 0x40); data &= ~0x0000ff00; - pci_conf_write(sc->sc_pct, pa->pa_tag, 0x40, data); + pci_conf_write(sc->sc_pct, sc->sc_pcitag, 0x40, data); /* enable bus-mastering */ - data = pci_conf_read(sc->sc_pct, pa->pa_tag, PCI_COMMAND_STATUS_REG); + data = pci_conf_read(sc->sc_pct, sc->sc_pcitag, PCI_COMMAND_STATUS_REG); data |= PCI_COMMAND_MASTER_ENABLE; - pci_conf_write(sc->sc_pct, pa->pa_tag, PCI_COMMAND_STATUS_REG, data); + pci_conf_write(sc->sc_pct, sc->sc_pcitag, PCI_COMMAND_STATUS_REG, data); /* map the register window */ error = pci_mapreg_map(pa, IPW_PCI_BAR0, PCI_MAPREG_TYPE_MEM | @@ -280,6 +283,8 @@ ipw_attach(struct device *parent, struct device *self, void *aux) ic->ic_newstate = ipw_newstate; ieee80211_media_init(ifp, ipw_media_change, ipw_media_status); + sc->powerhook = powerhook_establish(ipw_power, sc); + #if NBPFILTER > 0 bpfattach(&sc->sc_drvbpf, ifp, DLT_IEEE802_11_RADIO, sizeof (struct ieee80211_frame) + 64); @@ -320,6 +325,29 @@ ipw_detach(struct device* self, int flags) return 0; } +void +ipw_power(int why, void *arg) +{ + struct ipw_softc *sc = arg; + struct ifnet *ifp; + pcireg_t data; + + if (why != PWR_RESUME) + return; + + /* clear device specific PCI configuration register 0x41 */ + data = pci_conf_read(sc->sc_pct, sc->sc_pcitag, 0x40); + data &= ~0x0000ff00; + pci_conf_write(sc->sc_pct, sc->sc_pcitag, 0x40, data); + + ifp = &sc->sc_ic.ic_if; + if (ifp->if_flags & IFF_UP) { + ifp->if_init(ifp); + if (ifp->if_flags & IFF_RUNNING) + ifp->if_start(ifp); + } +} + int ipw_dma_alloc(struct ipw_softc *sc) { diff --git a/sys/dev/pci/if_ipwvar.h b/sys/dev/pci/if_ipwvar.h index e02759752a4..1fbe24a4c75 100644 --- a/sys/dev/pci/if_ipwvar.h +++ b/sys/dev/pci/if_ipwvar.h @@ -1,4 +1,4 @@ -/* $Id: if_ipwvar.h,v 1.5 2004/12/05 17:46:07 damien Exp $ */ +/* $Id: if_ipwvar.h,v 1.6 2004/12/21 17:29:53 damien Exp $ */ /*- * Copyright (c) 2004 @@ -100,6 +100,7 @@ struct ipw_softc { bus_space_handle_t sc_sh; void *sc_ih; pci_chipset_tag_t sc_pct; + pcitag_t sc_pcitag; bus_size_t sc_sz; int authmode; @@ -140,6 +141,8 @@ struct ipw_softc { u_int32_t txfree; u_int32_t rxcur; + void *powerhook; + #if NBPFILTER > 0 caddr_t sc_drvbpf; diff --git a/sys/dev/pci/if_iwi.c b/sys/dev/pci/if_iwi.c index 7b62b3fdec5..8ffe9381738 100644 --- a/sys/dev/pci/if_iwi.c +++ b/sys/dev/pci/if_iwi.c @@ -1,4 +1,4 @@ -/* $Id: if_iwi.c,v 1.21 2004/12/10 21:25:53 damien Exp $ */ +/* $Id: if_iwi.c,v 1.22 2004/12/21 17:29:53 damien Exp $ */ /*- * Copyright (c) 2004 @@ -94,6 +94,7 @@ static const struct ieee80211_rateset iwi_rateset_11g = int iwi_match(struct device *, void *, void *); void iwi_attach(struct device *, struct device *, void *); int iwi_detach(struct device *, int); +void iwi_power(int, void *); int iwi_dma_alloc(struct iwi_softc *); void iwi_release(struct iwi_softc *); int iwi_media_change(struct ifnet *); @@ -176,15 +177,17 @@ iwi_attach(struct device *parent, struct device *self, void *aux) int error, i; sc->sc_pct = pa->pa_pc; + sc->sc_pcitag = pa->pa_tag, - data = pci_conf_read(sc->sc_pct, pa->pa_tag, 0x40); + /* clear device specific PCI configuration register 0x41 */ + data = pci_conf_read(sc->sc_pct, sc->sc_pcitag, 0x40); data &= ~0x0000ff00; - pci_conf_write(sc->sc_pct, pa->pa_tag, 0x40, data); + pci_conf_write(sc->sc_pct, sc->sc_pcitag, 0x40, data); /* enable bus-mastering */ - data = pci_conf_read(sc->sc_pct, pa->pa_tag, PCI_COMMAND_STATUS_REG); + data = pci_conf_read(sc->sc_pct, sc->sc_pcitag, PCI_COMMAND_STATUS_REG); data |= PCI_COMMAND_MASTER_ENABLE; - pci_conf_write(sc->sc_pct, pa->pa_tag, PCI_COMMAND_STATUS_REG, data); + pci_conf_write(sc->sc_pct, sc->sc_pcitag, PCI_COMMAND_STATUS_REG, data); /* map the register window */ error = pci_mapreg_map(pa, IWI_PCI_BAR0, PCI_MAPREG_TYPE_MEM | @@ -301,6 +304,8 @@ iwi_attach(struct device *parent, struct device *self, void *aux) ic->ic_newstate = iwi_newstate; ieee80211_media_init(ifp, iwi_media_change, iwi_media_status); + sc->powerhook = powerhook_establish(iwi_power, sc); + #if NBPFILTER > 0 bpfattach(&sc->sc_drvbpf, ifp, DLT_IEEE802_11_RADIO, sizeof (struct ieee80211_frame) + 64); @@ -341,6 +346,29 @@ iwi_detach(struct device* self, int flags) return 0; } +void +iwi_power(int why, void *arg) +{ + struct iwi_softc *sc = arg; + struct ifnet *ifp; + pcireg_t data; + + if (why != PWR_RESUME) + return; + + /* clear device specific PCI configuration register 0x41 */ + data = pci_conf_read(sc->sc_pct, sc->sc_pcitag, 0x40); + data &= ~0x0000ff00; + pci_conf_write(sc->sc_pct, sc->sc_pcitag, 0x40, data); + + ifp = &sc->sc_ic.ic_if; + if (ifp->if_flags & IFF_UP) { + ifp->if_init(ifp); + if (ifp->if_flags & IFF_RUNNING) + ifp->if_start(ifp); + } +} + int iwi_dma_alloc(struct iwi_softc *sc) { diff --git a/sys/dev/pci/if_iwivar.h b/sys/dev/pci/if_iwivar.h index 5256de5b178..47cb476776e 100644 --- a/sys/dev/pci/if_iwivar.h +++ b/sys/dev/pci/if_iwivar.h @@ -1,4 +1,4 @@ -/* $Id: if_iwivar.h,v 1.3 2004/12/04 17:24:06 damien Exp $ */ +/* $Id: if_iwivar.h,v 1.4 2004/12/21 17:29:54 damien Exp $ */ /*- * Copyright (c) 2004 @@ -101,12 +101,15 @@ struct iwi_softc { bus_space_handle_t sc_sh; void *sc_ih; pci_chipset_tag_t sc_pct; + pcitag_t sc_pcitag; bus_size_t sc_sz; int authmode; int sc_tx_timer; + void *powerhook; + #if NBPFILTER > 0 caddr_t sc_drvbpf; |