blob: ed5a46707ad0d0cd229e36920aa510b4d79fb279 [file] [log] [blame]
David Brownell7560fa62008-03-04 14:28:27 -08001#ifndef __LINUX_GPIO_H
2#define __LINUX_GPIO_H
3
4/* see Documentation/gpio.txt */
5
Randy Dunlapc001fb72011-06-14 17:05:11 -07006/* make these flag values available regardless of GPIO kconfig options */
7#define GPIOF_DIR_OUT (0 << 0)
8#define GPIOF_DIR_IN (1 << 0)
9
10#define GPIOF_INIT_LOW (0 << 1)
11#define GPIOF_INIT_HIGH (1 << 1)
12
13#define GPIOF_IN (GPIOF_DIR_IN)
14#define GPIOF_OUT_INIT_LOW (GPIOF_DIR_OUT | GPIOF_INIT_LOW)
15#define GPIOF_OUT_INIT_HIGH (GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
16
Mark Brownfeb83692011-10-24 15:24:10 +020017/**
18 * struct gpio - a structure describing a GPIO with configuration
19 * @gpio: the GPIO number
20 * @flags: GPIO configuration as specified by GPIOF_*
21 * @label: a literal description string of this GPIO
22 */
23struct gpio {
24 unsigned gpio;
25 unsigned long flags;
26 const char *label;
27};
28
David Brownell7560fa62008-03-04 14:28:27 -080029#ifdef CONFIG_GENERIC_GPIO
30#include <asm/gpio.h>
31
32#else
33
Uwe Kleine-König3d599d12008-10-15 22:03:12 -070034#include <linux/kernel.h>
David Brownell6ea02052008-05-23 13:04:58 -070035#include <linux/types.h>
36#include <linux/errno.h>
Paul Gortmaker187f1882011-11-23 20:12:59 -050037#include <linux/bug.h>
David Brownell6ea02052008-05-23 13:04:58 -070038
Jani Nikulaa4177ee2009-09-22 16:46:33 -070039struct device;
Anton Vorontsov4e4438b2010-09-01 08:55:24 -060040struct gpio_chip;
Jani Nikulaa4177ee2009-09-22 16:46:33 -070041
Joe Perches3474cb32011-05-10 16:23:07 -070042static inline bool gpio_is_valid(int number)
David Brownell7560fa62008-03-04 14:28:27 -080043{
Joe Perches3474cb32011-05-10 16:23:07 -070044 return false;
David Brownell7560fa62008-03-04 14:28:27 -080045}
46
Linus Torvaldsd8a35152011-01-13 17:26:46 -080047static inline int gpio_request(unsigned gpio, const char *label)
David Brownell7560fa62008-03-04 14:28:27 -080048{
49 return -ENOSYS;
50}
51
Wolfram Sang323b7fe2011-01-14 09:34:29 +010052static inline int gpio_request_one(unsigned gpio,
Wolfram Sang5f829e42011-01-12 17:00:24 -080053 unsigned long flags, const char *label)
54{
55 return -ENOSYS;
56}
57
Lars-Peter Clausen7c295972011-05-25 16:20:31 -070058static inline int gpio_request_array(const struct gpio *array, size_t num)
Wolfram Sang5f829e42011-01-12 17:00:24 -080059{
60 return -ENOSYS;
61}
62
David Brownell7560fa62008-03-04 14:28:27 -080063static inline void gpio_free(unsigned gpio)
64{
Uwe Kleine-König3d599d12008-10-15 22:03:12 -070065 might_sleep();
66
David Brownell7560fa62008-03-04 14:28:27 -080067 /* GPIO can never have been requested */
68 WARN_ON(1);
69}
70
Lars-Peter Clausen7c295972011-05-25 16:20:31 -070071static inline void gpio_free_array(const struct gpio *array, size_t num)
Wolfram Sang5f829e42011-01-12 17:00:24 -080072{
73 might_sleep();
74
75 /* GPIO can never have been requested */
76 WARN_ON(1);
77}
78
Linus Torvaldsd8a35152011-01-13 17:26:46 -080079static inline int gpio_direction_input(unsigned gpio)
David Brownell7560fa62008-03-04 14:28:27 -080080{
81 return -ENOSYS;
82}
83
Linus Torvaldsd8a35152011-01-13 17:26:46 -080084static inline int gpio_direction_output(unsigned gpio, int value)
David Brownell7560fa62008-03-04 14:28:27 -080085{
86 return -ENOSYS;
87}
88
Felipe Balbic4b5be92010-05-26 14:42:23 -070089static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
90{
91 return -ENOSYS;
92}
93
David Brownell7560fa62008-03-04 14:28:27 -080094static inline int gpio_get_value(unsigned gpio)
95{
96 /* GPIO can never have been requested or set as {in,out}put */
97 WARN_ON(1);
98 return 0;
99}
100
101static inline void gpio_set_value(unsigned gpio, int value)
102{
103 /* GPIO can never have been requested or set as output */
104 WARN_ON(1);
105}
106
107static inline int gpio_cansleep(unsigned gpio)
108{
109 /* GPIO can never have been requested or set as {in,out}put */
110 WARN_ON(1);
111 return 0;
112}
113
114static inline int gpio_get_value_cansleep(unsigned gpio)
115{
116 /* GPIO can never have been requested or set as {in,out}put */
117 WARN_ON(1);
118 return 0;
119}
120
121static inline void gpio_set_value_cansleep(unsigned gpio, int value)
122{
123 /* GPIO can never have been requested or set as output */
124 WARN_ON(1);
125}
126
David Brownelld8f388d82008-07-25 01:46:07 -0700127static inline int gpio_export(unsigned gpio, bool direction_may_change)
128{
129 /* GPIO can never have been requested or set as {in,out}put */
130 WARN_ON(1);
131 return -EINVAL;
132}
133
Jani Nikulaa4177ee2009-09-22 16:46:33 -0700134static inline int gpio_export_link(struct device *dev, const char *name,
135 unsigned gpio)
136{
137 /* GPIO can never have been exported */
138 WARN_ON(1);
139 return -EINVAL;
140}
141
Jani Nikula07697462009-12-15 16:46:20 -0800142static inline int gpio_sysfs_set_active_low(unsigned gpio, int value)
143{
144 /* GPIO can never have been requested */
145 WARN_ON(1);
146 return -EINVAL;
147}
Jani Nikulaa4177ee2009-09-22 16:46:33 -0700148
David Brownelld8f388d82008-07-25 01:46:07 -0700149static inline void gpio_unexport(unsigned gpio)
150{
151 /* GPIO can never have been exported */
152 WARN_ON(1);
153}
154
David Brownell7560fa62008-03-04 14:28:27 -0800155static inline int gpio_to_irq(unsigned gpio)
156{
157 /* GPIO can never have been requested or set as input */
158 WARN_ON(1);
159 return -EINVAL;
160}
161
162static inline int irq_to_gpio(unsigned irq)
163{
164 /* irq can never have been returned from gpio_to_irq() */
165 WARN_ON(1);
166 return -EINVAL;
167}
168
169#endif
170
171#endif /* __LINUX_GPIO_H */