blob: 6155ecf192b0466f02ea616b5b8d8ef9fd5fc2f5 [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
Laxman Dewanganaca5ce12012-02-17 20:26:21 +053017/* Gpio pin is open drain */
18#define GPIOF_OPEN_DRAIN (1 << 2)
19
Laxman Dewangan25553ff2012-02-17 20:26:22 +053020/* Gpio pin is open source */
21#define GPIOF_OPEN_SOURCE (1 << 3)
22
Mark Brownfeb83692011-10-24 15:24:10 +020023/**
24 * struct gpio - a structure describing a GPIO with configuration
25 * @gpio: the GPIO number
26 * @flags: GPIO configuration as specified by GPIOF_*
27 * @label: a literal description string of this GPIO
28 */
29struct gpio {
30 unsigned gpio;
31 unsigned long flags;
32 const char *label;
33};
34
David Brownell7560fa62008-03-04 14:28:27 -080035#ifdef CONFIG_GENERIC_GPIO
36#include <asm/gpio.h>
37
38#else
39
Uwe Kleine-König3d599d12008-10-15 22:03:12 -070040#include <linux/kernel.h>
David Brownell6ea02052008-05-23 13:04:58 -070041#include <linux/types.h>
42#include <linux/errno.h>
Paul Gortmaker187f1882011-11-23 20:12:59 -050043#include <linux/bug.h>
David Brownell6ea02052008-05-23 13:04:58 -070044
Jani Nikulaa4177ee2009-09-22 16:46:33 -070045struct device;
Anton Vorontsov4e4438b2010-09-01 08:55:24 -060046struct gpio_chip;
Jani Nikulaa4177ee2009-09-22 16:46:33 -070047
Joe Perches3474cb32011-05-10 16:23:07 -070048static inline bool gpio_is_valid(int number)
David Brownell7560fa62008-03-04 14:28:27 -080049{
Joe Perches3474cb32011-05-10 16:23:07 -070050 return false;
David Brownell7560fa62008-03-04 14:28:27 -080051}
52
Linus Torvaldsd8a35152011-01-13 17:26:46 -080053static inline int gpio_request(unsigned gpio, const char *label)
David Brownell7560fa62008-03-04 14:28:27 -080054{
55 return -ENOSYS;
56}
57
Wolfram Sang323b7fe2011-01-14 09:34:29 +010058static inline int gpio_request_one(unsigned gpio,
Wolfram Sang5f829e42011-01-12 17:00:24 -080059 unsigned long flags, const char *label)
60{
61 return -ENOSYS;
62}
63
Lars-Peter Clausen7c295972011-05-25 16:20:31 -070064static inline int gpio_request_array(const struct gpio *array, size_t num)
Wolfram Sang5f829e42011-01-12 17:00:24 -080065{
66 return -ENOSYS;
67}
68
David Brownell7560fa62008-03-04 14:28:27 -080069static inline void gpio_free(unsigned gpio)
70{
Uwe Kleine-König3d599d12008-10-15 22:03:12 -070071 might_sleep();
72
David Brownell7560fa62008-03-04 14:28:27 -080073 /* GPIO can never have been requested */
74 WARN_ON(1);
75}
76
Lars-Peter Clausen7c295972011-05-25 16:20:31 -070077static inline void gpio_free_array(const struct gpio *array, size_t num)
Wolfram Sang5f829e42011-01-12 17:00:24 -080078{
79 might_sleep();
80
81 /* GPIO can never have been requested */
82 WARN_ON(1);
83}
84
Linus Torvaldsd8a35152011-01-13 17:26:46 -080085static inline int gpio_direction_input(unsigned gpio)
David Brownell7560fa62008-03-04 14:28:27 -080086{
87 return -ENOSYS;
88}
89
Linus Torvaldsd8a35152011-01-13 17:26:46 -080090static inline int gpio_direction_output(unsigned gpio, int value)
David Brownell7560fa62008-03-04 14:28:27 -080091{
92 return -ENOSYS;
93}
94
Felipe Balbic4b5be92010-05-26 14:42:23 -070095static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
96{
97 return -ENOSYS;
98}
99
David Brownell7560fa62008-03-04 14:28:27 -0800100static inline int gpio_get_value(unsigned gpio)
101{
102 /* GPIO can never have been requested or set as {in,out}put */
103 WARN_ON(1);
104 return 0;
105}
106
107static inline void gpio_set_value(unsigned gpio, int value)
108{
109 /* GPIO can never have been requested or set as output */
110 WARN_ON(1);
111}
112
113static inline int gpio_cansleep(unsigned gpio)
114{
115 /* GPIO can never have been requested or set as {in,out}put */
116 WARN_ON(1);
117 return 0;
118}
119
120static inline int gpio_get_value_cansleep(unsigned gpio)
121{
122 /* GPIO can never have been requested or set as {in,out}put */
123 WARN_ON(1);
124 return 0;
125}
126
127static inline void gpio_set_value_cansleep(unsigned gpio, int value)
128{
129 /* GPIO can never have been requested or set as output */
130 WARN_ON(1);
131}
132
David Brownelld8f388d2008-07-25 01:46:07 -0700133static inline int gpio_export(unsigned gpio, bool direction_may_change)
134{
135 /* GPIO can never have been requested or set as {in,out}put */
136 WARN_ON(1);
137 return -EINVAL;
138}
139
Jani Nikulaa4177ee2009-09-22 16:46:33 -0700140static inline int gpio_export_link(struct device *dev, const char *name,
141 unsigned gpio)
142{
143 /* GPIO can never have been exported */
144 WARN_ON(1);
145 return -EINVAL;
146}
147
Jani Nikula07697462009-12-15 16:46:20 -0800148static inline int gpio_sysfs_set_active_low(unsigned gpio, int value)
149{
150 /* GPIO can never have been requested */
151 WARN_ON(1);
152 return -EINVAL;
153}
Jani Nikulaa4177ee2009-09-22 16:46:33 -0700154
David Brownelld8f388d2008-07-25 01:46:07 -0700155static inline void gpio_unexport(unsigned gpio)
156{
157 /* GPIO can never have been exported */
158 WARN_ON(1);
159}
160
David Brownell7560fa62008-03-04 14:28:27 -0800161static inline int gpio_to_irq(unsigned gpio)
162{
163 /* GPIO can never have been requested or set as input */
164 WARN_ON(1);
165 return -EINVAL;
166}
167
168static inline int irq_to_gpio(unsigned irq)
169{
170 /* irq can never have been returned from gpio_to_irq() */
171 WARN_ON(1);
172 return -EINVAL;
173}
174
175#endif
176
177#endif /* __LINUX_GPIO_H */