From 01de2955e4110f96e2d7584f4000374cf4937fcd Mon Sep 17 00:00:00 2001
From: Doug Ambrisko <ambrisko@FreeBSD.org>
Date: Wed, 5 Feb 2003 03:37:42 +0000
Subject: [PATCH] Support for suspend/resume in laptops.  Loosely based on the
 wi(4) patches but not quite.  The memory descriptors and most of the card
 parameters need to be writen to the card.

MFC in:		3 days
---
 sys/dev/an/if_an.c     | 20 ++++++++++++++++++++
 sys/dev/an/if_an_pci.c | 20 ++++++++++++++++++++
 sys/dev/an/if_anreg.h  |  1 +
 3 files changed, 41 insertions(+)

diff --git a/sys/dev/an/if_an.c b/sys/dev/an/if_an.c
index 1197012b4fcf..717994304ff9 100644
--- a/sys/dev/an/if_an.c
+++ b/sys/dev/an/if_an.c
@@ -2832,6 +2832,26 @@ an_shutdown(dev)
 	return;
 }
 
+void
+an_resume(dev)
+	device_t		dev;
+{
+	struct an_softc		*sc;
+	struct ifnet		*ifp;
+	sc = device_get_softc(dev);
+	ifp = &sc->arpcom.ac_if;
+
+	an_reset(sc);
+	if (sc->mpi350)
+		an_init_mpi350_desc(sc);	
+	an_init(sc);
+
+	if (ifp->if_flags & IFF_UP)
+		an_start(ifp);
+
+	return;
+}
+
 #ifdef ANCACHE
 /* Aironet signal strength cache code.
  * store signal/noise/quality on per MAC src basis in
diff --git a/sys/dev/an/if_an_pci.c b/sys/dev/an/if_an_pci.c
index 2fe45e0a9c92..c21902417e61 100644
--- a/sys/dev/an/if_an_pci.c
+++ b/sys/dev/an/if_an_pci.c
@@ -116,6 +116,8 @@ static struct an_type an_devs[] = {
 static int an_probe_pci		(device_t);
 static int an_attach_pci	(device_t);
 static int an_detach_pci	(device_t);
+static int an_suspend_pci	(device_t);
+static int an_resume_pci	(device_t);
 
 static int
 an_probe_pci(device_t dev)
@@ -261,12 +263,30 @@ an_detach_pci(device_t dev)
 	return (0);
 }
 
+static int
+an_suspend_pci(device_t dev)
+{
+	an_shutdown(dev);
+	
+	return (0);
+}
+
+static int
+an_resume_pci(device_t dev)
+{
+	an_resume(dev);
+
+	return (0);
+}
+
 static device_method_t an_pci_methods[] = {
         /* Device interface */
         DEVMETHOD(device_probe,         an_probe_pci),
         DEVMETHOD(device_attach,        an_attach_pci),
 	DEVMETHOD(device_detach,	an_detach_pci),
 	DEVMETHOD(device_shutdown,	an_shutdown),
+	DEVMETHOD(device_suspend,	an_suspend_pci),
+	DEVMETHOD(device_resume,	an_resume_pci),
         { 0, 0 }
 };
 
diff --git a/sys/dev/an/if_anreg.h b/sys/dev/an/if_anreg.h
index 20ed9bb6c1a0..165f76028571 100644
--- a/sys/dev/an/if_anreg.h
+++ b/sys/dev/an/if_anreg.h
@@ -503,6 +503,7 @@ int	an_alloc_aux_memory	(device_t, int, int);
 int	an_alloc_irq		(device_t, int, int);
 int	an_probe	(device_t);
 void	an_shutdown	(device_t);
+void	an_resume	(device_t);
 int	an_attach		(struct an_softc *, int, int);
 void    an_stop		(struct an_softc *);