Commit | Line | Data |
---|---|---|
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 | */ | |
29 | struct 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> | |
187f1882 | 43 | #include <linux/bug.h> |
6ea0205b | 44 | |
a4177ee7 | 45 | struct device; |
4e4438b8 | 46 | struct gpio_chip; |
a4177ee7 | 47 | |
3474cb3c | 48 | static inline bool gpio_is_valid(int number) |
7560fa60 | 49 | { |
3474cb3c | 50 | return false; |
7560fa60 DB |
51 | } |
52 | ||
d8a3515e | 53 | static inline int gpio_request(unsigned gpio, const char *label) |
7560fa60 DB |
54 | { |
55 | return -ENOSYS; | |
56 | } | |
57 | ||
323b7fe8 | 58 | static inline int gpio_request_one(unsigned gpio, |
5f829e40 WS |
59 | unsigned long flags, const char *label) |
60 | { | |
61 | return -ENOSYS; | |
62 | } | |
63 | ||
7c295975 | 64 | static inline int gpio_request_array(const struct gpio *array, size_t num) |
5f829e40 WS |
65 | { |
66 | return -ENOSYS; | |
67 | } | |
68 | ||
7560fa60 DB |
69 | static inline void gpio_free(unsigned gpio) |
70 | { | |
3d599d1c UKK |
71 | might_sleep(); |
72 | ||
7560fa60 DB |
73 | /* GPIO can never have been requested */ |
74 | WARN_ON(1); | |
75 | } | |
76 | ||
7c295975 | 77 | static inline void gpio_free_array(const struct gpio *array, size_t num) |
5f829e40 WS |
78 | { |
79 | might_sleep(); | |
80 | ||
81 | /* GPIO can never have been requested */ | |
82 | WARN_ON(1); | |
83 | } | |
84 | ||
d8a3515e | 85 | static inline int gpio_direction_input(unsigned gpio) |
7560fa60 DB |
86 | { |
87 | return -ENOSYS; | |
88 | } | |
89 | ||
d8a3515e | 90 | static inline int gpio_direction_output(unsigned gpio, int value) |
7560fa60 DB |
91 | { |
92 | return -ENOSYS; | |
93 | } | |
94 | ||
c4b5be98 FB |
95 | static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) |
96 | { | |
97 | return -ENOSYS; | |
98 | } | |
99 | ||
7560fa60 DB |
100 | static inline int gpio_get_value(unsigned gpio) |
101 | { | |
102 | /* GPIO can never have been requested or set as {in,out}put */ | |
103 | WARN_ON(1); | |
104 | return 0; | |
105 | } | |
106 | ||
107 | static inline void gpio_set_value(unsigned gpio, int value) | |
108 | { | |
109 | /* GPIO can never have been requested or set as output */ | |
110 | WARN_ON(1); | |
111 | } | |
112 | ||
113 | static inline int gpio_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 | ||
120 | static inline int gpio_get_value_cansleep(unsigned gpio) | |
121 | { | |
122 | /* GPIO can never have been requested or set as {in,out}put */ | |
123 | WARN_ON(1); | |
124 | return 0; | |
125 | } | |
126 | ||
127 | static inline void gpio_set_value_cansleep(unsigned gpio, int value) | |
128 | { | |
129 | /* GPIO can never have been requested or set as output */ | |
130 | WARN_ON(1); | |
131 | } | |
132 | ||
d8f388d8 DB |
133 | static inline int gpio_export(unsigned gpio, bool direction_may_change) |
134 | { | |
135 | /* GPIO can never have been requested or set as {in,out}put */ | |
136 | WARN_ON(1); | |
137 | return -EINVAL; | |
138 | } | |
139 | ||
a4177ee7 JN |
140 | static inline int gpio_export_link(struct device *dev, const char *name, |
141 | unsigned gpio) | |
142 | { | |
143 | /* GPIO can never have been exported */ | |
144 | WARN_ON(1); | |
145 | return -EINVAL; | |
146 | } | |
147 | ||
07697461 JN |
148 | static inline int gpio_sysfs_set_active_low(unsigned gpio, int value) |
149 | { | |
150 | /* GPIO can never have been requested */ | |
151 | WARN_ON(1); | |
152 | return -EINVAL; | |
153 | } | |
a4177ee7 | 154 | |
d8f388d8 DB |
155 | static inline void gpio_unexport(unsigned gpio) |
156 | { | |
157 | /* GPIO can never have been exported */ | |
158 | WARN_ON(1); | |
159 | } | |
160 | ||
7560fa60 DB |
161 | static inline int gpio_to_irq(unsigned gpio) |
162 | { | |
163 | /* GPIO can never have been requested or set as input */ | |
164 | WARN_ON(1); | |
165 | return -EINVAL; | |
166 | } | |
167 | ||
168 | static inline int irq_to_gpio(unsigned irq) | |
169 | { | |
170 | /* irq can never have been returned from gpio_to_irq() */ | |
171 | WARN_ON(1); | |
172 | return -EINVAL; | |
173 | } | |
174 | ||
175 | #endif | |
176 | ||
177 | #endif /* __LINUX_GPIO_H */ |