blob: 5abde00962658794c893031542b0ba58a507e0ac [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2018 MediaTek Inc.
4 *
5 * Author: Sean Wang <sean.wang@mediatek.com>
6 * Zhiyong Tao <zhiyong.tao@mediatek.com>
7 * Hongzhou.Yang <hongzhou.yang@mediatek.com>
8 */
9#ifndef __PINCTRL_PARIS_H
10#define __PINCTRL_PARIS_H
11
12#include <linux/io.h>
13#include <linux/init.h>
14#include <linux/of.h>
15#include <linux/of_platform.h>
16#include <linux/platform_device.h>
17#include <linux/pinctrl/pinctrl.h>
18#include <linux/pinctrl/pinmux.h>
19#include <linux/pinctrl/pinconf.h>
20#include <linux/pinctrl/pinconf-generic.h>
21
22#include "../core.h"
23#include "../pinconf.h"
24#include "../pinctrl-utils.h"
25#include "../pinmux.h"
26#include "mtk-eint.h"
27#include "pinctrl-mtk-common-v2.h"
28
29#define MTK_RANGE(_a) { .range = (_a), .nranges = ARRAY_SIZE(_a), }
30
31#define MTK_EINT_FUNCTION(_eintmux, _eintnum) \
32 { \
33 .eint_m = _eintmux, \
34 .eint_n = _eintnum, \
35 }
36
37#define MTK_FUNCTION(_val, _name) \
38 { \
39 .muxval = _val, \
40 .name = _name, \
41 }
42
43#define MTK_PIN(_number, _name, _eint, _drv_n, ...) { \
44 .number = _number, \
45 .name = _name, \
46 .eint = _eint, \
47 .drv_n = _drv_n, \
48 .funcs = (struct mtk_func_desc[]){ \
49 __VA_ARGS__, { } }, \
50 }
51
52#define PINCTRL_PIN_GROUP(name, id) \
53 { \
54 name, \
55 id##_pins, \
56 ARRAY_SIZE(id##_pins), \
57 id##_funcs, \
58 }
59
60int mtk_paris_pinctrl_probe(struct platform_device *pdev,
61 const struct mtk_pin_soc *soc);
62
63int mtk_hw_get_value_wrap(struct mtk_pinctrl *hw, unsigned int gpio, int field);
64
65#define mtk_pctrl_get_pinmux(hw, gpio) \
66 mtk_hw_get_value_wrap(hw, gpio, PINCTRL_PIN_REG_MODE)
67
68/* MTK HW use 0 as input, 1 for output
69 * This interface is for get direct register value,
70 * so don't reverse
71 */
72#define mtk_pctrl_get_direction(hw, gpio) \
73 mtk_hw_get_value_wrap(hw, gpio, PINCTRL_PIN_REG_DIR)
74
75#define mtk_pctrl_get_out(hw, gpio) \
76 mtk_hw_get_value_wrap(hw, gpio, PINCTRL_PIN_REG_DO)
77
78#define mtk_pctrl_get_in(hw, gpio) \
79 mtk_hw_get_value_wrap(hw, gpio, PINCTRL_PIN_REG_DI)
80
81#define mtk_pctrl_get_smt(hw, gpio) \
82 mtk_hw_get_value_wrap(hw, gpio, PINCTRL_PIN_REG_SMT)
83
84#define mtk_pctrl_get_ies(hw, gpio) \
85 mtk_hw_get_value_wrap(hw, gpio, PINCTRL_PIN_REG_IES)
86
87#define mtk_pctrl_get_driving(hw, gpio) \
88 mtk_hw_get_value_wrap(hw, gpio, PINCTRL_PIN_REG_DRV)
89
90ssize_t mtk_pctrl_show_one_pin(struct mtk_pinctrl *hw,
91 unsigned int gpio, char *buf, unsigned int bufLen);
92
93#endif /* __PINCTRL_PARIS_H */