gpio: gpiolib: Support for open source/emitter gpios
[deliverable/linux.git] / include / linux / gpio.h
CommitLineData
7560fa60
DB
1#ifndef __LINUX_GPIO_H
2#define __LINUX_GPIO_H
3
4/* see Documentation/gpio.txt */
5
c001fb72
RD
6/* 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
aca5ce14
LD
17/* Gpio pin is open drain */
18#define GPIOF_OPEN_DRAIN (1 << 2)
19
25553ff0
LD
20/* Gpio pin is open source */
21#define GPIOF_OPEN_SOURCE (1 << 3)
22
feb83699
MB
23/**
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
7560fa60
DB
35#ifdef CONFIG_GENERIC_GPIO
36#include <asm/gpio.h>
37
38#else
39
3d599d1c 40#include <linux/kernel.h>
6ea0205b
DB
41#include <linux/types.h>
42#include <linux/errno.h>
43
a4177ee7 44struct device;
4e4438b8 45struct gpio_chip;
a4177ee7 46
3474cb3c 47static inline bool gpio_is_valid(int number)
7560fa60 48{
3474cb3c 49 return false;
7560fa60
DB
50}
51
d8a3515e 52static inline int gpio_request(unsigned gpio, const char *label)
7560fa60
DB
53{
54 return -ENOSYS;
55}
56
323b7fe8 57static inline int gpio_request_one(unsigned gpio,
5f829e40
WS
58 unsigned long flags, const char *label)
59{
60 return -ENOSYS;
61}
62
7c295975 63static inline int gpio_request_array(const struct gpio *array, size_t num)
5f829e40
WS
64{
65 return -ENOSYS;
66}
67
7560fa60
DB
68static inline void gpio_free(unsigned gpio)
69{
3d599d1c
UKK
70 might_sleep();
71
7560fa60
DB
72 /* GPIO can never have been requested */
73 WARN_ON(1);
74}
75
7c295975 76static inline void gpio_free_array(const struct gpio *array, size_t num)
5f829e40
WS
77{
78 might_sleep();
79
80 /* GPIO can never have been requested */
81 WARN_ON(1);
82}
83
d8a3515e 84static inline int gpio_direction_input(unsigned gpio)
7560fa60
DB
85{
86 return -ENOSYS;
87}
88
d8a3515e 89static inline int gpio_direction_output(unsigned gpio, int value)
7560fa60
DB
90{
91 return -ENOSYS;
92}
93
c4b5be98
FB
94static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
95{
96 return -ENOSYS;
97}
98
7560fa60
DB
99static 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
d8f388d8
DB
132static 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
a4177ee7
JN
139static 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
07697461
JN
147static 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}
a4177ee7 153
d8f388d8
DB
154static inline void gpio_unexport(unsigned gpio)
155{
156 /* GPIO can never have been exported */
157 WARN_ON(1);
158}
159
7560fa60
DB
160static 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 */
This page took 0.410983 seconds and 5 git commands to generate.