From 2da809330b846850adb44772016fa9d334f78392 Mon Sep 17 00:00:00 2001 From: patrick Date: Thu, 10 Nov 2022 16:20:54 +0000 Subject: [PATCH] Apparently we receive interrupts for both powerkey press and release, which isn't quite helpful when it's used to come back from suspend and then the second interrupt initiates powerdown. Ignore press, but handle release. ok kettenis@ --- sys/dev/fdt/qcpon.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/dev/fdt/qcpon.c b/sys/dev/fdt/qcpon.c index 0e23d507eb1..ee1f387cedb 100644 --- a/sys/dev/fdt/qcpon.c +++ b/sys/dev/fdt/qcpon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qcpon.c,v 1.1 2022/11/08 19:44:28 patrick Exp $ */ +/* $OpenBSD: qcpon.c,v 1.2 2022/11/10 16:20:54 patrick Exp $ */ /* * Copyright (c) 2022 Patrick Wildt * @@ -40,6 +40,7 @@ struct qcpon_softc { int8_t sc_sid; void *sc_pwrkey_ih; + int sc_pwrkey_debounce; struct task sc_powerdown_task; }; @@ -104,6 +105,11 @@ qcpon_pwrkey_intr(void *arg) { struct qcpon_softc *sc = arg; + /* Ignore presses, handle releases. */ + sc->sc_pwrkey_debounce = (sc->sc_pwrkey_debounce + 1) % 2; + if (sc->sc_pwrkey_debounce == 1) + return 1; + task_add(systq, &sc->sc_powerdown_task); return 1; } -- 2.20.1