diff options
author | Sonic Zhang <sonic.zhang@analog.com> | 2012-04-27 06:25:16 -0400 |
---|---|---|
committer | Bob Liu <lliubbo@gmail.com> | 2012-05-21 02:54:34 -0400 |
commit | 45abc49d194539144b5dd510c82c03c36cbd3a58 (patch) | |
tree | c088ed9f98279ba6191721c0d9d6fb9c3724704b /arch/blackfin/include | |
parent | 494b794808c6b1ead80590c01b08a87850cc4724 (diff) |
blackfin: GPIO: Implement more GPIO APIs
Implement more GPIO APIs in case GPIOLIB is disabled.
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Bob Liu <lliubbo@gmail.com>
Diffstat (limited to 'arch/blackfin/include')
-rw-r--r-- | arch/blackfin/include/asm/gpio.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/arch/blackfin/include/asm/gpio.h b/arch/blackfin/include/asm/gpio.h index 12d3571b5232..3d84d96f7c2c 100644 --- a/arch/blackfin/include/asm/gpio.h +++ b/arch/blackfin/include/asm/gpio.h | |||
@@ -26,6 +26,7 @@ | |||
26 | #ifndef __ASSEMBLY__ | 26 | #ifndef __ASSEMBLY__ |
27 | 27 | ||
28 | #include <linux/compiler.h> | 28 | #include <linux/compiler.h> |
29 | #include <linux/gpio.h> | ||
29 | 30 | ||
30 | /*********************************************************** | 31 | /*********************************************************** |
31 | * | 32 | * |
@@ -244,6 +245,49 @@ static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) | |||
244 | return -EINVAL; | 245 | return -EINVAL; |
245 | } | 246 | } |
246 | 247 | ||
248 | static inline int gpio_request_one(unsigned gpio, unsigned long flags, const char *label) | ||
249 | { | ||
250 | int err; | ||
251 | |||
252 | err = bfin_gpio_request(gpio, label); | ||
253 | if (err) | ||
254 | return err; | ||
255 | |||
256 | if (flags & GPIOF_DIR_IN) | ||
257 | err = bfin_gpio_direction_input(gpio); | ||
258 | else | ||
259 | err = bfin_gpio_direction_output(gpio, | ||
260 | (flags & GPIOF_INIT_HIGH) ? 1 : 0); | ||
261 | |||
262 | if (err) | ||
263 | bfin_gpio_free(gpio); | ||
264 | |||
265 | return err; | ||
266 | } | ||
267 | |||
268 | static inline int gpio_request_array(const struct gpio *array, size_t num) | ||
269 | { | ||
270 | int i, err; | ||
271 | |||
272 | for (i = 0; i < num; i++, array++) { | ||
273 | err = gpio_request_one(array->gpio, array->flags, array->label); | ||
274 | if (err) | ||
275 | goto err_free; | ||
276 | } | ||
277 | return 0; | ||
278 | |||
279 | err_free: | ||
280 | while (i--) | ||
281 | bfin_gpio_free((--array)->gpio); | ||
282 | return err; | ||
283 | } | ||
284 | |||
285 | static inline void gpio_free_array(const struct gpio *array, size_t num) | ||
286 | { | ||
287 | while (num--) | ||
288 | bfin_gpio_free((array++)->gpio); | ||
289 | } | ||
290 | |||
247 | static inline int __gpio_get_value(unsigned gpio) | 291 | static inline int __gpio_get_value(unsigned gpio) |
248 | { | 292 | { |
249 | return bfin_gpio_get_value(gpio); | 293 | return bfin_gpio_get_value(gpio); |