blob: 38ac48b7d3a8db90bf0ff7630df25c2d8880ecb9 [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>
37
Jani Nikulaa4177ee2009-09-22 16:46:33 -070038struct device;
Anton Vorontsov4e4438b2010-09-01 08:55:24 -060039struct gpio_chip;
Jani Nikulaa4177ee2009-09-22 16:46:33 -070040
Joe Perches3474cb32011-05-10 16:23:07 -070041static inline bool gpio_is_valid(int number)
David Brownell7560fa62008-03-04 14:28:27 -080042{
Joe Perches3474cb32011-05-10 16:23:07 -070043 return false;
David Brownell7560fa62008-03-04 14:28:27 -080044}
45
Linus Torvaldsd8a35152011-01-13 17:26:46 -080046static inline int gpio_request(unsigned gpio, const char *label)
David Brownell7560fa62008-03-04 14:28:27 -080047{
48 return -ENOSYS;
49}
50
Wolfram Sang323b7fe2011-01-14 09:34:29 +010051static inline int gpio_request_one(unsigned gpio,
Wolfram Sang5f829e42011-01-12 17:00:24 -080052 unsigned long flags, const char *label)
53{
54 return -ENOSYS;
55}
56
Lars-Peter Clausen7c295972011-05-25 16:20:31 -070057static inline int gpio_request_array(const struct gpio *array, size_t num)
Wolfram Sang5f829e42011-01-12 17:00:24 -080058{
59 return -ENOSYS;
60}
61
David Brownell7560fa62008-03-04 14:28:27 -080062static inline void gpio_free(unsigned gpio)
63{
Uwe Kleine-König3d599d12008-10-15 22:03:12 -070064 might_sleep();
65
David Brownell7560fa62008-03-04 14:28:27 -080066 /* GPIO can never have been requested */
67 WARN_ON(1);
68}
69
Lars-Peter Clausen7c295972011-05-25 16:20:31 -070070static inline void gpio_free_array(const struct gpio *array, size_t num)
Wolfram Sang5f829e42011-01-12 17:00:24 -080071{
72 might_sleep();
73
74 /* GPIO can never have been requested */
75 WARN_ON(1);
76}
77
Linus Torvaldsd8a35152011-01-13 17:26:46 -080078static inline int gpio_direction_input(unsigned gpio)
David Brownell7560fa62008-03-04 14:28:27 -080079{
80 return -ENOSYS;
81}
82
Linus Torvaldsd8a35152011-01-13 17:26:46 -080083static inline int gpio_direction_output(unsigned gpio, int value)
David Brownell7560fa62008-03-04 14:28:27 -080084{
85 return -ENOSYS;
86}
87
Felipe Balbic4b5be92010-05-26 14:42:23 -070088static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
89{
90 return -ENOSYS;
91}
92
David Brownell7560fa62008-03-04 14:28:27 -080093static inline int gpio_get_value(unsigned gpio)
94{
95 /* GPIO can never have been requested or set as {in,out}put */
96 WARN_ON(1);
97 return 0;
98}
99
100static inline void gpio_set_value(unsigned gpio, int value)
101{
102 /* GPIO can never have been requested or set as output */
103 WARN_ON(1);
104}
105
106static inline int gpio_cansleep(unsigned gpio)
107{
108 /* GPIO can never have been requested or set as {in,out}put */
109 WARN_ON(1);
110 return 0;
111}
112
113static inline int gpio_get_value_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 void gpio_set_value_cansleep(unsigned gpio, int value)
121{
122 /* GPIO can never have been requested or set as output */
123 WARN_ON(1);
124}
125
David Brownelld8f388d2008-07-25 01:46:07 -0700126static inline int gpio_export(unsigned gpio, bool direction_may_change)
127{
128 /* GPIO can never have been requested or set as {in,out}put */
129 WARN_ON(1);
130 return -EINVAL;
131}
132
Jani Nikulaa4177ee2009-09-22 16:46:33 -0700133static inline int gpio_export_link(struct device *dev, const char *name,
134 unsigned gpio)
135{
136 /* GPIO can never have been exported */
137 WARN_ON(1);
138 return -EINVAL;
139}
140
Jani Nikula07697462009-12-15 16:46:20 -0800141static inline int gpio_sysfs_set_active_low(unsigned gpio, int value)
142{
143 /* GPIO can never have been requested */
144 WARN_ON(1);
145 return -EINVAL;
146}
Jani Nikulaa4177ee2009-09-22 16:46:33 -0700147
David Brownelld8f388d2008-07-25 01:46:07 -0700148static inline void gpio_unexport(unsigned gpio)
149{
150 /* GPIO can never have been exported */
151 WARN_ON(1);
152}
153
David Brownell7560fa62008-03-04 14:28:27 -0800154static inline int gpio_to_irq(unsigned gpio)
155{
156 /* GPIO can never have been requested or set as input */
157 WARN_ON(1);
158 return -EINVAL;
159}
160
161static inline int irq_to_gpio(unsigned irq)
162{
163 /* irq can never have been returned from gpio_to_irq() */
164 WARN_ON(1);
165 return -EINVAL;
166}
167
168#endif
169
170#endif /* __LINUX_GPIO_H */