blob: 6b9769067b09ad2abc89f7c5a861c5551016b94d [file] [log] [blame]
developer22073352022-09-09 19:59:55 +08001// SPDX-License-Identifier: GPL-2.0
2/*
3 * The MT7981 driver based on Linux generic pinctrl binding.
4 *
5 * Copyright (C) 2022 MediaTek Inc.
6 * Author: Sam Shih <sam.shih@mediatek.com>
7 */
8
9#include <dm.h>
10#include "pinctrl-mtk-common.h"
11
12#define MT7981_TYPE0_PIN(_number, _name) \
13 MTK_TYPED_PIN(_number, _name, DRV_GRP4, IO_TYPE_GRP0)
14
15#define MT7981_TYPE1_PIN(_number, _name) \
16 MTK_TYPED_PIN(_number, _name, DRV_GRP4, IO_TYPE_GRP1)
17
18#define PIN_FIELD_GPIO(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits) \
19 PIN_FIELD_BASE_CALC(_s_pin, _e_pin, GPIO_BASE, _s_addr, _x_addrs, \
20 _s_bit, _x_bits, 32, 0)
21
22#define PIN_FIELD_BASE(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, _s_bit, \
23 _x_bits) \
24 PIN_FIELD_BASE_CALC(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, _s_bit, \
25 _x_bits, 32, 0)
26
27/**
28 * enum - Locking variants of the iocfg bases
29 *
30 * MT7981 have multiple bases to program pin configuration listed as the below:
31 * iocfg_rt:0x11c00000, iocfg_rm:0x11c10000, iocfg_rb:0x11d20000,
32 * iocfg_lb:0x11e00000, iocfg_bl:0x11e20000, iocfg_tm:0x11f00000,
33 * iocfg_tl:0x11f10000,
34 * _i_based could be used to indicate what base the pin should be mapped into.
35 *
36 * Each iocfg register base control different group of pads on the SoC
37 *
38 *
39 * chip carrier
40 *
41 * A B C D E F G H
42 * +------------------------+
43 * 8 | o o o o o o o o |
44 * 7 | o o o o o o o o |
45 * 6 | o o o o o o o o |
46 * 5 | o o o o o o o o |
47 * 4 | o o o o o o o o |
48 * 3 | o o o o o o o o |
49 * 2 | o o o o o o o o |
50 * 1 | o o o o o o o o |
51 * +------------------------+
52 *
53 * inside Chip carrier
54 *
55 * A B C D E F G H
56 * +------------------------+
57 * 8 | |
58 * 7 | TL TM |
59 * 6 | +---------+ |
60 * 5 | | | RT |
61 * 4 | | | RM |
62 * 3 | LB | | RB |
63 * 2 | +---------+ |
64 * 1 | BL |
65 * +------------------------+
66 *
67 */
68
69enum {
70 GPIO_BASE,
71 IOCFG_RT_BASE,
72 IOCFG_RM_BASE,
73 IOCFG_RB_BASE,
74 IOCFG_LB_BASE,
75 IOCFG_BL_BASE,
76 IOCFG_TM_BASE,
77 IOCFG_TL_BASE,
78};
79
80static const struct mtk_pin_field_calc mt7981_pin_mode_range[] = {
81 PIN_FIELD_GPIO(0, 56, 0x300, 0x10, 0, 4),
82};
83
84static const struct mtk_pin_field_calc mt7981_pin_dir_range[] = {
85 PIN_FIELD_GPIO(0, 56, 0x0, 0x10, 0, 1),
86};
87
88static const struct mtk_pin_field_calc mt7981_pin_di_range[] = {
89 PIN_FIELD_GPIO(0, 56, 0x200, 0x10, 0, 1),
90};
91
92static const struct mtk_pin_field_calc mt7981_pin_do_range[] = {
93 PIN_FIELD_GPIO(0, 56, 0x100, 0x10, 0, 1),
94};
95
96static const struct mtk_pin_field_calc mt7981_pin_ies_range[] = {
97 PIN_FIELD_BASE(0, 0, 1, 0x10, 0x10, 1, 1),
98 PIN_FIELD_BASE(1, 1, 1, 0x10, 0x10, 0, 1),
99 PIN_FIELD_BASE(2, 2, 5, 0x20, 0x10, 6, 1),
100 PIN_FIELD_BASE(3, 3, 4, 0x20, 0x10, 6, 1),
101 PIN_FIELD_BASE(4, 4, 4, 0x20, 0x10, 2, 1),
102 PIN_FIELD_BASE(5, 5, 4, 0x20, 0x10, 1, 1),
103 PIN_FIELD_BASE(6, 6, 4, 0x20, 0x10, 3, 1),
104 PIN_FIELD_BASE(7, 7, 4, 0x20, 0x10, 0, 1),
105 PIN_FIELD_BASE(8, 8, 4, 0x20, 0x10, 4, 1),
106 PIN_FIELD_BASE(9, 9, 4, 0x20, 0x10, 9, 1),
107
108 PIN_FIELD_BASE(10, 10, 5, 0x20, 0x10, 8, 1),
109 PIN_FIELD_BASE(11, 11, 5, 0x40, 0x10, 10, 1),
110 PIN_FIELD_BASE(12, 12, 5, 0x20, 0x10, 7, 1),
111 PIN_FIELD_BASE(13, 13, 5, 0x20, 0x10, 11, 1),
112
113 PIN_FIELD_BASE(14, 14, 4, 0x20, 0x10, 8, 1),
114
115 PIN_FIELD_BASE(15, 15, 2, 0x20, 0x10, 0, 1),
116 PIN_FIELD_BASE(16, 16, 2, 0x20, 0x10, 1, 1),
117 PIN_FIELD_BASE(17, 17, 2, 0x20, 0x10, 5, 1),
118 PIN_FIELD_BASE(18, 18, 2, 0x20, 0x10, 4, 1),
119 PIN_FIELD_BASE(19, 19, 2, 0x20, 0x10, 2, 1),
120 PIN_FIELD_BASE(20, 20, 2, 0x20, 0x10, 3, 1),
121 PIN_FIELD_BASE(21, 21, 2, 0x20, 0x10, 6, 1),
122 PIN_FIELD_BASE(22, 22, 2, 0x20, 0x10, 7, 1),
123 PIN_FIELD_BASE(23, 23, 2, 0x20, 0x10, 10, 1),
124 PIN_FIELD_BASE(24, 24, 2, 0x20, 0x10, 9, 1),
125 PIN_FIELD_BASE(25, 25, 2, 0x20, 0x10, 8, 1),
126
127 PIN_FIELD_BASE(26, 26, 5, 0x20, 0x10, 0, 1),
128 PIN_FIELD_BASE(27, 27, 5, 0x20, 0x10, 4, 1),
129 PIN_FIELD_BASE(28, 28, 5, 0x20, 0x10, 3, 1),
130 PIN_FIELD_BASE(29, 29, 5, 0x20, 0x10, 1, 1),
131 PIN_FIELD_BASE(30, 30, 5, 0x20, 0x10, 2, 1),
132 PIN_FIELD_BASE(31, 31, 5, 0x20, 0x10, 5, 1),
133
134 PIN_FIELD_BASE(32, 32, 1, 0x10, 0x10, 2, 1),
135 PIN_FIELD_BASE(33, 33, 1, 0x10, 0x10, 3, 1),
136
137 PIN_FIELD_BASE(34, 34, 4, 0x20, 0x10, 5, 1),
138 PIN_FIELD_BASE(35, 35, 4, 0x20, 0x10, 7, 1),
139
140 PIN_FIELD_BASE(36, 36, 3, 0x10, 0x10, 2, 1),
141 PIN_FIELD_BASE(37, 37, 3, 0x10, 0x10, 3, 1),
142 PIN_FIELD_BASE(38, 38, 3, 0x10, 0x10, 0, 1),
143 PIN_FIELD_BASE(39, 39, 3, 0x10, 0x10, 1, 1),
144
145 PIN_FIELD_BASE(40, 40, 7, 0x30, 0x10, 1, 1),
146 PIN_FIELD_BASE(41, 41, 7, 0x30, 0x10, 0, 1),
147 PIN_FIELD_BASE(42, 42, 7, 0x30, 0x10, 9, 1),
148 PIN_FIELD_BASE(43, 43, 7, 0x30, 0x10, 7, 1),
149 PIN_FIELD_BASE(44, 44, 7, 0x30, 0x10, 8, 1),
150 PIN_FIELD_BASE(45, 45, 7, 0x30, 0x10, 3, 1),
151 PIN_FIELD_BASE(46, 46, 7, 0x30, 0x10, 4, 1),
152 PIN_FIELD_BASE(47, 47, 7, 0x30, 0x10, 5, 1),
153 PIN_FIELD_BASE(48, 48, 7, 0x30, 0x10, 6, 1),
154 PIN_FIELD_BASE(49, 49, 7, 0x30, 0x10, 2, 1),
155
156 PIN_FIELD_BASE(50, 50, 6, 0x10, 0x10, 0, 1),
157 PIN_FIELD_BASE(51, 51, 6, 0x10, 0x10, 2, 1),
158 PIN_FIELD_BASE(52, 52, 6, 0x10, 0x10, 3, 1),
159 PIN_FIELD_BASE(53, 53, 6, 0x10, 0x10, 4, 1),
160 PIN_FIELD_BASE(54, 54, 6, 0x10, 0x10, 5, 1),
161 PIN_FIELD_BASE(55, 55, 6, 0x10, 0x10, 6, 1),
162 PIN_FIELD_BASE(56, 56, 6, 0x10, 0x10, 1, 1),
163};
164
165static const struct mtk_pin_field_calc mt7981_pin_smt_range[] = {
166 PIN_FIELD_BASE(0, 0, 1, 0x60, 0x10, 1, 1),
167 PIN_FIELD_BASE(1, 1, 1, 0x60, 0x10, 0, 1),
168 PIN_FIELD_BASE(2, 2, 5, 0x90, 0x10, 6, 1),
169 PIN_FIELD_BASE(3, 3, 4, 0x80, 0x10, 6, 1),
170 PIN_FIELD_BASE(4, 4, 4, 0x80, 0x10, 2, 1),
171 PIN_FIELD_BASE(5, 5, 4, 0x80, 0x10, 1, 1),
172 PIN_FIELD_BASE(6, 6, 4, 0x80, 0x10, 3, 1),
173 PIN_FIELD_BASE(7, 7, 4, 0x80, 0x10, 0, 1),
174 PIN_FIELD_BASE(8, 8, 4, 0x80, 0x10, 4, 1),
175 PIN_FIELD_BASE(9, 9, 4, 0x80, 0x10, 9, 1),
176
177 PIN_FIELD_BASE(10, 10, 5, 0x90, 0x10, 8, 1),
178 PIN_FIELD_BASE(11, 11, 5, 0x90, 0x10, 10, 1),
179 PIN_FIELD_BASE(12, 12, 5, 0x90, 0x10, 7, 1),
180 PIN_FIELD_BASE(13, 13, 5, 0x90, 0x10, 11, 1),
181
182 PIN_FIELD_BASE(14, 14, 4, 0x80, 0x10, 8, 1),
183
184 PIN_FIELD_BASE(15, 15, 2, 0x90, 0x10, 0, 1),
185 PIN_FIELD_BASE(16, 16, 2, 0x90, 0x10, 1, 1),
186 PIN_FIELD_BASE(17, 17, 2, 0x90, 0x10, 5, 1),
187 PIN_FIELD_BASE(18, 18, 2, 0x90, 0x10, 4, 1),
188 PIN_FIELD_BASE(19, 19, 2, 0x90, 0x10, 2, 1),
189 PIN_FIELD_BASE(20, 20, 2, 0x90, 0x10, 3, 1),
190 PIN_FIELD_BASE(21, 21, 2, 0x90, 0x10, 6, 1),
191 PIN_FIELD_BASE(22, 22, 2, 0x90, 0x10, 7, 1),
192 PIN_FIELD_BASE(23, 23, 2, 0x90, 0x10, 10, 1),
193 PIN_FIELD_BASE(24, 24, 2, 0x90, 0x10, 9, 1),
194 PIN_FIELD_BASE(25, 25, 2, 0x90, 0x10, 8, 1),
195
196 PIN_FIELD_BASE(26, 26, 5, 0x90, 0x10, 0, 1),
197 PIN_FIELD_BASE(27, 27, 5, 0x90, 0x10, 4, 1),
198 PIN_FIELD_BASE(28, 28, 5, 0x90, 0x10, 3, 1),
199 PIN_FIELD_BASE(29, 29, 5, 0x90, 0x10, 1, 1),
200 PIN_FIELD_BASE(30, 30, 5, 0x90, 0x10, 2, 1),
201 PIN_FIELD_BASE(31, 31, 5, 0x90, 0x10, 5, 1),
202
203 PIN_FIELD_BASE(32, 32, 1, 0x60, 0x10, 2, 1),
204 PIN_FIELD_BASE(33, 33, 1, 0x60, 0x10, 3, 1),
205
206 PIN_FIELD_BASE(34, 34, 4, 0x80, 0x10, 5, 1),
207 PIN_FIELD_BASE(35, 35, 4, 0x80, 0x10, 7, 1),
208
209 PIN_FIELD_BASE(36, 36, 3, 0x60, 0x10, 2, 1),
210 PIN_FIELD_BASE(37, 37, 3, 0x60, 0x10, 3, 1),
211 PIN_FIELD_BASE(38, 38, 3, 0x60, 0x10, 0, 1),
212 PIN_FIELD_BASE(39, 39, 3, 0x60, 0x10, 1, 1),
213
214 PIN_FIELD_BASE(40, 40, 7, 0x70, 0x10, 1, 1),
215 PIN_FIELD_BASE(41, 41, 7, 0x70, 0x10, 0, 1),
216 PIN_FIELD_BASE(42, 42, 7, 0x70, 0x10, 9, 1),
217 PIN_FIELD_BASE(43, 43, 7, 0x70, 0x10, 7, 1),
218 PIN_FIELD_BASE(44, 44, 7, 0x30, 0x10, 8, 1),
219 PIN_FIELD_BASE(45, 45, 7, 0x70, 0x10, 3, 1),
220 PIN_FIELD_BASE(46, 46, 7, 0x70, 0x10, 4, 1),
221 PIN_FIELD_BASE(47, 47, 7, 0x70, 0x10, 5, 1),
222 PIN_FIELD_BASE(48, 48, 7, 0x70, 0x10, 6, 1),
223 PIN_FIELD_BASE(49, 49, 7, 0x70, 0x10, 2, 1),
224
225 PIN_FIELD_BASE(50, 50, 6, 0x50, 0x10, 0, 1),
226 PIN_FIELD_BASE(51, 51, 6, 0x50, 0x10, 2, 1),
227 PIN_FIELD_BASE(52, 52, 6, 0x50, 0x10, 3, 1),
228 PIN_FIELD_BASE(53, 53, 6, 0x50, 0x10, 4, 1),
229 PIN_FIELD_BASE(54, 54, 6, 0x50, 0x10, 5, 1),
230 PIN_FIELD_BASE(55, 55, 6, 0x50, 0x10, 6, 1),
231 PIN_FIELD_BASE(56, 56, 6, 0x50, 0x10, 1, 1),
232};
233
234static const struct mtk_pin_field_calc mt7981_pin_pu_range[] = {
235 PIN_FIELD_BASE(40, 40, 7, 0x50, 0x10, 1, 1),
236 PIN_FIELD_BASE(41, 41, 7, 0x50, 0x10, 0, 1),
237 PIN_FIELD_BASE(42, 42, 7, 0x50, 0x10, 9, 1),
238 PIN_FIELD_BASE(43, 43, 7, 0x50, 0x10, 7, 1),
239 PIN_FIELD_BASE(44, 44, 7, 0x50, 0x10, 8, 1),
240 PIN_FIELD_BASE(45, 45, 7, 0x50, 0x10, 3, 1),
241 PIN_FIELD_BASE(46, 46, 7, 0x50, 0x10, 4, 1),
242 PIN_FIELD_BASE(47, 47, 7, 0x50, 0x10, 5, 1),
243 PIN_FIELD_BASE(48, 48, 7, 0x50, 0x10, 6, 1),
244 PIN_FIELD_BASE(49, 49, 7, 0x50, 0x10, 2, 1),
245
246 PIN_FIELD_BASE(50, 50, 6, 0x30, 0x10, 0, 1),
247 PIN_FIELD_BASE(51, 51, 6, 0x30, 0x10, 2, 1),
248 PIN_FIELD_BASE(52, 52, 6, 0x30, 0x10, 3, 1),
249 PIN_FIELD_BASE(53, 53, 6, 0x30, 0x10, 4, 1),
250 PIN_FIELD_BASE(54, 54, 6, 0x30, 0x10, 5, 1),
251 PIN_FIELD_BASE(55, 55, 6, 0x30, 0x10, 6, 1),
252 PIN_FIELD_BASE(56, 56, 6, 0x30, 0x10, 1, 1),
253};
254
255static const struct mtk_pin_field_calc mt7981_pin_pd_range[] = {
256 PIN_FIELD_BASE(40, 40, 7, 0x40, 0x10, 1, 1),
257 PIN_FIELD_BASE(41, 41, 7, 0x40, 0x10, 0, 1),
258 PIN_FIELD_BASE(42, 42, 7, 0x40, 0x10, 9, 1),
259 PIN_FIELD_BASE(43, 43, 7, 0x40, 0x10, 7, 1),
260 PIN_FIELD_BASE(44, 44, 7, 0x40, 0x10, 8, 1),
261 PIN_FIELD_BASE(45, 45, 7, 0x40, 0x10, 3, 1),
262 PIN_FIELD_BASE(46, 46, 7, 0x40, 0x10, 4, 1),
263 PIN_FIELD_BASE(47, 47, 7, 0x40, 0x10, 5, 1),
264 PIN_FIELD_BASE(48, 48, 7, 0x40, 0x10, 6, 1),
265 PIN_FIELD_BASE(49, 49, 7, 0x40, 0x10, 2, 1),
266
267 PIN_FIELD_BASE(50, 50, 6, 0x20, 0x10, 0, 1),
268 PIN_FIELD_BASE(51, 51, 6, 0x20, 0x10, 2, 1),
269 PIN_FIELD_BASE(52, 52, 6, 0x20, 0x10, 3, 1),
270 PIN_FIELD_BASE(53, 53, 6, 0x20, 0x10, 4, 1),
271 PIN_FIELD_BASE(54, 54, 6, 0x20, 0x10, 5, 1),
272 PIN_FIELD_BASE(55, 55, 6, 0x20, 0x10, 6, 1),
273 PIN_FIELD_BASE(56, 56, 6, 0x20, 0x10, 1, 1),
274};
275
276static const struct mtk_pin_field_calc mt7981_pin_drv_range[] = {
277 PIN_FIELD_BASE(0, 0, 1, 0x00, 0x10, 3, 3),
278 PIN_FIELD_BASE(1, 1, 1, 0x00, 0x10, 0, 3),
279
280 PIN_FIELD_BASE(2, 2, 5, 0x00, 0x10, 18, 3),
281
282 PIN_FIELD_BASE(3, 3, 4, 0x00, 0x10, 18, 1),
283 PIN_FIELD_BASE(4, 4, 4, 0x00, 0x10, 6, 1),
284 PIN_FIELD_BASE(5, 5, 4, 0x00, 0x10, 3, 3),
285 PIN_FIELD_BASE(6, 6, 4, 0x00, 0x10, 9, 3),
286 PIN_FIELD_BASE(7, 7, 4, 0x00, 0x10, 0, 3),
287 PIN_FIELD_BASE(8, 8, 4, 0x00, 0x10, 12, 3),
288 PIN_FIELD_BASE(9, 9, 4, 0x00, 0x10, 27, 3),
289
290 PIN_FIELD_BASE(10, 10, 5, 0x00, 0x10, 24, 3),
291 PIN_FIELD_BASE(11, 11, 5, 0x00, 0x10, 0, 3),
292 PIN_FIELD_BASE(12, 12, 5, 0x00, 0x10, 21, 3),
293 PIN_FIELD_BASE(13, 13, 5, 0x00, 0x10, 3, 3),
294
295 PIN_FIELD_BASE(14, 14, 4, 0x00, 0x10, 27, 3),
296
297 PIN_FIELD_BASE(15, 15, 2, 0x00, 0x10, 0, 3),
298 PIN_FIELD_BASE(16, 16, 2, 0x00, 0x10, 3, 3),
299 PIN_FIELD_BASE(17, 17, 2, 0x00, 0x10, 15, 3),
300 PIN_FIELD_BASE(18, 18, 2, 0x00, 0x10, 12, 3),
301 PIN_FIELD_BASE(19, 19, 2, 0x00, 0x10, 6, 3),
302 PIN_FIELD_BASE(20, 20, 2, 0x00, 0x10, 9, 3),
303 PIN_FIELD_BASE(21, 21, 2, 0x00, 0x10, 18, 3),
304 PIN_FIELD_BASE(22, 22, 2, 0x00, 0x10, 21, 3),
305 PIN_FIELD_BASE(23, 23, 2, 0x00, 0x10, 0, 3),
306 PIN_FIELD_BASE(24, 24, 2, 0x00, 0x10, 27, 3),
307 PIN_FIELD_BASE(25, 25, 2, 0x00, 0x10, 24, 3),
308
309 PIN_FIELD_BASE(26, 26, 5, 0x00, 0x10, 0, 3),
310 PIN_FIELD_BASE(27, 27, 5, 0x00, 0x10, 12, 3),
311 PIN_FIELD_BASE(28, 28, 5, 0x00, 0x10, 9, 3),
312 PIN_FIELD_BASE(29, 29, 5, 0x00, 0x10, 3, 3),
313 PIN_FIELD_BASE(30, 30, 5, 0x00, 0x10, 6, 3),
314 PIN_FIELD_BASE(31, 31, 5, 0x00, 0x10, 15, 3),
315
316 PIN_FIELD_BASE(32, 32, 1, 0x00, 0x10, 9, 3),
317 PIN_FIELD_BASE(33, 33, 1, 0x00, 0x10, 12, 3),
318
319 PIN_FIELD_BASE(34, 34, 4, 0x00, 0x10, 15, 3),
320 PIN_FIELD_BASE(35, 35, 4, 0x00, 0x10, 21, 3),
321
322 PIN_FIELD_BASE(36, 36, 3, 0x00, 0x10, 6, 3),
323 PIN_FIELD_BASE(37, 37, 3, 0x00, 0x10, 9, 3),
324 PIN_FIELD_BASE(38, 38, 3, 0x00, 0x10, 0, 3),
325 PIN_FIELD_BASE(39, 39, 3, 0x00, 0x10, 3, 3),
326
327 PIN_FIELD_BASE(40, 40, 7, 0x00, 0x10, 3, 3),
328 PIN_FIELD_BASE(41, 41, 7, 0x00, 0x10, 0, 3),
329 PIN_FIELD_BASE(42, 42, 7, 0x00, 0x10, 27, 3),
330 PIN_FIELD_BASE(43, 43, 7, 0x00, 0x10, 21, 3),
331 PIN_FIELD_BASE(44, 44, 7, 0x00, 0x10, 24, 3),
332 PIN_FIELD_BASE(45, 45, 7, 0x00, 0x10, 9, 3),
333 PIN_FIELD_BASE(46, 46, 7, 0x00, 0x10, 12, 3),
334 PIN_FIELD_BASE(47, 47, 7, 0x00, 0x10, 15, 3),
335 PIN_FIELD_BASE(48, 48, 7, 0x00, 0x10, 18, 3),
336 PIN_FIELD_BASE(49, 49, 7, 0x00, 0x10, 6, 3),
337
338 PIN_FIELD_BASE(50, 50, 6, 0x00, 0x10, 0, 3),
339 PIN_FIELD_BASE(51, 51, 6, 0x00, 0x10, 6, 3),
340 PIN_FIELD_BASE(52, 52, 6, 0x00, 0x10, 9, 3),
341 PIN_FIELD_BASE(53, 53, 6, 0x00, 0x10, 12, 3),
342 PIN_FIELD_BASE(54, 54, 6, 0x00, 0x10, 15, 3),
343 PIN_FIELD_BASE(55, 55, 6, 0x00, 0x10, 18, 3),
344 PIN_FIELD_BASE(56, 56, 6, 0x00, 0x10, 3, 3),
345};
346
347static const struct mtk_pin_field_calc mt7981_pin_pupd_range[] = {
348 PIN_FIELD_BASE(0, 0, 1, 0x20, 0x10, 1, 1),
349 PIN_FIELD_BASE(1, 1, 1, 0x20, 0x10, 0, 1),
350 PIN_FIELD_BASE(2, 2, 5, 0x30, 0x10, 6, 1),
351 PIN_FIELD_BASE(3, 3, 4, 0x30, 0x10, 6, 1),
352 PIN_FIELD_BASE(4, 4, 4, 0x30, 0x10, 2, 1),
353 PIN_FIELD_BASE(5, 5, 4, 0x30, 0x10, 1, 1),
354 PIN_FIELD_BASE(6, 6, 4, 0x30, 0x10, 3, 1),
355 PIN_FIELD_BASE(7, 7, 4, 0x30, 0x10, 0, 1),
356 PIN_FIELD_BASE(8, 8, 4, 0x30, 0x10, 4, 1),
357 PIN_FIELD_BASE(9, 9, 4, 0x30, 0x10, 9, 1),
358
359 PIN_FIELD_BASE(10, 10, 5, 0x30, 0x10, 8, 1),
360 PIN_FIELD_BASE(11, 11, 5, 0x30, 0x10, 10, 1),
361 PIN_FIELD_BASE(12, 12, 5, 0x30, 0x10, 7, 1),
362 PIN_FIELD_BASE(13, 13, 5, 0x30, 0x10, 11, 1),
363
364 PIN_FIELD_BASE(14, 14, 4, 0x30, 0x10, 8, 1),
365
366 PIN_FIELD_BASE(15, 15, 2, 0x30, 0x10, 0, 1),
367 PIN_FIELD_BASE(16, 16, 2, 0x30, 0x10, 1, 1),
368 PIN_FIELD_BASE(17, 17, 2, 0x30, 0x10, 5, 1),
369 PIN_FIELD_BASE(18, 18, 2, 0x30, 0x10, 4, 1),
370 PIN_FIELD_BASE(19, 19, 2, 0x30, 0x10, 2, 1),
371 PIN_FIELD_BASE(20, 20, 2, 0x90, 0x10, 3, 1),
372 PIN_FIELD_BASE(21, 21, 2, 0x30, 0x10, 6, 1),
373 PIN_FIELD_BASE(22, 22, 2, 0x30, 0x10, 7, 1),
374 PIN_FIELD_BASE(23, 23, 2, 0x30, 0x10, 10, 1),
375 PIN_FIELD_BASE(24, 24, 2, 0x30, 0x10, 9, 1),
376 PIN_FIELD_BASE(25, 25, 2, 0x30, 0x10, 8, 1),
377
378 PIN_FIELD_BASE(26, 26, 5, 0x30, 0x10, 0, 1),
379 PIN_FIELD_BASE(27, 27, 5, 0x30, 0x10, 4, 1),
380 PIN_FIELD_BASE(28, 28, 5, 0x30, 0x10, 3, 1),
381 PIN_FIELD_BASE(29, 29, 5, 0x30, 0x10, 1, 1),
382 PIN_FIELD_BASE(30, 30, 5, 0x30, 0x10, 2, 1),
383 PIN_FIELD_BASE(31, 31, 5, 0x30, 0x10, 5, 1),
384
385 PIN_FIELD_BASE(32, 32, 1, 0x20, 0x10, 2, 1),
386 PIN_FIELD_BASE(33, 33, 1, 0x20, 0x10, 3, 1),
387
388 PIN_FIELD_BASE(34, 34, 4, 0x30, 0x10, 5, 1),
389 PIN_FIELD_BASE(35, 35, 4, 0x30, 0x10, 7, 1),
390
391 PIN_FIELD_BASE(36, 36, 3, 0x20, 0x10, 2, 1),
392 PIN_FIELD_BASE(37, 37, 3, 0x20, 0x10, 3, 1),
393 PIN_FIELD_BASE(38, 38, 3, 0x20, 0x10, 0, 1),
394 PIN_FIELD_BASE(39, 39, 3, 0x20, 0x10, 1, 1),
395};
396
397static const struct mtk_pin_field_calc mt7981_pin_r0_range[] = {
398 PIN_FIELD_BASE(0, 0, 1, 0x30, 0x10, 1, 1),
399 PIN_FIELD_BASE(1, 1, 1, 0x30, 0x10, 0, 1),
400 PIN_FIELD_BASE(2, 2, 5, 0x40, 0x10, 6, 1),
401 PIN_FIELD_BASE(3, 3, 4, 0x40, 0x10, 6, 1),
402 PIN_FIELD_BASE(4, 4, 4, 0x40, 0x10, 2, 1),
403 PIN_FIELD_BASE(5, 5, 4, 0x40, 0x10, 1, 1),
404 PIN_FIELD_BASE(6, 6, 4, 0x40, 0x10, 3, 1),
405 PIN_FIELD_BASE(7, 7, 4, 0x40, 0x10, 0, 1),
406 PIN_FIELD_BASE(8, 8, 4, 0x40, 0x10, 4, 1),
407 PIN_FIELD_BASE(9, 9, 4, 0x40, 0x10, 9, 1),
408
409 PIN_FIELD_BASE(10, 10, 5, 0x40, 0x10, 8, 1),
410 PIN_FIELD_BASE(11, 11, 5, 0x40, 0x10, 10, 1),
411 PIN_FIELD_BASE(12, 12, 5, 0x40, 0x10, 7, 1),
412 PIN_FIELD_BASE(13, 13, 5, 0x40, 0x10, 11, 1),
413
414 PIN_FIELD_BASE(14, 14, 4, 0x40, 0x10, 8, 1),
415
416 PIN_FIELD_BASE(15, 15, 2, 0x40, 0x10, 0, 1),
417 PIN_FIELD_BASE(16, 16, 2, 0x40, 0x10, 1, 1),
418 PIN_FIELD_BASE(17, 17, 2, 0x40, 0x10, 5, 1),
419 PIN_FIELD_BASE(18, 18, 2, 0x40, 0x10, 4, 1),
420 PIN_FIELD_BASE(19, 19, 2, 0x40, 0x10, 2, 1),
421 PIN_FIELD_BASE(20, 20, 2, 0x40, 0x10, 3, 1),
422 PIN_FIELD_BASE(21, 21, 2, 0x40, 0x10, 6, 1),
423 PIN_FIELD_BASE(22, 22, 2, 0x40, 0x10, 7, 1),
424 PIN_FIELD_BASE(23, 23, 2, 0x40, 0x10, 10, 1),
425 PIN_FIELD_BASE(24, 24, 2, 0x40, 0x10, 9, 1),
426 PIN_FIELD_BASE(25, 25, 2, 0x40, 0x10, 8, 1),
427
428 PIN_FIELD_BASE(26, 26, 5, 0x40, 0x10, 0, 1),
429 PIN_FIELD_BASE(27, 27, 5, 0x40, 0x10, 4, 1),
430 PIN_FIELD_BASE(28, 28, 5, 0x40, 0x10, 3, 1),
431 PIN_FIELD_BASE(29, 29, 5, 0x40, 0x10, 1, 1),
432 PIN_FIELD_BASE(30, 30, 5, 0x40, 0x10, 2, 1),
433 PIN_FIELD_BASE(31, 31, 5, 0x40, 0x10, 5, 1),
434
435 PIN_FIELD_BASE(32, 32, 1, 0x30, 0x10, 2, 1),
436 PIN_FIELD_BASE(33, 33, 1, 0x30, 0x10, 3, 1),
437
438 PIN_FIELD_BASE(34, 34, 4, 0x40, 0x10, 5, 1),
439 PIN_FIELD_BASE(35, 35, 4, 0x40, 0x10, 7, 1),
440
441 PIN_FIELD_BASE(36, 36, 3, 0x30, 0x10, 2, 1),
442 PIN_FIELD_BASE(37, 37, 3, 0x30, 0x10, 3, 1),
443 PIN_FIELD_BASE(38, 38, 3, 0x30, 0x10, 0, 1),
444 PIN_FIELD_BASE(39, 39, 3, 0x30, 0x10, 1, 1),
445};
446
447static const struct mtk_pin_field_calc mt7981_pin_r1_range[] = {
448 PIN_FIELD_BASE(0, 0, 1, 0x40, 0x10, 1, 1),
449 PIN_FIELD_BASE(1, 1, 1, 0x40, 0x10, 0, 1),
450 PIN_FIELD_BASE(2, 2, 5, 0x50, 0x10, 6, 1),
451 PIN_FIELD_BASE(3, 3, 4, 0x50, 0x10, 6, 1),
452 PIN_FIELD_BASE(4, 4, 4, 0x50, 0x10, 2, 1),
453 PIN_FIELD_BASE(5, 5, 4, 0x50, 0x10, 1, 1),
454 PIN_FIELD_BASE(6, 6, 4, 0x50, 0x10, 3, 1),
455 PIN_FIELD_BASE(7, 7, 4, 0x50, 0x10, 0, 1),
456 PIN_FIELD_BASE(8, 8, 4, 0x50, 0x10, 4, 1),
457 PIN_FIELD_BASE(9, 9, 4, 0x50, 0x10, 9, 1),
458
459 PIN_FIELD_BASE(10, 10, 5, 0x50, 0x10, 8, 1),
460 PIN_FIELD_BASE(11, 11, 5, 0x50, 0x10, 10, 1),
461 PIN_FIELD_BASE(12, 12, 5, 0x50, 0x10, 7, 1),
462 PIN_FIELD_BASE(13, 13, 5, 0x50, 0x10, 11, 1),
463
464 PIN_FIELD_BASE(14, 14, 4, 0x50, 0x10, 8, 1),
465
466 PIN_FIELD_BASE(15, 15, 2, 0x50, 0x10, 0, 1),
467 PIN_FIELD_BASE(16, 16, 2, 0x50, 0x10, 1, 1),
468 PIN_FIELD_BASE(17, 17, 2, 0x50, 0x10, 5, 1),
469 PIN_FIELD_BASE(18, 18, 2, 0x50, 0x10, 4, 1),
470 PIN_FIELD_BASE(19, 19, 2, 0x50, 0x10, 2, 1),
471 PIN_FIELD_BASE(20, 20, 2, 0x50, 0x10, 3, 1),
472 PIN_FIELD_BASE(21, 21, 2, 0x50, 0x10, 6, 1),
473 PIN_FIELD_BASE(22, 22, 2, 0x50, 0x10, 7, 1),
474 PIN_FIELD_BASE(23, 23, 2, 0x50, 0x10, 10, 1),
475 PIN_FIELD_BASE(24, 24, 2, 0x50, 0x10, 9, 1),
476 PIN_FIELD_BASE(25, 25, 2, 0x50, 0x10, 8, 1),
477
478 PIN_FIELD_BASE(26, 26, 5, 0x50, 0x10, 0, 1),
479 PIN_FIELD_BASE(27, 27, 5, 0x50, 0x10, 4, 1),
480 PIN_FIELD_BASE(28, 28, 5, 0x50, 0x10, 3, 1),
481 PIN_FIELD_BASE(29, 29, 5, 0x50, 0x10, 1, 1),
482 PIN_FIELD_BASE(30, 30, 5, 0x50, 0x10, 2, 1),
483 PIN_FIELD_BASE(31, 31, 5, 0x50, 0x10, 5, 1),
484
485 PIN_FIELD_BASE(32, 32, 1, 0x40, 0x10, 2, 1),
486 PIN_FIELD_BASE(33, 33, 1, 0x40, 0x10, 3, 1),
487
488 PIN_FIELD_BASE(34, 34, 4, 0x50, 0x10, 5, 1),
489 PIN_FIELD_BASE(35, 35, 4, 0x50, 0x10, 7, 1),
490
491 PIN_FIELD_BASE(36, 36, 3, 0x40, 0x10, 2, 1),
492 PIN_FIELD_BASE(37, 37, 3, 0x40, 0x10, 3, 1),
493 PIN_FIELD_BASE(38, 38, 3, 0x40, 0x10, 0, 1),
494 PIN_FIELD_BASE(39, 39, 3, 0x40, 0x10, 1, 1),
495};
496
497static const struct mtk_pin_reg_calc mt7981_reg_cals[] = {
498 [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt7981_pin_mode_range),
499 [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt7981_pin_dir_range),
500 [PINCTRL_PIN_REG_DI] = MTK_RANGE(mt7981_pin_di_range),
501 [PINCTRL_PIN_REG_DO] = MTK_RANGE(mt7981_pin_do_range),
502 [PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt7981_pin_smt_range),
503 [PINCTRL_PIN_REG_IES] = MTK_RANGE(mt7981_pin_ies_range),
504 [PINCTRL_PIN_REG_PU] = MTK_RANGE(mt7981_pin_pu_range),
505 [PINCTRL_PIN_REG_PD] = MTK_RANGE(mt7981_pin_pd_range),
506 [PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt7981_pin_drv_range),
507 [PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt7981_pin_pupd_range),
508 [PINCTRL_PIN_REG_R0] = MTK_RANGE(mt7981_pin_r0_range),
509 [PINCTRL_PIN_REG_R1] = MTK_RANGE(mt7981_pin_r1_range),
510};
511
512static const struct mtk_pin_desc mt7981_pins[] = {
513 MT7981_TYPE0_PIN(0, "GPIO_WPS"),
514 MT7981_TYPE0_PIN(1, "GPIO_RESET"),
515 MT7981_TYPE0_PIN(2, "SYS_WATCHDOG"),
516 MT7981_TYPE0_PIN(3, "PCIE_PERESET_N"),
517 MT7981_TYPE0_PIN(4, "JTAG_JTDO"),
518 MT7981_TYPE0_PIN(5, "JTAG_JTDI"),
519 MT7981_TYPE0_PIN(6, "JTAG_JTMS"),
520 MT7981_TYPE0_PIN(7, "JTAG_JTCLK"),
521 MT7981_TYPE0_PIN(8, "JTAG_JTRST_N"),
522 MT7981_TYPE0_PIN(9, "WO_JTAG_JTDO"),
523 MT7981_TYPE0_PIN(10, "WO_JTAG_JTDI"),
524 MT7981_TYPE0_PIN(11, "WO_JTAG_JTMS"),
525 MT7981_TYPE0_PIN(12, "WO_JTAG_JTCLK"),
526 MT7981_TYPE0_PIN(13, "WO_JTAG_JTRST_N"),
527 MT7981_TYPE0_PIN(14, "USB_VBUS"),
528 MT7981_TYPE0_PIN(15, "PWM0"),
529 MT7981_TYPE0_PIN(16, "SPI0_CLK"),
530 MT7981_TYPE0_PIN(17, "SPI0_MOSI"),
531 MT7981_TYPE0_PIN(18, "SPI0_MISO"),
532 MT7981_TYPE0_PIN(19, "SPI0_CS"),
533 MT7981_TYPE0_PIN(20, "SPI0_HOLD"),
534 MT7981_TYPE0_PIN(21, "SPI0_WP"),
535 MT7981_TYPE0_PIN(22, "SPI1_CLK"),
536 MT7981_TYPE0_PIN(23, "SPI1_MOSI"),
537 MT7981_TYPE0_PIN(24, "SPI1_MISO"),
538 MT7981_TYPE0_PIN(25, "SPI1_CS"),
539 MT7981_TYPE0_PIN(26, "SPI2_CLK"),
540 MT7981_TYPE0_PIN(27, "SPI2_MOSI"),
541 MT7981_TYPE0_PIN(28, "SPI2_MISO"),
542 MT7981_TYPE0_PIN(29, "SPI2_CS"),
543 MT7981_TYPE0_PIN(30, "SPI2_HOLD"),
544 MT7981_TYPE0_PIN(31, "SPI2_WP"),
545 MT7981_TYPE0_PIN(32, "UART0_RXD"),
546 MT7981_TYPE0_PIN(33, "UART0_TXD"),
547 MT7981_TYPE0_PIN(34, "PCIE_CLK_REQ"),
548 MT7981_TYPE0_PIN(35, "PCIE_WAKE_N"),
549 MT7981_TYPE0_PIN(36, "SMI_MDC"),
550 MT7981_TYPE0_PIN(37, "SMI_MDIO"),
551 MT7981_TYPE0_PIN(38, "GBE_INT"),
552 MT7981_TYPE0_PIN(39, "GBE_RESET"),
553 MT7981_TYPE1_PIN(40, "WF_DIG_RESETB"),
554 MT7981_TYPE1_PIN(41, "WF_CBA_RESETB"),
555 MT7981_TYPE1_PIN(42, "WF_XO_REQ"),
556 MT7981_TYPE1_PIN(43, "WF_TOP_CLK"),
557 MT7981_TYPE1_PIN(44, "WF_TOP_DATA"),
558 MT7981_TYPE1_PIN(45, "WF_HB1"),
559 MT7981_TYPE1_PIN(46, "WF_HB2"),
560 MT7981_TYPE1_PIN(47, "WF_HB3"),
561 MT7981_TYPE1_PIN(48, "WF_HB4"),
562 MT7981_TYPE1_PIN(49, "WF_HB0"),
563 MT7981_TYPE1_PIN(50, "WF_HB0_B"),
564 MT7981_TYPE1_PIN(51, "WF_HB5"),
565 MT7981_TYPE1_PIN(52, "WF_HB6"),
566 MT7981_TYPE1_PIN(53, "WF_HB7"),
567 MT7981_TYPE1_PIN(54, "WF_HB8"),
568 MT7981_TYPE1_PIN(55, "WF_HB9"),
569 MT7981_TYPE1_PIN(56, "WF_HB10"),
570};
571
developer6080c782025-01-24 11:39:02 +0800572/* List all groups consisting of these pins dedicated to the enablement of
573 * certain hardware block and the corresponding mode for all of the pins.
574 * The hardware probably has multiple combinations of these pinouts.
575 */
576
developer22073352022-09-09 19:59:55 +0800577/* WA_AICE */
developer67873bd2023-07-19 17:16:37 +0800578static const int mt7981_wa_aice1_pins[] = { 0, 1, };
579static const int mt7981_wa_aice1_funcs[] = { 2, 2, };
developer22073352022-09-09 19:59:55 +0800580
developer67873bd2023-07-19 17:16:37 +0800581static const int mt7981_wa_aice2_pins[] = { 0, 1, };
582static const int mt7981_wa_aice2_funcs[] = { 3, 3, };
developer22073352022-09-09 19:59:55 +0800583
developer67873bd2023-07-19 17:16:37 +0800584static const int mt7981_wa_aice3_pins[] = { 28, 29, };
585static const int mt7981_wa_aice3_funcs[] = { 3, 3, };
developer22073352022-09-09 19:59:55 +0800586
developer67873bd2023-07-19 17:16:37 +0800587static const int mt7981_wm_aice1_pins[] = { 9, 10, };
588static const int mt7981_wm_aice1_funcs[] = { 2, 2, };
developer22073352022-09-09 19:59:55 +0800589
developer67873bd2023-07-19 17:16:37 +0800590static const int mt7981_wm_aice2_pins[] = { 30, 31, };
591static const int mt7981_wm_aice2_funcs[] = { 5, 5, };
developer22073352022-09-09 19:59:55 +0800592
593/* WM_UART */
developer67873bd2023-07-19 17:16:37 +0800594static const int mt7981_wm_uart_0_pins[] = { 0, 1, };
595static const int mt7981_wm_uart_0_funcs[] = { 5, 5, };
developer22073352022-09-09 19:59:55 +0800596
developer67873bd2023-07-19 17:16:37 +0800597static const int mt7981_wm_uart_1_pins[] = { 20, 21, };
598static const int mt7981_wm_uart_1_funcs[] = { 4, 4, };
developer22073352022-09-09 19:59:55 +0800599
developer67873bd2023-07-19 17:16:37 +0800600static const int mt7981_wm_uart_2_pins[] = { 30, 31, };
601static const int mt7981_wm_uart_2_funcs[] = { 3, 3, };
developer22073352022-09-09 19:59:55 +0800602
603/* DFD */
developer67873bd2023-07-19 17:16:37 +0800604static const int mt7981_dfd_pins[] = { 0, 1, 4, 5, };
605static const int mt7981_dfd_funcs[] = { 5, 5, 6, 6, };
developer22073352022-09-09 19:59:55 +0800606
607/* SYS_WATCHDOG */
developer67873bd2023-07-19 17:16:37 +0800608static const int mt7981_watchdog_pins[] = { 2, };
609static const int mt7981_watchdog_funcs[] = { 1, };
developer22073352022-09-09 19:59:55 +0800610
developer67873bd2023-07-19 17:16:37 +0800611static const int mt7981_watchdog1_pins[] = { 13, };
612static const int mt7981_watchdog1_funcs[] = { 5, };
developer22073352022-09-09 19:59:55 +0800613
614/* PCIE_PERESET_N */
developer67873bd2023-07-19 17:16:37 +0800615static const int mt7981_pcie_pereset_pins[] = { 3, };
616static const int mt7981_pcie_pereset_funcs[] = { 1, };
developer22073352022-09-09 19:59:55 +0800617
618/* JTAG */
developer67873bd2023-07-19 17:16:37 +0800619static const int mt7981_jtag_pins[] = { 4, 5, 6, 7, 8, };
620static const int mt7981_jtag_funcs[] = { 1, 1, 1, 1, 1, };
developer22073352022-09-09 19:59:55 +0800621
622/* WM_JTAG */
developer67873bd2023-07-19 17:16:37 +0800623static const int mt7981_wm_jtag_0_pins[] = { 4, 5, 6, 7, 8, };
624static const int mt7981_wm_jtag_0_funcs[] = { 2, 2, 2, 2, 2, };
developer22073352022-09-09 19:59:55 +0800625
developer67873bd2023-07-19 17:16:37 +0800626static const int mt7981_wm_jtag_1_pins[] = { 20, 21, 22, 23, 24, };
627static const int mt7981_wm_jtag_1_funcs[] = { 5, 5, 5, 5, 5, };
developer22073352022-09-09 19:59:55 +0800628
629/* WO0_JTAG */
developer67873bd2023-07-19 17:16:37 +0800630static const int mt7981_wo0_jtag_0_pins[] = { 9, 10, 11, 12, 13, };
631static const int mt7981_wo0_jtag_0_funcs[] = { 1, 1, 1, 1, 1, };
developer22073352022-09-09 19:59:55 +0800632
developer67873bd2023-07-19 17:16:37 +0800633static const int mt7981_wo0_jtag_1_pins[] = { 25, 26, 27, 28, 29, };
634static const int mt7981_wo0_jtag_1_funcs[] = { 5, 5, 5, 5, 5, };
developer22073352022-09-09 19:59:55 +0800635
636/* UART2 */
developer67873bd2023-07-19 17:16:37 +0800637static const int mt7981_uart2_0_pins[] = { 4, 5, 6, 7, };
638static const int mt7981_uart2_0_funcs[] = { 3, 3, 3, 3, };
developer22073352022-09-09 19:59:55 +0800639
developer6080c782025-01-24 11:39:02 +0800640static const int mt7981_uart2_0_tx_rx_pins[] = { 4, 5, };
641static const int mt7981_uart2_0_tx_rx_funcs[] = { 3, 3, };
642
developer22073352022-09-09 19:59:55 +0800643/* GBE_LED0 */
developer67873bd2023-07-19 17:16:37 +0800644static const int mt7981_gbe_led0_pins[] = { 8, };
645static const int mt7981_gbe_led0_funcs[] = { 3, };
developer22073352022-09-09 19:59:55 +0800646
647/* PTA_EXT */
developer67873bd2023-07-19 17:16:37 +0800648static const int mt7981_pta_ext_0_pins[] = { 4, 5, 6, };
649static const int mt7981_pta_ext_0_funcs[] = { 4, 4, 4, };
developer22073352022-09-09 19:59:55 +0800650
developer67873bd2023-07-19 17:16:37 +0800651static const int mt7981_pta_ext_1_pins[] = { 22, 23, 24, };
652static const int mt7981_pta_ext_1_funcs[] = { 4, 4, 4, };
developer22073352022-09-09 19:59:55 +0800653
654/* PWM2 */
developer67873bd2023-07-19 17:16:37 +0800655static const int mt7981_pwm2_pins[] = { 7, };
656static const int mt7981_pwm2_funcs[] = { 4, };
developer22073352022-09-09 19:59:55 +0800657
658/* NET_WO0_UART_TXD */
developer67873bd2023-07-19 17:16:37 +0800659static const int mt7981_net_wo0_uart_txd_0_pins[] = { 8, };
660static const int mt7981_net_wo0_uart_txd_0_funcs[] = { 4, };
developer22073352022-09-09 19:59:55 +0800661
developer67873bd2023-07-19 17:16:37 +0800662static const int mt7981_net_wo0_uart_txd_1_pins[] = { 14, };
663static const int mt7981_net_wo0_uart_txd_1_funcs[] = { 3, };
developer22073352022-09-09 19:59:55 +0800664
developer67873bd2023-07-19 17:16:37 +0800665static const int mt7981_net_wo0_uart_txd_2_pins[] = { 15, };
666static const int mt7981_net_wo0_uart_txd_2_funcs[] = { 4, };
developer22073352022-09-09 19:59:55 +0800667
668/* SPI1 */
developer67873bd2023-07-19 17:16:37 +0800669static const int mt7981_spi1_0_pins[] = { 4, 5, 6, 7, };
670static const int mt7981_spi1_0_funcs[] = { 5, 5, 5, 5, };
developer22073352022-09-09 19:59:55 +0800671
672/* I2C */
developer67873bd2023-07-19 17:16:37 +0800673static const int mt7981_i2c0_0_pins[] = { 6, 7, };
674static const int mt7981_i2c0_0_funcs[] = { 6, 6, };
developer22073352022-09-09 19:59:55 +0800675
developer67873bd2023-07-19 17:16:37 +0800676static const int mt7981_i2c0_1_pins[] = { 30, 31, };
677static const int mt7981_i2c0_1_funcs[] = { 4, 4, };
developer22073352022-09-09 19:59:55 +0800678
developer67873bd2023-07-19 17:16:37 +0800679static const int mt7981_i2c0_2_pins[] = { 36, 37, };
680static const int mt7981_i2c0_2_funcs[] = { 2, 2, };
developer22073352022-09-09 19:59:55 +0800681
developer67873bd2023-07-19 17:16:37 +0800682static const int mt7981_u2_phy_i2c_pins[] = { 30, 31, };
683static const int mt7981_u2_phy_i2c_funcs[] = { 6, 6, };
developer22073352022-09-09 19:59:55 +0800684
developer67873bd2023-07-19 17:16:37 +0800685static const int mt7981_u3_phy_i2c_pins[] = { 32, 33, };
686static const int mt7981_u3_phy_i2c_funcs[] = { 3, 3, };
developer22073352022-09-09 19:59:55 +0800687
developer67873bd2023-07-19 17:16:37 +0800688static const int mt7981_sgmii1_phy_i2c_pins[] = { 32, 33, };
689static const int mt7981_sgmii1_phy_i2c_funcs[] = { 2, 2, };
developer22073352022-09-09 19:59:55 +0800690
developer67873bd2023-07-19 17:16:37 +0800691static const int mt7981_sgmii0_phy_i2c_pins[] = { 32, 33, };
692static const int mt7981_sgmii0_phy_i2c_funcs[] = { 5, 5, };
developer22073352022-09-09 19:59:55 +0800693
694/* DFD_NTRST */
developer67873bd2023-07-19 17:16:37 +0800695static const int mt7981_dfd_ntrst_pins[] = { 8, };
696static const int mt7981_dfd_ntrst_funcs[] = { 6, };
developer22073352022-09-09 19:59:55 +0800697
698/* PWM0 */
developer67873bd2023-07-19 17:16:37 +0800699static const int mt7981_pwm0_0_pins[] = { 13, };
700static const int mt7981_pwm0_0_funcs[] = { 2, };
developer22073352022-09-09 19:59:55 +0800701
developer67873bd2023-07-19 17:16:37 +0800702static const int mt7981_pwm0_1_pins[] = { 15, };
703static const int mt7981_pwm0_1_funcs[] = { 1, };
developer22073352022-09-09 19:59:55 +0800704
705/* PWM1 */
developer67873bd2023-07-19 17:16:37 +0800706static const int mt7981_pwm1_0_pins[] = { 14, };
707static const int mt7981_pwm1_0_funcs[] = { 2, };
developer22073352022-09-09 19:59:55 +0800708
developer67873bd2023-07-19 17:16:37 +0800709static const int mt7981_pwm1_1_pins[] = { 15, };
710static const int mt7981_pwm1_1_funcs[] = { 3, };
developer22073352022-09-09 19:59:55 +0800711
712/* GBE_LED1 */
developer67873bd2023-07-19 17:16:37 +0800713static const int mt7981_gbe_led1_pins[] = { 13, };
714static const int mt7981_gbe_led1_funcs[] = { 3, };
developer22073352022-09-09 19:59:55 +0800715
716/* PCM */
developer67873bd2023-07-19 17:16:37 +0800717static const int mt7981_pcm_pins[] = { 9, 10, 11, 12, 13, 25 };
718static const int mt7981_pcm_funcs[] = { 4, 4, 4, 4, 4, 4, };
developer22073352022-09-09 19:59:55 +0800719
720/* UDI */
developer67873bd2023-07-19 17:16:37 +0800721static const int mt7981_udi_pins[] = { 9, 10, 11, 12, 13, };
722static const int mt7981_udi_funcs[] = { 6, 6, 6, 6, 6, };
developer22073352022-09-09 19:59:55 +0800723
724/* DRV_VBUS */
developer67873bd2023-07-19 17:16:37 +0800725static const int mt7981_drv_vbus_pins[] = { 14, };
726static const int mt7981_drv_vbus_funcs[] = { 1, };
developer22073352022-09-09 19:59:55 +0800727
728/* EMMC */
developer6080c782025-01-24 11:39:02 +0800729static const int mt7981_emmc_reset_pins[] = { 15, };
730static const int mt7981_emmc_reset_funcs[] = { 2, };
731
732static const int mt7981_emmc_4_pins[] = { 16, 17, 18, 19, 24, 25, };
733static const int mt7981_emmc_4_funcs[] = { 2, 2, 2, 2, 2, 2, };
734
735static const int mt7981_emmc_8_pins[] = {
736 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, };
737static const int mt7981_emmc_8_funcs[] = {
738 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, };
739
developer67873bd2023-07-19 17:16:37 +0800740static const int mt7981_emmc_45_pins[] = {
741 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, };
742static const int mt7981_emmc_45_funcs[] = {
743 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, };
developer22073352022-09-09 19:59:55 +0800744
745/* SNFI */
developer67873bd2023-07-19 17:16:37 +0800746static const int mt7981_snfi_pins[] = { 16, 17, 18, 19, 20, 21, };
747static const int mt7981_snfi_funcs[] = { 3, 3, 3, 3, 3, 3, };
developer22073352022-09-09 19:59:55 +0800748
749/* SPI0 */
developer67873bd2023-07-19 17:16:37 +0800750static const int mt7981_spi0_pins[] = { 16, 17, 18, 19, };
751static const int mt7981_spi0_funcs[] = { 1, 1, 1, 1, };
developer22073352022-09-09 19:59:55 +0800752
753/* SPI0 */
developer67873bd2023-07-19 17:16:37 +0800754static const int mt7981_spi0_wp_hold_pins[] = { 20, 21, };
755static const int mt7981_spi0_wp_hold_funcs[] = { 1, 1, };
developer22073352022-09-09 19:59:55 +0800756
757/* SPI1 */
developer67873bd2023-07-19 17:16:37 +0800758static const int mt7981_spi1_1_pins[] = { 22, 23, 24, 25, };
759static const int mt7981_spi1_1_funcs[] = { 1, 1, 1, 1, };
developer22073352022-09-09 19:59:55 +0800760
761/* SPI2 */
developer67873bd2023-07-19 17:16:37 +0800762static const int mt7981_spi2_pins[] = { 26, 27, 28, 29, };
763static const int mt7981_spi2_funcs[] = { 1, 1, 1, 1, };
developer22073352022-09-09 19:59:55 +0800764
765/* SPI2 */
developer67873bd2023-07-19 17:16:37 +0800766static const int mt7981_spi2_wp_hold_pins[] = { 30, 31, };
767static const int mt7981_spi2_wp_hold_funcs[] = { 1, 1, };
developer22073352022-09-09 19:59:55 +0800768
769/* UART1 */
developer67873bd2023-07-19 17:16:37 +0800770static const int mt7981_uart1_0_pins[] = { 16, 17, 18, 19, };
771static const int mt7981_uart1_0_funcs[] = { 4, 4, 4, 4, };
developer22073352022-09-09 19:59:55 +0800772
developer67873bd2023-07-19 17:16:37 +0800773static const int mt7981_uart1_1_pins[] = { 26, 27, 28, 29, };
774static const int mt7981_uart1_1_funcs[] = { 2, 2, 2, 2, };
developer22073352022-09-09 19:59:55 +0800775
developer6080c782025-01-24 11:39:02 +0800776static const int mt7981_uart1_2_pins[] = { 9, 10, };
777static const int mt7981_uart1_2_funcs[] = { 2, 2, };
778
779static const int mt7981_uart1_3_pins[] = { 26, 27, };
780static const int mt7981_uart1_3_funcs[] = { 2, 2, };
781
developer22073352022-09-09 19:59:55 +0800782/* UART2 */
developer67873bd2023-07-19 17:16:37 +0800783static const int mt7981_uart2_1_pins[] = { 22, 23, 24, 25, };
784static const int mt7981_uart2_1_funcs[] = { 3, 3, 3, 3, };
developer22073352022-09-09 19:59:55 +0800785
786/* UART0 */
developer67873bd2023-07-19 17:16:37 +0800787static const int mt7981_uart0_pins[] = { 32, 33, };
788static const int mt7981_uart0_funcs[] = { 1, 1, };
developer22073352022-09-09 19:59:55 +0800789
790/* PCIE_CLK_REQ */
developer67873bd2023-07-19 17:16:37 +0800791static const int mt7981_pcie_clk_pins[] = { 34, };
792static const int mt7981_pcie_clk_funcs[] = { 2, };
developer22073352022-09-09 19:59:55 +0800793
794/* PCIE_WAKE_N */
developer67873bd2023-07-19 17:16:37 +0800795static const int mt7981_pcie_wake_pins[] = { 35, };
796static const int mt7981_pcie_wake_funcs[] = { 2, };
developer22073352022-09-09 19:59:55 +0800797
798/* MDC_MDIO */
developer67873bd2023-07-19 17:16:37 +0800799static const int mt7981_smi_mdc_mdio_pins[] = { 36, 37, };
800static const int mt7981_smi_mdc_mdio_funcs[] = { 1, 1, };
developer22073352022-09-09 19:59:55 +0800801
developer67873bd2023-07-19 17:16:37 +0800802static const int mt7981_gbe_ext_mdc_mdio_pins[] = { 36, 37, };
803static const int mt7981_gbe_ext_mdc_mdio_funcs[] = { 3, 3, };
developer22073352022-09-09 19:59:55 +0800804
805/* WF0_MODE1 */
developer67873bd2023-07-19 17:16:37 +0800806static const int mt7981_wf0_mode1_pins[] = {
807 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56 };
808static const int mt7981_wf0_mode1_funcs[] = {
809 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
developer22073352022-09-09 19:59:55 +0800810
811/* WF0_MODE3 */
developer67873bd2023-07-19 17:16:37 +0800812static const int mt7981_wf0_mode3_pins[] = { 45, 46, 47, 48, 49, 51 };
813static const int mt7981_wf0_mode3_funcs[] = { 2, 2, 2, 2, 2, 2 };
developer22073352022-09-09 19:59:55 +0800814
815/* WF2G_LED */
developer67873bd2023-07-19 17:16:37 +0800816static const int mt7981_wf2g_led0_pins[] = { 30, };
817static const int mt7981_wf2g_led0_funcs[] = { 2, };
developer22073352022-09-09 19:59:55 +0800818
developer67873bd2023-07-19 17:16:37 +0800819static const int mt7981_wf2g_led1_pins[] = { 34, };
820static const int mt7981_wf2g_led1_funcs[] = { 1, };
developer22073352022-09-09 19:59:55 +0800821
822/* WF5G_LED */
developer67873bd2023-07-19 17:16:37 +0800823static const int mt7981_wf5g_led0_pins[] = { 31, };
824static const int mt7981_wf5g_led0_funcs[] = { 2, };
developer22073352022-09-09 19:59:55 +0800825
developer67873bd2023-07-19 17:16:37 +0800826static const int mt7981_wf5g_led1_pins[] = { 35, };
827static const int mt7981_wf5g_led1_funcs[] = { 1, };
developer22073352022-09-09 19:59:55 +0800828
829/* MT7531_INT */
developer67873bd2023-07-19 17:16:37 +0800830static const int mt7981_mt7531_int_pins[] = { 38, };
831static const int mt7981_mt7531_int_funcs[] = { 1, };
developer22073352022-09-09 19:59:55 +0800832
833/* ANT_SEL */
developer67873bd2023-07-19 17:16:37 +0800834static const int mt7981_ant_sel_pins[] = {
835 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 34, 35 };
836static const int mt7981_ant_sel_funcs[] = {
837 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 };
developer22073352022-09-09 19:59:55 +0800838
839static const struct mtk_group_desc mt7981_groups[] = {
840 /* @GPIO(0,1): WA_AICE(2) */
841 PINCTRL_PIN_GROUP("wa_aice1", mt7981_wa_aice1),
842 /* @GPIO(0,1): WA_AICE(3) */
843 PINCTRL_PIN_GROUP("wa_aice2", mt7981_wa_aice2),
844 /* @GPIO(0,1): WM_UART(5) */
845 PINCTRL_PIN_GROUP("wm_uart_0", mt7981_wm_uart_0),
846 /* @GPIO(0,1,4,5): DFD(6) */
847 PINCTRL_PIN_GROUP("dfd", mt7981_dfd),
848 /* @GPIO(2): SYS_WATCHDOG(1) */
849 PINCTRL_PIN_GROUP("watchdog", mt7981_watchdog),
850 /* @GPIO(3): PCIE_PERESET_N(1) */
851 PINCTRL_PIN_GROUP("pcie_pereset", mt7981_pcie_pereset),
852 /* @GPIO(4,8) JTAG(1) */
853 PINCTRL_PIN_GROUP("jtag", mt7981_jtag),
854 /* @GPIO(4,8) WM_JTAG(2) */
855 PINCTRL_PIN_GROUP("wm_jtag_0", mt7981_wm_jtag_0),
856 /* @GPIO(9,13) WO0_JTAG(1) */
857 PINCTRL_PIN_GROUP("wo0_jtag_0", mt7981_wo0_jtag_0),
858 /* @GPIO(4,7) WM_JTAG(3) */
859 PINCTRL_PIN_GROUP("uart2_0", mt7981_uart2_0),
developer6080c782025-01-24 11:39:02 +0800860 /* @GPIO(4,5) WM_JTAG(4) */
861 PINCTRL_PIN_GROUP("uart2_0_tx_rx", mt7981_uart2_0_tx_rx),
developer22073352022-09-09 19:59:55 +0800862 /* @GPIO(8) GBE_LED0(3) */
863 PINCTRL_PIN_GROUP("gbe_led0", mt7981_gbe_led0),
864 /* @GPIO(4,6) PTA_EXT(4) */
865 PINCTRL_PIN_GROUP("pta_ext_0", mt7981_pta_ext_0),
866 /* @GPIO(7) PWM2(4) */
867 PINCTRL_PIN_GROUP("pwm2", mt7981_pwm2),
868 /* @GPIO(8) NET_WO0_UART_TXD(4) */
869 PINCTRL_PIN_GROUP("net_wo0_uart_txd_0", mt7981_net_wo0_uart_txd_0),
870 /* @GPIO(4,7) SPI1(5) */
871 PINCTRL_PIN_GROUP("spi1_0", mt7981_spi1_0),
872 /* @GPIO(6,7) I2C(5) */
873 PINCTRL_PIN_GROUP("i2c0_0", mt7981_i2c0_0),
developer6080c782025-01-24 11:39:02 +0800874 /* @GPIO(0,1,4,5): DFD_NTRST(6) */
developer22073352022-09-09 19:59:55 +0800875 PINCTRL_PIN_GROUP("dfd_ntrst", mt7981_dfd_ntrst),
876 /* @GPIO(9,10): WM_AICE(2) */
877 PINCTRL_PIN_GROUP("wm_aice1", mt7981_wm_aice1),
878 /* @GPIO(13): PWM0(2) */
879 PINCTRL_PIN_GROUP("pwm0_0", mt7981_pwm0_0),
880 /* @GPIO(15): PWM0(1) */
881 PINCTRL_PIN_GROUP("pwm0_1", mt7981_pwm0_1),
882 /* @GPIO(14): PWM1(2) */
883 PINCTRL_PIN_GROUP("pwm1_0", mt7981_pwm1_0),
884 /* @GPIO(15): PWM1(3) */
885 PINCTRL_PIN_GROUP("pwm1_1", mt7981_pwm1_1),
886 /* @GPIO(14) NET_WO0_UART_TXD(3) */
887 PINCTRL_PIN_GROUP("net_wo0_uart_txd_1", mt7981_net_wo0_uart_txd_1),
888 /* @GPIO(15) NET_WO0_UART_TXD(4) */
889 PINCTRL_PIN_GROUP("net_wo0_uart_txd_2", mt7981_net_wo0_uart_txd_2),
890 /* @GPIO(13) GBE_LED0(3) */
891 PINCTRL_PIN_GROUP("gbe_led1", mt7981_gbe_led1),
892 /* @GPIO(9,13) PCM(4) */
893 PINCTRL_PIN_GROUP("pcm", mt7981_pcm),
894 /* @GPIO(13): SYS_WATCHDOG1(5) */
895 PINCTRL_PIN_GROUP("watchdog1", mt7981_watchdog1),
896 /* @GPIO(9,13) UDI(4) */
897 PINCTRL_PIN_GROUP("udi", mt7981_udi),
898 /* @GPIO(14) DRV_VBUS(1) */
899 PINCTRL_PIN_GROUP("drv_vbus", mt7981_drv_vbus),
developer6080c782025-01-24 11:39:02 +0800900 /* @GPIO(15): EMMC_RSTB(2) */
901 PINCTRL_PIN_GROUP("emmc_reset", mt7981_emmc_reset),
902 /* @GPIO(16,17,18,19,24,25): EMMC_DATx, EMMC_CLK, EMMC_CMD */
903 PINCTRL_PIN_GROUP("emmc_4", mt7981_emmc_4),
904 /* @GPIO(16,17,18,19,20,21,22,23,24,25): EMMC_DATx, EMMC_CLK, EMMC_CMD */
905 PINCTRL_PIN_GROUP("emmc_8", mt7981_emmc_8),
developer22073352022-09-09 19:59:55 +0800906 /* @GPIO(15,25): EMMC(2) */
907 PINCTRL_PIN_GROUP("emmc_45", mt7981_emmc_45),
908 /* @GPIO(16,21): SNFI(3) */
909 PINCTRL_PIN_GROUP("snfi", mt7981_snfi),
910 /* @GPIO(16,19): SPI0(1) */
911 PINCTRL_PIN_GROUP("spi0", mt7981_spi0),
912 /* @GPIO(20,21): SPI0(1) */
913 PINCTRL_PIN_GROUP("spi0_wp_hold", mt7981_spi0_wp_hold),
914 /* @GPIO(22,25) SPI1(1) */
915 PINCTRL_PIN_GROUP("spi1_1", mt7981_spi1_1),
916 /* @GPIO(26,29): SPI2(1) */
917 PINCTRL_PIN_GROUP("spi2", mt7981_spi2),
918 /* @GPIO(30,31): SPI2(1) */
919 PINCTRL_PIN_GROUP("spi2_wp_hold", mt7981_spi2_wp_hold),
920 /* @GPIO(16,19): UART1(4) */
921 PINCTRL_PIN_GROUP("uart1_0", mt7981_uart1_0),
922 /* @GPIO(26,29): UART1(2) */
923 PINCTRL_PIN_GROUP("uart1_1", mt7981_uart1_1),
developer6080c782025-01-24 11:39:02 +0800924 /* @GPIO(9,10): UART1(2) */
925 PINCTRL_PIN_GROUP("uart1_2", mt7981_uart1_2),
926 /* @GPIO(26,27): UART1(2) */
927 PINCTRL_PIN_GROUP("uart1_3", mt7981_uart1_3),
developer22073352022-09-09 19:59:55 +0800928 /* @GPIO(22,25): UART2(3) */
developer6080c782025-01-24 11:39:02 +0800929 PINCTRL_PIN_GROUP("uart2_1", mt7981_uart2_1),
developer22073352022-09-09 19:59:55 +0800930 /* @GPIO(22,24) PTA_EXT(4) */
931 PINCTRL_PIN_GROUP("pta_ext_1", mt7981_pta_ext_1),
932 /* @GPIO(20,21): WM_UART(4) */
933 PINCTRL_PIN_GROUP("wm_aurt_1", mt7981_wm_uart_1),
934 /* @GPIO(30,31): WM_UART(3) */
935 PINCTRL_PIN_GROUP("wm_aurt_2", mt7981_wm_uart_2),
936 /* @GPIO(20,24) WM_JTAG(5) */
937 PINCTRL_PIN_GROUP("wm_jtag_1", mt7981_wm_jtag_1),
938 /* @GPIO(25,29) WO0_JTAG(5) */
939 PINCTRL_PIN_GROUP("wo0_jtag_1", mt7981_wo0_jtag_1),
940 /* @GPIO(28,29): WA_AICE(3) */
941 PINCTRL_PIN_GROUP("wa_aice3", mt7981_wa_aice3),
942 /* @GPIO(30,31): WM_AICE(5) */
943 PINCTRL_PIN_GROUP("wm_aice2", mt7981_wm_aice2),
944 /* @GPIO(30,31): I2C(4) */
945 PINCTRL_PIN_GROUP("i2c0_1", mt7981_i2c0_1),
946 /* @GPIO(30,31): I2C(6) */
947 PINCTRL_PIN_GROUP("u2_phy_i2c", mt7981_u2_phy_i2c),
948 /* @GPIO(32,33): I2C(1) */
949 PINCTRL_PIN_GROUP("uart0", mt7981_uart0),
950 /* @GPIO(32,33): I2C(2) */
951 PINCTRL_PIN_GROUP("sgmii1_phy_i2c", mt7981_sgmii1_phy_i2c),
952 /* @GPIO(32,33): I2C(3) */
953 PINCTRL_PIN_GROUP("u3_phy_i2c", mt7981_u3_phy_i2c),
954 /* @GPIO(32,33): I2C(5) */
955 PINCTRL_PIN_GROUP("sgmii0_phy_i2c", mt7981_sgmii0_phy_i2c),
956 /* @GPIO(34): PCIE_CLK_REQ(2) */
957 PINCTRL_PIN_GROUP("pcie_clk", mt7981_pcie_clk),
958 /* @GPIO(35): PCIE_WAKE_N(2) */
959 PINCTRL_PIN_GROUP("pcie_wake", mt7981_pcie_wake),
960 /* @GPIO(36,37): I2C(2) */
961 PINCTRL_PIN_GROUP("i2c0_2", mt7981_i2c0_2),
962 /* @GPIO(36,37): MDC_MDIO(1) */
963 PINCTRL_PIN_GROUP("smi_mdc_mdio", mt7981_smi_mdc_mdio),
964 /* @GPIO(36,37): MDC_MDIO(3) */
965 PINCTRL_PIN_GROUP("gbe_ext_mdc_mdio", mt7981_gbe_ext_mdc_mdio),
966 /* @GPIO(40,56): WF0_MODE1(1) */
967 PINCTRL_PIN_GROUP("wf0_mode1", mt7981_wf0_mode1),
968 /* @GPIO(45,46,47,48,49,51): WF0_MODE3(3) */
969 PINCTRL_PIN_GROUP("wf0_mode3", mt7981_wf0_mode3),
970 /* @GPIO(30): WF2G_LED(2) */
971 PINCTRL_PIN_GROUP("wf2g_led0", mt7981_wf2g_led0),
972 /* @GPIO(34): WF2G_LED(1) */
973 PINCTRL_PIN_GROUP("wf2g_led1", mt7981_wf2g_led1),
974 /* @GPIO(31): WF5G_LED(2) */
975 PINCTRL_PIN_GROUP("wf5g_led0", mt7981_wf5g_led0),
976 /* @GPIO(35): WF5G_LED(1) */
977 PINCTRL_PIN_GROUP("wf5g_led1", mt7981_wf5g_led1),
978 /* @GPIO(38): MT7531_INT(1) */
979 PINCTRL_PIN_GROUP("mt7531_int", mt7981_mt7531_int),
980 /* @GPIO(14,15,26,17,18,19,20,21,22,23,24,25,34,35): ANT_SEL(1) */
981 PINCTRL_PIN_GROUP("ant_sel", mt7981_ant_sel),
982};
983
984static const struct mtk_io_type_desc mt7981_io_type_desc[] = {
985 [IO_TYPE_GRP0] = {
986 .name = "18OD33",
987 .bias_set = mtk_pinconf_bias_set_pupd_r1_r0,
988 .drive_set = mtk_pinconf_drive_set_v1,
989 .input_enable = mtk_pinconf_input_enable_v1,
990 },
991 [IO_TYPE_GRP1] = {
992 .name = "18A01",
993 .bias_set = mtk_pinconf_bias_set_pu_pd,
994 .drive_set = mtk_pinconf_drive_set_v1,
995 .input_enable = mtk_pinconf_input_enable_v1,
996 },
997};
998
999/* Joint those groups owning the same capability in user point of view which
1000 * allows that people tend to use through the device tree.
1001 */
1002static const char *const mt7981_wa_aice_groups[] = { "wa_aice1", "wa_aice2",
1003 "wm_aice1_1", "wa_aice3", "wm_aice1_2", };
developer6080c782025-01-24 11:39:02 +08001004static const char *const mt7981_uart_groups[] = { "net_wo0_uart_txd_0",
1005 "net_wo0_uart_txd_1", "net_wo0_uart_txd_2", "uart0", "uart1_0",
1006 "uart1_1", "uart1_2", "uart1_3", "uart2_0", "uart2_0_tx_rx", "uart2_1",
1007 "wm_uart_0", "wm_aurt_1", "wm_aurt_2", };
developer22073352022-09-09 19:59:55 +08001008static const char *const mt7981_dfd_groups[] = { "dfd", "dfd_ntrst", };
1009static const char *const mt7981_wdt_groups[] = { "watchdog", "watchdog1", };
1010static const char *const mt7981_pcie_groups[] = { "pcie_pereset", "pcie_clk",
1011 "pcie_wake", };
1012static const char *const mt7981_jtag_groups[] = { "jtag", "wm_jtag_0",
1013 "wo0_jtag_0", "wo0_jtag_1", "wm_jtag_1", };
1014static const char *const mt7981_led_groups[] = { "gbe_led0", "gbe_led1",
1015 "wf2g_led0", "wf2g_led1", "wf5g_led0", "wf5g_led1", };
1016static const char *const mt7981_pta_groups[] = { "pta_ext_0", "pta_ext_1", };
1017static const char *const mt7981_pwm_groups[] = { "pwm2", "pwm0_0", "pwm0_1",
1018 "pwm1_0", "pwm1_1", };
1019static const char *const mt7981_spi_groups[] = { "spi1_0", "spi0",
1020 "spi0_wp_hold", "spi1_1", "spi2", "spi2_wp_hold", };
1021static const char *const mt7981_i2c_groups[] = { "i2c0_0", "i2c0_1",
1022 "u2_phy_i2c", "sgmii1_phy_i2c", "u3_phy_i2c", "sgmii0_phy_i2c",
1023 "i2c0_2", };
1024static const char *const mt7981_pcm_groups[] = { "pcm", };
1025static const char *const mt7981_udi_groups[] = { "udi", };
1026static const char *const mt7981_usb_groups[] = { "drv_vbus", };
developer6080c782025-01-24 11:39:02 +08001027static const char *const mt7981_flash_groups[] = { "emmc_reset", "emmc_4",
1028 "emmc_8", "emmc_45", "snfi", };
developer22073352022-09-09 19:59:55 +08001029static const char *const mt7981_ethernet_groups[] = { "smi_mdc_mdio",
1030 "gbe_ext_mdc_mdio", "wf0_mode1", "wf0_mode3", "mt7531_int", };
1031static const char *const mt7981_ant_groups[] = { "ant_sel", };
1032
1033static const struct mtk_function_desc mt7981_functions[] = {
1034 {"wa_aice", mt7981_wa_aice_groups, ARRAY_SIZE(mt7981_wa_aice_groups)},
1035 {"dfd", mt7981_dfd_groups, ARRAY_SIZE(mt7981_dfd_groups)},
1036 {"jtag", mt7981_jtag_groups, ARRAY_SIZE(mt7981_jtag_groups)},
1037 {"pta", mt7981_pta_groups, ARRAY_SIZE(mt7981_pta_groups)},
1038 {"pcm", mt7981_pcm_groups, ARRAY_SIZE(mt7981_pcm_groups)},
1039 {"udi", mt7981_udi_groups, ARRAY_SIZE(mt7981_udi_groups)},
1040 {"usb", mt7981_usb_groups, ARRAY_SIZE(mt7981_usb_groups)},
1041 {"ant", mt7981_ant_groups, ARRAY_SIZE(mt7981_ant_groups)},
1042 {"eth", mt7981_ethernet_groups, ARRAY_SIZE(mt7981_ethernet_groups)},
1043 {"i2c", mt7981_i2c_groups, ARRAY_SIZE(mt7981_i2c_groups)},
1044 {"led", mt7981_led_groups, ARRAY_SIZE(mt7981_led_groups)},
1045 {"pwm", mt7981_pwm_groups, ARRAY_SIZE(mt7981_pwm_groups)},
1046 {"spi", mt7981_spi_groups, ARRAY_SIZE(mt7981_spi_groups)},
1047 {"uart", mt7981_uart_groups, ARRAY_SIZE(mt7981_uart_groups)},
1048 {"watchdog", mt7981_wdt_groups, ARRAY_SIZE(mt7981_wdt_groups)},
1049 {"flash", mt7981_flash_groups, ARRAY_SIZE(mt7981_flash_groups)},
1050 {"pcie", mt7981_pcie_groups, ARRAY_SIZE(mt7981_pcie_groups)},
1051};
1052
1053static const char *const mt7981_pinctrl_register_base_names[] = {
Christian Marangid205efa2025-01-27 14:40:38 +01001054 "gpio", "iocfg_rt", "iocfg_rm", "iocfg_rb",
1055 "iocfg_lb", "iocfg_bl", "iocfg_tm", "iocfg_tl",
1056 "eint",
developer22073352022-09-09 19:59:55 +08001057};
1058
developer67873bd2023-07-19 17:16:37 +08001059static const struct mtk_pinctrl_soc mt7981_data = {
developer22073352022-09-09 19:59:55 +08001060 .name = "mt7981_pinctrl",
1061 .reg_cal = mt7981_reg_cals,
1062 .pins = mt7981_pins,
1063 .npins = ARRAY_SIZE(mt7981_pins),
1064 .grps = mt7981_groups,
1065 .ngrps = ARRAY_SIZE(mt7981_groups),
1066 .funcs = mt7981_functions,
1067 .nfuncs = ARRAY_SIZE(mt7981_functions),
1068 .io_type = mt7981_io_type_desc,
1069 .ntype = ARRAY_SIZE(mt7981_io_type_desc),
1070 .gpio_mode = 0,
1071 .base_names = mt7981_pinctrl_register_base_names,
1072 .nbase_names = ARRAY_SIZE(mt7981_pinctrl_register_base_names),
1073 .base_calc = 1,
1074};
1075
1076static int mtk_pinctrl_mt7981_probe(struct udevice *dev)
1077{
1078 return mtk_pinctrl_common_probe(dev, &mt7981_data);
1079}
1080
1081static const struct udevice_id mt7981_pctrl_match[] = {
1082 {.compatible = "mediatek,mt7981-pinctrl"},
1083 { /* sentinel */ }
1084};
1085
1086U_BOOT_DRIVER(mt7981_pinctrl) = {
1087 .name = "mt7981_pinctrl",
1088 .id = UCLASS_PINCTRL,
1089 .of_match = mt7981_pctrl_match,
1090 .ops = &mtk_pinctrl_ops,
Chris Webbbe3ad162024-07-31 11:01:31 +01001091 .bind = mtk_pinctrl_common_bind,
developer22073352022-09-09 19:59:55 +08001092 .probe = mtk_pinctrl_mt7981_probe,
1093 .priv_auto = sizeof(struct mtk_pinctrl_priv),
Christian Marangif95b21d2024-06-24 23:03:37 +02001094 .flags = DM_FLAG_PRE_RELOC,
developer22073352022-09-09 19:59:55 +08001095};