gpio.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. ssb_gpio_outen(&ssb_bcm47xx, 1 << gpio, 0);
  28. return 0;
  29. }
  30. static inline int gpio_direction_output(unsigned gpio, int value)
  31. {
  32. ssb_gpio_outen(&ssb_bcm47xx, 1 << gpio, 1 << gpio);
  33. return 0;
  34. }
  35. static inline int gpio_intmask(unsigned gpio, int value)
  36. {
  37. ssb_gpio_intmask(&ssb_bcm47xx, 1 << gpio,
  38. value ? 1 << gpio : 0);
  39. return 0;
  40. }
  41. static inline int gpio_polarity(unsigned gpio, int value)
  42. {
  43. ssb_gpio_polarity(&ssb_bcm47xx, 1 << gpio,
  44. value ? 1 << gpio : 0);
  45. return 0;
  46. }
  47. /* cansleep wrappers */
  48. #include <asm-generic/gpio.h>
  49. #endif /* __BCM47XX_GPIO_H */