Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Add suspend/resume hooks to ensure that the chip doe...



details:   https://anonhg.NetBSD.org/src/rev/6c450c11356c
branches:  trunk
changeset: 483853:6c450c11356c
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Mar 19 21:45:23 2000 +0000

description:
Add suspend/resume hooks to ensure that the chip doesn't scramble memory
after an APM suspend and is unsnoozed after an APM resume.

diffstat:

 sys/dev/cardbus/if_tlp_cardbus.c |  24 +++++++++++++++++++++++-
 sys/dev/ic/tulip.c               |  39 ++++++++++++++++++++++++++++++++++++++-
 sys/dev/ic/tulipvar.h            |   4 +++-
 3 files changed, 64 insertions(+), 3 deletions(-)

diffs (144 lines):

diff -r 6e448742e60e -r 6c450c11356c sys/dev/cardbus/if_tlp_cardbus.c
--- a/sys/dev/cardbus/if_tlp_cardbus.c  Sun Mar 19 21:27:01 2000 +0000
+++ b/sys/dev/cardbus/if_tlp_cardbus.c  Sun Mar 19 21:45:23 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_tlp_cardbus.c,v 1.20 2000/03/15 18:39:52 thorpej Exp $      */
+/*     $NetBSD: if_tlp_cardbus.c,v 1.21 2000/03/19 21:45:24 thorpej Exp $      */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -152,6 +152,7 @@
 
 int    tlp_cardbus_enable __P((struct tulip_softc *));
 void   tlp_cardbus_disable __P((struct tulip_softc *));
+void   tlp_cardbus_power __P((struct tulip_softc *, int));
 
 void   tlp_cardbus_x3201_reset __P((struct tulip_softc *));
 
@@ -225,6 +226,7 @@
         */
        sc->sc_enable = tlp_cardbus_enable;
        sc->sc_disable = tlp_cardbus_disable;
+       sc->sc_power = tlp_cardbus_power;
 
        /*
         * Get revision info, and set some chip-specific variables.
@@ -450,6 +452,26 @@
 }
 
 void
+tlp_cardbus_power(sc, why)
+       struct tulip_softc *sc;
+       int why;
+{
+       struct tulip_cardbus_softc *csc = (void *) sc;
+
+       if (why == PWR_RESUME) {
+               /*
+                * Give the PCI configuration registers a kick
+                * in the head.
+                */
+#ifdef DIAGNOSTIC
+               if (TULIP_IS_ENABLED(sc) == 0)
+                       panic("tlp_cardbus_power");
+#endif
+               tlp_cardbus_setup(csc);
+       }
+}
+
+void
 tlp_cardbus_setup(csc)
        struct tulip_cardbus_softc *csc;
 {
diff -r 6e448742e60e -r 6c450c11356c sys/dev/ic/tulip.c
--- a/sys/dev/ic/tulip.c        Sun Mar 19 21:27:01 2000 +0000
+++ b/sys/dev/ic/tulip.c        Sun Mar 19 21:45:23 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tulip.c,v 1.53 2000/03/15 18:39:50 thorpej Exp $       */
+/*     $NetBSD: tulip.c,v 1.54 2000/03/19 21:45:23 thorpej Exp $       */
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -156,6 +156,7 @@
 
 int    tlp_enable __P((struct tulip_softc *));
 void   tlp_disable __P((struct tulip_softc *));
+void   tlp_power __P((int, void *));
 
 void   tlp_filter_setup __P((struct tulip_softc *));
 void   tlp_winb_filter_setup __P((struct tulip_softc *));
@@ -490,6 +491,15 @@
        if (sc->sc_sdhook == NULL)
                printf("%s: WARNING: unable to establish shutdown hook\n",
                    sc->sc_dev.dv_xname);
+
+       /*
+        * Add a suspend hook to make sure we come back up after a
+        * resume.
+        */
+       sc->sc_powerhook = powerhook_establish(tlp_power, sc);
+       if (sc->sc_powerhook == NULL)
+               printf("%s: WARNING: unable to establish power hook\n",
+                   sc->sc_dev.dv_xname);
        return;
 
        /*
@@ -1885,6 +1895,33 @@
 }
 
 /*
+ * tlp_power:
+ *
+ *     Power management (suspend/resume) hook.
+ */
+void
+tlp_power(why, arg)
+       int why;
+       void *arg;
+{
+       struct tulip_softc *sc = arg;
+       struct ifnet *ifp = &sc->sc_ethercom.ec_if;
+       int s;
+
+       s = splnet();
+       if (why != PWR_RESUME) {
+               tlp_stop(sc, 0);
+               if (sc->sc_power != NULL)
+                       (*sc->sc_power)(sc, why);
+       } else if (ifp->if_flags & IFF_UP) {
+               if (sc->sc_power != NULL)
+                       (*sc->sc_power)(sc, why);
+               tlp_init(sc);
+       }
+       splx(s);
+}
+
+/*
  * tlp_rxdrain:
  *
  *     Drain the receive queue.
diff -r 6e448742e60e -r 6c450c11356c sys/dev/ic/tulipvar.h
--- a/sys/dev/ic/tulipvar.h     Sun Mar 19 21:27:01 2000 +0000
+++ b/sys/dev/ic/tulipvar.h     Sun Mar 19 21:45:23 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tulipvar.h,v 1.30 2000/03/15 18:39:51 thorpej Exp $    */
+/*     $NetBSD: tulipvar.h,v 1.31 2000/03/19 21:45:24 thorpej Exp $    */
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -270,6 +270,7 @@
        bus_dma_tag_t sc_dmat;          /* bus DMA tag */
        struct ethercom sc_ethercom;    /* ethernet common data */
        void *sc_sdhook;                /* shutdown hook */
+       void *sc_powerhook;             /* power management hook */
 
        struct tulip_stats sc_stats;    /* debugging stats */
 
@@ -326,6 +327,7 @@
        /* Power management hooks. */
        int             (*sc_enable) __P((struct tulip_softc *));
        void            (*sc_disable) __P((struct tulip_softc *));
+       void            (*sc_power) __P((struct tulip_softc *, int));
 
        /*
         * The Winbond 89C840F places registers 4 bytes apart, instead



Home | Main Index | Thread Index | Old Index