1 /* $OpenBSD: gpio.h,v 1.1 2004/06/03 18:08:00 grange Exp $ */ 2 /* 3 * Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org> 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 _SYS_GPIO_H_ 19 #define _SYS_GPIO_H_ 20 21 /* GPIO pin states */ 22 #define GPIO_PIN_LOW 0x00 /* low level (logical 0) */ 23 #define GPIO_PIN_HIGH 0x01 /* high level (logical 1) */ 24 25 /* GPIO pin configuration flags */ 26 #define GPIO_PIN_INPUT 0x0001 /* input direction */ 27 #define GPIO_PIN_OUTPUT 0x0002 /* output direction */ 28 #define GPIO_PIN_INOUT 0x0004 /* bi-directional */ 29 #define GPIO_PIN_OPENDRAIN 0x0008 /* open-drain output */ 30 #define GPIO_PIN_PUSHPULL 0x0010 /* push-pull output */ 31 #define GPIO_PIN_TRISTATE 0x0020 /* output disabled */ 32 #define GPIO_PIN_PULLUP 0x0040 /* internal pull-up enabled */ 33 34 /* GPIO controller description */ 35 struct gpio_info { 36 int gpio_npins; /* total number of pins available */ 37 }; 38 39 /* GPIO pin operation (read/write/toggle) */ 40 struct gpio_pin_op { 41 int gp_pin; /* pin number */ 42 int gp_value; /* value */ 43 }; 44 45 /* GPIO pin control */ 46 struct gpio_pin_ctl { 47 int gp_pin; /* pin number */ 48 int gp_caps; /* pin capabilities (read-only) */ 49 int gp_flags; /* pin configuration flags */ 50 }; 51 52 #define GPIOINFO _IOR('G', 0, struct gpio_info) 53 #define GPIOPINREAD _IOWR('G', 1, struct gpio_pin_op) 54 #define GPIOPINWRITE _IOWR('G', 2, struct gpio_pin_op) 55 #define GPIOPINTOGGLE _IOWR('G', 3, struct gpio_pin_op) 56 #define GPIOPINCTL _IOWR('G', 4, struct gpio_pin_ctl) 57 58 #endif /* !_SYS_GPIO_H_ */