summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorTobias Heider <tobhe@cvs.openbsd.org>2023-09-05 11:04:07 +0000
committerTobias Heider <tobhe@cvs.openbsd.org>2023-09-05 11:04:07 +0000
commitc1b43d4e7957a063ae5ffed673d4ba1ecf2dbb6d (patch)
tree0f495e41cb4679682901dd9a9f0f4ad869ff5f04 /sys/arch
parent249d3e02d3e407e29e54045867dfb2328d90865a (diff)
Fix touchpad on newer device trees. The *gpio fields moved up one layer.
The driver will work with both formats for now but we plan to remove the old one in the future. ok kettenis@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/arm64/dev/apldc.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/sys/arch/arm64/dev/apldc.c b/sys/arch/arm64/dev/apldc.c
index ddd885226be..26edab2c20a 100644
--- a/sys/arch/arm64/dev/apldc.c
+++ b/sys/arch/arm64/dev/apldc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apldc.c,v 1.9 2023/07/03 15:54:07 tobhe Exp $ */
+/* $OpenBSD: apldc.c,v 1.10 2023/09/05 11:04:06 tobhe Exp $ */
/*
* Copyright (c) 2022 Mark Kettenis <kettenis@openbsd.org>
*
@@ -575,17 +575,22 @@ apldchidev_handle_gpio_req(struct apldchidev_softc *sc, uint8_t iface,
if (sc->sc_ngpios >= APLDCHIDEV_NUM_GPIOS)
return;
- if (iface == sc->sc_iface_mt)
- node = OF_getnodebyname(sc->sc_node, "multi-touch");
- else if (iface == sc->sc_iface_stm)
- node = OF_getnodebyname(sc->sc_node, "stm");
- if (node == -1)
- return;
-
+ node = sc->sc_node;
snprintf(name, sizeof(name), "apple,%s-gpios", req->name);
len = OF_getproplen(node, name);
- if (len <= 0 || len > sizeof(gpio))
- return;
+ if (len <= 0 || len > sizeof(gpio)) {
+ /* XXX: older device trees store gpios in sub-nodes */
+ if (iface == sc->sc_iface_mt)
+ node = OF_getnodebyname(sc->sc_node, "multi-touch");
+ else if (iface == sc->sc_iface_stm)
+ node = OF_getnodebyname(sc->sc_node, "stm");
+ if (node == -1)
+ return;
+ len = OF_getproplen(node, name);
+ if (len <= 0 || len > sizeof(gpio))
+ return;
+ }
+
OF_getpropintarray(node, name, gpio, len);
gpio_controller_config_pin(gpio, GPIO_CONFIG_OUTPUT);
gpio_controller_set_pin(gpio, 0);