gpio.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * arch/arm/plat-iop/gpio.c
  3. * GPIO handling for Intel IOP3xx processors.
  4. *
  5. * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or (at
  10. * your option) any later version.
  11. */
  12. #include <linux/device.h>
  13. #include <asm/hardware/iop3xx.h>
  14. void gpio_line_config(int line, int direction)
  15. {
  16. unsigned long flags;
  17. local_irq_save(flags);
  18. if (direction == GPIO_IN) {
  19. *IOP3XX_GPOE |= 1 << line;
  20. } else if (direction == GPIO_OUT) {
  21. *IOP3XX_GPOE &= ~(1 << line);
  22. }
  23. local_irq_restore(flags);
  24. }
  25. EXPORT_SYMBOL(gpio_line_config);
  26. int gpio_line_get(int line)
  27. {
  28. return !!(*IOP3XX_GPID & (1 << line));
  29. }
  30. EXPORT_SYMBOL(gpio_line_get);
  31. void gpio_line_set(int line, int value)
  32. {
  33. unsigned long flags;
  34. local_irq_save(flags);
  35. if (value == GPIO_LOW) {
  36. *IOP3XX_GPOD &= ~(1 << line);
  37. } else if (value == GPIO_HIGH) {
  38. *IOP3XX_GPOD |= 1 << line;
  39. }
  40. local_irq_restore(flags);
  41. }
  42. EXPORT_SYMBOL(gpio_line_set);