mt-eic.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #ifndef __EINT_H
  2. #define __EINT_H
  3. /*
  4. * Hardware registers and settings.
  5. */
  6. #define EINT_STA_BASE (((unsigned long)EINT_BASE + 0x000))
  7. #define EINT_INTACK_BASE (((unsigned long)EINT_BASE + 0x040))
  8. #define EINT_MASK_BASE (((unsigned long)EINT_BASE + 0x080))
  9. #define EINT_MASK_SET_BASE (((unsigned long)EINT_BASE + 0x0c0))
  10. #define EINT_MASK_CLR_BASE (((unsigned long)EINT_BASE + 0x100))
  11. #define EINT_SENS_BASE (((unsigned long)EINT_BASE + 0x140))
  12. #define EINT_SENS_SET_BASE (((unsigned long)EINT_BASE + 0x180))
  13. #define EINT_SENS_CLR_BASE (((unsigned long)EINT_BASE + 0x1c0))
  14. #define EINT_SOFT_BASE (((unsigned long)EINT_BASE + 0x200))
  15. #define EINT_SOFT_SET_BASE (((unsigned long)EINT_BASE + 0x240))
  16. #define EINT_SOFT_CLR_BASE (((unsigned long)EINT_BASE + 0x280))
  17. #define EINT_POL_BASE (((unsigned long)EINT_BASE + 0x300))
  18. #define EINT_POL_SET_BASE (((unsigned long)EINT_BASE + 0x340))
  19. #define EINT_POL_CLR_BASE (((unsigned long)EINT_BASE + 0x380))
  20. #define EINT_D0_EN_BASE (((unsigned long)EINT_BASE + 0x400))
  21. #define EINT_D1_EN_BASE (((unsigned long)EINT_BASE + 0x420))
  22. #define EINT_D2_EN_BASE (((unsigned long)EINT_BASE + 0x440))
  23. #define EINT_DBNC_BASE (((unsigned long)EINT_BASE + 0x500))
  24. #define EINT_DBNC_SET_BASE (((unsigned long)EINT_BASE + 0x600))
  25. #define EINT_DBNC_CLR_BASE (((unsigned long)EINT_BASE + 0x700))
  26. #define DEINT_CON_BASE (((unsigned long)EINT_BASE + 0x800))
  27. #define DEINT_SEL_BASE (((unsigned long)EINT_BASE + 0x840))
  28. #define DEINT_SEL_SET_BASE (((unsigned long)EINT_BASE + 0x880))
  29. #define DEINT_SEL_CLR_BASE (((unsigned long)EINT_BASE + 0x8c0))
  30. #define EINT_EEVT_BASE (((unsigned long)EINT_BASE + 0x900))
  31. #define EINT_RAW_STA_BASE (((unsigned long)EINT_BASE + 0xA00))
  32. #define EINT_EMUL_BASE (((unsigned long)EINT_BASE + 0xF00))
  33. #define EINT_DBNC_SET_DBNC_BITS (4)
  34. #define EINT_DBNC_CLR_DBNC_BITS (4)
  35. #define EINT_DBNC_SET_EN_BITS (0)
  36. #define EINT_DBNC_CLR_EN_BITS (0)
  37. #define EINT_DBNC_SET_RST_BITS (1)
  38. #define EINT_DBNC_EN_BIT (0x1)
  39. #define EINT_DBNC_RST_BIT (0x1)
  40. #define EINT_DBNC_0_MS (0x7)
  41. #define EINT_DBNC (0x7)
  42. #define EINT_DBNC_SET_EN (0x1)
  43. #define EINT_DBNC_CLR_EN (0x1)
  44. #define EINT_STA_DEFAULT 0x00000000
  45. #define EINT_INTACK_DEFAULT 0x00000000
  46. #define EINT_EEVT_DEFAULT 0x00000001
  47. #define EINT_MASK_DEFAULT 0x00000000
  48. #define EINT_MASK_SET_DEFAULT 0x00000000
  49. #define EINT_MASK_CLR_DEFAULT 0x00000000
  50. #define EINT_SENS_DEFAULT 0x0000FFFF
  51. #define EINT_SENS_SET_DEFAULT 0x00000000
  52. #define EINT_SENS_CLR_DEFAULT 0x00000000
  53. #define EINT_D0EN_DEFAULT 0x00000000
  54. #define EINT_D1EN_DEFAULT 0x00000000
  55. #define EINT_D2EN_DEFAULT 0x00000000
  56. #define EINT_DBNC_DEFAULT(n) 0x00000000
  57. #define DEINT_MASK_DEFAULT 0x00000000
  58. #define DEINT_MASK_SET_DEFAULT 0x00000000
  59. #define DEINT_MASK_CLR_DEFAULT 0x00000000
  60. /*
  61. * Define constants.
  62. */
  63. #define MT_EINT_POL_NEG 0
  64. #define MT_EINT_POL_POS 1
  65. #define MAX_HW_DEBOUNCE_CNT 32
  66. #define EINTF_TRIGGER_RISING 0x00000001
  67. #define EINTF_TRIGGER_FALLING 0x00000002
  68. #define EINTF_TRIGGER_HIGH 0x00000004
  69. #define EINTF_TRIGGER_LOW 0x00000008
  70. #define EINT_IRQ(eint) (eint+EINT_IRQ_BASE)
  71. #define DEMUX_EINT_IRQ(irq) (irq-EINT_IRQ_BASE)
  72. #define EINT_GPIO(eint) eint
  73. #define GPIOPIN 0
  74. #define DEBOUNCE 1
  75. #define EINT_DELAY_WARNING 3000000
  76. #define MT_EDGE_SENSITIVE 0
  77. #define MT_LEVEL_SENSITIVE 1
  78. #define MT_POLARITY_LOW 0
  79. #define MT_POLARITY_HIGH 1
  80. /*
  81. * Define function prototypes.
  82. */
  83. extern void _print_status(void);
  84. extern int mt_gpio_set_debounce(unsigned gpio, unsigned debounce);
  85. extern unsigned int mt_gpio_to_irq(unsigned gpio);
  86. extern int mt_get_supported_irq_num_ex(void) __attribute__((weak));
  87. void mt_eint_mask(unsigned int eint_num);
  88. void mt_eint_unmask(unsigned int eint_num);
  89. void mt_eint_set_hw_debounce(unsigned int eint_num, unsigned int ms);
  90. void mt_eint_set_polarity(unsigned int eint_num, unsigned int pol);
  91. unsigned int mt_eint_set_sens(unsigned int eint_num, unsigned int sens);
  92. void mt_eint_virq_soft_clr(unsigned int virq);
  93. /* used to access the gic device tree resource */
  94. extern int mt_get_supported_irq_num(void);
  95. /*
  96. * Define structure prototypes
  97. */
  98. struct EINT_HEADER {
  99. unsigned int is_autounmask;
  100. };
  101. struct pin_node {
  102. struct rb_node node;
  103. u32 gpio_pin;
  104. u32 eint_pin;
  105. };
  106. #endif