linux/drivers/pinctrl/mediatek/mtk-eint.h
<<
>>
Prefs
   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
  12#include <linux/irqdomain.h>
  13
  14struct 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;
  33};
  34
  35struct mtk_eint_hw {
  36        u8              port_mask;
  37        u8              ports;
  38        unsigned int    ap_num;
  39        unsigned int    db_cnt;
  40};
  41
  42struct mtk_eint;
  43
  44struct 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);
  50};
  51
  52struct mtk_eint {
  53        struct device *dev;
  54        void __iomem *base;
  55        struct irq_domain *domain;
  56        int irq;
  57
  58        int *dual_edge;
  59        u32 *wake_mask;
  60        u32 *cur_mask;
  61
  62        /* Used to fit into various EINT device */
  63        const struct mtk_eint_hw *hw;
  64        const struct mtk_eint_regs *regs;
  65
  66        /* Used to fit into various pinctrl device */
  67        void *pctl;
  68        const struct mtk_eint_xt *gpio_xlate;
  69};
  70
  71#if IS_ENABLED(CONFIG_EINT_MTK)
  72int mtk_eint_do_init(struct mtk_eint *eint);
  73int mtk_eint_do_suspend(struct mtk_eint *eint);
  74int mtk_eint_do_resume(struct mtk_eint *eint);
  75int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_n,
  76                          unsigned int debounce);
  77int mtk_eint_find_irq(struct mtk_eint *eint, unsigned long eint_n);
  78
  79#else
  80static inline int mtk_eint_do_init(struct mtk_eint *eint)
  81{
  82        return -EOPNOTSUPP;
  83}
  84
  85static inline int mtk_eint_do_suspend(struct mtk_eint *eint)
  86{
  87        return -EOPNOTSUPP;
  88}
  89
  90static inline int mtk_eint_do_resume(struct mtk_eint *eint)
  91{
  92        return -EOPNOTSUPP;
  93}
  94
  95static inline int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_n,
  96                          unsigned int debounce)
  97{
  98        return -EOPNOTSUPP;
  99}
 100
 101static inline int mtk_eint_find_irq(struct mtk_eint *eint, unsigned long eint_n)
 102{
 103        return -EOPNOTSUPP;
 104}
 105#endif
 106#endif /* __MTK_EINT_H */
 107