FreeBSD/Linux Kernel Cross Reference
sys/sys/gpio.h
1 /* $NetBSD: gpio.h,v 1.3 2008/01/09 15:11:30 xtraeme Exp $ */
2 /* $OpenBSD: gpio.h,v 1.1 2004/06/03 18:08:00 grange Exp $ */
3 /*
4 * Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #ifndef _SYS_GPIO_H_
20 #define _SYS_GPIO_H_
21
22 /* GPIO pin states */
23 #define GPIO_PIN_LOW 0x00 /* low level (logical 0) */
24 #define GPIO_PIN_HIGH 0x01 /* high level (logical 1) */
25
26 /* GPIO pin configuration flags */
27 #define GPIO_PIN_INPUT 0x0001 /* input direction */
28 #define GPIO_PIN_OUTPUT 0x0002 /* output direction */
29 #define GPIO_PIN_INOUT 0x0004 /* bi-directional */
30 #define GPIO_PIN_OPENDRAIN 0x0008 /* open-drain output */
31 #define GPIO_PIN_PUSHPULL 0x0010 /* push-pull output */
32 #define GPIO_PIN_TRISTATE 0x0020 /* output disabled */
33 #define GPIO_PIN_PULLUP 0x0040 /* internal pull-up enabled */
34 #define GPIO_PIN_PULLDOWN 0x0080 /* internal pull-down enabled */
35 #define GPIO_PIN_INVIN 0x0100 /* invert input */
36 #define GPIO_PIN_INVOUT 0x0200 /* invert output */
37
38 /* GPIO controller description */
39 struct gpio_info {
40 int gpio_npins; /* total number of pins available */
41 };
42
43 /* GPIO pin operation (read/write/toggle) */
44 struct gpio_pin_op {
45 int gp_pin; /* pin number */
46 int gp_value; /* value */
47 };
48
49 /* GPIO pin control */
50 struct gpio_pin_ctl {
51 int gp_pin; /* pin number */
52 int gp_caps; /* pin capabilities (read-only) */
53 int gp_flags; /* pin configuration flags */
54 };
55
56 #define GPIOINFO _IOR('G', 0, struct gpio_info)
57 #define GPIOPINREAD _IOWR('G', 1, struct gpio_pin_op)
58 #define GPIOPINWRITE _IOWR('G', 2, struct gpio_pin_op)
59 #define GPIOPINTOGGLE _IOWR('G', 3, struct gpio_pin_op)
60 #define GPIOPINCTL _IOWR('G', 4, struct gpio_pin_ctl)
61
62 #endif /* !_SYS_GPIO_H_ */
Cache object: 863cc7aea502b3d9b2e5ace42097b9c7
|