gpio.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * arch/asm-arm/mach-kirkwood/include/mach/gpio.h
  3. *
  4. * This file is licensed under the terms of the GNU General Public
  5. * License version 2. This program is licensed "as is" without any
  6. * warranty of any kind, whether express or implied.
  7. */
  8. /*
  9. * Based on (mostly copied from) plat-orion based Linux 2.6 kernel driver.
  10. * Removed kernel level irq handling. Took some macros from kernel to
  11. * allow build.
  12. *
  13. * Dieter Kiermaier dk-arm-linux@gmx.de
  14. */
  15. #ifndef __KIRKWOOD_GPIO_H
  16. #define __KIRKWOOD_GPIO_H
  17. /* got from kernel include/linux/kernel.h */
  18. #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
  19. /* got from kernel include/linux/bitops.h */
  20. #define BITS_PER_BYTE 8
  21. #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
  22. #define GPIO_MAX 50
  23. #define GPIO_OFF(pin) (((pin) >> 5) ? 0x0040 : 0x0000)
  24. #define GPIO_OUT(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x00)
  25. #define GPIO_IO_CONF(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x04)
  26. #define GPIO_BLINK_EN(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x08)
  27. #define GPIO_IN_POL(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x0c)
  28. #define GPIO_DATA_IN(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x10)
  29. #define GPIO_EDGE_CAUSE(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x14)
  30. #define GPIO_EDGE_MASK(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x18)
  31. #define GPIO_LEVEL_MASK(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x1c)
  32. /*
  33. * Kirkwood-specific GPIO API
  34. */
  35. int kw_gpio_is_valid(unsigned pin, int mode);
  36. int kw_gpio_direction_input(unsigned pin);
  37. int kw_gpio_direction_output(unsigned pin, int value);
  38. int kw_gpio_get_value(unsigned pin);
  39. void kw_gpio_set_value(unsigned pin, int value);
  40. void kw_gpio_set_blink(unsigned pin, int blink);
  41. void kw_gpio_set_unused(unsigned pin);
  42. #define GPIO_INPUT_OK (1 << 0)
  43. #define GPIO_OUTPUT_OK (1 << 1)
  44. #endif