1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (C) 2019 MediaTek Inc.
4  * Author: Andy Teng <andy.teng@mediatek.com>
5  *
6  */
7 
8 #include <linux/module.h>
9 #include "pinctrl-mtk-mt6779.h"
10 #include "pinctrl-paris.h"
11 
12 /* MT6779 have multiple bases to program pin configuration listed as the below:
13  * gpio:0x10005000,     iocfg_rm:0x11C20000, iocfg_br:0x11D10000,
14  * iocfg_lm:0x11E20000, iocfg_lb:0x11E70000, iocfg_rt:0x11EA0000,
15  * iocfg_lt:0x11F20000, iocfg_tl: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, x_bits, \
21 		       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, x_bits,  \
25 		       32, 1)
26 
27 static const struct mtk_pin_field_calc mt6779_pin_mode_range[] = {
28 	PIN_FIELD_BASE(0, 7, 0, 0x0300, 0x10, 0, 4),
29 	PIN_FIELD_BASE(8, 15, 0, 0x0310, 0x10, 0, 4),
30 	PIN_FIELD_BASE(16, 23, 0, 0x0320, 0x10, 0, 4),
31 	PIN_FIELD_BASE(24, 31, 0, 0x0330, 0x10, 0, 4),
32 	PIN_FIELD_BASE(32, 39, 0, 0x0340, 0x10, 0, 4),
33 	PIN_FIELD_BASE(40, 47, 0, 0x0350, 0x10, 0, 4),
34 	PIN_FIELD_BASE(48, 55, 0, 0x0360, 0x10, 0, 4),
35 	PIN_FIELD_BASE(56, 63, 0, 0x0370, 0x10, 0, 4),
36 	PIN_FIELD_BASE(64, 71, 0, 0x0380, 0x10, 0, 4),
37 	PIN_FIELD_BASE(72, 79, 0, 0x0390, 0x10, 0, 4),
38 	PIN_FIELD_BASE(80, 87, 0, 0x03A0, 0x10, 0, 4),
39 	PIN_FIELD_BASE(88, 95, 0, 0x03B0, 0x10, 0, 4),
40 	PIN_FIELD_BASE(96, 103, 0, 0x03C0, 0x10, 0, 4),
41 	PIN_FIELD_BASE(104, 111, 0, 0x03D0, 0x10, 0, 4),
42 	PIN_FIELD_BASE(112, 119, 0, 0x03E0, 0x10, 0, 4),
43 	PIN_FIELD_BASE(120, 127, 0, 0x03F0, 0x10, 0, 4),
44 	PIN_FIELD_BASE(128, 135, 0, 0x0400, 0x10, 0, 4),
45 	PIN_FIELD_BASE(136, 143, 0, 0x0410, 0x10, 0, 4),
46 	PIN_FIELD_BASE(144, 151, 0, 0x0420, 0x10, 0, 4),
47 	PIN_FIELD_BASE(152, 159, 0, 0x0430, 0x10, 0, 4),
48 	PIN_FIELD_BASE(160, 167, 0, 0x0440, 0x10, 0, 4),
49 	PIN_FIELD_BASE(168, 175, 0, 0x0450, 0x10, 0, 4),
50 	PIN_FIELD_BASE(176, 183, 0, 0x0460, 0x10, 0, 4),
51 	PIN_FIELD_BASE(184, 191, 0, 0x0470, 0x10, 0, 4),
52 	PIN_FIELD_BASE(192, 199, 0, 0x0480, 0x10, 0, 4),
53 	PIN_FIELD_BASE(200, 202, 0, 0x0490, 0x10, 0, 4),
54 };
55 
56 static const struct mtk_pin_field_calc mt6779_pin_dir_range[] = {
57 	PIN_FIELD_BASE(0, 31, 0, 0x0000, 0x10, 0, 1),
58 	PIN_FIELD_BASE(32, 63, 0, 0x0010, 0x10, 0, 1),
59 	PIN_FIELD_BASE(64, 95, 0, 0x0020, 0x10, 0, 1),
60 	PIN_FIELD_BASE(96, 127, 0, 0x0030, 0x10, 0, 1),
61 	PIN_FIELD_BASE(128, 159, 0, 0x0040, 0x10, 0, 1),
62 	PIN_FIELD_BASE(160, 191, 0, 0x0050, 0x10, 0, 1),
63 	PIN_FIELD_BASE(192, 202, 0, 0x0060, 0x10, 0, 1),
64 };
65 
66 static const struct mtk_pin_field_calc mt6779_pin_di_range[] = {
67 	PIN_FIELD_BASE(0, 31, 0, 0x0200, 0x10, 0, 1),
68 	PIN_FIELD_BASE(32, 63, 0, 0x0210, 0x10, 0, 1),
69 	PIN_FIELD_BASE(64, 95, 0, 0x0220, 0x10, 0, 1),
70 	PIN_FIELD_BASE(96, 127, 0, 0x0230, 0x10, 0, 1),
71 	PIN_FIELD_BASE(128, 159, 0, 0x0240, 0x10, 0, 1),
72 	PIN_FIELD_BASE(160, 191, 0, 0x0250, 0x10, 0, 1),
73 	PIN_FIELD_BASE(192, 202, 0, 0x0260, 0x10, 0, 1),
74 };
75 
76 static const struct mtk_pin_field_calc mt6779_pin_do_range[] = {
77 	PIN_FIELD_BASE(0, 31, 0, 0x0100, 0x10, 0, 1),
78 	PIN_FIELD_BASE(32, 63, 0, 0x0110, 0x10, 0, 1),
79 	PIN_FIELD_BASE(64, 95, 0, 0x0120, 0x10, 0, 1),
80 	PIN_FIELD_BASE(96, 127, 0, 0x0130, 0x10, 0, 1),
81 	PIN_FIELD_BASE(128, 159, 0, 0x0140, 0x10, 0, 1),
82 	PIN_FIELD_BASE(160, 191, 0, 0x0150, 0x10, 0, 1),
83 	PIN_FIELD_BASE(192, 202, 0, 0x0160, 0x10, 0, 1),
84 };
85 
86 static const struct mtk_pin_field_calc mt6779_pin_ies_range[] = {
87 	PIN_FIELD_BASE(0, 9, 6, 0x0030, 0x10, 3, 1),
88 	PIN_FIELD_BASE(10, 16, 3, 0x0050, 0x10, 0, 1),
89 	PIN_FIELD_BASE(17, 18, 6, 0x0030, 0x10, 28, 1),
90 	PIN_FIELD_BASE(19, 19, 6, 0x0030, 0x10, 27, 1),
91 	PIN_FIELD_BASE(20, 20, 6, 0x0030, 0x10, 26, 1),
92 	PIN_FIELD_BASE(21, 24, 6, 0x0030, 0x10, 19, 1),
93 	PIN_FIELD_BASE(25, 25, 6, 0x0030, 0x10, 30, 1),
94 	PIN_FIELD_BASE(26, 26, 6, 0x0030, 0x10, 23, 1),
95 	PIN_FIELD_BASE(27, 27, 6, 0x0030, 0x10, 0, 1),
96 	PIN_FIELD_BASE(28, 29, 6, 0x0030, 0x10, 24, 1),
97 	PIN_FIELD_BASE(30, 30, 6, 0x0030, 0x10, 16, 1),
98 	PIN_FIELD_BASE(31, 31, 6, 0x0030, 0x10, 13, 1),
99 	PIN_FIELD_BASE(32, 32, 6, 0x0030, 0x10, 15, 1),
100 	PIN_FIELD_BASE(33, 33, 6, 0x0030, 0x10, 17, 1),
101 	PIN_FIELD_BASE(34, 34, 6, 0x0030, 0x10, 14, 1),
102 	PIN_FIELD_BASE(35, 35, 6, 0x0040, 0x10, 4, 1),
103 	PIN_FIELD_BASE(36, 36, 6, 0x0030, 0x10, 31, 1),
104 	PIN_FIELD_BASE(37, 37, 6, 0x0040, 0x10, 5, 1),
105 	PIN_FIELD_BASE(38, 41, 6, 0x0040, 0x10, 0, 1),
106 	PIN_FIELD_BASE(42, 43, 6, 0x0030, 0x10, 1, 1),
107 	PIN_FIELD_BASE(44, 44, 6, 0x0030, 0x10, 18, 1),
108 	PIN_FIELD_BASE(45, 45, 3, 0x0050, 0x10, 14, 1),
109 	PIN_FIELD_BASE(46, 46, 3, 0x0050, 0x10, 22, 1),
110 	PIN_FIELD_BASE(47, 47, 3, 0x0050, 0x10, 25, 1),
111 	PIN_FIELD_BASE(48, 48, 3, 0x0050, 0x10, 24, 1),
112 	PIN_FIELD_BASE(49, 49, 3, 0x0050, 0x10, 26, 1),
113 	PIN_FIELD_BASE(50, 50, 3, 0x0050, 0x10, 23, 1),
114 	PIN_FIELD_BASE(51, 51, 3, 0x0050, 0x10, 11, 1),
115 	PIN_FIELD_BASE(52, 52, 3, 0x0050, 0x10, 19, 1),
116 	PIN_FIELD_BASE(53, 54, 3, 0x0050, 0x10, 27, 1),
117 	PIN_FIELD_BASE(55, 55, 3, 0x0050, 0x10, 13, 1),
118 	PIN_FIELD_BASE(56, 56, 3, 0x0050, 0x10, 21, 1),
119 	PIN_FIELD_BASE(57, 57, 3, 0x0050, 0x10, 10, 1),
120 	PIN_FIELD_BASE(58, 58, 3, 0x0050, 0x10, 9, 1),
121 	PIN_FIELD_BASE(59, 60, 3, 0x0050, 0x10, 7, 1),
122 	PIN_FIELD_BASE(61, 61, 3, 0x0050, 0x10, 12, 1),
123 	PIN_FIELD_BASE(62, 62, 3, 0x0050, 0x10, 20, 1),
124 	PIN_FIELD_BASE(63, 63, 3, 0x0050, 0x10, 17, 1),
125 	PIN_FIELD_BASE(64, 64, 3, 0x0050, 0x10, 16, 1),
126 	PIN_FIELD_BASE(65, 65, 3, 0x0050, 0x10, 18, 1),
127 	PIN_FIELD_BASE(66, 66, 3, 0x0050, 0x10, 15, 1),
128 	PIN_FIELD_BASE(67, 67, 2, 0x0060, 0x10, 7, 1),
129 	PIN_FIELD_BASE(68, 68, 2, 0x0060, 0x10, 6, 1),
130 	PIN_FIELD_BASE(69, 69, 2, 0x0060, 0x10, 8, 1),
131 	PIN_FIELD_BASE(70, 71, 2, 0x0060, 0x10, 4, 1),
132 	PIN_FIELD_BASE(72, 72, 4, 0x0020, 0x10, 3, 1),
133 	PIN_FIELD_BASE(73, 73, 4, 0x0020, 0x10, 2, 1),
134 	PIN_FIELD_BASE(74, 74, 4, 0x0020, 0x10, 1, 1),
135 	PIN_FIELD_BASE(75, 75, 4, 0x0020, 0x10, 4, 1),
136 	PIN_FIELD_BASE(76, 76, 4, 0x0020, 0x10, 12, 1),
137 	PIN_FIELD_BASE(77, 77, 4, 0x0020, 0x10, 11, 1),
138 	PIN_FIELD_BASE(78, 78, 2, 0x0050, 0x10, 18, 1),
139 	PIN_FIELD_BASE(79, 79, 2, 0x0050, 0x10, 17, 1),
140 	PIN_FIELD_BASE(80, 81, 2, 0x0050, 0x10, 19, 1),
141 	PIN_FIELD_BASE(82, 88, 2, 0x0050, 0x10, 1, 1),
142 	PIN_FIELD_BASE(89, 89, 2, 0x0050, 0x10, 16, 1),
143 	PIN_FIELD_BASE(90, 90, 2, 0x0050, 0x10, 15, 1),
144 	PIN_FIELD_BASE(91, 91, 2, 0x0050, 0x10, 14, 1),
145 	PIN_FIELD_BASE(92, 92, 2, 0x0050, 0x10, 8, 1),
146 	PIN_FIELD_BASE(93, 93, 4, 0x0020, 0x10, 0, 1),
147 	PIN_FIELD_BASE(94, 94, 2, 0x0050, 0x10, 0, 1),
148 	PIN_FIELD_BASE(95, 95, 4, 0x0020, 0x10, 7, 1),
149 	PIN_FIELD_BASE(96, 96, 4, 0x0020, 0x10, 5, 1),
150 	PIN_FIELD_BASE(97, 97, 4, 0x0020, 0x10, 8, 1),
151 	PIN_FIELD_BASE(98, 98, 4, 0x0020, 0x10, 6, 1),
152 	PIN_FIELD_BASE(99, 99, 2, 0x0060, 0x10, 9, 1),
153 	PIN_FIELD_BASE(100, 100, 2, 0x0060, 0x10, 12, 1),
154 	PIN_FIELD_BASE(101, 101, 2, 0x0060, 0x10, 10, 1),
155 	PIN_FIELD_BASE(102, 102, 2, 0x0060, 0x10, 13, 1),
156 	PIN_FIELD_BASE(103, 103, 2, 0x0060, 0x10, 11, 1),
157 	PIN_FIELD_BASE(104, 104, 2, 0x0060, 0x10, 14, 1),
158 	PIN_FIELD_BASE(105, 105, 2, 0x0050, 0x10, 10, 1),
159 	PIN_FIELD_BASE(106, 106, 2, 0x0050, 0x10, 9, 1),
160 	PIN_FIELD_BASE(107, 108, 2, 0x0050, 0x10, 12, 1),
161 	PIN_FIELD_BASE(109, 109, 2, 0x0050, 0x10, 11, 1),
162 	PIN_FIELD_BASE(110, 110, 2, 0x0060, 0x10, 16, 1),
163 	PIN_FIELD_BASE(111, 111, 2, 0x0060, 0x10, 18, 1),
164 	PIN_FIELD_BASE(112, 112, 2, 0x0060, 0x10, 15, 1),
165 	PIN_FIELD_BASE(113, 113, 2, 0x0060, 0x10, 17, 1),
166 	PIN_FIELD_BASE(114, 115, 2, 0x0050, 0x10, 26, 1),
167 	PIN_FIELD_BASE(116, 117, 2, 0x0050, 0x10, 21, 1),
168 	PIN_FIELD_BASE(118, 118, 2, 0x0050, 0x10, 31, 1),
169 	PIN_FIELD_BASE(119, 119, 2, 0x0060, 0x10, 0, 1),
170 	PIN_FIELD_BASE(120, 121, 2, 0x0050, 0x10, 23, 1),
171 	PIN_FIELD_BASE(122, 123, 2, 0x0050, 0x10, 28, 1),
172 	PIN_FIELD_BASE(124, 125, 2, 0x0060, 0x10, 1, 1),
173 	PIN_FIELD_BASE(126, 127, 1, 0x0030, 0x10, 8, 1),
174 	PIN_FIELD_BASE(128, 129, 1, 0x0030, 0x10, 17, 1),
175 	PIN_FIELD_BASE(130, 130, 1, 0x0030, 0x10, 16, 1),
176 	PIN_FIELD_BASE(131, 131, 1, 0x0030, 0x10, 19, 1),
177 	PIN_FIELD_BASE(132, 132, 1, 0x0030, 0x10, 21, 1),
178 	PIN_FIELD_BASE(133, 133, 1, 0x0030, 0x10, 20, 1),
179 	PIN_FIELD_BASE(134, 135, 1, 0x0030, 0x10, 2, 1),
180 	PIN_FIELD_BASE(136, 136, 1, 0x0030, 0x10, 7, 1),
181 	PIN_FIELD_BASE(137, 137, 1, 0x0030, 0x10, 4, 1),
182 	PIN_FIELD_BASE(138, 138, 1, 0x0030, 0x10, 6, 1),
183 	PIN_FIELD_BASE(139, 139, 1, 0x0030, 0x10, 5, 1),
184 	PIN_FIELD_BASE(140, 141, 1, 0x0030, 0x10, 0, 1),
185 	PIN_FIELD_BASE(142, 142, 1, 0x0030, 0x10, 15, 1),
186 	PIN_FIELD_BASE(143, 143, 5, 0x0020, 0x10, 15, 1),
187 	PIN_FIELD_BASE(144, 144, 5, 0x0020, 0x10, 17, 1),
188 	PIN_FIELD_BASE(145, 145, 5, 0x0020, 0x10, 16, 1),
189 	PIN_FIELD_BASE(146, 146, 5, 0x0020, 0x10, 12, 1),
190 	PIN_FIELD_BASE(147, 155, 5, 0x0020, 0x10, 0, 1),
191 	PIN_FIELD_BASE(156, 157, 5, 0x0020, 0x10, 22, 1),
192 	PIN_FIELD_BASE(158, 158, 5, 0x0020, 0x10, 21, 1),
193 	PIN_FIELD_BASE(159, 159, 5, 0x0020, 0x10, 24, 1),
194 	PIN_FIELD_BASE(160, 161, 5, 0x0020, 0x10, 19, 1),
195 	PIN_FIELD_BASE(162, 166, 5, 0x0020, 0x10, 25, 1),
196 	PIN_FIELD_BASE(167, 168, 7, 0x0010, 0x10, 1, 1),
197 	PIN_FIELD_BASE(169, 169, 7, 0x0010, 0x10, 4, 1),
198 	PIN_FIELD_BASE(170, 170, 7, 0x0010, 0x10, 6, 1),
199 	PIN_FIELD_BASE(171, 171, 7, 0x0010, 0x10, 8, 1),
200 	PIN_FIELD_BASE(172, 172, 7, 0x0010, 0x10, 3, 1),
201 	PIN_FIELD_BASE(173, 173, 7, 0x0010, 0x10, 7, 1),
202 	PIN_FIELD_BASE(174, 175, 7, 0x0010, 0x10, 9, 1),
203 	PIN_FIELD_BASE(176, 176, 7, 0x0010, 0x10, 0, 1),
204 	PIN_FIELD_BASE(177, 177, 7, 0x0010, 0x10, 5, 1),
205 	PIN_FIELD_BASE(178, 178, 7, 0x0010, 0x10, 11, 1),
206 	PIN_FIELD_BASE(179, 179, 4, 0x0020, 0x10, 13, 1),
207 	PIN_FIELD_BASE(180, 180, 4, 0x0020, 0x10, 10, 1),
208 	PIN_FIELD_BASE(181, 183, 1, 0x0030, 0x10, 22, 1),
209 	PIN_FIELD_BASE(184, 184, 1, 0x0030, 0x10, 12, 1),
210 	PIN_FIELD_BASE(185, 185, 1, 0x0030, 0x10, 11, 1),
211 	PIN_FIELD_BASE(186, 186, 1, 0x0030, 0x10, 13, 1),
212 	PIN_FIELD_BASE(187, 187, 1, 0x0030, 0x10, 10, 1),
213 	PIN_FIELD_BASE(188, 188, 1, 0x0030, 0x10, 14, 1),
214 	PIN_FIELD_BASE(189, 189, 5, 0x0020, 0x10, 9, 1),
215 	PIN_FIELD_BASE(190, 190, 5, 0x0020, 0x10, 18, 1),
216 	PIN_FIELD_BASE(191, 192, 5, 0x0020, 0x10, 13, 1),
217 	PIN_FIELD_BASE(193, 194, 5, 0x0020, 0x10, 10, 1),
218 	PIN_FIELD_BASE(195, 195, 2, 0x0050, 0x10, 30, 1),
219 	PIN_FIELD_BASE(196, 196, 2, 0x0050, 0x10, 25, 1),
220 	PIN_FIELD_BASE(197, 197, 2, 0x0060, 0x10, 3, 1),
221 	PIN_FIELD_BASE(198, 199, 4, 0x0020, 0x10, 14, 1),
222 	PIN_FIELD_BASE(200, 201, 6, 0x0040, 0x10, 6, 1),
223 	PIN_FIELD_BASE(202, 202, 4, 0x0020, 0x10, 9, 1),
224 };
225 
226 static const struct mtk_pin_field_calc mt6779_pin_smt_range[] = {
227 	PINS_FIELD_BASE(0, 9, 6, 0x00c0, 0x10, 3, 1),
228 	PIN_FIELD_BASE(10, 11, 3, 0x00e0, 0x10, 0, 1),
229 	PINS_FIELD_BASE(12, 15, 3, 0x00e0, 0x10, 2, 1),
230 	PIN_FIELD_BASE(16, 16, 3, 0x00e0, 0x10, 3, 1),
231 	PINS_FIELD_BASE(17, 20, 6, 0x00c0, 0x10, 11, 1),
232 	PINS_FIELD_BASE(21, 24, 6, 0x00c0, 0x10, 7, 1),
233 	PIN_FIELD_BASE(25, 25, 6, 0x00c0, 0x10, 12, 1),
234 	PIN_FIELD_BASE(26, 26, 6, 0x00c0, 0x10, 8, 1),
235 	PIN_FIELD_BASE(27, 27, 6, 0x00c0, 0x10, 0, 1),
236 	PIN_FIELD_BASE(28, 29, 6, 0x00c0, 0x10, 9, 1),
237 	PINS_FIELD_BASE(30, 32, 6, 0x00c0, 0x10, 4, 1),
238 	PIN_FIELD_BASE(33, 33, 6, 0x00c0, 0x10, 5, 1),
239 	PIN_FIELD_BASE(34, 34, 6, 0x00c0, 0x10, 4, 1),
240 	PINS_FIELD_BASE(35, 41, 6, 0x00c0, 0x10, 13, 1),
241 	PIN_FIELD_BASE(42, 43, 6, 0x00c0, 0x10, 1, 1),
242 	PIN_FIELD_BASE(44, 44, 6, 0x00c0, 0x10, 6, 1),
243 	PIN_FIELD_BASE(45, 45, 3, 0x00e0, 0x10, 8, 1),
244 	PIN_FIELD_BASE(46, 46, 3, 0x00e0, 0x10, 13, 1),
245 	PINS_FIELD_BASE(47, 50, 3, 0x00e0, 0x10, 14, 1),
246 	PIN_FIELD_BASE(51, 51, 3, 0x00e0, 0x10, 5, 1),
247 	PIN_FIELD_BASE(52, 52, 3, 0x00e0, 0x10, 10, 1),
248 	PIN_FIELD_BASE(53, 54, 3, 0x00e0, 0x10, 15, 1),
249 	PIN_FIELD_BASE(55, 55, 3, 0x00e0, 0x10, 7, 1),
250 	PIN_FIELD_BASE(56, 56, 3, 0x00e0, 0x10, 12, 1),
251 	PINS_FIELD_BASE(57, 60, 3, 0x00e0, 0x10, 4, 1),
252 	PIN_FIELD_BASE(61, 61, 3, 0x00e0, 0x10, 6, 1),
253 	PIN_FIELD_BASE(62, 62, 3, 0x00e0, 0x10, 11, 1),
254 	PINS_FIELD_BASE(63, 66, 3, 0x00e0, 0x10, 9, 1),
255 	PINS_FIELD_BASE(67, 69, 2, 0x00e0, 0x10, 11, 1),
256 	PIN_FIELD_BASE(70, 71, 2, 0x00e0, 0x10, 10, 1),
257 	PINS_FIELD_BASE(72, 75, 4, 0x0070, 0x10, 1, 1),
258 	PINS_FIELD_BASE(76, 77, 4, 0x0070, 0x10, 4, 1),
259 	PINS_FIELD_BASE(78, 86, 2, 0x00e0, 0x10, 1, 1),
260 	PINS_FIELD_BASE(87, 92, 2, 0x00e0, 0x10, 2, 1),
261 	PIN_FIELD_BASE(93, 93, 4, 0x0070, 0x10, 0, 1),
262 	PIN_FIELD_BASE(94, 94, 2, 0x00e0, 0x10, 2, 1),
263 	PINS_FIELD_BASE(95, 98, 4, 0x0070, 0x10, 2, 1),
264 	PINS_FIELD_BASE(99, 104, 2, 0x00e0, 0x10, 12, 1),
265 	PINS_FIELD_BASE(105, 109, 2, 0x00e0, 0x10, 0, 1),
266 	PIN_FIELD_BASE(110, 110, 2, 0x00e0, 0x10, 14, 1),
267 	PIN_FIELD_BASE(111, 111, 2, 0x00e0, 0x10, 16, 1),
268 	PIN_FIELD_BASE(112, 112, 2, 0x00e0, 0x10, 13, 1),
269 	PIN_FIELD_BASE(113, 113, 2, 0x00e0, 0x10, 15, 1),
270 	PINS_FIELD_BASE(114, 115, 2, 0x00e0, 0x10, 4, 1),
271 	PIN_FIELD_BASE(116, 117, 2, 0x00e0, 0x10, 5, 1),
272 	PINS_FIELD_BASE(118, 119, 2, 0x00e0, 0x10, 4, 1),
273 	PIN_FIELD_BASE(120, 121, 2, 0x00e0, 0x10, 7, 1),
274 	PINS_FIELD_BASE(122, 125, 2, 0x00e0, 0x10, 3, 1),
275 	PINS_FIELD_BASE(126, 127, 1, 0x00c0, 0x10, 5, 1),
276 	PINS_FIELD_BASE(128, 130, 1, 0x00c0, 0x10, 9, 1),
277 	PINS_FIELD_BASE(131, 133, 1, 0x00c0, 0x10, 10, 1),
278 	PIN_FIELD_BASE(134, 135, 1, 0x00c0, 0x10, 2, 1),
279 	PINS_FIELD_BASE(136, 139, 1, 0x00c0, 0x10, 4, 1),
280 	PIN_FIELD_BASE(140, 141, 1, 0x00c0, 0x10, 0, 1),
281 	PIN_FIELD_BASE(142, 142, 1, 0x00c0, 0x10, 8, 1),
282 	PINS_FIELD_BASE(143, 146, 5, 0x0060, 0x10, 1, 1),
283 	PINS_FIELD_BASE(147, 155, 5, 0x0060, 0x10, 0, 1),
284 	PIN_FIELD_BASE(156, 157, 5, 0x0060, 0x10, 6, 1),
285 	PIN_FIELD_BASE(158, 158, 5, 0x0060, 0x10, 5, 1),
286 	PIN_FIELD_BASE(159, 159, 5, 0x0060, 0x10, 8, 1),
287 	PIN_FIELD_BASE(160, 161, 5, 0x0060, 0x10, 3, 1),
288 	PINS_FIELD_BASE(162, 166, 5, 0x0060, 0x10, 2, 1),
289 	PIN_FIELD_BASE(167, 167, 7, 0x0060, 0x10, 1, 1),
290 	PINS_FIELD_BASE(168, 174, 7, 0x0060, 0x10, 2, 1),
291 	PIN_FIELD_BASE(175, 175, 7, 0x0060, 0x10, 3, 1),
292 	PIN_FIELD_BASE(176, 176, 7, 0x0060, 0x10, 0, 1),
293 	PINS_FIELD_BASE(177, 178, 7, 0x0060, 0x10, 2, 1),
294 	PINS_FIELD_BASE(179, 180, 4, 0x0070, 0x10, 4, 1),
295 	PIN_FIELD_BASE(181, 183, 1, 0x00c0, 0x10, 11, 1),
296 	PINS_FIELD_BASE(184, 187, 1, 0x00c0, 0x10, 6, 1),
297 	PIN_FIELD_BASE(188, 188, 1, 0x00c0, 0x10, 7, 1),
298 	PINS_FIELD_BASE(189, 194, 5, 0x0060, 0x10, 1, 1),
299 	PIN_FIELD_BASE(195, 195, 2, 0x00e0, 0x10, 3, 1),
300 	PIN_FIELD_BASE(196, 196, 2, 0x00e0, 0x10, 9, 1),
301 	PIN_FIELD_BASE(197, 197, 2, 0x00e0, 0x10, 3, 1),
302 	PIN_FIELD_BASE(198, 199, 4, 0x0070, 0x10, 5, 1),
303 	PIN_FIELD_BASE(200, 201, 6, 0x00c0, 0x10, 14, 1),
304 	PIN_FIELD_BASE(202, 202, 4, 0x0070, 0x10, 3, 1),
305 };
306 
307 static const struct mtk_pin_field_calc mt6779_pin_pu_range[] = {
308 	PIN_FIELD_BASE(0, 9, 6, 0x0070, 0x10, 3, 1),
309 	PIN_FIELD_BASE(16, 16, 3, 0x0080, 0x10, 0, 1),
310 	PIN_FIELD_BASE(17, 18, 6, 0x0070, 0x10, 28, 1),
311 	PIN_FIELD_BASE(19, 19, 6, 0x0070, 0x10, 27, 1),
312 	PIN_FIELD_BASE(20, 20, 6, 0x0070, 0x10, 26, 1),
313 	PIN_FIELD_BASE(21, 24, 6, 0x0070, 0x10, 19, 1),
314 	PIN_FIELD_BASE(25, 25, 6, 0x0070, 0x10, 30, 1),
315 	PIN_FIELD_BASE(26, 26, 6, 0x0070, 0x10, 23, 1),
316 	PIN_FIELD_BASE(27, 27, 6, 0x0070, 0x10, 0, 1),
317 	PIN_FIELD_BASE(28, 29, 6, 0x0070, 0x10, 24, 1),
318 	PIN_FIELD_BASE(30, 30, 6, 0x0070, 0x10, 16, 1),
319 	PIN_FIELD_BASE(31, 31, 6, 0x0070, 0x10, 13, 1),
320 	PIN_FIELD_BASE(32, 32, 6, 0x0070, 0x10, 15, 1),
321 	PIN_FIELD_BASE(33, 33, 6, 0x0070, 0x10, 17, 1),
322 	PIN_FIELD_BASE(34, 34, 6, 0x0070, 0x10, 14, 1),
323 	PIN_FIELD_BASE(35, 35, 6, 0x0080, 0x10, 5, 1),
324 	PIN_FIELD_BASE(36, 36, 6, 0x0080, 0x10, 0, 1),
325 	PIN_FIELD_BASE(37, 37, 6, 0x0080, 0x10, 6, 1),
326 	PIN_FIELD_BASE(38, 41, 6, 0x0080, 0x10, 1, 1),
327 	PIN_FIELD_BASE(42, 43, 6, 0x0070, 0x10, 1, 1),
328 	PIN_FIELD_BASE(44, 44, 6, 0x0070, 0x10, 18, 1),
329 	PIN_FIELD_BASE(45, 45, 3, 0x0080, 0x10, 4, 1),
330 	PIN_FIELD_BASE(46, 46, 3, 0x0080, 0x10, 12, 1),
331 	PIN_FIELD_BASE(47, 47, 3, 0x0080, 0x10, 15, 1),
332 	PIN_FIELD_BASE(48, 48, 3, 0x0080, 0x10, 14, 1),
333 	PIN_FIELD_BASE(49, 49, 3, 0x0080, 0x10, 16, 1),
334 	PIN_FIELD_BASE(50, 50, 3, 0x0080, 0x10, 13, 1),
335 	PIN_FIELD_BASE(51, 51, 3, 0x0080, 0x10, 1, 1),
336 	PIN_FIELD_BASE(52, 52, 3, 0x0080, 0x10, 9, 1),
337 	PIN_FIELD_BASE(53, 54, 3, 0x0080, 0x10, 18, 1),
338 	PIN_FIELD_BASE(55, 55, 3, 0x0080, 0x10, 3, 1),
339 	PIN_FIELD_BASE(56, 56, 3, 0x0080, 0x10, 11, 1),
340 	PIN_FIELD_BASE(61, 61, 3, 0x0080, 0x10, 2, 1),
341 	PIN_FIELD_BASE(62, 62, 3, 0x0080, 0x10, 10, 1),
342 	PIN_FIELD_BASE(63, 63, 3, 0x0080, 0x10, 7, 1),
343 	PIN_FIELD_BASE(64, 64, 3, 0x0080, 0x10, 6, 1),
344 	PIN_FIELD_BASE(65, 65, 3, 0x0080, 0x10, 8, 1),
345 	PIN_FIELD_BASE(66, 66, 3, 0x0080, 0x10, 5, 1),
346 	PIN_FIELD_BASE(67, 67, 2, 0x00a0, 0x10, 7, 1),
347 	PIN_FIELD_BASE(68, 68, 2, 0x00a0, 0x10, 6, 1),
348 	PIN_FIELD_BASE(69, 69, 2, 0x00a0, 0x10, 8, 1),
349 	PIN_FIELD_BASE(70, 71, 2, 0x00a0, 0x10, 4, 1),
350 	PIN_FIELD_BASE(72, 72, 4, 0x0040, 0x10, 3, 1),
351 	PIN_FIELD_BASE(73, 73, 4, 0x0040, 0x10, 2, 1),
352 	PIN_FIELD_BASE(74, 74, 4, 0x0040, 0x10, 1, 1),
353 	PIN_FIELD_BASE(75, 75, 4, 0x0040, 0x10, 4, 1),
354 	PIN_FIELD_BASE(76, 76, 4, 0x0040, 0x10, 12, 1),
355 	PIN_FIELD_BASE(77, 77, 4, 0x0040, 0x10, 11, 1),
356 	PIN_FIELD_BASE(78, 78, 2, 0x0090, 0x10, 18, 1),
357 	PIN_FIELD_BASE(79, 79, 2, 0x0090, 0x10, 17, 1),
358 	PIN_FIELD_BASE(80, 81, 2, 0x0090, 0x10, 19, 1),
359 	PIN_FIELD_BASE(82, 88, 2, 0x0090, 0x10, 1, 1),
360 	PIN_FIELD_BASE(89, 89, 2, 0x0090, 0x10, 16, 1),
361 	PIN_FIELD_BASE(90, 90, 2, 0x0090, 0x10, 15, 1),
362 	PIN_FIELD_BASE(91, 91, 2, 0x0090, 0x10, 14, 1),
363 	PIN_FIELD_BASE(92, 92, 2, 0x0090, 0x10, 8, 1),
364 	PIN_FIELD_BASE(93, 93, 4, 0x0040, 0x10, 0, 1),
365 	PIN_FIELD_BASE(94, 94, 2, 0x0090, 0x10, 0, 1),
366 	PIN_FIELD_BASE(95, 95, 4, 0x0040, 0x10, 7, 1),
367 	PIN_FIELD_BASE(96, 96, 4, 0x0040, 0x10, 5, 1),
368 	PIN_FIELD_BASE(97, 97, 4, 0x0040, 0x10, 8, 1),
369 	PIN_FIELD_BASE(98, 98, 4, 0x0040, 0x10, 6, 1),
370 	PIN_FIELD_BASE(99, 99, 2, 0x00a0, 0x10, 9, 1),
371 	PIN_FIELD_BASE(100, 100, 2, 0x00a0, 0x10, 12, 1),
372 	PIN_FIELD_BASE(101, 101, 2, 0x00a0, 0x10, 10, 1),
373 	PIN_FIELD_BASE(102, 102, 2, 0x00a0, 0x10, 13, 1),
374 	PIN_FIELD_BASE(103, 103, 2, 0x00a0, 0x10, 11, 1),
375 	PIN_FIELD_BASE(104, 104, 2, 0x00a0, 0x10, 14, 1),
376 	PIN_FIELD_BASE(105, 105, 2, 0x0090, 0x10, 10, 1),
377 	PIN_FIELD_BASE(106, 106, 2, 0x0090, 0x10, 9, 1),
378 	PIN_FIELD_BASE(107, 108, 2, 0x0090, 0x10, 12, 1),
379 	PIN_FIELD_BASE(109, 109, 2, 0x0090, 0x10, 11, 1),
380 	PIN_FIELD_BASE(110, 110, 2, 0x00a0, 0x10, 16, 1),
381 	PIN_FIELD_BASE(111, 111, 2, 0x00a0, 0x10, 18, 1),
382 	PIN_FIELD_BASE(112, 112, 2, 0x00a0, 0x10, 15, 1),
383 	PIN_FIELD_BASE(113, 113, 2, 0x00a0, 0x10, 17, 1),
384 	PIN_FIELD_BASE(114, 115, 2, 0x0090, 0x10, 26, 1),
385 	PIN_FIELD_BASE(116, 117, 2, 0x0090, 0x10, 21, 1),
386 	PIN_FIELD_BASE(118, 118, 2, 0x0090, 0x10, 31, 1),
387 	PIN_FIELD_BASE(119, 119, 2, 0x00a0, 0x10, 0, 1),
388 	PIN_FIELD_BASE(120, 121, 2, 0x0090, 0x10, 23, 1),
389 	PIN_FIELD_BASE(122, 123, 2, 0x0090, 0x10, 28, 1),
390 	PIN_FIELD_BASE(124, 125, 2, 0x00a0, 0x10, 1, 1),
391 	PIN_FIELD_BASE(126, 127, 1, 0x0070, 0x10, 2, 1),
392 	PIN_FIELD_BASE(140, 141, 1, 0x0070, 0x10, 0, 1),
393 	PIN_FIELD_BASE(142, 142, 1, 0x0070, 0x10, 9, 1),
394 	PIN_FIELD_BASE(143, 143, 5, 0x0040, 0x10, 15, 1),
395 	PIN_FIELD_BASE(144, 144, 5, 0x0040, 0x10, 17, 1),
396 	PIN_FIELD_BASE(145, 145, 5, 0x0040, 0x10, 16, 1),
397 	PIN_FIELD_BASE(146, 146, 5, 0x0040, 0x10, 12, 1),
398 	PIN_FIELD_BASE(147, 155, 5, 0x0040, 0x10, 0, 1),
399 	PIN_FIELD_BASE(156, 157, 5, 0x0040, 0x10, 22, 1),
400 	PIN_FIELD_BASE(158, 158, 5, 0x0040, 0x10, 21, 1),
401 	PIN_FIELD_BASE(159, 159, 5, 0x0040, 0x10, 24, 1),
402 	PIN_FIELD_BASE(160, 161, 5, 0x0040, 0x10, 19, 1),
403 	PIN_FIELD_BASE(162, 166, 5, 0x0040, 0x10, 25, 1),
404 	PIN_FIELD_BASE(179, 179, 4, 0x0040, 0x10, 13, 1),
405 	PIN_FIELD_BASE(180, 180, 4, 0x0040, 0x10, 10, 1),
406 	PIN_FIELD_BASE(181, 183, 1, 0x0070, 0x10, 10, 1),
407 	PIN_FIELD_BASE(184, 184, 1, 0x0070, 0x10, 6, 1),
408 	PIN_FIELD_BASE(185, 185, 1, 0x0070, 0x10, 5, 1),
409 	PIN_FIELD_BASE(186, 186, 1, 0x0070, 0x10, 7, 1),
410 	PIN_FIELD_BASE(187, 187, 1, 0x0070, 0x10, 4, 1),
411 	PIN_FIELD_BASE(188, 188, 1, 0x0070, 0x10, 8, 1),
412 	PIN_FIELD_BASE(189, 189, 5, 0x0040, 0x10, 9, 1),
413 	PIN_FIELD_BASE(190, 190, 5, 0x0040, 0x10, 18, 1),
414 	PIN_FIELD_BASE(191, 192, 5, 0x0040, 0x10, 13, 1),
415 	PIN_FIELD_BASE(193, 194, 5, 0x0040, 0x10, 10, 1),
416 	PIN_FIELD_BASE(195, 195, 2, 0x0090, 0x10, 30, 1),
417 	PIN_FIELD_BASE(196, 196, 2, 0x0090, 0x10, 25, 1),
418 	PIN_FIELD_BASE(197, 197, 2, 0x00a0, 0x10, 3, 1),
419 	PIN_FIELD_BASE(198, 199, 4, 0x0040, 0x10, 14, 1),
420 	PIN_FIELD_BASE(200, 201, 6, 0x0080, 0x10, 7, 1),
421 	PIN_FIELD_BASE(202, 202, 4, 0x0040, 0x10, 9, 1),
422 };
423 
424 static const struct mtk_pin_field_calc mt6779_pin_pd_range[] = {
425 	PIN_FIELD_BASE(0, 9, 6, 0x0050, 0x10, 3, 1),
426 	PIN_FIELD_BASE(16, 16, 3, 0x0060, 0x10, 0, 1),
427 	PIN_FIELD_BASE(17, 18, 6, 0x0050, 0x10, 28, 1),
428 	PIN_FIELD_BASE(19, 19, 6, 0x0050, 0x10, 27, 1),
429 	PIN_FIELD_BASE(20, 20, 6, 0x0050, 0x10, 26, 1),
430 	PIN_FIELD_BASE(21, 24, 6, 0x0050, 0x10, 19, 1),
431 	PIN_FIELD_BASE(25, 25, 6, 0x0050, 0x10, 30, 1),
432 	PIN_FIELD_BASE(26, 26, 6, 0x0050, 0x10, 23, 1),
433 	PIN_FIELD_BASE(27, 27, 6, 0x0050, 0x10, 0, 1),
434 	PIN_FIELD_BASE(28, 29, 6, 0x0050, 0x10, 24, 1),
435 	PIN_FIELD_BASE(30, 30, 6, 0x0050, 0x10, 16, 1),
436 	PIN_FIELD_BASE(31, 31, 6, 0x0050, 0x10, 13, 1),
437 	PIN_FIELD_BASE(32, 32, 6, 0x0050, 0x10, 15, 1),
438 	PIN_FIELD_BASE(33, 33, 6, 0x0050, 0x10, 17, 1),
439 	PIN_FIELD_BASE(34, 34, 6, 0x0050, 0x10, 14, 1),
440 	PIN_FIELD_BASE(35, 35, 6, 0x0060, 0x10, 5, 1),
441 	PIN_FIELD_BASE(36, 36, 6, 0x0060, 0x10, 0, 1),
442 	PIN_FIELD_BASE(37, 37, 6, 0x0060, 0x10, 6, 1),
443 	PIN_FIELD_BASE(38, 41, 6, 0x0060, 0x10, 1, 1),
444 	PIN_FIELD_BASE(42, 43, 6, 0x0050, 0x10, 1, 1),
445 	PIN_FIELD_BASE(44, 44, 6, 0x0050, 0x10, 18, 1),
446 	PIN_FIELD_BASE(45, 45, 3, 0x0060, 0x10, 4, 1),
447 	PIN_FIELD_BASE(46, 46, 3, 0x0060, 0x10, 12, 1),
448 	PIN_FIELD_BASE(47, 47, 3, 0x0060, 0x10, 15, 1),
449 	PIN_FIELD_BASE(48, 48, 3, 0x0060, 0x10, 14, 1),
450 	PIN_FIELD_BASE(49, 49, 3, 0x0060, 0x10, 16, 1),
451 	PIN_FIELD_BASE(50, 50, 3, 0x0060, 0x10, 13, 1),
452 	PIN_FIELD_BASE(51, 51, 3, 0x0060, 0x10, 1, 1),
453 	PIN_FIELD_BASE(52, 52, 3, 0x0060, 0x10, 9, 1),
454 	PIN_FIELD_BASE(53, 54, 3, 0x0060, 0x10, 18, 1),
455 	PIN_FIELD_BASE(55, 55, 3, 0x0060, 0x10, 3, 1),
456 	PIN_FIELD_BASE(56, 56, 3, 0x0060, 0x10, 11, 1),
457 	PIN_FIELD_BASE(61, 61, 3, 0x0060, 0x10, 2, 1),
458 	PIN_FIELD_BASE(62, 62, 3, 0x0060, 0x10, 10, 1),
459 	PIN_FIELD_BASE(63, 63, 3, 0x0060, 0x10, 7, 1),
460 	PIN_FIELD_BASE(64, 64, 3, 0x0060, 0x10, 6, 1),
461 	PIN_FIELD_BASE(65, 65, 3, 0x0060, 0x10, 8, 1),
462 	PIN_FIELD_BASE(66, 66, 3, 0x0060, 0x10, 5, 1),
463 	PIN_FIELD_BASE(67, 67, 2, 0x0080, 0x10, 7, 1),
464 	PIN_FIELD_BASE(68, 68, 2, 0x0080, 0x10, 6, 1),
465 	PIN_FIELD_BASE(69, 69, 2, 0x0080, 0x10, 8, 1),
466 	PIN_FIELD_BASE(70, 71, 2, 0x0080, 0x10, 4, 1),
467 	PIN_FIELD_BASE(72, 72, 4, 0x0030, 0x10, 3, 1),
468 	PIN_FIELD_BASE(73, 73, 4, 0x0030, 0x10, 2, 1),
469 	PIN_FIELD_BASE(74, 74, 4, 0x0030, 0x10, 1, 1),
470 	PIN_FIELD_BASE(75, 75, 4, 0x0030, 0x10, 4, 1),
471 	PIN_FIELD_BASE(76, 76, 4, 0x0030, 0x10, 12, 1),
472 	PIN_FIELD_BASE(77, 77, 4, 0x0030, 0x10, 11, 1),
473 	PIN_FIELD_BASE(78, 78, 2, 0x0070, 0x10, 18, 1),
474 	PIN_FIELD_BASE(79, 79, 2, 0x0070, 0x10, 17, 1),
475 	PIN_FIELD_BASE(80, 81, 2, 0x0070, 0x10, 19, 1),
476 	PIN_FIELD_BASE(82, 88, 2, 0x0070, 0x10, 1, 1),
477 	PIN_FIELD_BASE(89, 89, 2, 0x0070, 0x10, 16, 1),
478 	PIN_FIELD_BASE(90, 90, 2, 0x0070, 0x10, 15, 1),
479 	PIN_FIELD_BASE(91, 91, 2, 0x0070, 0x10, 14, 1),
480 	PIN_FIELD_BASE(92, 92, 2, 0x0070, 0x10, 8, 1),
481 	PIN_FIELD_BASE(93, 93, 4, 0x0030, 0x10, 0, 1),
482 	PIN_FIELD_BASE(94, 94, 2, 0x0070, 0x10, 0, 1),
483 	PIN_FIELD_BASE(95, 95, 4, 0x0030, 0x10, 7, 1),
484 	PIN_FIELD_BASE(96, 96, 4, 0x0030, 0x10, 5, 1),
485 	PIN_FIELD_BASE(97, 97, 4, 0x0030, 0x10, 8, 1),
486 	PIN_FIELD_BASE(98, 98, 4, 0x0030, 0x10, 6, 1),
487 	PIN_FIELD_BASE(99, 99, 2, 0x0080, 0x10, 9, 1),
488 	PIN_FIELD_BASE(100, 100, 2, 0x0080, 0x10, 12, 1),
489 	PIN_FIELD_BASE(101, 101, 2, 0x0080, 0x10, 10, 1),
490 	PIN_FIELD_BASE(102, 102, 2, 0x0080, 0x10, 13, 1),
491 	PIN_FIELD_BASE(103, 103, 2, 0x0080, 0x10, 11, 1),
492 	PIN_FIELD_BASE(104, 104, 2, 0x0080, 0x10, 14, 1),
493 	PIN_FIELD_BASE(105, 105, 2, 0x0070, 0x10, 10, 1),
494 	PIN_FIELD_BASE(106, 106, 2, 0x0070, 0x10, 9, 1),
495 	PIN_FIELD_BASE(107, 108, 2, 0x0070, 0x10, 12, 1),
496 	PIN_FIELD_BASE(109, 109, 2, 0x0070, 0x10, 11, 1),
497 	PIN_FIELD_BASE(110, 110, 2, 0x0080, 0x10, 16, 1),
498 	PIN_FIELD_BASE(111, 111, 2, 0x0080, 0x10, 18, 1),
499 	PIN_FIELD_BASE(112, 112, 2, 0x0080, 0x10, 15, 1),
500 	PIN_FIELD_BASE(113, 113, 2, 0x0080, 0x10, 17, 1),
501 	PIN_FIELD_BASE(114, 115, 2, 0x0070, 0x10, 26, 1),
502 	PIN_FIELD_BASE(116, 117, 2, 0x0070, 0x10, 21, 1),
503 	PIN_FIELD_BASE(118, 118, 2, 0x0070, 0x10, 31, 1),
504 	PIN_FIELD_BASE(119, 119, 2, 0x0080, 0x10, 0, 1),
505 	PIN_FIELD_BASE(120, 121, 2, 0x0070, 0x10, 23, 1),
506 	PIN_FIELD_BASE(122, 123, 2, 0x0070, 0x10, 28, 1),
507 	PIN_FIELD_BASE(124, 125, 2, 0x0080, 0x10, 1, 1),
508 	PIN_FIELD_BASE(126, 127, 1, 0x0050, 0x10, 2, 1),
509 	PIN_FIELD_BASE(140, 141, 1, 0x0050, 0x10, 0, 1),
510 	PIN_FIELD_BASE(142, 142, 1, 0x0050, 0x10, 9, 1),
511 	PIN_FIELD_BASE(143, 143, 5, 0x0030, 0x10, 15, 1),
512 	PIN_FIELD_BASE(144, 144, 5, 0x0030, 0x10, 17, 1),
513 	PIN_FIELD_BASE(145, 145, 5, 0x0030, 0x10, 16, 1),
514 	PIN_FIELD_BASE(146, 146, 5, 0x0030, 0x10, 12, 1),
515 	PIN_FIELD_BASE(147, 155, 5, 0x0030, 0x10, 0, 1),
516 	PIN_FIELD_BASE(156, 157, 5, 0x0030, 0x10, 22, 1),
517 	PIN_FIELD_BASE(158, 158, 5, 0x0030, 0x10, 21, 1),
518 	PIN_FIELD_BASE(159, 159, 5, 0x0030, 0x10, 24, 1),
519 	PIN_FIELD_BASE(160, 161, 5, 0x0030, 0x10, 19, 1),
520 	PIN_FIELD_BASE(162, 166, 5, 0x0030, 0x10, 25, 1),
521 	PIN_FIELD_BASE(179, 179, 4, 0x0030, 0x10, 13, 1),
522 	PIN_FIELD_BASE(180, 180, 4, 0x0030, 0x10, 10, 1),
523 	PIN_FIELD_BASE(181, 183, 1, 0x0050, 0x10, 10, 1),
524 	PIN_FIELD_BASE(184, 184, 1, 0x0050, 0x10, 6, 1),
525 	PIN_FIELD_BASE(185, 185, 1, 0x0050, 0x10, 5, 1),
526 	PIN_FIELD_BASE(186, 186, 1, 0x0050, 0x10, 7, 1),
527 	PIN_FIELD_BASE(187, 187, 1, 0x0050, 0x10, 4, 1),
528 	PIN_FIELD_BASE(188, 188, 1, 0x0050, 0x10, 8, 1),
529 	PIN_FIELD_BASE(189, 189, 5, 0x0030, 0x10, 9, 1),
530 	PIN_FIELD_BASE(190, 190, 5, 0x0030, 0x10, 18, 1),
531 	PIN_FIELD_BASE(191, 192, 5, 0x0030, 0x10, 13, 1),
532 	PIN_FIELD_BASE(193, 194, 5, 0x0030, 0x10, 10, 1),
533 	PIN_FIELD_BASE(195, 195, 2, 0x0070, 0x10, 30, 1),
534 	PIN_FIELD_BASE(196, 196, 2, 0x0070, 0x10, 25, 1),
535 	PIN_FIELD_BASE(197, 197, 2, 0x0080, 0x10, 3, 1),
536 	PIN_FIELD_BASE(198, 199, 4, 0x0030, 0x10, 14, 1),
537 	PIN_FIELD_BASE(200, 201, 6, 0x0060, 0x10, 7, 1),
538 	PIN_FIELD_BASE(202, 202, 4, 0x0030, 0x10, 9, 1),
539 };
540 
541 static const struct mtk_pin_field_calc mt6779_pin_drv_range[] = {
542 	PINS_FIELD_BASE(0, 9, 6, 0x0000, 0x10, 9, 3),
543 	PIN_FIELD_BASE(10, 16, 3, 0x0000, 0x10, 0, 3),
544 	PINS_FIELD_BASE(17, 19, 6, 0x0010, 0x10, 3, 3),
545 	PIN_FIELD_BASE(20, 20, 6, 0x0010, 0x10, 6, 3),
546 	PINS_FIELD_BASE(21, 24, 6, 0x0000, 0x10, 21, 3),
547 	PIN_FIELD_BASE(25, 25, 6, 0x0010, 0x10, 9, 3),
548 	PIN_FIELD_BASE(26, 26, 6, 0x0000, 0x10, 24, 3),
549 	PIN_FIELD_BASE(27, 27, 6, 0x0000, 0x10, 0, 3),
550 	PIN_FIELD_BASE(28, 28, 6, 0x0000, 0x10, 27, 3),
551 	PIN_FIELD_BASE(29, 29, 6, 0x0010, 0x10, 0, 3),
552 	PINS_FIELD_BASE(30, 32, 6, 0x0000, 0x10, 12, 3),
553 	PIN_FIELD_BASE(33, 33, 6, 0x0000, 0x10, 15, 3),
554 	PIN_FIELD_BASE(34, 34, 6, 0x0000, 0x10, 12, 3),
555 	PINS_FIELD_BASE(35, 41, 6, 0x0010, 0x10, 12, 3),
556 	PIN_FIELD_BASE(42, 43, 6, 0x0000, 0x10, 3, 3),
557 	PIN_FIELD_BASE(44, 44, 6, 0x0000, 0x10, 18, 3),
558 	PIN_FIELD_BASE(45, 45, 3, 0x0010, 0x10, 12, 3),
559 	PIN_FIELD_BASE(46, 46, 3, 0x0020, 0x10, 0, 3),
560 	PINS_FIELD_BASE(47, 49, 3, 0x0020, 0x10, 3, 3),
561 	PIN_FIELD_BASE(50, 50, 3, 0x0020, 0x10, 6, 3),
562 	PIN_FIELD_BASE(51, 51, 3, 0x0010, 0x10, 3, 3),
563 	PIN_FIELD_BASE(52, 52, 3, 0x0010, 0x10, 21, 3),
564 	PINS_FIELD_BASE(53, 54, 3, 0x0020, 0x10, 9, 3),
565 	PIN_FIELD_BASE(55, 55, 3, 0x0010, 0x10, 9, 3),
566 	PIN_FIELD_BASE(56, 56, 3, 0x0010, 0x10, 27, 3),
567 	PIN_FIELD_BASE(57, 57, 3, 0x0010, 0x10, 0, 3),
568 	PIN_FIELD_BASE(58, 58, 3, 0x0000, 0x10, 27, 3),
569 	PIN_FIELD_BASE(59, 60, 3, 0x0000, 0x10, 21, 3),
570 	PIN_FIELD_BASE(61, 61, 3, 0x0010, 0x10, 6, 3),
571 	PIN_FIELD_BASE(62, 62, 3, 0x0010, 0x10, 24, 3),
572 	PINS_FIELD_BASE(63, 65, 3, 0x0010, 0x10, 15, 3),
573 	PIN_FIELD_BASE(66, 66, 3, 0x0010, 0x10, 18, 3),
574 	PINS_FIELD_BASE(67, 69, 2, 0x0010, 0x10, 3, 3),
575 	PIN_FIELD_BASE(70, 71, 2, 0x0010, 0x10, 0, 3),
576 	PINS_FIELD_BASE(72, 75, 4, 0x0000, 0x10, 0, 3),
577 	PINS_FIELD_BASE(76, 77, 4, 0x0000, 0x10, 15, 3),
578 	PINS_FIELD_BASE(78, 86, 2, 0x0000, 0x10, 3, 3),
579 	PINS_FIELD_BASE(87, 92, 2, 0x0000, 0x10, 6, 3),
580 	PIN_FIELD_BASE(93, 93, 4, 0x0000, 0x10, 3, 3),
581 	PIN_FIELD_BASE(94, 94, 2, 0x0000, 0x10, 6, 3),
582 	PINS_FIELD_BASE(95, 96, 4, 0x0000, 0x10, 6, 3),
583 	PINS_FIELD_BASE(97, 98, 4, 0x0000, 0x10, 9, 3),
584 	PINS_FIELD_BASE(99, 100, 2, 0x0010, 0x10, 6, 3),
585 	PINS_FIELD_BASE(101, 102, 2, 0x0010, 0x10, 9, 3),
586 	PINS_FIELD_BASE(103, 104, 2, 0x0010, 0x10, 12, 3),
587 	PINS_FIELD_BASE(105, 109, 2, 0x0000, 0x10, 0, 3),
588 	PIN_FIELD_BASE(110, 110, 2, 0x0010, 0x10, 18, 3),
589 	PIN_FIELD_BASE(111, 111, 2, 0x0010, 0x10, 24, 3),
590 	PIN_FIELD_BASE(112, 112, 2, 0x0010, 0x10, 15, 3),
591 	PIN_FIELD_BASE(113, 113, 2, 0x0010, 0x10, 21, 3),
592 	PINS_FIELD_BASE(114, 115, 2, 0x0000, 0x10, 12, 3),
593 	PIN_FIELD_BASE(116, 117, 2, 0x0000, 0x10, 15, 3),
594 	PINS_FIELD_BASE(118, 119, 2, 0x0000, 0x10, 12, 3),
595 	PIN_FIELD_BASE(120, 121, 2, 0x0000, 0x10, 21, 3),
596 	PINS_FIELD_BASE(122, 125, 2, 0x0000, 0x10, 9, 3),
597 	PINS_FIELD_BASE(126, 127, 1, 0x0000, 0x10, 12, 3),
598 	PIN_FIELD_BASE(128, 128, 1, 0x0000, 0x10, 29, 2),
599 	PIN_FIELD_BASE(129, 129, 1, 0x0010, 0x10, 0, 2),
600 	PIN_FIELD_BASE(130, 130, 1, 0x0000, 0x10, 27, 2),
601 	PIN_FIELD_BASE(131, 131, 1, 0x0010, 0x10, 2, 2),
602 	PIN_FIELD_BASE(132, 132, 1, 0x0010, 0x10, 6, 2),
603 	PIN_FIELD_BASE(133, 133, 1, 0x0010, 0x10, 4, 2),
604 	PIN_FIELD_BASE(134, 135, 1, 0x0000, 0x10, 3, 3),
605 	PINS_FIELD_BASE(136, 139, 1, 0x0000, 0x10, 9, 3),
606 	PINS_FIELD_BASE(140, 141, 1, 0x0000, 0x10, 0, 3),
607 	PIN_FIELD_BASE(142, 142, 1, 0x0000, 0x10, 24, 3),
608 	PINS_FIELD_BASE(143, 146, 5, 0x0000, 0x10, 3, 3),
609 	PINS_FIELD_BASE(147, 155, 5, 0x0000, 0x10, 0, 3),
610 	PIN_FIELD_BASE(156, 157, 5, 0x0000, 0x10, 21, 3),
611 	PIN_FIELD_BASE(158, 158, 5, 0x0000, 0x10, 15, 3),
612 	PIN_FIELD_BASE(159, 159, 5, 0x0000, 0x10, 27, 3),
613 	PIN_FIELD_BASE(160, 161, 5, 0x0000, 0x10, 9, 3),
614 	PINS_FIELD_BASE(162, 166, 5, 0x0000, 0x10, 18, 3),
615 	PIN_FIELD_BASE(167, 167, 7, 0x0000, 0x10, 3, 3),
616 	PINS_FIELD_BASE(168, 174, 7, 0x0000, 0x10, 6, 3),
617 	PIN_FIELD_BASE(175, 175, 7, 0x0000, 0x10, 9, 3),
618 	PIN_FIELD_BASE(176, 176, 7, 0x0000, 0x10, 0, 3),
619 	PINS_FIELD_BASE(177, 178, 7, 0x0000, 0x10, 6, 3),
620 	PIN_FIELD_BASE(179, 180, 4, 0x0000, 0x10, 15, 3),
621 	PIN_FIELD_BASE(181, 183, 1, 0x0010, 0x10, 8, 3),
622 	PINS_FIELD_BASE(184, 186, 1, 0x0000, 0x10, 15, 3),
623 	PIN_FIELD_BASE(187, 188, 1, 0x0000, 0x10, 18, 3),
624 	PIN_FIELD_BASE(189, 189, 5, 0x0000, 0x10, 6, 3),
625 	PINS_FIELD_BASE(190, 194, 5, 0x0000, 0x10, 3, 3),
626 	PIN_FIELD_BASE(195, 195, 2, 0x0000, 0x10, 9, 3),
627 	PIN_FIELD_BASE(196, 196, 2, 0x0000, 0x10, 27, 3),
628 	PIN_FIELD_BASE(197, 197, 2, 0x0000, 0x10, 9, 3),
629 	PIN_FIELD_BASE(198, 199, 4, 0x0000, 0x10, 21, 3),
630 	PINS_FIELD_BASE(200, 201, 6, 0x0010, 0x10, 15, 3),
631 	PIN_FIELD_BASE(202, 202, 4, 0x0000, 0x10, 12, 3),
632 };
633 
634 static const struct mtk_pin_field_calc mt6779_pin_pupd_range[] = {
635 	PIN_FIELD_BASE(10, 15, 3, 0x0070, 0x10, 0, 1),
636 	PIN_FIELD_BASE(57, 57, 3, 0x0070, 0x10, 9, 1),
637 	PIN_FIELD_BASE(58, 58, 3, 0x0070, 0x10, 8, 1),
638 	PIN_FIELD_BASE(59, 60, 3, 0x0070, 0x10, 6, 1),
639 	PIN_FIELD_BASE(128, 129, 1, 0x0060, 0x10, 7, 1),
640 	PIN_FIELD_BASE(130, 130, 1, 0x0060, 0x10, 6, 1),
641 	PIN_FIELD_BASE(131, 131, 1, 0x0060, 0x10, 9, 1),
642 	PIN_FIELD_BASE(132, 132, 1, 0x0060, 0x10, 11, 1),
643 	PIN_FIELD_BASE(133, 133, 1, 0x0060, 0x10, 10, 1),
644 	PIN_FIELD_BASE(134, 135, 1, 0x0060, 0x10, 0, 1),
645 	PIN_FIELD_BASE(136, 136, 1, 0x0060, 0x10, 5, 1),
646 	PIN_FIELD_BASE(137, 137, 1, 0x0060, 0x10, 2, 1),
647 	PIN_FIELD_BASE(138, 138, 1, 0x0060, 0x10, 4, 1),
648 	PIN_FIELD_BASE(139, 139, 1, 0x0060, 0x10, 3, 1),
649 	PIN_FIELD_BASE(167, 168, 7, 0x0020, 0x10, 1, 1),
650 	PIN_FIELD_BASE(169, 169, 7, 0x0020, 0x10, 4, 1),
651 	PIN_FIELD_BASE(170, 170, 7, 0x0020, 0x10, 6, 1),
652 	PIN_FIELD_BASE(171, 171, 7, 0x0020, 0x10, 8, 1),
653 	PIN_FIELD_BASE(172, 172, 7, 0x0020, 0x10, 3, 1),
654 	PIN_FIELD_BASE(173, 173, 7, 0x0020, 0x10, 7, 1),
655 	PIN_FIELD_BASE(174, 175, 7, 0x0020, 0x10, 9, 1),
656 	PIN_FIELD_BASE(176, 176, 7, 0x0020, 0x10, 0, 1),
657 	PIN_FIELD_BASE(177, 177, 7, 0x0020, 0x10, 5, 1),
658 	PIN_FIELD_BASE(178, 178, 7, 0x0020, 0x10, 11, 1),
659 };
660 
661 static const struct mtk_pin_field_calc mt6779_pin_r0_range[] = {
662 	PIN_FIELD_BASE(10, 15, 3, 0x0090, 0x10, 0, 1),
663 	PIN_FIELD_BASE(57, 57, 3, 0x0090, 0x10, 9, 1),
664 	PIN_FIELD_BASE(58, 58, 3, 0x0090, 0x10, 8, 1),
665 	PIN_FIELD_BASE(59, 60, 3, 0x0090, 0x10, 6, 1),
666 	PIN_FIELD_BASE(128, 129, 1, 0x0080, 0x10, 7, 1),
667 	PIN_FIELD_BASE(130, 130, 1, 0x0080, 0x10, 6, 1),
668 	PIN_FIELD_BASE(131, 131, 1, 0x0080, 0x10, 9, 1),
669 	PIN_FIELD_BASE(132, 132, 1, 0x0080, 0x10, 11, 1),
670 	PIN_FIELD_BASE(133, 133, 1, 0x0080, 0x10, 10, 1),
671 	PIN_FIELD_BASE(134, 135, 1, 0x0080, 0x10, 0, 1),
672 	PIN_FIELD_BASE(136, 136, 1, 0x0080, 0x10, 5, 1),
673 	PIN_FIELD_BASE(137, 137, 1, 0x0080, 0x10, 2, 1),
674 	PIN_FIELD_BASE(138, 138, 1, 0x0080, 0x10, 4, 1),
675 	PIN_FIELD_BASE(139, 139, 1, 0x0080, 0x10, 3, 1),
676 	PIN_FIELD_BASE(167, 168, 7, 0x0030, 0x10, 1, 1),
677 	PIN_FIELD_BASE(169, 169, 7, 0x0030, 0x10, 4, 1),
678 	PIN_FIELD_BASE(170, 170, 7, 0x0030, 0x10, 6, 1),
679 	PIN_FIELD_BASE(171, 171, 7, 0x0030, 0x10, 8, 1),
680 	PIN_FIELD_BASE(172, 172, 7, 0x0030, 0x10, 3, 1),
681 	PIN_FIELD_BASE(173, 173, 7, 0x0030, 0x10, 7, 1),
682 	PIN_FIELD_BASE(174, 175, 7, 0x0030, 0x10, 9, 1),
683 	PIN_FIELD_BASE(176, 176, 7, 0x0030, 0x10, 0, 1),
684 	PIN_FIELD_BASE(177, 177, 7, 0x0030, 0x10, 5, 1),
685 	PIN_FIELD_BASE(178, 178, 7, 0x0030, 0x10, 11, 1),
686 };
687 
688 static const struct mtk_pin_field_calc mt6779_pin_r1_range[] = {
689 	PIN_FIELD_BASE(10, 15, 3, 0x00a0, 0x10, 0, 1),
690 	PIN_FIELD_BASE(57, 57, 3, 0x00a0, 0x10, 9, 1),
691 	PIN_FIELD_BASE(58, 58, 3, 0x00a0, 0x10, 8, 1),
692 	PIN_FIELD_BASE(59, 60, 3, 0x00a0, 0x10, 6, 1),
693 	PIN_FIELD_BASE(128, 129, 1, 0x0090, 0x10, 7, 1),
694 	PIN_FIELD_BASE(130, 130, 1, 0x0090, 0x10, 6, 1),
695 	PIN_FIELD_BASE(131, 131, 1, 0x0090, 0x10, 9, 1),
696 	PIN_FIELD_BASE(132, 132, 1, 0x0090, 0x10, 11, 1),
697 	PIN_FIELD_BASE(133, 133, 1, 0x0090, 0x10, 10, 1),
698 	PIN_FIELD_BASE(134, 135, 1, 0x0090, 0x10, 0, 1),
699 	PIN_FIELD_BASE(136, 136, 1, 0x0090, 0x10, 5, 1),
700 	PIN_FIELD_BASE(137, 137, 1, 0x0090, 0x10, 2, 1),
701 	PIN_FIELD_BASE(138, 138, 1, 0x0090, 0x10, 4, 1),
702 	PIN_FIELD_BASE(139, 139, 1, 0x0090, 0x10, 3, 1),
703 	PIN_FIELD_BASE(167, 168, 7, 0x0040, 0x10, 1, 1),
704 	PIN_FIELD_BASE(169, 169, 7, 0x0040, 0x10, 4, 1),
705 	PIN_FIELD_BASE(170, 170, 7, 0x0040, 0x10, 6, 1),
706 	PIN_FIELD_BASE(171, 171, 7, 0x0040, 0x10, 8, 1),
707 	PIN_FIELD_BASE(172, 172, 7, 0x0040, 0x10, 3, 1),
708 	PIN_FIELD_BASE(173, 173, 7, 0x0040, 0x10, 7, 1),
709 	PIN_FIELD_BASE(174, 175, 7, 0x0040, 0x10, 9, 1),
710 	PIN_FIELD_BASE(176, 176, 7, 0x0040, 0x10, 0, 1),
711 	PIN_FIELD_BASE(177, 177, 7, 0x0040, 0x10, 5, 1),
712 	PIN_FIELD_BASE(178, 178, 7, 0x0040, 0x10, 11, 1),
713 };
714 
715 static const struct mtk_pin_reg_calc mt6779_reg_cals[PINCTRL_PIN_REG_MAX] = {
716 	[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt6779_pin_mode_range),
717 	[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt6779_pin_dir_range),
718 	[PINCTRL_PIN_REG_DI] = MTK_RANGE(mt6779_pin_di_range),
719 	[PINCTRL_PIN_REG_DO] = MTK_RANGE(mt6779_pin_do_range),
720 	[PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt6779_pin_smt_range),
721 	[PINCTRL_PIN_REG_IES] = MTK_RANGE(mt6779_pin_ies_range),
722 	[PINCTRL_PIN_REG_PU] = MTK_RANGE(mt6779_pin_pu_range),
723 	[PINCTRL_PIN_REG_PD] = MTK_RANGE(mt6779_pin_pd_range),
724 	[PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt6779_pin_drv_range),
725 	[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt6779_pin_pupd_range),
726 	[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt6779_pin_r0_range),
727 	[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt6779_pin_r1_range),
728 };
729 
730 static const char * const mt6779_pinctrl_register_base_names[] = {
731 	"gpio", "iocfg_rm", "iocfg_br", "iocfg_lm", "iocfg_lb",
732 	"iocfg_rt", "iocfg_lt", "iocfg_tl",
733 };
734 
735 static const struct mtk_eint_hw mt6779_eint_hw = {
736 	.port_mask = 7,
737 	.ports     = 6,
738 	.ap_num    = 195,
739 	.db_cnt    = 13,
740 };
741 
742 static const struct mtk_pin_soc mt6779_data = {
743 	.reg_cal = mt6779_reg_cals,
744 	.pins = mtk_pins_mt6779,
745 	.npins = ARRAY_SIZE(mtk_pins_mt6779),
746 	.ngrps = ARRAY_SIZE(mtk_pins_mt6779),
747 	.eint_hw = &mt6779_eint_hw,
748 	.gpio_m = 0,
749 	.ies_present = true,
750 	.base_names = mt6779_pinctrl_register_base_names,
751 	.nbase_names = ARRAY_SIZE(mt6779_pinctrl_register_base_names),
752 	.bias_set_combo = mtk_pinconf_bias_set_combo,
753 	.bias_get_combo = mtk_pinconf_bias_get_combo,
754 	.drive_set = mtk_pinconf_drive_set_raw,
755 	.drive_get = mtk_pinconf_drive_get_raw,
756 	.adv_pull_get = mtk_pinconf_adv_pull_get,
757 	.adv_pull_set = mtk_pinconf_adv_pull_set,
758 };
759 
760 static const struct of_device_id mt6779_pinctrl_of_match[] = {
761 	{ .compatible = "mediatek,mt6779-pinctrl", },
762 	{ }
763 };
764 
mt6779_pinctrl_probe(struct platform_device * pdev)765 static int mt6779_pinctrl_probe(struct platform_device *pdev)
766 {
767 	return mtk_paris_pinctrl_probe(pdev, &mt6779_data);
768 }
769 
770 static struct platform_driver mt6779_pinctrl_driver = {
771 	.driver = {
772 		.name = "mt6779-pinctrl",
773 		.of_match_table = mt6779_pinctrl_of_match,
774 	},
775 	.probe = mt6779_pinctrl_probe,
776 };
777 
mt6779_pinctrl_init(void)778 static int __init mt6779_pinctrl_init(void)
779 {
780 	return platform_driver_register(&mt6779_pinctrl_driver);
781 }
782 arch_initcall(mt6779_pinctrl_init);
783 
784 MODULE_LICENSE("GPL v2");
785 MODULE_DESCRIPTION("MediaTek MT6779 Pinctrl Driver");
786