gpio.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. *
  3. * arch/arm/mach-u300/include/mach/gpio.h
  4. *
  5. *
  6. * Copyright (C) 2007-2009 ST-Ericsson AB
  7. * License terms: GNU General Public License (GPL) version 2
  8. * GPIO block resgister definitions and inline macros for
  9. * U300 GPIO COH 901 335 or COH 901 571/3
  10. * Author: Linus Walleij <linus.walleij@stericsson.com>
  11. */
  12. #ifndef __MACH_U300_GPIO_H
  13. #define __MACH_U300_GPIO_H
  14. #define __ARM_GPIOLIB_COMPLEX
  15. /* These can be found in arch/arm/mach-u300/gpio.c */
  16. extern int gpio_is_valid(int number);
  17. extern int gpio_request(unsigned gpio, const char *label);
  18. extern void gpio_free(unsigned gpio);
  19. extern int gpio_direction_input(unsigned gpio);
  20. extern int gpio_direction_output(unsigned gpio, int value);
  21. extern int gpio_register_callback(unsigned gpio,
  22. int (*func)(void *arg),
  23. void *);
  24. extern int gpio_unregister_callback(unsigned gpio);
  25. extern void enable_irq_on_gpio_pin(unsigned gpio, int edge);
  26. extern void disable_irq_on_gpio_pin(unsigned gpio);
  27. extern void gpio_pullup(unsigned gpio, int value);
  28. extern int gpio_get_value(unsigned gpio);
  29. extern void gpio_set_value(unsigned gpio, int value);
  30. #define gpio_get_value_cansleep gpio_get_value
  31. #define gpio_set_value_cansleep gpio_set_value
  32. /* translates a pin number to a port number */
  33. #define PIN_TO_PORT(val) (val >> 3)
  34. /* wrappers to sleep-enable the previous two functions */
  35. static inline unsigned gpio_to_irq(unsigned gpio)
  36. {
  37. return PIN_TO_PORT(gpio) + IRQ_U300_GPIO_PORT0;
  38. }
  39. #define gpio_to_irq gpio_to_irq
  40. #endif /* __MACH_U300_GPIO_H */