Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/acpi add pmf support
details: https://anonhg.NetBSD.org/src/rev/88759a3f791d
branches: trunk
changeset: 757210:88759a3f791d
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Thu Aug 19 14:59:24 2010 +0000
description:
add pmf support
diffstat:
sys/dev/acpi/wb_acpi.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 48 insertions(+), 2 deletions(-)
diffs (102 lines):
diff -r 62bd173602a0 -r 88759a3f791d sys/dev/acpi/wb_acpi.c
--- a/sys/dev/acpi/wb_acpi.c Thu Aug 19 14:58:22 2010 +0000
+++ b/sys/dev/acpi/wb_acpi.c Thu Aug 19 14:59:24 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wb_acpi.c,v 1.2 2010/03/05 14:00:17 jruoho Exp $ */
+/* $NetBSD: wb_acpi.c,v 1.3 2010/08/19 14:59:24 jmcneill Exp $ */
/*
* Copyright (c) 2009 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wb_acpi.c,v 1.2 2010/03/05 14:00:17 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wb_acpi.c,v 1.3 2010/08/19 14:59:24 jmcneill Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -44,12 +44,17 @@
static int wb_acpi_match(device_t, cfdata_t, void *);
static void wb_acpi_attach(device_t, device_t, void *);
static int wb_acpi_detach(device_t, int);
+static bool wb_acpi_suspend(device_t, const pmf_qual_t *);
+static bool wb_acpi_resume(device_t, const pmf_qual_t *);
struct wb_acpi_softc {
struct wb_softc sc_wb;
isa_chipset_tag_t sc_ic;
void *sc_ih;
int sc_ioh_length;
+
+ ACPI_HANDLE sc_crs, sc_srs;
+ ACPI_BUFFER sc_crs_buffer;
};
CFATTACH_DECL_NEW(wb_acpi, sizeof(struct wb_acpi_softc),
@@ -96,6 +101,16 @@
if (ACPI_FAILURE(rv))
return;
+ AcpiGetHandle(aa->aa_node->ad_handle, "_CRS", &sc->sc_crs);
+ AcpiGetHandle(aa->aa_node->ad_handle, "_SRS", &sc->sc_srs);
+ if (sc->sc_crs && sc->sc_srs) {
+ sc->sc_crs_buffer.Pointer = NULL;
+ sc->sc_crs_buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+ rv = AcpiGetCurrentResources(sc->sc_crs, &sc->sc_crs_buffer);
+ if (ACPI_FAILURE(rv))
+ sc->sc_crs = sc->sc_srs = NULL;
+ }
+
io = acpi_res_io(&res, 0);
irq = acpi_res_irq(&res, 0);
if (io == NULL || irq == NULL) {
@@ -125,6 +140,8 @@
sc->sc_wb.wb_irq = irq->ar_irq;
sc->sc_wb.wb_base = io->ar_base;
wb_attach(&sc->sc_wb);
+
+ pmf_device_register(self, wb_acpi_suspend, wb_acpi_resume);
cleanup:
acpi_resource_cleanup(&res);
@@ -136,6 +153,11 @@
struct wb_acpi_softc *sc = device_private(self);
int rv;
+ pmf_device_deregister(self);
+
+ if (sc->sc_crs_buffer.Pointer)
+ ACPI_FREE(sc->sc_crs_buffer.Pointer);
+
rv = wb_detach(&sc->sc_wb, flags);
if (rv)
return rv;
@@ -149,3 +171,27 @@
return 0;
}
+
+static bool
+wb_acpi_suspend(device_t self, const pmf_qual_t *qual)
+{
+ struct wb_acpi_softc *sc = device_private(self);
+
+ return wb_suspend(&sc->sc_wb);
+}
+
+static bool
+wb_acpi_resume(device_t self, const pmf_qual_t *qual)
+{
+ struct wb_acpi_softc *sc = device_private(self);
+ ACPI_STATUS rv;
+
+ if (sc->sc_crs && sc->sc_srs) {
+ rv = AcpiSetCurrentResources(sc->sc_srs, &sc->sc_crs_buffer);
+ if (ACPI_FAILURE(rv))
+ printf("%s: _SRS failed: %s\n",
+ device_xname(self), AcpiFormatException(rv));
+ }
+
+ return wb_resume(&sc->sc_wb);
+}
Home |
Main Index |
Thread Index |
Old Index