Page MenuHomeFreeBSD

D48387.id170479.diff
No OneTemporary

D48387.id170479.diff

diff --git a/sys/conf/files b/sys/conf/files
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -777,6 +777,7 @@
dev/acpica/acpi_video.c optional acpi_video acpi
dev/acpica/acpi_dock.c optional acpi_dock acpi
dev/acpica/acpi_spmc.c optional acpi
+dev/acpica/acpi_pmc_if.m optional acpi
dev/adlink/adlink.c optional adlink
dev/ae/if_ae.c optional ae pci
dev/age/if_age.c optional age pci
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -3636,6 +3636,7 @@
device_printf(sc->acpi_dev, "device_suspend failed\n");
goto backout;
}
+ EVENTHANDLER_INVOKE(acpi_pmc_suspend, stype);
slp_state |= ACPI_SS_DEV_SUSPEND;
if (stype != POWER_STYPE_SUSPEND_TO_IDLE) {
@@ -3685,6 +3686,7 @@
slp_state &= ~ACPI_SS_GPE_SET;
}
if ((slp_state & ACPI_SS_DEV_SUSPEND) != 0) {
+ EVENTHANDLER_INVOKE(acpi_pmc_resume, stype);
DEVICE_RESUME(root_bus);
slp_state &= ~ACPI_SS_DEV_SUSPEND;
}
diff --git a/sys/dev/acpica/acpi_spmc.c b/sys/dev/acpica/acpi_spmc.c
--- a/sys/dev/acpica/acpi_spmc.c
+++ b/sys/dev/acpica/acpi_spmc.c
@@ -8,12 +8,12 @@
*/
#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
#include <sys/bus.h>
+#include <sys/eventhandler.h>
+#include <sys/kernel.h>
#include <sys/malloc.h>
+#include <sys/module.h>
#include <sys/uuid.h>
-#include <sys/kdb.h>
#include <contrib/dev/acpica/include/acpi.h>
#include <contrib/dev/acpica/include/accommon.h>
@@ -156,6 +156,9 @@
ACPI_OBJECT *obj;
enum dsm_set_flags dsm_sets;
+ struct eventhandler_entry *eh_suspend;
+ struct eventhandler_entry *eh_resume;
+
bool constraints_populated;
size_t constraint_count;
struct acpi_spmc_constraint *constraints;
@@ -166,6 +169,9 @@
static int acpi_spmc_get_constraints(device_t dev);
static void acpi_spmc_free_constraints(struct acpi_spmc_softc *sc);
+static void acpi_spmc_suspend(device_t dev, enum power_stype stype);
+static void acpi_spmc_resume(device_t dev, enum power_stype stype);
+
static int
acpi_spmc_probe(device_t dev)
{
@@ -205,9 +211,8 @@
static int
acpi_spmc_attach(device_t dev)
{
- struct acpi_spmc_softc *sc;
+ struct acpi_spmc_softc *sc = device_get_softc(dev);
- sc = device_get_softc(dev);
sc->dev = dev;
sc->handle = acpi_get_handle(dev);
@@ -219,7 +224,16 @@
sc->constraints = NULL;
/* Get device constraints. We can only call this once so do this now. */
- acpi_spmc_get_constraints(sc->dev);
+ acpi_spmc_get_constraints(dev);
+
+ if ((sc->eh_suspend = EVENTHANDLER_REGISTER(acpi_pmc_suspend,
+ acpi_spmc_suspend, dev, 0)) == NULL)
+ device_printf(dev, "Failed to register PMC suspend event "
+ "handler.\n");
+ if ((sc->eh_resume = EVENTHANDLER_REGISTER(acpi_pmc_resume,
+ acpi_spmc_resume, dev, 0)) == NULL)
+ device_printf(dev, "Failed to register PMC resume event "
+ "handler.\n");
return (0);
}
@@ -227,6 +241,13 @@
static int
acpi_spmc_detach(device_t dev)
{
+ struct acpi_spmc_softc *sc = device_get_softc(dev);
+
+ if (sc->eh_suspend != NULL)
+ EVENTHANDLER_DEREGISTER(acpi_pmc_suspend, sc->eh_suspend);
+ if (sc->eh_resume != NULL)
+ EVENTHANDLER_DEREGISTER(acpi_pmc_resume, sc->eh_resume);
+
acpi_spmc_free_constraints(device_get_softc(dev));
return (0);
}
@@ -583,22 +604,24 @@
}
}
-static int
-acpi_spmc_suspend(device_t dev)
+static void
+acpi_spmc_suspend(device_t dev, enum power_stype stype)
{
+ if (stype != POWER_STYPE_SUSPEND_TO_IDLE)
+ return;
+
acpi_spmc_display_off_notif(dev);
acpi_spmc_entry_notif(dev);
-
- return (0);
}
-static int
-acpi_spmc_resume(device_t dev)
+static void
+acpi_spmc_resume(device_t dev, enum power_stype stype)
{
+ if (stype != POWER_STYPE_SUSPEND_TO_IDLE)
+ return;
+
acpi_spmc_exit_notif(dev);
acpi_spmc_display_on_notif(dev);
-
- return (0);
}
static device_method_t acpi_spmc_methods[] = {
diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h
--- a/sys/dev/acpica/acpivar.h
+++ b/sys/dev/acpica/acpivar.h
@@ -482,12 +482,14 @@
#define ACPI_EVENT_PRI_DEFAULT 10000
#define ACPI_EVENT_PRI_LAST 20000
-typedef void (*acpi_event_handler_t)(void *, int);
+typedef void (*acpi_event_handler_t)(void *, enum power_stype);
EVENTHANDLER_DECLARE(acpi_sleep_event, acpi_event_handler_t);
EVENTHANDLER_DECLARE(acpi_wakeup_event, acpi_event_handler_t);
EVENTHANDLER_DECLARE(acpi_acad_event, acpi_event_handler_t);
EVENTHANDLER_DECLARE(acpi_video_event, acpi_event_handler_t);
+EVENTHANDLER_DECLARE(acpi_pmc_suspend, acpi_event_handler_t);
+EVENTHANDLER_DECLARE(acpi_pmc_resume, acpi_event_handler_t);
/* Device power control. */
ACPI_STATUS acpi_pwr_wake_enable(ACPI_HANDLE consumer, int enable);

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 29, 8:59 AM (7 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28064882
Default Alt Text
D48387.id170479.diff (4 KB)

Event Timeline