gpio.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
  7. */
  8. #ifndef __BCM47XX_GPIO_H
  9. #define __BCM47XX_GPIO_H
  10. #include <linux/ssb/ssb_embedded.h>
  11. #include <asm/mach-bcm47xx/bcm47xx.h>
  12. #define BCM47XX_EXTIF_GPIO_LINES 5
  13. #define BCM47XX_CHIPCO_GPIO_LINES 16
  14. extern int gpio_request(unsigned gpio, const char *label);
  15. extern void gpio_free(unsigned gpio);
  16. extern int gpio_to_irq(unsigned gpio);
  17. static inline int gpio_get_value(unsigned gpio)
  18. {
  19. return ssb_gpio_in(&ssb_bcm47xx, 1 << gpio);
  20. }
  21. static inline void gpio_set_value(unsigned gpio, int value)
  22. {
  23. ssb_gpio_out(&ssb_bcm47xx, 1 << gpio, value ? 1 << gpio : 0);
  24. }
  25. static inline int gpio_direction_input(unsigned gpio)
  26. {
  27. return ssb_gpio_outen(&ssb_bcm47xx, 1 << gpio, 0);
  28. }
  29. static inline int gpio_direction_output(unsigned gpio, int value)
  30. {
  31. return ssb_gpio_outen(&ssb_bcm47xx, 1 << gpio, 1 << gpio);
  32. }
  33. static int gpio_intmask(unsigned gpio, int value)
  34. {
  35. return ssb_gpio_intmask(&ssb_bcm47xx, 1 << gpio,
  36. value ? 1 << gpio : 0);
  37. }
  38. static int gpio_polarity(unsigned gpio, int value)
  39. {
  40. return ssb_gpio_polarity(&ssb_bcm47xx, 1 << gpio,
  41. value ? 1 << gpio : 0);
  42. }
  43. /* cansleep wrappers */
  44. #include <asm-generic/gpio.h>
  45. #endif /* __BCM47XX_GPIO_H */