gpio.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Generic GPIO API and pinmux table support
  3. *
  4. * Copyright (c) 2008 Magnus Damm
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #ifndef __ASM_ARCH_GPIO_H
  11. #define __ASM_ARCH_GPIO_H
  12. #include <linux/kernel.h>
  13. #include <linux/errno.h>
  14. #include <linux/sh_pfc.h>
  15. #include <linux/io.h>
  16. #ifdef CONFIG_GPIOLIB
  17. static inline int irq_to_gpio(unsigned int irq)
  18. {
  19. return -ENOSYS;
  20. }
  21. #else
  22. #define __ARM_GPIOLIB_COMPLEX
  23. #endif /* CONFIG_GPIOLIB */
  24. /*
  25. * FIXME !!
  26. *
  27. * current gpio frame work doesn't have
  28. * the method to control only pull up/down/free.
  29. * this function should be replaced by correct gpio function
  30. */
  31. static inline void __init gpio_direction_none(u32 addr)
  32. {
  33. __raw_writeb(0x00, addr);
  34. }
  35. static inline void __init gpio_request_pullup(u32 addr)
  36. {
  37. u8 data = __raw_readb(addr);
  38. data &= 0x0F;
  39. data |= 0xC0;
  40. __raw_writeb(data, addr);
  41. }
  42. static inline void __init gpio_request_pulldown(u32 addr)
  43. {
  44. u8 data = __raw_readb(addr);
  45. data &= 0x0F;
  46. data |= 0xA0;
  47. __raw_writeb(data, addr);
  48. }
  49. #endif /* __ASM_ARCH_GPIO_H */