1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2018 MediaTek Inc.
5 * Author: Sean Wang <sean.wang@mediatek.com>
9 #ifndef __PINCTRL_MTK_COMMON_V2_H
10 #define __PINCTRL_MTK_COMMON_V2_H
12 #define MTK_GPIO_MODE 1
18 /* List these attributes which could be modified for the pin */
30 PINCTRL_PIN_REG_TDSEL,
31 PINCTRL_PIN_REG_RDSEL,
35 /* struct mtk_pin_field - the structure that holds the information of the field
36 * used to describe the attribute for the pin
37 * @offset: the register offset relative to the base address
38 * @mask: the mask used to filter out the field from the register
39 * @bitpos: the start bit relative to the register
40 * @next: the indication that the field would be extended to the
43 struct mtk_pin_field {
50 /* struct mtk_pin_field_calc - the structure that holds the range providing
51 * the guide used to look up the relevant field
52 * @s_pin: the start pin within the range
53 * @e_pin: the end pin within the range
54 * @s_addr: the start address for the range
55 * @x_addrs: the address distance between two consecutive registers
57 * @s_bit: the start bit for the first register within the range
58 * @x_bits: the bit distance between two consecutive pins within
61 struct mtk_pin_field_calc {
70 /* struct mtk_pin_reg_calc - the structure that holds all ranges used to
71 * determine which register the pin would make use of
72 * for certain pin attribute.
73 * @range: the start address for the range
74 * @nranges: the number of items in the range
76 struct mtk_pin_reg_calc {
77 const struct mtk_pin_field_calc *range;
81 /* struct mtk_pin_soc - the structure that holds SoC-specific data */
83 const struct mtk_pin_reg_calc *reg_cal;
84 const struct pinctrl_pin_desc *pins;
86 const struct group_desc *grps;
88 const struct function_desc *funcs;
90 const struct mtk_eint_regs *eint_regs;
91 const struct mtk_eint_hw *eint_hw;
95 struct pinctrl_dev *pctrl;
98 struct gpio_chip chip;
99 const struct mtk_pin_soc *soc;
100 struct mtk_eint *eint;
103 void mtk_rmw(struct mtk_pinctrl *pctl, u32 reg, u32 mask, u32 set);
105 int mtk_hw_set_value(struct mtk_pinctrl *hw, int pin, int field, int value);
106 int mtk_hw_get_value(struct mtk_pinctrl *hw, int pin, int field, int *value);
108 #endif /* __PINCTRL_MTK_COMMON_V2_H */