gpio.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * arch/asm-arm/mach-kirkwood/include/mach/gpio.h
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  20. * MA 02110-1301 USA
  21. */
  22. /*
  23. * Based on (mostly copied from) plat-orion based Linux 2.6 kernel driver.
  24. * Removed kernel level irq handling. Took some macros from kernel to
  25. * allow build.
  26. *
  27. * Dieter Kiermaier dk-arm-linux@gmx.de
  28. */
  29. #ifndef __KIRKWOOD_GPIO_H
  30. #define __KIRKWOOD_GPIO_H
  31. /* got from kernel include/linux/bitops.h */
  32. #define BITS_PER_BYTE 8
  33. #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
  34. #define GPIO_MAX 50
  35. #define GPIO_OFF(pin) (((pin) >> 5) ? 0x0040 : 0x0000)
  36. #define GPIO_OUT(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x00)
  37. #define GPIO_IO_CONF(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x04)
  38. #define GPIO_BLINK_EN(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x08)
  39. #define GPIO_IN_POL(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x0c)
  40. #define GPIO_DATA_IN(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x10)
  41. #define GPIO_EDGE_CAUSE(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x14)
  42. #define GPIO_EDGE_MASK(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x18)
  43. #define GPIO_LEVEL_MASK(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x1c)
  44. /*
  45. * Kirkwood-specific GPIO API
  46. */
  47. void kw_gpio_set_valid(unsigned pin, int mode);
  48. int kw_gpio_is_valid(unsigned pin, int mode);
  49. int kw_gpio_direction_input(unsigned pin);
  50. int kw_gpio_direction_output(unsigned pin, int value);
  51. int kw_gpio_get_value(unsigned pin);
  52. void kw_gpio_set_value(unsigned pin, int value);
  53. void kw_gpio_set_blink(unsigned pin, int blink);
  54. void kw_gpio_set_unused(unsigned pin);
  55. #define GPIO_INPUT_OK (1 << 0)
  56. #define GPIO_OUTPUT_OK (1 << 1)
  57. #endif