blob: 67851bbd3a42dfdb3fca7ab34d136bc6c839b0ca [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>
43
Jani Nikulaa4177ee2009-09-22 16:46:33 -070044struct device;
Anton Vorontsov4e4438b2010-09-01 08:55:24 -060045struct gpio_chip;
Jani Nikulaa4177ee2009-09-22 16:46:33 -070046
Joe Perches3474cb32011-05-10 16:23:07 -070047static inline bool gpio_is_valid(int number)
David Brownell7560fa62008-03-04 14:28:27 -080048{
Joe Perches3474cb32011-05-10 16:23:07 -070049 return false;
David Brownell7560fa62008-03-04 14:28:27 -080050}
51
Linus Torvaldsd8a35152011-01-13 17:26:46 -080052static inline int gpio_request(unsigned gpio, const char *label)
David Brownell7560fa62008-03-04 14:28:27 -080053{
54 return -ENOSYS;
55}
56
Wolfram Sang323b7fe2011-01-14 09:34:29 +010057static inline int gpio_request_one(unsigned gpio,
Wolfram Sang5f829e42011-01-12 17:00:24 -080058 unsigned long flags, const char *label)
59{
60 return -ENOSYS;
61}
62
Lars-Peter Clausen7c295972011-05-25 16:20:31 -070063static inline int gpio_request_array(const struct gpio *array, size_t num)
Wolfram Sang5f829e42011-01-12 17:00:24 -080064{
65 return -ENOSYS;
66}
67
David Brownell7560fa62008-03-04 14:28:27 -080068static inline void gpio_free(unsigned gpio)
69{
Uwe Kleine-König3d599d12008-10-15 22:03:12 -070070 might_sleep();
71
David Brownell7560fa62008-03-04 14:28:27 -080072 /* GPIO can never have been requested */
73 WARN_ON(1);
74}
75
Lars-Peter Clausen7c295972011-05-25 16:20:31 -070076static inline void gpio_free_array(const struct gpio *array, size_t num)
Wolfram Sang5f829e42011-01-12 17:00:24 -080077{
78 might_sleep();
79
80 /* GPIO can never have been requested */
81 WARN_ON(1);
82}
83
Linus Torvaldsd8a35152011-01-13 17:26:46 -080084static inline int gpio_direction_input(unsigned gpio)
David Brownell7560fa62008-03-04 14:28:27 -080085{
86 return -ENOSYS;
87}
88
Linus Torvaldsd8a35152011-01-13 17:26:46 -080089static inline int gpio_direction_output(unsigned gpio, int value)
David Brownell7560fa62008-03-04 14:28:27 -080090{
91 return -ENOSYS;
92}
93
Felipe Balbic4b5be92010-05-26 14:42:23 -070094static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
95{
96 return -ENOSYS;
97}
98
David Brownell7560fa62008-03-04 14:28:27 -080099static inline int gpio_get_value(unsigned gpio)
100{
101 /* GPIO can never have been requested or set as {in,out}put */
102 WARN_ON(1);
103 return 0;
104}
105
106static inline void gpio_set_value(unsigned gpio, int value)
107{
108 /* GPIO can never have been requested or set as output */
109 WARN_ON(1);
110}
111
112static inline int gpio_cansleep(unsigned gpio)
113{
114 /* GPIO can never have been requested or set as {in,out}put */
115 WARN_ON(1);
116 return 0;
117}
118
119static inline int gpio_get_value_cansleep(unsigned gpio)
120{
121 /* GPIO can never have been requested or set as {in,out}put */
122 WARN_ON(1);
123 return 0;
124}
125
126static inline void gpio_set_value_cansleep(unsigned gpio, int value)
127{
128 /* GPIO can never have been requested or set as output */
129 WARN_ON(1);
130}
131
David Brownelld8f388d82008-07-25 01:46:07 -0700132static inline int gpio_export(unsigned gpio, bool direction_may_change)
133{
134 /* GPIO can never have been requested or set as {in,out}put */
135 WARN_ON(1);
136 return -EINVAL;
137}
138
Jani Nikulaa4177ee2009-09-22 16:46:33 -0700139static inline int gpio_export_link(struct device *dev, const char *name,
140 unsigned gpio)
141{
142 /* GPIO can never have been exported */
143 WARN_ON(1);
144 return -EINVAL;
145}
146
Jani Nikula07697462009-12-15 16:46:20 -0800147static inline int gpio_sysfs_set_active_low(unsigned gpio, int value)
148{
149 /* GPIO can never have been requested */
150 WARN_ON(1);
151 return -EINVAL;
152}
Jani Nikulaa4177ee2009-09-22 16:46:33 -0700153
David Brownelld8f388d82008-07-25 01:46:07 -0700154static inline void gpio_unexport(unsigned gpio)
155{
156 /* GPIO can never have been exported */
157 WARN_ON(1);
158}
159
David Brownell7560fa62008-03-04 14:28:27 -0800160static inline int gpio_to_irq(unsigned gpio)
161{
162 /* GPIO can never have been requested or set as input */
163 WARN_ON(1);
164 return -EINVAL;
165}
166
167static inline int irq_to_gpio(unsigned irq)
168{
169 /* irq can never have been returned from gpio_to_irq() */
170 WARN_ON(1);
171 return -EINVAL;
172}
173
174#endif
175
176#endif /* __LINUX_GPIO_H */