gpio-davinci.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * DaVinci GPIO Platform Related Defines
  3. *
  4. * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation version 2.
  9. *
  10. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  11. * kind, whether express or implied; without even the implied warranty
  12. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #ifndef __DAVINCI_GPIO_PLATFORM_H
  16. #define __DAVINCI_GPIO_PLATFORM_H
  17. #include <linux/io.h>
  18. #include <linux/spinlock.h>
  19. #include <asm-generic/gpio.h>
  20. struct davinci_gpio_platform_data {
  21. u32 ngpio;
  22. u32 gpio_unbanked;
  23. };
  24. struct davinci_gpio_controller {
  25. struct gpio_chip chip;
  26. struct irq_domain *irq_domain;
  27. /* Serialize access to GPIO registers */
  28. spinlock_t lock;
  29. void __iomem *regs;
  30. void __iomem *set_data;
  31. void __iomem *clr_data;
  32. void __iomem *in_data;
  33. int gpio_unbanked;
  34. unsigned gpio_irq;
  35. };
  36. /*
  37. * basic gpio routines
  38. */
  39. #define GPIO(X) (X) /* 0 <= X <= (DAVINCI_N_GPIO - 1) */
  40. /* Convert GPIO signal to GPIO pin number */
  41. #define GPIO_TO_PIN(bank, gpio) (16 * (bank) + (gpio))
  42. static inline u32 __gpio_mask(unsigned gpio)
  43. {
  44. return 1 << (gpio % 32);
  45. }
  46. #endif