mtk-eint.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2014-2018 MediaTek Inc.
  4. *
  5. * Author: Maoguang Meng <[email protected]>
  6. * Sean Wang <[email protected]>
  7. *
  8. */
  9. #ifndef __MTK_EINT_H
  10. #define __MTK_EINT_H
  11. #include <linux/irqdomain.h>
  12. struct mtk_eint_regs {
  13. unsigned int stat;
  14. unsigned int ack;
  15. unsigned int mask;
  16. unsigned int mask_set;
  17. unsigned int mask_clr;
  18. unsigned int sens;
  19. unsigned int sens_set;
  20. unsigned int sens_clr;
  21. unsigned int soft;
  22. unsigned int soft_set;
  23. unsigned int soft_clr;
  24. unsigned int pol;
  25. unsigned int pol_set;
  26. unsigned int pol_clr;
  27. unsigned int dom_en;
  28. unsigned int dbnc_ctrl;
  29. unsigned int dbnc_set;
  30. unsigned int dbnc_clr;
  31. };
  32. struct mtk_eint_hw {
  33. u8 port_mask;
  34. u8 ports;
  35. unsigned int ap_num;
  36. unsigned int db_cnt;
  37. const unsigned int *db_time;
  38. };
  39. extern const unsigned int debounce_time_mt2701[];
  40. extern const unsigned int debounce_time_mt6765[];
  41. extern const unsigned int debounce_time_mt6795[];
  42. struct mtk_eint;
  43. struct mtk_eint_xt {
  44. int (*get_gpio_n)(void *data, unsigned long eint_n,
  45. unsigned int *gpio_n,
  46. struct gpio_chip **gpio_chip);
  47. int (*get_gpio_state)(void *data, unsigned long eint_n);
  48. int (*set_gpio_as_eint)(void *data, unsigned long eint_n);
  49. };
  50. struct mtk_eint {
  51. struct device *dev;
  52. void __iomem *base;
  53. struct irq_domain *domain;
  54. int irq;
  55. int *dual_edge;
  56. u32 *wake_mask;
  57. u32 *cur_mask;
  58. /* Used to fit into various EINT device */
  59. const struct mtk_eint_hw *hw;
  60. const struct mtk_eint_regs *regs;
  61. u16 num_db_time;
  62. /* Used to fit into various pinctrl device */
  63. void *pctl;
  64. const struct mtk_eint_xt *gpio_xlate;
  65. };
  66. #if IS_ENABLED(CONFIG_EINT_MTK)
  67. int mtk_eint_do_init(struct mtk_eint *eint);
  68. int mtk_eint_do_suspend(struct mtk_eint *eint);
  69. int mtk_eint_do_resume(struct mtk_eint *eint);
  70. int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_n,
  71. unsigned int debounce);
  72. int mtk_eint_find_irq(struct mtk_eint *eint, unsigned long eint_n);
  73. #else
  74. static inline int mtk_eint_do_init(struct mtk_eint *eint)
  75. {
  76. return -EOPNOTSUPP;
  77. }
  78. static inline int mtk_eint_do_suspend(struct mtk_eint *eint)
  79. {
  80. return -EOPNOTSUPP;
  81. }
  82. static inline int mtk_eint_do_resume(struct mtk_eint *eint)
  83. {
  84. return -EOPNOTSUPP;
  85. }
  86. static inline int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_n,
  87. unsigned int debounce)
  88. {
  89. return -EOPNOTSUPP;
  90. }
  91. static inline int mtk_eint_find_irq(struct mtk_eint *eint, unsigned long eint_n)
  92. {
  93. return -EOPNOTSUPP;
  94. }
  95. #endif
  96. #endif /* __MTK_EINT_H */