Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/dev/pci/if_bge.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/dev/pci/if_bge.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.81 retrieving revision 1.81.2.1 diff -u -p -r1.81 -r1.81.2.1 --- src/sys/dev/pci/if_bge.c 2005/01/24 21:25:09 1.81 +++ src/sys/dev/pci/if_bge.c 2005/02/12 18:17:47 1.81.2.1 @@ -1,4 +1,4 @@ -/* $NetBSD: if_bge.c,v 1.81 2005/01/24 21:25:09 matt Exp $ */ +/* $NetBSD: if_bge.c,v 1.81.2.1 2005/02/12 18:17:47 yamt Exp $ */ /* * Copyright (c) 2001 Wind River Systems @@ -79,7 +79,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.81 2005/01/24 21:25:09 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.81.2.1 2005/02/12 18:17:47 yamt Exp $"); #include "bpfilter.h" #include "vlan.h" @@ -178,6 +178,7 @@ static int bge_rxthresh_nodenum; int bge_probe(struct device *, struct cfdata *, void *); void bge_attach(struct device *, struct device *, void *); +void bge_powerhook(int, void *); void bge_release_resources(struct bge_softc *); void bge_txeof(struct bge_softc *); void bge_rxeof(struct bge_softc *); @@ -2579,6 +2580,11 @@ bge_attach(parent, self, aux) #endif /* BGE_EVENT_COUNTERS */ DPRINTFN(5, ("callout_init\n")); callout_init(&sc->bge_timeout); + + sc->bge_powerhook = powerhook_establish(bge_powerhook, sc); + if (sc->bge_powerhook == NULL) + printf("%s: WARNING: unable to establish PCI power hook\n", + sc->bge_dev.dv_xname); } void @@ -4007,3 +4013,35 @@ SYSCTL_SETUP(sysctl_bge, "sysctl bge sub err: printf("%s: sysctl_createv failed (rc = %d)\n", __func__, rc); } + +void +bge_powerhook(int why, void *hdl) +{ + struct bge_softc *sc = (struct bge_softc *)hdl; + struct ifnet *ifp = &sc->ethercom.ec_if; + struct pci_attach_args *pa = &(sc->bge_pa); + pci_chipset_tag_t pc = pa->pa_pc; + pcitag_t tag = pa->pa_tag; + + switch (why) { + case PWR_SOFTSUSPEND: + case PWR_SOFTSTANDBY: + bge_shutdown(sc); + break; + case PWR_SOFTRESUME: + if (ifp->if_flags & IFF_UP) { + ifp->if_flags &= ~IFF_RUNNING; + bge_init(ifp); + } + break; + case PWR_SUSPEND: + case PWR_STANDBY: + pci_conf_capture(pc, tag, &sc->bge_pciconf); + break; + case PWR_RESUME: + pci_conf_restore(pc, tag, &sc->bge_pciconf); + break; + } + + return; +}