18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2014-2018 MediaTek Inc. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Author: Maoguang Meng <maoguang.meng@mediatek.com> 68c2ecf20Sopenharmony_ci * Sean Wang <sean.wang@mediatek.com> 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci#ifndef __MTK_EINT_H 108c2ecf20Sopenharmony_ci#define __MTK_EINT_H 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/irqdomain.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_cistruct mtk_eint_regs { 158c2ecf20Sopenharmony_ci unsigned int stat; 168c2ecf20Sopenharmony_ci unsigned int ack; 178c2ecf20Sopenharmony_ci unsigned int mask; 188c2ecf20Sopenharmony_ci unsigned int mask_set; 198c2ecf20Sopenharmony_ci unsigned int mask_clr; 208c2ecf20Sopenharmony_ci unsigned int sens; 218c2ecf20Sopenharmony_ci unsigned int sens_set; 228c2ecf20Sopenharmony_ci unsigned int sens_clr; 238c2ecf20Sopenharmony_ci unsigned int soft; 248c2ecf20Sopenharmony_ci unsigned int soft_set; 258c2ecf20Sopenharmony_ci unsigned int soft_clr; 268c2ecf20Sopenharmony_ci unsigned int pol; 278c2ecf20Sopenharmony_ci unsigned int pol_set; 288c2ecf20Sopenharmony_ci unsigned int pol_clr; 298c2ecf20Sopenharmony_ci unsigned int dom_en; 308c2ecf20Sopenharmony_ci unsigned int dbnc_ctrl; 318c2ecf20Sopenharmony_ci unsigned int dbnc_set; 328c2ecf20Sopenharmony_ci unsigned int dbnc_clr; 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistruct mtk_eint_hw { 368c2ecf20Sopenharmony_ci u8 port_mask; 378c2ecf20Sopenharmony_ci u8 ports; 388c2ecf20Sopenharmony_ci unsigned int ap_num; 398c2ecf20Sopenharmony_ci unsigned int db_cnt; 408c2ecf20Sopenharmony_ci}; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cistruct mtk_eint; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_cistruct mtk_eint_xt { 458c2ecf20Sopenharmony_ci int (*get_gpio_n)(void *data, unsigned long eint_n, 468c2ecf20Sopenharmony_ci unsigned int *gpio_n, 478c2ecf20Sopenharmony_ci struct gpio_chip **gpio_chip); 488c2ecf20Sopenharmony_ci int (*get_gpio_state)(void *data, unsigned long eint_n); 498c2ecf20Sopenharmony_ci int (*set_gpio_as_eint)(void *data, unsigned long eint_n); 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistruct mtk_eint { 538c2ecf20Sopenharmony_ci struct device *dev; 548c2ecf20Sopenharmony_ci void __iomem *base; 558c2ecf20Sopenharmony_ci struct irq_domain *domain; 568c2ecf20Sopenharmony_ci int irq; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci int *dual_edge; 598c2ecf20Sopenharmony_ci u32 *wake_mask; 608c2ecf20Sopenharmony_ci u32 *cur_mask; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci /* Used to fit into various EINT device */ 638c2ecf20Sopenharmony_ci const struct mtk_eint_hw *hw; 648c2ecf20Sopenharmony_ci const struct mtk_eint_regs *regs; 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci /* Used to fit into various pinctrl device */ 678c2ecf20Sopenharmony_ci void *pctl; 688c2ecf20Sopenharmony_ci const struct mtk_eint_xt *gpio_xlate; 698c2ecf20Sopenharmony_ci}; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_EINT_MTK) 728c2ecf20Sopenharmony_ciint mtk_eint_do_init(struct mtk_eint *eint); 738c2ecf20Sopenharmony_ciint mtk_eint_do_suspend(struct mtk_eint *eint); 748c2ecf20Sopenharmony_ciint mtk_eint_do_resume(struct mtk_eint *eint); 758c2ecf20Sopenharmony_ciint mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_n, 768c2ecf20Sopenharmony_ci unsigned int debounce); 778c2ecf20Sopenharmony_ciint mtk_eint_find_irq(struct mtk_eint *eint, unsigned long eint_n); 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci#else 808c2ecf20Sopenharmony_cistatic inline int mtk_eint_do_init(struct mtk_eint *eint) 818c2ecf20Sopenharmony_ci{ 828c2ecf20Sopenharmony_ci return -EOPNOTSUPP; 838c2ecf20Sopenharmony_ci} 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_cistatic inline int mtk_eint_do_suspend(struct mtk_eint *eint) 868c2ecf20Sopenharmony_ci{ 878c2ecf20Sopenharmony_ci return -EOPNOTSUPP; 888c2ecf20Sopenharmony_ci} 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_cistatic inline int mtk_eint_do_resume(struct mtk_eint *eint) 918c2ecf20Sopenharmony_ci{ 928c2ecf20Sopenharmony_ci return -EOPNOTSUPP; 938c2ecf20Sopenharmony_ci} 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_cistatic inline int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_n, 968c2ecf20Sopenharmony_ci unsigned int debounce) 978c2ecf20Sopenharmony_ci{ 988c2ecf20Sopenharmony_ci return -EOPNOTSUPP; 998c2ecf20Sopenharmony_ci} 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_cistatic inline int mtk_eint_find_irq(struct mtk_eint *eint, unsigned long eint_n) 1028c2ecf20Sopenharmony_ci{ 1038c2ecf20Sopenharmony_ci return -EOPNOTSUPP; 1048c2ecf20Sopenharmony_ci} 1058c2ecf20Sopenharmony_ci#endif 1068c2ecf20Sopenharmony_ci#endif /* __MTK_EINT_H */ 107