gpio.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef _ASM_SH_HD64465_GPIO_
  2. #define _ASM_SH_HD64465_GPIO_ 1
  3. /*
  4. * $Id: gpio.h,v 1.3 2003/05/04 19:30:14 lethal Exp $
  5. *
  6. * Hitachi HD64465 companion chip: General Purpose IO pins support.
  7. * This layer enables other device drivers to configure GPIO
  8. * pins, get and set their values, and register an interrupt
  9. * routine for when input pins change in hardware.
  10. *
  11. * by Greg Banks <gbanks@pocketpenguins.com>
  12. * (c) 2000 PocketPenguins Inc.
  13. */
  14. #include <asm/hd64465.h>
  15. /* Macro to construct a portpin number (used in all
  16. * subsequent functions) from a port letter and a pin
  17. * number, e.g. HD64465_GPIO_PORTPIN('A', 5).
  18. */
  19. #define HD64465_GPIO_PORTPIN(port,pin) (((port)-'A')<<3|(pin))
  20. /* Pin configuration constants for _configure() */
  21. #define HD64465_GPIO_FUNCTION2 0 /* use the pin's *other* function */
  22. #define HD64465_GPIO_OUT 1 /* output */
  23. #define HD64465_GPIO_IN_PULLUP 2 /* input, pull-up MOS on */
  24. #define HD64465_GPIO_IN 3 /* input */
  25. /* Configure a pin's direction */
  26. extern void hd64465_gpio_configure(int portpin, int direction);
  27. /* Get, set value */
  28. extern void hd64465_gpio_set_pin(int portpin, unsigned int value);
  29. extern unsigned int hd64465_gpio_get_pin(int portpin);
  30. extern void hd64465_gpio_set_port(int port, unsigned int value);
  31. extern unsigned int hd64465_gpio_get_port(int port);
  32. /* mode constants for _register_irq() */
  33. #define HD64465_GPIO_FALLING 0
  34. #define HD64465_GPIO_RISING 1
  35. /* Interrupt on external value change */
  36. extern void hd64465_gpio_register_irq(int portpin, int mode,
  37. void (*handler)(int portpin, void *dev), void *dev);
  38. extern void hd64465_gpio_unregister_irq(int portpin);
  39. #endif /* _ASM_SH_HD64465_GPIO_ */