gpio-davinci.h 1.5 KB

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