Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / pinctrl / mediatek / mtk-eint.h
blob48468d0fae686dff21cc8a8b2f0e8e55aabee352
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (C) 2014-2018 MediaTek Inc.
5 * Author: Maoguang Meng <maoguang.meng@mediatek.com>
6 * Sean Wang <sean.wang@mediatek.com>
8 */
9 #ifndef __MTK_EINT_H
10 #define __MTK_EINT_H
12 #include <linux/irqdomain.h>
14 struct mtk_eint_regs {
15 unsigned int stat;
16 unsigned int ack;
17 unsigned int mask;
18 unsigned int mask_set;
19 unsigned int mask_clr;
20 unsigned int sens;
21 unsigned int sens_set;
22 unsigned int sens_clr;
23 unsigned int soft;
24 unsigned int soft_set;
25 unsigned int soft_clr;
26 unsigned int pol;
27 unsigned int pol_set;
28 unsigned int pol_clr;
29 unsigned int dom_en;
30 unsigned int dbnc_ctrl;
31 unsigned int dbnc_set;
32 unsigned int dbnc_clr;
35 struct mtk_eint_hw {
36 u8 port_mask;
37 u8 ports;
38 unsigned int ap_num;
39 unsigned int db_cnt;
42 struct mtk_eint;
44 struct mtk_eint_xt {
45 int (*get_gpio_n)(void *data, unsigned long eint_n,
46 unsigned int *gpio_n,
47 struct gpio_chip **gpio_chip);
48 int (*get_gpio_state)(void *data, unsigned long eint_n);
49 int (*set_gpio_as_eint)(void *data, unsigned long eint_n);
52 struct mtk_eint {
53 struct device *dev;
54 void __iomem *base;
55 struct irq_domain *domain;
56 int irq;
58 int *dual_edge;
59 u32 *wake_mask;
60 u32 *cur_mask;
62 /* Used to fit into various EINT device */
63 const struct mtk_eint_hw *hw;
64 const struct mtk_eint_regs *regs;
66 /* Used to fit into various pinctrl device */
67 void *pctl;
68 const struct mtk_eint_xt *gpio_xlate;
71 #if IS_ENABLED(CONFIG_EINT_MTK)
72 int mtk_eint_do_init(struct mtk_eint *eint);
73 int mtk_eint_do_suspend(struct mtk_eint *eint);
74 int mtk_eint_do_resume(struct mtk_eint *eint);
75 int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_n,
76 unsigned int debounce);
77 int mtk_eint_find_irq(struct mtk_eint *eint, unsigned long eint_n);
79 #else
80 static inline int mtk_eint_do_init(struct mtk_eint *eint)
82 return -EOPNOTSUPP;
85 static inline int mtk_eint_do_suspend(struct mtk_eint *eint)
87 return -EOPNOTSUPP;
90 static inline int mtk_eint_do_resume(struct mtk_eint *eint)
92 return -EOPNOTSUPP;
95 static inline int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_n,
96 unsigned int debounce)
98 return -EOPNOTSUPP;
101 static inline int mtk_eint_find_irq(struct mtk_eint *eint, unsigned long eint_n)
103 return -EOPNOTSUPP;
105 #endif
106 #endif /* __MTK_EINT_H */