aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Wibo <obiwac@FreeBSD.org>2026-02-02 23:49:23 +0000
committerAymeric Wibo <obiwac@FreeBSD.org>2026-02-02 23:51:17 +0000
commitfedc9746bd37340a06dfcafea28904cf401127cf (patch)
tree7296f15c3ae0473f115bb2f9c5462e35b3ce7c19
parent4a71fc3b5cebdf3e6227470d50cf559bab28f26b (diff)
acpi_spmc: Register SPMC suspend/resume routines
SPMC suspend runs after the device tree is suspended using the acpi_post_dev_suspend eventhandler, and SPMC resume runs before the device tree is resumed using the acpi_pre_dev_suspend eventhandler. Reviewed by: olce Approved by: olce Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48735
-rw-r--r--sys/dev/acpica/acpi_spmc.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/sys/dev/acpica/acpi_spmc.c b/sys/dev/acpica/acpi_spmc.c
index d8d28d59340d..e8ed14fdcb1b 100644
--- 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 <machine/_inttypes.h>
@@ -158,6 +158,9 @@ struct acpi_spmc_softc {
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;
@@ -168,6 +171,9 @@ static void acpi_spmc_check_dsm_set(struct acpi_spmc_softc *sc,
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)
{
@@ -207,9 +213,8 @@ acpi_spmc_probe(device_t dev)
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);
@@ -221,7 +226,12 @@ acpi_spmc_attach(device_t dev)
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);
+
+ sc->eh_suspend = EVENTHANDLER_REGISTER(acpi_post_dev_suspend,
+ acpi_spmc_suspend, dev, 0);
+ sc->eh_resume = EVENTHANDLER_REGISTER(acpi_pre_dev_resume,
+ acpi_spmc_resume, dev, 0);
return (0);
}
@@ -229,6 +239,11 @@ acpi_spmc_attach(device_t dev)
static int
acpi_spmc_detach(device_t dev)
{
+ struct acpi_spmc_softc *sc = device_get_softc(dev);
+
+ EVENTHANDLER_DEREGISTER(acpi_post_dev_suspend, sc->eh_suspend);
+ EVENTHANDLER_DEREGISTER(acpi_pre_dev_resume, sc->eh_resume);
+
acpi_spmc_free_constraints(device_get_softc(dev));
return (0);
}
@@ -586,22 +601,24 @@ acpi_spmc_exit_notif(device_t dev)
}
}
-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[] = {