]> Git Repo - linux.git/blame - include/linux/gpio.h
BUG: headers with BUG/BUG_ON etc. need linux/bug.h
[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
feb83699
MB
17/**
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
7560fa60
DB
29#ifdef CONFIG_GENERIC_GPIO
30#include <asm/gpio.h>
31
32#else
33
3d599d1c 34#include <linux/kernel.h>
6ea0205b
DB
35#include <linux/types.h>
36#include <linux/errno.h>
187f1882 37#include <linux/bug.h>
6ea0205b 38
a4177ee7 39struct device;
4e4438b8 40struct gpio_chip;
a4177ee7 41
3474cb3c 42static inline bool gpio_is_valid(int number)
7560fa60 43{
3474cb3c 44 return false;
7560fa60
DB
45}
46
d8a3515e 47static inline int gpio_request(unsigned gpio, const char *label)
7560fa60
DB
48{
49 return -ENOSYS;
50}
51
323b7fe8 52static inline int gpio_request_one(unsigned gpio,
5f829e40
WS
53 unsigned long flags, const char *label)
54{
55 return -ENOSYS;
56}
57
7c295975 58static inline int gpio_request_array(const struct gpio *array, size_t num)
5f829e40
WS
59{
60 return -ENOSYS;
61}
62
7560fa60
DB
63static inline void gpio_free(unsigned gpio)
64{
3d599d1c
UKK
65 might_sleep();
66
7560fa60
DB
67 /* GPIO can never have been requested */
68 WARN_ON(1);
69}
70
7c295975 71static inline void gpio_free_array(const struct gpio *array, size_t num)
5f829e40
WS
72{
73 might_sleep();
74
75 /* GPIO can never have been requested */
76 WARN_ON(1);
77}
78
d8a3515e 79static inline int gpio_direction_input(unsigned gpio)
7560fa60
DB
80{
81 return -ENOSYS;
82}
83
d8a3515e 84static inline int gpio_direction_output(unsigned gpio, int value)
7560fa60
DB
85{
86 return -ENOSYS;
87}
88
c4b5be98
FB
89static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
90{
91 return -ENOSYS;
92}
93
7560fa60
DB
94static inline int gpio_get_value(unsigned gpio)
95{
96 /* GPIO can never have been requested or set as {in,out}put */
97 WARN_ON(1);
98 return 0;
99}
100
101static inline void gpio_set_value(unsigned gpio, int value)
102{
103 /* GPIO can never have been requested or set as output */
104 WARN_ON(1);
105}
106
107static inline int gpio_cansleep(unsigned gpio)
108{
109 /* GPIO can never have been requested or set as {in,out}put */
110 WARN_ON(1);
111 return 0;
112}
113
114static inline int gpio_get_value_cansleep(unsigned gpio)
115{
116 /* GPIO can never have been requested or set as {in,out}put */
117 WARN_ON(1);
118 return 0;
119}
120
121static inline void gpio_set_value_cansleep(unsigned gpio, int value)
122{
123 /* GPIO can never have been requested or set as output */
124 WARN_ON(1);
125}
126
d8f388d8
DB
127static inline int gpio_export(unsigned gpio, bool direction_may_change)
128{
129 /* GPIO can never have been requested or set as {in,out}put */
130 WARN_ON(1);
131 return -EINVAL;
132}
133
a4177ee7
JN
134static inline int gpio_export_link(struct device *dev, const char *name,
135 unsigned gpio)
136{
137 /* GPIO can never have been exported */
138 WARN_ON(1);
139 return -EINVAL;
140}
141
07697461
JN
142static inline int gpio_sysfs_set_active_low(unsigned gpio, int value)
143{
144 /* GPIO can never have been requested */
145 WARN_ON(1);
146 return -EINVAL;
147}
a4177ee7 148
d8f388d8
DB
149static inline void gpio_unexport(unsigned gpio)
150{
151 /* GPIO can never have been exported */
152 WARN_ON(1);
153}
154
7560fa60
DB
155static inline int gpio_to_irq(unsigned gpio)
156{
157 /* GPIO can never have been requested or set as input */
158 WARN_ON(1);
159 return -EINVAL;
160}
161
162static inline int irq_to_gpio(unsigned irq)
163{
164 /* irq can never have been returned from gpio_to_irq() */
165 WARN_ON(1);
166 return -EINVAL;
167}
168
169#endif
170
171#endif /* __LINUX_GPIO_H */
This page took 0.647241 seconds and 4 git commands to generate.