FreeBSD/Linux Kernel Cross Reference
sys/sys/gpio.h
1 /* $NetBSD: gpio.h,v 1.2 2005/12/11 12:25:20 christos 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
35 /* GPIO controller description */
36 struct gpio_info {
37 int gpio_npins; /* total number of pins available */
38 };
39
40 /* GPIO pin operation (read/write/toggle) */
41 struct gpio_pin_op {
42 int gp_pin; /* pin number */
43 int gp_value; /* value */
44 };
45
46 /* GPIO pin control */
47 struct gpio_pin_ctl {
48 int gp_pin; /* pin number */
49 int gp_caps; /* pin capabilities (read-only) */
50 int gp_flags; /* pin configuration flags */
51 };
52
53 #define GPIOINFO _IOR('G', 0, struct gpio_info)
54 #define GPIOPINREAD _IOWR('G', 1, struct gpio_pin_op)
55 #define GPIOPINWRITE _IOWR('G', 2, struct gpio_pin_op)
56 #define GPIOPINTOGGLE _IOWR('G', 3, struct gpio_pin_op)
57 #define GPIOPINCTL _IOWR('G', 4, struct gpio_pin_ctl)
58
59 #endif /* !_SYS_GPIO_H_ */
Cache object: 3fe7b2733a339483ec683b31c9e28c39
|