Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (C) 2014-2018 MediaTek Inc.
0004  *
0005  * Author: Maoguang Meng <maoguang.meng@mediatek.com>
0006  *     Sean Wang <sean.wang@mediatek.com>
0007  *
0008  */
0009 #ifndef __MTK_EINT_H
0010 #define __MTK_EINT_H
0011 
0012 #include <linux/irqdomain.h>
0013 
0014 struct mtk_eint_regs {
0015     unsigned int    stat;
0016     unsigned int    ack;
0017     unsigned int    mask;
0018     unsigned int    mask_set;
0019     unsigned int    mask_clr;
0020     unsigned int    sens;
0021     unsigned int    sens_set;
0022     unsigned int    sens_clr;
0023     unsigned int    soft;
0024     unsigned int    soft_set;
0025     unsigned int    soft_clr;
0026     unsigned int    pol;
0027     unsigned int    pol_set;
0028     unsigned int    pol_clr;
0029     unsigned int    dom_en;
0030     unsigned int    dbnc_ctrl;
0031     unsigned int    dbnc_set;
0032     unsigned int    dbnc_clr;
0033 };
0034 
0035 struct mtk_eint_hw {
0036     u8      port_mask;
0037     u8      ports;
0038     unsigned int    ap_num;
0039     unsigned int    db_cnt;
0040 };
0041 
0042 struct mtk_eint;
0043 
0044 struct mtk_eint_xt {
0045     int (*get_gpio_n)(void *data, unsigned long eint_n,
0046               unsigned int *gpio_n,
0047               struct gpio_chip **gpio_chip);
0048     int (*get_gpio_state)(void *data, unsigned long eint_n);
0049     int (*set_gpio_as_eint)(void *data, unsigned long eint_n);
0050 };
0051 
0052 struct mtk_eint {
0053     struct device *dev;
0054     void __iomem *base;
0055     struct irq_domain *domain;
0056     int irq;
0057 
0058     int *dual_edge;
0059     u32 *wake_mask;
0060     u32 *cur_mask;
0061 
0062     /* Used to fit into various EINT device */
0063     const struct mtk_eint_hw *hw;
0064     const struct mtk_eint_regs *regs;
0065 
0066     /* Used to fit into various pinctrl device */
0067     void *pctl;
0068     const struct mtk_eint_xt *gpio_xlate;
0069 };
0070 
0071 #if IS_ENABLED(CONFIG_EINT_MTK)
0072 int mtk_eint_do_init(struct mtk_eint *eint);
0073 int mtk_eint_do_suspend(struct mtk_eint *eint);
0074 int mtk_eint_do_resume(struct mtk_eint *eint);
0075 int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_n,
0076               unsigned int debounce);
0077 int mtk_eint_find_irq(struct mtk_eint *eint, unsigned long eint_n);
0078 
0079 #else
0080 static inline int mtk_eint_do_init(struct mtk_eint *eint)
0081 {
0082     return -EOPNOTSUPP;
0083 }
0084 
0085 static inline int mtk_eint_do_suspend(struct mtk_eint *eint)
0086 {
0087     return -EOPNOTSUPP;
0088 }
0089 
0090 static inline int mtk_eint_do_resume(struct mtk_eint *eint)
0091 {
0092     return -EOPNOTSUPP;
0093 }
0094 
0095 static inline int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_n,
0096               unsigned int debounce)
0097 {
0098     return -EOPNOTSUPP;
0099 }
0100 
0101 static inline int mtk_eint_find_irq(struct mtk_eint *eint, unsigned long eint_n)
0102 {
0103     return -EOPNOTSUPP;
0104 }
0105 #endif
0106 #endif /* __MTK_EINT_H */