gpio.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * include/asm-arm/arch-ixp2000/gpio.h
  3. *
  4. * Copyright (C) 2002 Intel Corporation.
  5. *
  6. * This program is free software, you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. /*
  11. * IXP2000 GPIO in/out, edge/level detection for IRQs:
  12. * IRQs are generated on Falling-edge, Rising-Edge, Level-low, Level-High
  13. * or both Falling-edge and Rising-edge.
  14. * This must be called *before* the corresponding IRQ is registerd.
  15. * Use this instead of directly setting the GPIO registers.
  16. * GPIOs may also be used as GPIOs (e.g. for emulating i2c/smb)
  17. */
  18. #ifndef __ASM_ARCH_GPIO_H
  19. #define __ASM_ARCH_GPIO_H
  20. #ifndef __ASSEMBLY__
  21. #define GPIO_IN 0
  22. #define GPIO_OUT 1
  23. #define IXP2000_GPIO_LOW 0
  24. #define IXP2000_GPIO_HIGH 1
  25. extern void gpio_line_config(int line, int direction);
  26. static inline int gpio_line_get(int line)
  27. {
  28. return (((*IXP2000_GPIO_PLR) >> line) & 1);
  29. }
  30. static inline void gpio_line_set(int line, int value)
  31. {
  32. if (value == IXP2000_GPIO_HIGH) {
  33. ixp2000_reg_write(IXP2000_GPIO_POSR, 1 << line);
  34. } else if (value == IXP2000_GPIO_LOW) {
  35. ixp2000_reg_write(IXP2000_GPIO_POCR, 1 << line);
  36. }
  37. }
  38. #endif /* !__ASSEMBLY__ */
  39. #endif /* ASM_ARCH_IXP2000_GPIO_H_ */