summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/mediatek
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2018-09-18 17:55:54 -0400
committerLinus Walleij <linus.walleij@linaro.org>2018-09-18 17:55:54 -0400
commit55818b90233bc13cbc46083e5ce0ea7f3c169aeb (patch)
tree6cdc8fde31f25d9bb251bf4c905ba23ce72c9ac6 /drivers/pinctrl/mediatek
parent1c5fb66afa2a1d1860cff46ef426117b11e029aa (diff)
parent6561859b067fcd6c5b89fd625b2c7dc324b706b5 (diff)
Merge branch 'ib-mtk' into devel
Diffstat (limited to 'drivers/pinctrl/mediatek')
-rw-r--r--drivers/pinctrl/mediatek/Kconfig41
-rw-r--r--drivers/pinctrl/mediatek/Makefile4
-rw-r--r--drivers/pinctrl/mediatek/pinctrl-moore.c689
-rw-r--r--drivers/pinctrl/mediatek/pinctrl-moore.h53
-rw-r--r--drivers/pinctrl/mediatek/pinctrl-mt7622.c1406
-rw-r--r--drivers/pinctrl/mediatek/pinctrl-mt7623.c1441
-rw-r--r--drivers/pinctrl/mediatek/pinctrl-mt8183.c544
-rw-r--r--drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c670
-rw-r--r--drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h288
-rw-r--r--drivers/pinctrl/mediatek/pinctrl-mtk-mt8183.h1916
-rw-r--r--drivers/pinctrl/mediatek/pinctrl-paris.c906
-rw-r--r--drivers/pinctrl/mediatek/pinctrl-paris.h65
12 files changed, 6833 insertions, 1190 deletions
diff --git a/drivers/pinctrl/mediatek/Kconfig b/drivers/pinctrl/mediatek/Kconfig
index 9905dc672f6b..1cd55022ab4f 100644
--- a/drivers/pinctrl/mediatek/Kconfig
+++ b/drivers/pinctrl/mediatek/Kconfig
@@ -3,7 +3,7 @@ menu "MediaTek pinctrl drivers"
3 3
4config EINT_MTK 4config EINT_MTK
5 bool "MediaTek External Interrupt Support" 5 bool "MediaTek External Interrupt Support"
6 depends on PINCTRL_MTK || PINCTRL_MT7622 || COMPILE_TEST 6 depends on PINCTRL_MTK || PINCTRL_MTK_MOORE || COMPILE_TEST
7 select IRQ_DOMAIN 7 select IRQ_DOMAIN
8 8
9config PINCTRL_MTK 9config PINCTRL_MTK
@@ -15,6 +15,24 @@ config PINCTRL_MTK
15 select EINT_MTK 15 select EINT_MTK
16 select OF_GPIO 16 select OF_GPIO
17 17
18config PINCTRL_MTK_MOORE
19 bool "MediaTek Moore Core that implements generic binding"
20 depends on OF
21 select GENERIC_PINCONF
22 select GENERIC_PINCTRL_GROUPS
23 select GENERIC_PINMUX_FUNCTIONS
24 select GPIOLIB
25 select OF_GPIO
26
27config PINCTRL_MTK_PARIS
28 bool "MediaTek Paris Core that implements vendor binding"
29 depends on OF
30 select PINMUX
31 select GENERIC_PINCONF
32 select GPIOLIB
33 select EINT_MTK
34 select OF_GPIO
35
18# For ARMv7 SoCs 36# For ARMv7 SoCs
19config PINCTRL_MT2701 37config PINCTRL_MT2701
20 bool "Mediatek MT2701 pin control" 38 bool "Mediatek MT2701 pin control"
@@ -23,6 +41,12 @@ config PINCTRL_MT2701
23 default MACH_MT2701 41 default MACH_MT2701
24 select PINCTRL_MTK 42 select PINCTRL_MTK
25 43
44config PINCTRL_MT7623
45 bool "Mediatek MT7623 pin control with generic binding"
46 depends on MACH_MT7623 || COMPILE_TEST
47 depends on PINCTRL_MTK_MOORE
48 default y
49
26config PINCTRL_MT8135 50config PINCTRL_MT8135
27 bool "Mediatek MT8135 pin control" 51 bool "Mediatek MT8135 pin control"
28 depends on MACH_MT8135 || COMPILE_TEST 52 depends on MACH_MT8135 || COMPILE_TEST
@@ -47,13 +71,9 @@ config PINCTRL_MT2712
47 71
48config PINCTRL_MT7622 72config PINCTRL_MT7622
49 bool "MediaTek MT7622 pin control" 73 bool "MediaTek MT7622 pin control"
50 depends on OF
51 depends on ARM64 || COMPILE_TEST 74 depends on ARM64 || COMPILE_TEST
52 select GENERIC_PINCONF 75 depends on PINCTRL_MTK_MOORE
53 select GENERIC_PINCTRL_GROUPS 76 default y
54 select GENERIC_PINMUX_FUNCTIONS
55 select GPIOLIB
56 select OF_GPIO
57 77
58config PINCTRL_MT8173 78config PINCTRL_MT8173
59 bool "Mediatek MT8173 pin control" 79 bool "Mediatek MT8173 pin control"
@@ -62,6 +82,13 @@ config PINCTRL_MT8173
62 default ARM64 && ARCH_MEDIATEK 82 default ARM64 && ARCH_MEDIATEK
63 select PINCTRL_MTK 83 select PINCTRL_MTK
64 84
85config PINCTRL_MT8183
86 bool "Mediatek MT8183 pin control"
87 depends on OF
88 depends on ARM64 || COMPILE_TEST
89 default ARM64 && ARCH_MEDIATEK
90 select PINCTRL_MTK_PARIS
91
65# For PMIC 92# For PMIC
66config PINCTRL_MT6397 93config PINCTRL_MT6397
67 bool "Mediatek MT6397 pin control" 94 bool "Mediatek MT6397 pin control"
diff --git a/drivers/pinctrl/mediatek/Makefile b/drivers/pinctrl/mediatek/Makefile
index 3de7156df345..871e0e2f04ed 100644
--- a/drivers/pinctrl/mediatek/Makefile
+++ b/drivers/pinctrl/mediatek/Makefile
@@ -2,6 +2,8 @@
2# Core 2# Core
3obj-$(CONFIG_EINT_MTK) += mtk-eint.o 3obj-$(CONFIG_EINT_MTK) += mtk-eint.o
4obj-$(CONFIG_PINCTRL_MTK) += pinctrl-mtk-common.o 4obj-$(CONFIG_PINCTRL_MTK) += pinctrl-mtk-common.o
5obj-$(CONFIG_PINCTRL_MTK_MOORE) += pinctrl-moore.o pinctrl-mtk-common-v2.o
6obj-$(CONFIG_PINCTRL_MTK_PARIS) += pinctrl-paris.o pinctrl-mtk-common-v2.o
5 7
6# SoC Drivers 8# SoC Drivers
7obj-$(CONFIG_PINCTRL_MT2701) += pinctrl-mt2701.o 9obj-$(CONFIG_PINCTRL_MT2701) += pinctrl-mt2701.o
@@ -9,5 +11,7 @@ obj-$(CONFIG_PINCTRL_MT2712) += pinctrl-mt2712.o
9obj-$(CONFIG_PINCTRL_MT8135) += pinctrl-mt8135.o 11obj-$(CONFIG_PINCTRL_MT8135) += pinctrl-mt8135.o
10obj-$(CONFIG_PINCTRL_MT8127) += pinctrl-mt8127.o 12obj-$(CONFIG_PINCTRL_MT8127) += pinctrl-mt8127.o
11obj-$(CONFIG_PINCTRL_MT7622) += pinctrl-mt7622.o 13obj-$(CONFIG_PINCTRL_MT7622) += pinctrl-mt7622.o
14obj-$(CONFIG_PINCTRL_MT7623) += pinctrl-mt7623.o
12obj-$(CONFIG_PINCTRL_MT8173) += pinctrl-mt8173.o 15obj-$(CONFIG_PINCTRL_MT8173) += pinctrl-mt8173.o
16obj-$(CONFIG_PINCTRL_MT8183) += pinctrl-mt8183.o
13obj-$(CONFIG_PINCTRL_MT6397) += pinctrl-mt6397.o 17obj-$(CONFIG_PINCTRL_MT6397) += pinctrl-mt6397.o
diff --git a/drivers/pinctrl/mediatek/pinctrl-moore.c b/drivers/pinctrl/mediatek/pinctrl-moore.c
new file mode 100644
index 000000000000..7cfab0cfd18c
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-moore.c
@@ -0,0 +1,689 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * MediaTek Pinctrl Moore Driver, which implement the generic dt-binding
4 * pinctrl-bindings.txt for MediaTek SoC.
5 *
6 * Copyright (C) 2017-2018 MediaTek Inc.
7 * Author: Sean Wang <sean.wang@mediatek.com>
8 *
9 */
10
11#include "pinctrl-moore.h"
12
13#define PINCTRL_PINCTRL_DEV KBUILD_MODNAME
14
15/* Custom pinconf parameters */
16#define MTK_PIN_CONFIG_TDSEL (PIN_CONFIG_END + 1)
17#define MTK_PIN_CONFIG_RDSEL (PIN_CONFIG_END + 2)
18#define MTK_PIN_CONFIG_PU_ADV (PIN_CONFIG_END + 3)
19#define MTK_PIN_CONFIG_PD_ADV (PIN_CONFIG_END + 4)
20
21static const struct pinconf_generic_params mtk_custom_bindings[] = {
22 {"mediatek,tdsel", MTK_PIN_CONFIG_TDSEL, 0},
23 {"mediatek,rdsel", MTK_PIN_CONFIG_RDSEL, 0},
24 {"mediatek,pull-up-adv", MTK_PIN_CONFIG_PU_ADV, 1},
25 {"mediatek,pull-down-adv", MTK_PIN_CONFIG_PD_ADV, 1},
26};
27
28#ifdef CONFIG_DEBUG_FS
29static const struct pin_config_item mtk_conf_items[] = {
30 PCONFDUMP(MTK_PIN_CONFIG_TDSEL, "tdsel", NULL, true),
31 PCONFDUMP(MTK_PIN_CONFIG_RDSEL, "rdsel", NULL, true),
32 PCONFDUMP(MTK_PIN_CONFIG_PU_ADV, "pu-adv", NULL, true),
33 PCONFDUMP(MTK_PIN_CONFIG_PD_ADV, "pd-adv", NULL, true),
34};
35#endif
36
37static int mtk_pinmux_set_mux(struct pinctrl_dev *pctldev,
38 unsigned int selector, unsigned int group)
39{
40 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
41 struct function_desc *func;
42 struct group_desc *grp;
43 int i;
44
45 func = pinmux_generic_get_function(pctldev, selector);
46 if (!func)
47 return -EINVAL;
48
49 grp = pinctrl_generic_get_group(pctldev, group);
50 if (!grp)
51 return -EINVAL;
52
53 dev_dbg(pctldev->dev, "enable function %s group %s\n",
54 func->name, grp->name);
55
56 for (i = 0; i < grp->num_pins; i++) {
57 const struct mtk_pin_desc *desc;
58 int *pin_modes = grp->data;
59 int pin = grp->pins[i];
60
61 desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
62
63 mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_MODE,
64 pin_modes[i]);
65 }
66
67 return 0;
68}
69
70static int mtk_pinmux_gpio_request_enable(struct pinctrl_dev *pctldev,
71 struct pinctrl_gpio_range *range,
72 unsigned int pin)
73{
74 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
75 const struct mtk_pin_desc *desc;
76
77 desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
78
79 return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_MODE,
80 hw->soc->gpio_m);
81}
82
83static int mtk_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
84 struct pinctrl_gpio_range *range,
85 unsigned int pin, bool input)
86{
87 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
88 const struct mtk_pin_desc *desc;
89
90 desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
91
92 /* hardware would take 0 as input direction */
93 return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR, !input);
94}
95
96static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
97 unsigned int pin, unsigned long *config)
98{
99 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
100 u32 param = pinconf_to_config_param(*config);
101 int val, val2, err, reg, ret = 1;
102 const struct mtk_pin_desc *desc;
103
104 desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
105
106 switch (param) {
107 case PIN_CONFIG_BIAS_DISABLE:
108 if (hw->soc->bias_disable_get) {
109 err = hw->soc->bias_disable_get(hw, desc, &ret);
110 if (err)
111 return err;
112 } else {
113 return -ENOTSUPP;
114 }
115 break;
116 case PIN_CONFIG_BIAS_PULL_UP:
117 if (hw->soc->bias_get) {
118 err = hw->soc->bias_get(hw, desc, 1, &ret);
119 if (err)
120 return err;
121 } else {
122 return -ENOTSUPP;
123 }
124 break;
125 case PIN_CONFIG_BIAS_PULL_DOWN:
126 if (hw->soc->bias_get) {
127 err = hw->soc->bias_get(hw, desc, 0, &ret);
128 if (err)
129 return err;
130 } else {
131 return -ENOTSUPP;
132 }
133 break;
134 case PIN_CONFIG_SLEW_RATE:
135 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_SR, &val);
136 if (err)
137 return err;
138
139 if (!val)
140 return -EINVAL;
141
142 break;
143 case PIN_CONFIG_INPUT_ENABLE:
144 case PIN_CONFIG_OUTPUT_ENABLE:
145 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &val);
146 if (err)
147 return err;
148
149 /* HW takes input mode as zero; output mode as non-zero */
150 if ((val && param == PIN_CONFIG_INPUT_ENABLE) ||
151 (!val && param == PIN_CONFIG_OUTPUT_ENABLE))
152 return -EINVAL;
153
154 break;
155 case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
156 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &val);
157 if (err)
158 return err;
159
160 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_SMT, &val2);
161 if (err)
162 return err;
163
164 if (val || !val2)
165 return -EINVAL;
166
167 break;
168 case PIN_CONFIG_DRIVE_STRENGTH:
169 if (hw->soc->drive_get) {
170 err = hw->soc->drive_get(hw, desc, &ret);
171 if (err)
172 return err;
173 } else {
174 err = -ENOTSUPP;
175 }
176 break;
177 case MTK_PIN_CONFIG_TDSEL:
178 case MTK_PIN_CONFIG_RDSEL:
179 reg = (param == MTK_PIN_CONFIG_TDSEL) ?
180 PINCTRL_PIN_REG_TDSEL : PINCTRL_PIN_REG_RDSEL;
181
182 err = mtk_hw_get_value(hw, desc, reg, &val);
183 if (err)
184 return err;
185
186 ret = val;
187
188 break;
189 case MTK_PIN_CONFIG_PU_ADV:
190 case MTK_PIN_CONFIG_PD_ADV:
191 if (hw->soc->adv_pull_get) {
192 bool pullup;
193
194 pullup = param == MTK_PIN_CONFIG_PU_ADV;
195 err = hw->soc->adv_pull_get(hw, desc, pullup, &ret);
196 if (err)
197 return err;
198 } else {
199 return -ENOTSUPP;
200 }
201 break;
202 default:
203 return -ENOTSUPP;
204 }
205
206 *config = pinconf_to_config_packed(param, ret);
207
208 return 0;
209}
210
211static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
212 unsigned long *configs, unsigned int num_configs)
213{
214 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
215 const struct mtk_pin_desc *desc;
216 u32 reg, param, arg;
217 int cfg, err = 0;
218
219 desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
220
221 for (cfg = 0; cfg < num_configs; cfg++) {
222 param = pinconf_to_config_param(configs[cfg]);
223 arg = pinconf_to_config_argument(configs[cfg]);
224
225 switch (param) {
226 case PIN_CONFIG_BIAS_DISABLE:
227 if (hw->soc->bias_disable_set) {
228 err = hw->soc->bias_disable_set(hw, desc);
229 if (err)
230 return err;
231 } else {
232 return -ENOTSUPP;
233 }
234 break;
235 case PIN_CONFIG_BIAS_PULL_UP:
236 if (hw->soc->bias_set) {
237 err = hw->soc->bias_set(hw, desc, 1);
238 if (err)
239 return err;
240 } else {
241 return -ENOTSUPP;
242 }
243 break;
244 case PIN_CONFIG_BIAS_PULL_DOWN:
245 if (hw->soc->bias_set) {
246 err = hw->soc->bias_set(hw, desc, 0);
247 if (err)
248 return err;
249 } else {
250 return -ENOTSUPP;
251 }
252 break;
253 case PIN_CONFIG_OUTPUT_ENABLE:
254 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_SMT,
255 MTK_DISABLE);
256 if (err)
257 goto err;
258
259 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
260 MTK_OUTPUT);
261 if (err)
262 goto err;
263 break;
264 case PIN_CONFIG_INPUT_ENABLE:
265
266 if (hw->soc->ies_present) {
267 mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_IES,
268 MTK_ENABLE);
269 }
270
271 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
272 MTK_INPUT);
273 if (err)
274 goto err;
275 break;
276 case PIN_CONFIG_SLEW_RATE:
277 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_SR,
278 arg);
279 if (err)
280 goto err;
281
282 break;
283 case PIN_CONFIG_OUTPUT:
284 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
285 MTK_OUTPUT);
286 if (err)
287 goto err;
288
289 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DO,
290 arg);
291 if (err)
292 goto err;
293 break;
294 case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
295 /* arg = 1: Input mode & SMT enable ;
296 * arg = 0: Output mode & SMT disable
297 */
298 arg = arg ? 2 : 1;
299 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
300 arg & 1);
301 if (err)
302 goto err;
303
304 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_SMT,
305 !!(arg & 2));
306 if (err)
307 goto err;
308 break;
309 case PIN_CONFIG_DRIVE_STRENGTH:
310 if (hw->soc->drive_set) {
311 err = hw->soc->drive_set(hw, desc, arg);
312 if (err)
313 return err;
314 } else {
315 err = -ENOTSUPP;
316 }
317 break;
318 case MTK_PIN_CONFIG_TDSEL:
319 case MTK_PIN_CONFIG_RDSEL:
320 reg = (param == MTK_PIN_CONFIG_TDSEL) ?
321 PINCTRL_PIN_REG_TDSEL : PINCTRL_PIN_REG_RDSEL;
322
323 err = mtk_hw_set_value(hw, desc, reg, arg);
324 if (err)
325 goto err;
326 break;
327 case MTK_PIN_CONFIG_PU_ADV:
328 case MTK_PIN_CONFIG_PD_ADV:
329 if (hw->soc->adv_pull_set) {
330 bool pullup;
331
332 pullup = param == MTK_PIN_CONFIG_PU_ADV;
333 err = hw->soc->adv_pull_set(hw, desc, pullup,
334 arg);
335 if (err)
336 return err;
337 } else {
338 return -ENOTSUPP;
339 }
340 break;
341 default:
342 err = -ENOTSUPP;
343 }
344 }
345err:
346 return err;
347}
348
349static int mtk_pinconf_group_get(struct pinctrl_dev *pctldev,
350 unsigned int group, unsigned long *config)
351{
352 const unsigned int *pins;
353 unsigned int i, npins, old = 0;
354 int ret;
355
356 ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins);
357 if (ret)
358 return ret;
359
360 for (i = 0; i < npins; i++) {
361 if (mtk_pinconf_get(pctldev, pins[i], config))
362 return -ENOTSUPP;
363
364 /* configs do not match between two pins */
365 if (i && old != *config)
366 return -ENOTSUPP;
367
368 old = *config;
369 }
370
371 return 0;
372}
373
374static int mtk_pinconf_group_set(struct pinctrl_dev *pctldev,
375 unsigned int group, unsigned long *configs,
376 unsigned int num_configs)
377{
378 const unsigned int *pins;
379 unsigned int i, npins;
380 int ret;
381
382 ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins);
383 if (ret)
384 return ret;
385
386 for (i = 0; i < npins; i++) {
387 ret = mtk_pinconf_set(pctldev, pins[i], configs, num_configs);
388 if (ret)
389 return ret;
390 }
391
392 return 0;
393}
394
395static const struct pinctrl_ops mtk_pctlops = {
396 .get_groups_count = pinctrl_generic_get_group_count,
397 .get_group_name = pinctrl_generic_get_group_name,
398 .get_group_pins = pinctrl_generic_get_group_pins,
399 .dt_node_to_map = pinconf_generic_dt_node_to_map_all,
400 .dt_free_map = pinconf_generic_dt_free_map,
401};
402
403static const struct pinmux_ops mtk_pmxops = {
404 .get_functions_count = pinmux_generic_get_function_count,
405 .get_function_name = pinmux_generic_get_function_name,
406 .get_function_groups = pinmux_generic_get_function_groups,
407 .set_mux = mtk_pinmux_set_mux,
408 .gpio_request_enable = mtk_pinmux_gpio_request_enable,
409 .gpio_set_direction = mtk_pinmux_gpio_set_direction,
410 .strict = true,
411};
412
413static const struct pinconf_ops mtk_confops = {
414 .is_generic = true,
415 .pin_config_get = mtk_pinconf_get,
416 .pin_config_set = mtk_pinconf_set,
417 .pin_config_group_get = mtk_pinconf_group_get,
418 .pin_config_group_set = mtk_pinconf_group_set,
419 .pin_config_config_dbg_show = pinconf_generic_dump_config,
420};
421
422static struct pinctrl_desc mtk_desc = {
423 .name = PINCTRL_PINCTRL_DEV,
424 .pctlops = &mtk_pctlops,
425 .pmxops = &mtk_pmxops,
426 .confops = &mtk_confops,
427 .owner = THIS_MODULE,
428};
429
430static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio)
431{
432 struct mtk_pinctrl *hw = gpiochip_get_data(chip);
433 const struct mtk_pin_desc *desc;
434 int value, err;
435
436 desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
437
438 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DI, &value);
439 if (err)
440 return err;
441
442 return !!value;
443}
444
445static void mtk_gpio_set(struct gpio_chip *chip, unsigned int gpio, int value)
446{
447 struct mtk_pinctrl *hw = gpiochip_get_data(chip);
448 const struct mtk_pin_desc *desc;
449
450 desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
451
452 mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DO, !!value);
453}
454
455static int mtk_gpio_direction_input(struct gpio_chip *chip, unsigned int gpio)
456{
457 return pinctrl_gpio_direction_input(chip->base + gpio);
458}
459
460static int mtk_gpio_direction_output(struct gpio_chip *chip, unsigned int gpio,
461 int value)
462{
463 mtk_gpio_set(chip, gpio, value);
464
465 return pinctrl_gpio_direction_output(chip->base + gpio);
466}
467
468static int mtk_gpio_to_irq(struct gpio_chip *chip, unsigned int offset)
469{
470 struct mtk_pinctrl *hw = gpiochip_get_data(chip);
471 const struct mtk_pin_desc *desc;
472
473 if (!hw->eint)
474 return -ENOTSUPP;
475
476 desc = (const struct mtk_pin_desc *)&hw->soc->pins[offset];
477
478 if (desc->eint.eint_n == EINT_NA)
479 return -ENOTSUPP;
480
481 return mtk_eint_find_irq(hw->eint, desc->eint.eint_n);
482}
483
484static int mtk_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
485 unsigned long config)
486{
487 struct mtk_pinctrl *hw = gpiochip_get_data(chip);
488 const struct mtk_pin_desc *desc;
489 u32 debounce;
490
491 desc = (const struct mtk_pin_desc *)&hw->soc->pins[offset];
492
493 if (!hw->eint ||
494 pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE ||
495 desc->eint.eint_n == EINT_NA)
496 return -ENOTSUPP;
497
498 debounce = pinconf_to_config_argument(config);
499
500 return mtk_eint_set_debounce(hw->eint, desc->eint.eint_n, debounce);
501}
502
503static int mtk_build_gpiochip(struct mtk_pinctrl *hw, struct device_node *np)
504{
505 struct gpio_chip *chip = &hw->chip;
506 int ret;
507
508 chip->label = PINCTRL_PINCTRL_DEV;
509 chip->parent = hw->dev;
510 chip->request = gpiochip_generic_request;
511 chip->free = gpiochip_generic_free;
512 chip->direction_input = mtk_gpio_direction_input;
513 chip->direction_output = mtk_gpio_direction_output;
514 chip->get = mtk_gpio_get;
515 chip->set = mtk_gpio_set;
516 chip->to_irq = mtk_gpio_to_irq,
517 chip->set_config = mtk_gpio_set_config,
518 chip->base = -1;
519 chip->ngpio = hw->soc->npins;
520 chip->of_node = np;
521 chip->of_gpio_n_cells = 2;
522
523 ret = gpiochip_add_data(chip, hw);
524 if (ret < 0)
525 return ret;
526
527 /* Just for backward compatible for these old pinctrl nodes without
528 * "gpio-ranges" property. Otherwise, called directly from a
529 * DeviceTree-supported pinctrl driver is DEPRECATED.
530 * Please see Section 2.1 of
531 * Documentation/devicetree/bindings/gpio/gpio.txt on how to
532 * bind pinctrl and gpio drivers via the "gpio-ranges" property.
533 */
534 if (!of_find_property(np, "gpio-ranges", NULL)) {
535 ret = gpiochip_add_pin_range(chip, dev_name(hw->dev), 0, 0,
536 chip->ngpio);
537 if (ret < 0) {
538 gpiochip_remove(chip);
539 return ret;
540 }
541 }
542
543 return 0;
544}
545
546static int mtk_build_groups(struct mtk_pinctrl *hw)
547{
548 int err, i;
549
550 for (i = 0; i < hw->soc->ngrps; i++) {
551 const struct group_desc *group = hw->soc->grps + i;
552
553 err = pinctrl_generic_add_group(hw->pctrl, group->name,
554 group->pins, group->num_pins,
555 group->data);
556 if (err < 0) {
557 dev_err(hw->dev, "Failed to register group %s\n",
558 group->name);
559 return err;
560 }
561 }
562
563 return 0;
564}
565
566static int mtk_build_functions(struct mtk_pinctrl *hw)
567{
568 int i, err;
569
570 for (i = 0; i < hw->soc->nfuncs ; i++) {
571 const struct function_desc *func = hw->soc->funcs + i;
572
573 err = pinmux_generic_add_function(hw->pctrl, func->name,
574 func->group_names,
575 func->num_group_names,
576 func->data);
577 if (err < 0) {
578 dev_err(hw->dev, "Failed to register function %s\n",
579 func->name);
580 return err;
581 }
582 }
583
584 return 0;
585}
586
587int mtk_moore_pinctrl_probe(struct platform_device *pdev,
588 const struct mtk_pin_soc *soc)
589{
590 struct pinctrl_pin_desc *pins;
591 struct resource *res;
592 struct mtk_pinctrl *hw;
593 int err, i;
594
595 hw = devm_kzalloc(&pdev->dev, sizeof(*hw), GFP_KERNEL);
596 if (!hw)
597 return -ENOMEM;
598
599 hw->soc = soc;
600 hw->dev = &pdev->dev;
601
602 if (!hw->soc->nbase_names) {
603 dev_err(&pdev->dev,
604 "SoC should be assigned at least one register base\n");
605 return -EINVAL;
606 }
607
608 hw->base = devm_kmalloc_array(&pdev->dev, hw->soc->nbase_names,
609 sizeof(*hw->base), GFP_KERNEL);
610 if (IS_ERR(hw->base))
611 return PTR_ERR(hw->base);
612
613 for (i = 0; i < hw->soc->nbase_names; i++) {
614 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
615 hw->soc->base_names[i]);
616 if (!res) {
617 dev_err(&pdev->dev, "missing IO resource\n");
618 return -ENXIO;
619 }
620
621 hw->base[i] = devm_ioremap_resource(&pdev->dev, res);
622 if (IS_ERR(hw->base[i]))
623 return PTR_ERR(hw->base[i]);
624 }
625
626 hw->nbase = hw->soc->nbase_names;
627
628 /* Copy from internal struct mtk_pin_desc to register to the core */
629 pins = devm_kmalloc_array(&pdev->dev, hw->soc->npins, sizeof(*pins),
630 GFP_KERNEL);
631 if (IS_ERR(pins))
632 return PTR_ERR(pins);
633
634 for (i = 0; i < hw->soc->npins; i++) {
635 pins[i].number = hw->soc->pins[i].number;
636 pins[i].name = hw->soc->pins[i].name;
637 }
638
639 /* Setup pins descriptions per SoC types */
640 mtk_desc.pins = (const struct pinctrl_pin_desc *)pins;
641 mtk_desc.npins = hw->soc->npins;
642 mtk_desc.num_custom_params = ARRAY_SIZE(mtk_custom_bindings);
643 mtk_desc.custom_params = mtk_custom_bindings;
644#ifdef CONFIG_DEBUG_FS
645 mtk_desc.custom_conf_items = mtk_conf_items;
646#endif
647
648 err = devm_pinctrl_register_and_init(&pdev->dev, &mtk_desc, hw,
649 &hw->pctrl);
650 if (err)
651 return err;
652
653 /* Setup groups descriptions per SoC types */
654 err = mtk_build_groups(hw);
655 if (err) {
656 dev_err(&pdev->dev, "Failed to build groups\n");
657 return err;
658 }
659
660 /* Setup functions descriptions per SoC types */
661 err = mtk_build_functions(hw);
662 if (err) {
663 dev_err(&pdev->dev, "Failed to build functions\n");
664 return err;
665 }
666
667 /* For able to make pinctrl_claim_hogs, we must not enable pinctrl
668 * until all groups and functions are being added one.
669 */
670 err = pinctrl_enable(hw->pctrl);
671 if (err)
672 return err;
673
674 err = mtk_build_eint(hw, pdev);
675 if (err)
676 dev_warn(&pdev->dev,
677 "Failed to add EINT, but pinctrl still can work\n");
678
679 /* Build gpiochip should be after pinctrl_enable is done */
680 err = mtk_build_gpiochip(hw, pdev->dev.of_node);
681 if (err) {
682 dev_err(&pdev->dev, "Failed to add gpio_chip\n");
683 return err;
684 }
685
686 platform_set_drvdata(pdev, hw);
687
688 return 0;
689}
diff --git a/drivers/pinctrl/mediatek/pinctrl-moore.h b/drivers/pinctrl/mediatek/pinctrl-moore.h
new file mode 100644
index 000000000000..74a6568a9220
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-moore.h
@@ -0,0 +1,53 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2017-2018 MediaTek Inc.
4 *
5 * Author: Sean Wang <sean.wang@mediatek.com>
6 *
7 */
8#ifndef __PINCTRL_MOORE_H
9#define __PINCTRL_MOORE_H
10
11#include <linux/gpio.h>
12#include <linux/gpio/driver.h>
13#include <linux/io.h>
14#include <linux/init.h>
15#include <linux/of.h>
16#include <linux/of_platform.h>
17#include <linux/platform_device.h>
18#include <linux/pinctrl/pinctrl.h>
19#include <linux/pinctrl/pinmux.h>
20#include <linux/pinctrl/pinconf.h>
21#include <linux/pinctrl/pinconf-generic.h>
22
23#include "../core.h"
24#include "../pinconf.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_PIN(_number, _name, _eint_m, _eint_n, _drv_n) { \
32 .number = _number, \
33 .name = _name, \
34 .eint = { \
35 .eint_m = _eint_m, \
36 .eint_n = _eint_n, \
37 }, \
38 .drv_n = _drv_n, \
39 .funcs = NULL, \
40 }
41
42#define PINCTRL_PIN_GROUP(name, id) \
43 { \
44 name, \
45 id##_pins, \
46 ARRAY_SIZE(id##_pins), \
47 id##_funcs, \
48 }
49
50int mtk_moore_pinctrl_probe(struct platform_device *pdev,
51 const struct mtk_pin_soc *soc);
52
53#endif /* __PINCTRL_MOORE_H */
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7622.c b/drivers/pinctrl/mediatek/pinctrl-mt7622.c
index 2107fd5ac471..ce4a8a0cc19c 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt7622.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7622.c
@@ -1,296 +1,140 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MediaTek MT7622 Pinctrl Driver 3 * Copyright (C) 2017-2018 MediaTek Inc.
3 * 4 *
4 * Copyright (C) 2017 Sean Wang <sean.wang@mediatek.com> 5 * Author: Sean Wang <sean.wang@mediatek.com>
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/gpio/driver.h>
17#include <linux/io.h>
18#include <linux/init.h>
19#include <linux/mfd/syscon.h>
20#include <linux/of.h>
21#include <linux/of_irq.h>
22#include <linux/of_platform.h>
23#include <linux/platform_device.h>
24#include <linux/pinctrl/pinctrl.h>
25#include <linux/pinctrl/pinmux.h>
26#include <linux/pinctrl/pinconf.h>
27#include <linux/pinctrl/pinconf-generic.h>
28#include <linux/regmap.h>
29
30#include "../core.h"
31#include "../pinconf.h"
32#include "../pinmux.h"
33#include "mtk-eint.h"
34
35#define PINCTRL_PINCTRL_DEV KBUILD_MODNAME
36#define MTK_RANGE(_a) { .range = (_a), .nranges = ARRAY_SIZE(_a), }
37#define PINCTRL_PIN_GROUP(name, id) \
38 { \
39 name, \
40 id##_pins, \
41 ARRAY_SIZE(id##_pins), \
42 id##_funcs, \
43 }
44
45#define MTK_GPIO_MODE 1
46#define MTK_INPUT 0
47#define MTK_OUTPUT 1
48#define MTK_DISABLE 0
49#define MTK_ENABLE 1
50
51/* Custom pinconf parameters */
52#define MTK_PIN_CONFIG_TDSEL (PIN_CONFIG_END + 1)
53#define MTK_PIN_CONFIG_RDSEL (PIN_CONFIG_END + 2)
54
55/* List these attributes which could be modified for the pin */
56enum {
57 PINCTRL_PIN_REG_MODE,
58 PINCTRL_PIN_REG_DIR,
59 PINCTRL_PIN_REG_DI,
60 PINCTRL_PIN_REG_DO,
61 PINCTRL_PIN_REG_SR,
62 PINCTRL_PIN_REG_SMT,
63 PINCTRL_PIN_REG_PD,
64 PINCTRL_PIN_REG_PU,
65 PINCTRL_PIN_REG_E4,
66 PINCTRL_PIN_REG_E8,
67 PINCTRL_PIN_REG_TDSEL,
68 PINCTRL_PIN_REG_RDSEL,
69 PINCTRL_PIN_REG_MAX,
70};
71
72/* struct mtk_pin_field - the structure that holds the information of the field
73 * used to describe the attribute for the pin
74 * @offset: the register offset relative to the base address
75 * @mask: the mask used to filter out the field from the register
76 * @bitpos: the start bit relative to the register
77 * @next: the indication that the field would be extended to the
78 next register
79 */ 7 */
80struct mtk_pin_field {
81 u32 offset;
82 u32 mask;
83 u8 bitpos;
84 u8 next;
85};
86 8
87/* struct mtk_pin_field_calc - the structure that holds the range providing 9#include "pinctrl-moore.h"
88 * the guide used to look up the relevant field
89 * @s_pin: the start pin within the range
90 * @e_pin: the end pin within the range
91 * @s_addr: the start address for the range
92 * @x_addrs: the address distance between two consecutive registers
93 * within the range
94 * @s_bit: the start bit for the first register within the range
95 * @x_bits: the bit distance between two consecutive pins within
96 * the range
97 */
98struct mtk_pin_field_calc {
99 u16 s_pin;
100 u16 e_pin;
101 u32 s_addr;
102 u8 x_addrs;
103 u8 s_bit;
104 u8 x_bits;
105};
106 10
107/* struct mtk_pin_reg_calc - the structure that holds all ranges used to 11#define MT7622_PIN(_number, _name) \
108 * determine which register the pin would make use of 12 MTK_PIN(_number, _name, 1, _number, DRV_GRP0)
109 * for certain pin attribute.
110 * @range: the start address for the range
111 * @nranges: the number of items in the range
112 */
113struct mtk_pin_reg_calc {
114 const struct mtk_pin_field_calc *range;
115 unsigned int nranges;
116};
117
118/* struct mtk_pin_soc - the structure that holds SoC-specific data */
119struct mtk_pin_soc {
120 const struct mtk_pin_reg_calc *reg_cal;
121 const struct pinctrl_pin_desc *pins;
122 unsigned int npins;
123 const struct group_desc *grps;
124 unsigned int ngrps;
125 const struct function_desc *funcs;
126 unsigned int nfuncs;
127 const struct mtk_eint_regs *eint_regs;
128 const struct mtk_eint_hw *eint_hw;
129};
130
131struct mtk_pinctrl {
132 struct pinctrl_dev *pctrl;
133 void __iomem *base;
134 struct device *dev;
135 struct gpio_chip chip;
136 const struct mtk_pin_soc *soc;
137 struct mtk_eint *eint;
138};
139 13
140static const struct mtk_pin_field_calc mt7622_pin_mode_range[] = { 14static const struct mtk_pin_field_calc mt7622_pin_mode_range[] = {
141 {0, 0, 0x320, 0x10, 16, 4}, 15 PIN_FIELD(0, 0, 0x320, 0x10, 16, 4),
142 {1, 4, 0x3a0, 0x10, 16, 4}, 16 PIN_FIELD(1, 4, 0x3a0, 0x10, 16, 4),
143 {5, 5, 0x320, 0x10, 0, 4}, 17 PIN_FIELD(5, 5, 0x320, 0x10, 0, 4),
144 {6, 6, 0x300, 0x10, 4, 4}, 18 PINS_FIELD(6, 7, 0x300, 0x10, 4, 4),
145 {7, 7, 0x300, 0x10, 4, 4}, 19 PIN_FIELD(8, 9, 0x350, 0x10, 20, 4),
146 {8, 9, 0x350, 0x10, 20, 4}, 20 PINS_FIELD(10, 13, 0x300, 0x10, 8, 4),
147 {10, 10, 0x300, 0x10, 8, 4}, 21 PIN_FIELD(14, 15, 0x320, 0x10, 4, 4),
148 {11, 11, 0x300, 0x10, 8, 4}, 22 PIN_FIELD(16, 17, 0x320, 0x10, 20, 4),
149 {12, 12, 0x300, 0x10, 8, 4}, 23 PIN_FIELD(18, 21, 0x310, 0x10, 16, 4),
150 {13, 13, 0x300, 0x10, 8, 4}, 24 PIN_FIELD(22, 22, 0x380, 0x10, 16, 4),
151 {14, 15, 0x320, 0x10, 4, 4}, 25 PINS_FIELD(23, 24, 0x300, 0x10, 24, 4),
152 {16, 17, 0x320, 0x10, 20, 4}, 26 PINS_FIELD(25, 36, 0x300, 0x10, 12, 4),
153 {18, 21, 0x310, 0x10, 16, 4}, 27 PINS_FIELD(37, 50, 0x300, 0x10, 20, 4),
154 {22, 22, 0x380, 0x10, 16, 4}, 28 PIN_FIELD(51, 70, 0x330, 0x10, 4, 4),
155 {23, 23, 0x300, 0x10, 24, 4}, 29 PINS_FIELD(71, 72, 0x300, 0x10, 16, 4),
156 {24, 24, 0x300, 0x10, 24, 4}, 30 PIN_FIELD(73, 76, 0x310, 0x10, 0, 4),
157 {25, 25, 0x300, 0x10, 12, 4}, 31 PIN_FIELD(77, 77, 0x320, 0x10, 28, 4),
158 {25, 25, 0x300, 0x10, 12, 4}, 32 PIN_FIELD(78, 78, 0x320, 0x10, 12, 4),
159 {26, 26, 0x300, 0x10, 12, 4}, 33 PIN_FIELD(79, 82, 0x3a0, 0x10, 0, 4),
160 {27, 27, 0x300, 0x10, 12, 4}, 34 PIN_FIELD(83, 83, 0x350, 0x10, 28, 4),
161 {28, 28, 0x300, 0x10, 12, 4}, 35 PIN_FIELD(84, 84, 0x330, 0x10, 0, 4),
162 {29, 29, 0x300, 0x10, 12, 4}, 36 PIN_FIELD(85, 90, 0x360, 0x10, 4, 4),
163 {30, 30, 0x300, 0x10, 12, 4}, 37 PIN_FIELD(91, 94, 0x390, 0x10, 16, 4),
164 {31, 31, 0x300, 0x10, 12, 4}, 38 PIN_FIELD(95, 97, 0x380, 0x10, 20, 4),
165 {32, 32, 0x300, 0x10, 12, 4}, 39 PIN_FIELD(98, 101, 0x390, 0x10, 0, 4),
166 {33, 33, 0x300, 0x10, 12, 4}, 40 PIN_FIELD(102, 102, 0x360, 0x10, 0, 4),
167 {34, 34, 0x300, 0x10, 12, 4},
168 {35, 35, 0x300, 0x10, 12, 4},
169 {36, 36, 0x300, 0x10, 12, 4},
170 {37, 37, 0x300, 0x10, 20, 4},
171 {38, 38, 0x300, 0x10, 20, 4},
172 {39, 39, 0x300, 0x10, 20, 4},
173 {40, 40, 0x300, 0x10, 20, 4},
174 {41, 41, 0x300, 0x10, 20, 4},
175 {42, 42, 0x300, 0x10, 20, 4},
176 {43, 43, 0x300, 0x10, 20, 4},
177 {44, 44, 0x300, 0x10, 20, 4},
178 {45, 46, 0x300, 0x10, 20, 4},
179 {47, 47, 0x300, 0x10, 20, 4},
180 {48, 48, 0x300, 0x10, 20, 4},
181 {49, 49, 0x300, 0x10, 20, 4},
182 {50, 50, 0x300, 0x10, 20, 4},
183 {51, 70, 0x330, 0x10, 4, 4},
184 {71, 71, 0x300, 0x10, 16, 4},
185 {72, 72, 0x300, 0x10, 16, 4},
186 {73, 76, 0x310, 0x10, 0, 4},
187 {77, 77, 0x320, 0x10, 28, 4},
188 {78, 78, 0x320, 0x10, 12, 4},
189 {79, 82, 0x3a0, 0x10, 0, 4},
190 {83, 83, 0x350, 0x10, 28, 4},
191 {84, 84, 0x330, 0x10, 0, 4},
192 {85, 90, 0x360, 0x10, 4, 4},
193 {91, 94, 0x390, 0x10, 16, 4},
194 {95, 97, 0x380, 0x10, 20, 4},
195 {98, 101, 0x390, 0x10, 0, 4},
196 {102, 102, 0x360, 0x10, 0, 4},
197}; 41};
198 42
199static const struct mtk_pin_field_calc mt7622_pin_dir_range[] = { 43static const struct mtk_pin_field_calc mt7622_pin_dir_range[] = {
200 {0, 102, 0x0, 0x10, 0, 1}, 44 PIN_FIELD(0, 102, 0x0, 0x10, 0, 1),
201}; 45};
202 46
203static const struct mtk_pin_field_calc mt7622_pin_di_range[] = { 47static const struct mtk_pin_field_calc mt7622_pin_di_range[] = {
204 {0, 102, 0x200, 0x10, 0, 1}, 48 PIN_FIELD(0, 102, 0x200, 0x10, 0, 1),
205}; 49};
206 50
207static const struct mtk_pin_field_calc mt7622_pin_do_range[] = { 51static const struct mtk_pin_field_calc mt7622_pin_do_range[] = {
208 {0, 102, 0x100, 0x10, 0, 1}, 52 PIN_FIELD(0, 102, 0x100, 0x10, 0, 1),
209}; 53};
210 54
211static const struct mtk_pin_field_calc mt7622_pin_sr_range[] = { 55static const struct mtk_pin_field_calc mt7622_pin_sr_range[] = {
212 {0, 31, 0x910, 0x10, 0, 1}, 56 PIN_FIELD(0, 31, 0x910, 0x10, 0, 1),
213 {32, 50, 0xa10, 0x10, 0, 1}, 57 PIN_FIELD(32, 50, 0xa10, 0x10, 0, 1),
214 {51, 70, 0x810, 0x10, 0, 1}, 58 PIN_FIELD(51, 70, 0x810, 0x10, 0, 1),
215 {71, 72, 0xb10, 0x10, 0, 1}, 59 PIN_FIELD(71, 72, 0xb10, 0x10, 0, 1),
216 {73, 86, 0xb10, 0x10, 4, 1}, 60 PIN_FIELD(73, 86, 0xb10, 0x10, 4, 1),
217 {87, 90, 0xc10, 0x10, 0, 1}, 61 PIN_FIELD(87, 90, 0xc10, 0x10, 0, 1),
218 {91, 102, 0xb10, 0x10, 18, 1}, 62 PIN_FIELD(91, 102, 0xb10, 0x10, 18, 1),
219}; 63};
220 64
221static const struct mtk_pin_field_calc mt7622_pin_smt_range[] = { 65static const struct mtk_pin_field_calc mt7622_pin_smt_range[] = {
222 {0, 31, 0x920, 0x10, 0, 1}, 66 PIN_FIELD(0, 31, 0x920, 0x10, 0, 1),
223 {32, 50, 0xa20, 0x10, 0, 1}, 67 PIN_FIELD(32, 50, 0xa20, 0x10, 0, 1),
224 {51, 70, 0x820, 0x10, 0, 1}, 68 PIN_FIELD(51, 70, 0x820, 0x10, 0, 1),
225 {71, 72, 0xb20, 0x10, 0, 1}, 69 PIN_FIELD(71, 72, 0xb20, 0x10, 0, 1),
226 {73, 86, 0xb20, 0x10, 4, 1}, 70 PIN_FIELD(73, 86, 0xb20, 0x10, 4, 1),
227 {87, 90, 0xc20, 0x10, 0, 1}, 71 PIN_FIELD(87, 90, 0xc20, 0x10, 0, 1),
228 {91, 102, 0xb20, 0x10, 18, 1}, 72 PIN_FIELD(91, 102, 0xb20, 0x10, 18, 1),
229}; 73};
230 74
231static const struct mtk_pin_field_calc mt7622_pin_pu_range[] = { 75static const struct mtk_pin_field_calc mt7622_pin_pu_range[] = {
232 {0, 31, 0x930, 0x10, 0, 1}, 76 PIN_FIELD(0, 31, 0x930, 0x10, 0, 1),
233 {32, 50, 0xa30, 0x10, 0, 1}, 77 PIN_FIELD(32, 50, 0xa30, 0x10, 0, 1),
234 {51, 70, 0x830, 0x10, 0, 1}, 78 PIN_FIELD(51, 70, 0x830, 0x10, 0, 1),
235 {71, 72, 0xb30, 0x10, 0, 1}, 79 PIN_FIELD(71, 72, 0xb30, 0x10, 0, 1),
236 {73, 86, 0xb30, 0x10, 4, 1}, 80 PIN_FIELD(73, 86, 0xb30, 0x10, 4, 1),
237 {87, 90, 0xc30, 0x10, 0, 1}, 81 PIN_FIELD(87, 90, 0xc30, 0x10, 0, 1),
238 {91, 102, 0xb30, 0x10, 18, 1}, 82 PIN_FIELD(91, 102, 0xb30, 0x10, 18, 1),
239}; 83};
240 84
241static const struct mtk_pin_field_calc mt7622_pin_pd_range[] = { 85static const struct mtk_pin_field_calc mt7622_pin_pd_range[] = {
242 {0, 31, 0x940, 0x10, 0, 1}, 86 PIN_FIELD(0, 31, 0x940, 0x10, 0, 1),
243 {32, 50, 0xa40, 0x10, 0, 1}, 87 PIN_FIELD(32, 50, 0xa40, 0x10, 0, 1),
244 {51, 70, 0x840, 0x10, 0, 1}, 88 PIN_FIELD(51, 70, 0x840, 0x10, 0, 1),
245 {71, 72, 0xb40, 0x10, 0, 1}, 89 PIN_FIELD(71, 72, 0xb40, 0x10, 0, 1),
246 {73, 86, 0xb40, 0x10, 4, 1}, 90 PIN_FIELD(73, 86, 0xb40, 0x10, 4, 1),
247 {87, 90, 0xc40, 0x10, 0, 1}, 91 PIN_FIELD(87, 90, 0xc40, 0x10, 0, 1),
248 {91, 102, 0xb40, 0x10, 18, 1}, 92 PIN_FIELD(91, 102, 0xb40, 0x10, 18, 1),
249}; 93};
250 94
251static const struct mtk_pin_field_calc mt7622_pin_e4_range[] = { 95static const struct mtk_pin_field_calc mt7622_pin_e4_range[] = {
252 {0, 31, 0x960, 0x10, 0, 1}, 96 PIN_FIELD(0, 31, 0x960, 0x10, 0, 1),
253 {32, 50, 0xa60, 0x10, 0, 1}, 97 PIN_FIELD(32, 50, 0xa60, 0x10, 0, 1),
254 {51, 70, 0x860, 0x10, 0, 1}, 98 PIN_FIELD(51, 70, 0x860, 0x10, 0, 1),
255 {71, 72, 0xb60, 0x10, 0, 1}, 99 PIN_FIELD(71, 72, 0xb60, 0x10, 0, 1),
256 {73, 86, 0xb60, 0x10, 4, 1}, 100 PIN_FIELD(73, 86, 0xb60, 0x10, 4, 1),
257 {87, 90, 0xc60, 0x10, 0, 1}, 101 PIN_FIELD(87, 90, 0xc60, 0x10, 0, 1),
258 {91, 102, 0xb60, 0x10, 18, 1}, 102 PIN_FIELD(91, 102, 0xb60, 0x10, 18, 1),
259}; 103};
260 104
261static const struct mtk_pin_field_calc mt7622_pin_e8_range[] = { 105static const struct mtk_pin_field_calc mt7622_pin_e8_range[] = {
262 {0, 31, 0x970, 0x10, 0, 1}, 106 PIN_FIELD(0, 31, 0x970, 0x10, 0, 1),
263 {32, 50, 0xa70, 0x10, 0, 1}, 107 PIN_FIELD(32, 50, 0xa70, 0x10, 0, 1),
264 {51, 70, 0x870, 0x10, 0, 1}, 108 PIN_FIELD(51, 70, 0x870, 0x10, 0, 1),
265 {71, 72, 0xb70, 0x10, 0, 1}, 109 PIN_FIELD(71, 72, 0xb70, 0x10, 0, 1),
266 {73, 86, 0xb70, 0x10, 4, 1}, 110 PIN_FIELD(73, 86, 0xb70, 0x10, 4, 1),
267 {87, 90, 0xc70, 0x10, 0, 1}, 111 PIN_FIELD(87, 90, 0xc70, 0x10, 0, 1),
268 {91, 102, 0xb70, 0x10, 18, 1}, 112 PIN_FIELD(91, 102, 0xb70, 0x10, 18, 1),
269}; 113};
270 114
271static const struct mtk_pin_field_calc mt7622_pin_tdsel_range[] = { 115static const struct mtk_pin_field_calc mt7622_pin_tdsel_range[] = {
272 {0, 31, 0x980, 0x4, 0, 4}, 116 PIN_FIELD(0, 31, 0x980, 0x4, 0, 4),
273 {32, 50, 0xa80, 0x4, 0, 4}, 117 PIN_FIELD(32, 50, 0xa80, 0x4, 0, 4),
274 {51, 70, 0x880, 0x4, 0, 4}, 118 PIN_FIELD(51, 70, 0x880, 0x4, 0, 4),
275 {71, 72, 0xb80, 0x4, 0, 4}, 119 PIN_FIELD(71, 72, 0xb80, 0x4, 0, 4),
276 {73, 86, 0xb80, 0x4, 16, 4}, 120 PIN_FIELD(73, 86, 0xb80, 0x4, 16, 4),
277 {87, 90, 0xc80, 0x4, 0, 4}, 121 PIN_FIELD(87, 90, 0xc80, 0x4, 0, 4),
278 {91, 102, 0xb88, 0x4, 8, 4}, 122 PIN_FIELD(91, 102, 0xb88, 0x4, 8, 4),
279}; 123};
280 124
281static const struct mtk_pin_field_calc mt7622_pin_rdsel_range[] = { 125static const struct mtk_pin_field_calc mt7622_pin_rdsel_range[] = {
282 {0, 31, 0x990, 0x4, 0, 6}, 126 PIN_FIELD(0, 31, 0x990, 0x4, 0, 6),
283 {32, 50, 0xa90, 0x4, 0, 6}, 127 PIN_FIELD(32, 50, 0xa90, 0x4, 0, 6),
284 {51, 58, 0x890, 0x4, 0, 6}, 128 PIN_FIELD(51, 58, 0x890, 0x4, 0, 6),
285 {59, 60, 0x894, 0x4, 28, 6}, 129 PIN_FIELD(59, 60, 0x894, 0x4, 28, 6),
286 {61, 62, 0x894, 0x4, 16, 6}, 130 PIN_FIELD(61, 62, 0x894, 0x4, 16, 6),
287 {63, 66, 0x898, 0x4, 8, 6}, 131 PIN_FIELD(63, 66, 0x898, 0x4, 8, 6),
288 {67, 68, 0x89c, 0x4, 12, 6}, 132 PIN_FIELD(67, 68, 0x89c, 0x4, 12, 6),
289 {69, 70, 0x89c, 0x4, 0, 6}, 133 PIN_FIELD(69, 70, 0x89c, 0x4, 0, 6),
290 {71, 72, 0xb90, 0x4, 0, 6}, 134 PIN_FIELD(71, 72, 0xb90, 0x4, 0, 6),
291 {73, 86, 0xb90, 0x4, 24, 6}, 135 PIN_FIELD(73, 86, 0xb90, 0x4, 24, 6),
292 {87, 90, 0xc90, 0x4, 0, 6}, 136 PIN_FIELD(87, 90, 0xc90, 0x4, 0, 6),
293 {91, 102, 0xb9c, 0x4, 12, 6}, 137 PIN_FIELD(91, 102, 0xb9c, 0x4, 12, 6),
294}; 138};
295 139
296static const struct mtk_pin_reg_calc mt7622_reg_cals[PINCTRL_PIN_REG_MAX] = { 140static const struct mtk_pin_reg_calc mt7622_reg_cals[PINCTRL_PIN_REG_MAX] = {
@@ -308,110 +152,110 @@ static const struct mtk_pin_reg_calc mt7622_reg_cals[PINCTRL_PIN_REG_MAX] = {
308 [PINCTRL_PIN_REG_RDSEL] = MTK_RANGE(mt7622_pin_rdsel_range), 152 [PINCTRL_PIN_REG_RDSEL] = MTK_RANGE(mt7622_pin_rdsel_range),
309}; 153};
310 154
311static const struct pinctrl_pin_desc mt7622_pins[] = { 155static const struct mtk_pin_desc mt7622_pins[] = {
312 PINCTRL_PIN(0, "GPIO_A"), 156 MT7622_PIN(0, "GPIO_A"),
313 PINCTRL_PIN(1, "I2S1_IN"), 157 MT7622_PIN(1, "I2S1_IN"),
314 PINCTRL_PIN(2, "I2S1_OUT"), 158 MT7622_PIN(2, "I2S1_OUT"),
315 PINCTRL_PIN(3, "I2S_BCLK"), 159 MT7622_PIN(3, "I2S_BCLK"),
316 PINCTRL_PIN(4, "I2S_WS"), 160 MT7622_PIN(4, "I2S_WS"),
317 PINCTRL_PIN(5, "I2S_MCLK"), 161 MT7622_PIN(5, "I2S_MCLK"),
318 PINCTRL_PIN(6, "TXD0"), 162 MT7622_PIN(6, "TXD0"),
319 PINCTRL_PIN(7, "RXD0"), 163 MT7622_PIN(7, "RXD0"),
320 PINCTRL_PIN(8, "SPI_WP"), 164 MT7622_PIN(8, "SPI_WP"),
321 PINCTRL_PIN(9, "SPI_HOLD"), 165 MT7622_PIN(9, "SPI_HOLD"),
322 PINCTRL_PIN(10, "SPI_CLK"), 166 MT7622_PIN(10, "SPI_CLK"),
323 PINCTRL_PIN(11, "SPI_MOSI"), 167 MT7622_PIN(11, "SPI_MOSI"),
324 PINCTRL_PIN(12, "SPI_MISO"), 168 MT7622_PIN(12, "SPI_MISO"),
325 PINCTRL_PIN(13, "SPI_CS"), 169 MT7622_PIN(13, "SPI_CS"),
326 PINCTRL_PIN(14, "I2C_SDA"), 170 MT7622_PIN(14, "I2C_SDA"),
327 PINCTRL_PIN(15, "I2C_SCL"), 171 MT7622_PIN(15, "I2C_SCL"),
328 PINCTRL_PIN(16, "I2S2_IN"), 172 MT7622_PIN(16, "I2S2_IN"),
329 PINCTRL_PIN(17, "I2S3_IN"), 173 MT7622_PIN(17, "I2S3_IN"),
330 PINCTRL_PIN(18, "I2S4_IN"), 174 MT7622_PIN(18, "I2S4_IN"),
331 PINCTRL_PIN(19, "I2S2_OUT"), 175 MT7622_PIN(19, "I2S2_OUT"),
332 PINCTRL_PIN(20, "I2S3_OUT"), 176 MT7622_PIN(20, "I2S3_OUT"),
333 PINCTRL_PIN(21, "I2S4_OUT"), 177 MT7622_PIN(21, "I2S4_OUT"),
334 PINCTRL_PIN(22, "GPIO_B"), 178 MT7622_PIN(22, "GPIO_B"),
335 PINCTRL_PIN(23, "MDC"), 179 MT7622_PIN(23, "MDC"),
336 PINCTRL_PIN(24, "MDIO"), 180 MT7622_PIN(24, "MDIO"),
337 PINCTRL_PIN(25, "G2_TXD0"), 181 MT7622_PIN(25, "G2_TXD0"),
338 PINCTRL_PIN(26, "G2_TXD1"), 182 MT7622_PIN(26, "G2_TXD1"),
339 PINCTRL_PIN(27, "G2_TXD2"), 183 MT7622_PIN(27, "G2_TXD2"),
340 PINCTRL_PIN(28, "G2_TXD3"), 184 MT7622_PIN(28, "G2_TXD3"),
341 PINCTRL_PIN(29, "G2_TXEN"), 185 MT7622_PIN(29, "G2_TXEN"),
342 PINCTRL_PIN(30, "G2_TXC"), 186 MT7622_PIN(30, "G2_TXC"),
343 PINCTRL_PIN(31, "G2_RXD0"), 187 MT7622_PIN(31, "G2_RXD0"),
344 PINCTRL_PIN(32, "G2_RXD1"), 188 MT7622_PIN(32, "G2_RXD1"),
345 PINCTRL_PIN(33, "G2_RXD2"), 189 MT7622_PIN(33, "G2_RXD2"),
346 PINCTRL_PIN(34, "G2_RXD3"), 190 MT7622_PIN(34, "G2_RXD3"),
347 PINCTRL_PIN(35, "G2_RXDV"), 191 MT7622_PIN(35, "G2_RXDV"),
348 PINCTRL_PIN(36, "G2_RXC"), 192 MT7622_PIN(36, "G2_RXC"),
349 PINCTRL_PIN(37, "NCEB"), 193 MT7622_PIN(37, "NCEB"),
350 PINCTRL_PIN(38, "NWEB"), 194 MT7622_PIN(38, "NWEB"),
351 PINCTRL_PIN(39, "NREB"), 195 MT7622_PIN(39, "NREB"),
352 PINCTRL_PIN(40, "NDL4"), 196 MT7622_PIN(40, "NDL4"),
353 PINCTRL_PIN(41, "NDL5"), 197 MT7622_PIN(41, "NDL5"),
354 PINCTRL_PIN(42, "NDL6"), 198 MT7622_PIN(42, "NDL6"),
355 PINCTRL_PIN(43, "NDL7"), 199 MT7622_PIN(43, "NDL7"),
356 PINCTRL_PIN(44, "NRB"), 200 MT7622_PIN(44, "NRB"),
357 PINCTRL_PIN(45, "NCLE"), 201 MT7622_PIN(45, "NCLE"),
358 PINCTRL_PIN(46, "NALE"), 202 MT7622_PIN(46, "NALE"),
359 PINCTRL_PIN(47, "NDL0"), 203 MT7622_PIN(47, "NDL0"),
360 PINCTRL_PIN(48, "NDL1"), 204 MT7622_PIN(48, "NDL1"),
361 PINCTRL_PIN(49, "NDL2"), 205 MT7622_PIN(49, "NDL2"),
362 PINCTRL_PIN(50, "NDL3"), 206 MT7622_PIN(50, "NDL3"),
363 PINCTRL_PIN(51, "MDI_TP_P0"), 207 MT7622_PIN(51, "MDI_TP_P0"),
364 PINCTRL_PIN(52, "MDI_TN_P0"), 208 MT7622_PIN(52, "MDI_TN_P0"),
365 PINCTRL_PIN(53, "MDI_RP_P0"), 209 MT7622_PIN(53, "MDI_RP_P0"),
366 PINCTRL_PIN(54, "MDI_RN_P0"), 210 MT7622_PIN(54, "MDI_RN_P0"),
367 PINCTRL_PIN(55, "MDI_TP_P1"), 211 MT7622_PIN(55, "MDI_TP_P1"),
368 PINCTRL_PIN(56, "MDI_TN_P1"), 212 MT7622_PIN(56, "MDI_TN_P1"),
369 PINCTRL_PIN(57, "MDI_RP_P1"), 213 MT7622_PIN(57, "MDI_RP_P1"),
370 PINCTRL_PIN(58, "MDI_RN_P1"), 214 MT7622_PIN(58, "MDI_RN_P1"),
371 PINCTRL_PIN(59, "MDI_RP_P2"), 215 MT7622_PIN(59, "MDI_RP_P2"),
372 PINCTRL_PIN(60, "MDI_RN_P2"), 216 MT7622_PIN(60, "MDI_RN_P2"),
373 PINCTRL_PIN(61, "MDI_TP_P2"), 217 MT7622_PIN(61, "MDI_TP_P2"),
374 PINCTRL_PIN(62, "MDI_TN_P2"), 218 MT7622_PIN(62, "MDI_TN_P2"),
375 PINCTRL_PIN(63, "MDI_TP_P3"), 219 MT7622_PIN(63, "MDI_TP_P3"),
376 PINCTRL_PIN(64, "MDI_TN_P3"), 220 MT7622_PIN(64, "MDI_TN_P3"),
377 PINCTRL_PIN(65, "MDI_RP_P3"), 221 MT7622_PIN(65, "MDI_RP_P3"),
378 PINCTRL_PIN(66, "MDI_RN_P3"), 222 MT7622_PIN(66, "MDI_RN_P3"),
379 PINCTRL_PIN(67, "MDI_RP_P4"), 223 MT7622_PIN(67, "MDI_RP_P4"),
380 PINCTRL_PIN(68, "MDI_RN_P4"), 224 MT7622_PIN(68, "MDI_RN_P4"),
381 PINCTRL_PIN(69, "MDI_TP_P4"), 225 MT7622_PIN(69, "MDI_TP_P4"),
382 PINCTRL_PIN(70, "MDI_TN_P4"), 226 MT7622_PIN(70, "MDI_TN_P4"),
383 PINCTRL_PIN(71, "PMIC_SCL"), 227 MT7622_PIN(71, "PMIC_SCL"),
384 PINCTRL_PIN(72, "PMIC_SDA"), 228 MT7622_PIN(72, "PMIC_SDA"),
385 PINCTRL_PIN(73, "SPIC1_CLK"), 229 MT7622_PIN(73, "SPIC1_CLK"),
386 PINCTRL_PIN(74, "SPIC1_MOSI"), 230 MT7622_PIN(74, "SPIC1_MOSI"),
387 PINCTRL_PIN(75, "SPIC1_MISO"), 231 MT7622_PIN(75, "SPIC1_MISO"),
388 PINCTRL_PIN(76, "SPIC1_CS"), 232 MT7622_PIN(76, "SPIC1_CS"),
389 PINCTRL_PIN(77, "GPIO_D"), 233 MT7622_PIN(77, "GPIO_D"),
390 PINCTRL_PIN(78, "WATCHDOG"), 234 MT7622_PIN(78, "WATCHDOG"),
391 PINCTRL_PIN(79, "RTS3_N"), 235 MT7622_PIN(79, "RTS3_N"),
392 PINCTRL_PIN(80, "CTS3_N"), 236 MT7622_PIN(80, "CTS3_N"),
393 PINCTRL_PIN(81, "TXD3"), 237 MT7622_PIN(81, "TXD3"),
394 PINCTRL_PIN(82, "RXD3"), 238 MT7622_PIN(82, "RXD3"),
395 PINCTRL_PIN(83, "PERST0_N"), 239 MT7622_PIN(83, "PERST0_N"),
396 PINCTRL_PIN(84, "PERST1_N"), 240 MT7622_PIN(84, "PERST1_N"),
397 PINCTRL_PIN(85, "WLED_N"), 241 MT7622_PIN(85, "WLED_N"),
398 PINCTRL_PIN(86, "EPHY_LED0_N"), 242 MT7622_PIN(86, "EPHY_LED0_N"),
399 PINCTRL_PIN(87, "AUXIN0"), 243 MT7622_PIN(87, "AUXIN0"),
400 PINCTRL_PIN(88, "AUXIN1"), 244 MT7622_PIN(88, "AUXIN1"),
401 PINCTRL_PIN(89, "AUXIN2"), 245 MT7622_PIN(89, "AUXIN2"),
402 PINCTRL_PIN(90, "AUXIN3"), 246 MT7622_PIN(90, "AUXIN3"),
403 PINCTRL_PIN(91, "TXD4"), 247 MT7622_PIN(91, "TXD4"),
404 PINCTRL_PIN(92, "RXD4"), 248 MT7622_PIN(92, "RXD4"),
405 PINCTRL_PIN(93, "RTS4_N"), 249 MT7622_PIN(93, "RTS4_N"),
406 PINCTRL_PIN(94, "CTS4_N"), 250 MT7622_PIN(94, "CTS4_N"),
407 PINCTRL_PIN(95, "PWM1"), 251 MT7622_PIN(95, "PWM1"),
408 PINCTRL_PIN(96, "PWM2"), 252 MT7622_PIN(96, "PWM2"),
409 PINCTRL_PIN(97, "PWM3"), 253 MT7622_PIN(97, "PWM3"),
410 PINCTRL_PIN(98, "PWM4"), 254 MT7622_PIN(98, "PWM4"),
411 PINCTRL_PIN(99, "PWM5"), 255 MT7622_PIN(99, "PWM5"),
412 PINCTRL_PIN(100, "PWM6"), 256 MT7622_PIN(100, "PWM6"),
413 PINCTRL_PIN(101, "PWM7"), 257 MT7622_PIN(101, "PWM7"),
414 PINCTRL_PIN(102, "GPIO_E"), 258 MT7622_PIN(102, "GPIO_E"),
415}; 259};
416 260
417/* List all groups consisting of these pins dedicated to the enablement of 261/* List all groups consisting of these pins dedicated to the enablement of
@@ -905,18 +749,6 @@ static const struct function_desc mt7622_functions[] = {
905 {"watchdog", mt7622_wdt_groups, ARRAY_SIZE(mt7622_wdt_groups)}, 749 {"watchdog", mt7622_wdt_groups, ARRAY_SIZE(mt7622_wdt_groups)},
906}; 750};
907 751
908static const struct pinconf_generic_params mtk_custom_bindings[] = {
909 {"mediatek,tdsel", MTK_PIN_CONFIG_TDSEL, 0},
910 {"mediatek,rdsel", MTK_PIN_CONFIG_RDSEL, 0},
911};
912
913#ifdef CONFIG_DEBUG_FS
914static const struct pin_config_item mtk_conf_items[] = {
915 PCONFDUMP(MTK_PIN_CONFIG_TDSEL, "tdsel", NULL, true),
916 PCONFDUMP(MTK_PIN_CONFIG_RDSEL, "rdsel", NULL, true),
917};
918#endif
919
920static const struct mtk_eint_hw mt7622_eint_hw = { 752static const struct mtk_eint_hw mt7622_eint_hw = {
921 .port_mask = 7, 753 .port_mask = 7,
922 .ports = 7, 754 .ports = 7,
@@ -933,830 +765,38 @@ static const struct mtk_pin_soc mt7622_data = {
933 .funcs = mt7622_functions, 765 .funcs = mt7622_functions,
934 .nfuncs = ARRAY_SIZE(mt7622_functions), 766 .nfuncs = ARRAY_SIZE(mt7622_functions),
935 .eint_hw = &mt7622_eint_hw, 767 .eint_hw = &mt7622_eint_hw,
936}; 768 .gpio_m = 1,
937 769 .ies_present = false,
938static void mtk_w32(struct mtk_pinctrl *pctl, u32 reg, u32 val) 770 .base_names = mtk_default_register_base_names,
939{ 771 .nbase_names = ARRAY_SIZE(mtk_default_register_base_names),
940 writel_relaxed(val, pctl->base + reg); 772 .bias_disable_set = mtk_pinconf_bias_disable_set,
941} 773 .bias_disable_get = mtk_pinconf_bias_disable_get,
942 774 .bias_set = mtk_pinconf_bias_set,
943static u32 mtk_r32(struct mtk_pinctrl *pctl, u32 reg) 775 .bias_get = mtk_pinconf_bias_get,
944{ 776 .drive_set = mtk_pinconf_drive_set,
945 return readl_relaxed(pctl->base + reg); 777 .drive_get = mtk_pinconf_drive_get,
946} 778};
947 779
948static void mtk_rmw(struct mtk_pinctrl *pctl, u32 reg, u32 mask, u32 set) 780static const struct of_device_id mt7622_pinctrl_of_match[] = {
949{ 781 { .compatible = "mediatek,mt7622-pinctrl", },
950 u32 val;
951
952 val = mtk_r32(pctl, reg);
953 val &= ~mask;
954 val |= set;
955 mtk_w32(pctl, reg, val);
956}
957
958static int mtk_hw_pin_field_lookup(struct mtk_pinctrl *hw, int pin,
959 const struct mtk_pin_reg_calc *rc,
960 struct mtk_pin_field *pfd)
961{
962 const struct mtk_pin_field_calc *c, *e;
963 u32 bits;
964
965 c = rc->range;
966 e = c + rc->nranges;
967
968 while (c < e) {
969 if (pin >= c->s_pin && pin <= c->e_pin)
970 break;
971 c++;
972 }
973
974 if (c >= e) {
975 dev_err(hw->dev, "Out of range for pin = %d\n", pin);
976 return -EINVAL;
977 }
978
979 /* Caculated bits as the overall offset the pin is located at */
980 bits = c->s_bit + (pin - c->s_pin) * (c->x_bits);
981
982 /* Fill pfd from bits and 32-bit register applied is assumed */
983 pfd->offset = c->s_addr + c->x_addrs * (bits / 32);
984 pfd->bitpos = bits % 32;
985 pfd->mask = (1 << c->x_bits) - 1;
986
987 /* pfd->next is used for indicating that bit wrapping-around happens
988 * which requires the manipulation for bit 0 starting in the next
989 * register to form the complete field read/write.
990 */
991 pfd->next = pfd->bitpos + c->x_bits - 1 > 31 ? c->x_addrs : 0;
992
993 return 0;
994}
995
996static int mtk_hw_pin_field_get(struct mtk_pinctrl *hw, int pin,
997 int field, struct mtk_pin_field *pfd)
998{
999 const struct mtk_pin_reg_calc *rc;
1000
1001 if (field < 0 || field >= PINCTRL_PIN_REG_MAX) {
1002 dev_err(hw->dev, "Invalid Field %d\n", field);
1003 return -EINVAL;
1004 }
1005
1006 if (hw->soc->reg_cal && hw->soc->reg_cal[field].range) {
1007 rc = &hw->soc->reg_cal[field];
1008 } else {
1009 dev_err(hw->dev, "Undefined range for field %d\n", field);
1010 return -EINVAL;
1011 }
1012
1013 return mtk_hw_pin_field_lookup(hw, pin, rc, pfd);
1014}
1015
1016static void mtk_hw_bits_part(struct mtk_pin_field *pf, int *h, int *l)
1017{
1018 *l = 32 - pf->bitpos;
1019 *h = get_count_order(pf->mask) - *l;
1020}
1021
1022static void mtk_hw_write_cross_field(struct mtk_pinctrl *hw,
1023 struct mtk_pin_field *pf, int value)
1024{
1025 int nbits_l, nbits_h;
1026
1027 mtk_hw_bits_part(pf, &nbits_h, &nbits_l);
1028
1029 mtk_rmw(hw, pf->offset, pf->mask << pf->bitpos,
1030 (value & pf->mask) << pf->bitpos);
1031
1032 mtk_rmw(hw, pf->offset + pf->next, BIT(nbits_h) - 1,
1033 (value & pf->mask) >> nbits_l);
1034}
1035
1036static void mtk_hw_read_cross_field(struct mtk_pinctrl *hw,
1037 struct mtk_pin_field *pf, int *value)
1038{
1039 int nbits_l, nbits_h, h, l;
1040
1041 mtk_hw_bits_part(pf, &nbits_h, &nbits_l);
1042
1043 l = (mtk_r32(hw, pf->offset) >> pf->bitpos) & (BIT(nbits_l) - 1);
1044 h = (mtk_r32(hw, pf->offset + pf->next)) & (BIT(nbits_h) - 1);
1045
1046 *value = (h << nbits_l) | l;
1047}
1048
1049static int mtk_hw_set_value(struct mtk_pinctrl *hw, int pin, int field,
1050 int value)
1051{
1052 struct mtk_pin_field pf;
1053 int err;
1054
1055 err = mtk_hw_pin_field_get(hw, pin, field, &pf);
1056 if (err)
1057 return err;
1058
1059 if (!pf.next)
1060 mtk_rmw(hw, pf.offset, pf.mask << pf.bitpos,
1061 (value & pf.mask) << pf.bitpos);
1062 else
1063 mtk_hw_write_cross_field(hw, &pf, value);
1064
1065 return 0;
1066}
1067
1068static int mtk_hw_get_value(struct mtk_pinctrl *hw, int pin, int field,
1069 int *value)
1070{
1071 struct mtk_pin_field pf;
1072 int err;
1073
1074 err = mtk_hw_pin_field_get(hw, pin, field, &pf);
1075 if (err)
1076 return err;
1077
1078 if (!pf.next)
1079 *value = (mtk_r32(hw, pf.offset) >> pf.bitpos) & pf.mask;
1080 else
1081 mtk_hw_read_cross_field(hw, &pf, value);
1082
1083 return 0;
1084}
1085
1086static int mtk_pinmux_set_mux(struct pinctrl_dev *pctldev,
1087 unsigned int selector, unsigned int group)
1088{
1089 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
1090 struct function_desc *func;
1091 struct group_desc *grp;
1092 int i;
1093
1094 func = pinmux_generic_get_function(pctldev, selector);
1095 if (!func)
1096 return -EINVAL;
1097
1098 grp = pinctrl_generic_get_group(pctldev, group);
1099 if (!grp)
1100 return -EINVAL;
1101
1102 dev_dbg(pctldev->dev, "enable function %s group %s\n",
1103 func->name, grp->name);
1104
1105 for (i = 0; i < grp->num_pins; i++) {
1106 int *pin_modes = grp->data;
1107
1108 mtk_hw_set_value(hw, grp->pins[i], PINCTRL_PIN_REG_MODE,
1109 pin_modes[i]);
1110 }
1111
1112 return 0;
1113}
1114
1115static int mtk_pinmux_gpio_request_enable(struct pinctrl_dev *pctldev,
1116 struct pinctrl_gpio_range *range,
1117 unsigned int pin)
1118{
1119 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
1120
1121 return mtk_hw_set_value(hw, pin, PINCTRL_PIN_REG_MODE, MTK_GPIO_MODE);
1122}
1123
1124static int mtk_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
1125 struct pinctrl_gpio_range *range,
1126 unsigned int pin, bool input)
1127{
1128 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
1129
1130 /* hardware would take 0 as input direction */
1131 return mtk_hw_set_value(hw, pin, PINCTRL_PIN_REG_DIR, !input);
1132}
1133
1134static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
1135 unsigned int pin, unsigned long *config)
1136{
1137 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
1138 u32 param = pinconf_to_config_param(*config);
1139 int val, val2, err, reg, ret = 1;
1140
1141 switch (param) {
1142 case PIN_CONFIG_BIAS_DISABLE:
1143 err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_PU, &val);
1144 if (err)
1145 return err;
1146
1147 err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_PD, &val2);
1148 if (err)
1149 return err;
1150
1151 if (val || val2)
1152 return -EINVAL;
1153
1154 break;
1155 case PIN_CONFIG_BIAS_PULL_UP:
1156 case PIN_CONFIG_BIAS_PULL_DOWN:
1157 case PIN_CONFIG_SLEW_RATE:
1158 reg = (param == PIN_CONFIG_BIAS_PULL_UP) ?
1159 PINCTRL_PIN_REG_PU :
1160 (param == PIN_CONFIG_BIAS_PULL_DOWN) ?
1161 PINCTRL_PIN_REG_PD : PINCTRL_PIN_REG_SR;
1162
1163 err = mtk_hw_get_value(hw, pin, reg, &val);
1164 if (err)
1165 return err;
1166
1167 if (!val)
1168 return -EINVAL;
1169
1170 break;
1171 case PIN_CONFIG_INPUT_ENABLE:
1172 case PIN_CONFIG_OUTPUT_ENABLE:
1173 err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_DIR, &val);
1174 if (err)
1175 return err;
1176
1177 /* HW takes input mode as zero; output mode as non-zero */
1178 if ((val && param == PIN_CONFIG_INPUT_ENABLE) ||
1179 (!val && param == PIN_CONFIG_OUTPUT_ENABLE))
1180 return -EINVAL;
1181
1182 break;
1183 case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
1184 err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_DIR, &val);
1185 if (err)
1186 return err;
1187
1188 err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_SMT, &val2);
1189 if (err)
1190 return err;
1191
1192 if (val || !val2)
1193 return -EINVAL;
1194
1195 break;
1196 case PIN_CONFIG_DRIVE_STRENGTH:
1197 err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_E4, &val);
1198 if (err)
1199 return err;
1200
1201 err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_E8, &val2);
1202 if (err)
1203 return err;
1204
1205 /* 4mA when (e8, e4) = (0, 0); 8mA when (e8, e4) = (0, 1)
1206 * 12mA when (e8, e4) = (1, 0); 16mA when (e8, e4) = (1, 1)
1207 */
1208 ret = ((val2 << 1) + val + 1) * 4;
1209
1210 break;
1211 case MTK_PIN_CONFIG_TDSEL:
1212 case MTK_PIN_CONFIG_RDSEL:
1213 reg = (param == MTK_PIN_CONFIG_TDSEL) ?
1214 PINCTRL_PIN_REG_TDSEL : PINCTRL_PIN_REG_RDSEL;
1215
1216 err = mtk_hw_get_value(hw, pin, reg, &val);
1217 if (err)
1218 return err;
1219
1220 ret = val;
1221
1222 break;
1223 default:
1224 return -ENOTSUPP;
1225 }
1226
1227 *config = pinconf_to_config_packed(param, ret);
1228
1229 return 0;
1230}
1231
1232static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
1233 unsigned long *configs, unsigned int num_configs)
1234{
1235 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
1236 u32 reg, param, arg;
1237 int cfg, err = 0;
1238
1239 for (cfg = 0; cfg < num_configs; cfg++) {
1240 param = pinconf_to_config_param(configs[cfg]);
1241 arg = pinconf_to_config_argument(configs[cfg]);
1242
1243 switch (param) {
1244 case PIN_CONFIG_BIAS_DISABLE:
1245 case PIN_CONFIG_BIAS_PULL_UP:
1246 case PIN_CONFIG_BIAS_PULL_DOWN:
1247 arg = (param == PIN_CONFIG_BIAS_DISABLE) ? 0 :
1248 (param == PIN_CONFIG_BIAS_PULL_UP) ? 1 : 2;
1249
1250 err = mtk_hw_set_value(hw, pin, PINCTRL_PIN_REG_PU,
1251 arg & 1);
1252 if (err)
1253 goto err;
1254
1255 err = mtk_hw_set_value(hw, pin, PINCTRL_PIN_REG_PD,
1256 !!(arg & 2));
1257 if (err)
1258 goto err;
1259 break;
1260 case PIN_CONFIG_OUTPUT_ENABLE:
1261 err = mtk_hw_set_value(hw, pin, PINCTRL_PIN_REG_SMT,
1262 MTK_DISABLE);
1263 if (err)
1264 goto err;
1265 /* else: fall through */
1266 case PIN_CONFIG_INPUT_ENABLE:
1267 case PIN_CONFIG_SLEW_RATE:
1268 reg = (param == PIN_CONFIG_SLEW_RATE) ?
1269 PINCTRL_PIN_REG_SR : PINCTRL_PIN_REG_DIR;
1270
1271 arg = (param == PIN_CONFIG_INPUT_ENABLE) ? 0 :
1272 (param == PIN_CONFIG_OUTPUT_ENABLE) ? 1 : arg;
1273 err = mtk_hw_set_value(hw, pin, reg, arg);
1274 if (err)
1275 goto err;
1276
1277 break;
1278 case PIN_CONFIG_OUTPUT:
1279 err = mtk_hw_set_value(hw, pin, PINCTRL_PIN_REG_DIR,
1280 MTK_OUTPUT);
1281 if (err)
1282 goto err;
1283
1284 err = mtk_hw_set_value(hw, pin, PINCTRL_PIN_REG_DO,
1285 arg);
1286 if (err)
1287 goto err;
1288 break;
1289 case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
1290 /* arg = 1: Input mode & SMT enable ;
1291 * arg = 0: Output mode & SMT disable
1292 */
1293 arg = arg ? 2 : 1;
1294 err = mtk_hw_set_value(hw, pin, PINCTRL_PIN_REG_DIR,
1295 arg & 1);
1296 if (err)
1297 goto err;
1298
1299 err = mtk_hw_set_value(hw, pin, PINCTRL_PIN_REG_SMT,
1300 !!(arg & 2));
1301 if (err)
1302 goto err;
1303 break;
1304 case PIN_CONFIG_DRIVE_STRENGTH:
1305 /* 4mA when (e8, e4) = (0, 0);
1306 * 8mA when (e8, e4) = (0, 1);
1307 * 12mA when (e8, e4) = (1, 0);
1308 * 16mA when (e8, e4) = (1, 1)
1309 */
1310 if (!(arg % 4) && (arg >= 4 && arg <= 16)) {
1311 arg = arg / 4 - 1;
1312 err = mtk_hw_set_value(hw, pin,
1313 PINCTRL_PIN_REG_E4,
1314 arg & 0x1);
1315 if (err)
1316 goto err;
1317
1318 err = mtk_hw_set_value(hw, pin,
1319 PINCTRL_PIN_REG_E8,
1320 (arg & 0x2) >> 1);
1321 if (err)
1322 goto err;
1323 } else {
1324 err = -ENOTSUPP;
1325 }
1326 break;
1327 case MTK_PIN_CONFIG_TDSEL:
1328 case MTK_PIN_CONFIG_RDSEL:
1329 reg = (param == MTK_PIN_CONFIG_TDSEL) ?
1330 PINCTRL_PIN_REG_TDSEL : PINCTRL_PIN_REG_RDSEL;
1331
1332 err = mtk_hw_set_value(hw, pin, reg, arg);
1333 if (err)
1334 goto err;
1335 break;
1336 default:
1337 err = -ENOTSUPP;
1338 }
1339 }
1340err:
1341 return err;
1342}
1343
1344static int mtk_pinconf_group_get(struct pinctrl_dev *pctldev,
1345 unsigned int group, unsigned long *config)
1346{
1347 const unsigned int *pins;
1348 unsigned int i, npins, old = 0;
1349 int ret;
1350
1351 ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins);
1352 if (ret)
1353 return ret;
1354
1355 for (i = 0; i < npins; i++) {
1356 if (mtk_pinconf_get(pctldev, pins[i], config))
1357 return -ENOTSUPP;
1358
1359 /* configs do not match between two pins */
1360 if (i && old != *config)
1361 return -ENOTSUPP;
1362
1363 old = *config;
1364 }
1365
1366 return 0;
1367}
1368
1369static int mtk_pinconf_group_set(struct pinctrl_dev *pctldev,
1370 unsigned int group, unsigned long *configs,
1371 unsigned int num_configs)
1372{
1373 const unsigned int *pins;
1374 unsigned int i, npins;
1375 int ret;
1376
1377 ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins);
1378 if (ret)
1379 return ret;
1380
1381 for (i = 0; i < npins; i++) {
1382 ret = mtk_pinconf_set(pctldev, pins[i], configs, num_configs);
1383 if (ret)
1384 return ret;
1385 }
1386
1387 return 0;
1388}
1389
1390static const struct pinctrl_ops mtk_pctlops = {
1391 .get_groups_count = pinctrl_generic_get_group_count,
1392 .get_group_name = pinctrl_generic_get_group_name,
1393 .get_group_pins = pinctrl_generic_get_group_pins,
1394 .dt_node_to_map = pinconf_generic_dt_node_to_map_all,
1395 .dt_free_map = pinconf_generic_dt_free_map,
1396};
1397
1398static const struct pinmux_ops mtk_pmxops = {
1399 .get_functions_count = pinmux_generic_get_function_count,
1400 .get_function_name = pinmux_generic_get_function_name,
1401 .get_function_groups = pinmux_generic_get_function_groups,
1402 .set_mux = mtk_pinmux_set_mux,
1403 .gpio_request_enable = mtk_pinmux_gpio_request_enable,
1404 .gpio_set_direction = mtk_pinmux_gpio_set_direction,
1405 .strict = true,
1406};
1407
1408static const struct pinconf_ops mtk_confops = {
1409 .is_generic = true,
1410 .pin_config_get = mtk_pinconf_get,
1411 .pin_config_set = mtk_pinconf_set,
1412 .pin_config_group_get = mtk_pinconf_group_get,
1413 .pin_config_group_set = mtk_pinconf_group_set,
1414 .pin_config_config_dbg_show = pinconf_generic_dump_config,
1415};
1416
1417static struct pinctrl_desc mtk_desc = {
1418 .name = PINCTRL_PINCTRL_DEV,
1419 .pctlops = &mtk_pctlops,
1420 .pmxops = &mtk_pmxops,
1421 .confops = &mtk_confops,
1422 .owner = THIS_MODULE,
1423};
1424
1425static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio)
1426{
1427 struct mtk_pinctrl *hw = gpiochip_get_data(chip);
1428 int value, err;
1429
1430 err = mtk_hw_get_value(hw, gpio, PINCTRL_PIN_REG_DI, &value);
1431 if (err)
1432 return err;
1433
1434 return !!value;
1435}
1436
1437static void mtk_gpio_set(struct gpio_chip *chip, unsigned int gpio, int value)
1438{
1439 struct mtk_pinctrl *hw = gpiochip_get_data(chip);
1440
1441 mtk_hw_set_value(hw, gpio, PINCTRL_PIN_REG_DO, !!value);
1442}
1443
1444static int mtk_gpio_direction_input(struct gpio_chip *chip, unsigned int gpio)
1445{
1446 return pinctrl_gpio_direction_input(chip->base + gpio);
1447}
1448
1449static int mtk_gpio_direction_output(struct gpio_chip *chip, unsigned int gpio,
1450 int value)
1451{
1452 mtk_gpio_set(chip, gpio, value);
1453
1454 return pinctrl_gpio_direction_output(chip->base + gpio);
1455}
1456
1457static int mtk_gpio_to_irq(struct gpio_chip *chip, unsigned int offset)
1458{
1459 struct mtk_pinctrl *hw = gpiochip_get_data(chip);
1460 unsigned long eint_n;
1461
1462 if (!hw->eint)
1463 return -ENOTSUPP;
1464
1465 eint_n = offset;
1466
1467 return mtk_eint_find_irq(hw->eint, eint_n);
1468}
1469
1470static int mtk_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
1471 unsigned long config)
1472{
1473 struct mtk_pinctrl *hw = gpiochip_get_data(chip);
1474 unsigned long eint_n;
1475 u32 debounce;
1476
1477 if (!hw->eint ||
1478 pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE)
1479 return -ENOTSUPP;
1480
1481 debounce = pinconf_to_config_argument(config);
1482 eint_n = offset;
1483
1484 return mtk_eint_set_debounce(hw->eint, eint_n, debounce);
1485}
1486
1487static int mtk_build_gpiochip(struct mtk_pinctrl *hw, struct device_node *np)
1488{
1489 struct gpio_chip *chip = &hw->chip;
1490 int ret;
1491
1492 chip->label = PINCTRL_PINCTRL_DEV;
1493 chip->parent = hw->dev;
1494 chip->request = gpiochip_generic_request;
1495 chip->free = gpiochip_generic_free;
1496 chip->direction_input = mtk_gpio_direction_input;
1497 chip->direction_output = mtk_gpio_direction_output;
1498 chip->get = mtk_gpio_get;
1499 chip->set = mtk_gpio_set;
1500 chip->to_irq = mtk_gpio_to_irq,
1501 chip->set_config = mtk_gpio_set_config,
1502 chip->base = -1;
1503 chip->ngpio = hw->soc->npins;
1504 chip->of_node = np;
1505 chip->of_gpio_n_cells = 2;
1506
1507 ret = gpiochip_add_data(chip, hw);
1508 if (ret < 0)
1509 return ret;
1510
1511 /* Just for backward compatible for these old pinctrl nodes without
1512 * "gpio-ranges" property. Otherwise, called directly from a
1513 * DeviceTree-supported pinctrl driver is DEPRECATED.
1514 * Please see Section 2.1 of
1515 * Documentation/devicetree/bindings/gpio/gpio.txt on how to
1516 * bind pinctrl and gpio drivers via the "gpio-ranges" property.
1517 */
1518 if (!of_find_property(np, "gpio-ranges", NULL)) {
1519 ret = gpiochip_add_pin_range(chip, dev_name(hw->dev), 0, 0,
1520 chip->ngpio);
1521 if (ret < 0) {
1522 gpiochip_remove(chip);
1523 return ret;
1524 }
1525 }
1526
1527 return 0;
1528}
1529
1530static int mtk_build_groups(struct mtk_pinctrl *hw)
1531{
1532 int err, i;
1533
1534 for (i = 0; i < hw->soc->ngrps; i++) {
1535 const struct group_desc *group = hw->soc->grps + i;
1536
1537 err = pinctrl_generic_add_group(hw->pctrl, group->name,
1538 group->pins, group->num_pins,
1539 group->data);
1540 if (err < 0) {
1541 dev_err(hw->dev, "Failed to register group %s\n",
1542 group->name);
1543 return err;
1544 }
1545 }
1546
1547 return 0;
1548}
1549
1550static int mtk_build_functions(struct mtk_pinctrl *hw)
1551{
1552 int i, err;
1553
1554 for (i = 0; i < hw->soc->nfuncs ; i++) {
1555 const struct function_desc *func = hw->soc->funcs + i;
1556
1557 err = pinmux_generic_add_function(hw->pctrl, func->name,
1558 func->group_names,
1559 func->num_group_names,
1560 func->data);
1561 if (err < 0) {
1562 dev_err(hw->dev, "Failed to register function %s\n",
1563 func->name);
1564 return err;
1565 }
1566 }
1567
1568 return 0;
1569}
1570
1571static int mtk_xt_get_gpio_n(void *data, unsigned long eint_n,
1572 unsigned int *gpio_n,
1573 struct gpio_chip **gpio_chip)
1574{
1575 struct mtk_pinctrl *hw = (struct mtk_pinctrl *)data;
1576
1577 *gpio_chip = &hw->chip;
1578 *gpio_n = eint_n;
1579
1580 return 0;
1581}
1582
1583static int mtk_xt_get_gpio_state(void *data, unsigned long eint_n)
1584{
1585 struct mtk_pinctrl *hw = (struct mtk_pinctrl *)data;
1586 struct gpio_chip *gpio_chip;
1587 unsigned int gpio_n;
1588 int err;
1589
1590 err = mtk_xt_get_gpio_n(hw, eint_n, &gpio_n, &gpio_chip);
1591 if (err)
1592 return err;
1593
1594 return mtk_gpio_get(gpio_chip, gpio_n);
1595}
1596
1597static int mtk_xt_set_gpio_as_eint(void *data, unsigned long eint_n)
1598{
1599 struct mtk_pinctrl *hw = (struct mtk_pinctrl *)data;
1600 struct gpio_chip *gpio_chip;
1601 unsigned int gpio_n;
1602 int err;
1603
1604 err = mtk_xt_get_gpio_n(hw, eint_n, &gpio_n, &gpio_chip);
1605 if (err)
1606 return err;
1607
1608 err = mtk_hw_set_value(hw, gpio_n, PINCTRL_PIN_REG_MODE,
1609 MTK_GPIO_MODE);
1610 if (err)
1611 return err;
1612
1613 err = mtk_hw_set_value(hw, gpio_n, PINCTRL_PIN_REG_DIR, MTK_INPUT);
1614 if (err)
1615 return err;
1616
1617 err = mtk_hw_set_value(hw, gpio_n, PINCTRL_PIN_REG_SMT, MTK_ENABLE);
1618 if (err)
1619 return err;
1620
1621 return 0;
1622}
1623
1624static const struct mtk_eint_xt mtk_eint_xt = {
1625 .get_gpio_n = mtk_xt_get_gpio_n,
1626 .get_gpio_state = mtk_xt_get_gpio_state,
1627 .set_gpio_as_eint = mtk_xt_set_gpio_as_eint,
1628};
1629
1630static int
1631mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev)
1632{
1633 struct device_node *np = pdev->dev.of_node;
1634 struct resource *res;
1635
1636 if (!IS_ENABLED(CONFIG_EINT_MTK))
1637 return 0;
1638
1639 if (!of_property_read_bool(np, "interrupt-controller"))
1640 return -ENODEV;
1641
1642 hw->eint = devm_kzalloc(hw->dev, sizeof(*hw->eint), GFP_KERNEL);
1643 if (!hw->eint)
1644 return -ENOMEM;
1645
1646 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "eint");
1647 if (!res) {
1648 dev_err(&pdev->dev, "Unable to get eint resource\n");
1649 return -ENODEV;
1650 }
1651
1652 hw->eint->base = devm_ioremap_resource(&pdev->dev, res);
1653 if (IS_ERR(hw->eint->base))
1654 return PTR_ERR(hw->eint->base);
1655
1656 hw->eint->irq = irq_of_parse_and_map(np, 0);
1657 if (!hw->eint->irq)
1658 return -EINVAL;
1659
1660 hw->eint->dev = &pdev->dev;
1661 hw->eint->hw = hw->soc->eint_hw;
1662 hw->eint->pctl = hw;
1663 hw->eint->gpio_xlate = &mtk_eint_xt;
1664
1665 return mtk_eint_do_init(hw->eint);
1666}
1667
1668static const struct of_device_id mtk_pinctrl_of_match[] = {
1669 { .compatible = "mediatek,mt7622-pinctrl", .data = &mt7622_data},
1670 { } 782 { }
1671}; 783};
1672 784
1673static int mtk_pinctrl_probe(struct platform_device *pdev) 785static int mt7622_pinctrl_probe(struct platform_device *pdev)
1674{ 786{
1675 struct resource *res; 787 return mtk_moore_pinctrl_probe(pdev, &mt7622_data);
1676 struct mtk_pinctrl *hw;
1677 const struct of_device_id *of_id =
1678 of_match_device(mtk_pinctrl_of_match, &pdev->dev);
1679 int err;
1680
1681 hw = devm_kzalloc(&pdev->dev, sizeof(*hw), GFP_KERNEL);
1682 if (!hw)
1683 return -ENOMEM;
1684
1685 hw->soc = of_id->data;
1686
1687 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1688 if (!res) {
1689 dev_err(&pdev->dev, "missing IO resource\n");
1690 return -ENXIO;
1691 }
1692
1693 hw->dev = &pdev->dev;
1694 hw->base = devm_ioremap_resource(&pdev->dev, res);
1695 if (IS_ERR(hw->base))
1696 return PTR_ERR(hw->base);
1697
1698 /* Setup pins descriptions per SoC types */
1699 mtk_desc.pins = hw->soc->pins;
1700 mtk_desc.npins = hw->soc->npins;
1701 mtk_desc.num_custom_params = ARRAY_SIZE(mtk_custom_bindings);
1702 mtk_desc.custom_params = mtk_custom_bindings;
1703#ifdef CONFIG_DEBUG_FS
1704 mtk_desc.custom_conf_items = mtk_conf_items;
1705#endif
1706
1707 err = devm_pinctrl_register_and_init(&pdev->dev, &mtk_desc, hw,
1708 &hw->pctrl);
1709 if (err)
1710 return err;
1711
1712 /* Setup groups descriptions per SoC types */
1713 err = mtk_build_groups(hw);
1714 if (err) {
1715 dev_err(&pdev->dev, "Failed to build groups\n");
1716 return err;
1717 }
1718
1719 /* Setup functions descriptions per SoC types */
1720 err = mtk_build_functions(hw);
1721 if (err) {
1722 dev_err(&pdev->dev, "Failed to build functions\n");
1723 return err;
1724 }
1725
1726 /* For able to make pinctrl_claim_hogs, we must not enable pinctrl
1727 * until all groups and functions are being added one.
1728 */
1729 err = pinctrl_enable(hw->pctrl);
1730 if (err)
1731 return err;
1732
1733 err = mtk_build_eint(hw, pdev);
1734 if (err)
1735 dev_warn(&pdev->dev,
1736 "Failed to add EINT, but pinctrl still can work\n");
1737
1738 /* Build gpiochip should be after pinctrl_enable is done */
1739 err = mtk_build_gpiochip(hw, pdev->dev.of_node);
1740 if (err) {
1741 dev_err(&pdev->dev, "Failed to add gpio_chip\n");
1742 return err;
1743 }
1744
1745 platform_set_drvdata(pdev, hw);
1746
1747 return 0;
1748} 788}
1749 789
1750static struct platform_driver mtk_pinctrl_driver = { 790static struct platform_driver mt7622_pinctrl_driver = {
1751 .driver = { 791 .driver = {
1752 .name = "mtk-pinctrl", 792 .name = "mt7622-pinctrl",
1753 .of_match_table = mtk_pinctrl_of_match, 793 .of_match_table = mt7622_pinctrl_of_match,
1754 }, 794 },
1755 .probe = mtk_pinctrl_probe, 795 .probe = mt7622_pinctrl_probe,
1756}; 796};
1757 797
1758static int __init mtk_pinctrl_init(void) 798static int __init mt7622_pinctrl_init(void)
1759{ 799{
1760 return platform_driver_register(&mtk_pinctrl_driver); 800 return platform_driver_register(&mt7622_pinctrl_driver);
1761} 801}
1762arch_initcall(mtk_pinctrl_init); 802arch_initcall(mt7622_pinctrl_init);
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7623.c b/drivers/pinctrl/mediatek/pinctrl-mt7623.c
new file mode 100644
index 000000000000..b8d9d31db74f
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7623.c
@@ -0,0 +1,1441 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * The MT7623 driver based on Linux generic pinctrl binding.
4 *
5 * Copyright (C) 2015 - 2018 MediaTek Inc.
6 * Author: Biao Huang <biao.huang@mediatek.com>
7 * Ryder Lee <ryder.lee@mediatek.com>
8 * Sean Wang <sean.wang@mediatek.com>
9 */
10
11#include "pinctrl-moore.h"
12
13#define PIN_BOND_REG0 0xb10
14#define PIN_BOND_REG1 0xf20
15#define PIN_BOND_REG2 0xef0
16#define BOND_PCIE_CLR (0x77 << 3)
17#define BOND_I2S_CLR 0x3
18#define BOND_MSDC0E_CLR 0x1
19
20#define PIN_FIELD15(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits) \
21 PIN_FIELD_CALC(_s_pin, _e_pin, 0, _s_addr, _x_addrs, _s_bit, \
22 _x_bits, 15, false)
23
24#define PIN_FIELD16(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits) \
25 PIN_FIELD_CALC(_s_pin, _e_pin, 0, _s_addr, _x_addrs, _s_bit, \
26 _x_bits, 16, 0)
27
28#define PINS_FIELD16(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits) \
29 PIN_FIELD_CALC(_s_pin, _e_pin, 0, _s_addr, _x_addrs, _s_bit, \
30 _x_bits, 16, 1)
31
32#define MT7623_PIN(_number, _name, _eint_n, _drv_grp) \
33 MTK_PIN(_number, _name, 0, _eint_n, _drv_grp)
34
35static const struct mtk_pin_field_calc mt7623_pin_mode_range[] = {
36 PIN_FIELD15(0, 278, 0x760, 0x10, 0, 3),
37};
38
39static const struct mtk_pin_field_calc mt7623_pin_dir_range[] = {
40 PIN_FIELD16(0, 175, 0x0, 0x10, 0, 1),
41 PIN_FIELD16(176, 278, 0xc0, 0x10, 0, 1),
42};
43
44static const struct mtk_pin_field_calc mt7623_pin_di_range[] = {
45 PIN_FIELD16(0, 278, 0x630, 0x10, 0, 1),
46};
47
48static const struct mtk_pin_field_calc mt7623_pin_do_range[] = {
49 PIN_FIELD16(0, 278, 0x500, 0x10, 0, 1),
50};
51
52static const struct mtk_pin_field_calc mt7623_pin_ies_range[] = {
53 PINS_FIELD16(0, 6, 0xb20, 0x10, 0, 1),
54 PINS_FIELD16(7, 9, 0xb20, 0x10, 1, 1),
55 PINS_FIELD16(10, 13, 0xb30, 0x10, 3, 1),
56 PINS_FIELD16(14, 15, 0xb30, 0x10, 13, 1),
57 PINS_FIELD16(16, 17, 0xb40, 0x10, 7, 1),
58 PINS_FIELD16(18, 29, 0xb40, 0x10, 13, 1),
59 PINS_FIELD16(30, 32, 0xb40, 0x10, 7, 1),
60 PINS_FIELD16(33, 37, 0xb40, 0x10, 13, 1),
61 PIN_FIELD16(38, 38, 0xb20, 0x10, 13, 1),
62 PINS_FIELD16(39, 42, 0xb40, 0x10, 13, 1),
63 PINS_FIELD16(43, 45, 0xb20, 0x10, 10, 1),
64 PINS_FIELD16(47, 48, 0xb20, 0x10, 11, 1),
65 PIN_FIELD16(49, 49, 0xb20, 0x10, 12, 1),
66 PINS_FIELD16(50, 52, 0xb20, 0x10, 13, 1),
67 PINS_FIELD16(53, 56, 0xb20, 0x10, 14, 1),
68 PINS_FIELD16(57, 58, 0xb20, 0x10, 15, 1),
69 PIN_FIELD16(59, 59, 0xb30, 0x10, 10, 1),
70 PINS_FIELD16(60, 62, 0xb30, 0x10, 0, 1),
71 PINS_FIELD16(63, 65, 0xb30, 0x10, 1, 1),
72 PINS_FIELD16(66, 71, 0xb30, 0x10, 2, 1),
73 PINS_FIELD16(72, 74, 0xb20, 0x10, 12, 1),
74 PINS_FIELD16(75, 76, 0xb30, 0x10, 3, 1),
75 PINS_FIELD16(77, 78, 0xb30, 0x10, 4, 1),
76 PINS_FIELD16(79, 82, 0xb30, 0x10, 5, 1),
77 PINS_FIELD16(83, 84, 0xb30, 0x10, 2, 1),
78 PIN_FIELD16(85, 85, 0xda0, 0x10, 4, 1),
79 PIN_FIELD16(86, 86, 0xd90, 0x10, 4, 1),
80 PINS_FIELD16(87, 90, 0xdb0, 0x10, 4, 1),
81 PINS_FIELD16(101, 104, 0xb30, 0x10, 6, 1),
82 PIN_FIELD16(105, 105, 0xd40, 0x10, 4, 1),
83 PIN_FIELD16(106, 106, 0xd30, 0x10, 4, 1),
84 PINS_FIELD16(107, 110, 0xd50, 0x10, 4, 1),
85 PINS_FIELD16(111, 115, 0xce0, 0x10, 4, 1),
86 PIN_FIELD16(116, 116, 0xcd0, 0x10, 4, 1),
87 PIN_FIELD16(117, 117, 0xcc0, 0x10, 4, 1),
88 PINS_FIELD16(118, 121, 0xce0, 0x10, 4, 1),
89 PINS_FIELD16(122, 125, 0xb30, 0x10, 7, 1),
90 PIN_FIELD16(126, 126, 0xb20, 0x10, 12, 1),
91 PINS_FIELD16(127, 142, 0xb30, 0x10, 9, 1),
92 PINS_FIELD16(143, 160, 0xb30, 0x10, 10, 1),
93 PINS_FIELD16(161, 168, 0xb30, 0x10, 12, 1),
94 PINS_FIELD16(169, 183, 0xb30, 0x10, 10, 1),
95 PINS_FIELD16(184, 186, 0xb30, 0x10, 9, 1),
96 PIN_FIELD16(187, 187, 0xb30, 0x10, 14, 1),
97 PIN_FIELD16(188, 188, 0xb20, 0x10, 13, 1),
98 PINS_FIELD16(189, 193, 0xb30, 0x10, 15, 1),
99 PINS_FIELD16(194, 198, 0xb40, 0x10, 0, 1),
100 PIN_FIELD16(199, 199, 0xb20, 0x10, 1, 1),
101 PINS_FIELD16(200, 202, 0xb40, 0x10, 1, 1),
102 PINS_FIELD16(203, 207, 0xb40, 0x10, 2, 1),
103 PINS_FIELD16(208, 209, 0xb40, 0x10, 3, 1),
104 PIN_FIELD16(210, 210, 0xb40, 0x10, 4, 1),
105 PINS_FIELD16(211, 235, 0xb40, 0x10, 5, 1),
106 PINS_FIELD16(236, 241, 0xb40, 0x10, 6, 1),
107 PINS_FIELD16(242, 243, 0xb40, 0x10, 7, 1),
108 PINS_FIELD16(244, 247, 0xb40, 0x10, 8, 1),
109 PIN_FIELD16(248, 248, 0xb40, 0x10, 9, 1),
110 PINS_FIELD16(249, 257, 0xfc0, 0x10, 4, 1),
111 PIN_FIELD16(258, 258, 0xcb0, 0x10, 4, 1),
112 PIN_FIELD16(259, 259, 0xc90, 0x10, 4, 1),
113 PIN_FIELD16(260, 260, 0x3a0, 0x10, 4, 1),
114 PIN_FIELD16(261, 261, 0xd50, 0x10, 4, 1),
115 PINS_FIELD16(262, 277, 0xb40, 0x10, 12, 1),
116 PIN_FIELD16(278, 278, 0xb40, 0x10, 13, 1),
117};
118
119static const struct mtk_pin_field_calc mt7623_pin_smt_range[] = {
120 PINS_FIELD16(0, 6, 0xb50, 0x10, 0, 1),
121 PINS_FIELD16(7, 9, 0xb50, 0x10, 1, 1),
122 PINS_FIELD16(10, 13, 0xb60, 0x10, 3, 1),
123 PINS_FIELD16(14, 15, 0xb60, 0x10, 13, 1),
124 PINS_FIELD16(16, 17, 0xb70, 0x10, 7, 1),
125 PINS_FIELD16(18, 29, 0xb70, 0x10, 13, 1),
126 PINS_FIELD16(30, 32, 0xb70, 0x10, 7, 1),
127 PINS_FIELD16(33, 37, 0xb70, 0x10, 13, 1),
128 PIN_FIELD16(38, 38, 0xb50, 0x10, 13, 1),
129 PINS_FIELD16(39, 42, 0xb70, 0x10, 13, 1),
130 PINS_FIELD16(43, 45, 0xb50, 0x10, 10, 1),
131 PINS_FIELD16(47, 48, 0xb50, 0x10, 11, 1),
132 PIN_FIELD16(49, 49, 0xb50, 0x10, 12, 1),
133 PINS_FIELD16(50, 52, 0xb50, 0x10, 13, 1),
134 PINS_FIELD16(53, 56, 0xb50, 0x10, 14, 1),
135 PINS_FIELD16(57, 58, 0xb50, 0x10, 15, 1),
136 PIN_FIELD16(59, 59, 0xb60, 0x10, 10, 1),
137 PINS_FIELD16(60, 62, 0xb60, 0x10, 0, 1),
138 PINS_FIELD16(63, 65, 0xb60, 0x10, 1, 1),
139 PINS_FIELD16(66, 71, 0xb60, 0x10, 2, 1),
140 PINS_FIELD16(72, 74, 0xb50, 0x10, 12, 1),
141 PINS_FIELD16(75, 76, 0xb60, 0x10, 3, 1),
142 PINS_FIELD16(77, 78, 0xb60, 0x10, 4, 1),
143 PINS_FIELD16(79, 82, 0xb60, 0x10, 5, 1),
144 PINS_FIELD16(83, 84, 0xb60, 0x10, 2, 1),
145 PIN_FIELD16(85, 85, 0xda0, 0x10, 11, 1),
146 PIN_FIELD16(86, 86, 0xd90, 0x10, 11, 1),
147 PIN_FIELD16(87, 87, 0xdc0, 0x10, 3, 1),
148 PIN_FIELD16(88, 88, 0xdc0, 0x10, 7, 1),
149 PIN_FIELD16(89, 89, 0xdc0, 0x10, 11, 1),
150 PIN_FIELD16(90, 90, 0xdc0, 0x10, 15, 1),
151 PINS_FIELD16(101, 104, 0xb60, 0x10, 6, 1),
152 PIN_FIELD16(105, 105, 0xd40, 0x10, 11, 1),
153 PIN_FIELD16(106, 106, 0xd30, 0x10, 11, 1),
154 PIN_FIELD16(107, 107, 0xd60, 0x10, 3, 1),
155 PIN_FIELD16(108, 108, 0xd60, 0x10, 7, 1),
156 PIN_FIELD16(109, 109, 0xd60, 0x10, 11, 1),
157 PIN_FIELD16(110, 110, 0xd60, 0x10, 15, 1),
158 PIN_FIELD16(111, 111, 0xd00, 0x10, 15, 1),
159 PIN_FIELD16(112, 112, 0xd00, 0x10, 11, 1),
160 PIN_FIELD16(113, 113, 0xd00, 0x10, 7, 1),
161 PIN_FIELD16(114, 114, 0xd00, 0x10, 3, 1),
162 PIN_FIELD16(115, 115, 0xd10, 0x10, 3, 1),
163 PIN_FIELD16(116, 116, 0xcd0, 0x10, 11, 1),
164 PIN_FIELD16(117, 117, 0xcc0, 0x10, 11, 1),
165 PIN_FIELD16(118, 118, 0xcf0, 0x10, 15, 1),
166 PIN_FIELD16(119, 119, 0xcf0, 0x10, 7, 1),
167 PIN_FIELD16(120, 120, 0xcf0, 0x10, 3, 1),
168 PIN_FIELD16(121, 121, 0xcf0, 0x10, 7, 1),
169 PINS_FIELD16(122, 125, 0xb60, 0x10, 7, 1),
170 PIN_FIELD16(126, 126, 0xb50, 0x10, 12, 1),
171 PINS_FIELD16(127, 142, 0xb60, 0x10, 9, 1),
172 PINS_FIELD16(143, 160, 0xb60, 0x10, 10, 1),
173 PINS_FIELD16(161, 168, 0xb60, 0x10, 12, 1),
174 PINS_FIELD16(169, 183, 0xb60, 0x10, 10, 1),
175 PINS_FIELD16(184, 186, 0xb60, 0x10, 9, 1),
176 PIN_FIELD16(187, 187, 0xb60, 0x10, 14, 1),
177 PIN_FIELD16(188, 188, 0xb50, 0x10, 13, 1),
178 PINS_FIELD16(189, 193, 0xb60, 0x10, 15, 1),
179 PINS_FIELD16(194, 198, 0xb70, 0x10, 0, 1),
180 PIN_FIELD16(199, 199, 0xb50, 0x10, 1, 1),
181 PINS_FIELD16(200, 202, 0xb70, 0x10, 1, 1),
182 PINS_FIELD16(203, 207, 0xb70, 0x10, 2, 1),
183 PINS_FIELD16(208, 209, 0xb70, 0x10, 3, 1),
184 PIN_FIELD16(210, 210, 0xb70, 0x10, 4, 1),
185 PINS_FIELD16(211, 235, 0xb70, 0x10, 5, 1),
186 PINS_FIELD16(236, 241, 0xb70, 0x10, 6, 1),
187 PINS_FIELD16(242, 243, 0xb70, 0x10, 7, 1),
188 PINS_FIELD16(244, 247, 0xb70, 0x10, 8, 1),
189 PIN_FIELD16(248, 248, 0xb70, 0x10, 9, 10),
190 PIN_FIELD16(249, 249, 0x140, 0x10, 3, 1),
191 PIN_FIELD16(250, 250, 0x130, 0x10, 15, 1),
192 PIN_FIELD16(251, 251, 0x130, 0x10, 11, 1),
193 PIN_FIELD16(252, 252, 0x130, 0x10, 7, 1),
194 PIN_FIELD16(253, 253, 0x130, 0x10, 3, 1),
195 PIN_FIELD16(254, 254, 0xf40, 0x10, 15, 1),
196 PIN_FIELD16(255, 255, 0xf40, 0x10, 11, 1),
197 PIN_FIELD16(256, 256, 0xf40, 0x10, 7, 1),
198 PIN_FIELD16(257, 257, 0xf40, 0x10, 3, 1),
199 PIN_FIELD16(258, 258, 0xcb0, 0x10, 11, 1),
200 PIN_FIELD16(259, 259, 0xc90, 0x10, 11, 1),
201 PIN_FIELD16(260, 260, 0x3a0, 0x10, 11, 1),
202 PIN_FIELD16(261, 261, 0x0b0, 0x10, 3, 1),
203 PINS_FIELD16(262, 277, 0xb70, 0x10, 12, 1),
204 PIN_FIELD16(278, 278, 0xb70, 0x10, 13, 1),
205};
206
207static const struct mtk_pin_field_calc mt7623_pin_pullen_range[] = {
208 PIN_FIELD16(0, 278, 0x150, 0x10, 0, 1),
209};
210
211static const struct mtk_pin_field_calc mt7623_pin_pullsel_range[] = {
212 PIN_FIELD16(0, 278, 0x280, 0x10, 0, 1),
213};
214
215static const struct mtk_pin_field_calc mt7623_pin_drv_range[] = {
216 PINS_FIELD16(0, 6, 0xf50, 0x10, 0, 4),
217 PINS_FIELD16(7, 9, 0xf50, 0x10, 4, 4),
218 PINS_FIELD16(10, 13, 0xf50, 0x10, 4, 4),
219 PINS_FIELD16(14, 15, 0xf50, 0x10, 12, 4),
220 PINS_FIELD16(16, 17, 0xf60, 0x10, 0, 4),
221 PINS_FIELD16(18, 21, 0xf60, 0x10, 0, 4),
222 PINS_FIELD16(22, 26, 0xf60, 0x10, 8, 4),
223 PINS_FIELD16(27, 29, 0xf60, 0x10, 12, 4),
224 PINS_FIELD16(30, 32, 0xf60, 0x10, 0, 4),
225 PINS_FIELD16(33, 37, 0xf70, 0x10, 0, 4),
226 PIN_FIELD16(38, 38, 0xf70, 0x10, 4, 4),
227 PINS_FIELD16(39, 42, 0xf70, 0x10, 8, 4),
228 PINS_FIELD16(43, 45, 0xf70, 0x10, 12, 4),
229 PINS_FIELD16(47, 48, 0xf80, 0x10, 0, 4),
230 PIN_FIELD16(49, 49, 0xf80, 0x10, 4, 4),
231 PINS_FIELD16(50, 52, 0xf70, 0x10, 4, 4),
232 PINS_FIELD16(53, 56, 0xf80, 0x10, 12, 4),
233 PINS_FIELD16(60, 62, 0xf90, 0x10, 8, 4),
234 PINS_FIELD16(63, 65, 0xf90, 0x10, 12, 4),
235 PINS_FIELD16(66, 71, 0xfa0, 0x10, 0, 4),
236 PINS_FIELD16(72, 74, 0xf80, 0x10, 4, 4),
237 PIN_FIELD16(85, 85, 0xda0, 0x10, 0, 4),
238 PIN_FIELD16(86, 86, 0xd90, 0x10, 0, 4),
239 PINS_FIELD16(87, 90, 0xdb0, 0x10, 0, 4),
240 PIN_FIELD16(105, 105, 0xd40, 0x10, 0, 4),
241 PIN_FIELD16(106, 106, 0xd30, 0x10, 0, 4),
242 PINS_FIELD16(107, 110, 0xd50, 0x10, 0, 4),
243 PINS_FIELD16(111, 115, 0xce0, 0x10, 0, 4),
244 PIN_FIELD16(116, 116, 0xcd0, 0x10, 0, 4),
245 PIN_FIELD16(117, 117, 0xcc0, 0x10, 0, 4),
246 PINS_FIELD16(118, 121, 0xce0, 0x10, 0, 4),
247 PIN_FIELD16(126, 126, 0xf80, 0x10, 4, 4),
248 PIN_FIELD16(188, 188, 0xf70, 0x10, 4, 4),
249 PINS_FIELD16(189, 193, 0xfe0, 0x10, 8, 4),
250 PINS_FIELD16(194, 198, 0xfe0, 0x10, 12, 4),
251 PIN_FIELD16(199, 199, 0xf50, 0x10, 4, 4),
252 PINS_FIELD16(200, 202, 0xfd0, 0x10, 0, 4),
253 PINS_FIELD16(203, 207, 0xfd0, 0x10, 4, 4),
254 PINS_FIELD16(208, 209, 0xfd0, 0x10, 8, 4),
255 PIN_FIELD16(210, 210, 0xfd0, 0x10, 12, 4),
256 PINS_FIELD16(211, 235, 0xff0, 0x10, 0, 4),
257 PINS_FIELD16(236, 241, 0xff0, 0x10, 4, 4),
258 PINS_FIELD16(242, 243, 0xff0, 0x10, 8, 4),
259 PIN_FIELD16(248, 248, 0xf00, 0x10, 0, 4),
260 PINS_FIELD16(249, 256, 0xfc0, 0x10, 0, 4),
261 PIN_FIELD16(257, 257, 0xce0, 0x10, 0, 4),
262 PIN_FIELD16(258, 258, 0xcb0, 0x10, 0, 4),
263 PIN_FIELD16(259, 259, 0xc90, 0x10, 0, 4),
264 PIN_FIELD16(260, 260, 0x3a0, 0x10, 0, 4),
265 PIN_FIELD16(261, 261, 0xd50, 0x10, 0, 4),
266 PINS_FIELD16(262, 277, 0xf00, 0x10, 8, 4),
267 PIN_FIELD16(278, 278, 0xf70, 0x10, 8, 4),
268};
269
270static const struct mtk_pin_field_calc mt7623_pin_tdsel_range[] = {
271 PINS_FIELD16(262, 276, 0x4c0, 0x10, 0, 4),
272};
273
274static const struct mtk_pin_field_calc mt7623_pin_pupd_range[] = {
275 /* MSDC0 */
276 PIN_FIELD16(111, 111, 0xd00, 0x10, 12, 1),
277 PIN_FIELD16(112, 112, 0xd00, 0x10, 8, 1),
278 PIN_FIELD16(113, 113, 0xd00, 0x10, 4, 1),
279 PIN_FIELD16(114, 114, 0xd00, 0x10, 0, 1),
280 PIN_FIELD16(115, 115, 0xd10, 0x10, 0, 1),
281 PIN_FIELD16(116, 116, 0xcd0, 0x10, 8, 1),
282 PIN_FIELD16(117, 117, 0xcc0, 0x10, 8, 1),
283 PIN_FIELD16(118, 118, 0xcf0, 0x10, 12, 1),
284 PIN_FIELD16(119, 119, 0xcf0, 0x10, 8, 1),
285 PIN_FIELD16(120, 120, 0xcf0, 0x10, 4, 1),
286 PIN_FIELD16(121, 121, 0xcf0, 0x10, 0, 1),
287 /* MSDC1 */
288 PIN_FIELD16(105, 105, 0xd40, 0x10, 8, 1),
289 PIN_FIELD16(106, 106, 0xd30, 0x10, 8, 1),
290 PIN_FIELD16(107, 107, 0xd60, 0x10, 0, 1),
291 PIN_FIELD16(108, 108, 0xd60, 0x10, 10, 1),
292 PIN_FIELD16(109, 109, 0xd60, 0x10, 4, 1),
293 PIN_FIELD16(110, 110, 0xc60, 0x10, 12, 1),
294 /* MSDC1 */
295 PIN_FIELD16(85, 85, 0xda0, 0x10, 8, 1),
296 PIN_FIELD16(86, 86, 0xd90, 0x10, 8, 1),
297 PIN_FIELD16(87, 87, 0xdc0, 0x10, 0, 1),
298 PIN_FIELD16(88, 88, 0xdc0, 0x10, 10, 1),
299 PIN_FIELD16(89, 89, 0xdc0, 0x10, 4, 1),
300 PIN_FIELD16(90, 90, 0xdc0, 0x10, 12, 1),
301 /* MSDC0E */
302 PIN_FIELD16(249, 249, 0x140, 0x10, 0, 1),
303 PIN_FIELD16(250, 250, 0x130, 0x10, 12, 1),
304 PIN_FIELD16(251, 251, 0x130, 0x10, 8, 1),
305 PIN_FIELD16(252, 252, 0x130, 0x10, 4, 1),
306 PIN_FIELD16(253, 253, 0x130, 0x10, 0, 1),
307 PIN_FIELD16(254, 254, 0xf40, 0x10, 12, 1),
308 PIN_FIELD16(255, 255, 0xf40, 0x10, 8, 1),
309 PIN_FIELD16(256, 256, 0xf40, 0x10, 4, 1),
310 PIN_FIELD16(257, 257, 0xf40, 0x10, 0, 1),
311 PIN_FIELD16(258, 258, 0xcb0, 0x10, 8, 1),
312 PIN_FIELD16(259, 259, 0xc90, 0x10, 8, 1),
313 PIN_FIELD16(261, 261, 0x140, 0x10, 8, 1),
314};
315
316static const struct mtk_pin_field_calc mt7623_pin_r1_range[] = {
317 /* MSDC0 */
318 PIN_FIELD16(111, 111, 0xd00, 0x10, 13, 1),
319 PIN_FIELD16(112, 112, 0xd00, 0x10, 9, 1),
320 PIN_FIELD16(113, 113, 0xd00, 0x10, 5, 1),
321 PIN_FIELD16(114, 114, 0xd00, 0x10, 1, 1),
322 PIN_FIELD16(115, 115, 0xd10, 0x10, 1, 1),
323 PIN_FIELD16(116, 116, 0xcd0, 0x10, 9, 1),
324 PIN_FIELD16(117, 117, 0xcc0, 0x10, 9, 1),
325 PIN_FIELD16(118, 118, 0xcf0, 0x10, 13, 1),
326 PIN_FIELD16(119, 119, 0xcf0, 0x10, 9, 1),
327 PIN_FIELD16(120, 120, 0xcf0, 0x10, 5, 1),
328 PIN_FIELD16(121, 121, 0xcf0, 0x10, 1, 1),
329 /* MSDC1 */
330 PIN_FIELD16(105, 105, 0xd40, 0x10, 9, 1),
331 PIN_FIELD16(106, 106, 0xd30, 0x10, 9, 1),
332 PIN_FIELD16(107, 107, 0xd60, 0x10, 1, 1),
333 PIN_FIELD16(108, 108, 0xd60, 0x10, 9, 1),
334 PIN_FIELD16(109, 109, 0xd60, 0x10, 5, 1),
335 PIN_FIELD16(110, 110, 0xc60, 0x10, 13, 1),
336 /* MSDC2 */
337 PIN_FIELD16(85, 85, 0xda0, 0x10, 9, 1),
338 PIN_FIELD16(86, 86, 0xd90, 0x10, 9, 1),
339 PIN_FIELD16(87, 87, 0xdc0, 0x10, 1, 1),
340 PIN_FIELD16(88, 88, 0xdc0, 0x10, 9, 1),
341 PIN_FIELD16(89, 89, 0xdc0, 0x10, 5, 1),
342 PIN_FIELD16(90, 90, 0xdc0, 0x10, 13, 1),
343 /* MSDC0E */
344 PIN_FIELD16(249, 249, 0x140, 0x10, 1, 1),
345 PIN_FIELD16(250, 250, 0x130, 0x10, 13, 1),
346 PIN_FIELD16(251, 251, 0x130, 0x10, 9, 1),
347 PIN_FIELD16(252, 252, 0x130, 0x10, 5, 1),
348 PIN_FIELD16(253, 253, 0x130, 0x10, 1, 1),
349 PIN_FIELD16(254, 254, 0xf40, 0x10, 13, 1),
350 PIN_FIELD16(255, 255, 0xf40, 0x10, 9, 1),
351 PIN_FIELD16(256, 256, 0xf40, 0x10, 5, 1),
352 PIN_FIELD16(257, 257, 0xf40, 0x10, 1, 1),
353 PIN_FIELD16(258, 258, 0xcb0, 0x10, 9, 1),
354 PIN_FIELD16(259, 259, 0xc90, 0x10, 9, 1),
355 PIN_FIELD16(261, 261, 0x140, 0x10, 9, 1),
356};
357
358static const struct mtk_pin_field_calc mt7623_pin_r0_range[] = {
359 /* MSDC0 */
360 PIN_FIELD16(111, 111, 0xd00, 0x10, 14, 1),
361 PIN_FIELD16(112, 112, 0xd00, 0x10, 10, 1),
362 PIN_FIELD16(113, 113, 0xd00, 0x10, 6, 1),
363 PIN_FIELD16(114, 114, 0xd00, 0x10, 2, 1),
364 PIN_FIELD16(115, 115, 0xd10, 0x10, 2, 1),
365 PIN_FIELD16(116, 116, 0xcd0, 0x10, 10, 1),
366 PIN_FIELD16(117, 117, 0xcc0, 0x10, 10, 1),
367 PIN_FIELD16(118, 118, 0xcf0, 0x10, 14, 1),
368 PIN_FIELD16(119, 119, 0xcf0, 0x10, 10, 1),
369 PIN_FIELD16(120, 120, 0xcf0, 0x10, 6, 1),
370 PIN_FIELD16(121, 121, 0xcf0, 0x10, 2, 1),
371 /* MSDC1 */
372 PIN_FIELD16(105, 105, 0xd40, 0x10, 10, 1),
373 PIN_FIELD16(106, 106, 0xd30, 0x10, 10, 1),
374 PIN_FIELD16(107, 107, 0xd60, 0x10, 2, 1),
375 PIN_FIELD16(108, 108, 0xd60, 0x10, 8, 1),
376 PIN_FIELD16(109, 109, 0xd60, 0x10, 6, 1),
377 PIN_FIELD16(110, 110, 0xc60, 0x10, 14, 1),
378 /* MSDC2 */
379 PIN_FIELD16(85, 85, 0xda0, 0x10, 10, 1),
380 PIN_FIELD16(86, 86, 0xd90, 0x10, 10, 1),
381 PIN_FIELD16(87, 87, 0xdc0, 0x10, 2, 1),
382 PIN_FIELD16(88, 88, 0xdc0, 0x10, 8, 1),
383 PIN_FIELD16(89, 89, 0xdc0, 0x10, 6, 1),
384 PIN_FIELD16(90, 90, 0xdc0, 0x10, 14, 1),
385 /* MSDC0E */
386 PIN_FIELD16(249, 249, 0x140, 0x10, 2, 1),
387 PIN_FIELD16(250, 250, 0x130, 0x10, 14, 1),
388 PIN_FIELD16(251, 251, 0x130, 0x10, 10, 1),
389 PIN_FIELD16(252, 252, 0x130, 0x10, 6, 1),
390 PIN_FIELD16(253, 253, 0x130, 0x10, 2, 1),
391 PIN_FIELD16(254, 254, 0xf40, 0x10, 14, 1),
392 PIN_FIELD16(255, 255, 0xf40, 0x10, 10, 1),
393 PIN_FIELD16(256, 256, 0xf40, 0x10, 6, 1),
394 PIN_FIELD16(257, 257, 0xf40, 0x10, 5, 1),
395 PIN_FIELD16(258, 258, 0xcb0, 0x10, 10, 1),
396 PIN_FIELD16(259, 259, 0xc90, 0x10, 10, 1),
397 PIN_FIELD16(261, 261, 0x140, 0x10, 10, 1),
398};
399
400static const struct mtk_pin_reg_calc mt7623_reg_cals[] = {
401 [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt7623_pin_mode_range),
402 [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt7623_pin_dir_range),
403 [PINCTRL_PIN_REG_DI] = MTK_RANGE(mt7623_pin_di_range),
404 [PINCTRL_PIN_REG_DO] = MTK_RANGE(mt7623_pin_do_range),
405 [PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt7623_pin_smt_range),
406 [PINCTRL_PIN_REG_PULLSEL] = MTK_RANGE(mt7623_pin_pullsel_range),
407 [PINCTRL_PIN_REG_PULLEN] = MTK_RANGE(mt7623_pin_pullen_range),
408 [PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt7623_pin_drv_range),
409 [PINCTRL_PIN_REG_TDSEL] = MTK_RANGE(mt7623_pin_tdsel_range),
410 [PINCTRL_PIN_REG_IES] = MTK_RANGE(mt7623_pin_ies_range),
411 [PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt7623_pin_pupd_range),
412 [PINCTRL_PIN_REG_R0] = MTK_RANGE(mt7623_pin_r0_range),
413 [PINCTRL_PIN_REG_R1] = MTK_RANGE(mt7623_pin_r1_range),
414};
415
416static const struct mtk_pin_desc mt7623_pins[] = {
417 MT7623_PIN(0, "PWRAP_SPI0_MI", 148, DRV_GRP3),
418 MT7623_PIN(1, "PWRAP_SPI0_MO", 149, DRV_GRP3),
419 MT7623_PIN(2, "PWRAP_INT", 150, DRV_GRP3),
420 MT7623_PIN(3, "PWRAP_SPI0_CK", 151, DRV_GRP3),
421 MT7623_PIN(4, "PWRAP_SPI0_CSN", 152, DRV_GRP3),
422 MT7623_PIN(5, "PWRAP_SPI0_CK2", 153, DRV_GRP3),
423 MT7623_PIN(6, "PWRAP_SPI0_CSN2", 154, DRV_GRP3),
424 MT7623_PIN(7, "SPI1_CSN", 155, DRV_GRP3),
425 MT7623_PIN(8, "SPI1_MI", 156, DRV_GRP3),
426 MT7623_PIN(9, "SPI1_MO", 157, DRV_GRP3),
427 MT7623_PIN(10, "RTC32K_CK", 158, DRV_GRP3),
428 MT7623_PIN(11, "WATCHDOG", 159, DRV_GRP3),
429 MT7623_PIN(12, "SRCLKENA", 160, DRV_GRP3),
430 MT7623_PIN(13, "SRCLKENAI", 161, DRV_GRP3),
431 MT7623_PIN(14, "URXD2", 162, DRV_GRP1),
432 MT7623_PIN(15, "UTXD2", 163, DRV_GRP1),
433 MT7623_PIN(16, "I2S5_DATA_IN", 164, DRV_GRP1),
434 MT7623_PIN(17, "I2S5_BCK", 165, DRV_GRP1),
435 MT7623_PIN(18, "PCM_CLK", 166, DRV_GRP1),
436 MT7623_PIN(19, "PCM_SYNC", 167, DRV_GRP1),
437 MT7623_PIN(20, "PCM_RX", EINT_NA, DRV_GRP1),
438 MT7623_PIN(21, "PCM_TX", EINT_NA, DRV_GRP1),
439 MT7623_PIN(22, "EINT0", 0, DRV_GRP1),
440 MT7623_PIN(23, "EINT1", 1, DRV_GRP1),
441 MT7623_PIN(24, "EINT2", 2, DRV_GRP1),
442 MT7623_PIN(25, "EINT3", 3, DRV_GRP1),
443 MT7623_PIN(26, "EINT4", 4, DRV_GRP1),
444 MT7623_PIN(27, "EINT5", 5, DRV_GRP1),
445 MT7623_PIN(28, "EINT6", 6, DRV_GRP1),
446 MT7623_PIN(29, "EINT7", 7, DRV_GRP1),
447 MT7623_PIN(30, "I2S5_LRCK", 12, DRV_GRP1),
448 MT7623_PIN(31, "I2S5_MCLK", 13, DRV_GRP1),
449 MT7623_PIN(32, "I2S5_DATA", 14, DRV_GRP1),
450 MT7623_PIN(33, "I2S1_DATA", 15, DRV_GRP1),
451 MT7623_PIN(34, "I2S1_DATA_IN", 16, DRV_GRP1),
452 MT7623_PIN(35, "I2S1_BCK", 17, DRV_GRP1),
453 MT7623_PIN(36, "I2S1_LRCK", 18, DRV_GRP1),
454 MT7623_PIN(37, "I2S1_MCLK", 19, DRV_GRP1),
455 MT7623_PIN(38, "I2S2_DATA", 20, DRV_GRP1),
456 MT7623_PIN(39, "JTMS", 21, DRV_GRP3),
457 MT7623_PIN(40, "JTCK", 22, DRV_GRP3),
458 MT7623_PIN(41, "JTDI", 23, DRV_GRP3),
459 MT7623_PIN(42, "JTDO", 24, DRV_GRP3),
460 MT7623_PIN(43, "NCLE", 25, DRV_GRP1),
461 MT7623_PIN(44, "NCEB1", 26, DRV_GRP1),
462 MT7623_PIN(45, "NCEB0", 27, DRV_GRP1),
463 MT7623_PIN(46, "IR", 28, DRV_FIXED),
464 MT7623_PIN(47, "NREB", 29, DRV_GRP1),
465 MT7623_PIN(48, "NRNB", 30, DRV_GRP1),
466 MT7623_PIN(49, "I2S0_DATA", 31, DRV_GRP1),
467 MT7623_PIN(50, "I2S2_BCK", 32, DRV_GRP1),
468 MT7623_PIN(51, "I2S2_DATA_IN", 33, DRV_GRP1),
469 MT7623_PIN(52, "I2S2_LRCK", 34, DRV_GRP1),
470 MT7623_PIN(53, "SPI0_CSN", 35, DRV_GRP1),
471 MT7623_PIN(54, "SPI0_CK", 36, DRV_GRP1),
472 MT7623_PIN(55, "SPI0_MI", 37, DRV_GRP1),
473 MT7623_PIN(56, "SPI0_MO", 38, DRV_GRP1),
474 MT7623_PIN(57, "SDA1", 39, DRV_FIXED),
475 MT7623_PIN(58, "SCL1", 40, DRV_FIXED),
476 MT7623_PIN(59, "RAMBUF_I_CLK", EINT_NA, DRV_FIXED),
477 MT7623_PIN(60, "WB_RSTB", 41, DRV_GRP3),
478 MT7623_PIN(61, "F2W_DATA", 42, DRV_GRP3),
479 MT7623_PIN(62, "F2W_CLK", 43, DRV_GRP3),
480 MT7623_PIN(63, "WB_SCLK", 44, DRV_GRP3),
481 MT7623_PIN(64, "WB_SDATA", 45, DRV_GRP3),
482 MT7623_PIN(65, "WB_SEN", 46, DRV_GRP3),
483 MT7623_PIN(66, "WB_CRTL0", 47, DRV_GRP3),
484 MT7623_PIN(67, "WB_CRTL1", 48, DRV_GRP3),
485 MT7623_PIN(68, "WB_CRTL2", 49, DRV_GRP3),
486 MT7623_PIN(69, "WB_CRTL3", 50, DRV_GRP3),
487 MT7623_PIN(70, "WB_CRTL4", 51, DRV_GRP3),
488 MT7623_PIN(71, "WB_CRTL5", 52, DRV_GRP3),
489 MT7623_PIN(72, "I2S0_DATA_IN", 53, DRV_GRP1),
490 MT7623_PIN(73, "I2S0_LRCK", 54, DRV_GRP1),
491 MT7623_PIN(74, "I2S0_BCK", 55, DRV_GRP1),
492 MT7623_PIN(75, "SDA0", 56, DRV_FIXED),
493 MT7623_PIN(76, "SCL0", 57, DRV_FIXED),
494 MT7623_PIN(77, "SDA2", 58, DRV_FIXED),
495 MT7623_PIN(78, "SCL2", 59, DRV_FIXED),
496 MT7623_PIN(79, "URXD0", 60, DRV_FIXED),
497 MT7623_PIN(80, "UTXD0", 61, DRV_FIXED),
498 MT7623_PIN(81, "URXD1", 62, DRV_FIXED),
499 MT7623_PIN(82, "UTXD1", 63, DRV_FIXED),
500 MT7623_PIN(83, "LCM_RST", 64, DRV_FIXED),
501 MT7623_PIN(84, "DSI_TE", 65, DRV_FIXED),
502 MT7623_PIN(85, "MSDC2_CMD", 66, DRV_GRP4),
503 MT7623_PIN(86, "MSDC2_CLK", 67, DRV_GRP4),
504 MT7623_PIN(87, "MSDC2_DAT0", 68, DRV_GRP4),
505 MT7623_PIN(88, "MSDC2_DAT1", 69, DRV_GRP4),
506 MT7623_PIN(89, "MSDC2_DAT2", 70, DRV_GRP4),
507 MT7623_PIN(90, "MSDC2_DAT3", 71, DRV_GRP4),
508 MT7623_PIN(91, "TDN3", EINT_NA, DRV_FIXED),
509 MT7623_PIN(92, "TDP3", EINT_NA, DRV_FIXED),
510 MT7623_PIN(93, "TDN2", EINT_NA, DRV_FIXED),
511 MT7623_PIN(94, "TDP2", EINT_NA, DRV_FIXED),
512 MT7623_PIN(95, "TCN", EINT_NA, DRV_FIXED),
513 MT7623_PIN(96, "TCP", EINT_NA, DRV_FIXED),
514 MT7623_PIN(97, "TDN1", EINT_NA, DRV_FIXED),
515 MT7623_PIN(98, "TDP1", EINT_NA, DRV_FIXED),
516 MT7623_PIN(99, "TDN0", EINT_NA, DRV_FIXED),
517 MT7623_PIN(100, "TDP0", EINT_NA, DRV_FIXED),
518 MT7623_PIN(101, "SPI2_CSN", 74, DRV_FIXED),
519 MT7623_PIN(102, "SPI2_MI", 75, DRV_FIXED),
520 MT7623_PIN(103, "SPI2_MO", 76, DRV_FIXED),
521 MT7623_PIN(104, "SPI2_CLK", 77, DRV_FIXED),
522 MT7623_PIN(105, "MSDC1_CMD", 78, DRV_GRP4),
523 MT7623_PIN(106, "MSDC1_CLK", 79, DRV_GRP4),
524 MT7623_PIN(107, "MSDC1_DAT0", 80, DRV_GRP4),
525 MT7623_PIN(108, "MSDC1_DAT1", 81, DRV_GRP4),
526 MT7623_PIN(109, "MSDC1_DAT2", 82, DRV_GRP4),
527 MT7623_PIN(110, "MSDC1_DAT3", 83, DRV_GRP4),
528 MT7623_PIN(111, "MSDC0_DAT7", 84, DRV_GRP4),
529 MT7623_PIN(112, "MSDC0_DAT6", 85, DRV_GRP4),
530 MT7623_PIN(113, "MSDC0_DAT5", 86, DRV_GRP4),
531 MT7623_PIN(114, "MSDC0_DAT4", 87, DRV_GRP4),
532 MT7623_PIN(115, "MSDC0_RSTB", 88, DRV_GRP4),
533 MT7623_PIN(116, "MSDC0_CMD", 89, DRV_GRP4),
534 MT7623_PIN(117, "MSDC0_CLK", 90, DRV_GRP4),
535 MT7623_PIN(118, "MSDC0_DAT3", 91, DRV_GRP4),
536 MT7623_PIN(119, "MSDC0_DAT2", 92, DRV_GRP4),
537 MT7623_PIN(120, "MSDC0_DAT1", 93, DRV_GRP4),
538 MT7623_PIN(121, "MSDC0_DAT0", 94, DRV_GRP4),
539 MT7623_PIN(122, "CEC", 95, DRV_FIXED),
540 MT7623_PIN(123, "HTPLG", 96, DRV_FIXED),
541 MT7623_PIN(124, "HDMISCK", 97, DRV_FIXED),
542 MT7623_PIN(125, "HDMISD", 98, DRV_FIXED),
543 MT7623_PIN(126, "I2S0_MCLK", 99, DRV_GRP1),
544 MT7623_PIN(127, "RAMBUF_IDATA0", EINT_NA, DRV_FIXED),
545 MT7623_PIN(128, "RAMBUF_IDATA1", EINT_NA, DRV_FIXED),
546 MT7623_PIN(129, "RAMBUF_IDATA2", EINT_NA, DRV_FIXED),
547 MT7623_PIN(130, "RAMBUF_IDATA3", EINT_NA, DRV_FIXED),
548 MT7623_PIN(131, "RAMBUF_IDATA4", EINT_NA, DRV_FIXED),
549 MT7623_PIN(132, "RAMBUF_IDATA5", EINT_NA, DRV_FIXED),
550 MT7623_PIN(133, "RAMBUF_IDATA6", EINT_NA, DRV_FIXED),
551 MT7623_PIN(134, "RAMBUF_IDATA7", EINT_NA, DRV_FIXED),
552 MT7623_PIN(135, "RAMBUF_IDATA8", EINT_NA, DRV_FIXED),
553 MT7623_PIN(136, "RAMBUF_IDATA9", EINT_NA, DRV_FIXED),
554 MT7623_PIN(137, "RAMBUF_IDATA10", EINT_NA, DRV_FIXED),
555 MT7623_PIN(138, "RAMBUF_IDATA11", EINT_NA, DRV_FIXED),
556 MT7623_PIN(139, "RAMBUF_IDATA12", EINT_NA, DRV_FIXED),
557 MT7623_PIN(140, "RAMBUF_IDATA13", EINT_NA, DRV_FIXED),
558 MT7623_PIN(141, "RAMBUF_IDATA14", EINT_NA, DRV_FIXED),
559 MT7623_PIN(142, "RAMBUF_IDATA15", EINT_NA, DRV_FIXED),
560 MT7623_PIN(143, "RAMBUF_ODATA0", EINT_NA, DRV_FIXED),
561 MT7623_PIN(144, "RAMBUF_ODATA1", EINT_NA, DRV_FIXED),
562 MT7623_PIN(145, "RAMBUF_ODATA2", EINT_NA, DRV_FIXED),
563 MT7623_PIN(146, "RAMBUF_ODATA3", EINT_NA, DRV_FIXED),
564 MT7623_PIN(147, "RAMBUF_ODATA4", EINT_NA, DRV_FIXED),
565 MT7623_PIN(148, "RAMBUF_ODATA5", EINT_NA, DRV_FIXED),
566 MT7623_PIN(149, "RAMBUF_ODATA6", EINT_NA, DRV_FIXED),
567 MT7623_PIN(150, "RAMBUF_ODATA7", EINT_NA, DRV_FIXED),
568 MT7623_PIN(151, "RAMBUF_ODATA8", EINT_NA, DRV_FIXED),
569 MT7623_PIN(152, "RAMBUF_ODATA9", EINT_NA, DRV_FIXED),
570 MT7623_PIN(153, "RAMBUF_ODATA10", EINT_NA, DRV_FIXED),
571 MT7623_PIN(154, "RAMBUF_ODATA11", EINT_NA, DRV_FIXED),
572 MT7623_PIN(155, "RAMBUF_ODATA12", EINT_NA, DRV_FIXED),
573 MT7623_PIN(156, "RAMBUF_ODATA13", EINT_NA, DRV_FIXED),
574 MT7623_PIN(157, "RAMBUF_ODATA14", EINT_NA, DRV_FIXED),
575 MT7623_PIN(158, "RAMBUF_ODATA15", EINT_NA, DRV_FIXED),
576 MT7623_PIN(159, "RAMBUF_BE0", EINT_NA, DRV_FIXED),
577 MT7623_PIN(160, "RAMBUF_BE1", EINT_NA, DRV_FIXED),
578 MT7623_PIN(161, "AP2PT_INT", EINT_NA, DRV_FIXED),
579 MT7623_PIN(162, "AP2PT_INT_CLR", EINT_NA, DRV_FIXED),
580 MT7623_PIN(163, "PT2AP_INT", EINT_NA, DRV_FIXED),
581 MT7623_PIN(164, "PT2AP_INT_CLR", EINT_NA, DRV_FIXED),
582 MT7623_PIN(165, "AP2UP_INT", EINT_NA, DRV_FIXED),
583 MT7623_PIN(166, "AP2UP_INT_CLR", EINT_NA, DRV_FIXED),
584 MT7623_PIN(167, "UP2AP_INT", EINT_NA, DRV_FIXED),
585 MT7623_PIN(168, "UP2AP_INT_CLR", EINT_NA, DRV_FIXED),
586 MT7623_PIN(169, "RAMBUF_ADDR0", EINT_NA, DRV_FIXED),
587 MT7623_PIN(170, "RAMBUF_ADDR1", EINT_NA, DRV_FIXED),
588 MT7623_PIN(171, "RAMBUF_ADDR2", EINT_NA, DRV_FIXED),
589 MT7623_PIN(172, "RAMBUF_ADDR3", EINT_NA, DRV_FIXED),
590 MT7623_PIN(173, "RAMBUF_ADDR4", EINT_NA, DRV_FIXED),
591 MT7623_PIN(174, "RAMBUF_ADDR5", EINT_NA, DRV_FIXED),
592 MT7623_PIN(175, "RAMBUF_ADDR6", EINT_NA, DRV_FIXED),
593 MT7623_PIN(176, "RAMBUF_ADDR7", EINT_NA, DRV_FIXED),
594 MT7623_PIN(177, "RAMBUF_ADDR8", EINT_NA, DRV_FIXED),
595 MT7623_PIN(178, "RAMBUF_ADDR9", EINT_NA, DRV_FIXED),
596 MT7623_PIN(179, "RAMBUF_ADDR10", EINT_NA, DRV_FIXED),
597 MT7623_PIN(180, "RAMBUF_RW", EINT_NA, DRV_FIXED),
598 MT7623_PIN(181, "RAMBUF_LAST", EINT_NA, DRV_FIXED),
599 MT7623_PIN(182, "RAMBUF_HP", EINT_NA, DRV_FIXED),
600 MT7623_PIN(183, "RAMBUF_REQ", EINT_NA, DRV_FIXED),
601 MT7623_PIN(184, "RAMBUF_ALE", EINT_NA, DRV_FIXED),
602 MT7623_PIN(185, "RAMBUF_DLE", EINT_NA, DRV_FIXED),
603 MT7623_PIN(186, "RAMBUF_WDLE", EINT_NA, DRV_FIXED),
604 MT7623_PIN(187, "RAMBUF_O_CLK", EINT_NA, DRV_FIXED),
605 MT7623_PIN(188, "I2S2_MCLK", 100, DRV_GRP1),
606 MT7623_PIN(189, "I2S3_DATA", 101, DRV_GRP1),
607 MT7623_PIN(190, "I2S3_DATA_IN", 102, DRV_GRP1),
608 MT7623_PIN(191, "I2S3_BCK", 103, DRV_GRP1),
609 MT7623_PIN(192, "I2S3_LRCK", 104, DRV_GRP1),
610 MT7623_PIN(193, "I2S3_MCLK", 105, DRV_GRP1),
611 MT7623_PIN(194, "I2S4_DATA", 106, DRV_GRP1),
612 MT7623_PIN(195, "I2S4_DATA_IN", 107, DRV_GRP1),
613 MT7623_PIN(196, "I2S4_BCK", 108, DRV_GRP1),
614 MT7623_PIN(197, "I2S4_LRCK", 109, DRV_GRP1),
615 MT7623_PIN(198, "I2S4_MCLK", 110, DRV_GRP1),
616 MT7623_PIN(199, "SPI1_CLK", 111, DRV_GRP3),
617 MT7623_PIN(200, "SPDIF_OUT", 112, DRV_GRP1),
618 MT7623_PIN(201, "SPDIF_IN0", 113, DRV_GRP1),
619 MT7623_PIN(202, "SPDIF_IN1", 114, DRV_GRP1),
620 MT7623_PIN(203, "PWM0", 115, DRV_GRP1),
621 MT7623_PIN(204, "PWM1", 116, DRV_GRP1),
622 MT7623_PIN(205, "PWM2", 117, DRV_GRP1),
623 MT7623_PIN(206, "PWM3", 118, DRV_GRP1),
624 MT7623_PIN(207, "PWM4", 119, DRV_GRP1),
625 MT7623_PIN(208, "AUD_EXT_CK1", 120, DRV_GRP1),
626 MT7623_PIN(209, "AUD_EXT_CK2", 121, DRV_GRP1),
627 MT7623_PIN(210, "AUD_CLOCK", EINT_NA, DRV_GRP3),
628 MT7623_PIN(211, "DVP_RESET", EINT_NA, DRV_GRP3),
629 MT7623_PIN(212, "DVP_CLOCK", EINT_NA, DRV_GRP3),
630 MT7623_PIN(213, "DVP_CS", EINT_NA, DRV_GRP3),
631 MT7623_PIN(214, "DVP_CK", EINT_NA, DRV_GRP3),
632 MT7623_PIN(215, "DVP_DI", EINT_NA, DRV_GRP3),
633 MT7623_PIN(216, "DVP_DO", EINT_NA, DRV_GRP3),
634 MT7623_PIN(217, "AP_CS", EINT_NA, DRV_GRP3),
635 MT7623_PIN(218, "AP_CK", EINT_NA, DRV_GRP3),
636 MT7623_PIN(219, "AP_DI", EINT_NA, DRV_GRP3),
637 MT7623_PIN(220, "AP_DO", EINT_NA, DRV_GRP3),
638 MT7623_PIN(221, "DVD_BCLK", EINT_NA, DRV_GRP3),
639 MT7623_PIN(222, "T8032_CLK", EINT_NA, DRV_GRP3),
640 MT7623_PIN(223, "AP_BCLK", EINT_NA, DRV_GRP3),
641 MT7623_PIN(224, "HOST_CS", EINT_NA, DRV_GRP3),
642 MT7623_PIN(225, "HOST_CK", EINT_NA, DRV_GRP3),
643 MT7623_PIN(226, "HOST_DO0", EINT_NA, DRV_GRP3),
644 MT7623_PIN(227, "HOST_DO1", EINT_NA, DRV_GRP3),
645 MT7623_PIN(228, "SLV_CS", EINT_NA, DRV_GRP3),
646 MT7623_PIN(229, "SLV_CK", EINT_NA, DRV_GRP3),
647 MT7623_PIN(230, "SLV_DI0", EINT_NA, DRV_GRP3),
648 MT7623_PIN(231, "SLV_DI1", EINT_NA, DRV_GRP3),
649 MT7623_PIN(232, "AP2DSP_INT", EINT_NA, DRV_GRP3),
650 MT7623_PIN(233, "AP2DSP_INT_CLR", EINT_NA, DRV_GRP3),
651 MT7623_PIN(234, "DSP2AP_INT", EINT_NA, DRV_GRP3),
652 MT7623_PIN(235, "DSP2AP_INT_CLR", EINT_NA, DRV_GRP3),
653 MT7623_PIN(236, "EXT_SDIO3", 122, DRV_GRP1),
654 MT7623_PIN(237, "EXT_SDIO2", 123, DRV_GRP1),
655 MT7623_PIN(238, "EXT_SDIO1", 124, DRV_GRP1),
656 MT7623_PIN(239, "EXT_SDIO0", 125, DRV_GRP1),
657 MT7623_PIN(240, "EXT_XCS", 126, DRV_GRP1),
658 MT7623_PIN(241, "EXT_SCK", 127, DRV_GRP1),
659 MT7623_PIN(242, "URTS2", 128, DRV_GRP1),
660 MT7623_PIN(243, "UCTS2", 129, DRV_GRP1),
661 MT7623_PIN(244, "HDMI_SDA_RX", 130, DRV_FIXED),
662 MT7623_PIN(245, "HDMI_SCL_RX", 131, DRV_FIXED),
663 MT7623_PIN(246, "MHL_SENCE", 132, DRV_FIXED),
664 MT7623_PIN(247, "HDMI_HPD_CBUS_RX", 69, DRV_FIXED),
665 MT7623_PIN(248, "HDMI_TESTOUTP_RX", 133, DRV_GRP1),
666 MT7623_PIN(249, "MSDC0E_RSTB", 134, DRV_GRP4),
667 MT7623_PIN(250, "MSDC0E_DAT7", 135, DRV_GRP4),
668 MT7623_PIN(251, "MSDC0E_DAT6", 136, DRV_GRP4),
669 MT7623_PIN(252, "MSDC0E_DAT5", 137, DRV_GRP4),
670 MT7623_PIN(253, "MSDC0E_DAT4", 138, DRV_GRP4),
671 MT7623_PIN(254, "MSDC0E_DAT3", 139, DRV_GRP4),
672 MT7623_PIN(255, "MSDC0E_DAT2", 140, DRV_GRP4),
673 MT7623_PIN(256, "MSDC0E_DAT1", 141, DRV_GRP4),
674 MT7623_PIN(257, "MSDC0E_DAT0", 142, DRV_GRP4),
675 MT7623_PIN(258, "MSDC0E_CMD", 143, DRV_GRP4),
676 MT7623_PIN(259, "MSDC0E_CLK", 144, DRV_GRP4),
677 MT7623_PIN(260, "MSDC0E_DSL", 145, DRV_GRP4),
678 MT7623_PIN(261, "MSDC1_INS", 146, DRV_GRP4),
679 MT7623_PIN(262, "G2_TXEN", 8, DRV_GRP1),
680 MT7623_PIN(263, "G2_TXD3", 9, DRV_GRP1),
681 MT7623_PIN(264, "G2_TXD2", 10, DRV_GRP1),
682 MT7623_PIN(265, "G2_TXD1", 11, DRV_GRP1),
683 MT7623_PIN(266, "G2_TXD0", EINT_NA, DRV_GRP1),
684 MT7623_PIN(267, "G2_TXC", EINT_NA, DRV_GRP1),
685 MT7623_PIN(268, "G2_RXC", EINT_NA, DRV_GRP1),
686 MT7623_PIN(269, "G2_RXD0", EINT_NA, DRV_GRP1),
687 MT7623_PIN(270, "G2_RXD1", EINT_NA, DRV_GRP1),
688 MT7623_PIN(271, "G2_RXD2", EINT_NA, DRV_GRP1),
689 MT7623_PIN(272, "G2_RXD3", EINT_NA, DRV_GRP1),
690 MT7623_PIN(273, "ESW_INT", 168, DRV_GRP1),
691 MT7623_PIN(274, "G2_RXDV", EINT_NA, DRV_GRP1),
692 MT7623_PIN(275, "MDC", EINT_NA, DRV_GRP1),
693 MT7623_PIN(276, "MDIO", EINT_NA, DRV_GRP1),
694 MT7623_PIN(277, "ESW_RST", EINT_NA, DRV_GRP1),
695 MT7623_PIN(278, "JTAG_RESET", 147, DRV_GRP3),
696 MT7623_PIN(279, "USB3_RES_BOND", EINT_NA, DRV_GRP1),
697};
698
699/* List all groups consisting of these pins dedicated to the enablement of
700 * certain hardware block and the corresponding mode for all of the pins.
701 * The hardware probably has multiple combinations of these pinouts.
702 */
703
704/* AUDIO EXT CLK */
705static int mt7623_aud_ext_clk0_pins[] = { 208, };
706static int mt7623_aud_ext_clk0_funcs[] = { 1, };
707static int mt7623_aud_ext_clk1_pins[] = { 209, };
708static int mt7623_aud_ext_clk1_funcs[] = { 1, };
709
710/* DISP PWM */
711static int mt7623_disp_pwm_0_pins[] = { 72, };
712static int mt7623_disp_pwm_0_funcs[] = { 5, };
713static int mt7623_disp_pwm_1_pins[] = { 203, };
714static int mt7623_disp_pwm_1_funcs[] = { 2, };
715static int mt7623_disp_pwm_2_pins[] = { 208, };
716static int mt7623_disp_pwm_2_funcs[] = { 5, };
717
718/* ESW */
719static int mt7623_esw_int_pins[] = { 273, };
720static int mt7623_esw_int_funcs[] = { 1, };
721static int mt7623_esw_rst_pins[] = { 277, };
722static int mt7623_esw_rst_funcs[] = { 1, };
723
724/* EPHY */
725static int mt7623_ephy_pins[] = { 262, 263, 264, 265, 266, 267, 268,
726 269, 270, 271, 272, 274, };
727static int mt7623_ephy_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
728
729/* EXT_SDIO */
730static int mt7623_ext_sdio_pins[] = { 236, 237, 238, 239, 240, 241, };
731static int mt7623_ext_sdio_funcs[] = { 1, 1, 1, 1, 1, 1, };
732
733/* HDMI RX */
734static int mt7623_hdmi_rx_pins[] = { 247, 248, };
735static int mt7623_hdmi_rx_funcs[] = { 1, 1 };
736static int mt7623_hdmi_rx_i2c_pins[] = { 244, 245, };
737static int mt7623_hdmi_rx_i2c_funcs[] = { 1, 1 };
738
739/* HDMI TX */
740static int mt7623_hdmi_cec_pins[] = { 122, };
741static int mt7623_hdmi_cec_funcs[] = { 1, };
742static int mt7623_hdmi_htplg_pins[] = { 123, };
743static int mt7623_hdmi_htplg_funcs[] = { 1, };
744static int mt7623_hdmi_i2c_pins[] = { 124, 125, };
745static int mt7623_hdmi_i2c_funcs[] = { 1, 1 };
746
747/* I2C */
748static int mt7623_i2c0_pins[] = { 75, 76, };
749static int mt7623_i2c0_funcs[] = { 1, 1, };
750static int mt7623_i2c1_0_pins[] = { 57, 58, };
751static int mt7623_i2c1_0_funcs[] = { 1, 1, };
752static int mt7623_i2c1_1_pins[] = { 242, 243, };
753static int mt7623_i2c1_1_funcs[] = { 4, 4, };
754static int mt7623_i2c1_2_pins[] = { 85, 86, };
755static int mt7623_i2c1_2_funcs[] = { 3, 3, };
756static int mt7623_i2c1_3_pins[] = { 105, 106, };
757static int mt7623_i2c1_3_funcs[] = { 3, 3, };
758static int mt7623_i2c1_4_pins[] = { 124, 125, };
759static int mt7623_i2c1_4_funcs[] = { 4, 4, };
760static int mt7623_i2c2_0_pins[] = { 77, 78, };
761static int mt7623_i2c2_0_funcs[] = { 1, 1, };
762static int mt7623_i2c2_1_pins[] = { 89, 90, };
763static int mt7623_i2c2_1_funcs[] = { 3, 3, };
764static int mt7623_i2c2_2_pins[] = { 109, 110, };
765static int mt7623_i2c2_2_funcs[] = { 3, 3, };
766static int mt7623_i2c2_3_pins[] = { 122, 123, };
767static int mt7623_i2c2_3_funcs[] = { 4, 4, };
768
769/* I2S */
770static int mt7623_i2s0_pins[] = { 49, 72, 73, 74, 126, };
771static int mt7623_i2s0_funcs[] = { 1, 1, 1, 1, 1, };
772static int mt7623_i2s1_pins[] = { 33, 34, 35, 36, 37, };
773static int mt7623_i2s1_funcs[] = { 1, 1, 1, 1, 1, };
774static int mt7623_i2s2_bclk_lrclk_mclk_pins[] = { 50, 52, 188, };
775static int mt7623_i2s2_bclk_lrclk_mclk_funcs[] = { 1, 1, 1, };
776static int mt7623_i2s2_data_in_pins[] = { 51, };
777static int mt7623_i2s2_data_in_funcs[] = { 1, };
778static int mt7623_i2s2_data_0_pins[] = { 203, };
779static int mt7623_i2s2_data_0_funcs[] = { 9, };
780static int mt7623_i2s2_data_1_pins[] = { 38, };
781static int mt7623_i2s2_data_1_funcs[] = { 4, };
782static int mt7623_i2s3_bclk_lrclk_mclk_pins[] = { 191, 192, 193, };
783static int mt7623_i2s3_bclk_lrclk_mclk_funcs[] = { 1, 1, 1, };
784static int mt7623_i2s3_data_in_pins[] = { 190, };
785static int mt7623_i2s3_data_in_funcs[] = { 1, };
786static int mt7623_i2s3_data_0_pins[] = { 204, };
787static int mt7623_i2s3_data_0_funcs[] = { 9, };
788static int mt7623_i2s3_data_1_pins[] = { 2, };
789static int mt7623_i2s3_data_1_funcs[] = { 0, };
790static int mt7623_i2s4_pins[] = { 194, 195, 196, 197, 198, };
791static int mt7623_i2s4_funcs[] = { 1, 1, 1, 1, 1, };
792static int mt7623_i2s5_pins[] = { 16, 17, 30, 31, 32, };
793static int mt7623_i2s5_funcs[] = { 1, 1, 1, 1, 1, };
794
795/* IR */
796static int mt7623_ir_pins[] = { 46, };
797static int mt7623_ir_funcs[] = { 1, };
798
799/* LCD */
800static int mt7623_mipi_tx_pins[] = { 91, 92, 93, 94, 95, 96, 97, 98,
801 99, 100, };
802static int mt7623_mipi_tx_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
803static int mt7623_dsi_te_pins[] = { 84, };
804static int mt7623_dsi_te_funcs[] = { 1, };
805static int mt7623_lcm_rst_pins[] = { 83, };
806static int mt7623_lcm_rst_funcs[] = { 1, };
807
808/* MDC/MDIO */
809static int mt7623_mdc_mdio_pins[] = { 275, 276, };
810static int mt7623_mdc_mdio_funcs[] = { 1, 1, };
811
812/* MSDC */
813static int mt7623_msdc0_pins[] = { 111, 112, 113, 114, 115, 116, 117, 118,
814 119, 120, 121, };
815static int mt7623_msdc0_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
816static int mt7623_msdc1_pins[] = { 105, 106, 107, 108, 109, 110, };
817static int mt7623_msdc1_funcs[] = { 1, 1, 1, 1, 1, 1, };
818static int mt7623_msdc1_ins_pins[] = { 261, };
819static int mt7623_msdc1_ins_funcs[] = { 1, };
820static int mt7623_msdc1_wp_0_pins[] = { 29, };
821static int mt7623_msdc1_wp_0_funcs[] = { 1, };
822static int mt7623_msdc1_wp_1_pins[] = { 55, };
823static int mt7623_msdc1_wp_1_funcs[] = { 3, };
824static int mt7623_msdc1_wp_2_pins[] = { 209, };
825static int mt7623_msdc1_wp_2_funcs[] = { 2, };
826static int mt7623_msdc2_pins[] = { 85, 86, 87, 88, 89, 90, };
827static int mt7623_msdc2_funcs[] = { 1, 1, 1, 1, 1, 1, };
828static int mt7623_msdc3_pins[] = { 249, 250, 251, 252, 253, 254, 255, 256,
829 257, 258, 259, 260, };
830static int mt7623_msdc3_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
831
832/* NAND */
833static int mt7623_nandc_pins[] = { 43, 47, 48, 111, 112, 113, 114, 115,
834 116, 117, 118, 119, 120, 121, };
835static int mt7623_nandc_funcs[] = { 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4,
836 4, 4, };
837static int mt7623_nandc_ceb0_pins[] = { 45, };
838static int mt7623_nandc_ceb0_funcs[] = { 1, };
839static int mt7623_nandc_ceb1_pins[] = { 44, };
840static int mt7623_nandc_ceb1_funcs[] = { 1, };
841
842/* RTC */
843static int mt7623_rtc_pins[] = { 10, };
844static int mt7623_rtc_funcs[] = { 1, };
845
846/* OTG */
847static int mt7623_otg_iddig0_0_pins[] = { 29, };
848static int mt7623_otg_iddig0_0_funcs[] = { 1, };
849static int mt7623_otg_iddig0_1_pins[] = { 44, };
850static int mt7623_otg_iddig0_1_funcs[] = { 2, };
851static int mt7623_otg_iddig0_2_pins[] = { 236, };
852static int mt7623_otg_iddig0_2_funcs[] = { 2, };
853static int mt7623_otg_iddig1_0_pins[] = { 27, };
854static int mt7623_otg_iddig1_0_funcs[] = { 2, };
855static int mt7623_otg_iddig1_1_pins[] = { 47, };
856static int mt7623_otg_iddig1_1_funcs[] = { 2, };
857static int mt7623_otg_iddig1_2_pins[] = { 238, };
858static int mt7623_otg_iddig1_2_funcs[] = { 2, };
859static int mt7623_otg_drv_vbus0_0_pins[] = { 28, };
860static int mt7623_otg_drv_vbus0_0_funcs[] = { 1, };
861static int mt7623_otg_drv_vbus0_1_pins[] = { 45, };
862static int mt7623_otg_drv_vbus0_1_funcs[] = { 2, };
863static int mt7623_otg_drv_vbus0_2_pins[] = { 237, };
864static int mt7623_otg_drv_vbus0_2_funcs[] = { 2, };
865static int mt7623_otg_drv_vbus1_0_pins[] = { 26, };
866static int mt7623_otg_drv_vbus1_0_funcs[] = { 2, };
867static int mt7623_otg_drv_vbus1_1_pins[] = { 48, };
868static int mt7623_otg_drv_vbus1_1_funcs[] = { 2, };
869static int mt7623_otg_drv_vbus1_2_pins[] = { 239, };
870static int mt7623_otg_drv_vbus1_2_funcs[] = { 2, };
871
872/* PCIE */
873static int mt7623_pcie0_0_perst_pins[] = { 208, };
874static int mt7623_pcie0_0_perst_funcs[] = { 3, };
875static int mt7623_pcie0_1_perst_pins[] = { 22, };
876static int mt7623_pcie0_1_perst_funcs[] = { 2, };
877static int mt7623_pcie1_0_perst_pins[] = { 209, };
878static int mt7623_pcie1_0_perst_funcs[] = { 3, };
879static int mt7623_pcie1_1_perst_pins[] = { 23, };
880static int mt7623_pcie1_1_perst_funcs[] = { 2, };
881static int mt7623_pcie2_0_perst_pins[] = { 24, };
882static int mt7623_pcie2_0_perst_funcs[] = { 2, };
883static int mt7623_pcie2_1_perst_pins[] = { 29, };
884static int mt7623_pcie2_1_perst_funcs[] = { 6, };
885static int mt7623_pcie0_0_wake_pins[] = { 28, };
886static int mt7623_pcie0_0_wake_funcs[] = { 6, };
887static int mt7623_pcie0_1_wake_pins[] = { 251, };
888static int mt7623_pcie0_1_wake_funcs[] = { 6, };
889static int mt7623_pcie1_0_wake_pins[] = { 27, };
890static int mt7623_pcie1_0_wake_funcs[] = { 6, };
891static int mt7623_pcie1_1_wake_pins[] = { 253, };
892static int mt7623_pcie1_1_wake_funcs[] = { 6, };
893static int mt7623_pcie2_0_wake_pins[] = { 26, };
894static int mt7623_pcie2_0_wake_funcs[] = { 6, };
895static int mt7623_pcie2_1_wake_pins[] = { 255, };
896static int mt7623_pcie2_1_wake_funcs[] = { 6, };
897static int mt7623_pcie0_clkreq_pins[] = { 250, };
898static int mt7623_pcie0_clkreq_funcs[] = { 6, };
899static int mt7623_pcie1_clkreq_pins[] = { 252, };
900static int mt7623_pcie1_clkreq_funcs[] = { 6, };
901static int mt7623_pcie2_clkreq_pins[] = { 254, };
902static int mt7623_pcie2_clkreq_funcs[] = { 6, };
903
904/* the pcie_*_rev are only used for MT7623 */
905static int mt7623_pcie0_0_rev_perst_pins[] = { 208, };
906static int mt7623_pcie0_0_rev_perst_funcs[] = { 11, };
907static int mt7623_pcie0_1_rev_perst_pins[] = { 22, };
908static int mt7623_pcie0_1_rev_perst_funcs[] = { 10, };
909static int mt7623_pcie1_0_rev_perst_pins[] = { 209, };
910static int mt7623_pcie1_0_rev_perst_funcs[] = { 11, };
911static int mt7623_pcie1_1_rev_perst_pins[] = { 23, };
912static int mt7623_pcie1_1_rev_perst_funcs[] = { 10, };
913static int mt7623_pcie2_0_rev_perst_pins[] = { 24, };
914static int mt7623_pcie2_0_rev_perst_funcs[] = { 11, };
915static int mt7623_pcie2_1_rev_perst_pins[] = { 29, };
916static int mt7623_pcie2_1_rev_perst_funcs[] = { 14, };
917
918/* PCM */
919static int mt7623_pcm_clk_0_pins[] = { 18, };
920static int mt7623_pcm_clk_0_funcs[] = { 1, };
921static int mt7623_pcm_clk_1_pins[] = { 17, };
922static int mt7623_pcm_clk_1_funcs[] = { 3, };
923static int mt7623_pcm_clk_2_pins[] = { 35, };
924static int mt7623_pcm_clk_2_funcs[] = { 3, };
925static int mt7623_pcm_clk_3_pins[] = { 50, };
926static int mt7623_pcm_clk_3_funcs[] = { 3, };
927static int mt7623_pcm_clk_4_pins[] = { 74, };
928static int mt7623_pcm_clk_4_funcs[] = { 3, };
929static int mt7623_pcm_clk_5_pins[] = { 191, };
930static int mt7623_pcm_clk_5_funcs[] = { 3, };
931static int mt7623_pcm_clk_6_pins[] = { 196, };
932static int mt7623_pcm_clk_6_funcs[] = { 3, };
933static int mt7623_pcm_sync_0_pins[] = { 19, };
934static int mt7623_pcm_sync_0_funcs[] = { 1, };
935static int mt7623_pcm_sync_1_pins[] = { 30, };
936static int mt7623_pcm_sync_1_funcs[] = { 3, };
937static int mt7623_pcm_sync_2_pins[] = { 36, };
938static int mt7623_pcm_sync_2_funcs[] = { 3, };
939static int mt7623_pcm_sync_3_pins[] = { 52, };
940static int mt7623_pcm_sync_3_funcs[] = { 31, };
941static int mt7623_pcm_sync_4_pins[] = { 73, };
942static int mt7623_pcm_sync_4_funcs[] = { 3, };
943static int mt7623_pcm_sync_5_pins[] = { 192, };
944static int mt7623_pcm_sync_5_funcs[] = { 3, };
945static int mt7623_pcm_sync_6_pins[] = { 197, };
946static int mt7623_pcm_sync_6_funcs[] = { 3, };
947static int mt7623_pcm_rx_0_pins[] = { 20, };
948static int mt7623_pcm_rx_0_funcs[] = { 1, };
949static int mt7623_pcm_rx_1_pins[] = { 16, };
950static int mt7623_pcm_rx_1_funcs[] = { 3, };
951static int mt7623_pcm_rx_2_pins[] = { 34, };
952static int mt7623_pcm_rx_2_funcs[] = { 3, };
953static int mt7623_pcm_rx_3_pins[] = { 51, };
954static int mt7623_pcm_rx_3_funcs[] = { 3, };
955static int mt7623_pcm_rx_4_pins[] = { 72, };
956static int mt7623_pcm_rx_4_funcs[] = { 3, };
957static int mt7623_pcm_rx_5_pins[] = { 190, };
958static int mt7623_pcm_rx_5_funcs[] = { 3, };
959static int mt7623_pcm_rx_6_pins[] = { 195, };
960static int mt7623_pcm_rx_6_funcs[] = { 3, };
961static int mt7623_pcm_tx_0_pins[] = { 21, };
962static int mt7623_pcm_tx_0_funcs[] = { 1, };
963static int mt7623_pcm_tx_1_pins[] = { 32, };
964static int mt7623_pcm_tx_1_funcs[] = { 3, };
965static int mt7623_pcm_tx_2_pins[] = { 33, };
966static int mt7623_pcm_tx_2_funcs[] = { 3, };
967static int mt7623_pcm_tx_3_pins[] = { 38, };
968static int mt7623_pcm_tx_3_funcs[] = { 3, };
969static int mt7623_pcm_tx_4_pins[] = { 49, };
970static int mt7623_pcm_tx_4_funcs[] = { 3, };
971static int mt7623_pcm_tx_5_pins[] = { 189, };
972static int mt7623_pcm_tx_5_funcs[] = { 3, };
973static int mt7623_pcm_tx_6_pins[] = { 194, };
974static int mt7623_pcm_tx_6_funcs[] = { 3, };
975
976/* PWM */
977static int mt7623_pwm_ch1_0_pins[] = { 203, };
978static int mt7623_pwm_ch1_0_funcs[] = { 1, };
979static int mt7623_pwm_ch1_1_pins[] = { 208, };
980static int mt7623_pwm_ch1_1_funcs[] = { 2, };
981static int mt7623_pwm_ch1_2_pins[] = { 72, };
982static int mt7623_pwm_ch1_2_funcs[] = { 4, };
983static int mt7623_pwm_ch1_3_pins[] = { 88, };
984static int mt7623_pwm_ch1_3_funcs[] = { 3, };
985static int mt7623_pwm_ch1_4_pins[] = { 108, };
986static int mt7623_pwm_ch1_4_funcs[] = { 3, };
987static int mt7623_pwm_ch2_0_pins[] = { 204, };
988static int mt7623_pwm_ch2_0_funcs[] = { 1, };
989static int mt7623_pwm_ch2_1_pins[] = { 53, };
990static int mt7623_pwm_ch2_1_funcs[] = { 5, };
991static int mt7623_pwm_ch2_2_pins[] = { 88, };
992static int mt7623_pwm_ch2_2_funcs[] = { 6, };
993static int mt7623_pwm_ch2_3_pins[] = { 108, };
994static int mt7623_pwm_ch2_3_funcs[] = { 6, };
995static int mt7623_pwm_ch2_4_pins[] = { 209, };
996static int mt7623_pwm_ch2_4_funcs[] = { 5, };
997static int mt7623_pwm_ch3_0_pins[] = { 205, };
998static int mt7623_pwm_ch3_0_funcs[] = { 1, };
999static int mt7623_pwm_ch3_1_pins[] = { 55, };
1000static int mt7623_pwm_ch3_1_funcs[] = { 5, };
1001static int mt7623_pwm_ch3_2_pins[] = { 89, };
1002static int mt7623_pwm_ch3_2_funcs[] = { 6, };
1003static int mt7623_pwm_ch3_3_pins[] = { 109, };
1004static int mt7623_pwm_ch3_3_funcs[] = { 6, };
1005static int mt7623_pwm_ch4_0_pins[] = { 206, };
1006static int mt7623_pwm_ch4_0_funcs[] = { 1, };
1007static int mt7623_pwm_ch4_1_pins[] = { 90, };
1008static int mt7623_pwm_ch4_1_funcs[] = { 6, };
1009static int mt7623_pwm_ch4_2_pins[] = { 110, };
1010static int mt7623_pwm_ch4_2_funcs[] = { 6, };
1011static int mt7623_pwm_ch4_3_pins[] = { 124, };
1012static int mt7623_pwm_ch4_3_funcs[] = { 5, };
1013static int mt7623_pwm_ch5_0_pins[] = { 207, };
1014static int mt7623_pwm_ch5_0_funcs[] = { 1, };
1015static int mt7623_pwm_ch5_1_pins[] = { 125, };
1016static int mt7623_pwm_ch5_1_funcs[] = { 5, };
1017
1018/* PWRAP */
1019static int mt7623_pwrap_pins[] = { 0, 1, 2, 3, 4, 5, 6, };
1020static int mt7623_pwrap_funcs[] = { 1, 1, 1, 1, 1, 1, 1, };
1021
1022/* SPDIF */
1023static int mt7623_spdif_in0_0_pins[] = { 56, };
1024static int mt7623_spdif_in0_0_funcs[] = { 3, };
1025static int mt7623_spdif_in0_1_pins[] = { 201, };
1026static int mt7623_spdif_in0_1_funcs[] = { 1, };
1027static int mt7623_spdif_in1_0_pins[] = { 54, };
1028static int mt7623_spdif_in1_0_funcs[] = { 3, };
1029static int mt7623_spdif_in1_1_pins[] = { 202, };
1030static int mt7623_spdif_in1_1_funcs[] = { 1, };
1031static int mt7623_spdif_out_pins[] = { 202, };
1032static int mt7623_spdif_out_funcs[] = { 1, };
1033
1034/* SPI */
1035static int mt7623_spi0_pins[] = { 53, 54, 55, 56, };
1036static int mt7623_spi0_funcs[] = { 1, 1, 1, 1, };
1037static int mt7623_spi1_pins[] = { 7, 199, 8, 9, };
1038static int mt7623_spi1_funcs[] = { 1, 1, 1, 1, };
1039static int mt7623_spi2_pins[] = { 101, 104, 102, 103, };
1040static int mt7623_spi2_funcs[] = { 1, 1, 1, 1, };
1041
1042/* UART */
1043static int mt7623_uart0_0_txd_rxd_pins[] = { 79, 80, };
1044static int mt7623_uart0_0_txd_rxd_funcs[] = { 1, 1, };
1045static int mt7623_uart0_1_txd_rxd_pins[] = { 87, 88, };
1046static int mt7623_uart0_1_txd_rxd_funcs[] = { 5, 5, };
1047static int mt7623_uart0_2_txd_rxd_pins[] = { 107, 108, };
1048static int mt7623_uart0_2_txd_rxd_funcs[] = { 5, 5, };
1049static int mt7623_uart0_3_txd_rxd_pins[] = { 123, 122, };
1050static int mt7623_uart0_3_txd_rxd_funcs[] = { 5, 5, };
1051static int mt7623_uart0_rts_cts_pins[] = { 22, 23, };
1052static int mt7623_uart0_rts_cts_funcs[] = { 1, 1, };
1053static int mt7623_uart1_0_txd_rxd_pins[] = { 81, 82, };
1054static int mt7623_uart1_0_txd_rxd_funcs[] = { 1, 1, };
1055static int mt7623_uart1_1_txd_rxd_pins[] = { 89, 90, };
1056static int mt7623_uart1_1_txd_rxd_funcs[] = { 5, 5, };
1057static int mt7623_uart1_2_txd_rxd_pins[] = { 109, 110, };
1058static int mt7623_uart1_2_txd_rxd_funcs[] = { 5, 5, };
1059static int mt7623_uart1_rts_cts_pins[] = { 24, 25, };
1060static int mt7623_uart1_rts_cts_funcs[] = { 1, 1, };
1061static int mt7623_uart2_0_txd_rxd_pins[] = { 14, 15, };
1062static int mt7623_uart2_0_txd_rxd_funcs[] = { 1, 1, };
1063static int mt7623_uart2_1_txd_rxd_pins[] = { 200, 201, };
1064static int mt7623_uart2_1_txd_rxd_funcs[] = { 6, 6, };
1065static int mt7623_uart2_rts_cts_pins[] = { 242, 243, };
1066static int mt7623_uart2_rts_cts_funcs[] = { 1, 1, };
1067static int mt7623_uart3_txd_rxd_pins[] = { 242, 243, };
1068static int mt7623_uart3_txd_rxd_funcs[] = { 2, 2, };
1069static int mt7623_uart3_rts_cts_pins[] = { 26, 27, };
1070static int mt7623_uart3_rts_cts_funcs[] = { 1, 1, };
1071
1072/* Watchdog */
1073static int mt7623_watchdog_0_pins[] = { 11, };
1074static int mt7623_watchdog_0_funcs[] = { 1, };
1075static int mt7623_watchdog_1_pins[] = { 121, };
1076static int mt7623_watchdog_1_funcs[] = { 5, };
1077
1078static const struct group_desc mt7623_groups[] = {
1079 PINCTRL_PIN_GROUP("aud_ext_clk0", mt7623_aud_ext_clk0),
1080 PINCTRL_PIN_GROUP("aud_ext_clk1", mt7623_aud_ext_clk1),
1081 PINCTRL_PIN_GROUP("dsi_te", mt7623_dsi_te),
1082 PINCTRL_PIN_GROUP("disp_pwm_0", mt7623_disp_pwm_0),
1083 PINCTRL_PIN_GROUP("disp_pwm_1", mt7623_disp_pwm_1),
1084 PINCTRL_PIN_GROUP("disp_pwm_2", mt7623_disp_pwm_2),
1085 PINCTRL_PIN_GROUP("ephy", mt7623_ephy),
1086 PINCTRL_PIN_GROUP("esw_int", mt7623_esw_int),
1087 PINCTRL_PIN_GROUP("esw_rst", mt7623_esw_rst),
1088 PINCTRL_PIN_GROUP("ext_sdio", mt7623_ext_sdio),
1089 PINCTRL_PIN_GROUP("hdmi_cec", mt7623_hdmi_cec),
1090 PINCTRL_PIN_GROUP("hdmi_htplg", mt7623_hdmi_htplg),
1091 PINCTRL_PIN_GROUP("hdmi_i2c", mt7623_hdmi_i2c),
1092 PINCTRL_PIN_GROUP("hdmi_rx", mt7623_hdmi_rx),
1093 PINCTRL_PIN_GROUP("hdmi_rx_i2c", mt7623_hdmi_rx_i2c),
1094 PINCTRL_PIN_GROUP("i2c0", mt7623_i2c0),
1095 PINCTRL_PIN_GROUP("i2c1_0", mt7623_i2c1_0),
1096 PINCTRL_PIN_GROUP("i2c1_1", mt7623_i2c1_1),
1097 PINCTRL_PIN_GROUP("i2c1_2", mt7623_i2c1_2),
1098 PINCTRL_PIN_GROUP("i2c1_3", mt7623_i2c1_3),
1099 PINCTRL_PIN_GROUP("i2c1_4", mt7623_i2c1_4),
1100 PINCTRL_PIN_GROUP("i2c2_0", mt7623_i2c2_0),
1101 PINCTRL_PIN_GROUP("i2c2_1", mt7623_i2c2_1),
1102 PINCTRL_PIN_GROUP("i2c2_2", mt7623_i2c2_2),
1103 PINCTRL_PIN_GROUP("i2c2_3", mt7623_i2c2_3),
1104 PINCTRL_PIN_GROUP("i2s0", mt7623_i2s0),
1105 PINCTRL_PIN_GROUP("i2s1", mt7623_i2s1),
1106 PINCTRL_PIN_GROUP("i2s4", mt7623_i2s4),
1107 PINCTRL_PIN_GROUP("i2s5", mt7623_i2s5),
1108 PINCTRL_PIN_GROUP("i2s2_bclk_lrclk_mclk", mt7623_i2s2_bclk_lrclk_mclk),
1109 PINCTRL_PIN_GROUP("i2s3_bclk_lrclk_mclk", mt7623_i2s3_bclk_lrclk_mclk),
1110 PINCTRL_PIN_GROUP("i2s2_data_in", mt7623_i2s2_data_in),
1111 PINCTRL_PIN_GROUP("i2s3_data_in", mt7623_i2s3_data_in),
1112 PINCTRL_PIN_GROUP("i2s2_data_0", mt7623_i2s2_data_0),
1113 PINCTRL_PIN_GROUP("i2s2_data_1", mt7623_i2s2_data_1),
1114 PINCTRL_PIN_GROUP("i2s3_data_0", mt7623_i2s3_data_0),
1115 PINCTRL_PIN_GROUP("i2s3_data_1", mt7623_i2s3_data_1),
1116 PINCTRL_PIN_GROUP("ir", mt7623_ir),
1117 PINCTRL_PIN_GROUP("lcm_rst", mt7623_lcm_rst),
1118 PINCTRL_PIN_GROUP("mdc_mdio", mt7623_mdc_mdio),
1119 PINCTRL_PIN_GROUP("mipi_tx", mt7623_mipi_tx),
1120 PINCTRL_PIN_GROUP("msdc0", mt7623_msdc0),
1121 PINCTRL_PIN_GROUP("msdc1", mt7623_msdc1),
1122 PINCTRL_PIN_GROUP("msdc1_ins", mt7623_msdc1_ins),
1123 PINCTRL_PIN_GROUP("msdc1_wp_0", mt7623_msdc1_wp_0),
1124 PINCTRL_PIN_GROUP("msdc1_wp_1", mt7623_msdc1_wp_1),
1125 PINCTRL_PIN_GROUP("msdc1_wp_2", mt7623_msdc1_wp_2),
1126 PINCTRL_PIN_GROUP("msdc2", mt7623_msdc2),
1127 PINCTRL_PIN_GROUP("msdc3", mt7623_msdc3),
1128 PINCTRL_PIN_GROUP("nandc", mt7623_nandc),
1129 PINCTRL_PIN_GROUP("nandc_ceb0", mt7623_nandc_ceb0),
1130 PINCTRL_PIN_GROUP("nandc_ceb1", mt7623_nandc_ceb1),
1131 PINCTRL_PIN_GROUP("otg_iddig0_0", mt7623_otg_iddig0_0),
1132 PINCTRL_PIN_GROUP("otg_iddig0_1", mt7623_otg_iddig0_1),
1133 PINCTRL_PIN_GROUP("otg_iddig0_2", mt7623_otg_iddig0_2),
1134 PINCTRL_PIN_GROUP("otg_iddig1_0", mt7623_otg_iddig1_0),
1135 PINCTRL_PIN_GROUP("otg_iddig1_1", mt7623_otg_iddig1_1),
1136 PINCTRL_PIN_GROUP("otg_iddig1_2", mt7623_otg_iddig1_2),
1137 PINCTRL_PIN_GROUP("otg_drv_vbus0_0", mt7623_otg_drv_vbus0_0),
1138 PINCTRL_PIN_GROUP("otg_drv_vbus0_1", mt7623_otg_drv_vbus0_1),
1139 PINCTRL_PIN_GROUP("otg_drv_vbus0_2", mt7623_otg_drv_vbus0_2),
1140 PINCTRL_PIN_GROUP("otg_drv_vbus1_0", mt7623_otg_drv_vbus1_0),
1141 PINCTRL_PIN_GROUP("otg_drv_vbus1_1", mt7623_otg_drv_vbus1_1),
1142 PINCTRL_PIN_GROUP("otg_drv_vbus1_2", mt7623_otg_drv_vbus1_2),
1143 PINCTRL_PIN_GROUP("pcie0_0_perst", mt7623_pcie0_0_perst),
1144 PINCTRL_PIN_GROUP("pcie0_1_perst", mt7623_pcie0_1_perst),
1145 PINCTRL_PIN_GROUP("pcie1_0_perst", mt7623_pcie1_0_perst),
1146 PINCTRL_PIN_GROUP("pcie1_1_perst", mt7623_pcie1_1_perst),
1147 PINCTRL_PIN_GROUP("pcie1_1_perst", mt7623_pcie1_1_perst),
1148 PINCTRL_PIN_GROUP("pcie0_0_rev_perst", mt7623_pcie0_0_rev_perst),
1149 PINCTRL_PIN_GROUP("pcie0_1_rev_perst", mt7623_pcie0_1_rev_perst),
1150 PINCTRL_PIN_GROUP("pcie1_0_rev_perst", mt7623_pcie1_0_rev_perst),
1151 PINCTRL_PIN_GROUP("pcie1_1_rev_perst", mt7623_pcie1_1_rev_perst),
1152 PINCTRL_PIN_GROUP("pcie2_0_rev_perst", mt7623_pcie2_0_rev_perst),
1153 PINCTRL_PIN_GROUP("pcie2_1_rev_perst", mt7623_pcie2_1_rev_perst),
1154 PINCTRL_PIN_GROUP("pcie2_0_perst", mt7623_pcie2_0_perst),
1155 PINCTRL_PIN_GROUP("pcie2_1_perst", mt7623_pcie2_1_perst),
1156 PINCTRL_PIN_GROUP("pcie0_0_wake", mt7623_pcie0_0_wake),
1157 PINCTRL_PIN_GROUP("pcie0_1_wake", mt7623_pcie0_1_wake),
1158 PINCTRL_PIN_GROUP("pcie1_0_wake", mt7623_pcie1_0_wake),
1159 PINCTRL_PIN_GROUP("pcie1_1_wake", mt7623_pcie1_1_wake),
1160 PINCTRL_PIN_GROUP("pcie2_0_wake", mt7623_pcie2_0_wake),
1161 PINCTRL_PIN_GROUP("pcie2_1_wake", mt7623_pcie2_1_wake),
1162 PINCTRL_PIN_GROUP("pcie0_clkreq", mt7623_pcie0_clkreq),
1163 PINCTRL_PIN_GROUP("pcie1_clkreq", mt7623_pcie1_clkreq),
1164 PINCTRL_PIN_GROUP("pcie2_clkreq", mt7623_pcie2_clkreq),
1165 PINCTRL_PIN_GROUP("pcm_clk_0", mt7623_pcm_clk_0),
1166 PINCTRL_PIN_GROUP("pcm_clk_1", mt7623_pcm_clk_1),
1167 PINCTRL_PIN_GROUP("pcm_clk_2", mt7623_pcm_clk_2),
1168 PINCTRL_PIN_GROUP("pcm_clk_3", mt7623_pcm_clk_3),
1169 PINCTRL_PIN_GROUP("pcm_clk_4", mt7623_pcm_clk_4),
1170 PINCTRL_PIN_GROUP("pcm_clk_5", mt7623_pcm_clk_5),
1171 PINCTRL_PIN_GROUP("pcm_clk_6", mt7623_pcm_clk_6),
1172 PINCTRL_PIN_GROUP("pcm_sync_0", mt7623_pcm_sync_0),
1173 PINCTRL_PIN_GROUP("pcm_sync_1", mt7623_pcm_sync_1),
1174 PINCTRL_PIN_GROUP("pcm_sync_2", mt7623_pcm_sync_2),
1175 PINCTRL_PIN_GROUP("pcm_sync_3", mt7623_pcm_sync_3),
1176 PINCTRL_PIN_GROUP("pcm_sync_4", mt7623_pcm_sync_4),
1177 PINCTRL_PIN_GROUP("pcm_sync_5", mt7623_pcm_sync_5),
1178 PINCTRL_PIN_GROUP("pcm_sync_6", mt7623_pcm_sync_6),
1179 PINCTRL_PIN_GROUP("pcm_rx_0", mt7623_pcm_rx_0),
1180 PINCTRL_PIN_GROUP("pcm_rx_1", mt7623_pcm_rx_1),
1181 PINCTRL_PIN_GROUP("pcm_rx_2", mt7623_pcm_rx_2),
1182 PINCTRL_PIN_GROUP("pcm_rx_3", mt7623_pcm_rx_3),
1183 PINCTRL_PIN_GROUP("pcm_rx_4", mt7623_pcm_rx_4),
1184 PINCTRL_PIN_GROUP("pcm_rx_5", mt7623_pcm_rx_5),
1185 PINCTRL_PIN_GROUP("pcm_rx_6", mt7623_pcm_rx_6),
1186 PINCTRL_PIN_GROUP("pcm_tx_0", mt7623_pcm_tx_0),
1187 PINCTRL_PIN_GROUP("pcm_tx_1", mt7623_pcm_tx_1),
1188 PINCTRL_PIN_GROUP("pcm_tx_2", mt7623_pcm_tx_2),
1189 PINCTRL_PIN_GROUP("pcm_tx_3", mt7623_pcm_tx_3),
1190 PINCTRL_PIN_GROUP("pcm_tx_4", mt7623_pcm_tx_4),
1191 PINCTRL_PIN_GROUP("pcm_tx_5", mt7623_pcm_tx_5),
1192 PINCTRL_PIN_GROUP("pcm_tx_6", mt7623_pcm_tx_6),
1193 PINCTRL_PIN_GROUP("pwm_ch1_0", mt7623_pwm_ch1_0),
1194 PINCTRL_PIN_GROUP("pwm_ch1_1", mt7623_pwm_ch1_1),
1195 PINCTRL_PIN_GROUP("pwm_ch1_2", mt7623_pwm_ch1_2),
1196 PINCTRL_PIN_GROUP("pwm_ch1_3", mt7623_pwm_ch1_3),
1197 PINCTRL_PIN_GROUP("pwm_ch1_4", mt7623_pwm_ch1_4),
1198 PINCTRL_PIN_GROUP("pwm_ch2_0", mt7623_pwm_ch2_0),
1199 PINCTRL_PIN_GROUP("pwm_ch2_1", mt7623_pwm_ch2_1),
1200 PINCTRL_PIN_GROUP("pwm_ch2_2", mt7623_pwm_ch2_2),
1201 PINCTRL_PIN_GROUP("pwm_ch2_3", mt7623_pwm_ch2_3),
1202 PINCTRL_PIN_GROUP("pwm_ch2_4", mt7623_pwm_ch2_4),
1203 PINCTRL_PIN_GROUP("pwm_ch3_0", mt7623_pwm_ch3_0),
1204 PINCTRL_PIN_GROUP("pwm_ch3_1", mt7623_pwm_ch3_1),
1205 PINCTRL_PIN_GROUP("pwm_ch3_2", mt7623_pwm_ch3_2),
1206 PINCTRL_PIN_GROUP("pwm_ch3_3", mt7623_pwm_ch3_3),
1207 PINCTRL_PIN_GROUP("pwm_ch4_0", mt7623_pwm_ch4_0),
1208 PINCTRL_PIN_GROUP("pwm_ch4_1", mt7623_pwm_ch4_1),
1209 PINCTRL_PIN_GROUP("pwm_ch4_2", mt7623_pwm_ch4_2),
1210 PINCTRL_PIN_GROUP("pwm_ch4_3", mt7623_pwm_ch4_3),
1211 PINCTRL_PIN_GROUP("pwm_ch5_0", mt7623_pwm_ch5_0),
1212 PINCTRL_PIN_GROUP("pwm_ch5_1", mt7623_pwm_ch5_1),
1213 PINCTRL_PIN_GROUP("pwrap", mt7623_pwrap),
1214 PINCTRL_PIN_GROUP("rtc", mt7623_rtc),
1215 PINCTRL_PIN_GROUP("spdif_in0_0", mt7623_spdif_in0_0),
1216 PINCTRL_PIN_GROUP("spdif_in0_1", mt7623_spdif_in0_1),
1217 PINCTRL_PIN_GROUP("spdif_in1_0", mt7623_spdif_in1_0),
1218 PINCTRL_PIN_GROUP("spdif_in1_1", mt7623_spdif_in1_1),
1219 PINCTRL_PIN_GROUP("spdif_out", mt7623_spdif_out),
1220 PINCTRL_PIN_GROUP("spi0", mt7623_spi0),
1221 PINCTRL_PIN_GROUP("spi1", mt7623_spi1),
1222 PINCTRL_PIN_GROUP("spi2", mt7623_spi2),
1223 PINCTRL_PIN_GROUP("uart0_0_txd_rxd", mt7623_uart0_0_txd_rxd),
1224 PINCTRL_PIN_GROUP("uart0_1_txd_rxd", mt7623_uart0_1_txd_rxd),
1225 PINCTRL_PIN_GROUP("uart0_2_txd_rxd", mt7623_uart0_2_txd_rxd),
1226 PINCTRL_PIN_GROUP("uart0_3_txd_rxd", mt7623_uart0_3_txd_rxd),
1227 PINCTRL_PIN_GROUP("uart1_0_txd_rxd", mt7623_uart1_0_txd_rxd),
1228 PINCTRL_PIN_GROUP("uart1_1_txd_rxd", mt7623_uart1_1_txd_rxd),
1229 PINCTRL_PIN_GROUP("uart1_2_txd_rxd", mt7623_uart1_2_txd_rxd),
1230 PINCTRL_PIN_GROUP("uart2_0_txd_rxd", mt7623_uart2_0_txd_rxd),
1231 PINCTRL_PIN_GROUP("uart2_1_txd_rxd", mt7623_uart2_1_txd_rxd),
1232 PINCTRL_PIN_GROUP("uart3_txd_rxd", mt7623_uart3_txd_rxd),
1233 PINCTRL_PIN_GROUP("uart0_rts_cts", mt7623_uart0_rts_cts),
1234 PINCTRL_PIN_GROUP("uart1_rts_cts", mt7623_uart1_rts_cts),
1235 PINCTRL_PIN_GROUP("uart2_rts_cts", mt7623_uart2_rts_cts),
1236 PINCTRL_PIN_GROUP("uart3_rts_cts", mt7623_uart3_rts_cts),
1237 PINCTRL_PIN_GROUP("watchdog_0", mt7623_watchdog_0),
1238 PINCTRL_PIN_GROUP("watchdog_1", mt7623_watchdog_1),
1239};
1240
1241/* Joint those groups owning the same capability in user point of view which
1242 * allows that people tend to use through the device tree.
1243 */
1244static const char *mt7623_aud_clk_groups[] = { "aud_ext_clk0",
1245 "aud_ext_clk1", };
1246static const char *mt7623_disp_pwm_groups[] = { "disp_pwm_0", "disp_pwm_1",
1247 "disp_pwm_2", };
1248static const char *mt7623_ethernet_groups[] = { "esw_int", "esw_rst",
1249 "ephy", "mdc_mdio", };
1250static const char *mt7623_ext_sdio_groups[] = { "ext_sdio", };
1251static const char *mt7623_hdmi_groups[] = { "hdmi_cec", "hdmi_htplg",
1252 "hdmi_i2c", "hdmi_rx",
1253 "hdmi_rx_i2c", };
1254static const char *mt7623_i2c_groups[] = { "i2c0", "i2c1_0", "i2c1_1",
1255 "i2c1_2", "i2c1_3", "i2c1_4",
1256 "i2c2_0", "i2c2_1", "i2c2_2",
1257 "i2c2_3", };
1258static const char *mt7623_i2s_groups[] = { "i2s0", "i2s1",
1259 "i2s2_bclk_lrclk_mclk",
1260 "i2s3_bclk_lrclk_mclk",
1261 "i2s4", "i2s5",
1262 "i2s2_data_in", "i2s3_data_in",
1263 "i2s2_data_0", "i2s2_data_1",
1264 "i2s3_data_0", "i2s3_data_1", };
1265static const char *mt7623_ir_groups[] = { "ir", };
1266static const char *mt7623_lcd_groups[] = { "dsi_te", "lcm_rst", "mipi_tx", };
1267static const char *mt7623_msdc_groups[] = { "msdc0", "msdc1", "msdc1_ins",
1268 "msdc1_wp_0", "msdc1_wp_1",
1269 "msdc1_wp_2", "msdc2",
1270 "msdc3", };
1271static const char *mt7623_nandc_groups[] = { "nandc", "nandc_ceb0",
1272 "nandc_ceb1", };
1273static const char *mt7623_otg_groups[] = { "otg_iddig0_0", "otg_iddig0_1",
1274 "otg_iddig0_2", "otg_iddig1_0",
1275 "otg_iddig1_1", "otg_iddig1_2",
1276 "otg_drv_vbus0_0",
1277 "otg_drv_vbus0_1",
1278 "otg_drv_vbus0_2",
1279 "otg_drv_vbus1_0",
1280 "otg_drv_vbus1_1",
1281 "otg_drv_vbus1_2", };
1282static const char *mt7623_pcie_groups[] = { "pcie0_0_perst", "pcie0_1_perst",
1283 "pcie1_0_perst", "pcie1_1_perst",
1284 "pcie2_0_perst", "pcie2_1_perst",
1285 "pcie0_0_rev_perst",
1286 "pcie0_1_rev_perst",
1287 "pcie1_0_rev_perst",
1288 "pcie1_1_rev_perst",
1289 "pcie2_0_rev_perst",
1290 "pcie2_1_rev_perst",
1291 "pcie0_0_wake", "pcie0_1_wake",
1292 "pcie2_0_wake", "pcie2_1_wake",
1293 "pcie0_clkreq", "pcie1_clkreq",
1294 "pcie2_clkreq", };
1295static const char *mt7623_pcm_groups[] = { "pcm_clk_0", "pcm_clk_1",
1296 "pcm_clk_2", "pcm_clk_3",
1297 "pcm_clk_4", "pcm_clk_5",
1298 "pcm_clk_6", "pcm_sync_0",
1299 "pcm_sync_1", "pcm_sync_2",
1300 "pcm_sync_3", "pcm_sync_4",
1301 "pcm_sync_5", "pcm_sync_6",
1302 "pcm_rx_0", "pcm_rx_1",
1303 "pcm_rx_2", "pcm_rx_3",
1304 "pcm_rx_4", "pcm_rx_5",
1305 "pcm_rx_6", "pcm_tx_0",
1306 "pcm_tx_1", "pcm_tx_2",
1307 "pcm_tx_3", "pcm_tx_4",
1308 "pcm_tx_5", "pcm_tx_6", };
1309static const char *mt7623_pwm_groups[] = { "pwm_ch1_0", "pwm_ch1_1",
1310 "pwm_ch1_2", "pwm_ch2_0",
1311 "pwm_ch2_1", "pwm_ch2_2",
1312 "pwm_ch3_0", "pwm_ch3_1",
1313 "pwm_ch3_2", "pwm_ch4_0",
1314 "pwm_ch4_1", "pwm_ch4_2",
1315 "pwm_ch4_3", "pwm_ch5_0",
1316 "pwm_ch5_1", "pwm_ch5_2",
1317 "pwm_ch6_0", "pwm_ch6_1",
1318 "pwm_ch6_2", "pwm_ch6_3",
1319 "pwm_ch7_0", "pwm_ch7_1",
1320 "pwm_ch7_2", };
1321static const char *mt7623_pwrap_groups[] = { "pwrap", };
1322static const char *mt7623_rtc_groups[] = { "rtc", };
1323static const char *mt7623_spi_groups[] = { "spi0", "spi2", "spi2", };
1324static const char *mt7623_spdif_groups[] = { "spdif_in0_0", "spdif_in0_1",
1325 "spdif_in1_0", "spdif_in1_1",
1326 "spdif_out", };
1327static const char *mt7623_uart_groups[] = { "uart0_0_txd_rxd",
1328 "uart0_1_txd_rxd",
1329 "uart0_2_txd_rxd",
1330 "uart0_3_txd_rxd",
1331 "uart1_0_txd_rxd",
1332 "uart1_1_txd_rxd",
1333 "uart1_2_txd_rxd",
1334 "uart2_0_txd_rxd",
1335 "uart2_1_txd_rxd",
1336 "uart3_txd_rxd",
1337 "uart0_rts_cts",
1338 "uart1_rts_cts",
1339 "uart2_rts_cts",
1340 "uart3_rts_cts", };
1341static const char *mt7623_wdt_groups[] = { "watchdog_0", "watchdog_1", };
1342
1343static const struct function_desc mt7623_functions[] = {
1344 {"audck", mt7623_aud_clk_groups, ARRAY_SIZE(mt7623_aud_clk_groups)},
1345 {"disp", mt7623_disp_pwm_groups, ARRAY_SIZE(mt7623_disp_pwm_groups)},
1346 {"eth", mt7623_ethernet_groups, ARRAY_SIZE(mt7623_ethernet_groups)},
1347 {"sdio", mt7623_ext_sdio_groups, ARRAY_SIZE(mt7623_ext_sdio_groups)},
1348 {"hdmi", mt7623_hdmi_groups, ARRAY_SIZE(mt7623_hdmi_groups)},
1349 {"i2c", mt7623_i2c_groups, ARRAY_SIZE(mt7623_i2c_groups)},
1350 {"i2s", mt7623_i2s_groups, ARRAY_SIZE(mt7623_i2s_groups)},
1351 {"ir", mt7623_ir_groups, ARRAY_SIZE(mt7623_ir_groups)},
1352 {"lcd", mt7623_lcd_groups, ARRAY_SIZE(mt7623_lcd_groups)},
1353 {"msdc", mt7623_msdc_groups, ARRAY_SIZE(mt7623_msdc_groups)},
1354 {"nand", mt7623_nandc_groups, ARRAY_SIZE(mt7623_nandc_groups)},
1355 {"otg", mt7623_otg_groups, ARRAY_SIZE(mt7623_otg_groups)},
1356 {"pcie", mt7623_pcie_groups, ARRAY_SIZE(mt7623_pcie_groups)},
1357 {"pcm", mt7623_pcm_groups, ARRAY_SIZE(mt7623_pcm_groups)},
1358 {"pwm", mt7623_pwm_groups, ARRAY_SIZE(mt7623_pwm_groups)},
1359 {"pwrap", mt7623_pwrap_groups, ARRAY_SIZE(mt7623_pwrap_groups)},
1360 {"rtc", mt7623_rtc_groups, ARRAY_SIZE(mt7623_rtc_groups)},
1361 {"spi", mt7623_spi_groups, ARRAY_SIZE(mt7623_spi_groups)},
1362 {"spdif", mt7623_spdif_groups, ARRAY_SIZE(mt7623_spdif_groups)},
1363 {"uart", mt7623_uart_groups, ARRAY_SIZE(mt7623_uart_groups)},
1364 {"watchdog", mt7623_wdt_groups, ARRAY_SIZE(mt7623_wdt_groups)},
1365};
1366
1367static const struct mtk_eint_hw mt7623_eint_hw = {
1368 .port_mask = 6,
1369 .ports = 6,
1370 .ap_num = 169,
1371 .db_cnt = 20,
1372};
1373
1374static struct mtk_pin_soc mt7623_data = {
1375 .reg_cal = mt7623_reg_cals,
1376 .pins = mt7623_pins,
1377 .npins = ARRAY_SIZE(mt7623_pins),
1378 .grps = mt7623_groups,
1379 .ngrps = ARRAY_SIZE(mt7623_groups),
1380 .funcs = mt7623_functions,
1381 .nfuncs = ARRAY_SIZE(mt7623_functions),
1382 .eint_hw = &mt7623_eint_hw,
1383 .gpio_m = 0,
1384 .ies_present = true,
1385 .base_names = mtk_default_register_base_names,
1386 .nbase_names = ARRAY_SIZE(mtk_default_register_base_names),
1387 .bias_disable_set = mtk_pinconf_bias_disable_set_rev1,
1388 .bias_disable_get = mtk_pinconf_bias_disable_get_rev1,
1389 .bias_set = mtk_pinconf_bias_set_rev1,
1390 .bias_get = mtk_pinconf_bias_get_rev1,
1391 .drive_set = mtk_pinconf_drive_set_rev1,
1392 .drive_get = mtk_pinconf_drive_get_rev1,
1393 .adv_pull_get = mtk_pinconf_adv_pull_get,
1394 .adv_pull_set = mtk_pinconf_adv_pull_set,
1395};
1396
1397/*
1398 * There are some specific pins have mux functions greater than 8,
1399 * and if we want to switch thees high modes we need to disable
1400 * bonding constraints firstly.
1401 */
1402static void mt7623_bonding_disable(struct platform_device *pdev)
1403{
1404 struct mtk_pinctrl *hw = platform_get_drvdata(pdev);
1405
1406 mtk_rmw(hw, 0, PIN_BOND_REG0, BOND_PCIE_CLR, BOND_PCIE_CLR);
1407 mtk_rmw(hw, 0, PIN_BOND_REG1, BOND_I2S_CLR, BOND_I2S_CLR);
1408 mtk_rmw(hw, 0, PIN_BOND_REG2, BOND_MSDC0E_CLR, BOND_MSDC0E_CLR);
1409}
1410
1411static const struct of_device_id mt7623_pctrl_match[] = {
1412 { .compatible = "mediatek,mt7623-moore-pinctrl", },
1413 {}
1414};
1415
1416static int mt7623_pinctrl_probe(struct platform_device *pdev)
1417{
1418 int err;
1419
1420 err = mtk_moore_pinctrl_probe(pdev, &mt7623_data);
1421 if (err)
1422 return err;
1423
1424 mt7623_bonding_disable(pdev);
1425
1426 return 0;
1427}
1428
1429static struct platform_driver mtk_pinctrl_driver = {
1430 .probe = mt7623_pinctrl_probe,
1431 .driver = {
1432 .name = "mt7623-moore-pinctrl",
1433 .of_match_table = mt7623_pctrl_match,
1434 },
1435};
1436
1437static int __init mtk_pinctrl_init(void)
1438{
1439 return platform_driver_register(&mtk_pinctrl_driver);
1440}
1441arch_initcall(mtk_pinctrl_init);
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8183.c b/drivers/pinctrl/mediatek/pinctrl-mt8183.c
new file mode 100644
index 000000000000..6262fd3678ea
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8183.c
@@ -0,0 +1,544 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2018 MediaTek Inc.
4 *
5 * Author: Zhiyong Tao <zhiyong.tao@mediatek.com>
6 *
7 */
8
9#include "pinctrl-mtk-mt8183.h"
10#include "pinctrl-paris.h"
11
12/* MT8183 have multiple bases to program pin configuration listed as the below:
13 * iocfg[0]:0x10005000, iocfg[1]:0x11F20000, iocfg[2]:0x11E80000,
14 * iocfg[3]:0x11E70000, iocfg[4]:0x11E90000, iocfg[5]:0x11D30000,
15 * iocfg[6]:0x11D20000, iocfg[7]:0x11C50000, iocfg[8]:0x11F30000.
16 * _i_based could be used to indicate what base the pin should be mapped into.
17 */
18
19#define PIN_FIELD_BASE(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, _s_bit, _x_bits) \
20 PIN_FIELD_CALC(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, _s_bit, \
21 _x_bits, 32, 0)
22
23#define PINS_FIELD_BASE(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, _s_bit, _x_bits) \
24 PIN_FIELD_CALC(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, _s_bit, \
25 _x_bits, 32, 1)
26
27static const struct mtk_pin_field_calc mt8183_pin_mode_range[] = {
28 PIN_FIELD(0, 192, 0x300, 0x10, 0, 4),
29};
30
31static const struct mtk_pin_field_calc mt8183_pin_dir_range[] = {
32 PIN_FIELD(0, 192, 0x0, 0x10, 0, 1),
33};
34
35static const struct mtk_pin_field_calc mt8183_pin_di_range[] = {
36 PIN_FIELD(0, 192, 0x200, 0x10, 0, 1),
37};
38
39static const struct mtk_pin_field_calc mt8183_pin_do_range[] = {
40 PIN_FIELD(0, 192, 0x100, 0x10, 0, 1),
41};
42
43static const struct mtk_pin_field_calc mt8183_pin_ies_range[] = {
44 PINS_FIELD_BASE(0, 3, 6, 0x000, 0x10, 3, 1),
45 PINS_FIELD_BASE(4, 7, 6, 0x000, 0x10, 5, 1),
46 PIN_FIELD_BASE(8, 8, 6, 0x000, 0x10, 0, 1),
47 PINS_FIELD_BASE(9, 10, 6, 0x000, 0x10, 12, 1),
48 PIN_FIELD_BASE(11, 11, 1, 0x000, 0x10, 3, 1),
49 PIN_FIELD_BASE(12, 12, 1, 0x000, 0x10, 7, 1),
50 PINS_FIELD_BASE(13, 16, 2, 0x000, 0x10, 2, 1),
51 PINS_FIELD_BASE(17, 20, 2, 0x000, 0x10, 3, 1),
52 PINS_FIELD_BASE(21, 24, 2, 0x000, 0x10, 4, 1),
53 PINS_FIELD_BASE(25, 28, 2, 0x000, 0x10, 5, 1),
54 PIN_FIELD_BASE(29, 29, 2, 0x000, 0x10, 6, 1),
55 PIN_FIELD_BASE(30, 30, 2, 0x000, 0x10, 7, 1),
56 PINS_FIELD_BASE(31, 31, 2, 0x000, 0x10, 8, 1),
57 PINS_FIELD_BASE(32, 34, 2, 0x000, 0x10, 7, 1),
58 PINS_FIELD_BASE(35, 37, 3, 0x000, 0x10, 0, 1),
59 PINS_FIELD_BASE(38, 40, 3, 0x000, 0x10, 1, 1),
60 PINS_FIELD_BASE(41, 42, 3, 0x000, 0x10, 2, 1),
61 PINS_FIELD_BASE(43, 45, 3, 0x000, 0x10, 3, 1),
62 PINS_FIELD_BASE(46, 47, 3, 0x000, 0x10, 4, 1),
63 PINS_FIELD_BASE(48, 49, 3, 0x000, 0x10, 5, 1),
64 PINS_FIELD_BASE(50, 51, 4, 0x000, 0x10, 0, 1),
65 PINS_FIELD_BASE(52, 57, 4, 0x000, 0x10, 1, 1),
66 PINS_FIELD_BASE(58, 60, 4, 0x000, 0x10, 2, 1),
67 PINS_FIELD_BASE(61, 64, 5, 0x000, 0x10, 0, 1),
68 PINS_FIELD_BASE(65, 66, 5, 0x000, 0x10, 1, 1),
69 PINS_FIELD_BASE(67, 68, 5, 0x000, 0x10, 2, 1),
70 PINS_FIELD_BASE(69, 71, 5, 0x000, 0x10, 3, 1),
71 PINS_FIELD_BASE(72, 76, 5, 0x000, 0x10, 4, 1),
72 PINS_FIELD_BASE(77, 80, 5, 0x000, 0x10, 5, 1),
73 PIN_FIELD_BASE(81, 81, 5, 0x000, 0x10, 6, 1),
74 PINS_FIELD_BASE(82, 83, 5, 0x000, 0x10, 7, 1),
75 PIN_FIELD_BASE(84, 84, 5, 0x000, 0x10, 6, 1),
76 PINS_FIELD_BASE(85, 88, 5, 0x000, 0x10, 8, 1),
77 PIN_FIELD_BASE(89, 89, 6, 0x000, 0x10, 11, 1),
78 PIN_FIELD_BASE(90, 90, 6, 0x000, 0x10, 1, 1),
79 PINS_FIELD_BASE(91, 94, 6, 0x000, 0x10, 2, 1),
80 PINS_FIELD_BASE(95, 96, 6, 0x000, 0x10, 6, 1),
81 PINS_FIELD_BASE(97, 98, 6, 0x000, 0x10, 7, 1),
82 PIN_FIELD_BASE(99, 99, 6, 0x000, 0x10, 8, 1),
83 PIN_FIELD_BASE(100, 100, 6, 0x000, 0x10, 9, 1),
84 PINS_FIELD_BASE(101, 102, 6, 0x000, 0x10, 10, 1),
85 PINS_FIELD_BASE(103, 104, 6, 0x000, 0x10, 13, 1),
86 PINS_FIELD_BASE(105, 106, 6, 0x000, 0x10, 14, 1),
87 PIN_FIELD_BASE(107, 107, 7, 0x000, 0x10, 0, 1),
88 PIN_FIELD_BASE(108, 108, 7, 0x000, 0x10, 1, 1),
89 PIN_FIELD_BASE(109, 109, 7, 0x000, 0x10, 2, 1),
90 PIN_FIELD_BASE(110, 110, 7, 0x000, 0x10, 0, 1),
91 PIN_FIELD_BASE(111, 111, 7, 0x000, 0x10, 3, 1),
92 PIN_FIELD_BASE(112, 112, 7, 0x000, 0x10, 2, 1),
93 PIN_FIELD_BASE(113, 113, 7, 0x000, 0x10, 4, 1),
94 PIN_FIELD_BASE(114, 114, 7, 0x000, 0x10, 5, 1),
95 PIN_FIELD_BASE(115, 115, 7, 0x000, 0x10, 6, 1),
96 PIN_FIELD_BASE(116, 116, 7, 0x000, 0x10, 7, 1),
97 PIN_FIELD_BASE(117, 117, 7, 0x000, 0x10, 8, 1),
98 PIN_FIELD_BASE(118, 118, 7, 0x000, 0x10, 9, 1),
99 PIN_FIELD_BASE(119, 119, 7, 0x000, 0x10, 10, 1),
100 PIN_FIELD_BASE(120, 120, 7, 0x000, 0x10, 11, 1),
101 PIN_FIELD_BASE(121, 121, 7, 0x000, 0x10, 12, 1),
102 PIN_FIELD_BASE(122, 122, 8, 0x000, 0x10, 0, 1),
103 PIN_FIELD_BASE(123, 123, 8, 0x000, 0x10, 1, 1),
104 PIN_FIELD_BASE(124, 124, 8, 0x000, 0x10, 2, 1),
105 PINS_FIELD_BASE(125, 130, 8, 0x000, 0x10, 1, 1),
106 PIN_FIELD_BASE(131, 131, 8, 0x000, 0x10, 3, 1),
107 PIN_FIELD_BASE(132, 132, 8, 0x000, 0x10, 1, 1),
108 PIN_FIELD_BASE(133, 133, 8, 0x000, 0x10, 4, 1),
109 PIN_FIELD_BASE(134, 134, 1, 0x000, 0x10, 0, 1),
110 PIN_FIELD_BASE(135, 135, 1, 0x000, 0x10, 1, 1),
111 PINS_FIELD_BASE(136, 143, 1, 0x000, 0x10, 2, 1),
112 PINS_FIELD_BASE(144, 147, 1, 0x000, 0x10, 4, 1),
113 PIN_FIELD_BASE(148, 148, 1, 0x000, 0x10, 5, 1),
114 PIN_FIELD_BASE(149, 149, 1, 0x000, 0x10, 6, 1),
115 PINS_FIELD_BASE(150, 153, 1, 0x000, 0x10, 8, 1),
116 PIN_FIELD_BASE(154, 154, 1, 0x000, 0x10, 9, 1),
117 PINS_FIELD_BASE(155, 157, 1, 0x000, 0x10, 10, 1),
118 PINS_FIELD_BASE(158, 160, 1, 0x000, 0x10, 8, 1),
119 PINS_FIELD_BASE(161, 164, 2, 0x000, 0x10, 0, 1),
120 PINS_FIELD_BASE(165, 166, 2, 0x000, 0x10, 1, 1),
121 PINS_FIELD_BASE(167, 168, 4, 0x000, 0x10, 2, 1),
122 PIN_FIELD_BASE(169, 169, 4, 0x000, 0x10, 3, 1),
123 PINS_FIELD_BASE(170, 174, 4, 0x000, 0x10, 4, 1),
124 PINS_FIELD_BASE(175, 176, 4, 0x000, 0x10, 3, 1),
125 PINS_FIELD_BASE(177, 179, 6, 0x000, 0x10, 4, 1),
126};
127
128static const struct mtk_pin_field_calc mt8183_pin_smt_range[] = {
129 PINS_FIELD_BASE(0, 3, 6, 0x010, 0x10, 3, 1),
130 PINS_FIELD_BASE(4, 7, 6, 0x010, 0x10, 5, 1),
131 PIN_FIELD_BASE(8, 8, 6, 0x010, 0x10, 0, 1),
132 PINS_FIELD_BASE(9, 10, 6, 0x010, 0x10, 12, 1),
133 PIN_FIELD_BASE(11, 11, 1, 0x010, 0x10, 3, 1),
134 PIN_FIELD_BASE(12, 12, 1, 0x010, 0x10, 7, 1),
135 PINS_FIELD_BASE(13, 16, 2, 0x010, 0x10, 2, 1),
136 PINS_FIELD_BASE(17, 20, 2, 0x010, 0x10, 3, 1),
137 PINS_FIELD_BASE(21, 24, 2, 0x010, 0x10, 4, 1),
138 PINS_FIELD_BASE(25, 28, 2, 0x010, 0x10, 5, 1),
139 PIN_FIELD_BASE(29, 29, 2, 0x010, 0x10, 6, 1),
140 PIN_FIELD_BASE(30, 30, 2, 0x010, 0x10, 7, 1),
141 PINS_FIELD_BASE(31, 31, 2, 0x010, 0x10, 8, 1),
142 PINS_FIELD_BASE(32, 34, 2, 0x010, 0x10, 7, 1),
143 PINS_FIELD_BASE(35, 37, 3, 0x010, 0x10, 0, 1),
144 PINS_FIELD_BASE(38, 40, 3, 0x010, 0x10, 1, 1),
145 PINS_FIELD_BASE(41, 42, 3, 0x010, 0x10, 2, 1),
146 PINS_FIELD_BASE(43, 45, 3, 0x010, 0x10, 3, 1),
147 PINS_FIELD_BASE(46, 47, 3, 0x010, 0x10, 4, 1),
148 PINS_FIELD_BASE(48, 49, 3, 0x010, 0x10, 5, 1),
149 PINS_FIELD_BASE(50, 51, 4, 0x010, 0x10, 0, 1),
150 PINS_FIELD_BASE(52, 57, 4, 0x010, 0x10, 1, 1),
151 PINS_FIELD_BASE(58, 60, 4, 0x010, 0x10, 2, 1),
152 PINS_FIELD_BASE(61, 64, 5, 0x010, 0x10, 0, 1),
153 PINS_FIELD_BASE(65, 66, 5, 0x010, 0x10, 1, 1),
154 PINS_FIELD_BASE(67, 68, 5, 0x010, 0x10, 2, 1),
155 PINS_FIELD_BASE(69, 71, 5, 0x010, 0x10, 3, 1),
156 PINS_FIELD_BASE(72, 76, 5, 0x010, 0x10, 4, 1),
157 PINS_FIELD_BASE(77, 80, 5, 0x010, 0x10, 5, 1),
158 PIN_FIELD_BASE(81, 81, 5, 0x010, 0x10, 6, 1),
159 PINS_FIELD_BASE(82, 83, 5, 0x010, 0x10, 7, 1),
160 PIN_FIELD_BASE(84, 84, 5, 0x010, 0x10, 6, 1),
161 PINS_FIELD_BASE(85, 88, 5, 0x010, 0x10, 8, 1),
162 PIN_FIELD_BASE(89, 89, 6, 0x010, 0x10, 11, 1),
163 PIN_FIELD_BASE(90, 90, 6, 0x010, 0x10, 1, 1),
164 PINS_FIELD_BASE(91, 94, 6, 0x010, 0x10, 2, 1),
165 PINS_FIELD_BASE(95, 96, 6, 0x010, 0x10, 6, 1),
166 PINS_FIELD_BASE(97, 98, 6, 0x010, 0x10, 7, 1),
167 PIN_FIELD_BASE(99, 99, 6, 0x010, 0x10, 8, 1),
168 PIN_FIELD_BASE(100, 100, 6, 0x010, 0x10, 9, 1),
169 PINS_FIELD_BASE(101, 102, 6, 0x010, 0x10, 10, 1),
170 PINS_FIELD_BASE(103, 104, 6, 0x010, 0x10, 13, 1),
171 PINS_FIELD_BASE(105, 106, 6, 0x010, 0x10, 14, 1),
172 PIN_FIELD_BASE(107, 107, 7, 0x010, 0x10, 0, 1),
173 PIN_FIELD_BASE(108, 108, 7, 0x010, 0x10, 1, 1),
174 PIN_FIELD_BASE(109, 109, 7, 0x010, 0x10, 2, 1),
175 PIN_FIELD_BASE(110, 110, 7, 0x010, 0x10, 0, 1),
176 PIN_FIELD_BASE(111, 111, 7, 0x010, 0x10, 3, 1),
177 PIN_FIELD_BASE(112, 112, 7, 0x010, 0x10, 2, 1),
178 PIN_FIELD_BASE(113, 113, 7, 0x010, 0x10, 4, 1),
179 PIN_FIELD_BASE(114, 114, 7, 0x010, 0x10, 5, 1),
180 PIN_FIELD_BASE(115, 115, 7, 0x010, 0x10, 6, 1),
181 PIN_FIELD_BASE(116, 116, 7, 0x010, 0x10, 7, 1),
182 PIN_FIELD_BASE(117, 117, 7, 0x010, 0x10, 8, 1),
183 PIN_FIELD_BASE(118, 118, 7, 0x010, 0x10, 9, 1),
184 PIN_FIELD_BASE(119, 119, 7, 0x010, 0x10, 10, 1),
185 PIN_FIELD_BASE(120, 120, 7, 0x010, 0x10, 11, 1),
186 PIN_FIELD_BASE(121, 121, 7, 0x010, 0x10, 12, 1),
187 PIN_FIELD_BASE(122, 122, 8, 0x010, 0x10, 0, 1),
188 PIN_FIELD_BASE(123, 123, 8, 0x010, 0x10, 1, 1),
189 PIN_FIELD_BASE(124, 124, 8, 0x010, 0x10, 2, 1),
190 PINS_FIELD_BASE(125, 130, 8, 0x010, 0x10, 1, 1),
191 PIN_FIELD_BASE(131, 131, 8, 0x010, 0x10, 3, 1),
192 PIN_FIELD_BASE(132, 132, 8, 0x010, 0x10, 1, 1),
193 PIN_FIELD_BASE(133, 133, 8, 0x010, 0x10, 4, 1),
194 PIN_FIELD_BASE(134, 134, 1, 0x010, 0x10, 0, 1),
195 PIN_FIELD_BASE(135, 135, 1, 0x010, 0x10, 1, 1),
196 PINS_FIELD_BASE(136, 143, 1, 0x010, 0x10, 2, 1),
197 PINS_FIELD_BASE(144, 147, 1, 0x010, 0x10, 4, 1),
198 PIN_FIELD_BASE(148, 148, 1, 0x010, 0x10, 5, 1),
199 PIN_FIELD_BASE(149, 149, 1, 0x010, 0x10, 6, 1),
200 PINS_FIELD_BASE(150, 153, 1, 0x010, 0x10, 8, 1),
201 PIN_FIELD_BASE(154, 154, 1, 0x010, 0x10, 9, 1),
202 PINS_FIELD_BASE(155, 157, 1, 0x010, 0x10, 10, 1),
203 PINS_FIELD_BASE(158, 160, 1, 0x010, 0x10, 8, 1),
204 PINS_FIELD_BASE(161, 164, 2, 0x010, 0x10, 0, 1),
205 PINS_FIELD_BASE(165, 166, 2, 0x010, 0x10, 1, 1),
206 PINS_FIELD_BASE(167, 168, 4, 0x010, 0x10, 2, 1),
207 PIN_FIELD_BASE(169, 169, 4, 0x010, 0x10, 3, 1),
208 PINS_FIELD_BASE(170, 174, 4, 0x010, 0x10, 4, 1),
209 PINS_FIELD_BASE(175, 176, 4, 0x010, 0x10, 3, 1),
210 PINS_FIELD_BASE(177, 179, 6, 0x010, 0x10, 4, 1),
211};
212
213static const struct mtk_pin_field_calc mt8183_pin_pullen_range[] = {
214 PIN_FIELD_BASE(0, 3, 6, 0x060, 0x10, 6, 1),
215 PIN_FIELD_BASE(4, 7, 6, 0x060, 0x10, 11, 1),
216 PIN_FIELD_BASE(8, 8, 6, 0x060, 0x10, 0, 1),
217 PIN_FIELD_BASE(9, 10, 6, 0x060, 0x10, 26, 1),
218 PIN_FIELD_BASE(11, 11, 1, 0x060, 0x10, 10, 1),
219 PIN_FIELD_BASE(12, 12, 1, 0x060, 0x10, 17, 1),
220 PIN_FIELD_BASE(13, 28, 2, 0x060, 0x10, 6, 1),
221 PIN_FIELD_BASE(43, 49, 3, 0x060, 0x10, 8, 1),
222 PIN_FIELD_BASE(50, 60, 4, 0x060, 0x10, 0, 1),
223 PIN_FIELD_BASE(61, 88, 5, 0x060, 0x10, 0, 1),
224 PIN_FIELD_BASE(89, 89, 6, 0x060, 0x10, 24, 1),
225 PIN_FIELD_BASE(90, 90, 6, 0x060, 0x10, 1, 1),
226 PIN_FIELD_BASE(95, 95, 6, 0x060, 0x10, 15, 1),
227 PIN_FIELD_BASE(96, 102, 6, 0x060, 0x10, 17, 1),
228 PIN_FIELD_BASE(103, 106, 6, 0x060, 0x10, 28, 1),
229 PIN_FIELD_BASE(107, 121, 7, 0x060, 0x10, 0, 1),
230 PIN_FIELD_BASE(134, 143, 1, 0x060, 0x10, 0, 1),
231 PIN_FIELD_BASE(144, 149, 1, 0x060, 0x10, 11, 1),
232 PIN_FIELD_BASE(150, 160, 1, 0x060, 0x10, 18, 1),
233 PIN_FIELD_BASE(161, 166, 2, 0x060, 0x10, 0, 1),
234 PIN_FIELD_BASE(167, 176, 4, 0x060, 0x10, 11, 1),
235 PIN_FIELD_BASE(177, 177, 6, 0x060, 0x10, 10, 1),
236 PIN_FIELD_BASE(178, 178, 6, 0x060, 0x10, 16, 1),
237 PIN_FIELD_BASE(179, 179, 6, 0x060, 0x10, 25, 1),
238};
239
240static const struct mtk_pin_field_calc mt8183_pin_pullsel_range[] = {
241 PIN_FIELD_BASE(0, 3, 6, 0x080, 0x10, 6, 1),
242 PIN_FIELD_BASE(4, 7, 6, 0x080, 0x10, 11, 1),
243 PIN_FIELD_BASE(8, 8, 6, 0x080, 0x10, 0, 1),
244 PIN_FIELD_BASE(9, 10, 6, 0x080, 0x10, 26, 1),
245 PIN_FIELD_BASE(11, 11, 1, 0x080, 0x10, 10, 1),
246 PIN_FIELD_BASE(12, 12, 1, 0x080, 0x10, 17, 1),
247 PIN_FIELD_BASE(13, 28, 2, 0x080, 0x10, 6, 1),
248 PIN_FIELD_BASE(43, 49, 3, 0x080, 0x10, 8, 1),
249 PIN_FIELD_BASE(50, 60, 4, 0x080, 0x10, 0, 1),
250 PIN_FIELD_BASE(61, 88, 5, 0x080, 0x10, 0, 1),
251 PIN_FIELD_BASE(89, 89, 6, 0x080, 0x10, 24, 1),
252 PIN_FIELD_BASE(90, 90, 6, 0x080, 0x10, 1, 1),
253 PIN_FIELD_BASE(95, 95, 6, 0x080, 0x10, 15, 1),
254 PIN_FIELD_BASE(96, 102, 6, 0x080, 0x10, 17, 1),
255 PIN_FIELD_BASE(103, 106, 6, 0x080, 0x10, 28, 1),
256 PIN_FIELD_BASE(107, 121, 7, 0x080, 0x10, 0, 1),
257 PIN_FIELD_BASE(134, 143, 1, 0x080, 0x10, 0, 1),
258 PIN_FIELD_BASE(144, 149, 1, 0x080, 0x10, 11, 1),
259 PIN_FIELD_BASE(150, 160, 1, 0x080, 0x10, 18, 1),
260 PIN_FIELD_BASE(161, 166, 2, 0x080, 0x10, 0, 1),
261 PIN_FIELD_BASE(167, 176, 4, 0x080, 0x10, 11, 1),
262 PIN_FIELD_BASE(177, 177, 6, 0x080, 0x10, 10, 1),
263 PIN_FIELD_BASE(178, 178, 6, 0x080, 0x10, 16, 1),
264 PIN_FIELD_BASE(179, 179, 6, 0x080, 0x10, 25, 1),
265};
266
267static const struct mtk_pin_field_calc mt8183_pin_drv_range[] = {
268 PINS_FIELD_BASE(0, 3, 6, 0x0A0, 0x10, 12, 3),
269 PINS_FIELD_BASE(4, 7, 6, 0x0A0, 0x10, 20, 3),
270 PIN_FIELD_BASE(8, 8, 6, 0x0A0, 0x10, 0, 3),
271 PINS_FIELD_BASE(9, 10, 6, 0x0B0, 0x10, 16, 3),
272 PIN_FIELD_BASE(11, 11, 1, 0x0A0, 0x10, 12, 3),
273 PIN_FIELD_BASE(12, 12, 1, 0x0A0, 0x10, 28, 3),
274 PINS_FIELD_BASE(13, 16, 2, 0x0A0, 0x10, 8, 3),
275 PINS_FIELD_BASE(17, 20, 2, 0x0A0, 0x10, 12, 3),
276 PINS_FIELD_BASE(21, 24, 2, 0x0A0, 0x10, 16, 3),
277 PINS_FIELD_BASE(25, 28, 2, 0x0A0, 0x10, 20, 3),
278 PIN_FIELD_BASE(29, 29, 2, 0x0A0, 0x10, 24, 3),
279 PIN_FIELD_BASE(30, 30, 2, 0x0A0, 0x10, 28, 3),
280 PINS_FIELD_BASE(31, 31, 2, 0x0B0, 0x10, 0, 3),
281 PINS_FIELD_BASE(32, 34, 2, 0x0A0, 0x10, 28, 3),
282 PINS_FIELD_BASE(35, 37, 3, 0x0A0, 0x10, 0, 3),
283 PINS_FIELD_BASE(38, 40, 3, 0x0A0, 0x10, 4, 3),
284 PINS_FIELD_BASE(41, 42, 3, 0x0A0, 0x10, 8, 3),
285 PINS_FIELD_BASE(43, 45, 3, 0x0A0, 0x10, 12, 3),
286 PINS_FIELD_BASE(46, 47, 3, 0x0A0, 0x10, 16, 3),
287 PINS_FIELD_BASE(48, 49, 3, 0x0A0, 0x10, 20, 3),
288 PINS_FIELD_BASE(50, 51, 4, 0x0A0, 0x10, 0, 3),
289 PINS_FIELD_BASE(52, 57, 4, 0x0A0, 0x10, 4, 3),
290 PINS_FIELD_BASE(58, 60, 4, 0x0A0, 0x10, 8, 3),
291 PINS_FIELD_BASE(61, 64, 5, 0x0A0, 0x10, 0, 3),
292 PINS_FIELD_BASE(65, 66, 5, 0x0A0, 0x10, 4, 3),
293 PINS_FIELD_BASE(67, 68, 5, 0x0A0, 0x10, 8, 3),
294 PINS_FIELD_BASE(69, 71, 5, 0x0A0, 0x10, 12, 3),
295 PINS_FIELD_BASE(72, 76, 5, 0x0A0, 0x10, 16, 3),
296 PINS_FIELD_BASE(77, 80, 5, 0x0A0, 0x10, 20, 3),
297 PIN_FIELD_BASE(81, 81, 5, 0x0A0, 0x10, 24, 3),
298 PINS_FIELD_BASE(82, 83, 5, 0x0A0, 0x10, 28, 3),
299 PIN_FIELD_BASE(84, 84, 5, 0x0A0, 0x10, 24, 3),
300 PINS_FIELD_BASE(85, 88, 5, 0x0B0, 0x10, 0, 3),
301 PIN_FIELD_BASE(89, 89, 6, 0x0B0, 0x10, 12, 3),
302 PIN_FIELD_BASE(90, 90, 6, 0x0A0, 0x10, 4, 3),
303 PINS_FIELD_BASE(91, 94, 6, 0x0A0, 0x10, 8, 3),
304 PINS_FIELD_BASE(95, 96, 6, 0x0A0, 0x10, 24, 3),
305 PINS_FIELD_BASE(97, 98, 6, 0x0A0, 0x10, 28, 3),
306 PIN_FIELD_BASE(99, 99, 6, 0x0B0, 0x10, 0, 3),
307 PIN_FIELD_BASE(100, 100, 6, 0x0B0, 0x10, 4, 3),
308 PINS_FIELD_BASE(101, 102, 6, 0x0B0, 0x10, 8, 3),
309 PINS_FIELD_BASE(103, 104, 6, 0x0B0, 0x10, 20, 3),
310 PINS_FIELD_BASE(105, 106, 6, 0x0B0, 0x10, 24, 3),
311 PIN_FIELD_BASE(107, 107, 7, 0x0A0, 0x10, 0, 3),
312 PIN_FIELD_BASE(108, 108, 7, 0x0A0, 0x10, 4, 3),
313 PIN_FIELD_BASE(109, 109, 7, 0x0A0, 0x10, 8, 3),
314 PIN_FIELD_BASE(110, 110, 7, 0x0A0, 0x10, 0, 3),
315 PIN_FIELD_BASE(111, 111, 7, 0x0A0, 0x10, 4, 3),
316 PIN_FIELD_BASE(112, 112, 7, 0x0A0, 0x10, 8, 3),
317 PIN_FIELD_BASE(113, 113, 7, 0x0A0, 0x10, 16, 3),
318 PIN_FIELD_BASE(114, 114, 7, 0x0A0, 0x10, 20, 3),
319 PIN_FIELD_BASE(115, 115, 7, 0x0A0, 0x10, 24, 3),
320 PIN_FIELD_BASE(116, 116, 7, 0x0A0, 0x10, 28, 3),
321 PIN_FIELD_BASE(117, 117, 7, 0x0B0, 0x10, 0, 3),
322 PIN_FIELD_BASE(118, 118, 7, 0x0B0, 0x10, 4, 3),
323 PIN_FIELD_BASE(119, 119, 7, 0x0B0, 0x10, 8, 3),
324 PIN_FIELD_BASE(120, 120, 7, 0x0B0, 0x10, 12, 3),
325 PIN_FIELD_BASE(121, 121, 7, 0x0B0, 0x10, 16, 3),
326 PIN_FIELD_BASE(122, 122, 8, 0x0A0, 0x10, 0, 3),
327 PIN_FIELD_BASE(123, 123, 8, 0x0A0, 0x10, 4, 3),
328 PIN_FIELD_BASE(124, 124, 8, 0x0A0, 0x10, 8, 3),
329 PINS_FIELD_BASE(125, 130, 8, 0x0A0, 0x10, 4, 3),
330 PIN_FIELD_BASE(131, 131, 8, 0x0A0, 0x10, 12, 3),
331 PIN_FIELD_BASE(132, 132, 8, 0x0A0, 0x10, 4, 3),
332 PIN_FIELD_BASE(133, 133, 8, 0x0A0, 0x10, 16, 3),
333 PIN_FIELD_BASE(134, 134, 1, 0x0A0, 0x10, 0, 3),
334 PIN_FIELD_BASE(135, 135, 1, 0x0A0, 0x10, 4, 3),
335 PINS_FIELD_BASE(136, 143, 1, 0x0A0, 0x10, 8, 3),
336 PINS_FIELD_BASE(144, 147, 1, 0x0A0, 0x10, 16, 3),
337 PIN_FIELD_BASE(148, 148, 1, 0x0A0, 0x10, 20, 3),
338 PIN_FIELD_BASE(149, 149, 1, 0x0A0, 0x10, 24, 3),
339 PINS_FIELD_BASE(150, 153, 1, 0x0B0, 0x10, 0, 3),
340 PIN_FIELD_BASE(154, 154, 1, 0x0B0, 0x10, 4, 3),
341 PINS_FIELD_BASE(155, 157, 1, 0x0B0, 0x10, 8, 3),
342 PINS_FIELD_BASE(158, 160, 1, 0x0B0, 0x10, 0, 3),
343 PINS_FIELD_BASE(161, 164, 2, 0x0A0, 0x10, 0, 3),
344 PINS_FIELD_BASE(165, 166, 2, 0x0A0, 0x10, 4, 3),
345 PINS_FIELD_BASE(167, 168, 4, 0x0A0, 0x10, 8, 3),
346 PIN_FIELD_BASE(169, 169, 4, 0x0A0, 0x10, 12, 3),
347 PINS_FIELD_BASE(170, 174, 4, 0x0A0, 0x10, 16, 3),
348 PINS_FIELD_BASE(175, 176, 4, 0x0A0, 0x10, 12, 3),
349 PINS_FIELD_BASE(177, 179, 6, 0x0A0, 0x10, 16, 3),
350};
351
352static const struct mtk_pin_field_calc mt8183_pin_pupd_range[] = {
353 PIN_FIELD_BASE(29, 29, 2, 0x0C0, 0x10, 2, 1),
354 PIN_FIELD_BASE(30, 30, 2, 0x0C0, 0x10, 6, 1),
355 PIN_FIELD_BASE(31, 31, 2, 0x0C0, 0x10, 10, 1),
356 PIN_FIELD_BASE(32, 32, 2, 0x0C0, 0x10, 14, 1),
357 PIN_FIELD_BASE(33, 33, 2, 0x0C0, 0x10, 18, 1),
358 PIN_FIELD_BASE(34, 34, 2, 0x0C0, 0x10, 22, 1),
359 PIN_FIELD_BASE(35, 35, 3, 0x0C0, 0x10, 2, 1),
360 PIN_FIELD_BASE(36, 36, 3, 0x0C0, 0x10, 6, 1),
361 PIN_FIELD_BASE(37, 37, 3, 0x0C0, 0x10, 10, 1),
362 PIN_FIELD_BASE(38, 38, 3, 0x0C0, 0x10, 14, 1),
363 PIN_FIELD_BASE(39, 39, 3, 0x0C0, 0x10, 18, 1),
364 PIN_FIELD_BASE(40, 40, 3, 0x0C0, 0x10, 22, 1),
365 PIN_FIELD_BASE(41, 41, 3, 0x0C0, 0x10, 26, 1),
366 PIN_FIELD_BASE(42, 42, 3, 0x0C0, 0x10, 30, 1),
367 PIN_FIELD_BASE(91, 91, 6, 0x0C0, 0x10, 2, 1),
368 PIN_FIELD_BASE(92, 92, 6, 0x0C0, 0x10, 6, 1),
369 PIN_FIELD_BASE(93, 93, 6, 0x0C0, 0x10, 10, 1),
370 PIN_FIELD_BASE(94, 94, 6, 0x0C0, 0x10, 14, 1),
371 PIN_FIELD_BASE(122, 122, 8, 0x0C0, 0x10, 2, 1),
372 PIN_FIELD_BASE(123, 123, 8, 0x0C0, 0x10, 6, 1),
373 PIN_FIELD_BASE(124, 124, 8, 0x0C0, 0x10, 10, 1),
374 PIN_FIELD_BASE(125, 125, 8, 0x0C0, 0x10, 14, 1),
375 PIN_FIELD_BASE(126, 126, 8, 0x0C0, 0x10, 18, 1),
376 PIN_FIELD_BASE(127, 127, 8, 0x0C0, 0x10, 22, 1),
377 PIN_FIELD_BASE(128, 128, 8, 0x0C0, 0x10, 26, 1),
378 PIN_FIELD_BASE(129, 129, 8, 0x0C0, 0x10, 30, 1),
379 PIN_FIELD_BASE(130, 130, 8, 0x0D0, 0x10, 2, 1),
380 PIN_FIELD_BASE(131, 131, 8, 0x0D0, 0x10, 6, 1),
381 PIN_FIELD_BASE(132, 132, 8, 0x0D0, 0x10, 10, 1),
382 PIN_FIELD_BASE(133, 133, 8, 0x0D0, 0x10, 14, 1),
383};
384
385static const struct mtk_pin_field_calc mt8183_pin_r0_range[] = {
386 PIN_FIELD_BASE(29, 29, 2, 0x0C0, 0x10, 0, 1),
387 PIN_FIELD_BASE(30, 30, 2, 0x0C0, 0x10, 4, 1),
388 PIN_FIELD_BASE(31, 31, 2, 0x0C0, 0x10, 8, 1),
389 PIN_FIELD_BASE(32, 32, 2, 0x0C0, 0x10, 12, 1),
390 PIN_FIELD_BASE(33, 33, 2, 0x0C0, 0x10, 16, 1),
391 PIN_FIELD_BASE(34, 34, 2, 0x0C0, 0x10, 20, 1),
392 PIN_FIELD_BASE(35, 35, 3, 0x0C0, 0x10, 0, 1),
393 PIN_FIELD_BASE(36, 36, 3, 0x0C0, 0x10, 4, 1),
394 PIN_FIELD_BASE(37, 37, 3, 0x0C0, 0x10, 8, 1),
395 PIN_FIELD_BASE(38, 38, 3, 0x0C0, 0x10, 12, 1),
396 PIN_FIELD_BASE(39, 39, 3, 0x0C0, 0x10, 16, 1),
397 PIN_FIELD_BASE(40, 40, 3, 0x0C0, 0x10, 20, 1),
398 PIN_FIELD_BASE(41, 41, 3, 0x0C0, 0x10, 24, 1),
399 PIN_FIELD_BASE(42, 42, 3, 0x0C0, 0x10, 28, 1),
400 PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 18, 1),
401 PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 13, 1),
402 PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 10, 1),
403 PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 5, 1),
404 PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 7, 1),
405 PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 5, 1),
406 PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 15, 1),
407 PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 17, 1),
408 PIN_FIELD_BASE(91, 91, 6, 0x0C0, 0x10, 0, 1),
409 PIN_FIELD_BASE(92, 92, 6, 0x0C0, 0x10, 4, 1),
410 PIN_FIELD_BASE(93, 93, 6, 0x0C0, 0x10, 8, 1),
411 PIN_FIELD_BASE(94, 94, 6, 0x0C0, 0x10, 12, 1),
412 PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 20, 1),
413 PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 10, 1),
414 PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 22, 1),
415 PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 12, 1),
416 PIN_FIELD_BASE(122, 122, 8, 0x0C0, 0x10, 0, 1),
417 PIN_FIELD_BASE(123, 123, 8, 0x0C0, 0x10, 4, 1),
418 PIN_FIELD_BASE(124, 124, 8, 0x0C0, 0x10, 8, 1),
419 PIN_FIELD_BASE(125, 125, 8, 0x0C0, 0x10, 12, 1),
420 PIN_FIELD_BASE(126, 126, 8, 0x0C0, 0x10, 16, 1),
421 PIN_FIELD_BASE(127, 127, 8, 0x0C0, 0x10, 20, 1),
422 PIN_FIELD_BASE(128, 128, 8, 0x0C0, 0x10, 24, 1),
423 PIN_FIELD_BASE(129, 129, 8, 0x0C0, 0x10, 28, 1),
424 PIN_FIELD_BASE(130, 130, 8, 0x0D0, 0x10, 0, 1),
425 PIN_FIELD_BASE(131, 131, 8, 0x0D0, 0x10, 4, 1),
426 PIN_FIELD_BASE(132, 132, 8, 0x0D0, 0x10, 8, 1),
427 PIN_FIELD_BASE(133, 133, 8, 0x0D0, 0x10, 12, 1),
428};
429
430static const struct mtk_pin_field_calc mt8183_pin_r1_range[] = {
431 PIN_FIELD_BASE(29, 29, 2, 0x0C0, 0x10, 1, 1),
432 PIN_FIELD_BASE(30, 30, 2, 0x0C0, 0x10, 5, 1),
433 PIN_FIELD_BASE(31, 31, 2, 0x0C0, 0x10, 9, 1),
434 PIN_FIELD_BASE(32, 32, 2, 0x0C0, 0x10, 13, 1),
435 PIN_FIELD_BASE(33, 33, 2, 0x0C0, 0x10, 17, 1),
436 PIN_FIELD_BASE(34, 34, 2, 0x0C0, 0x10, 21, 1),
437 PIN_FIELD_BASE(35, 35, 3, 0x0C0, 0x10, 1, 1),
438 PIN_FIELD_BASE(36, 36, 3, 0x0C0, 0x10, 5, 1),
439 PIN_FIELD_BASE(37, 37, 3, 0x0C0, 0x10, 9, 1),
440 PIN_FIELD_BASE(38, 38, 3, 0x0C0, 0x10, 13, 1),
441 PIN_FIELD_BASE(39, 39, 3, 0x0C0, 0x10, 17, 1),
442 PIN_FIELD_BASE(40, 40, 3, 0x0C0, 0x10, 21, 1),
443 PIN_FIELD_BASE(41, 41, 3, 0x0C0, 0x10, 25, 1),
444 PIN_FIELD_BASE(42, 42, 3, 0x0C0, 0x10, 29, 1),
445 PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 19, 1),
446 PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 14, 1),
447 PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 11, 1),
448 PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 6, 1),
449 PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 8, 1),
450 PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 6, 1),
451 PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 16, 1),
452 PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 18, 1),
453 PIN_FIELD_BASE(91, 91, 6, 0x0C0, 0x10, 1, 1),
454 PIN_FIELD_BASE(92, 92, 6, 0x0C0, 0x10, 5, 1),
455 PIN_FIELD_BASE(93, 93, 6, 0x0C0, 0x10, 9, 1),
456 PIN_FIELD_BASE(94, 94, 6, 0x0C0, 0x10, 13, 1),
457 PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 21, 1),
458 PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 11, 1),
459 PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 23, 1),
460 PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 13, 1),
461 PIN_FIELD_BASE(122, 122, 8, 0x0C0, 0x10, 1, 1),
462 PIN_FIELD_BASE(123, 123, 8, 0x0C0, 0x10, 5, 1),
463 PIN_FIELD_BASE(124, 124, 8, 0x0C0, 0x10, 9, 1),
464 PIN_FIELD_BASE(125, 125, 8, 0x0C0, 0x10, 13, 1),
465 PIN_FIELD_BASE(126, 126, 8, 0x0C0, 0x10, 17, 1),
466 PIN_FIELD_BASE(127, 127, 8, 0x0C0, 0x10, 21, 1),
467 PIN_FIELD_BASE(128, 128, 8, 0x0C0, 0x10, 25, 1),
468 PIN_FIELD_BASE(129, 129, 8, 0x0C0, 0x10, 29, 1),
469 PIN_FIELD_BASE(130, 130, 8, 0x0D0, 0x10, 1, 1),
470 PIN_FIELD_BASE(131, 131, 8, 0x0D0, 0x10, 5, 1),
471 PIN_FIELD_BASE(132, 132, 8, 0x0D0, 0x10, 9, 1),
472 PIN_FIELD_BASE(133, 133, 8, 0x0D0, 0x10, 13, 1),
473};
474
475static const struct mtk_pin_reg_calc mt8183_reg_cals[PINCTRL_PIN_REG_MAX] = {
476 [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8183_pin_mode_range),
477 [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8183_pin_dir_range),
478 [PINCTRL_PIN_REG_DI] = MTK_RANGE(mt8183_pin_di_range),
479 [PINCTRL_PIN_REG_DO] = MTK_RANGE(mt8183_pin_do_range),
480 [PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt8183_pin_smt_range),
481 [PINCTRL_PIN_REG_IES] = MTK_RANGE(mt8183_pin_ies_range),
482 [PINCTRL_PIN_REG_PULLEN] = MTK_RANGE(mt8183_pin_pullen_range),
483 [PINCTRL_PIN_REG_PULLSEL] = MTK_RANGE(mt8183_pin_pullsel_range),
484 [PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt8183_pin_drv_range),
485 [PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt8183_pin_pupd_range),
486 [PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8183_pin_r0_range),
487 [PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8183_pin_r1_range),
488};
489
490static const char * const mt8183_pinctrl_register_base_names[] = {
491 "iocfg0", "iocfg1", "iocfg2", "iocfg3", "iocfg4", "iocfg5",
492 "iocfg6", "iocfg7", "iocfg8",
493};
494
495static const struct mtk_eint_hw mt8183_eint_hw = {
496 .port_mask = 7,
497 .ports = 6,
498 .ap_num = 212,
499 .db_cnt = 13,
500};
501
502static const struct mtk_pin_soc mt8183_data = {
503 .reg_cal = mt8183_reg_cals,
504 .pins = mtk_pins_mt8183,
505 .npins = ARRAY_SIZE(mtk_pins_mt8183),
506 .ngrps = ARRAY_SIZE(mtk_pins_mt8183),
507 .eint_hw = &mt8183_eint_hw,
508 .gpio_m = 0,
509 .ies_present = true,
510 .base_names = mt8183_pinctrl_register_base_names,
511 .nbase_names = ARRAY_SIZE(mt8183_pinctrl_register_base_names),
512 .bias_disable_set = mtk_pinconf_bias_disable_set_rev1,
513 .bias_disable_get = mtk_pinconf_bias_disable_get_rev1,
514 .bias_set = mtk_pinconf_bias_set_rev1,
515 .bias_get = mtk_pinconf_bias_get_rev1,
516 .drive_set = mtk_pinconf_drive_set_rev1,
517 .drive_get = mtk_pinconf_drive_get_rev1,
518 .adv_pull_get = mtk_pinconf_adv_pull_get,
519 .adv_pull_set = mtk_pinconf_adv_pull_set,
520};
521
522static const struct of_device_id mt8183_pinctrl_of_match[] = {
523 { .compatible = "mediatek,mt8183-pinctrl", },
524 { }
525};
526
527static int mt8183_pinctrl_probe(struct platform_device *pdev)
528{
529 return mtk_paris_pinctrl_probe(pdev, &mt8183_data);
530}
531
532static struct platform_driver mt8183_pinctrl_driver = {
533 .driver = {
534 .name = "mt8183-pinctrl",
535 .of_match_table = mt8183_pinctrl_of_match,
536 },
537 .probe = mt8183_pinctrl_probe,
538};
539
540static int __init mt8183_pinctrl_init(void)
541{
542 return platform_driver_register(&mt8183_pinctrl_driver);
543}
544arch_initcall(mt8183_pinctrl_init);
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
new file mode 100644
index 000000000000..e8a2066a4d15
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -0,0 +1,670 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2018 MediaTek Inc.
4 *
5 * Author: Sean Wang <sean.wang@mediatek.com>
6 *
7 */
8
9#include <linux/device.h>
10#include <linux/err.h>
11#include <linux/gpio.h>
12#include <linux/platform_device.h>
13#include <linux/io.h>
14#include <linux/of_irq.h>
15
16#include "mtk-eint.h"
17#include "pinctrl-mtk-common-v2.h"
18
19/**
20 * struct mtk_drive_desc - the structure that holds the information
21 * of the driving current
22 * @min: the minimum current of this group
23 * @max: the maximum current of this group
24 * @step: the step current of this group
25 * @scal: the weight factor
26 *
27 * formula: output = ((input) / step - 1) * scal
28 */
29struct mtk_drive_desc {
30 u8 min;
31 u8 max;
32 u8 step;
33 u8 scal;
34};
35
36/* The groups of drive strength */
37const struct mtk_drive_desc mtk_drive[] = {
38 [DRV_GRP0] = { 4, 16, 4, 1 },
39 [DRV_GRP1] = { 4, 16, 4, 2 },
40 [DRV_GRP2] = { 2, 8, 2, 1 },
41 [DRV_GRP3] = { 2, 8, 2, 2 },
42 [DRV_GRP4] = { 2, 16, 2, 1 },
43};
44
45static void mtk_w32(struct mtk_pinctrl *pctl, u8 i, u32 reg, u32 val)
46{
47 writel_relaxed(val, pctl->base[i] + reg);
48}
49
50static u32 mtk_r32(struct mtk_pinctrl *pctl, u8 i, u32 reg)
51{
52 return readl_relaxed(pctl->base[i] + reg);
53}
54
55void mtk_rmw(struct mtk_pinctrl *pctl, u8 i, u32 reg, u32 mask, u32 set)
56{
57 u32 val;
58
59 val = mtk_r32(pctl, i, reg);
60 val &= ~mask;
61 val |= set;
62 mtk_w32(pctl, i, reg, val);
63}
64
65static int mtk_hw_pin_field_lookup(struct mtk_pinctrl *hw,
66 const struct mtk_pin_desc *desc,
67 int field, struct mtk_pin_field *pfd)
68{
69 const struct mtk_pin_field_calc *c, *e;
70 const struct mtk_pin_reg_calc *rc;
71 u32 bits;
72
73 if (hw->soc->reg_cal && hw->soc->reg_cal[field].range) {
74 rc = &hw->soc->reg_cal[field];
75 } else {
76 dev_dbg(hw->dev,
77 "Not support field %d for pin %d (%s)\n",
78 field, desc->number, desc->name);
79 return -ENOTSUPP;
80 }
81
82 c = rc->range;
83 e = c + rc->nranges;
84
85 while (c < e) {
86 if (desc->number >= c->s_pin && desc->number <= c->e_pin)
87 break;
88 c++;
89 }
90
91 if (c >= e) {
92 dev_dbg(hw->dev, "Not support field %d for pin = %d (%s)\n",
93 field, desc->number, desc->name);
94 return -ENOTSUPP;
95 }
96
97 if (c->i_base > hw->nbase - 1) {
98 dev_err(hw->dev,
99 "Invalid base for field %d for pin = %d (%s)\n",
100 field, desc->number, desc->name);
101 return -EINVAL;
102 }
103
104 /* Calculated bits as the overall offset the pin is located at,
105 * if c->fixed is held, that determines the all the pins in the
106 * range use the same field with the s_pin.
107 */
108 bits = c->fixed ? c->s_bit : c->s_bit +
109 (desc->number - c->s_pin) * (c->x_bits);
110
111 /* Fill pfd from bits. For example 32-bit register applied is assumed
112 * when c->sz_reg is equal to 32.
113 */
114 pfd->index = c->i_base;
115 pfd->offset = c->s_addr + c->x_addrs * (bits / c->sz_reg);
116 pfd->bitpos = bits % c->sz_reg;
117 pfd->mask = (1 << c->x_bits) - 1;
118
119 /* pfd->next is used for indicating that bit wrapping-around happens
120 * which requires the manipulation for bit 0 starting in the next
121 * register to form the complete field read/write.
122 */
123 pfd->next = pfd->bitpos + c->x_bits > c->sz_reg ? c->x_addrs : 0;
124
125 return 0;
126}
127
128static int mtk_hw_pin_field_get(struct mtk_pinctrl *hw,
129 const struct mtk_pin_desc *desc,
130 int field, struct mtk_pin_field *pfd)
131{
132 if (field < 0 || field >= PINCTRL_PIN_REG_MAX) {
133 dev_err(hw->dev, "Invalid Field %d\n", field);
134 return -EINVAL;
135 }
136
137 return mtk_hw_pin_field_lookup(hw, desc, field, pfd);
138}
139
140static void mtk_hw_bits_part(struct mtk_pin_field *pf, int *h, int *l)
141{
142 *l = 32 - pf->bitpos;
143 *h = get_count_order(pf->mask) - *l;
144}
145
146static void mtk_hw_write_cross_field(struct mtk_pinctrl *hw,
147 struct mtk_pin_field *pf, int value)
148{
149 int nbits_l, nbits_h;
150
151 mtk_hw_bits_part(pf, &nbits_h, &nbits_l);
152
153 mtk_rmw(hw, pf->index, pf->offset, pf->mask << pf->bitpos,
154 (value & pf->mask) << pf->bitpos);
155
156 mtk_rmw(hw, pf->index, pf->offset + pf->next, BIT(nbits_h) - 1,
157 (value & pf->mask) >> nbits_l);
158}
159
160static void mtk_hw_read_cross_field(struct mtk_pinctrl *hw,
161 struct mtk_pin_field *pf, int *value)
162{
163 int nbits_l, nbits_h, h, l;
164
165 mtk_hw_bits_part(pf, &nbits_h, &nbits_l);
166
167 l = (mtk_r32(hw, pf->index, pf->offset)
168 >> pf->bitpos) & (BIT(nbits_l) - 1);
169 h = (mtk_r32(hw, pf->index, pf->offset + pf->next))
170 & (BIT(nbits_h) - 1);
171
172 *value = (h << nbits_l) | l;
173}
174
175int mtk_hw_set_value(struct mtk_pinctrl *hw, const struct mtk_pin_desc *desc,
176 int field, int value)
177{
178 struct mtk_pin_field pf;
179 int err;
180
181 err = mtk_hw_pin_field_get(hw, desc, field, &pf);
182 if (err)
183 return err;
184
185 if (!pf.next)
186 mtk_rmw(hw, pf.index, pf.offset, pf.mask << pf.bitpos,
187 (value & pf.mask) << pf.bitpos);
188 else
189 mtk_hw_write_cross_field(hw, &pf, value);
190
191 return 0;
192}
193
194int mtk_hw_get_value(struct mtk_pinctrl *hw, const struct mtk_pin_desc *desc,
195 int field, int *value)
196{
197 struct mtk_pin_field pf;
198 int err;
199
200 err = mtk_hw_pin_field_get(hw, desc, field, &pf);
201 if (err)
202 return err;
203
204 if (!pf.next)
205 *value = (mtk_r32(hw, pf.index, pf.offset)
206 >> pf.bitpos) & pf.mask;
207 else
208 mtk_hw_read_cross_field(hw, &pf, value);
209
210 return 0;
211}
212
213static int mtk_xt_find_eint_num(struct mtk_pinctrl *hw, unsigned long eint_n)
214{
215 const struct mtk_pin_desc *desc;
216 int i = 0;
217
218 desc = (const struct mtk_pin_desc *)hw->soc->pins;
219
220 while (i < hw->soc->npins) {
221 if (desc[i].eint.eint_n == eint_n)
222 return desc[i].number;
223 i++;
224 }
225
226 return EINT_NA;
227}
228
229static int mtk_xt_get_gpio_n(void *data, unsigned long eint_n,
230 unsigned int *gpio_n,
231 struct gpio_chip **gpio_chip)
232{
233 struct mtk_pinctrl *hw = (struct mtk_pinctrl *)data;
234 const struct mtk_pin_desc *desc;
235
236 desc = (const struct mtk_pin_desc *)hw->soc->pins;
237 *gpio_chip = &hw->chip;
238
239 /* Be greedy to guess first gpio_n is equal to eint_n */
240 if (desc[eint_n].eint.eint_n == eint_n)
241 *gpio_n = eint_n;
242 else
243 *gpio_n = mtk_xt_find_eint_num(hw, eint_n);
244
245 return *gpio_n == EINT_NA ? -EINVAL : 0;
246}
247
248static int mtk_xt_get_gpio_state(void *data, unsigned long eint_n)
249{
250 struct mtk_pinctrl *hw = (struct mtk_pinctrl *)data;
251 const struct mtk_pin_desc *desc;
252 struct gpio_chip *gpio_chip;
253 unsigned int gpio_n;
254 int value, err;
255
256 err = mtk_xt_get_gpio_n(hw, eint_n, &gpio_n, &gpio_chip);
257 if (err)
258 return err;
259
260 desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio_n];
261
262 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DI, &value);
263 if (err)
264 return err;
265
266 return !!value;
267}
268
269static int mtk_xt_set_gpio_as_eint(void *data, unsigned long eint_n)
270{
271 struct mtk_pinctrl *hw = (struct mtk_pinctrl *)data;
272 const struct mtk_pin_desc *desc;
273 struct gpio_chip *gpio_chip;
274 unsigned int gpio_n;
275 int err;
276
277 err = mtk_xt_get_gpio_n(hw, eint_n, &gpio_n, &gpio_chip);
278 if (err)
279 return err;
280
281 desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio_n];
282
283 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_MODE,
284 desc->eint.eint_m);
285 if (err)
286 return err;
287
288 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR, MTK_INPUT);
289 if (err)
290 return err;
291
292 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_SMT, MTK_ENABLE);
293 if (err)
294 return err;
295
296 return 0;
297}
298
299static const struct mtk_eint_xt mtk_eint_xt = {
300 .get_gpio_n = mtk_xt_get_gpio_n,
301 .get_gpio_state = mtk_xt_get_gpio_state,
302 .set_gpio_as_eint = mtk_xt_set_gpio_as_eint,
303};
304
305int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev)
306{
307 struct device_node *np = pdev->dev.of_node;
308 struct resource *res;
309
310 if (!IS_ENABLED(CONFIG_EINT_MTK))
311 return 0;
312
313 if (!of_property_read_bool(np, "interrupt-controller"))
314 return -ENODEV;
315
316 hw->eint = devm_kzalloc(hw->dev, sizeof(*hw->eint), GFP_KERNEL);
317 if (!hw->eint)
318 return -ENOMEM;
319
320 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "eint");
321 if (!res) {
322 dev_err(&pdev->dev, "Unable to get eint resource\n");
323 return -ENODEV;
324 }
325
326 hw->eint->base = devm_ioremap_resource(&pdev->dev, res);
327 if (IS_ERR(hw->eint->base))
328 return PTR_ERR(hw->eint->base);
329
330 hw->eint->irq = irq_of_parse_and_map(np, 0);
331 if (!hw->eint->irq)
332 return -EINVAL;
333
334 if (!hw->soc->eint_hw)
335 return -ENODEV;
336
337 hw->eint->dev = &pdev->dev;
338 hw->eint->hw = hw->soc->eint_hw;
339 hw->eint->pctl = hw;
340 hw->eint->gpio_xlate = &mtk_eint_xt;
341
342 return mtk_eint_do_init(hw->eint);
343}
344
345/* Revision 0 */
346int mtk_pinconf_bias_disable_set(struct mtk_pinctrl *hw,
347 const struct mtk_pin_desc *desc)
348{
349 int err;
350
351 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_PU,
352 MTK_DISABLE);
353 if (err)
354 return err;
355
356 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_PD,
357 MTK_DISABLE);
358 if (err)
359 return err;
360
361 return 0;
362}
363
364int mtk_pinconf_bias_disable_get(struct mtk_pinctrl *hw,
365 const struct mtk_pin_desc *desc, int *res)
366{
367 int v, v2;
368 int err;
369
370 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_PU, &v);
371 if (err)
372 return err;
373
374 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_PD, &v2);
375 if (err)
376 return err;
377
378 if (v == MTK_ENABLE || v2 == MTK_ENABLE)
379 return -EINVAL;
380
381 *res = 1;
382
383 return 0;
384}
385
386int mtk_pinconf_bias_set(struct mtk_pinctrl *hw,
387 const struct mtk_pin_desc *desc, bool pullup)
388{
389 int err, arg;
390
391 arg = pullup ? 1 : 2;
392
393 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_PU, arg & 1);
394 if (err)
395 return err;
396
397 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_PD,
398 !!(arg & 2));
399 if (err)
400 return err;
401
402 return 0;
403}
404
405int mtk_pinconf_bias_get(struct mtk_pinctrl *hw,
406 const struct mtk_pin_desc *desc, bool pullup, int *res)
407{
408 int reg, err, v;
409
410 reg = pullup ? PINCTRL_PIN_REG_PU : PINCTRL_PIN_REG_PD;
411
412 err = mtk_hw_get_value(hw, desc, reg, &v);
413 if (err)
414 return err;
415
416 if (!v)
417 return -EINVAL;
418
419 *res = 1;
420
421 return 0;
422}
423
424/* Revision 1 */
425int mtk_pinconf_bias_disable_set_rev1(struct mtk_pinctrl *hw,
426 const struct mtk_pin_desc *desc)
427{
428 int err;
429
430 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_PULLEN,
431 MTK_DISABLE);
432 if (err)
433 return err;
434
435 return 0;
436}
437
438int mtk_pinconf_bias_disable_get_rev1(struct mtk_pinctrl *hw,
439 const struct mtk_pin_desc *desc, int *res)
440{
441 int v, err;
442
443 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_PULLEN, &v);
444 if (err)
445 return err;
446
447 if (v == MTK_ENABLE)
448 return -EINVAL;
449
450 *res = 1;
451
452 return 0;
453}
454
455int mtk_pinconf_bias_set_rev1(struct mtk_pinctrl *hw,
456 const struct mtk_pin_desc *desc, bool pullup)
457{
458 int err, arg;
459
460 arg = pullup ? MTK_PULLUP : MTK_PULLDOWN;
461
462 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_PULLEN,
463 MTK_ENABLE);
464 if (err)
465 return err;
466
467 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_PULLSEL, arg);
468 if (err)
469 return err;
470
471 return 0;
472}
473
474int mtk_pinconf_bias_get_rev1(struct mtk_pinctrl *hw,
475 const struct mtk_pin_desc *desc, bool pullup,
476 int *res)
477{
478 int err, v;
479
480 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_PULLEN, &v);
481 if (err)
482 return err;
483
484 if (v == MTK_DISABLE)
485 return -EINVAL;
486
487 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_PULLSEL, &v);
488 if (err)
489 return err;
490
491 if (pullup ^ (v == MTK_PULLUP))
492 return -EINVAL;
493
494 *res = 1;
495
496 return 0;
497}
498
499/* Revision 0 */
500int mtk_pinconf_drive_set(struct mtk_pinctrl *hw,
501 const struct mtk_pin_desc *desc, u32 arg)
502{
503 const struct mtk_drive_desc *tb;
504 int err = -ENOTSUPP;
505
506 tb = &mtk_drive[desc->drv_n];
507 /* 4mA when (e8, e4) = (0, 0)
508 * 8mA when (e8, e4) = (0, 1)
509 * 12mA when (e8, e4) = (1, 0)
510 * 16mA when (e8, e4) = (1, 1)
511 */
512 if ((arg >= tb->min && arg <= tb->max) && !(arg % tb->step)) {
513 arg = (arg / tb->step - 1) * tb->scal;
514 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_E4,
515 arg & 0x1);
516 if (err)
517 return err;
518
519 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_E8,
520 (arg & 0x2) >> 1);
521 if (err)
522 return err;
523 }
524
525 return err;
526}
527
528int mtk_pinconf_drive_get(struct mtk_pinctrl *hw,
529 const struct mtk_pin_desc *desc, int *val)
530{
531 const struct mtk_drive_desc *tb;
532 int err, val1, val2;
533
534 tb = &mtk_drive[desc->drv_n];
535
536 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_E4, &val1);
537 if (err)
538 return err;
539
540 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_E8, &val2);
541 if (err)
542 return err;
543
544 /* 4mA when (e8, e4) = (0, 0); 8mA when (e8, e4) = (0, 1)
545 * 12mA when (e8, e4) = (1, 0); 16mA when (e8, e4) = (1, 1)
546 */
547 *val = (((val2 << 1) + val1) / tb->scal + 1) * tb->step;
548
549 return 0;
550}
551
552/* Revision 1 */
553int mtk_pinconf_drive_set_rev1(struct mtk_pinctrl *hw,
554 const struct mtk_pin_desc *desc, u32 arg)
555{
556 const struct mtk_drive_desc *tb;
557 int err = -ENOTSUPP;
558
559 tb = &mtk_drive[desc->drv_n];
560
561 if ((arg >= tb->min && arg <= tb->max) && !(arg % tb->step)) {
562 arg = (arg / tb->step - 1) * tb->scal;
563
564 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DRV,
565 arg);
566 if (err)
567 return err;
568 }
569
570 return err;
571}
572
573int mtk_pinconf_drive_get_rev1(struct mtk_pinctrl *hw,
574 const struct mtk_pin_desc *desc, int *val)
575{
576 const struct mtk_drive_desc *tb;
577 int err, val1;
578
579 tb = &mtk_drive[desc->drv_n];
580
581 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DRV, &val1);
582 if (err)
583 return err;
584
585 *val = ((val1 & 0x7) / tb->scal + 1) * tb->step;
586
587 return 0;
588}
589
590int mtk_pinconf_adv_pull_set(struct mtk_pinctrl *hw,
591 const struct mtk_pin_desc *desc, bool pullup,
592 u32 arg)
593{
594 int err;
595
596 /* 10K off & 50K (75K) off, when (R0, R1) = (0, 0);
597 * 10K off & 50K (75K) on, when (R0, R1) = (0, 1);
598 * 10K on & 50K (75K) off, when (R0, R1) = (1, 0);
599 * 10K on & 50K (75K) on, when (R0, R1) = (1, 1)
600 */
601 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_R0, arg & 1);
602 if (err)
603 return 0;
604
605 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_R1,
606 !!(arg & 2));
607 if (err)
608 return 0;
609
610 arg = pullup ? 0 : 1;
611
612 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_PUPD, arg);
613
614 /* If PUPD register is not supported for that pin, let's fallback to
615 * general bias control.
616 */
617 if (err == -ENOTSUPP) {
618 if (hw->soc->bias_set) {
619 err = hw->soc->bias_set(hw, desc, pullup);
620 if (err)
621 return err;
622 } else {
623 return -ENOTSUPP;
624 }
625 }
626
627 return err;
628}
629
630int mtk_pinconf_adv_pull_get(struct mtk_pinctrl *hw,
631 const struct mtk_pin_desc *desc, bool pullup,
632 u32 *val)
633{
634 u32 t, t2;
635 int err;
636
637 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_PUPD, &t);
638
639 /* If PUPD register is not supported for that pin, let's fallback to
640 * general bias control.
641 */
642 if (err == -ENOTSUPP) {
643 if (hw->soc->bias_get) {
644 err = hw->soc->bias_get(hw, desc, pullup, val);
645 if (err)
646 return err;
647 } else {
648 return -ENOTSUPP;
649 }
650 } else {
651 /* t == 0 supposes PULLUP for the customized PULL setup */
652 if (err)
653 return err;
654
655 if (pullup ^ !t)
656 return -EINVAL;
657 }
658
659 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_R0, &t);
660 if (err)
661 return err;
662
663 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_R1, &t2);
664 if (err)
665 return err;
666
667 *val = (t | t2 << 1) & 0x7;
668
669 return 0;
670}
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
new file mode 100644
index 000000000000..e0d4e68b7cdd
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
@@ -0,0 +1,288 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2018 MediaTek Inc.
4 *
5 * Author: Sean Wang <sean.wang@mediatek.com>
6 *
7 */
8
9#ifndef __PINCTRL_MTK_COMMON_V2_H
10#define __PINCTRL_MTK_COMMON_V2_H
11
12#define MTK_INPUT 0
13#define MTK_OUTPUT 1
14#define MTK_DISABLE 0
15#define MTK_ENABLE 1
16#define MTK_PULLDOWN 0
17#define MTK_PULLUP 1
18
19#define EINT_NA -1
20
21#define PIN_FIELD_CALC(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, \
22 _s_bit, _x_bits, _sz_reg, _fixed) { \
23 .s_pin = _s_pin, \
24 .e_pin = _e_pin, \
25 .i_base = _i_base, \
26 .s_addr = _s_addr, \
27 .x_addrs = _x_addrs, \
28 .s_bit = _s_bit, \
29 .x_bits = _x_bits, \
30 .sz_reg = _sz_reg, \
31 .fixed = _fixed, \
32 }
33
34#define PIN_FIELD(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits) \
35 PIN_FIELD_CALC(_s_pin, _e_pin, 0, _s_addr, _x_addrs, _s_bit, \
36 _x_bits, 32, 0)
37
38#define PINS_FIELD(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits) \
39 PIN_FIELD_CALC(_s_pin, _e_pin, 0, _s_addr, _x_addrs, _s_bit, \
40 _x_bits, 32, 1)
41
42/* List these attributes which could be modified for the pin */
43enum {
44 PINCTRL_PIN_REG_MODE,
45 PINCTRL_PIN_REG_DIR,
46 PINCTRL_PIN_REG_DI,
47 PINCTRL_PIN_REG_DO,
48 PINCTRL_PIN_REG_SR,
49 PINCTRL_PIN_REG_SMT,
50 PINCTRL_PIN_REG_PD,
51 PINCTRL_PIN_REG_PU,
52 PINCTRL_PIN_REG_E4,
53 PINCTRL_PIN_REG_E8,
54 PINCTRL_PIN_REG_TDSEL,
55 PINCTRL_PIN_REG_RDSEL,
56 PINCTRL_PIN_REG_DRV,
57 PINCTRL_PIN_REG_PUPD,
58 PINCTRL_PIN_REG_R0,
59 PINCTRL_PIN_REG_R1,
60 PINCTRL_PIN_REG_IES,
61 PINCTRL_PIN_REG_PULLEN,
62 PINCTRL_PIN_REG_PULLSEL,
63 PINCTRL_PIN_REG_MAX,
64};
65
66/* Group the pins by the driving current */
67enum {
68 DRV_FIXED,
69 DRV_GRP0,
70 DRV_GRP1,
71 DRV_GRP2,
72 DRV_GRP3,
73 DRV_GRP4,
74 DRV_GRP_MAX,
75};
76
77static const char * const mtk_default_register_base_names[] = {
78 "base",
79};
80
81/* struct mtk_pin_field - the structure that holds the information of the field
82 * used to describe the attribute for the pin
83 * @base: the index pointing to the entry in base address list
84 * @offset: the register offset relative to the base address
85 * @mask: the mask used to filter out the field from the register
86 * @bitpos: the start bit relative to the register
87 * @next: the indication that the field would be extended to the
88 next register
89 */
90struct mtk_pin_field {
91 u8 index;
92 u32 offset;
93 u32 mask;
94 u8 bitpos;
95 u8 next;
96};
97
98/* struct mtk_pin_field_calc - the structure that holds the range providing
99 * the guide used to look up the relevant field
100 * @s_pin: the start pin within the range
101 * @e_pin: the end pin within the range
102 * @i_base: the index pointing to the entry in base address list
103 * @s_addr: the start address for the range
104 * @x_addrs: the address distance between two consecutive registers
105 * within the range
106 * @s_bit: the start bit for the first register within the range
107 * @x_bits: the bit distance between two consecutive pins within
108 * the range
109 * @sz_reg: the size of bits in a register
110 * @fixed: the consecutive pins share the same bits with the 1st
111 * pin
112 */
113struct mtk_pin_field_calc {
114 u16 s_pin;
115 u16 e_pin;
116 u8 i_base;
117 u32 s_addr;
118 u8 x_addrs;
119 u8 s_bit;
120 u8 x_bits;
121 u8 sz_reg;
122 u8 fixed;
123};
124
125/* struct mtk_pin_reg_calc - the structure that holds all ranges used to
126 * determine which register the pin would make use of
127 * for certain pin attribute.
128 * @range: the start address for the range
129 * @nranges: the number of items in the range
130 */
131struct mtk_pin_reg_calc {
132 const struct mtk_pin_field_calc *range;
133 unsigned int nranges;
134};
135
136/**
137 * struct mtk_func_desc - the structure that providing information
138 * all the funcs for this pin
139 * @name: the name of function
140 * @muxval: the mux to the function
141 */
142struct mtk_func_desc {
143 const char *name;
144 u8 muxval;
145};
146
147/**
148 * struct mtk_eint_desc - the structure that providing information
149 * for eint data per pin
150 * @eint_m: the eint mux for this pin
151 * @eitn_n: the eint number for this pin
152 */
153struct mtk_eint_desc {
154 u8 eint_m;
155 u16 eint_n;
156};
157
158/**
159 * struct mtk_pin_desc - the structure that providing information
160 * for each pin of chips
161 * @number: unique pin number from the global pin number space
162 * @name: name for this pin
163 * @eint: the eint data for this pin
164 * @drv_n: the index with the driving group
165 * @funcs: all available functions for this pins (only used in
166 * those drivers compatible to pinctrl-mtk-common.c-like
167 * ones)
168 */
169struct mtk_pin_desc {
170 unsigned int number;
171 const char *name;
172 struct mtk_eint_desc eint;
173 u8 drv_n;
174 struct mtk_func_desc *funcs;
175};
176
177struct mtk_pinctrl_group {
178 const char *name;
179 unsigned long config;
180 unsigned pin;
181};
182
183struct mtk_pinctrl;
184
185/* struct mtk_pin_soc - the structure that holds SoC-specific data */
186struct mtk_pin_soc {
187 const struct mtk_pin_reg_calc *reg_cal;
188 const struct mtk_pin_desc *pins;
189 unsigned int npins;
190 const struct group_desc *grps;
191 unsigned int ngrps;
192 const struct function_desc *funcs;
193 unsigned int nfuncs;
194 const struct mtk_eint_regs *eint_regs;
195 const struct mtk_eint_hw *eint_hw;
196
197 /* Specific parameters per SoC */
198 u8 gpio_m;
199 bool ies_present;
200 const char * const *base_names;
201 unsigned int nbase_names;
202
203 /* Specific pinconfig operations */
204 int (*bias_disable_set)(struct mtk_pinctrl *hw,
205 const struct mtk_pin_desc *desc);
206 int (*bias_disable_get)(struct mtk_pinctrl *hw,
207 const struct mtk_pin_desc *desc, int *res);
208 int (*bias_set)(struct mtk_pinctrl *hw,
209 const struct mtk_pin_desc *desc, bool pullup);
210 int (*bias_get)(struct mtk_pinctrl *hw,
211 const struct mtk_pin_desc *desc, bool pullup, int *res);
212
213 int (*drive_set)(struct mtk_pinctrl *hw,
214 const struct mtk_pin_desc *desc, u32 arg);
215 int (*drive_get)(struct mtk_pinctrl *hw,
216 const struct mtk_pin_desc *desc, int *val);
217
218 int (*adv_pull_set)(struct mtk_pinctrl *hw,
219 const struct mtk_pin_desc *desc, bool pullup,
220 u32 arg);
221 int (*adv_pull_get)(struct mtk_pinctrl *hw,
222 const struct mtk_pin_desc *desc, bool pullup,
223 u32 *val);
224
225 /* Specific driver data */
226 void *driver_data;
227};
228
229struct mtk_pinctrl {
230 struct pinctrl_dev *pctrl;
231 void __iomem **base;
232 u8 nbase;
233 struct device *dev;
234 struct gpio_chip chip;
235 const struct mtk_pin_soc *soc;
236 struct mtk_eint *eint;
237 struct mtk_pinctrl_group *groups;
238 const char **grp_names;
239};
240
241void mtk_rmw(struct mtk_pinctrl *pctl, u8 i, u32 reg, u32 mask, u32 set);
242
243int mtk_hw_set_value(struct mtk_pinctrl *hw, const struct mtk_pin_desc *desc,
244 int field, int value);
245int mtk_hw_get_value(struct mtk_pinctrl *hw, const struct mtk_pin_desc *desc,
246 int field, int *value);
247
248int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev);
249
250int mtk_pinconf_bias_disable_set(struct mtk_pinctrl *hw,
251 const struct mtk_pin_desc *desc);
252int mtk_pinconf_bias_disable_get(struct mtk_pinctrl *hw,
253 const struct mtk_pin_desc *desc, int *res);
254int mtk_pinconf_bias_set(struct mtk_pinctrl *hw,
255 const struct mtk_pin_desc *desc, bool pullup);
256int mtk_pinconf_bias_get(struct mtk_pinctrl *hw,
257 const struct mtk_pin_desc *desc, bool pullup,
258 int *res);
259
260int mtk_pinconf_bias_disable_set_rev1(struct mtk_pinctrl *hw,
261 const struct mtk_pin_desc *desc);
262int mtk_pinconf_bias_disable_get_rev1(struct mtk_pinctrl *hw,
263 const struct mtk_pin_desc *desc,
264 int *res);
265int mtk_pinconf_bias_set_rev1(struct mtk_pinctrl *hw,
266 const struct mtk_pin_desc *desc, bool pullup);
267int mtk_pinconf_bias_get_rev1(struct mtk_pinctrl *hw,
268 const struct mtk_pin_desc *desc, bool pullup,
269 int *res);
270
271int mtk_pinconf_drive_set(struct mtk_pinctrl *hw,
272 const struct mtk_pin_desc *desc, u32 arg);
273int mtk_pinconf_drive_get(struct mtk_pinctrl *hw,
274 const struct mtk_pin_desc *desc, int *val);
275
276int mtk_pinconf_drive_set_rev1(struct mtk_pinctrl *hw,
277 const struct mtk_pin_desc *desc, u32 arg);
278int mtk_pinconf_drive_get_rev1(struct mtk_pinctrl *hw,
279 const struct mtk_pin_desc *desc, int *val);
280
281int mtk_pinconf_adv_pull_set(struct mtk_pinctrl *hw,
282 const struct mtk_pin_desc *desc, bool pullup,
283 u32 arg);
284int mtk_pinconf_adv_pull_get(struct mtk_pinctrl *hw,
285 const struct mtk_pin_desc *desc, bool pullup,
286 u32 *val);
287
288#endif /* __PINCTRL_MTK_COMMON_V2_H */
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-mt8183.h b/drivers/pinctrl/mediatek/pinctrl-mtk-mt8183.h
new file mode 100644
index 000000000000..79adf5b8a186
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-mt8183.h
@@ -0,0 +1,1916 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2018 MediaTek Inc.
4 *
5 * Author: Zhiyong Tao <zhiyong.tao@mediatek.com>
6 *
7 */
8
9#ifndef __PINCTRL_MTK_MT8183_H
10#define __PINCTRL_MTK_MT8183_H
11
12#include "pinctrl-paris.h"
13
14static struct mtk_pin_desc mtk_pins_mt8183[] = {
15 MTK_PIN(
16 0, "GPIO0",
17 MTK_EINT_FUNCTION(0, 0),
18 DRV_GRP4,
19 MTK_FUNCTION(0, "GPIO0"),
20 MTK_FUNCTION(1, "MRG_SYNC"),
21 MTK_FUNCTION(2, "PCM0_SYNC"),
22 MTK_FUNCTION(3, "TP_GPIO0_AO"),
23 MTK_FUNCTION(4, "SRCLKENAI0"),
24 MTK_FUNCTION(5, "SCP_SPI2_CS"),
25 MTK_FUNCTION(6, "I2S3_MCK"),
26 MTK_FUNCTION(7, "SPI2_CSB")
27 ),
28 MTK_PIN(
29 1, "GPIO1",
30 MTK_EINT_FUNCTION(0, 1),
31 DRV_GRP4,
32 MTK_FUNCTION(0, "GPIO1"),
33 MTK_FUNCTION(1, "MRG_CLK"),
34 MTK_FUNCTION(2, "PCM0_CLK"),
35 MTK_FUNCTION(3, "TP_GPIO1_AO"),
36 MTK_FUNCTION(4, "CLKM3"),
37 MTK_FUNCTION(5, "SCP_SPI2_MO"),
38 MTK_FUNCTION(6, "I2S3_BCK"),
39 MTK_FUNCTION(7, "SPI2_MO")
40 ),
41 MTK_PIN(
42 2, "GPIO2",
43 MTK_EINT_FUNCTION(0, 2),
44 DRV_GRP4,
45 MTK_FUNCTION(0, "GPIO2"),
46 MTK_FUNCTION(1, "MRG_DO"),
47 MTK_FUNCTION(2, "PCM0_DO"),
48 MTK_FUNCTION(3, "TP_GPIO2_AO"),
49 MTK_FUNCTION(4, "SCL6"),
50 MTK_FUNCTION(5, "SCP_SPI2_CK"),
51 MTK_FUNCTION(6, "I2S3_LRCK"),
52 MTK_FUNCTION(7, "SPI2_CLK")
53 ),
54 MTK_PIN(
55 3, "GPIO3",
56 MTK_EINT_FUNCTION(0, 3),
57 DRV_GRP4,
58 MTK_FUNCTION(0, "GPIO3"),
59 MTK_FUNCTION(1, "MRG_DI"),
60 MTK_FUNCTION(2, "PCM0_DI"),
61 MTK_FUNCTION(3, "TP_GPIO3_AO"),
62 MTK_FUNCTION(4, "SDA6"),
63 MTK_FUNCTION(5, "TDM_MCK"),
64 MTK_FUNCTION(6, "I2S3_DO"),
65 MTK_FUNCTION(7, "SCP_VREQ_VAO")
66 ),
67 MTK_PIN(
68 4, "GPIO4",
69 MTK_EINT_FUNCTION(0, 4),
70 DRV_GRP4,
71 MTK_FUNCTION(0, "GPIO4"),
72 MTK_FUNCTION(1, "PWM_B"),
73 MTK_FUNCTION(2, "I2S0_MCK"),
74 MTK_FUNCTION(3, "SSPM_UTXD_AO"),
75 MTK_FUNCTION(4, "MD_URXD1"),
76 MTK_FUNCTION(5, "TDM_BCK"),
77 MTK_FUNCTION(6, "TP_GPIO4_AO"),
78 MTK_FUNCTION(7, "DAP_MD32_SWD")
79 ),
80 MTK_PIN(
81 5, "GPIO5",
82 MTK_EINT_FUNCTION(0, 5),
83 DRV_GRP4,
84 MTK_FUNCTION(0, "GPIO5"),
85 MTK_FUNCTION(1, "PWM_C"),
86 MTK_FUNCTION(2, "I2S0_BCK"),
87 MTK_FUNCTION(3, "SSPM_URXD_AO"),
88 MTK_FUNCTION(4, "MD_UTXD1"),
89 MTK_FUNCTION(5, "TDM_LRCK"),
90 MTK_FUNCTION(6, "TP_GPIO5_AO"),
91 MTK_FUNCTION(7, "DAP_MD32_SWCK")
92 ),
93 MTK_PIN(
94 6, "GPIO6",
95 MTK_EINT_FUNCTION(0, 6),
96 DRV_GRP4,
97 MTK_FUNCTION(0, "GPIO6"),
98 MTK_FUNCTION(1, "PWM_A"),
99 MTK_FUNCTION(2, "I2S0_LRCK"),
100 MTK_FUNCTION(3, "IDDIG"),
101 MTK_FUNCTION(4, "MD_URXD0"),
102 MTK_FUNCTION(5, "TDM_DATA0"),
103 MTK_FUNCTION(6, "TP_GPIO6_AO"),
104 MTK_FUNCTION(7, "CMFLASH")
105 ),
106 MTK_PIN(
107 7, "GPIO7",
108 MTK_EINT_FUNCTION(0, 7),
109 DRV_GRP4,
110 MTK_FUNCTION(0, "GPIO7"),
111 MTK_FUNCTION(1, "SPI1_B_MI"),
112 MTK_FUNCTION(2, "I2S0_DI"),
113 MTK_FUNCTION(3, "USB_DRVVBUS"),
114 MTK_FUNCTION(4, "MD_UTXD0"),
115 MTK_FUNCTION(5, "TDM_DATA1"),
116 MTK_FUNCTION(6, "TP_GPIO7_AO"),
117 MTK_FUNCTION(7, "DVFSRC_EXT_REQ")
118 ),
119 MTK_PIN(
120 8, "GPIO8",
121 MTK_EINT_FUNCTION(0, 8),
122 DRV_GRP4,
123 MTK_FUNCTION(0, "GPIO8"),
124 MTK_FUNCTION(1, "SPI1_B_CSB"),
125 MTK_FUNCTION(2, "ANT_SEL3"),
126 MTK_FUNCTION(3, "SCL7"),
127 MTK_FUNCTION(4, "CONN_MCU_TRST_B"),
128 MTK_FUNCTION(5, "TDM_DATA2"),
129 MTK_FUNCTION(6, "MD_INT0"),
130 MTK_FUNCTION(7, "JTRSTN_SEL1")
131 ),
132 MTK_PIN(
133 9, "GPIO9",
134 MTK_EINT_FUNCTION(0, 9),
135 DRV_GRP4,
136 MTK_FUNCTION(0, "GPIO9"),
137 MTK_FUNCTION(1, "SPI1_B_MO"),
138 MTK_FUNCTION(2, "ANT_SEL4"),
139 MTK_FUNCTION(3, "CMMCLK2"),
140 MTK_FUNCTION(4, "CONN_MCU_DBGACK_N"),
141 MTK_FUNCTION(5, "SSPM_JTAG_TRSTN"),
142 MTK_FUNCTION(6, "IO_JTAG_TRSTN"),
143 MTK_FUNCTION(7, "DBG_MON_B10")
144 ),
145 MTK_PIN(
146 10, "GPIO10",
147 MTK_EINT_FUNCTION(0, 10),
148 DRV_GRP4,
149 MTK_FUNCTION(0, "GPIO10"),
150 MTK_FUNCTION(1, "SPI1_B_CLK"),
151 MTK_FUNCTION(2, "ANT_SEL5"),
152 MTK_FUNCTION(3, "CMMCLK3"),
153 MTK_FUNCTION(4, "CONN_MCU_DBGI_N"),
154 MTK_FUNCTION(5, "TDM_DATA3"),
155 MTK_FUNCTION(6, "EXT_FRAME_SYNC"),
156 MTK_FUNCTION(7, "DBG_MON_B11")
157 ),
158 MTK_PIN(
159 11, "GPIO11",
160 MTK_EINT_FUNCTION(0, 11),
161 DRV_GRP4,
162 MTK_FUNCTION(0, "GPIO11"),
163 MTK_FUNCTION(1, "TP_URXD1_AO"),
164 MTK_FUNCTION(2, "IDDIG"),
165 MTK_FUNCTION(3, "SCL6"),
166 MTK_FUNCTION(4, "UCTS1"),
167 MTK_FUNCTION(5, "UCTS0"),
168 MTK_FUNCTION(6, "SRCLKENAI1"),
169 MTK_FUNCTION(7, "I2S5_MCK")
170 ),
171 MTK_PIN(
172 12, "GPIO12",
173 MTK_EINT_FUNCTION(0, 12),
174 DRV_GRP4,
175 MTK_FUNCTION(0, "GPIO12"),
176 MTK_FUNCTION(1, "TP_UTXD1_AO"),
177 MTK_FUNCTION(2, "USB_DRVVBUS"),
178 MTK_FUNCTION(3, "SDA6"),
179 MTK_FUNCTION(4, "URTS1"),
180 MTK_FUNCTION(5, "URTS0"),
181 MTK_FUNCTION(6, "I2S2_DI2"),
182 MTK_FUNCTION(7, "I2S5_BCK")
183 ),
184 MTK_PIN(
185 13, "GPIO13",
186 MTK_EINT_FUNCTION(0, 13),
187 DRV_GRP4,
188 MTK_FUNCTION(0, "GPIO13"),
189 MTK_FUNCTION(1, "DBPI_D0"),
190 MTK_FUNCTION(2, "SPI5_MI"),
191 MTK_FUNCTION(3, "PCM0_SYNC"),
192 MTK_FUNCTION(4, "MD_URXD0"),
193 MTK_FUNCTION(5, "ANT_SEL3"),
194 MTK_FUNCTION(6, "I2S0_MCK"),
195 MTK_FUNCTION(7, "DBG_MON_B15")
196 ),
197 MTK_PIN(
198 14, "GPIO14",
199 MTK_EINT_FUNCTION(0, 14),
200 DRV_GRP4,
201 MTK_FUNCTION(0, "GPIO14"),
202 MTK_FUNCTION(1, "DBPI_D1"),
203 MTK_FUNCTION(2, "SPI5_CSB"),
204 MTK_FUNCTION(3, "PCM0_CLK"),
205 MTK_FUNCTION(4, "MD_UTXD0"),
206 MTK_FUNCTION(5, "ANT_SEL4"),
207 MTK_FUNCTION(6, "I2S0_BCK"),
208 MTK_FUNCTION(7, "DBG_MON_B16")
209 ),
210 MTK_PIN(
211 15, "GPIO15",
212 MTK_EINT_FUNCTION(0, 15),
213 DRV_GRP4,
214 MTK_FUNCTION(0, "GPIO15"),
215 MTK_FUNCTION(1, "DBPI_D2"),
216 MTK_FUNCTION(2, "SPI5_MO"),
217 MTK_FUNCTION(3, "PCM0_DO"),
218 MTK_FUNCTION(4, "MD_URXD1"),
219 MTK_FUNCTION(5, "ANT_SEL5"),
220 MTK_FUNCTION(6, "I2S0_LRCK"),
221 MTK_FUNCTION(7, "DBG_MON_B17")
222 ),
223 MTK_PIN(
224 16, "GPIO16",
225 MTK_EINT_FUNCTION(0, 16),
226 DRV_GRP4,
227 MTK_FUNCTION(0, "GPIO16"),
228 MTK_FUNCTION(1, "DBPI_D3"),
229 MTK_FUNCTION(2, "SPI5_CLK"),
230 MTK_FUNCTION(3, "PCM0_DI"),
231 MTK_FUNCTION(4, "MD_UTXD1"),
232 MTK_FUNCTION(5, "ANT_SEL6"),
233 MTK_FUNCTION(6, "I2S0_DI"),
234 MTK_FUNCTION(7, "DBG_MON_B23")
235 ),
236 MTK_PIN(
237 17, "GPIO17",
238 MTK_EINT_FUNCTION(0, 17),
239 DRV_GRP4,
240 MTK_FUNCTION(0, "GPIO17"),
241 MTK_FUNCTION(1, "DBPI_D4"),
242 MTK_FUNCTION(2, "SPI4_MI"),
243 MTK_FUNCTION(3, "CONN_MCU_TRST_B"),
244 MTK_FUNCTION(4, "MD_INT0"),
245 MTK_FUNCTION(5, "ANT_SEL7"),
246 MTK_FUNCTION(6, "I2S3_MCK"),
247 MTK_FUNCTION(7, "DBG_MON_A1")
248 ),
249 MTK_PIN(
250 18, "GPIO18",
251 MTK_EINT_FUNCTION(0, 18),
252 DRV_GRP4,
253 MTK_FUNCTION(0, "GPIO18"),
254 MTK_FUNCTION(1, "DBPI_D5"),
255 MTK_FUNCTION(2, "SPI4_CSB"),
256 MTK_FUNCTION(3, "CONN_MCU_DBGI_N"),
257 MTK_FUNCTION(4, "MD_INT0"),
258 MTK_FUNCTION(5, "SCP_VREQ_VAO"),
259 MTK_FUNCTION(6, "I2S3_BCK"),
260 MTK_FUNCTION(7, "DBG_MON_A2")
261 ),
262 MTK_PIN(
263 19, "GPIO19",
264 MTK_EINT_FUNCTION(0, 19),
265 DRV_GRP4,
266 MTK_FUNCTION(0, "GPIO19"),
267 MTK_FUNCTION(1, "DBPI_D6"),
268 MTK_FUNCTION(2, "SPI4_MO"),
269 MTK_FUNCTION(3, "CONN_MCU_TDO"),
270 MTK_FUNCTION(4, "MD_INT2_C2K_UIM1_HOT_PLUG"),
271 MTK_FUNCTION(5, "URXD1"),
272 MTK_FUNCTION(6, "I2S3_LRCK"),
273 MTK_FUNCTION(7, "DBG_MON_A3")
274 ),
275 MTK_PIN(
276 20, "GPIO20",
277 MTK_EINT_FUNCTION(0, 20),
278 DRV_GRP4,
279 MTK_FUNCTION(0, "GPIO20"),
280 MTK_FUNCTION(1, "DBPI_D7"),
281 MTK_FUNCTION(2, "SPI4_CLK"),
282 MTK_FUNCTION(3, "CONN_MCU_DBGACK_N"),
283 MTK_FUNCTION(4, "MD_INT1_C2K_UIM0_HOT_PLUG"),
284 MTK_FUNCTION(5, "UTXD1"),
285 MTK_FUNCTION(6, "I2S3_DO"),
286 MTK_FUNCTION(7, "DBG_MON_A19")
287 ),
288 MTK_PIN(
289 21, "GPIO21",
290 MTK_EINT_FUNCTION(0, 21),
291 DRV_GRP4,
292 MTK_FUNCTION(0, "GPIO21"),
293 MTK_FUNCTION(1, "DBPI_D8"),
294 MTK_FUNCTION(2, "SPI3_MI"),
295 MTK_FUNCTION(3, "CONN_MCU_TMS"),
296 MTK_FUNCTION(4, "DAP_MD32_SWD"),
297 MTK_FUNCTION(5, "CONN_MCU_AICE_TMSC"),
298 MTK_FUNCTION(6, "I2S2_MCK"),
299 MTK_FUNCTION(7, "DBG_MON_B5")
300 ),
301 MTK_PIN(
302 22, "GPIO22",
303 MTK_EINT_FUNCTION(0, 22),
304 DRV_GRP4,
305 MTK_FUNCTION(0, "GPIO22"),
306 MTK_FUNCTION(1, "DBPI_D9"),
307 MTK_FUNCTION(2, "SPI3_CSB"),
308 MTK_FUNCTION(3, "CONN_MCU_TCK"),
309 MTK_FUNCTION(4, "DAP_MD32_SWCK"),
310 MTK_FUNCTION(5, "CONN_MCU_AICE_TCKC"),
311 MTK_FUNCTION(6, "I2S2_BCK"),
312 MTK_FUNCTION(7, "DBG_MON_B6")
313 ),
314 MTK_PIN(
315 23, "GPIO23",
316 MTK_EINT_FUNCTION(0, 23),
317 DRV_GRP4,
318 MTK_FUNCTION(0, "GPIO23"),
319 MTK_FUNCTION(1, "DBPI_D10"),
320 MTK_FUNCTION(2, "SPI3_MO"),
321 MTK_FUNCTION(3, "CONN_MCU_TDI"),
322 MTK_FUNCTION(4, "UCTS1"),
323 MTK_FUNCTION(5, "EXT_FRAME_SYNC"),
324 MTK_FUNCTION(6, "I2S2_LRCK"),
325 MTK_FUNCTION(7, "DBG_MON_B7")
326 ),
327 MTK_PIN(
328 24, "GPIO24",
329 MTK_EINT_FUNCTION(0, 24),
330 DRV_GRP4,
331 MTK_FUNCTION(0, "GPIO24"),
332 MTK_FUNCTION(1, "DBPI_D11"),
333 MTK_FUNCTION(2, "SPI3_CLK"),
334 MTK_FUNCTION(3, "SRCLKENAI0"),
335 MTK_FUNCTION(4, "URTS1"),
336 MTK_FUNCTION(5, "IO_JTAG_TCK"),
337 MTK_FUNCTION(6, "I2S2_DI"),
338 MTK_FUNCTION(7, "DBG_MON_B31")
339 ),
340 MTK_PIN(
341 25, "GPIO25",
342 MTK_EINT_FUNCTION(0, 25),
343 DRV_GRP4,
344 MTK_FUNCTION(0, "GPIO25"),
345 MTK_FUNCTION(1, "DBPI_HSYNC"),
346 MTK_FUNCTION(2, "ANT_SEL0"),
347 MTK_FUNCTION(3, "SCL6"),
348 MTK_FUNCTION(4, "KPCOL2"),
349 MTK_FUNCTION(5, "IO_JTAG_TMS"),
350 MTK_FUNCTION(6, "I2S1_MCK"),
351 MTK_FUNCTION(7, "DBG_MON_B0")
352 ),
353 MTK_PIN(
354 26, "GPIO26",
355 MTK_EINT_FUNCTION(0, 26),
356 DRV_GRP4,
357 MTK_FUNCTION(0, "GPIO26"),
358 MTK_FUNCTION(1, "DBPI_VSYNC"),
359 MTK_FUNCTION(2, "ANT_SEL1"),
360 MTK_FUNCTION(3, "SDA6"),
361 MTK_FUNCTION(4, "KPROW2"),
362 MTK_FUNCTION(5, "IO_JTAG_TDI"),
363 MTK_FUNCTION(6, "I2S1_BCK"),
364 MTK_FUNCTION(7, "DBG_MON_B1")
365 ),
366 MTK_PIN(
367 27, "GPIO27",
368 MTK_EINT_FUNCTION(0, 27),
369 DRV_GRP4,
370 MTK_FUNCTION(0, "GPIO27"),
371 MTK_FUNCTION(1, "DBPI_DE"),
372 MTK_FUNCTION(2, "ANT_SEL2"),
373 MTK_FUNCTION(3, "SCL7"),
374 MTK_FUNCTION(4, "DMIC_CLK"),
375 MTK_FUNCTION(5, "IO_JTAG_TDO"),
376 MTK_FUNCTION(6, "I2S1_LRCK"),
377 MTK_FUNCTION(7, "DBG_MON_B9")
378 ),
379 MTK_PIN(
380 28, "GPIO28",
381 MTK_EINT_FUNCTION(0, 28),
382 DRV_GRP4,
383 MTK_FUNCTION(0, "GPIO28"),
384 MTK_FUNCTION(1, "DBPI_CK"),
385 MTK_FUNCTION(2, "DVFSRC_EXT_REQ"),
386 MTK_FUNCTION(3, "SDA7"),
387 MTK_FUNCTION(4, "DMIC_DAT"),
388 MTK_FUNCTION(5, "IO_JTAG_TRSTN"),
389 MTK_FUNCTION(6, "I2S1_DO"),
390 MTK_FUNCTION(7, "DBG_MON_B32")
391 ),
392 MTK_PIN(
393 29, "GPIO29",
394 MTK_EINT_FUNCTION(0, 29),
395 DRV_GRP4,
396 MTK_FUNCTION(0, "GPIO29"),
397 MTK_FUNCTION(1, "MSDC1_CLK"),
398 MTK_FUNCTION(2, "IO_JTAG_TCK"),
399 MTK_FUNCTION(3, "UDI_TCK"),
400 MTK_FUNCTION(4, "CONN_DSP_JCK"),
401 MTK_FUNCTION(5, "SSPM_JTAG_TCK"),
402 MTK_FUNCTION(6, "PCM1_CLK"),
403 MTK_FUNCTION(7, "DBG_MON_A6")
404 ),
405 MTK_PIN(
406 30, "GPIO30",
407 MTK_EINT_FUNCTION(0, 30),
408 DRV_GRP4,
409 MTK_FUNCTION(0, "GPIO30"),
410 MTK_FUNCTION(1, "MSDC1_DAT3"),
411 MTK_FUNCTION(2, "DAP_MD32_SWD"),
412 MTK_FUNCTION(3, "CONN_MCU_AICE_TMSC"),
413 MTK_FUNCTION(4, "CONN_DSP_JINTP"),
414 MTK_FUNCTION(5, "SSPM_JTAG_TRSTN"),
415 MTK_FUNCTION(6, "PCM1_DI"),
416 MTK_FUNCTION(7, "DBG_MON_A7")
417 ),
418 MTK_PIN(
419 31, "GPIO31",
420 MTK_EINT_FUNCTION(0, 31),
421 DRV_GRP4,
422 MTK_FUNCTION(0, "GPIO31"),
423 MTK_FUNCTION(1, "MSDC1_CMD"),
424 MTK_FUNCTION(2, "IO_JTAG_TMS"),
425 MTK_FUNCTION(3, "UDI_TMS"),
426 MTK_FUNCTION(4, "CONN_DSP_JMS"),
427 MTK_FUNCTION(5, "SSPM_JTAG_TMS"),
428 MTK_FUNCTION(6, "PCM1_SYNC"),
429 MTK_FUNCTION(7, "DBG_MON_A8")
430 ),
431 MTK_PIN(
432 32, "GPIO32",
433 MTK_EINT_FUNCTION(0, 32),
434 DRV_GRP4,
435 MTK_FUNCTION(0, "GPIO32"),
436 MTK_FUNCTION(1, "MSDC1_DAT0"),
437 MTK_FUNCTION(2, "IO_JTAG_TDI"),
438 MTK_FUNCTION(3, "UDI_TDI"),
439 MTK_FUNCTION(4, "CONN_DSP_JDI"),
440 MTK_FUNCTION(5, "SSPM_JTAG_TDI"),
441 MTK_FUNCTION(6, "PCM1_DO0"),
442 MTK_FUNCTION(7, "DBG_MON_A9")
443 ),
444 MTK_PIN(
445 33, "GPIO33",
446 MTK_EINT_FUNCTION(0, 33),
447 DRV_GRP4,
448 MTK_FUNCTION(0, "GPIO33"),
449 MTK_FUNCTION(1, "MSDC1_DAT2"),
450 MTK_FUNCTION(2, "IO_JTAG_TRSTN"),
451 MTK_FUNCTION(3, "UDI_NTRST"),
452 MTK_FUNCTION(4, "DAP_MD32_SWCK"),
453 MTK_FUNCTION(5, "CONN_MCU_AICE_TCKC"),
454 MTK_FUNCTION(6, "PCM1_DO2"),
455 MTK_FUNCTION(7, "DBG_MON_A10")
456 ),
457 MTK_PIN(
458 34, "GPIO34",
459 MTK_EINT_FUNCTION(0, 34),
460 DRV_GRP4,
461 MTK_FUNCTION(0, "GPIO34"),
462 MTK_FUNCTION(1, "MSDC1_DAT1"),
463 MTK_FUNCTION(2, "IO_JTAG_TDO"),
464 MTK_FUNCTION(3, "UDI_TDO"),
465 MTK_FUNCTION(4, "CONN_DSP_JDO"),
466 MTK_FUNCTION(5, "SSPM_JTAG_TDO"),
467 MTK_FUNCTION(6, "PCM1_DO1"),
468 MTK_FUNCTION(7, "DBG_MON_A11")
469 ),
470 MTK_PIN(
471 35, "GPIO35",
472 MTK_EINT_FUNCTION(0, 35),
473 DRV_GRP4,
474 MTK_FUNCTION(0, "GPIO35"),
475 MTK_FUNCTION(1, "MD1_SIM2_SIO"),
476 MTK_FUNCTION(2, "CCU_JTAG_TDO"),
477 MTK_FUNCTION(3, "MD1_SIM1_SIO"),
478 MTK_FUNCTION(5, "SCP_JTAG_TDO"),
479 MTK_FUNCTION(6, "CONN_DSP_JMS"),
480 MTK_FUNCTION(7, "DBG_MON_A28")
481 ),
482 MTK_PIN(
483 36, "GPIO36",
484 MTK_EINT_FUNCTION(0, 36),
485 DRV_GRP4,
486 MTK_FUNCTION(0, "GPIO36"),
487 MTK_FUNCTION(1, "MD1_SIM2_SRST"),
488 MTK_FUNCTION(2, "CCU_JTAG_TMS"),
489 MTK_FUNCTION(3, "MD1_SIM1_SRST"),
490 MTK_FUNCTION(4, "CONN_MCU_AICE_TMSC"),
491 MTK_FUNCTION(5, "SCP_JTAG_TMS"),
492 MTK_FUNCTION(6, "CONN_DSP_JINTP"),
493 MTK_FUNCTION(7, "DBG_MON_A29")
494 ),
495 MTK_PIN(
496 37, "GPIO37",
497 MTK_EINT_FUNCTION(0, 37),
498 DRV_GRP4,
499 MTK_FUNCTION(0, "GPIO37"),
500 MTK_FUNCTION(1, "MD1_SIM2_SCLK"),
501 MTK_FUNCTION(2, "CCU_JTAG_TDI"),
502 MTK_FUNCTION(3, "MD1_SIM1_SCLK"),
503 MTK_FUNCTION(5, "SCP_JTAG_TDI"),
504 MTK_FUNCTION(6, "CONN_DSP_JDO"),
505 MTK_FUNCTION(7, "DBG_MON_A30")
506 ),
507 MTK_PIN(
508 38, "GPIO38",
509 MTK_EINT_FUNCTION(0, 38),
510 DRV_GRP4,
511 MTK_FUNCTION(0, "GPIO38"),
512 MTK_FUNCTION(1, "MD1_SIM1_SCLK"),
513 MTK_FUNCTION(3, "MD1_SIM2_SCLK"),
514 MTK_FUNCTION(4, "CONN_MCU_AICE_TCKC"),
515 MTK_FUNCTION(7, "DBG_MON_A20")
516 ),
517 MTK_PIN(
518 39, "GPIO39",
519 MTK_EINT_FUNCTION(0, 39),
520 DRV_GRP4,
521 MTK_FUNCTION(0, "GPIO39"),
522 MTK_FUNCTION(1, "MD1_SIM1_SRST"),
523 MTK_FUNCTION(2, "CCU_JTAG_TCK"),
524 MTK_FUNCTION(3, "MD1_SIM2_SRST"),
525 MTK_FUNCTION(5, "SCP_JTAG_TCK"),
526 MTK_FUNCTION(6, "CONN_DSP_JCK"),
527 MTK_FUNCTION(7, "DBG_MON_A31")
528 ),
529 MTK_PIN(
530 40, "GPIO40",
531 MTK_EINT_FUNCTION(0, 40),
532 DRV_GRP4,
533 MTK_FUNCTION(0, "GPIO40"),
534 MTK_FUNCTION(1, "MD1_SIM1_SIO"),
535 MTK_FUNCTION(2, "CCU_JTAG_TRST"),
536 MTK_FUNCTION(3, "MD1_SIM2_SIO"),
537 MTK_FUNCTION(5, "SCP_JTAG_TRSTN"),
538 MTK_FUNCTION(6, "CONN_DSP_JDI"),
539 MTK_FUNCTION(7, "DBG_MON_A32")
540 ),
541 MTK_PIN(
542 41, "GPIO41",
543 MTK_EINT_FUNCTION(0, 41),
544 DRV_GRP4,
545 MTK_FUNCTION(0, "GPIO41"),
546 MTK_FUNCTION(1, "IDDIG"),
547 MTK_FUNCTION(2, "URXD1"),
548 MTK_FUNCTION(3, "UCTS0"),
549 MTK_FUNCTION(4, "SSPM_UTXD_AO"),
550 MTK_FUNCTION(5, "EXT_FRAME_SYNC"),
551 MTK_FUNCTION(6, "DMIC_CLK")
552 ),
553 MTK_PIN(
554 42, "GPIO42",
555 MTK_EINT_FUNCTION(0, 42),
556 DRV_GRP4,
557 MTK_FUNCTION(0, "GPIO42"),
558 MTK_FUNCTION(1, "USB_DRVVBUS"),
559 MTK_FUNCTION(2, "UTXD1"),
560 MTK_FUNCTION(3, "URTS0"),
561 MTK_FUNCTION(4, "SSPM_URXD_AO"),
562 MTK_FUNCTION(5, "EXT_FRAME_SYNC"),
563 MTK_FUNCTION(6, "DMIC_DAT")
564 ),
565 MTK_PIN(
566 43, "GPIO43",
567 MTK_EINT_FUNCTION(0, 43),
568 DRV_GRP4,
569 MTK_FUNCTION(0, "GPIO43"),
570 MTK_FUNCTION(1, "DISP_PWM")
571 ),
572 MTK_PIN(
573 44, "GPIO44",
574 MTK_EINT_FUNCTION(0, 44),
575 DRV_GRP4,
576 MTK_FUNCTION(0, "GPIO44"),
577 MTK_FUNCTION(1, "DSI_TE")
578 ),
579 MTK_PIN(
580 45, "GPIO45",
581 MTK_EINT_FUNCTION(0, 45),
582 DRV_GRP4,
583 MTK_FUNCTION(0, "GPIO45"),
584 MTK_FUNCTION(1, "LCM_RST")
585 ),
586 MTK_PIN(
587 46, "GPIO46",
588 MTK_EINT_FUNCTION(0, 46),
589 DRV_GRP4,
590 MTK_FUNCTION(0, "GPIO46"),
591 MTK_FUNCTION(1, "MD_INT2_C2K_UIM1_HOT_PLUG"),
592 MTK_FUNCTION(2, "URXD1"),
593 MTK_FUNCTION(3, "UCTS1"),
594 MTK_FUNCTION(4, "CCU_UTXD_AO"),
595 MTK_FUNCTION(5, "TP_UCTS1_AO"),
596 MTK_FUNCTION(6, "IDDIG"),
597 MTK_FUNCTION(7, "I2S5_LRCK")
598 ),
599 MTK_PIN(
600 47, "GPIO47",
601 MTK_EINT_FUNCTION(0, 47),
602 DRV_GRP4,
603 MTK_FUNCTION(0, "GPIO47"),
604 MTK_FUNCTION(1, "MD_INT1_C2K_UIM0_HOT_PLUG"),
605 MTK_FUNCTION(2, "UTXD1"),
606 MTK_FUNCTION(3, "URTS1"),
607 MTK_FUNCTION(4, "CCU_URXD_AO"),
608 MTK_FUNCTION(5, "TP_URTS1_AO"),
609 MTK_FUNCTION(6, "USB_DRVVBUS"),
610 MTK_FUNCTION(7, "I2S5_DO")
611 ),
612 MTK_PIN(
613 48, "GPIO48",
614 MTK_EINT_FUNCTION(0, 48),
615 DRV_GRP4,
616 MTK_FUNCTION(0, "GPIO48"),
617 MTK_FUNCTION(1, "SCL5")
618 ),
619 MTK_PIN(
620 49, "GPIO49",
621 MTK_EINT_FUNCTION(0, 49),
622 DRV_GRP4,
623 MTK_FUNCTION(0, "GPIO49"),
624 MTK_FUNCTION(1, "SDA5")
625 ),
626 MTK_PIN(
627 50, "GPIO50",
628 MTK_EINT_FUNCTION(0, 50),
629 DRV_GRP4,
630 MTK_FUNCTION(0, "GPIO50"),
631 MTK_FUNCTION(1, "SCL3")
632 ),
633 MTK_PIN(
634 51, "GPIO51",
635 MTK_EINT_FUNCTION(0, 51),
636 DRV_GRP4,
637 MTK_FUNCTION(0, "GPIO51"),
638 MTK_FUNCTION(1, "SDA3")
639 ),
640 MTK_PIN(
641 52, "GPIO52",
642 MTK_EINT_FUNCTION(0, 52),
643 DRV_GRP4,
644 MTK_FUNCTION(0, "GPIO52"),
645 MTK_FUNCTION(1, "BPI_ANT2")
646 ),
647 MTK_PIN(
648 53, "GPIO53",
649 MTK_EINT_FUNCTION(0, 53),
650 DRV_GRP4,
651 MTK_FUNCTION(0, "GPIO53"),
652 MTK_FUNCTION(1, "BPI_ANT0")
653 ),
654 MTK_PIN(
655 54, "GPIO54",
656 MTK_EINT_FUNCTION(0, 54),
657 DRV_GRP4,
658 MTK_FUNCTION(0, "GPIO54"),
659 MTK_FUNCTION(1, "BPI_OLAT1")
660 ),
661 MTK_PIN(
662 55, "GPIO55",
663 MTK_EINT_FUNCTION(0, 55),
664 DRV_GRP4,
665 MTK_FUNCTION(0, "GPIO55"),
666 MTK_FUNCTION(1, "BPI_BUS8")
667 ),
668 MTK_PIN(
669 56, "GPIO56",
670 MTK_EINT_FUNCTION(0, 56),
671 DRV_GRP4,
672 MTK_FUNCTION(0, "GPIO56"),
673 MTK_FUNCTION(1, "BPI_BUS9"),
674 MTK_FUNCTION(2, "SCL_6306")
675 ),
676 MTK_PIN(
677 57, "GPIO57",
678 MTK_EINT_FUNCTION(0, 57),
679 DRV_GRP4,
680 MTK_FUNCTION(0, "GPIO57"),
681 MTK_FUNCTION(1, "BPI_BUS10"),
682 MTK_FUNCTION(2, "SDA_6306")
683 ),
684 MTK_PIN(
685 58, "GPIO58",
686 MTK_EINT_FUNCTION(0, 58),
687 DRV_GRP4,
688 MTK_FUNCTION(0, "GPIO58"),
689 MTK_FUNCTION(1, "RFIC0_BSI_D2"),
690 MTK_FUNCTION(2, "SPM_BSI_D2"),
691 MTK_FUNCTION(3, "PWM_B")
692 ),
693 MTK_PIN(
694 59, "GPIO59",
695 MTK_EINT_FUNCTION(0, 59),
696 DRV_GRP4,
697 MTK_FUNCTION(0, "GPIO59"),
698 MTK_FUNCTION(1, "RFIC0_BSI_D1"),
699 MTK_FUNCTION(2, "SPM_BSI_D1")
700 ),
701 MTK_PIN(
702 60, "GPIO60",
703 MTK_EINT_FUNCTION(0, 60),
704 DRV_GRP4,
705 MTK_FUNCTION(0, "GPIO60"),
706 MTK_FUNCTION(1, "RFIC0_BSI_D0"),
707 MTK_FUNCTION(2, "SPM_BSI_D0")
708 ),
709 MTK_PIN(
710 61, "GPIO61",
711 MTK_EINT_FUNCTION(0, 61),
712 DRV_GRP4,
713 MTK_FUNCTION(0, "GPIO61"),
714 MTK_FUNCTION(1, "MIPI1_SDATA")
715 ),
716 MTK_PIN(
717 62, "GPIO62",
718 MTK_EINT_FUNCTION(0, 62),
719 DRV_GRP4,
720 MTK_FUNCTION(0, "GPIO62"),
721 MTK_FUNCTION(1, "MIPI1_SCLK")
722 ),
723 MTK_PIN(
724 63, "GPIO63",
725 MTK_EINT_FUNCTION(0, 63),
726 DRV_GRP4,
727 MTK_FUNCTION(0, "GPIO63"),
728 MTK_FUNCTION(1, "MIPI0_SDATA")
729 ),
730 MTK_PIN(
731 64, "GPIO64",
732 MTK_EINT_FUNCTION(0, 64),
733 DRV_GRP4,
734 MTK_FUNCTION(0, "GPIO64"),
735 MTK_FUNCTION(1, "MIPI0_SCLK")
736 ),
737 MTK_PIN(
738 65, "GPIO65",
739 MTK_EINT_FUNCTION(0, 65),
740 DRV_GRP4,
741 MTK_FUNCTION(0, "GPIO65"),
742 MTK_FUNCTION(1, "MIPI3_SDATA"),
743 MTK_FUNCTION(2, "BPI_OLAT2")
744 ),
745 MTK_PIN(
746 66, "GPIO66",
747 MTK_EINT_FUNCTION(0, 66),
748 DRV_GRP4,
749 MTK_FUNCTION(0, "GPIO66"),
750 MTK_FUNCTION(1, "MIPI3_SCLK"),
751 MTK_FUNCTION(2, "BPI_OLAT3")
752 ),
753 MTK_PIN(
754 67, "GPIO67",
755 MTK_EINT_FUNCTION(0, 67),
756 DRV_GRP4,
757 MTK_FUNCTION(0, "GPIO67"),
758 MTK_FUNCTION(1, "MIPI2_SDATA")
759 ),
760 MTK_PIN(
761 68, "GPIO68",
762 MTK_EINT_FUNCTION(0, 68),
763 DRV_GRP4,
764 MTK_FUNCTION(0, "GPIO68"),
765 MTK_FUNCTION(1, "MIPI2_SCLK")
766 ),
767 MTK_PIN(
768 69, "GPIO69",
769 MTK_EINT_FUNCTION(0, 69),
770 DRV_GRP4,
771 MTK_FUNCTION(0, "GPIO69"),
772 MTK_FUNCTION(1, "BPI_BUS7")
773 ),
774 MTK_PIN(
775 70, "GPIO70",
776 MTK_EINT_FUNCTION(0, 70),
777 DRV_GRP4,
778 MTK_FUNCTION(0, "GPIO70"),
779 MTK_FUNCTION(1, "BPI_BUS6")
780 ),
781 MTK_PIN(
782 71, "GPIO71",
783 MTK_EINT_FUNCTION(0, 71),
784 DRV_GRP4,
785 MTK_FUNCTION(0, "GPIO71"),
786 MTK_FUNCTION(1, "BPI_BUS5")
787 ),
788 MTK_PIN(
789 72, "GPIO72",
790 MTK_EINT_FUNCTION(0, 72),
791 DRV_GRP4,
792 MTK_FUNCTION(0, "GPIO72"),
793 MTK_FUNCTION(1, "BPI_BUS4")
794 ),
795 MTK_PIN(
796 73, "GPIO73",
797 MTK_EINT_FUNCTION(0, 73),
798 DRV_GRP4,
799 MTK_FUNCTION(0, "GPIO73"),
800 MTK_FUNCTION(1, "BPI_BUS3")
801 ),
802 MTK_PIN(
803 74, "GPIO74",
804 MTK_EINT_FUNCTION(0, 74),
805 DRV_GRP4,
806 MTK_FUNCTION(0, "GPIO74"),
807 MTK_FUNCTION(1, "BPI_BUS2")
808 ),
809 MTK_PIN(
810 75, "GPIO75",
811 MTK_EINT_FUNCTION(0, 75),
812 DRV_GRP4,
813 MTK_FUNCTION(0, "GPIO75"),
814 MTK_FUNCTION(1, "BPI_BUS1")
815 ),
816 MTK_PIN(
817 76, "GPIO76",
818 MTK_EINT_FUNCTION(0, 76),
819 DRV_GRP4,
820 MTK_FUNCTION(0, "GPIO76"),
821 MTK_FUNCTION(1, "BPI_BUS0")
822 ),
823 MTK_PIN(
824 77, "GPIO77",
825 MTK_EINT_FUNCTION(0, 77),
826 DRV_GRP4,
827 MTK_FUNCTION(0, "GPIO77"),
828 MTK_FUNCTION(1, "BPI_ANT1")
829 ),
830 MTK_PIN(
831 78, "GPIO78",
832 MTK_EINT_FUNCTION(0, 78),
833 DRV_GRP4,
834 MTK_FUNCTION(0, "GPIO78"),
835 MTK_FUNCTION(1, "BPI_OLAT0")
836 ),
837 MTK_PIN(
838 79, "GPIO79",
839 MTK_EINT_FUNCTION(0, 79),
840 DRV_GRP4,
841 MTK_FUNCTION(0, "GPIO79"),
842 MTK_FUNCTION(1, "BPI_PA_VM1"),
843 MTK_FUNCTION(2, "MIPI4_SDATA")
844 ),
845 MTK_PIN(
846 80, "GPIO80",
847 MTK_EINT_FUNCTION(0, 80),
848 DRV_GRP4,
849 MTK_FUNCTION(0, "GPIO80"),
850 MTK_FUNCTION(1, "BPI_PA_VM0"),
851 MTK_FUNCTION(2, "MIPI4_SCLK")
852 ),
853 MTK_PIN(
854 81, "GPIO81",
855 MTK_EINT_FUNCTION(0, 81),
856 DRV_GRP4,
857 MTK_FUNCTION(0, "GPIO81"),
858 MTK_FUNCTION(1, "SDA1")
859 ),
860 MTK_PIN(
861 82, "GPIO82",
862 MTK_EINT_FUNCTION(0, 82),
863 DRV_GRP4,
864 MTK_FUNCTION(0, "GPIO82"),
865 MTK_FUNCTION(1, "SDA0")
866 ),
867 MTK_PIN(
868 83, "GPIO83",
869 MTK_EINT_FUNCTION(0, 83),
870 DRV_GRP4,
871 MTK_FUNCTION(0, "GPIO83"),
872 MTK_FUNCTION(1, "SCL0")
873 ),
874 MTK_PIN(
875 84, "GPIO84",
876 MTK_EINT_FUNCTION(0, 84),
877 DRV_GRP4,
878 MTK_FUNCTION(0, "GPIO84"),
879 MTK_FUNCTION(1, "SCL1")
880 ),
881 MTK_PIN(
882 85, "GPIO85",
883 MTK_EINT_FUNCTION(0, 85),
884 DRV_GRP4,
885 MTK_FUNCTION(0, "GPIO85"),
886 MTK_FUNCTION(1, "SPI0_MI"),
887 MTK_FUNCTION(2, "SCP_SPI0_MI"),
888 MTK_FUNCTION(3, "CLKM3"),
889 MTK_FUNCTION(4, "I2S1_BCK"),
890 MTK_FUNCTION(5, "MFG_DFD_JTAG_TDO"),
891 MTK_FUNCTION(6, "DFD_TDO"),
892 MTK_FUNCTION(7, "JTDO_SEL1")
893 ),
894 MTK_PIN(
895 86, "GPIO86",
896 MTK_EINT_FUNCTION(0, 86),
897 DRV_GRP4,
898 MTK_FUNCTION(0, "GPIO86"),
899 MTK_FUNCTION(1, "SPI0_CSB"),
900 MTK_FUNCTION(2, "SCP_SPI0_CS"),
901 MTK_FUNCTION(3, "CLKM0"),
902 MTK_FUNCTION(4, "I2S1_LRCK"),
903 MTK_FUNCTION(5, "MFG_DFD_JTAG_TMS"),
904 MTK_FUNCTION(6, "DFD_TMS"),
905 MTK_FUNCTION(7, "JTMS_SEL1")
906 ),
907 MTK_PIN(
908 87, "GPIO87",
909 MTK_EINT_FUNCTION(0, 87),
910 DRV_GRP4,
911 MTK_FUNCTION(0, "GPIO87"),
912 MTK_FUNCTION(1, "SPI0_MO"),
913 MTK_FUNCTION(2, "SCP_SPI0_MO"),
914 MTK_FUNCTION(3, "SDA1"),
915 MTK_FUNCTION(4, "I2S1_DO"),
916 MTK_FUNCTION(5, "MFG_DFD_JTAG_TDI"),
917 MTK_FUNCTION(6, "DFD_TDI"),
918 MTK_FUNCTION(7, "JTDI_SEL1")
919 ),
920 MTK_PIN(
921 88, "GPIO88",
922 MTK_EINT_FUNCTION(0, 88),
923 DRV_GRP4,
924 MTK_FUNCTION(0, "GPIO88"),
925 MTK_FUNCTION(1, "SPI0_CLK"),
926 MTK_FUNCTION(2, "SCP_SPI0_CK"),
927 MTK_FUNCTION(3, "SCL1"),
928 MTK_FUNCTION(4, "I2S1_MCK"),
929 MTK_FUNCTION(5, "MFG_DFD_JTAG_TCK"),
930 MTK_FUNCTION(6, "DFD_TCK_XI"),
931 MTK_FUNCTION(7, "JTCK_SEL1")
932 ),
933 MTK_PIN(
934 89, "GPIO89",
935 MTK_EINT_FUNCTION(0, 89),
936 DRV_GRP4,
937 MTK_FUNCTION(0, "GPIO89"),
938 MTK_FUNCTION(1, "SRCLKENAI0"),
939 MTK_FUNCTION(2, "PWM_C"),
940 MTK_FUNCTION(3, "I2S5_BCK"),
941 MTK_FUNCTION(4, "ANT_SEL6"),
942 MTK_FUNCTION(5, "SDA8"),
943 MTK_FUNCTION(6, "CMVREF0"),
944 MTK_FUNCTION(7, "DBG_MON_A21")
945 ),
946 MTK_PIN(
947 90, "GPIO90",
948 MTK_EINT_FUNCTION(0, 90),
949 DRV_GRP4,
950 MTK_FUNCTION(0, "GPIO90"),
951 MTK_FUNCTION(1, "PWM_A"),
952 MTK_FUNCTION(2, "CMMCLK2"),
953 MTK_FUNCTION(3, "I2S5_LRCK"),
954 MTK_FUNCTION(4, "SCP_VREQ_VAO"),
955 MTK_FUNCTION(5, "SCL8"),
956 MTK_FUNCTION(6, "PTA_RXD"),
957 MTK_FUNCTION(7, "DBG_MON_A22")
958 ),
959 MTK_PIN(
960 91, "GPIO91",
961 MTK_EINT_FUNCTION(0, 91),
962 DRV_GRP4,
963 MTK_FUNCTION(0, "GPIO91"),
964 MTK_FUNCTION(1, "KPROW1"),
965 MTK_FUNCTION(2, "PWM_B"),
966 MTK_FUNCTION(3, "I2S5_DO"),
967 MTK_FUNCTION(4, "ANT_SEL7"),
968 MTK_FUNCTION(5, "CMMCLK3"),
969 MTK_FUNCTION(6, "PTA_TXD")
970 ),
971 MTK_PIN(
972 92, "GPIO92",
973 MTK_EINT_FUNCTION(0, 92),
974 DRV_GRP4,
975 MTK_FUNCTION(0, "GPIO92"),
976 MTK_FUNCTION(1, "KPROW0")
977 ),
978 MTK_PIN(
979 93, "GPIO93",
980 MTK_EINT_FUNCTION(0, 93),
981 DRV_GRP4,
982 MTK_FUNCTION(0, "GPIO93"),
983 MTK_FUNCTION(1, "KPCOL0"),
984 MTK_FUNCTION(7, "DBG_MON_B27")
985 ),
986 MTK_PIN(
987 94, "GPIO94",
988 MTK_EINT_FUNCTION(0, 94),
989 DRV_GRP4,
990 MTK_FUNCTION(0, "GPIO94"),
991 MTK_FUNCTION(1, "KPCOL1"),
992 MTK_FUNCTION(2, "I2S2_DI2"),
993 MTK_FUNCTION(3, "I2S5_MCK"),
994 MTK_FUNCTION(4, "CMMCLK2"),
995 MTK_FUNCTION(5, "SCP_SPI2_MI"),
996 MTK_FUNCTION(6, "SRCLKENAI1"),
997 MTK_FUNCTION(7, "SPI2_MI")
998 ),
999 MTK_PIN(
1000 95, "GPIO95",
1001 MTK_EINT_FUNCTION(0, 95),
1002 DRV_GRP4,
1003 MTK_FUNCTION(0, "GPIO95"),
1004 MTK_FUNCTION(1, "URXD0"),
1005 MTK_FUNCTION(2, "UTXD0"),
1006 MTK_FUNCTION(3, "MD_URXD0"),
1007 MTK_FUNCTION(4, "MD_URXD1"),
1008 MTK_FUNCTION(5, "SSPM_URXD_AO"),
1009 MTK_FUNCTION(6, "CCU_URXD_AO")
1010 ),
1011 MTK_PIN(
1012 96, "GPIO96",
1013 MTK_EINT_FUNCTION(0, 96),
1014 DRV_GRP4,
1015 MTK_FUNCTION(0, "GPIO96"),
1016 MTK_FUNCTION(1, "UTXD0"),
1017 MTK_FUNCTION(2, "URXD0"),
1018 MTK_FUNCTION(3, "MD_UTXD0"),
1019 MTK_FUNCTION(4, "MD_UTXD1"),
1020 MTK_FUNCTION(5, "SSPM_UTXD_AO"),
1021 MTK_FUNCTION(6, "CCU_UTXD_AO"),
1022 MTK_FUNCTION(7, "DBG_MON_B2")
1023 ),
1024 MTK_PIN(
1025 97, "GPIO97",
1026 MTK_EINT_FUNCTION(0, 97),
1027 DRV_GRP4,
1028 MTK_FUNCTION(0, "GPIO97"),
1029 MTK_FUNCTION(1, "UCTS0"),
1030 MTK_FUNCTION(2, "I2S2_MCK"),
1031 MTK_FUNCTION(3, "IDDIG"),
1032 MTK_FUNCTION(4, "CONN_MCU_TDO"),
1033 MTK_FUNCTION(5, "SSPM_JTAG_TDO"),
1034 MTK_FUNCTION(6, "IO_JTAG_TDO"),
1035 MTK_FUNCTION(7, "DBG_MON_B3")
1036 ),
1037 MTK_PIN(
1038 98, "GPIO98",
1039 MTK_EINT_FUNCTION(0, 98),
1040 DRV_GRP4,
1041 MTK_FUNCTION(0, "GPIO98"),
1042 MTK_FUNCTION(1, "URTS0"),
1043 MTK_FUNCTION(2, "I2S2_BCK"),
1044 MTK_FUNCTION(3, "USB_DRVVBUS"),
1045 MTK_FUNCTION(4, "CONN_MCU_TMS"),
1046 MTK_FUNCTION(5, "SSPM_JTAG_TMS"),
1047 MTK_FUNCTION(6, "IO_JTAG_TMS"),
1048 MTK_FUNCTION(7, "DBG_MON_B4")
1049 ),
1050 MTK_PIN(
1051 99, "GPIO99",
1052 MTK_EINT_FUNCTION(0, 99),
1053 DRV_GRP4,
1054 MTK_FUNCTION(0, "GPIO99"),
1055 MTK_FUNCTION(1, "CMMCLK0"),
1056 MTK_FUNCTION(4, "CONN_MCU_AICE_TMSC"),
1057 MTK_FUNCTION(7, "DBG_MON_B28")
1058 ),
1059 MTK_PIN(
1060 100, "GPIO100",
1061 MTK_EINT_FUNCTION(0, 100),
1062 DRV_GRP4,
1063 MTK_FUNCTION(0, "GPIO100"),
1064 MTK_FUNCTION(1, "CMMCLK1"),
1065 MTK_FUNCTION(2, "PWM_C"),
1066 MTK_FUNCTION(3, "MD_INT1_C2K_UIM0_HOT_PLUG"),
1067 MTK_FUNCTION(4, "CONN_MCU_AICE_TCKC"),
1068 MTK_FUNCTION(7, "DBG_MON_B29")
1069 ),
1070 MTK_PIN(
1071 101, "GPIO101",
1072 MTK_EINT_FUNCTION(0, 101),
1073 DRV_GRP4,
1074 MTK_FUNCTION(0, "GPIO101"),
1075 MTK_FUNCTION(1, "CLKM2"),
1076 MTK_FUNCTION(2, "I2S2_LRCK"),
1077 MTK_FUNCTION(3, "CMVREF1"),
1078 MTK_FUNCTION(4, "CONN_MCU_TCK"),
1079 MTK_FUNCTION(5, "SSPM_JTAG_TCK"),
1080 MTK_FUNCTION(6, "IO_JTAG_TCK")
1081 ),
1082 MTK_PIN(
1083 102, "GPIO102",
1084 MTK_EINT_FUNCTION(0, 102),
1085 DRV_GRP4,
1086 MTK_FUNCTION(0, "GPIO102"),
1087 MTK_FUNCTION(1, "CLKM1"),
1088 MTK_FUNCTION(2, "I2S2_DI"),
1089 MTK_FUNCTION(3, "DVFSRC_EXT_REQ"),
1090 MTK_FUNCTION(4, "CONN_MCU_TDI"),
1091 MTK_FUNCTION(5, "SSPM_JTAG_TDI"),
1092 MTK_FUNCTION(6, "IO_JTAG_TDI"),
1093 MTK_FUNCTION(7, "DBG_MON_B8")
1094 ),
1095 MTK_PIN(
1096 103, "GPIO103",
1097 MTK_EINT_FUNCTION(0, 103),
1098 DRV_GRP4,
1099 MTK_FUNCTION(0, "GPIO103"),
1100 MTK_FUNCTION(1, "SCL2")
1101 ),
1102 MTK_PIN(
1103 104, "GPIO104",
1104 MTK_EINT_FUNCTION(0, 104),
1105 DRV_GRP4,
1106 MTK_FUNCTION(0, "GPIO104"),
1107 MTK_FUNCTION(1, "SDA2")
1108 ),
1109 MTK_PIN(
1110 105, "GPIO105",
1111 MTK_EINT_FUNCTION(0, 105),
1112 DRV_GRP4,
1113 MTK_FUNCTION(0, "GPIO105"),
1114 MTK_FUNCTION(1, "SCL4")
1115 ),
1116 MTK_PIN(
1117 106, "GPIO106",
1118 MTK_EINT_FUNCTION(0, 106),
1119 DRV_GRP4,
1120 MTK_FUNCTION(0, "GPIO106"),
1121 MTK_FUNCTION(1, "SDA4")
1122 ),
1123 MTK_PIN(
1124 107, "GPIO107",
1125 MTK_EINT_FUNCTION(0, 107),
1126 DRV_GRP4,
1127 MTK_FUNCTION(0, "GPIO107"),
1128 MTK_FUNCTION(1, "DMIC_CLK"),
1129 MTK_FUNCTION(2, "ANT_SEL0"),
1130 MTK_FUNCTION(3, "CLKM0"),
1131 MTK_FUNCTION(4, "SDA7"),
1132 MTK_FUNCTION(5, "EXT_FRAME_SYNC"),
1133 MTK_FUNCTION(6, "PWM_A"),
1134 MTK_FUNCTION(7, "DBG_MON_B12")
1135 ),
1136 MTK_PIN(
1137 108, "GPIO108",
1138 MTK_EINT_FUNCTION(0, 108),
1139 DRV_GRP4,
1140 MTK_FUNCTION(0, "GPIO108"),
1141 MTK_FUNCTION(1, "CMMCLK2"),
1142 MTK_FUNCTION(2, "ANT_SEL1"),
1143 MTK_FUNCTION(3, "CLKM1"),
1144 MTK_FUNCTION(4, "SCL8"),
1145 MTK_FUNCTION(5, "DAP_MD32_SWD"),
1146 MTK_FUNCTION(6, "PWM_B"),
1147 MTK_FUNCTION(7, "DBG_MON_B13")
1148 ),
1149 MTK_PIN(
1150 109, "GPIO109",
1151 MTK_EINT_FUNCTION(0, 109),
1152 DRV_GRP4,
1153 MTK_FUNCTION(0, "GPIO109"),
1154 MTK_FUNCTION(1, "DMIC_DAT"),
1155 MTK_FUNCTION(2, "ANT_SEL2"),
1156 MTK_FUNCTION(3, "CLKM2"),
1157 MTK_FUNCTION(4, "SDA8"),
1158 MTK_FUNCTION(5, "DAP_MD32_SWCK"),
1159 MTK_FUNCTION(6, "PWM_C"),
1160 MTK_FUNCTION(7, "DBG_MON_B14")
1161 ),
1162 MTK_PIN(
1163 110, "GPIO110",
1164 MTK_EINT_FUNCTION(0, 110),
1165 DRV_GRP4,
1166 MTK_FUNCTION(0, "GPIO110"),
1167 MTK_FUNCTION(1, "SCL7"),
1168 MTK_FUNCTION(2, "ANT_SEL0"),
1169 MTK_FUNCTION(3, "TP_URXD1_AO"),
1170 MTK_FUNCTION(4, "USB_DRVVBUS"),
1171 MTK_FUNCTION(5, "SRCLKENAI1"),
1172 MTK_FUNCTION(6, "KPCOL2"),
1173 MTK_FUNCTION(7, "URXD1")
1174 ),
1175 MTK_PIN(
1176 111, "GPIO111",
1177 MTK_EINT_FUNCTION(0, 111),
1178 DRV_GRP4,
1179 MTK_FUNCTION(0, "GPIO111"),
1180 MTK_FUNCTION(1, "CMMCLK3"),
1181 MTK_FUNCTION(2, "ANT_SEL1"),
1182 MTK_FUNCTION(3, "SRCLKENAI0"),
1183 MTK_FUNCTION(4, "SCP_VREQ_VAO"),
1184 MTK_FUNCTION(5, "MD_INT2_C2K_UIM1_HOT_PLUG"),
1185 MTK_FUNCTION(7, "DVFSRC_EXT_REQ")
1186 ),
1187 MTK_PIN(
1188 112, "GPIO112",
1189 MTK_EINT_FUNCTION(0, 112),
1190 DRV_GRP4,
1191 MTK_FUNCTION(0, "GPIO112"),
1192 MTK_FUNCTION(1, "SDA7"),
1193 MTK_FUNCTION(2, "ANT_SEL2"),
1194 MTK_FUNCTION(3, "TP_UTXD1_AO"),
1195 MTK_FUNCTION(4, "IDDIG"),
1196 MTK_FUNCTION(5, "AGPS_SYNC"),
1197 MTK_FUNCTION(6, "KPROW2"),
1198 MTK_FUNCTION(7, "UTXD1")
1199 ),
1200 MTK_PIN(
1201 113, "GPIO113",
1202 MTK_EINT_FUNCTION(0, 113),
1203 DRV_GRP4,
1204 MTK_FUNCTION(0, "GPIO113"),
1205 MTK_FUNCTION(1, "CONN_TOP_CLK"),
1206 MTK_FUNCTION(3, "SCL6"),
1207 MTK_FUNCTION(4, "AUXIF_CLK0"),
1208 MTK_FUNCTION(6, "TP_UCTS1_AO")
1209 ),
1210 MTK_PIN(
1211 114, "GPIO114",
1212 MTK_EINT_FUNCTION(0, 114),
1213 DRV_GRP4,
1214 MTK_FUNCTION(0, "GPIO114"),
1215 MTK_FUNCTION(1, "CONN_TOP_DATA"),
1216 MTK_FUNCTION(3, "SDA6"),
1217 MTK_FUNCTION(4, "AUXIF_ST0"),
1218 MTK_FUNCTION(6, "TP_URTS1_AO")
1219 ),
1220 MTK_PIN(
1221 115, "GPIO115",
1222 MTK_EINT_FUNCTION(0, 115),
1223 DRV_GRP4,
1224 MTK_FUNCTION(0, "GPIO115"),
1225 MTK_FUNCTION(1, "CONN_BT_CLK"),
1226 MTK_FUNCTION(2, "UTXD1"),
1227 MTK_FUNCTION(3, "PTA_TXD"),
1228 MTK_FUNCTION(4, "AUXIF_CLK1"),
1229 MTK_FUNCTION(5, "DAP_MD32_SWD"),
1230 MTK_FUNCTION(6, "TP_UTXD1_AO")
1231 ),
1232 MTK_PIN(
1233 116, "GPIO116",
1234 MTK_EINT_FUNCTION(0, 116),
1235 DRV_GRP4,
1236 MTK_FUNCTION(0, "GPIO116"),
1237 MTK_FUNCTION(1, "CONN_BT_DATA"),
1238 MTK_FUNCTION(2, "IPU_JTAG_TRST"),
1239 MTK_FUNCTION(4, "AUXIF_ST1"),
1240 MTK_FUNCTION(5, "DAP_MD32_SWCK"),
1241 MTK_FUNCTION(6, "TP_URXD2_AO"),
1242 MTK_FUNCTION(7, "DBG_MON_A0")
1243 ),
1244 MTK_PIN(
1245 117, "GPIO117",
1246 MTK_EINT_FUNCTION(0, 117),
1247 DRV_GRP4,
1248 MTK_FUNCTION(0, "GPIO117"),
1249 MTK_FUNCTION(1, "CONN_WF_HB0"),
1250 MTK_FUNCTION(2, "IPU_JTAG_TDO"),
1251 MTK_FUNCTION(6, "TP_UTXD2_AO"),
1252 MTK_FUNCTION(7, "DBG_MON_A4")
1253 ),
1254 MTK_PIN(
1255 118, "GPIO118",
1256 MTK_EINT_FUNCTION(0, 118),
1257 DRV_GRP4,
1258 MTK_FUNCTION(0, "GPIO118"),
1259 MTK_FUNCTION(1, "CONN_WF_HB1"),
1260 MTK_FUNCTION(2, "IPU_JTAG_TDI"),
1261 MTK_FUNCTION(5, "SSPM_URXD_AO"),
1262 MTK_FUNCTION(6, "TP_UCTS2_AO"),
1263 MTK_FUNCTION(7, "DBG_MON_A5")
1264 ),
1265 MTK_PIN(
1266 119, "GPIO119",
1267 MTK_EINT_FUNCTION(0, 119),
1268 DRV_GRP4,
1269 MTK_FUNCTION(0, "GPIO119"),
1270 MTK_FUNCTION(1, "CONN_WF_HB2"),
1271 MTK_FUNCTION(2, "IPU_JTAG_TCK"),
1272 MTK_FUNCTION(5, "SSPM_UTXD_AO"),
1273 MTK_FUNCTION(6, "TP_URTS2_AO")
1274 ),
1275 MTK_PIN(
1276 120, "GPIO120",
1277 MTK_EINT_FUNCTION(0, 120),
1278 DRV_GRP4,
1279 MTK_FUNCTION(0, "GPIO120"),
1280 MTK_FUNCTION(1, "CONN_WB_PTA"),
1281 MTK_FUNCTION(2, "IPU_JTAG_TMS"),
1282 MTK_FUNCTION(5, "CCU_URXD_AO")
1283 ),
1284 MTK_PIN(
1285 121, "GPIO121",
1286 MTK_EINT_FUNCTION(0, 121),
1287 DRV_GRP4,
1288 MTK_FUNCTION(0, "GPIO121"),
1289 MTK_FUNCTION(1, "CONN_HRST_B"),
1290 MTK_FUNCTION(2, "URXD1"),
1291 MTK_FUNCTION(3, "PTA_RXD"),
1292 MTK_FUNCTION(5, "CCU_UTXD_AO"),
1293 MTK_FUNCTION(6, "TP_URXD1_AO")
1294 ),
1295 MTK_PIN(
1296 122, "GPIO122",
1297 MTK_EINT_FUNCTION(0, 122),
1298 DRV_GRP4,
1299 MTK_FUNCTION(0, "GPIO122"),
1300 MTK_FUNCTION(1, "MSDC0_CMD"),
1301 MTK_FUNCTION(2, "SSPM_URXD2_AO"),
1302 MTK_FUNCTION(3, "ANT_SEL1"),
1303 MTK_FUNCTION(7, "DBG_MON_A12")
1304 ),
1305 MTK_PIN(
1306 123, "GPIO123",
1307 MTK_EINT_FUNCTION(0, 123),
1308 DRV_GRP4,
1309 MTK_FUNCTION(0, "GPIO123"),
1310 MTK_FUNCTION(1, "MSDC0_DAT0"),
1311 MTK_FUNCTION(3, "ANT_SEL0"),
1312 MTK_FUNCTION(7, "DBG_MON_A13")
1313 ),
1314 MTK_PIN(
1315 124, "GPIO124",
1316 MTK_EINT_FUNCTION(0, 124),
1317 DRV_GRP4,
1318 MTK_FUNCTION(0, "GPIO124"),
1319 MTK_FUNCTION(1, "MSDC0_CLK"),
1320 MTK_FUNCTION(7, "DBG_MON_A14")
1321 ),
1322 MTK_PIN(
1323 125, "GPIO125",
1324 MTK_EINT_FUNCTION(0, 125),
1325 DRV_GRP4,
1326 MTK_FUNCTION(0, "GPIO125"),
1327 MTK_FUNCTION(1, "MSDC0_DAT2"),
1328 MTK_FUNCTION(3, "MRG_CLK"),
1329 MTK_FUNCTION(7, "DBG_MON_A15")
1330 ),
1331 MTK_PIN(
1332 126, "GPIO126",
1333 MTK_EINT_FUNCTION(0, 126),
1334 DRV_GRP4,
1335 MTK_FUNCTION(0, "GPIO126"),
1336 MTK_FUNCTION(1, "MSDC0_DAT4"),
1337 MTK_FUNCTION(3, "ANT_SEL5"),
1338 MTK_FUNCTION(6, "UFS_MPHY_SCL"),
1339 MTK_FUNCTION(7, "DBG_MON_A16")
1340 ),
1341 MTK_PIN(
1342 127, "GPIO127",
1343 MTK_EINT_FUNCTION(0, 127),
1344 DRV_GRP4,
1345 MTK_FUNCTION(0, "GPIO127"),
1346 MTK_FUNCTION(1, "MSDC0_DAT6"),
1347 MTK_FUNCTION(3, "ANT_SEL4"),
1348 MTK_FUNCTION(6, "UFS_MPHY_SDA"),
1349 MTK_FUNCTION(7, "DBG_MON_A17")
1350 ),
1351 MTK_PIN(
1352 128, "GPIO128",
1353 MTK_EINT_FUNCTION(0, 128),
1354 DRV_GRP4,
1355 MTK_FUNCTION(0, "GPIO128"),
1356 MTK_FUNCTION(1, "MSDC0_DAT1"),
1357 MTK_FUNCTION(3, "ANT_SEL2"),
1358 MTK_FUNCTION(6, "UFS_UNIPRO_SDA"),
1359 MTK_FUNCTION(7, "DBG_MON_A18")
1360 ),
1361 MTK_PIN(
1362 129, "GPIO129",
1363 MTK_EINT_FUNCTION(0, 129),
1364 DRV_GRP4,
1365 MTK_FUNCTION(0, "GPIO129"),
1366 MTK_FUNCTION(1, "MSDC0_DAT5"),
1367 MTK_FUNCTION(3, "ANT_SEL3"),
1368 MTK_FUNCTION(6, "UFS_UNIPRO_SCL"),
1369 MTK_FUNCTION(7, "DBG_MON_A23")
1370 ),
1371 MTK_PIN(
1372 130, "GPIO130",
1373 MTK_EINT_FUNCTION(0, 130),
1374 DRV_GRP4,
1375 MTK_FUNCTION(0, "GPIO130"),
1376 MTK_FUNCTION(1, "MSDC0_DAT7"),
1377 MTK_FUNCTION(3, "MRG_DO"),
1378 MTK_FUNCTION(7, "DBG_MON_A24")
1379 ),
1380 MTK_PIN(
1381 131, "GPIO131",
1382 MTK_EINT_FUNCTION(0, 131),
1383 DRV_GRP4,
1384 MTK_FUNCTION(0, "GPIO131"),
1385 MTK_FUNCTION(1, "MSDC0_DSL"),
1386 MTK_FUNCTION(3, "MRG_SYNC"),
1387 MTK_FUNCTION(7, "DBG_MON_A25")
1388 ),
1389 MTK_PIN(
1390 132, "GPIO132",
1391 MTK_EINT_FUNCTION(0, 132),
1392 DRV_GRP4,
1393 MTK_FUNCTION(0, "GPIO132"),
1394 MTK_FUNCTION(1, "MSDC0_DAT3"),
1395 MTK_FUNCTION(3, "MRG_DI"),
1396 MTK_FUNCTION(7, "DBG_MON_A26")
1397 ),
1398 MTK_PIN(
1399 133, "GPIO133",
1400 MTK_EINT_FUNCTION(0, 133),
1401 DRV_GRP4,
1402 MTK_FUNCTION(0, "GPIO133"),
1403 MTK_FUNCTION(1, "MSDC0_RSTB"),
1404 MTK_FUNCTION(3, "AGPS_SYNC"),
1405 MTK_FUNCTION(7, "DBG_MON_A27")
1406 ),
1407 MTK_PIN(
1408 134, "GPIO134",
1409 MTK_EINT_FUNCTION(0, 134),
1410 DRV_GRP4,
1411 MTK_FUNCTION(0, "GPIO134"),
1412 MTK_FUNCTION(1, "RTC32K_CK")
1413 ),
1414 MTK_PIN(
1415 135, "GPIO135",
1416 MTK_EINT_FUNCTION(0, 135),
1417 DRV_GRP4,
1418 MTK_FUNCTION(0, "GPIO135"),
1419 MTK_FUNCTION(1, "WATCHDOG")
1420 ),
1421 MTK_PIN(
1422 136, "GPIO136",
1423 MTK_EINT_FUNCTION(0, 136),
1424 DRV_GRP4,
1425 MTK_FUNCTION(0, "GPIO136"),
1426 MTK_FUNCTION(1, "AUD_CLK_MOSI"),
1427 MTK_FUNCTION(2, "AUD_CLK_MISO"),
1428 MTK_FUNCTION(3, "I2S1_MCK"),
1429 MTK_FUNCTION(6, "UFS_UNIPRO_SCL")
1430 ),
1431 MTK_PIN(
1432 137, "GPIO137",
1433 MTK_EINT_FUNCTION(0, 137),
1434 DRV_GRP4,
1435 MTK_FUNCTION(0, "GPIO137"),
1436 MTK_FUNCTION(1, "AUD_SYNC_MOSI"),
1437 MTK_FUNCTION(2, "AUD_SYNC_MISO"),
1438 MTK_FUNCTION(3, "I2S1_BCK")
1439 ),
1440 MTK_PIN(
1441 138, "GPIO138",
1442 MTK_EINT_FUNCTION(0, 138),
1443 DRV_GRP4,
1444 MTK_FUNCTION(0, "GPIO138"),
1445 MTK_FUNCTION(1, "AUD_DAT_MOSI0"),
1446 MTK_FUNCTION(2, "AUD_DAT_MISO0"),
1447 MTK_FUNCTION(3, "I2S1_LRCK"),
1448 MTK_FUNCTION(7, "DBG_MON_B24")
1449 ),
1450 MTK_PIN(
1451 139, "GPIO139",
1452 MTK_EINT_FUNCTION(0, 139),
1453 DRV_GRP4,
1454 MTK_FUNCTION(0, "GPIO139"),
1455 MTK_FUNCTION(1, "AUD_DAT_MOSI1"),
1456 MTK_FUNCTION(2, "AUD_DAT_MISO1"),
1457 MTK_FUNCTION(3, "I2S1_DO"),
1458 MTK_FUNCTION(6, "UFS_MPHY_SDA")
1459 ),
1460 MTK_PIN(
1461 140, "GPIO140",
1462 MTK_EINT_FUNCTION(0, 140),
1463 DRV_GRP4,
1464 MTK_FUNCTION(0, "GPIO140"),
1465 MTK_FUNCTION(1, "AUD_CLK_MISO"),
1466 MTK_FUNCTION(2, "AUD_CLK_MOSI"),
1467 MTK_FUNCTION(3, "I2S0_MCK"),
1468 MTK_FUNCTION(6, "UFS_UNIPRO_SDA")
1469 ),
1470 MTK_PIN(
1471 141, "GPIO141",
1472 MTK_EINT_FUNCTION(0, 141),
1473 DRV_GRP4,
1474 MTK_FUNCTION(0, "GPIO141"),
1475 MTK_FUNCTION(1, "AUD_SYNC_MISO"),
1476 MTK_FUNCTION(2, "AUD_SYNC_MOSI"),
1477 MTK_FUNCTION(3, "I2S0_BCK")
1478 ),
1479 MTK_PIN(
1480 142, "GPIO142",
1481 MTK_EINT_FUNCTION(0, 142),
1482 DRV_GRP4,
1483 MTK_FUNCTION(0, "GPIO142"),
1484 MTK_FUNCTION(1, "AUD_DAT_MISO0"),
1485 MTK_FUNCTION(2, "AUD_DAT_MOSI0"),
1486 MTK_FUNCTION(3, "I2S0_LRCK"),
1487 MTK_FUNCTION(4, "VOW_DAT_MISO"),
1488 MTK_FUNCTION(7, "DBG_MON_B25")
1489 ),
1490 MTK_PIN(
1491 143, "GPIO143",
1492 MTK_EINT_FUNCTION(0, 143),
1493 DRV_GRP4,
1494 MTK_FUNCTION(0, "GPIO143"),
1495 MTK_FUNCTION(1, "AUD_DAT_MISO1"),
1496 MTK_FUNCTION(2, "AUD_DAT_MOSI1"),
1497 MTK_FUNCTION(3, "I2S0_DI"),
1498 MTK_FUNCTION(4, "VOW_CLK_MISO"),
1499 MTK_FUNCTION(6, "UFS_MPHY_SCL"),
1500 MTK_FUNCTION(7, "DBG_MON_B26")
1501 ),
1502 MTK_PIN(
1503 144, "GPIO144",
1504 MTK_EINT_FUNCTION(0, 144),
1505 DRV_GRP4,
1506 MTK_FUNCTION(0, "GPIO144"),
1507 MTK_FUNCTION(1, "PWRAP_SPI0_MI"),
1508 MTK_FUNCTION(2, "PWRAP_SPI0_MO")
1509 ),
1510 MTK_PIN(
1511 145, "GPIO145",
1512 MTK_EINT_FUNCTION(0, 145),
1513 DRV_GRP4,
1514 MTK_FUNCTION(0, "GPIO145"),
1515 MTK_FUNCTION(1, "PWRAP_SPI0_CSN")
1516 ),
1517 MTK_PIN(
1518 146, "GPIO146",
1519 MTK_EINT_FUNCTION(0, 146),
1520 DRV_GRP4,
1521 MTK_FUNCTION(0, "GPIO146"),
1522 MTK_FUNCTION(1, "PWRAP_SPI0_MO"),
1523 MTK_FUNCTION(2, "PWRAP_SPI0_MI")
1524 ),
1525 MTK_PIN(
1526 147, "GPIO147",
1527 MTK_EINT_FUNCTION(0, 147),
1528 DRV_GRP4,
1529 MTK_FUNCTION(0, "GPIO147"),
1530 MTK_FUNCTION(1, "PWRAP_SPI0_CK")
1531 ),
1532 MTK_PIN(
1533 148, "GPIO148",
1534 MTK_EINT_FUNCTION(0, 148),
1535 DRV_GRP4,
1536 MTK_FUNCTION(0, "GPIO148"),
1537 MTK_FUNCTION(1, "SRCLKENA0")
1538 ),
1539 MTK_PIN(
1540 149, "GPIO149",
1541 MTK_EINT_FUNCTION(0, 149),
1542 DRV_GRP4,
1543 MTK_FUNCTION(0, "GPIO149"),
1544 MTK_FUNCTION(1, "SRCLKENA1")
1545 ),
1546 MTK_PIN(
1547 150, "GPIO150",
1548 MTK_EINT_FUNCTION(0, 150),
1549 DRV_GRP4,
1550 MTK_FUNCTION(0, "GPIO150"),
1551 MTK_FUNCTION(1, "PWM_A"),
1552 MTK_FUNCTION(2, "CMFLASH"),
1553 MTK_FUNCTION(3, "CLKM0"),
1554 MTK_FUNCTION(7, "DBG_MON_B30")
1555 ),
1556 MTK_PIN(
1557 151, "GPIO151",
1558 MTK_EINT_FUNCTION(0, 151),
1559 DRV_GRP4,
1560 MTK_FUNCTION(0, "GPIO151"),
1561 MTK_FUNCTION(1, "PWM_B"),
1562 MTK_FUNCTION(2, "CMVREF0"),
1563 MTK_FUNCTION(3, "CLKM1"),
1564 MTK_FUNCTION(7, "DBG_MON_B20")
1565 ),
1566 MTK_PIN(
1567 152, "GPIO152",
1568 MTK_EINT_FUNCTION(0, 152),
1569 DRV_GRP4,
1570 MTK_FUNCTION(0, "GPIO152"),
1571 MTK_FUNCTION(1, "PWM_C"),
1572 MTK_FUNCTION(2, "CMFLASH"),
1573 MTK_FUNCTION(3, "CLKM2"),
1574 MTK_FUNCTION(7, "DBG_MON_B21")
1575 ),
1576 MTK_PIN(
1577 153, "GPIO153",
1578 MTK_EINT_FUNCTION(0, 153),
1579 DRV_GRP4,
1580 MTK_FUNCTION(0, "GPIO153"),
1581 MTK_FUNCTION(1, "PWM_A"),
1582 MTK_FUNCTION(2, "CMVREF0"),
1583 MTK_FUNCTION(3, "CLKM3"),
1584 MTK_FUNCTION(7, "DBG_MON_B22")
1585 ),
1586 MTK_PIN(
1587 154, "GPIO154",
1588 MTK_EINT_FUNCTION(0, 154),
1589 DRV_GRP4,
1590 MTK_FUNCTION(0, "GPIO154"),
1591 MTK_FUNCTION(1, "SCP_VREQ_VAO"),
1592 MTK_FUNCTION(2, "DVFSRC_EXT_REQ"),
1593 MTK_FUNCTION(7, "DBG_MON_B18")
1594 ),
1595 MTK_PIN(
1596 155, "GPIO155",
1597 MTK_EINT_FUNCTION(0, 155),
1598 DRV_GRP4,
1599 MTK_FUNCTION(0, "GPIO155"),
1600 MTK_FUNCTION(1, "ANT_SEL0"),
1601 MTK_FUNCTION(2, "DVFSRC_EXT_REQ"),
1602 MTK_FUNCTION(3, "CMVREF1"),
1603 MTK_FUNCTION(7, "SCP_JTAG_TDI")
1604 ),
1605 MTK_PIN(
1606 156, "GPIO156",
1607 MTK_EINT_FUNCTION(0, 156),
1608 DRV_GRP4,
1609 MTK_FUNCTION(0, "GPIO156"),
1610 MTK_FUNCTION(1, "ANT_SEL1"),
1611 MTK_FUNCTION(2, "SRCLKENAI0"),
1612 MTK_FUNCTION(3, "SCL6"),
1613 MTK_FUNCTION(4, "KPCOL2"),
1614 MTK_FUNCTION(5, "IDDIG"),
1615 MTK_FUNCTION(7, "SCP_JTAG_TCK")
1616 ),
1617 MTK_PIN(
1618 157, "GPIO157",
1619 MTK_EINT_FUNCTION(0, 157),
1620 DRV_GRP4,
1621 MTK_FUNCTION(0, "GPIO157"),
1622 MTK_FUNCTION(1, "ANT_SEL2"),
1623 MTK_FUNCTION(2, "SRCLKENAI1"),
1624 MTK_FUNCTION(3, "SDA6"),
1625 MTK_FUNCTION(4, "KPROW2"),
1626 MTK_FUNCTION(5, "USB_DRVVBUS"),
1627 MTK_FUNCTION(7, "SCP_JTAG_TRSTN")
1628 ),
1629 MTK_PIN(
1630 158, "GPIO158",
1631 MTK_EINT_FUNCTION(0, 158),
1632 DRV_GRP4,
1633 MTK_FUNCTION(0, "GPIO158"),
1634 MTK_FUNCTION(1, "ANT_SEL3")
1635 ),
1636 MTK_PIN(
1637 159, "GPIO159",
1638 MTK_EINT_FUNCTION(0, 159),
1639 DRV_GRP4,
1640 MTK_FUNCTION(0, "GPIO159"),
1641 MTK_FUNCTION(1, "ANT_SEL4")
1642 ),
1643 MTK_PIN(
1644 160, "GPIO160",
1645 MTK_EINT_FUNCTION(0, 160),
1646 DRV_GRP4,
1647 MTK_FUNCTION(0, "GPIO160"),
1648 MTK_FUNCTION(1, "ANT_SEL5")
1649 ),
1650 MTK_PIN(
1651 161, "GPIO161",
1652 MTK_EINT_FUNCTION(0, 161),
1653 DRV_GRP4,
1654 MTK_FUNCTION(0, "GPIO161"),
1655 MTK_FUNCTION(1, "SPI1_A_MI"),
1656 MTK_FUNCTION(2, "SCP_SPI1_MI"),
1657 MTK_FUNCTION(3, "IDDIG"),
1658 MTK_FUNCTION(4, "ANT_SEL6"),
1659 MTK_FUNCTION(5, "KPCOL2"),
1660 MTK_FUNCTION(6, "PTA_RXD"),
1661 MTK_FUNCTION(7, "DBG_MON_B19")
1662 ),
1663 MTK_PIN(
1664 162, "GPIO162",
1665 MTK_EINT_FUNCTION(0, 162),
1666 DRV_GRP4,
1667 MTK_FUNCTION(0, "GPIO162"),
1668 MTK_FUNCTION(1, "SPI1_A_CSB"),
1669 MTK_FUNCTION(2, "SCP_SPI1_CS"),
1670 MTK_FUNCTION(3, "USB_DRVVBUS"),
1671 MTK_FUNCTION(4, "ANT_SEL5"),
1672 MTK_FUNCTION(5, "KPROW2"),
1673 MTK_FUNCTION(6, "PTA_TXD")
1674 ),
1675 MTK_PIN(
1676 163, "GPIO163",
1677 MTK_EINT_FUNCTION(0, 163),
1678 DRV_GRP4,
1679 MTK_FUNCTION(0, "GPIO163"),
1680 MTK_FUNCTION(1, "SPI1_A_MO"),
1681 MTK_FUNCTION(2, "SCP_SPI1_MO"),
1682 MTK_FUNCTION(3, "SDA1"),
1683 MTK_FUNCTION(4, "ANT_SEL4"),
1684 MTK_FUNCTION(5, "CMMCLK2"),
1685 MTK_FUNCTION(6, "DMIC_CLK")
1686 ),
1687 MTK_PIN(
1688 164, "GPIO164",
1689 MTK_EINT_FUNCTION(0, 164),
1690 DRV_GRP4,
1691 MTK_FUNCTION(0, "GPIO164"),
1692 MTK_FUNCTION(1, "SPI1_A_CLK"),
1693 MTK_FUNCTION(2, "SCP_SPI1_CK"),
1694 MTK_FUNCTION(3, "SCL1"),
1695 MTK_FUNCTION(4, "ANT_SEL3"),
1696 MTK_FUNCTION(5, "CMMCLK3"),
1697 MTK_FUNCTION(6, "DMIC_DAT")
1698 ),
1699 MTK_PIN(
1700 165, "GPIO165",
1701 MTK_EINT_FUNCTION(0, 165),
1702 DRV_GRP4,
1703 MTK_FUNCTION(0, "GPIO165"),
1704 MTK_FUNCTION(1, "PWM_B"),
1705 MTK_FUNCTION(2, "CMMCLK2"),
1706 MTK_FUNCTION(3, "SCP_VREQ_VAO"),
1707 MTK_FUNCTION(6, "TDM_MCK_2ND"),
1708 MTK_FUNCTION(7, "SCP_JTAG_TDO")
1709 ),
1710 MTK_PIN(
1711 166, "GPIO166",
1712 MTK_EINT_FUNCTION(0, 166),
1713 DRV_GRP4,
1714 MTK_FUNCTION(0, "GPIO166"),
1715 MTK_FUNCTION(1, "ANT_SEL6")
1716 ),
1717 MTK_PIN(
1718 167, "GPIO167",
1719 MTK_EINT_FUNCTION(0, 167),
1720 DRV_GRP4,
1721 MTK_FUNCTION(0, "GPIO167"),
1722 MTK_FUNCTION(1, "RFIC0_BSI_EN"),
1723 MTK_FUNCTION(2, "SPM_BSI_EN")
1724 ),
1725 MTK_PIN(
1726 168, "GPIO168",
1727 MTK_EINT_FUNCTION(0, 168),
1728 DRV_GRP4,
1729 MTK_FUNCTION(0, "GPIO168"),
1730 MTK_FUNCTION(1, "RFIC0_BSI_CK"),
1731 MTK_FUNCTION(2, "SPM_BSI_CK")
1732 ),
1733 MTK_PIN(
1734 169, "GPIO169",
1735 MTK_EINT_FUNCTION(0, 169),
1736 DRV_GRP4,
1737 MTK_FUNCTION(0, "GPIO169"),
1738 MTK_FUNCTION(1, "PWM_C"),
1739 MTK_FUNCTION(2, "CMMCLK3"),
1740 MTK_FUNCTION(3, "CMVREF1"),
1741 MTK_FUNCTION(4, "ANT_SEL7"),
1742 MTK_FUNCTION(5, "AGPS_SYNC"),
1743 MTK_FUNCTION(6, "TDM_BCK_2ND"),
1744 MTK_FUNCTION(7, "SCP_JTAG_TMS")
1745 ),
1746 MTK_PIN(
1747 170, "GPIO170",
1748 MTK_EINT_FUNCTION(0, 170),
1749 DRV_GRP4,
1750 MTK_FUNCTION(0, "GPIO170"),
1751 MTK_FUNCTION(1, "I2S1_BCK"),
1752 MTK_FUNCTION(2, "I2S3_BCK"),
1753 MTK_FUNCTION(3, "SCL7"),
1754 MTK_FUNCTION(4, "I2S5_BCK"),
1755 MTK_FUNCTION(5, "EXT_FRAME_SYNC"),
1756 MTK_FUNCTION(6, "TDM_LRCK_2ND"),
1757 MTK_FUNCTION(7, "ANT_SEL3")
1758 ),
1759 MTK_PIN(
1760 171, "GPIO171",
1761 MTK_EINT_FUNCTION(0, 184),
1762 DRV_GRP4,
1763 MTK_FUNCTION(0, "GPIO171"),
1764 MTK_FUNCTION(1, "I2S1_LRCK"),
1765 MTK_FUNCTION(2, "I2S3_LRCK"),
1766 MTK_FUNCTION(3, "SDA7"),
1767 MTK_FUNCTION(4, "I2S5_LRCK"),
1768 MTK_FUNCTION(5, "URXD1"),
1769 MTK_FUNCTION(6, "TDM_DATA0_2ND"),
1770 MTK_FUNCTION(7, "ANT_SEL4")
1771 ),
1772 MTK_PIN(
1773 172, "GPIO172",
1774 MTK_EINT_FUNCTION(0, 185),
1775 DRV_GRP4,
1776 MTK_FUNCTION(0, "GPIO172"),
1777 MTK_FUNCTION(1, "I2S1_DO"),
1778 MTK_FUNCTION(2, "I2S3_DO"),
1779 MTK_FUNCTION(3, "SCL8"),
1780 MTK_FUNCTION(4, "I2S5_DO"),
1781 MTK_FUNCTION(5, "UTXD1"),
1782 MTK_FUNCTION(6, "TDM_DATA1_2ND"),
1783 MTK_FUNCTION(7, "ANT_SEL5")
1784 ),
1785 MTK_PIN(
1786 173, "GPIO173",
1787 MTK_EINT_FUNCTION(0, 186),
1788 DRV_GRP4,
1789 MTK_FUNCTION(0, "GPIO173"),
1790 MTK_FUNCTION(1, "I2S1_MCK"),
1791 MTK_FUNCTION(2, "I2S3_MCK"),
1792 MTK_FUNCTION(3, "SDA8"),
1793 MTK_FUNCTION(4, "I2S5_MCK"),
1794 MTK_FUNCTION(5, "UCTS0"),
1795 MTK_FUNCTION(6, "TDM_DATA2_2ND"),
1796 MTK_FUNCTION(7, "ANT_SEL6")
1797 ),
1798 MTK_PIN(
1799 174, "GPIO174",
1800 MTK_EINT_FUNCTION(0, 187),
1801 DRV_GRP4,
1802 MTK_FUNCTION(0, "GPIO174"),
1803 MTK_FUNCTION(1, "I2S2_DI"),
1804 MTK_FUNCTION(2, "I2S0_DI"),
1805 MTK_FUNCTION(3, "DVFSRC_EXT_REQ"),
1806 MTK_FUNCTION(4, "I2S2_DI2"),
1807 MTK_FUNCTION(5, "URTS0"),
1808 MTK_FUNCTION(6, "TDM_DATA3_2ND"),
1809 MTK_FUNCTION(7, "ANT_SEL7")
1810 ),
1811 MTK_PIN(
1812 175, "GPIO175",
1813 MTK_EINT_FUNCTION(0, 188),
1814 DRV_GRP4,
1815 MTK_FUNCTION(0, "GPIO175"),
1816 MTK_FUNCTION(1, "ANT_SEL7")
1817 ),
1818 MTK_PIN(
1819 176, "GPIO176",
1820 MTK_EINT_FUNCTION(0, 189),
1821 DRV_GRP4,
1822 MTK_FUNCTION(0, "GPIO176")
1823 ),
1824 MTK_PIN(
1825 177, "GPIO177",
1826 MTK_EINT_FUNCTION(0, 190),
1827 DRV_GRP4,
1828 MTK_FUNCTION(0, "GPIO177")
1829 ),
1830 MTK_PIN(
1831 178, "GPIO178",
1832 MTK_EINT_FUNCTION(0, 191),
1833 DRV_GRP4,
1834 MTK_FUNCTION(0, "GPIO178")
1835 ),
1836 MTK_PIN(
1837 179, "GPIO179",
1838 MTK_EINT_FUNCTION(0, 192),
1839 DRV_GRP4,
1840 MTK_FUNCTION(0, "GPIO179")
1841 ),
1842 MTK_PIN(
1843 180, "GPIO180",
1844 MTK_EINT_FUNCTION(0, 171),
1845 DRV_GRP4,
1846 MTK_FUNCTION(0, "GPIO180")
1847 ),
1848 MTK_PIN(
1849 181, "GPIO181",
1850 MTK_EINT_FUNCTION(0, 172),
1851 DRV_GRP4,
1852 MTK_FUNCTION(0, "GPIO181")
1853 ),
1854 MTK_PIN(
1855 182, "GPIO182",
1856 MTK_EINT_FUNCTION(0, 173),
1857 DRV_GRP4,
1858 MTK_FUNCTION(0, "GPIO182")
1859 ),
1860 MTK_PIN(
1861 183, "GPIO183",
1862 MTK_EINT_FUNCTION(0, 174),
1863 DRV_GRP4,
1864 MTK_FUNCTION(0, "GPIO183")
1865 ),
1866 MTK_PIN(
1867 184, "GPIO184",
1868 MTK_EINT_FUNCTION(0, 175),
1869 DRV_GRP4,
1870 MTK_FUNCTION(0, "GPIO184")
1871 ),
1872 MTK_PIN(
1873 185, "GPIO185",
1874 MTK_EINT_FUNCTION(0, 177),
1875 DRV_GRP4,
1876 MTK_FUNCTION(0, "GPIO185")
1877 ),
1878 MTK_PIN(
1879 186, "GPIO186",
1880 MTK_EINT_FUNCTION(0, 178),
1881 DRV_GRP4,
1882 MTK_FUNCTION(0, "GPIO186")
1883 ),
1884 MTK_PIN(
1885 187, "GPIO187",
1886 MTK_EINT_FUNCTION(0, 179),
1887 DRV_GRP4,
1888 MTK_FUNCTION(0, "GPIO187")
1889 ),
1890 MTK_PIN(
1891 188, "GPIO188",
1892 MTK_EINT_FUNCTION(0, 180),
1893 DRV_GRP4,
1894 MTK_FUNCTION(0, "GPIO188")
1895 ),
1896 MTK_PIN(
1897 189, "GPIO189",
1898 MTK_EINT_FUNCTION(0, 181),
1899 DRV_GRP4,
1900 MTK_FUNCTION(0, "GPIO189")
1901 ),
1902 MTK_PIN(
1903 190, "GPIO190",
1904 MTK_EINT_FUNCTION(0, 182),
1905 DRV_GRP4,
1906 MTK_FUNCTION(0, "GPIO190")
1907 ),
1908 MTK_PIN(
1909 191, "GPIO191",
1910 MTK_EINT_FUNCTION(0, 183),
1911 DRV_GRP4,
1912 MTK_FUNCTION(0, "GPIO191")
1913 ),
1914};
1915
1916#endif /* __PINCTRL_MTK_MT8183_H */
diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c
new file mode 100644
index 000000000000..9f4224f9d605
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
@@ -0,0 +1,906 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * MediaTek Pinctrl Paris Driver, which implement the vendor per-pin
4 * bindings for MediaTek SoC.
5 *
6 * Copyright (C) 2018 MediaTek Inc.
7 * Author: Sean Wang <sean.wang@mediatek.com>
8 * Zhiyong Tao <zhiyong.tao@mediatek.com>
9 * Hongzhou.Yang <hongzhou.yang@mediatek.com>
10 */
11
12#include <dt-bindings/pinctrl/mt65xx.h>
13#include "pinctrl-paris.h"
14
15#define PINCTRL_PINCTRL_DEV KBUILD_MODNAME
16
17/* Custom pinconf parameters */
18#define MTK_PIN_CONFIG_TDSEL (PIN_CONFIG_END + 1)
19#define MTK_PIN_CONFIG_RDSEL (PIN_CONFIG_END + 2)
20#define MTK_PIN_CONFIG_PU_ADV (PIN_CONFIG_END + 3)
21#define MTK_PIN_CONFIG_PD_ADV (PIN_CONFIG_END + 4)
22
23static const struct pinconf_generic_params mtk_custom_bindings[] = {
24 {"mediatek,tdsel", MTK_PIN_CONFIG_TDSEL, 0},
25 {"mediatek,rdsel", MTK_PIN_CONFIG_RDSEL, 0},
26 {"mediatek,pull-up-adv", MTK_PIN_CONFIG_PU_ADV, 1},
27 {"mediatek,pull-down-adv", MTK_PIN_CONFIG_PD_ADV, 1},
28};
29
30#ifdef CONFIG_DEBUG_FS
31static const struct pin_config_item mtk_conf_items[] = {
32 PCONFDUMP(MTK_PIN_CONFIG_TDSEL, "tdsel", NULL, true),
33 PCONFDUMP(MTK_PIN_CONFIG_RDSEL, "rdsel", NULL, true),
34 PCONFDUMP(MTK_PIN_CONFIG_PU_ADV, "pu-adv", NULL, true),
35 PCONFDUMP(MTK_PIN_CONFIG_PD_ADV, "pd-adv", NULL, true),
36};
37#endif
38
39static const char * const mtk_gpio_functions[] = {
40 "func0", "func1", "func2", "func3",
41 "func4", "func5", "func6", "func7",
42 "func8", "func9", "func10", "func11",
43 "func12", "func13", "func14", "func15",
44};
45
46static int mtk_pinmux_gpio_request_enable(struct pinctrl_dev *pctldev,
47 struct pinctrl_gpio_range *range,
48 unsigned int pin)
49{
50 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
51 const struct mtk_pin_desc *desc;
52
53 desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
54
55 return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_MODE,
56 hw->soc->gpio_m);
57}
58
59static int mtk_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
60 struct pinctrl_gpio_range *range,
61 unsigned int pin, bool input)
62{
63 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
64 const struct mtk_pin_desc *desc;
65
66 desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
67
68 /* hardware would take 0 as input direction */
69 return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR, !input);
70}
71
72static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
73 unsigned int pin, unsigned long *config)
74{
75 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
76 u32 param = pinconf_to_config_param(*config);
77 int val, val2, err, reg, ret = 1;
78 const struct mtk_pin_desc *desc;
79
80 desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
81
82 switch (param) {
83 case PIN_CONFIG_BIAS_DISABLE:
84 if (hw->soc->bias_disable_get) {
85 err = hw->soc->bias_disable_get(hw, desc, &ret);
86 if (err)
87 return err;
88 } else {
89 return -ENOTSUPP;
90 }
91 break;
92 case PIN_CONFIG_BIAS_PULL_UP:
93 if (hw->soc->bias_get) {
94 err = hw->soc->bias_get(hw, desc, 1, &ret);
95 if (err)
96 return err;
97 } else {
98 return -ENOTSUPP;
99 }
100 break;
101 case PIN_CONFIG_BIAS_PULL_DOWN:
102 if (hw->soc->bias_get) {
103 err = hw->soc->bias_get(hw, desc, 0, &ret);
104 if (err)
105 return err;
106 } else {
107 return -ENOTSUPP;
108 }
109 break;
110 case PIN_CONFIG_SLEW_RATE:
111 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_SR, &val);
112 if (err)
113 return err;
114
115 if (!val)
116 return -EINVAL;
117
118 break;
119 case PIN_CONFIG_INPUT_ENABLE:
120 case PIN_CONFIG_OUTPUT_ENABLE:
121 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &val);
122 if (err)
123 return err;
124
125 /* HW takes input mode as zero; output mode as non-zero */
126 if ((val && param == PIN_CONFIG_INPUT_ENABLE) ||
127 (!val && param == PIN_CONFIG_OUTPUT_ENABLE))
128 return -EINVAL;
129
130 break;
131 case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
132 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &val);
133 if (err)
134 return err;
135
136 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_SMT, &val2);
137 if (err)
138 return err;
139
140 if (val || !val2)
141 return -EINVAL;
142
143 break;
144 case PIN_CONFIG_DRIVE_STRENGTH:
145 if (hw->soc->drive_get) {
146 err = hw->soc->drive_get(hw, desc, &ret);
147 if (err)
148 return err;
149 } else {
150 err = -ENOTSUPP;
151 }
152 break;
153 case MTK_PIN_CONFIG_TDSEL:
154 case MTK_PIN_CONFIG_RDSEL:
155 reg = (param == MTK_PIN_CONFIG_TDSEL) ?
156 PINCTRL_PIN_REG_TDSEL : PINCTRL_PIN_REG_RDSEL;
157
158 err = mtk_hw_get_value(hw, desc, reg, &val);
159 if (err)
160 return err;
161
162 ret = val;
163
164 break;
165 case MTK_PIN_CONFIG_PU_ADV:
166 case MTK_PIN_CONFIG_PD_ADV:
167 if (hw->soc->adv_pull_get) {
168 bool pullup;
169
170 pullup = param == MTK_PIN_CONFIG_PU_ADV;
171 err = hw->soc->adv_pull_get(hw, desc, pullup, &ret);
172 if (err)
173 return err;
174 } else {
175 return -ENOTSUPP;
176 }
177 break;
178 default:
179 return -ENOTSUPP;
180 }
181
182 *config = pinconf_to_config_packed(param, ret);
183
184 return 0;
185}
186
187static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
188 enum pin_config_param param,
189 enum pin_config_param arg)
190{
191 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
192 const struct mtk_pin_desc *desc;
193 int err = 0;
194 u32 reg;
195
196 desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
197
198 switch ((u32)param) {
199 case PIN_CONFIG_BIAS_DISABLE:
200 if (hw->soc->bias_disable_set) {
201 err = hw->soc->bias_disable_set(hw, desc);
202 if (err)
203 return err;
204 } else {
205 return -ENOTSUPP;
206 }
207 break;
208 case PIN_CONFIG_BIAS_PULL_UP:
209 if (hw->soc->bias_set) {
210 err = hw->soc->bias_set(hw, desc, 1);
211 if (err)
212 return err;
213 } else {
214 return -ENOTSUPP;
215 }
216 break;
217 case PIN_CONFIG_BIAS_PULL_DOWN:
218 if (hw->soc->bias_set) {
219 err = hw->soc->bias_set(hw, desc, 0);
220 if (err)
221 return err;
222 } else {
223 return -ENOTSUPP;
224 }
225 break;
226 case PIN_CONFIG_OUTPUT_ENABLE:
227 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_SMT,
228 MTK_DISABLE);
229 if (err)
230 goto err;
231
232 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
233 MTK_OUTPUT);
234 if (err)
235 goto err;
236 break;
237 case PIN_CONFIG_INPUT_ENABLE:
238 if (hw->soc->ies_present) {
239 mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_IES,
240 MTK_ENABLE);
241 }
242
243 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
244 MTK_INPUT);
245 if (err)
246 goto err;
247 break;
248 case PIN_CONFIG_SLEW_RATE:
249 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_SR,
250 arg);
251 if (err)
252 goto err;
253
254 break;
255 case PIN_CONFIG_OUTPUT:
256 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
257 MTK_OUTPUT);
258 if (err)
259 goto err;
260
261 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DO,
262 arg);
263 if (err)
264 goto err;
265 break;
266 case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
267 /* arg = 1: Input mode & SMT enable ;
268 * arg = 0: Output mode & SMT disable
269 */
270 arg = arg ? 2 : 1;
271 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
272 arg & 1);
273 if (err)
274 goto err;
275
276 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_SMT,
277 !!(arg & 2));
278 if (err)
279 goto err;
280 break;
281 case PIN_CONFIG_DRIVE_STRENGTH:
282 if (hw->soc->drive_set) {
283 err = hw->soc->drive_set(hw, desc, arg);
284 if (err)
285 return err;
286 } else {
287 return -ENOTSUPP;
288 }
289 break;
290 case MTK_PIN_CONFIG_TDSEL:
291 case MTK_PIN_CONFIG_RDSEL:
292 reg = (param == MTK_PIN_CONFIG_TDSEL) ?
293 PINCTRL_PIN_REG_TDSEL : PINCTRL_PIN_REG_RDSEL;
294
295 err = mtk_hw_set_value(hw, desc, reg, arg);
296 if (err)
297 goto err;
298 break;
299 case MTK_PIN_CONFIG_PU_ADV:
300 case MTK_PIN_CONFIG_PD_ADV:
301 if (hw->soc->adv_pull_set) {
302 bool pullup;
303
304 pullup = param == MTK_PIN_CONFIG_PU_ADV;
305 err = hw->soc->adv_pull_set(hw, desc, pullup,
306 arg);
307 if (err)
308 return err;
309 } else {
310 return -ENOTSUPP;
311 }
312 break;
313 default:
314 err = -ENOTSUPP;
315 }
316
317err:
318 return err;
319}
320
321static struct mtk_pinctrl_group *
322mtk_pctrl_find_group_by_pin(struct mtk_pinctrl *hw, u32 pin)
323{
324 int i;
325
326 for (i = 0; i < hw->soc->ngrps; i++) {
327 struct mtk_pinctrl_group *grp = hw->groups + i;
328
329 if (grp->pin == pin)
330 return grp;
331 }
332
333 return NULL;
334}
335
336static const struct mtk_func_desc *
337mtk_pctrl_find_function_by_pin(struct mtk_pinctrl *hw, u32 pin_num, u32 fnum)
338{
339 const struct mtk_pin_desc *pin = hw->soc->pins + pin_num;
340 const struct mtk_func_desc *func = pin->funcs;
341
342 while (func && func->name) {
343 if (func->muxval == fnum)
344 return func;
345 func++;
346 }
347
348 return NULL;
349}
350
351static bool mtk_pctrl_is_function_valid(struct mtk_pinctrl *hw, u32 pin_num,
352 u32 fnum)
353{
354 int i;
355
356 for (i = 0; i < hw->soc->npins; i++) {
357 const struct mtk_pin_desc *pin = hw->soc->pins + i;
358
359 if (pin->number == pin_num) {
360 const struct mtk_func_desc *func = pin->funcs;
361
362 while (func && func->name) {
363 if (func->muxval == fnum)
364 return true;
365 func++;
366 }
367
368 break;
369 }
370 }
371
372 return false;
373}
374
375static int mtk_pctrl_dt_node_to_map_func(struct mtk_pinctrl *pctl,
376 u32 pin, u32 fnum,
377 struct mtk_pinctrl_group *grp,
378 struct pinctrl_map **map,
379 unsigned *reserved_maps,
380 unsigned *num_maps)
381{
382 bool ret;
383
384 if (*num_maps == *reserved_maps)
385 return -ENOSPC;
386
387 (*map)[*num_maps].type = PIN_MAP_TYPE_MUX_GROUP;
388 (*map)[*num_maps].data.mux.group = grp->name;
389
390 ret = mtk_pctrl_is_function_valid(pctl, pin, fnum);
391 if (!ret) {
392 dev_err(pctl->dev, "invalid function %d on pin %d .\n",
393 fnum, pin);
394 return -EINVAL;
395 }
396
397 (*map)[*num_maps].data.mux.function = mtk_gpio_functions[fnum];
398 (*num_maps)++;
399
400 return 0;
401}
402
403static int mtk_pctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
404 struct device_node *node,
405 struct pinctrl_map **map,
406 unsigned *reserved_maps,
407 unsigned *num_maps)
408{
409 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
410 int num_pins, num_funcs, maps_per_pin, i, err;
411 struct mtk_pinctrl_group *grp;
412 unsigned int num_configs;
413 bool has_config = false;
414 unsigned long *configs;
415 u32 pinfunc, pin, func;
416 struct property *pins;
417 unsigned reserve = 0;
418
419 pins = of_find_property(node, "pinmux", NULL);
420 if (!pins) {
421 dev_err(hw->dev, "missing pins property in node %s .\n",
422 node->name);
423 return -EINVAL;
424 }
425
426 err = pinconf_generic_parse_dt_config(node, pctldev, &configs,
427 &num_configs);
428 if (err)
429 return err;
430
431 if (num_configs)
432 has_config = true;
433
434 num_pins = pins->length / sizeof(u32);
435 num_funcs = num_pins;
436 maps_per_pin = 0;
437 if (num_funcs)
438 maps_per_pin++;
439 if (has_config && num_pins >= 1)
440 maps_per_pin++;
441
442 if (!num_pins || !maps_per_pin) {
443 err = -EINVAL;
444 goto exit;
445 }
446
447 reserve = num_pins * maps_per_pin;
448
449 err = pinctrl_utils_reserve_map(pctldev, map, reserved_maps, num_maps,
450 reserve);
451 if (err < 0)
452 goto exit;
453
454 for (i = 0; i < num_pins; i++) {
455 err = of_property_read_u32_index(node, "pinmux", i, &pinfunc);
456 if (err)
457 goto exit;
458
459 pin = MTK_GET_PIN_NO(pinfunc);
460 func = MTK_GET_PIN_FUNC(pinfunc);
461
462 if (pin >= hw->soc->npins ||
463 func >= ARRAY_SIZE(mtk_gpio_functions)) {
464 dev_err(hw->dev, "invalid pins value.\n");
465 err = -EINVAL;
466 goto exit;
467 }
468
469 grp = mtk_pctrl_find_group_by_pin(hw, pin);
470 if (!grp) {
471 dev_err(hw->dev, "unable to match pin %d to group\n",
472 pin);
473 err = -EINVAL;
474 goto exit;
475 }
476
477 err = mtk_pctrl_dt_node_to_map_func(hw, pin, func, grp, map,
478 reserved_maps, num_maps);
479 if (err < 0)
480 goto exit;
481
482 if (has_config) {
483 err = pinctrl_utils_add_map_configs(pctldev, map,
484 reserved_maps,
485 num_maps,
486 grp->name,
487 configs,
488 num_configs,
489 PIN_MAP_TYPE_CONFIGS_GROUP);
490 if (err < 0)
491 goto exit;
492 }
493 }
494
495 err = 0;
496
497exit:
498 kfree(configs);
499 return err;
500}
501
502static int mtk_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
503 struct device_node *np_config,
504 struct pinctrl_map **map,
505 unsigned *num_maps)
506{
507 struct device_node *np;
508 unsigned reserved_maps;
509 int ret;
510
511 *map = NULL;
512 *num_maps = 0;
513 reserved_maps = 0;
514
515 for_each_child_of_node(np_config, np) {
516 ret = mtk_pctrl_dt_subnode_to_map(pctldev, np, map,
517 &reserved_maps,
518 num_maps);
519 if (ret < 0) {
520 pinctrl_utils_free_map(pctldev, *map, *num_maps);
521 of_node_put(np);
522 return ret;
523 }
524 }
525
526 return 0;
527}
528
529static int mtk_pctrl_get_groups_count(struct pinctrl_dev *pctldev)
530{
531 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
532
533 return hw->soc->ngrps;
534}
535
536static const char *mtk_pctrl_get_group_name(struct pinctrl_dev *pctldev,
537 unsigned group)
538{
539 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
540
541 return hw->groups[group].name;
542}
543
544static int mtk_pctrl_get_group_pins(struct pinctrl_dev *pctldev,
545 unsigned group, const unsigned **pins,
546 unsigned *num_pins)
547{
548 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
549
550 *pins = (unsigned *)&hw->groups[group].pin;
551 *num_pins = 1;
552
553 return 0;
554}
555
556static const struct pinctrl_ops mtk_pctlops = {
557 .dt_node_to_map = mtk_pctrl_dt_node_to_map,
558 .dt_free_map = pinctrl_utils_free_map,
559 .get_groups_count = mtk_pctrl_get_groups_count,
560 .get_group_name = mtk_pctrl_get_group_name,
561 .get_group_pins = mtk_pctrl_get_group_pins,
562};
563
564static int mtk_pmx_get_funcs_cnt(struct pinctrl_dev *pctldev)
565{
566 return ARRAY_SIZE(mtk_gpio_functions);
567}
568
569static const char *mtk_pmx_get_func_name(struct pinctrl_dev *pctldev,
570 unsigned selector)
571{
572 return mtk_gpio_functions[selector];
573}
574
575static int mtk_pmx_get_func_groups(struct pinctrl_dev *pctldev,
576 unsigned function,
577 const char * const **groups,
578 unsigned * const num_groups)
579{
580 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
581
582 *groups = hw->grp_names;
583 *num_groups = hw->soc->ngrps;
584
585 return 0;
586}
587
588static int mtk_pmx_set_mux(struct pinctrl_dev *pctldev,
589 unsigned function,
590 unsigned group)
591{
592 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
593 struct mtk_pinctrl_group *grp = hw->groups + group;
594 const struct mtk_func_desc *desc_func;
595 const struct mtk_pin_desc *desc;
596 bool ret;
597
598 ret = mtk_pctrl_is_function_valid(hw, grp->pin, function);
599 if (!ret) {
600 dev_err(hw->dev, "invalid function %d on group %d .\n",
601 function, group);
602 return -EINVAL;
603 }
604
605 desc_func = mtk_pctrl_find_function_by_pin(hw, grp->pin, function);
606 if (!desc_func)
607 return -EINVAL;
608
609 desc = (const struct mtk_pin_desc *)&hw->soc->pins[grp->pin];
610 mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_MODE, desc_func->muxval);
611
612 return 0;
613}
614
615static const struct pinmux_ops mtk_pmxops = {
616 .get_functions_count = mtk_pmx_get_funcs_cnt,
617 .get_function_name = mtk_pmx_get_func_name,
618 .get_function_groups = mtk_pmx_get_func_groups,
619 .set_mux = mtk_pmx_set_mux,
620 .gpio_set_direction = mtk_pinmux_gpio_set_direction,
621 .gpio_request_enable = mtk_pinmux_gpio_request_enable,
622};
623
624static int mtk_pconf_group_get(struct pinctrl_dev *pctldev, unsigned group,
625 unsigned long *config)
626{
627 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
628
629 *config = hw->groups[group].config;
630
631 return 0;
632}
633
634static int mtk_pconf_group_set(struct pinctrl_dev *pctldev, unsigned group,
635 unsigned long *configs, unsigned num_configs)
636{
637 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
638 struct mtk_pinctrl_group *grp = &hw->groups[group];
639 int i, ret;
640
641 for (i = 0; i < num_configs; i++) {
642 ret = mtk_pinconf_set(pctldev, grp->pin,
643 pinconf_to_config_param(configs[i]),
644 pinconf_to_config_argument(configs[i]));
645 if (ret < 0)
646 return ret;
647
648 grp->config = configs[i];
649 }
650
651 return 0;
652}
653
654static const struct pinconf_ops mtk_confops = {
655 .pin_config_get = mtk_pinconf_get,
656 .pin_config_group_get = mtk_pconf_group_get,
657 .pin_config_group_set = mtk_pconf_group_set,
658};
659
660static struct pinctrl_desc mtk_desc = {
661 .name = PINCTRL_PINCTRL_DEV,
662 .pctlops = &mtk_pctlops,
663 .pmxops = &mtk_pmxops,
664 .confops = &mtk_confops,
665 .owner = THIS_MODULE,
666};
667
668static int mtk_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)
669{
670 struct mtk_pinctrl *hw = gpiochip_get_data(chip);
671 const struct mtk_pin_desc *desc;
672 int value, err;
673
674 desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
675
676 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &value);
677 if (err)
678 return err;
679
680 return !value;
681}
682
683static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio)
684{
685 struct mtk_pinctrl *hw = gpiochip_get_data(chip);
686 const struct mtk_pin_desc *desc;
687 int value, err;
688
689 desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
690
691 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DI, &value);
692 if (err)
693 return err;
694
695 return !!value;
696}
697
698static void mtk_gpio_set(struct gpio_chip *chip, unsigned int gpio, int value)
699{
700 struct mtk_pinctrl *hw = gpiochip_get_data(chip);
701 const struct mtk_pin_desc *desc;
702
703 desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
704
705 mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DO, !!value);
706}
707
708static int mtk_gpio_direction_input(struct gpio_chip *chip, unsigned int gpio)
709{
710 return pinctrl_gpio_direction_input(chip->base + gpio);
711}
712
713static int mtk_gpio_direction_output(struct gpio_chip *chip, unsigned int gpio,
714 int value)
715{
716 mtk_gpio_set(chip, gpio, value);
717
718 return pinctrl_gpio_direction_output(chip->base + gpio);
719}
720
721static int mtk_gpio_to_irq(struct gpio_chip *chip, unsigned int offset)
722{
723 struct mtk_pinctrl *hw = gpiochip_get_data(chip);
724 const struct mtk_pin_desc *desc;
725
726 if (!hw->eint)
727 return -ENOTSUPP;
728
729 desc = (const struct mtk_pin_desc *)&hw->soc->pins[offset];
730
731 if (desc->eint.eint_n == EINT_NA)
732 return -ENOTSUPP;
733
734 return mtk_eint_find_irq(hw->eint, desc->eint.eint_n);
735}
736
737static int mtk_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
738 unsigned long config)
739{
740 struct mtk_pinctrl *hw = gpiochip_get_data(chip);
741 const struct mtk_pin_desc *desc;
742 u32 debounce;
743
744 desc = (const struct mtk_pin_desc *)&hw->soc->pins[offset];
745
746 if (!hw->eint ||
747 pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE ||
748 desc->eint.eint_n == EINT_NA)
749 return -ENOTSUPP;
750
751 debounce = pinconf_to_config_argument(config);
752
753 return mtk_eint_set_debounce(hw->eint, desc->eint.eint_n, debounce);
754}
755
756static int mtk_build_gpiochip(struct mtk_pinctrl *hw, struct device_node *np)
757{
758 struct gpio_chip *chip = &hw->chip;
759 int ret;
760
761 chip->label = PINCTRL_PINCTRL_DEV;
762 chip->parent = hw->dev;
763 chip->request = gpiochip_generic_request;
764 chip->free = gpiochip_generic_free;
765 chip->get_direction = mtk_gpio_get_direction;
766 chip->direction_input = mtk_gpio_direction_input;
767 chip->direction_output = mtk_gpio_direction_output;
768 chip->get = mtk_gpio_get;
769 chip->set = mtk_gpio_set;
770 chip->to_irq = mtk_gpio_to_irq,
771 chip->set_config = mtk_gpio_set_config,
772 chip->base = -1;
773 chip->ngpio = hw->soc->npins;
774 chip->of_node = np;
775 chip->of_gpio_n_cells = 2;
776
777 ret = gpiochip_add_data(chip, hw);
778 if (ret < 0)
779 return ret;
780
781 return 0;
782}
783
784static int mtk_pctrl_build_state(struct platform_device *pdev)
785{
786 struct mtk_pinctrl *hw = platform_get_drvdata(pdev);
787 int i;
788
789 /* Allocate groups */
790 hw->groups = devm_kmalloc_array(&pdev->dev, hw->soc->ngrps,
791 sizeof(*hw->groups), GFP_KERNEL);
792 if (!hw->groups)
793 return -ENOMEM;
794
795 /* We assume that one pin is one group, use pin name as group name. */
796 hw->grp_names = devm_kmalloc_array(&pdev->dev, hw->soc->ngrps,
797 sizeof(*hw->grp_names), GFP_KERNEL);
798 if (!hw->grp_names)
799 return -ENOMEM;
800
801 for (i = 0; i < hw->soc->npins; i++) {
802 const struct mtk_pin_desc *pin = hw->soc->pins + i;
803 struct mtk_pinctrl_group *group = hw->groups + i;
804
805 group->name = pin->name;
806 group->pin = pin->number;
807
808 hw->grp_names[i] = pin->name;
809 }
810
811 return 0;
812}
813
814int mtk_paris_pinctrl_probe(struct platform_device *pdev,
815 const struct mtk_pin_soc *soc)
816{
817 struct pinctrl_pin_desc *pins;
818 struct mtk_pinctrl *hw;
819 struct resource *res;
820 int err, i;
821
822 hw = devm_kzalloc(&pdev->dev, sizeof(*hw), GFP_KERNEL);
823 if (!hw)
824 return -ENOMEM;
825
826 platform_set_drvdata(pdev, hw);
827 hw->soc = soc;
828 hw->dev = &pdev->dev;
829
830 if (!hw->soc->nbase_names) {
831 dev_err(&pdev->dev,
832 "SoC should be assigned at least one register base\n");
833 return -EINVAL;
834 }
835
836 hw->base = devm_kmalloc_array(&pdev->dev, hw->soc->nbase_names,
837 sizeof(*hw->base), GFP_KERNEL);
838 if (IS_ERR(hw->base))
839 return PTR_ERR(hw->base);
840
841 for (i = 0; i < hw->soc->nbase_names; i++) {
842 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
843 hw->soc->base_names[i]);
844 if (!res) {
845 dev_err(&pdev->dev, "missing IO resource\n");
846 return -ENXIO;
847 }
848
849 hw->base[i] = devm_ioremap_resource(&pdev->dev, res);
850 if (IS_ERR(hw->base[i]))
851 return PTR_ERR(hw->base[i]);
852 }
853
854 hw->nbase = hw->soc->nbase_names;
855
856 err = mtk_pctrl_build_state(pdev);
857 if (err) {
858 dev_err(&pdev->dev, "build state failed: %d\n", err);
859 return -EINVAL;
860 }
861
862 /* Copy from internal struct mtk_pin_desc to register to the core */
863 pins = devm_kmalloc_array(&pdev->dev, hw->soc->npins, sizeof(*pins),
864 GFP_KERNEL);
865 if (IS_ERR(pins))
866 return PTR_ERR(pins);
867
868 for (i = 0; i < hw->soc->npins; i++) {
869 pins[i].number = hw->soc->pins[i].number;
870 pins[i].name = hw->soc->pins[i].name;
871 }
872
873 /* Setup pins descriptions per SoC types */
874 mtk_desc.pins = (const struct pinctrl_pin_desc *)pins;
875 mtk_desc.npins = hw->soc->npins;
876 mtk_desc.num_custom_params = ARRAY_SIZE(mtk_custom_bindings);
877 mtk_desc.custom_params = mtk_custom_bindings;
878#ifdef CONFIG_DEBUG_FS
879 mtk_desc.custom_conf_items = mtk_conf_items;
880#endif
881
882 err = devm_pinctrl_register_and_init(&pdev->dev, &mtk_desc, hw,
883 &hw->pctrl);
884 if (err)
885 return err;
886
887 err = pinctrl_enable(hw->pctrl);
888 if (err)
889 return err;
890
891 err = mtk_build_eint(hw, pdev);
892 if (err)
893 dev_warn(&pdev->dev,
894 "Failed to add EINT, but pinctrl still can work\n");
895
896 /* Build gpiochip should be after pinctrl_enable is done */
897 err = mtk_build_gpiochip(hw, pdev->dev.of_node);
898 if (err) {
899 dev_err(&pdev->dev, "Failed to add gpio_chip\n");
900 return err;
901 }
902
903 platform_set_drvdata(pdev, hw);
904
905 return 0;
906}
diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.h b/drivers/pinctrl/mediatek/pinctrl-paris.h
new file mode 100644
index 000000000000..e4d204e4ce8d
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-paris.h
@@ -0,0 +1,65 @@
1/* 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/gpio.h>
13#include <linux/gpio/driver.h>
14#include <linux/io.h>
15#include <linux/init.h>
16#include <linux/of.h>
17#include <linux/of_platform.h>
18#include <linux/platform_device.h>
19#include <linux/pinctrl/pinctrl.h>
20#include <linux/pinctrl/pinmux.h>
21#include <linux/pinctrl/pinconf.h>
22#include <linux/pinctrl/pinconf-generic.h>
23
24#include "../core.h"
25#include "../pinconf.h"
26#include "../pinctrl-utils.h"
27#include "../pinmux.h"
28#include "mtk-eint.h"
29#include "pinctrl-mtk-common-v2.h"
30
31#define MTK_RANGE(_a) { .range = (_a), .nranges = ARRAY_SIZE(_a), }
32
33#define MTK_EINT_FUNCTION(_eintmux, _eintnum) \
34 { \
35 .eint_m = _eintmux, \
36 .eint_n = _eintnum, \
37 }
38
39#define MTK_FUNCTION(_val, _name) \
40 { \
41 .muxval = _val, \
42 .name = _name, \
43 }
44
45#define MTK_PIN(_number, _name, _eint, _drv_n, ...) { \
46 .number = _number, \
47 .name = _name, \
48 .eint = _eint, \
49 .drv_n = _drv_n, \
50 .funcs = (struct mtk_func_desc[]){ \
51 __VA_ARGS__, { } }, \
52 }
53
54#define PINCTRL_PIN_GROUP(name, id) \
55 { \
56 name, \
57 id##_pins, \
58 ARRAY_SIZE(id##_pins), \
59 id##_funcs, \
60 }
61
62int mtk_paris_pinctrl_probe(struct platform_device *pdev,
63 const struct mtk_pin_soc *soc);
64
65#endif /* __PINCTRL_PARIS_H */