summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2025-01-09 19:38:14 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2025-01-09 19:38:14 +0000
commitd07be8c9861b3d76900a4647746f3ddc5dae42cc (patch)
treedcef80bb095d1d3514c62abb665ed6f5746265b2 /sys
parentada38b979bf3a4f3defea56864b8a8da55400d17 (diff)
Implement support for using GPIO pins as interrupt pins.
ok kn@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ofw/ofw_gpio.c30
-rw-r--r--sys/dev/ofw/ofw_gpio.h8
2 files changed, 36 insertions, 2 deletions
diff --git a/sys/dev/ofw/ofw_gpio.c b/sys/dev/ofw/ofw_gpio.c
index f8f818e8fb1..929a87aea84 100644
--- a/sys/dev/ofw/ofw_gpio.c
+++ b/sys/dev/ofw/ofw_gpio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ofw_gpio.c,v 1.3 2019/08/26 09:22:27 kettenis Exp $ */
+/* $OpenBSD: ofw_gpio.c,v 1.4 2025/01/09 19:38:13 kettenis Exp $ */
/*
* Copyright (c) 2016, 2019 Mark Kettenis
*
@@ -19,6 +19,8 @@
#include <sys/systm.h>
#include <sys/malloc.h>
+#include <machine/fdt.h>
+
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_gpio.h>
@@ -141,3 +143,29 @@ gpio_controller_next_pin(uint32_t *cells)
return NULL;
}
+
+void *
+gpio_controller_intr_establish(uint32_t *cells, int ipl, struct cpu_info *ci,
+ int (*func)(void *), void *arg, char *name)
+{
+ struct gpio_controller *gc;
+ uint32_t phandle = cells[0];
+
+ LIST_FOREACH(gc, &gpio_controllers, gc_list) {
+ if (gc->gc_phandle == phandle)
+ break;
+ }
+
+ if (gc && gc->gc_intr_establish) {
+ return gc->gc_intr_establish(gc->gc_cookie, &cells[1], ipl,
+ ci, func, arg, name);
+ }
+
+ return NULL;
+}
+
+void
+gpio_controller_intr_disestablish(void *ih)
+{
+ fdt_intr_disestablish(ih);
+}
diff --git a/sys/dev/ofw/ofw_gpio.h b/sys/dev/ofw/ofw_gpio.h
index 95bcea95351..027dfc484d8 100644
--- a/sys/dev/ofw/ofw_gpio.h
+++ b/sys/dev/ofw/ofw_gpio.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ofw_gpio.h,v 1.5 2020/12/18 22:14:13 kettenis Exp $ */
+/* $OpenBSD: ofw_gpio.h,v 1.6 2025/01/09 19:38:13 kettenis Exp $ */
/*
* Copyright (c) 2016 Mark Kettenis
*
@@ -34,6 +34,8 @@ struct gpio_controller {
void (*gc_config_pin)(void *, uint32_t *, int);
int (*gc_get_pin)(void *, uint32_t *);
void (*gc_set_pin)(void *, uint32_t *, int);
+ void *(*gc_intr_establish)(void *, uint32_t *, int,
+ struct cpu_info *, int (*)(void *), void *, char *);
LIST_ENTRY(gpio_controller) gc_list;
uint32_t gc_phandle;
@@ -56,4 +58,8 @@ int gpio_controller_get_pin(uint32_t *);
void gpio_controller_set_pin(uint32_t *, int);
uint32_t *gpio_controller_next_pin(uint32_t *);
+void *gpio_controller_intr_establish(uint32_t *, int, struct cpu_info *,
+ int (*)(void *), void *, char *);
+void gpio_controller_intr_disestablish(void *);
+
#endif /* _DEV_OFW_GPIO_H_ */