xref: /OK3568_Linux_fs/kernel/drivers/pinctrl/mediatek/pinctrl-mt8167.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (c) 2020 MediaTek Inc.
4*4882a593Smuzhiyun  * Author: Min.Guo <min.guo@mediatek.com>
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #include <dt-bindings/pinctrl/mt65xx.h>
8*4882a593Smuzhiyun #include <linux/of.h>
9*4882a593Smuzhiyun #include <linux/of_device.h>
10*4882a593Smuzhiyun #include <linux/module.h>
11*4882a593Smuzhiyun #include <linux/pinctrl/pinctrl.h>
12*4882a593Smuzhiyun #include <linux/platform_device.h>
13*4882a593Smuzhiyun #include <linux/regmap.h>
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #include "pinctrl-mtk-common.h"
16*4882a593Smuzhiyun #include "pinctrl-mtk-mt8167.h"
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun static const struct mtk_drv_group_desc mt8167_drv_grp[] = {
19*4882a593Smuzhiyun 	/* 0E4E8SR 4/8/12/16 */
20*4882a593Smuzhiyun 	MTK_DRV_GRP(4, 16, 1, 2, 4),
21*4882a593Smuzhiyun 	/* 0E2E4SR  2/4/6/8 */
22*4882a593Smuzhiyun 	MTK_DRV_GRP(2, 8, 1, 2, 2),
23*4882a593Smuzhiyun 	/* E8E4E2  2/4/6/8/10/12/14/16 */
24*4882a593Smuzhiyun 	MTK_DRV_GRP(2, 16, 0, 2, 2)
25*4882a593Smuzhiyun };
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun static const struct mtk_pin_drv_grp mt8167_pin_drv[] = {
28*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(0, 0xd00, 0, 0),
29*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(1, 0xd00, 0, 0),
30*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(2, 0xd00, 0, 0),
31*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(3, 0xd00, 0, 0),
32*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(4, 0xd00, 0, 0),
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(5, 0xd00, 4, 0),
35*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(6, 0xd00, 4, 0),
36*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(7, 0xd00, 4, 0),
37*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(8, 0xd00, 4, 0),
38*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(9, 0xd00, 4, 0),
39*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(10, 0xd00, 4, 0),
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(11, 0xd00, 8, 0),
42*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(12, 0xd00, 8, 0),
43*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(13, 0xd00, 8, 0),
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(14, 0xd00, 12, 2),
46*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(15, 0xd00, 12, 2),
47*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(16, 0xd00, 12, 2),
48*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(17, 0xd00, 12, 2),
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(18, 0xd10, 0, 0),
51*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(19, 0xd10, 0, 0),
52*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(20, 0xd10, 0, 0),
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(21, 0xd00, 12, 2),
55*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(22, 0xd00, 12, 2),
56*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(23, 0xd00, 12, 2),
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(24, 0xd00, 8, 0),
59*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(25, 0xd00, 8, 0),
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(26, 0xd10, 4, 1),
62*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(27, 0xd10, 4, 1),
63*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(28, 0xd10, 4, 1),
64*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(29, 0xd10, 4, 1),
65*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(30, 0xd10, 4, 1),
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(31, 0xd10, 8, 1),
68*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(32, 0xd10, 8, 1),
69*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(33, 0xd10, 8, 1),
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(34, 0xd10, 12, 0),
72*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(35, 0xd10, 12, 0),
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(36, 0xd20, 0, 0),
75*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(37, 0xd20, 0, 0),
76*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(38, 0xd20, 0, 0),
77*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(39, 0xd20, 0, 0),
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(40, 0xd20, 4, 1),
80*4882a593Smuzhiyun 
81*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(41, 0xd20, 8, 1),
82*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(42, 0xd20, 8, 1),
83*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(43, 0xd20, 8, 1),
84*4882a593Smuzhiyun 
85*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(44, 0xd20, 12, 1),
86*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(45, 0xd20, 12, 1),
87*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(46, 0xd20, 12, 1),
88*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(47, 0xd20, 12, 1),
89*4882a593Smuzhiyun 
90*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(48, 0xd30, 0, 1),
91*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(49, 0xd30, 0, 1),
92*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(50, 0xd30, 0, 1),
93*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(51, 0xd30, 0, 1),
94*4882a593Smuzhiyun 
95*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(54, 0xd30, 8, 1),
96*4882a593Smuzhiyun 
97*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(55, 0xd30, 12, 1),
98*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(56, 0xd30, 12, 1),
99*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(57, 0xd30, 12, 1),
100*4882a593Smuzhiyun 
101*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(62, 0xd40, 8, 1),
102*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(63, 0xd40, 8, 1),
103*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(64, 0xd40, 8, 1),
104*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(65, 0xd40, 8, 1),
105*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(66, 0xd40, 8, 1),
106*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(67, 0xd40, 8, 1),
107*4882a593Smuzhiyun 
108*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(68, 0xd40, 12, 2),
109*4882a593Smuzhiyun 
110*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(69, 0xd50, 0, 2),
111*4882a593Smuzhiyun 
112*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(70, 0xd50, 4, 2),
113*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(71, 0xd50, 4, 2),
114*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(72, 0xd50, 4, 2),
115*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(73, 0xd50, 4, 2),
116*4882a593Smuzhiyun 
117*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(100, 0xd50, 8, 1),
118*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(101, 0xd50, 8, 1),
119*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(102, 0xd50, 8, 1),
120*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(103, 0xd50, 8, 1),
121*4882a593Smuzhiyun 
122*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(104, 0xd50, 12, 2),
123*4882a593Smuzhiyun 
124*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(105, 0xd60, 0, 2),
125*4882a593Smuzhiyun 
126*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(106, 0xd60, 4, 2),
127*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(107, 0xd60, 4, 2),
128*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(108, 0xd60, 4, 2),
129*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(109, 0xd60, 4, 2),
130*4882a593Smuzhiyun 
131*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(110, 0xd70, 0, 2),
132*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(111, 0xd70, 0, 2),
133*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(112, 0xd70, 0, 2),
134*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(113, 0xd70, 0, 2),
135*4882a593Smuzhiyun 
136*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(114, 0xd70, 4, 2),
137*4882a593Smuzhiyun 
138*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(115, 0xd60, 12, 2),
139*4882a593Smuzhiyun 
140*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(116, 0xd60, 8, 2),
141*4882a593Smuzhiyun 
142*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(117, 0xd70, 0, 2),
143*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(118, 0xd70, 0, 2),
144*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(119, 0xd70, 0, 2),
145*4882a593Smuzhiyun 	MTK_PIN_DRV_GRP(120, 0xd70, 0, 2),
146*4882a593Smuzhiyun };
147*4882a593Smuzhiyun 
148*4882a593Smuzhiyun static const struct mtk_pin_spec_pupd_set_samereg mt8167_spec_pupd[] = {
149*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(14, 0xe50, 14, 13, 12),
150*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(15, 0xe60, 2, 1, 0),
151*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(16, 0xe60, 6, 5, 4),
152*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(17, 0xe60, 10, 9, 8),
153*4882a593Smuzhiyun 
154*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(21, 0xe60, 14, 13, 12),
155*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(22, 0xe70, 2, 1, 0),
156*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(23, 0xe70, 6, 5, 4),
157*4882a593Smuzhiyun 
158*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(40, 0xe80, 2, 1, 0),
159*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(41, 0xe80, 6, 5, 4),
160*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(42, 0xe90, 2, 1, 0),
161*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(43, 0xe90, 6, 5, 4),
162*4882a593Smuzhiyun 
163*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(68, 0xe50, 10, 9, 8),
164*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(69, 0xe50, 6, 5, 4),
165*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(70, 0xe40, 6, 5, 4),
166*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(71, 0xe40, 10, 9, 8),
167*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(72, 0xe40, 14, 13, 12),
168*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(73, 0xe50, 2, 1, 0),
169*4882a593Smuzhiyun 
170*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(104, 0xe40, 2, 1, 0),
171*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(105, 0xe30, 14, 13, 12),
172*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(106, 0xe20, 14, 13, 12),
173*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(107, 0xe30, 2, 1, 0),
174*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(108, 0xe30, 6, 5, 4),
175*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(109, 0xe30, 10, 9, 8),
176*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(110, 0xe10, 14, 13, 12),
177*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(111, 0xe10, 10, 9, 8),
178*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(112, 0xe10, 6, 5, 4),
179*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(113, 0xe10, 2, 1, 0),
180*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(114, 0xe20, 10, 9, 8),
181*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(115, 0xe20, 2, 1, 0),
182*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(116, 0xe20, 6, 5, 4),
183*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(117, 0xe00, 14, 13, 12),
184*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(118, 0xe00, 10, 9, 8),
185*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(119, 0xe00, 6, 5, 4),
186*4882a593Smuzhiyun 	MTK_PIN_PUPD_SPEC_SR(120, 0xe00, 2, 1, 0),
187*4882a593Smuzhiyun };
188*4882a593Smuzhiyun 
mt8167_spec_pull_set(struct regmap * regmap,unsigned int pin,unsigned char align,bool isup,unsigned int r1r0)189*4882a593Smuzhiyun static int mt8167_spec_pull_set(struct regmap *regmap, unsigned int pin,
190*4882a593Smuzhiyun 			unsigned char align, bool isup, unsigned int r1r0)
191*4882a593Smuzhiyun {
192*4882a593Smuzhiyun 	return mtk_pctrl_spec_pull_set_samereg(regmap, mt8167_spec_pupd,
193*4882a593Smuzhiyun 		ARRAY_SIZE(mt8167_spec_pupd), pin, align, isup, r1r0);
194*4882a593Smuzhiyun }
195*4882a593Smuzhiyun 
196*4882a593Smuzhiyun static const struct mtk_pin_ies_smt_set mt8167_ies_set[] = {
197*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(0, 6, 0x900, 2),
198*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(7, 10, 0x900, 3),
199*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(11, 13, 0x900, 12),
200*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(14, 17, 0x900, 13),
201*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(18, 20, 0x910, 10),
202*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(21, 23, 0x900, 13),
203*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(24, 25, 0x900, 12),
204*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(26, 30, 0x900, 0),
205*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(31, 33, 0x900, 1),
206*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(34, 39, 0x900, 2),
207*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(40, 40, 0x910, 11),
208*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(41, 43, 0x900, 10),
209*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(44, 47, 0x900, 11),
210*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(48, 51, 0x900, 14),
211*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(52, 53, 0x910, 0),
212*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(54, 54, 0x910, 2),
213*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(55, 57, 0x910, 4),
214*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(58, 59, 0x900, 15),
215*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(60, 61, 0x910, 1),
216*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(62, 65, 0x910, 5),
217*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(66, 67, 0x910, 6),
218*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(68, 68, 0x930, 2),
219*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(69, 69, 0x930, 1),
220*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(70, 70, 0x930, 6),
221*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(71, 71, 0x930, 5),
222*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(72, 72, 0x930, 4),
223*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(73, 73, 0x930, 3),
224*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(100, 103, 0x910, 7),
225*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(104, 104, 0x920, 12),
226*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(105, 105, 0x920, 11),
227*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(106, 106, 0x930, 0),
228*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(107, 107, 0x920, 15),
229*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(108, 108, 0x920, 14),
230*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(109, 109, 0x920, 13),
231*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(110, 110, 0x920, 9),
232*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(111, 111, 0x920, 8),
233*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(112, 112, 0x920, 7),
234*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(113, 113, 0x920, 6),
235*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(114, 114, 0x920, 10),
236*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(115, 115, 0x920, 1),
237*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(116, 116, 0x920, 0),
238*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(117, 117, 0x920, 5),
239*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(118, 118, 0x920, 4),
240*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(119, 119, 0x920, 3),
241*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(120, 120, 0x920, 2),
242*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(121, 124, 0x910, 9),
243*4882a593Smuzhiyun };
244*4882a593Smuzhiyun 
245*4882a593Smuzhiyun static const struct mtk_pin_ies_smt_set mt8167_smt_set[] = {
246*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(0, 6, 0xA00, 2),
247*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(7, 10, 0xA00, 3),
248*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(11, 13, 0xA00, 12),
249*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(14, 17, 0xA00, 13),
250*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(18, 20, 0xA10, 10),
251*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(21, 23, 0xA00, 13),
252*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(24, 25, 0xA00, 12),
253*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(26, 30, 0xA00, 0),
254*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(31, 33, 0xA00, 1),
255*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(34, 39, 0xA900, 2),
256*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(40, 40, 0xA10, 11),
257*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(41, 43, 0xA00, 10),
258*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(44, 47, 0xA00, 11),
259*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(48, 51, 0xA00, 14),
260*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(52, 53, 0xA10, 0),
261*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(54, 54, 0xA10, 2),
262*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(55, 57, 0xA10, 4),
263*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(58, 59, 0xA00, 15),
264*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(60, 61, 0xA10, 1),
265*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(62, 65, 0xA10, 5),
266*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(66, 67, 0xA10, 6),
267*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(68, 68, 0xA30, 2),
268*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(69, 69, 0xA30, 1),
269*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(70, 70, 0xA30, 3),
270*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(71, 71, 0xA30, 4),
271*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(72, 72, 0xA30, 5),
272*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(73, 73, 0xA30, 6),
273*4882a593Smuzhiyun 
274*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(100, 103, 0xA10, 7),
275*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(104, 104, 0xA20, 12),
276*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(105, 105, 0xA20, 11),
277*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(106, 106, 0xA30, 13),
278*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(107, 107, 0xA20, 14),
279*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(108, 108, 0xA20, 15),
280*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(109, 109, 0xA30, 0),
281*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(110, 110, 0xA20, 9),
282*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(111, 111, 0xA20, 8),
283*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(112, 112, 0xA20, 7),
284*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(113, 113, 0xA20, 6),
285*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(114, 114, 0xA20, 10),
286*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(115, 115, 0xA20, 1),
287*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(116, 116, 0xA20, 0),
288*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(117, 117, 0xA20, 5),
289*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(118, 118, 0xA20, 4),
290*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(119, 119, 0xA20, 3),
291*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(120, 120, 0xA20, 2),
292*4882a593Smuzhiyun 	MTK_PIN_IES_SMT_SPEC(121, 124, 0xA10, 9),
293*4882a593Smuzhiyun };
294*4882a593Smuzhiyun 
mt8167_ies_smt_set(struct regmap * regmap,unsigned int pin,unsigned char align,int value,enum pin_config_param arg)295*4882a593Smuzhiyun static int mt8167_ies_smt_set(struct regmap *regmap, unsigned int pin,
296*4882a593Smuzhiyun 		unsigned char align, int value, enum pin_config_param arg)
297*4882a593Smuzhiyun {
298*4882a593Smuzhiyun 	if (arg == PIN_CONFIG_INPUT_ENABLE)
299*4882a593Smuzhiyun 		return mtk_pconf_spec_set_ies_smt_range(regmap, mt8167_ies_set,
300*4882a593Smuzhiyun 			ARRAY_SIZE(mt8167_ies_set), pin, align, value);
301*4882a593Smuzhiyun 	else if (arg == PIN_CONFIG_INPUT_SCHMITT_ENABLE)
302*4882a593Smuzhiyun 		return mtk_pconf_spec_set_ies_smt_range(regmap, mt8167_smt_set,
303*4882a593Smuzhiyun 			ARRAY_SIZE(mt8167_smt_set), pin, align, value);
304*4882a593Smuzhiyun 	return -EINVAL;
305*4882a593Smuzhiyun }
306*4882a593Smuzhiyun 
307*4882a593Smuzhiyun static const struct mtk_pinctrl_devdata mt8167_pinctrl_data = {
308*4882a593Smuzhiyun 	.pins = mtk_pins_mt8167,
309*4882a593Smuzhiyun 	.npins = ARRAY_SIZE(mtk_pins_mt8167),
310*4882a593Smuzhiyun 	.grp_desc = mt8167_drv_grp,
311*4882a593Smuzhiyun 	.n_grp_cls = ARRAY_SIZE(mt8167_drv_grp),
312*4882a593Smuzhiyun 	.pin_drv_grp = mt8167_pin_drv,
313*4882a593Smuzhiyun 	.n_pin_drv_grps = ARRAY_SIZE(mt8167_pin_drv),
314*4882a593Smuzhiyun 	.spec_pull_set = mt8167_spec_pull_set,
315*4882a593Smuzhiyun 	.spec_ies_smt_set = mt8167_ies_smt_set,
316*4882a593Smuzhiyun 	.dir_offset = 0x0000,
317*4882a593Smuzhiyun 	.pullen_offset = 0x0500,
318*4882a593Smuzhiyun 	.pullsel_offset = 0x0600,
319*4882a593Smuzhiyun 	.dout_offset = 0x0100,
320*4882a593Smuzhiyun 	.din_offset = 0x0200,
321*4882a593Smuzhiyun 	.pinmux_offset = 0x0300,
322*4882a593Smuzhiyun 	.type1_start = 125,
323*4882a593Smuzhiyun 	.type1_end = 125,
324*4882a593Smuzhiyun 	.port_shf = 4,
325*4882a593Smuzhiyun 	.port_mask = 0xf,
326*4882a593Smuzhiyun 	.port_align = 4,
327*4882a593Smuzhiyun 	.eint_hw = {
328*4882a593Smuzhiyun 		.port_mask = 7,
329*4882a593Smuzhiyun 		.ports     = 6,
330*4882a593Smuzhiyun 		.ap_num    = 169,
331*4882a593Smuzhiyun 		.db_cnt    = 64,
332*4882a593Smuzhiyun 	},
333*4882a593Smuzhiyun };
334*4882a593Smuzhiyun 
mt8167_pinctrl_probe(struct platform_device * pdev)335*4882a593Smuzhiyun static int mt8167_pinctrl_probe(struct platform_device *pdev)
336*4882a593Smuzhiyun {
337*4882a593Smuzhiyun 	return mtk_pctrl_init(pdev, &mt8167_pinctrl_data, NULL);
338*4882a593Smuzhiyun }
339*4882a593Smuzhiyun 
340*4882a593Smuzhiyun static const struct of_device_id mt8167_pctrl_match[] = {
341*4882a593Smuzhiyun 	{
342*4882a593Smuzhiyun 		.compatible = "mediatek,mt8167-pinctrl",
343*4882a593Smuzhiyun 	},
344*4882a593Smuzhiyun 	{}
345*4882a593Smuzhiyun };
346*4882a593Smuzhiyun 
347*4882a593Smuzhiyun MODULE_DEVICE_TABLE(of, mt8167_pctrl_match);
348*4882a593Smuzhiyun 
349*4882a593Smuzhiyun static struct platform_driver mtk_pinctrl_driver = {
350*4882a593Smuzhiyun 	.probe = mt8167_pinctrl_probe,
351*4882a593Smuzhiyun 	.driver = {
352*4882a593Smuzhiyun 		.name = "mediatek-mt8167-pinctrl",
353*4882a593Smuzhiyun 		.of_match_table = mt8167_pctrl_match,
354*4882a593Smuzhiyun 		.pm = &mtk_eint_pm_ops,
355*4882a593Smuzhiyun 	},
356*4882a593Smuzhiyun };
357*4882a593Smuzhiyun 
mtk_pinctrl_init(void)358*4882a593Smuzhiyun static int __init mtk_pinctrl_init(void)
359*4882a593Smuzhiyun {
360*4882a593Smuzhiyun 	return platform_driver_register(&mtk_pinctrl_driver);
361*4882a593Smuzhiyun }
362*4882a593Smuzhiyun arch_initcall(mtk_pinctrl_init);
363