Merge branch 'for-linus' of git://git.open-osd.org/linux-open-osd
[pandora-kernel.git] / include / linux / gpio.h
1 #ifndef __LINUX_GPIO_H
2 #define __LINUX_GPIO_H
3
4 /* see Documentation/gpio.txt */
5
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
17 #ifdef CONFIG_GENERIC_GPIO
18 #include <asm/gpio.h>
19
20 #else
21
22 #include <linux/kernel.h>
23 #include <linux/types.h>
24 #include <linux/errno.h>
25
26 struct device;
27 struct gpio;
28 struct gpio_chip;
29
30 /*
31  * Some platforms don't support the GPIO programming interface.
32  *
33  * In case some driver uses it anyway (it should normally have
34  * depended on GENERIC_GPIO), these routines help the compiler
35  * optimize out much GPIO-related code ... or trigger a runtime
36  * warning when something is wrongly called.
37  */
38
39 static inline bool gpio_is_valid(int number)
40 {
41         return false;
42 }
43
44 static inline int gpio_request(unsigned gpio, const char *label)
45 {
46         return -ENOSYS;
47 }
48
49 static inline int gpio_request_one(unsigned gpio,
50                                         unsigned long flags, const char *label)
51 {
52         return -ENOSYS;
53 }
54
55 static inline int gpio_request_array(const struct gpio *array, size_t num)
56 {
57         return -ENOSYS;
58 }
59
60 static inline void gpio_free(unsigned gpio)
61 {
62         might_sleep();
63
64         /* GPIO can never have been requested */
65         WARN_ON(1);
66 }
67
68 static inline void gpio_free_array(const struct gpio *array, size_t num)
69 {
70         might_sleep();
71
72         /* GPIO can never have been requested */
73         WARN_ON(1);
74 }
75
76 static inline int gpio_direction_input(unsigned gpio)
77 {
78         return -ENOSYS;
79 }
80
81 static inline int gpio_direction_output(unsigned gpio, int value)
82 {
83         return -ENOSYS;
84 }
85
86 static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
87 {
88         return -ENOSYS;
89 }
90
91 static inline int gpio_get_value(unsigned gpio)
92 {
93         /* GPIO can never have been requested or set as {in,out}put */
94         WARN_ON(1);
95         return 0;
96 }
97
98 static inline void gpio_set_value(unsigned gpio, int value)
99 {
100         /* GPIO can never have been requested or set as output */
101         WARN_ON(1);
102 }
103
104 static inline int gpio_cansleep(unsigned gpio)
105 {
106         /* GPIO can never have been requested or set as {in,out}put */
107         WARN_ON(1);
108         return 0;
109 }
110
111 static inline int gpio_get_value_cansleep(unsigned gpio)
112 {
113         /* GPIO can never have been requested or set as {in,out}put */
114         WARN_ON(1);
115         return 0;
116 }
117
118 static inline void gpio_set_value_cansleep(unsigned gpio, int value)
119 {
120         /* GPIO can never have been requested or set as output */
121         WARN_ON(1);
122 }
123
124 static inline int gpio_export(unsigned gpio, bool direction_may_change)
125 {
126         /* GPIO can never have been requested or set as {in,out}put */
127         WARN_ON(1);
128         return -EINVAL;
129 }
130
131 static inline int gpio_export_link(struct device *dev, const char *name,
132                                 unsigned gpio)
133 {
134         /* GPIO can never have been exported */
135         WARN_ON(1);
136         return -EINVAL;
137 }
138
139 static inline int gpio_sysfs_set_active_low(unsigned gpio, int value)
140 {
141         /* GPIO can never have been requested */
142         WARN_ON(1);
143         return -EINVAL;
144 }
145
146 static inline void gpio_unexport(unsigned gpio)
147 {
148         /* GPIO can never have been exported */
149         WARN_ON(1);
150 }
151
152 static inline int gpio_to_irq(unsigned gpio)
153 {
154         /* GPIO can never have been requested or set as input */
155         WARN_ON(1);
156         return -EINVAL;
157 }
158
159 static inline int irq_to_gpio(unsigned irq)
160 {
161         /* irq can never have been returned from gpio_to_irq() */
162         WARN_ON(1);
163         return -EINVAL;
164 }
165
166 #endif
167
168 #endif /* __LINUX_GPIO_H */