diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2016-07-27 21:13:50 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2016-07-27 21:13:50 +0000 |
commit | 538331371777deebe2eda442996ed4889696c252 (patch) | |
tree | 510aa90cb8b0ee6341e93a08b6e17d91eb80caed /sys/dev | |
parent | 145d1e6440c6556928e2f20b76f75eb2803b8617 (diff) |
Add interface to facilitate iterating over gpios.
ok patrick@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ofw/ofw_gpio.c | 15 | ||||
-rw-r--r-- | sys/dev/ofw/ofw_gpio.h | 3 |
2 files changed, 16 insertions, 2 deletions
diff --git a/sys/dev/ofw/ofw_gpio.c b/sys/dev/ofw/ofw_gpio.c index 668210ae955..5f814ac7322 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.1 2016/07/11 14:49:41 kettenis Exp $ */ +/* $OpenBSD: ofw_gpio.c,v 1.2 2016/07/27 21:13:49 kettenis Exp $ */ /* * Copyright (c) 2016 Mark Kettenis * @@ -82,3 +82,16 @@ gpio_controller_set_pin(uint32_t *cells, int val) if (gc && gc->gc_set_pin) gc->gc_set_pin(gc->gc_cookie, &cells[1], val); } + +uint32_t * +gpio_controller_next_pin(uint32_t *cells) +{ + struct gpio_controller *gc; + uint32_t phandle = cells[0]; + + LIST_FOREACH(gc, &gpio_controllers, gc_list) + if (gc->gc_phandle == phandle) + return cells + gc->gc_cells + 1; + + return NULL; +} diff --git a/sys/dev/ofw/ofw_gpio.h b/sys/dev/ofw/ofw_gpio.h index 52f00b0f530..52b2fe08453 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.1 2016/07/11 14:49:41 kettenis Exp $ */ +/* $OpenBSD: ofw_gpio.h,v 1.2 2016/07/27 21:13:49 kettenis Exp $ */ /* * Copyright (c) 2016 Mark Kettenis * @@ -41,5 +41,6 @@ void gpio_controller_config_pin(uint32_t *, int); int gpio_controller_get_pin(uint32_t *); void gpio_controller_set_pin(uint32_t *, int); +uint32_t *gpio_controller_next_pin(uint32_t *); #endif /* _DEV_OFW_GPIO_H_ */ |