summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2022-11-10 11:45:30 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2022-11-10 11:45:30 +0000
commit95e0375e34b18c0acdf59d95b25146b33e267cd7 (patch)
treefdd19123ffb461a656209ce61f08d5838c7fa371 /sys/arch
parentda31aeff7138247181bf4a7c2b8fb64efe996900 (diff)
Make the power button function as a wakeup button during suspend.
ok phessler@, patrick@, tobhe@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/arm64/dev/aplsmc.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/sys/arch/arm64/dev/aplsmc.c b/sys/arch/arm64/dev/aplsmc.c
index a210dcbe687..185e97635a2 100644
--- a/sys/arch/arm64/dev/aplsmc.c
+++ b/sys/arch/arm64/dev/aplsmc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aplsmc.c,v 1.15 2022/11/09 19:18:11 kettenis Exp $ */
+/* $OpenBSD: aplsmc.c,v 1.16 2022/11/10 11:45:29 kettenis Exp $ */
/*
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
*
@@ -330,20 +330,29 @@ aplsmc_attach(struct device *parent, struct device *self, void *aux)
#endif
#endif
+
+#ifdef SUSPEND
+ device_register_wakeup(&sc->sc_dev);
+#endif
}
void
aplsmc_handle_notification(struct aplsmc_softc *sc, uint64_t data)
{
extern int allowpowerdown;
+ extern int cpu_suspended;
switch (SMC_EV_TYPE(data)) {
case SMC_EV_TYPE_BTN:
switch (SMC_EV_SUBTYPE(data)) {
case SMC_PWRBTN_SHORT:
- if (SMC_EV_DATA(data) == 1 && allowpowerdown) {
- allowpowerdown = 0;
- prsignal(initprocess, SIGUSR2);
+ if (SMC_EV_DATA(data) == 1) {
+ if (cpu_suspended) {
+ cpu_suspended = 0;
+ } else if (allowpowerdown) {
+ allowpowerdown = 0;
+ prsignal(initprocess, SIGUSR2);
+ }
}
break;
case SMC_PWRBTN_LONG: