Merge commit 'v3.1-rc4' into next
[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
7560fa60
DB
17#ifdef CONFIG_GENERIC_GPIO
18#include <asm/gpio.h>
19
20#else
21
3d599d1c 22#include <linux/kernel.h>
6ea0205b
DB
23#include <linux/types.h>
24#include <linux/errno.h>
25
a4177ee7 26struct device;
5f829e40 27struct gpio;
4e4438b8 28struct gpio_chip;
a4177ee7 29
7560fa60
DB
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
3474cb3c 39static inline bool gpio_is_valid(int number)
7560fa60 40{
3474cb3c 41 return false;
7560fa60
DB
42}
43
d8a3515e 44static inline int gpio_request(unsigned gpio, const char *label)
7560fa60
DB
45{
46 return -ENOSYS;
47}
48
323b7fe8 49static inline int gpio_request_one(unsigned gpio,
5f829e40
WS
50 unsigned long flags, const char *label)
51{
52 return -ENOSYS;
53}
54
7c295975 55static inline int gpio_request_array(const struct gpio *array, size_t num)
5f829e40
WS
56{
57 return -ENOSYS;
58}
59
7560fa60
DB
60static inline void gpio_free(unsigned gpio)
61{
3d599d1c
UKK
62 might_sleep();
63
7560fa60
DB
64 /* GPIO can never have been requested */
65 WARN_ON(1);
66}
67
7c295975 68static inline void gpio_free_array(const struct gpio *array, size_t num)
5f829e40
WS
69{
70 might_sleep();
71
72 /* GPIO can never have been requested */
73 WARN_ON(1);
74}
75
d8a3515e 76static inline int gpio_direction_input(unsigned gpio)
7560fa60
DB
77{
78 return -ENOSYS;
79}
80
d8a3515e 81static inline int gpio_direction_output(unsigned gpio, int value)
7560fa60
DB
82{
83 return -ENOSYS;
84}
85
c4b5be98
FB
86static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
87{
88 return -ENOSYS;
89}
90
7560fa60
DB
91static 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
98static 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
104static 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
111static 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
118static 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
d8f388d8
DB
124static 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
a4177ee7
JN
131static 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
07697461
JN
139static 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}
a4177ee7 145
d8f388d8
DB
146static inline void gpio_unexport(unsigned gpio)
147{
148 /* GPIO can never have been exported */
149 WARN_ON(1);
150}
151
7560fa60
DB
152static 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
159static 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 */
This page took 0.393525 seconds and 5 git commands to generate.