mtk-eint.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. };
  61. #if IS_ENABLED(CONFIG_EINT_MTK)
  62. int mtk_eint_do_init(struct mtk_eint *eint);
  63. int mtk_eint_do_suspend(struct mtk_eint *eint);
  64. int mtk_eint_do_resume(struct mtk_eint *eint);
  65. int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_n,
  66. unsigned int debounce);
  67. int mtk_eint_find_irq(struct mtk_eint *eint, unsigned long eint_n);
  68. #else
  69. static inline int mtk_eint_do_init(struct mtk_eint *eint)
  70. {
  71. return -EOPNOTSUPP;
  72. }
  73. static inline int mtk_eint_do_suspend(struct mtk_eint *eint)
  74. {
  75. return -EOPNOTSUPP;
  76. }
  77. static inline int mtk_eint_do_resume(struct mtk_eint *eint)
  78. {
  79. return -EOPNOTSUPP;
  80. }
  81. int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_n,
  82. unsigned int debounce)
  83. {
  84. return -EOPNOTSUPP;
  85. }
  86. int mtk_eint_find_irq(struct mtk_eint *eint, unsigned long eint_n)
  87. {
  88. return -EOPNOTSUPP;
  89. }
  90. #endif
  91. #endif /* __MTK_EINT_H */