mtk-eint.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2014-2018 MediaTek Inc.
  4. *
  5. * Author: Maoguang Meng <maoguang.meng@mediatek.com>
  6. * Sean Wang <sean.wang@mediatek.com>
  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. };
  38. struct mtk_eint;
  39. struct mtk_eint_xt {
  40. int (*get_gpio_n)(void *data, unsigned long eint_n,
  41. unsigned int *gpio_n,
  42. struct gpio_chip **gpio_chip);
  43. int (*get_gpio_state)(void *data, unsigned long eint_n);
  44. int (*set_gpio_as_eint)(void *data, unsigned long eint_n);
  45. };
  46. struct mtk_eint {
  47. struct device *dev;
  48. void __iomem *base;
  49. struct irq_domain *domain;
  50. int irq;
  51. int *dual_edge;
  52. u32 *wake_mask;
  53. u32 *cur_mask;
  54. /* Used to fit into various EINT device */
  55. const struct mtk_eint_hw *hw;
  56. const struct mtk_eint_regs *regs;
  57. /* Used to fit into various pinctrl device */
  58. void *pctl;
  59. const struct mtk_eint_xt *gpio_xlate;
  60. /* Used to support SW debounce */
  61. struct timer_list *eint_timers;
  62. int *eint_sw_debounce_en;
  63. u32 *eint_sw_debounce;
  64. };
  65. #if IS_ENABLED(CONFIG_EINT_MTK)
  66. int mtk_eint_do_init(struct mtk_eint *eint);
  67. int mtk_eint_do_suspend(struct mtk_eint *eint);
  68. int mtk_eint_do_resume(struct mtk_eint *eint);
  69. int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_n,
  70. unsigned int debounce);
  71. int mtk_eint_find_irq(struct mtk_eint *eint, unsigned long eint_n);
  72. #else
  73. static inline int mtk_eint_do_init(struct mtk_eint *eint)
  74. {
  75. return -EOPNOTSUPP;
  76. }
  77. static inline int mtk_eint_do_suspend(struct mtk_eint *eint)
  78. {
  79. return -EOPNOTSUPP;
  80. }
  81. static inline int mtk_eint_do_resume(struct mtk_eint *eint)
  82. {
  83. return -EOPNOTSUPP;
  84. }
  85. static inline int mtk_eint_set_debounce(struct mtk_eint *eint,
  86. unsigned long eint_n, unsigned int debounce)
  87. {
  88. return -EOPNOTSUPP;
  89. }
  90. static inline int mtk_eint_find_irq(struct mtk_eint *eint,
  91. unsigned long eint_n)
  92. {
  93. return -EOPNOTSUPP;
  94. }
  95. #endif
  96. #endif /* __MTK_EINT_H */