1 /* $OpenBSD: ofw_gpio.h,v 1.4 2020/04/27 12:15:30 kettenis Exp $ */ 2 /* 3 * Copyright (c) 2016 Mark Kettenis 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 #ifndef _DEV_OFW_GPIO_H_ 19 #define _DEV_OFW_GPIO_H_ 20 21 #define GPIO_ACTIVE_HIGH 0 22 #define GPIO_ACTIVE_LOW 1 23 24 struct gpio_controller { 25 int gc_node; 26 void *gc_cookie; 27 void (*gc_config_pin)(void *, uint32_t *, int); 28 int (*gc_get_pin)(void *, uint32_t *); 29 void (*gc_set_pin)(void *, uint32_t *, int); 30 31 LIST_ENTRY(gpio_controller) gc_list; 32 uint32_t gc_phandle; 33 uint32_t gc_cells; 34 }; 35 36 void gpio_controller_register(struct gpio_controller *); 37 38 #define GPIO_CONFIG_INPUT 0x0000 39 #define GPIO_CONFIG_OUTPUT 0x0001 40 #define GPIO_CONFIG_PULL_UP 0x0010 41 #define GPIO_CONFIG_PULL_DOWN 0x0020 42 #define GPIO_CONFIG_MD0 0x1000 43 #define GPIO_CONFIG_MD1 0x2000 44 #define GPIO_CONFIG_MD2 0x4000 45 #define GPIO_CONFIG_MD3 0x8000 46 void gpio_controller_config_pin(uint32_t *, int); 47 48 int gpio_controller_get_pin(uint32_t *); 49 void gpio_controller_set_pin(uint32_t *, int); 50 uint32_t *gpio_controller_next_pin(uint32_t *); 51 52 #endif /* _DEV_OFW_GPIO_H_ */ 53