gpio-davinci.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. enum davinci_gpio_type {
  21. GPIO_TYPE_TNETV107X = 0,
  22. };
  23. struct davinci_gpio_platform_data {
  24. u32 ngpio;
  25. u32 gpio_unbanked;
  26. u32 intc_irq_num;
  27. };
  28. struct davinci_gpio_controller {
  29. struct gpio_chip chip;
  30. int irq_base;
  31. /* Serialize access to GPIO registers */
  32. spinlock_t lock;
  33. void __iomem *regs;
  34. void __iomem *set_data;
  35. void __iomem *clr_data;
  36. void __iomem *in_data;
  37. int gpio_unbanked;
  38. unsigned gpio_irq;
  39. };
  40. /*
  41. * basic gpio routines
  42. */
  43. #define GPIO(X) (X) /* 0 <= X <= (DAVINCI_N_GPIO - 1) */
  44. /* Convert GPIO signal to GPIO pin number */
  45. #define GPIO_TO_PIN(bank, gpio) (16 * (bank) + (gpio))
  46. static inline u32 __gpio_mask(unsigned gpio)
  47. {
  48. return 1 << (gpio % 32);
  49. }
  50. #endif