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