1 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2 /*
3  * Pin controller and GPIO driver for Amlogic Meson A1 SoC.
4  *
5  * Copyright (c) 2019 Amlogic, Inc. All rights reserved.
6  * Author: Qianggui Song <qianggui.song@amlogic.com>
7  */
8 
9 #include <dt-bindings/gpio/meson-a1-gpio.h>
10 #include "pinctrl-meson.h"
11 #include "pinctrl-meson-axg-pmx.h"
12 
13 static const struct pinctrl_pin_desc meson_a1_periphs_pins[] = {
14 	MESON_PIN(GPIOP_0),
15 	MESON_PIN(GPIOP_1),
16 	MESON_PIN(GPIOP_2),
17 	MESON_PIN(GPIOP_3),
18 	MESON_PIN(GPIOP_4),
19 	MESON_PIN(GPIOP_5),
20 	MESON_PIN(GPIOP_6),
21 	MESON_PIN(GPIOP_7),
22 	MESON_PIN(GPIOP_8),
23 	MESON_PIN(GPIOP_9),
24 	MESON_PIN(GPIOP_10),
25 	MESON_PIN(GPIOP_11),
26 	MESON_PIN(GPIOP_12),
27 	MESON_PIN(GPIOB_0),
28 	MESON_PIN(GPIOB_1),
29 	MESON_PIN(GPIOB_2),
30 	MESON_PIN(GPIOB_3),
31 	MESON_PIN(GPIOB_4),
32 	MESON_PIN(GPIOB_5),
33 	MESON_PIN(GPIOB_6),
34 	MESON_PIN(GPIOX_0),
35 	MESON_PIN(GPIOX_1),
36 	MESON_PIN(GPIOX_2),
37 	MESON_PIN(GPIOX_3),
38 	MESON_PIN(GPIOX_4),
39 	MESON_PIN(GPIOX_5),
40 	MESON_PIN(GPIOX_6),
41 	MESON_PIN(GPIOX_7),
42 	MESON_PIN(GPIOX_8),
43 	MESON_PIN(GPIOX_9),
44 	MESON_PIN(GPIOX_10),
45 	MESON_PIN(GPIOX_11),
46 	MESON_PIN(GPIOX_12),
47 	MESON_PIN(GPIOX_13),
48 	MESON_PIN(GPIOX_14),
49 	MESON_PIN(GPIOX_15),
50 	MESON_PIN(GPIOX_16),
51 	MESON_PIN(GPIOF_0),
52 	MESON_PIN(GPIOF_1),
53 	MESON_PIN(GPIOF_2),
54 	MESON_PIN(GPIOF_3),
55 	MESON_PIN(GPIOF_4),
56 	MESON_PIN(GPIOF_5),
57 	MESON_PIN(GPIOF_6),
58 	MESON_PIN(GPIOF_7),
59 	MESON_PIN(GPIOF_8),
60 	MESON_PIN(GPIOF_9),
61 	MESON_PIN(GPIOF_10),
62 	MESON_PIN(GPIOF_11),
63 	MESON_PIN(GPIOF_12),
64 	MESON_PIN(GPIOA_0),
65 	MESON_PIN(GPIOA_1),
66 	MESON_PIN(GPIOA_2),
67 	MESON_PIN(GPIOA_3),
68 	MESON_PIN(GPIOA_4),
69 	MESON_PIN(GPIOA_5),
70 	MESON_PIN(GPIOA_6),
71 	MESON_PIN(GPIOA_7),
72 	MESON_PIN(GPIOA_8),
73 	MESON_PIN(GPIOA_9),
74 	MESON_PIN(GPIOA_10),
75 	MESON_PIN(GPIOA_11),
76 };
77 
78 /* psram */
79 static const unsigned int psram_clkn_pins[]		= { GPIOP_0 };
80 static const unsigned int psram_clkp_pins[]		= { GPIOP_1 };
81 static const unsigned int psram_ce_n_pins[]		= { GPIOP_2 };
82 static const unsigned int psram_rst_n_pins[]		= { GPIOP_3 };
83 static const unsigned int psram_adq0_pins[]		= { GPIOP_4 };
84 static const unsigned int psram_adq1_pins[]		= { GPIOP_5 };
85 static const unsigned int psram_adq2_pins[]		= { GPIOP_6 };
86 static const unsigned int psram_adq3_pins[]		= { GPIOP_7 };
87 static const unsigned int psram_adq4_pins[]		= { GPIOP_8 };
88 static const unsigned int psram_adq5_pins[]		= { GPIOP_9 };
89 static const unsigned int psram_adq6_pins[]		= { GPIOP_10 };
90 static const unsigned int psram_adq7_pins[]		= { GPIOP_11 };
91 static const unsigned int psram_dqs_dm_pins[]		= { GPIOP_12 };
92 
93 /* sdcard */
94 static const unsigned int sdcard_d0_b_pins[]		= { GPIOB_0 };
95 static const unsigned int sdcard_d1_b_pins[]		= { GPIOB_1 };
96 static const unsigned int sdcard_d2_b_pins[]		= { GPIOB_2 };
97 static const unsigned int sdcard_d3_b_pins[]		= { GPIOB_3 };
98 static const unsigned int sdcard_clk_b_pins[]		= { GPIOB_4 };
99 static const unsigned int sdcard_cmd_b_pins[]		= { GPIOB_5 };
100 
101 static const unsigned int sdcard_d0_x_pins[]		= { GPIOX_0 };
102 static const unsigned int sdcard_d1_x_pins[]		= { GPIOX_1 };
103 static const unsigned int sdcard_d2_x_pins[]		= { GPIOX_2 };
104 static const unsigned int sdcard_d3_x_pins[]		= { GPIOX_3 };
105 static const unsigned int sdcard_clk_x_pins[]		= { GPIOX_4 };
106 static const unsigned int sdcard_cmd_x_pins[]		= { GPIOX_5 };
107 
108 /* spif */
109 static const unsigned int spif_mo_pins[]		= { GPIOB_0 };
110 static const unsigned int spif_mi_pins[]		= { GPIOB_1 };
111 static const unsigned int spif_wp_n_pins[]		= { GPIOB_2 };
112 static const unsigned int spif_hold_n_pins[]		= { GPIOB_3 };
113 static const unsigned int spif_clk_pins[]		= { GPIOB_4 };
114 static const unsigned int spif_cs_pins[]		= { GPIOB_5 };
115 
116 /* i2c0 */
117 static const unsigned int i2c0_sck_f9_pins[]		= { GPIOF_9 };
118 static const unsigned int i2c0_sda_f10_pins[]		= { GPIOF_10 };
119 static const unsigned int i2c0_sck_f11_pins[]		= { GPIOF_11 };
120 static const unsigned int i2c0_sda_f12_pins[]		= { GPIOF_12 };
121 
122 /* i2c1 */
123 static const unsigned int i2c1_sda_x_pins[]		= { GPIOX_9 };
124 static const unsigned int i2c1_sck_x_pins[]		= { GPIOX_10 };
125 static const unsigned int i2c1_sda_a_pins[]		= { GPIOA_10 };
126 static const unsigned int i2c1_sck_a_pins[]		= { GPIOA_11 };
127 
128 /* i2c2 */
129 static const unsigned int i2c2_sck_x0_pins[]		= { GPIOX_0 };
130 static const unsigned int i2c2_sda_x1_pins[]		= { GPIOX_1 };
131 static const unsigned int i2c2_sck_x15_pins[]		= { GPIOX_15 };
132 static const unsigned int i2c2_sda_x16_pins[]		= { GPIOX_16 };
133 static const unsigned int i2c2_sck_a4_pins[]		= { GPIOA_4 };
134 static const unsigned int i2c2_sda_a5_pins[]		= { GPIOA_5 };
135 static const unsigned int i2c2_sck_a8_pins[]		= { GPIOA_8 };
136 static const unsigned int i2c2_sda_a9_pins[]		= { GPIOA_9 };
137 
138 /* i2c3 */
139 static const unsigned int i2c3_sck_f_pins[]		= { GPIOF_4 };
140 static const unsigned int i2c3_sda_f_pins[]		= { GPIOF_5 };
141 static const unsigned int i2c3_sck_x_pins[]		= { GPIOX_11 };
142 static const unsigned int i2c3_sda_x_pins[]		= { GPIOX_12 };
143 
144 /* i2c slave */
145 static const unsigned int i2c_slave_sck_a_pins[]	= { GPIOA_10 };
146 static const unsigned int i2c_slave_sda_a_pins[]	= { GPIOA_11 };
147 static const unsigned int i2c_slave_sck_f_pins[]	= { GPIOF_11 };
148 static const unsigned int i2c_slave_sda_f_pins[]	= { GPIOF_12 };
149 
150 /* uart_a */
151 static const unsigned int uart_a_tx_pins[]		= { GPIOX_11 };
152 static const unsigned int uart_a_rx_pins[]		= { GPIOX_12 };
153 static const unsigned int uart_a_cts_pins[]		= { GPIOX_13 };
154 static const unsigned int uart_a_rts_pins[]		= { GPIOX_14 };
155 
156 /* uart_b */
157 static const unsigned int uart_b_tx_x_pins[]		= { GPIOX_7 };
158 static const unsigned int uart_b_rx_x_pins[]		= { GPIOX_8 };
159 static const unsigned int uart_b_tx_f_pins[]		= { GPIOF_0 };
160 static const unsigned int uart_b_rx_f_pins[]		= { GPIOF_1 };
161 
162 /* uart_c */
163 static const unsigned int uart_c_tx_x0_pins[]		= { GPIOX_0 };
164 static const unsigned int uart_c_rx_x1_pins[]		= { GPIOX_1 };
165 static const unsigned int uart_c_cts_pins[]		= { GPIOX_2 };
166 static const unsigned int uart_c_rts_pins[]		= { GPIOX_3 };
167 static const unsigned int uart_c_tx_x15_pins[]		= { GPIOX_15 };
168 static const unsigned int uart_c_rx_x16_pins[]		= { GPIOX_16 };
169 
170 /* pmw_a */
171 static const unsigned int pwm_a_x6_pins[]		= { GPIOX_6 };
172 static const unsigned int pwm_a_x7_pins[]		= { GPIOX_7 };
173 static const unsigned int pwm_a_f6_pins[]		= { GPIOF_6 };
174 static const unsigned int pwm_a_f10_pins[]		= { GPIOF_10 };
175 static const unsigned int pwm_a_a_pins[]		= { GPIOA_5 };
176 
177 /* pmw_b */
178 static const unsigned int pwm_b_x_pins[]		= { GPIOX_8 };
179 static const unsigned int pwm_b_f_pins[]		= { GPIOF_7 };
180 static const unsigned int pwm_b_a_pins[]		= { GPIOA_11 };
181 
182 /* pmw_c */
183 static const unsigned int pwm_c_x_pins[]		= { GPIOX_9 };
184 static const unsigned int pwm_c_f3_pins[]		= { GPIOF_3 };
185 static const unsigned int pwm_c_f8_pins[]		= { GPIOF_8 };
186 static const unsigned int pwm_c_a_pins[]		= { GPIOA_10 };
187 
188 /* pwm_d */
189 static const unsigned int pwm_d_x10_pins[]		= { GPIOX_10 };
190 static const unsigned int pwm_d_x13_pins[]		= { GPIOX_13 };
191 static const unsigned int pwm_d_x15_pins[]		= { GPIOX_15 };
192 static const unsigned int pwm_d_f_pins[]		= { GPIOF_11 };
193 
194 /* pwm_e */
195 static const unsigned int pwm_e_p_pins[]		= { GPIOP_3 };
196 static const unsigned int pwm_e_x2_pins[]		= { GPIOX_2 };
197 static const unsigned int pwm_e_x14_pins[]		= { GPIOX_14 };
198 static const unsigned int pwm_e_x16_pins[]		= { GPIOX_16 };
199 static const unsigned int pwm_e_f_pins[]		= { GPIOF_3 };
200 static const unsigned int pwm_e_a_pins[]		= { GPIOA_0 };
201 
202 /* pwm_f */
203 static const unsigned int pwm_f_b_pins[]		= { GPIOB_6 };
204 static const unsigned int pwm_f_x_pins[]		= { GPIOX_3 };
205 static const unsigned int pwm_f_f4_pins[]		= { GPIOF_4 };
206 static const unsigned int pwm_f_f12_pins[]		= { GPIOF_12 };
207 
208 /* pwm_a_hiz */
209 static const unsigned int pwm_a_hiz_f8_pins[]		= { GPIOF_8 };
210 static const unsigned int pwm_a_hiz_f10_pins[]		= { GPIOF_10 };
211 static const unsigned int pmw_a_hiz_f6_pins[]		= { GPIOF_6 };
212 
213 /* pwm_b_hiz */
214 static const unsigned int pwm_b_hiz_pins[]		= { GPIOF_7 };
215 
216 /* pmw_c_hiz */
217 static const unsigned int pwm_c_hiz_pins[]		= { GPIOF_8 };
218 
219 /* tdm_a */
220 static const unsigned int tdm_a_dout1_pins[]		= { GPIOX_7 };
221 static const unsigned int tdm_a_dout0_pins[]		= { GPIOX_8 };
222 static const unsigned int tdm_a_fs_pins[]		= { GPIOX_9 };
223 static const unsigned int tdm_a_sclk_pins[]		= { GPIOX_10 };
224 static const unsigned int tdm_a_din1_pins[]		= { GPIOX_7 };
225 static const unsigned int tdm_a_din0_pins[]		= { GPIOX_8 };
226 static const unsigned int tdm_a_slv_fs_pins[]		= { GPIOX_9 };
227 static const unsigned int tdm_a_slv_sclk_pins[]		= { GPIOX_10 };
228 
229 /* spi_a */
230 static const unsigned int spi_a_mosi_x2_pins[]		= { GPIOX_2 };
231 static const unsigned int spi_a_ss0_x3_pins[]		= { GPIOX_3 };
232 static const unsigned int spi_a_sclk_x4_pins[]		= { GPIOX_4 };
233 static const unsigned int spi_a_miso_x5_pins[]		= { GPIOX_5 };
234 static const unsigned int spi_a_mosi_x7_pins[]		= { GPIOX_7 };
235 static const unsigned int spi_a_miso_x8_pins[]		= { GPIOX_8 };
236 static const unsigned int spi_a_ss0_x9_pins[]		= { GPIOX_9 };
237 static const unsigned int spi_a_sclk_x10_pins[]		= { GPIOX_10 };
238 
239 static const unsigned int spi_a_mosi_a_pins[]		= { GPIOA_6 };
240 static const unsigned int spi_a_miso_a_pins[]		= { GPIOA_7 };
241 static const unsigned int spi_a_ss0_a_pins[]		= { GPIOA_8 };
242 static const unsigned int spi_a_sclk_a_pins[]		= { GPIOA_9 };
243 
244 /* pdm */
245 static const unsigned int pdm_din0_x_pins[]		= { GPIOX_7 };
246 static const unsigned int pdm_din1_x_pins[]		= { GPIOX_8 };
247 static const unsigned int pdm_din2_x_pins[]		= { GPIOX_9 };
248 static const unsigned int pdm_dclk_x_pins[]		= { GPIOX_10 };
249 
250 static const unsigned int pdm_din2_a_pins[]		= { GPIOA_6 };
251 static const unsigned int pdm_din1_a_pins[]		= { GPIOA_7 };
252 static const unsigned int pdm_din0_a_pins[]		= { GPIOA_8 };
253 static const unsigned int pdm_dclk_pins[]		= { GPIOA_9 };
254 
255 /* gen_clk */
256 static const unsigned int gen_clk_x_pins[]		= { GPIOX_7 };
257 static const unsigned int gen_clk_f8_pins[]		= { GPIOF_8 };
258 static const unsigned int gen_clk_f10_pins[]		= { GPIOF_10 };
259 static const unsigned int gen_clk_a_pins[]		= { GPIOA_11 };
260 
261 /* jtag_a */
262 static const unsigned int jtag_a_clk_pins[]		= { GPIOF_4 };
263 static const unsigned int jtag_a_tms_pins[]		= { GPIOF_5 };
264 static const unsigned int jtag_a_tdi_pins[]		= { GPIOF_6 };
265 static const unsigned int jtag_a_tdo_pins[]		= { GPIOF_7 };
266 
267 /* clk_32_in */
268 static const unsigned int clk_32k_in_pins[]		= { GPIOF_2 };
269 
270 /* ir in */
271 static const unsigned int remote_input_f_pins[]		= { GPIOF_3 };
272 static const unsigned int remote_input_a_pins[]		= { GPIOA_11 };
273 
274 /* ir out */
275 static const unsigned int remote_out_pins[]		= { GPIOF_5 };
276 
277 /* spdif */
278 static const unsigned int spdif_in_f6_pins[]		= { GPIOF_6 };
279 static const unsigned int spdif_in_f7_pins[]		= { GPIOF_7 };
280 
281 /* sw */
282 static const unsigned int swclk_pins[]			= { GPIOF_4 };
283 static const unsigned int swdio_pins[]			= { GPIOF_5 };
284 
285 /* clk_25 */
286 static const unsigned int clk25_pins[]			= { GPIOF_10 };
287 
288 /* cec_a */
289 static const unsigned int cec_a_pins[]			= { GPIOF_2 };
290 
291 /* cec_b */
292 static const unsigned int cec_b_pins[]			= { GPIOF_2 };
293 
294 /* clk12_24 */
295 static const unsigned int clk12_24_pins[]		= { GPIOF_10 };
296 
297 /* mclk_0 */
298 static const unsigned int mclk_0_pins[]			= { GPIOA_0 };
299 
300 /* tdm_b */
301 static const unsigned int tdm_b_sclk_pins[]		= { GPIOA_1 };
302 static const unsigned int tdm_b_fs_pins[]		= { GPIOA_2 };
303 static const unsigned int tdm_b_dout0_pins[]		= { GPIOA_3 };
304 static const unsigned int tdm_b_dout1_pins[]		= { GPIOA_4 };
305 static const unsigned int tdm_b_dout2_pins[]		= { GPIOA_5 };
306 static const unsigned int tdm_b_dout3_pins[]		= { GPIOA_6 };
307 static const unsigned int tdm_b_dout4_pins[]		= { GPIOA_7 };
308 static const unsigned int tdm_b_dout5_pins[]		= { GPIOA_8 };
309 static const unsigned int tdm_b_slv_sclk_pins[]		= { GPIOA_5 };
310 static const unsigned int tdm_b_slv_fs_pins[]		= { GPIOA_6 };
311 static const unsigned int tdm_b_din0_pins[]		= { GPIOA_7 };
312 static const unsigned int tdm_b_din1_pins[]		= { GPIOA_8 };
313 static const unsigned int tdm_b_din2_pins[]		= { GPIOA_9 };
314 
315 /* mclk_vad */
316 static const unsigned int mclk_vad_pins[]		= { GPIOA_0 };
317 
318 /* tdm_vad */
319 static const unsigned int tdm_vad_sclk_a1_pins[]	= { GPIOA_1 };
320 static const unsigned int tdm_vad_fs_a2_pins[]		= { GPIOA_2 };
321 static const unsigned int tdm_vad_sclk_a5_pins[]	= { GPIOA_5 };
322 static const unsigned int tdm_vad_fs_a6_pins[]		= { GPIOA_6 };
323 
324 /* tst_out */
325 static const unsigned int tst_out0_pins[]		= { GPIOA_0 };
326 static const unsigned int tst_out1_pins[]		= { GPIOA_1 };
327 static const unsigned int tst_out2_pins[]		= { GPIOA_2 };
328 static const unsigned int tst_out3_pins[]		= { GPIOA_3 };
329 static const unsigned int tst_out4_pins[]		= { GPIOA_4 };
330 static const unsigned int tst_out5_pins[]		= { GPIOA_5 };
331 static const unsigned int tst_out6_pins[]		= { GPIOA_6 };
332 static const unsigned int tst_out7_pins[]		= { GPIOA_7 };
333 static const unsigned int tst_out8_pins[]		= { GPIOA_8 };
334 static const unsigned int tst_out9_pins[]		= { GPIOA_9 };
335 static const unsigned int tst_out10_pins[]		= { GPIOA_10 };
336 static const unsigned int tst_out11_pins[]		= { GPIOA_11 };
337 
338 /* mute */
339 static const unsigned int mute_key_pins[]		= { GPIOA_4 };
340 static const unsigned int mute_en_pins[]		= { GPIOA_5 };
341 
342 static struct meson_pmx_group meson_a1_periphs_groups[] = {
343 	GPIO_GROUP(GPIOP_0),
344 	GPIO_GROUP(GPIOP_1),
345 	GPIO_GROUP(GPIOP_2),
346 	GPIO_GROUP(GPIOP_3),
347 	GPIO_GROUP(GPIOP_4),
348 	GPIO_GROUP(GPIOP_5),
349 	GPIO_GROUP(GPIOP_6),
350 	GPIO_GROUP(GPIOP_7),
351 	GPIO_GROUP(GPIOP_8),
352 	GPIO_GROUP(GPIOP_9),
353 	GPIO_GROUP(GPIOP_10),
354 	GPIO_GROUP(GPIOP_11),
355 	GPIO_GROUP(GPIOP_12),
356 	GPIO_GROUP(GPIOB_0),
357 	GPIO_GROUP(GPIOB_1),
358 	GPIO_GROUP(GPIOB_2),
359 	GPIO_GROUP(GPIOB_3),
360 	GPIO_GROUP(GPIOB_4),
361 	GPIO_GROUP(GPIOB_5),
362 	GPIO_GROUP(GPIOB_6),
363 	GPIO_GROUP(GPIOX_0),
364 	GPIO_GROUP(GPIOX_1),
365 	GPIO_GROUP(GPIOX_2),
366 	GPIO_GROUP(GPIOX_3),
367 	GPIO_GROUP(GPIOX_4),
368 	GPIO_GROUP(GPIOX_5),
369 	GPIO_GROUP(GPIOX_6),
370 	GPIO_GROUP(GPIOX_7),
371 	GPIO_GROUP(GPIOX_8),
372 	GPIO_GROUP(GPIOX_9),
373 	GPIO_GROUP(GPIOX_10),
374 	GPIO_GROUP(GPIOX_11),
375 	GPIO_GROUP(GPIOX_12),
376 	GPIO_GROUP(GPIOX_13),
377 	GPIO_GROUP(GPIOX_14),
378 	GPIO_GROUP(GPIOX_15),
379 	GPIO_GROUP(GPIOX_16),
380 	GPIO_GROUP(GPIOF_0),
381 	GPIO_GROUP(GPIOF_1),
382 	GPIO_GROUP(GPIOF_2),
383 	GPIO_GROUP(GPIOF_3),
384 	GPIO_GROUP(GPIOF_4),
385 	GPIO_GROUP(GPIOF_5),
386 	GPIO_GROUP(GPIOF_6),
387 	GPIO_GROUP(GPIOF_7),
388 	GPIO_GROUP(GPIOF_8),
389 	GPIO_GROUP(GPIOF_9),
390 	GPIO_GROUP(GPIOF_10),
391 	GPIO_GROUP(GPIOF_11),
392 	GPIO_GROUP(GPIOF_12),
393 	GPIO_GROUP(GPIOA_0),
394 	GPIO_GROUP(GPIOA_1),
395 	GPIO_GROUP(GPIOA_2),
396 	GPIO_GROUP(GPIOA_3),
397 	GPIO_GROUP(GPIOA_4),
398 	GPIO_GROUP(GPIOA_5),
399 	GPIO_GROUP(GPIOA_6),
400 	GPIO_GROUP(GPIOA_7),
401 	GPIO_GROUP(GPIOA_8),
402 	GPIO_GROUP(GPIOA_9),
403 	GPIO_GROUP(GPIOA_10),
404 	GPIO_GROUP(GPIOA_11),
405 
406 	/* bank P func1 */
407 	GROUP(psram_clkn,		1),
408 	GROUP(psram_clkp,		1),
409 	GROUP(psram_ce_n,		1),
410 	GROUP(psram_rst_n,		1),
411 	GROUP(psram_adq0,		1),
412 	GROUP(psram_adq1,		1),
413 	GROUP(psram_adq2,		1),
414 	GROUP(psram_adq3,		1),
415 	GROUP(psram_adq4,		1),
416 	GROUP(psram_adq5,		1),
417 	GROUP(psram_adq6,		1),
418 	GROUP(psram_adq7,		1),
419 	GROUP(psram_dqs_dm,		1),
420 
421 	/*bank P func2 */
422 	GROUP(pwm_e_p,			2),
423 
424 	/*bank B func1 */
425 	GROUP(spif_mo,			1),
426 	GROUP(spif_mi,			1),
427 	GROUP(spif_wp_n,		1),
428 	GROUP(spif_hold_n,		1),
429 	GROUP(spif_clk,			1),
430 	GROUP(spif_cs,			1),
431 	GROUP(pwm_f_b,			1),
432 
433 	/*bank B func2 */
434 	GROUP(sdcard_d0_b,		2),
435 	GROUP(sdcard_d1_b,		2),
436 	GROUP(sdcard_d2_b,		2),
437 	GROUP(sdcard_d3_b,		2),
438 	GROUP(sdcard_clk_b,		2),
439 	GROUP(sdcard_cmd_b,		2),
440 
441 	/*bank X func1 */
442 	GROUP(sdcard_d0_x,		1),
443 	GROUP(sdcard_d1_x,		1),
444 	GROUP(sdcard_d2_x,		1),
445 	GROUP(sdcard_d3_x,		1),
446 	GROUP(sdcard_clk_x,		1),
447 	GROUP(sdcard_cmd_x,		1),
448 	GROUP(pwm_a_x6,			1),
449 	GROUP(tdm_a_dout1,		1),
450 	GROUP(tdm_a_dout0,		1),
451 	GROUP(tdm_a_fs,			1),
452 	GROUP(tdm_a_sclk,		1),
453 	GROUP(uart_a_tx,		1),
454 	GROUP(uart_a_rx,		1),
455 	GROUP(uart_a_cts,		1),
456 	GROUP(uart_a_rts,		1),
457 	GROUP(pwm_d_x15,		1),
458 	GROUP(pwm_e_x16,		1),
459 
460 	/*bank X func2 */
461 	GROUP(i2c2_sck_x0,		2),
462 	GROUP(i2c2_sda_x1,		2),
463 	GROUP(spi_a_mosi_x2,		2),
464 	GROUP(spi_a_ss0_x3,		2),
465 	GROUP(spi_a_sclk_x4,		2),
466 	GROUP(spi_a_miso_x5,		2),
467 	GROUP(tdm_a_din1,		2),
468 	GROUP(tdm_a_din0,		2),
469 	GROUP(tdm_a_slv_fs,		2),
470 	GROUP(tdm_a_slv_sclk,		2),
471 	GROUP(i2c3_sck_x,		2),
472 	GROUP(i2c3_sda_x,		2),
473 	GROUP(pwm_d_x13,		2),
474 	GROUP(pwm_e_x14,		2),
475 	GROUP(i2c2_sck_x15,		2),
476 	GROUP(i2c2_sda_x16,		2),
477 
478 	/*bank X func3 */
479 	GROUP(uart_c_tx_x0,		3),
480 	GROUP(uart_c_rx_x1,		3),
481 	GROUP(uart_c_cts,		3),
482 	GROUP(uart_c_rts,		3),
483 	GROUP(pdm_din0_x,		3),
484 	GROUP(pdm_din1_x,		3),
485 	GROUP(pdm_din2_x,		3),
486 	GROUP(pdm_dclk_x,		3),
487 	GROUP(uart_c_tx_x15,		3),
488 	GROUP(uart_c_rx_x16,		3),
489 
490 	/*bank X func4 */
491 	GROUP(pwm_e_x2,			4),
492 	GROUP(pwm_f_x,			4),
493 	GROUP(spi_a_mosi_x7,		4),
494 	GROUP(spi_a_miso_x8,		4),
495 	GROUP(spi_a_ss0_x9,		4),
496 	GROUP(spi_a_sclk_x10,		4),
497 
498 	/*bank X func5 */
499 	GROUP(uart_b_tx_x,		5),
500 	GROUP(uart_b_rx_x,		5),
501 	GROUP(i2c1_sda_x,		5),
502 	GROUP(i2c1_sck_x,		5),
503 
504 	/*bank X func6 */
505 	GROUP(pwm_a_x7,			6),
506 	GROUP(pwm_b_x,			6),
507 	GROUP(pwm_c_x,			6),
508 	GROUP(pwm_d_x10,		6),
509 
510 	/*bank X func7 */
511 	GROUP(gen_clk_x,		7),
512 
513 	/*bank F func1 */
514 	GROUP(uart_b_tx_f,		1),
515 	GROUP(uart_b_rx_f,		1),
516 	GROUP(remote_input_f,		1),
517 	GROUP(jtag_a_clk,		1),
518 	GROUP(jtag_a_tms,		1),
519 	GROUP(jtag_a_tdi,		1),
520 	GROUP(jtag_a_tdo,		1),
521 	GROUP(gen_clk_f8,		1),
522 	GROUP(pwm_a_f10,		1),
523 	GROUP(i2c0_sck_f11,		1),
524 	GROUP(i2c0_sda_f12,		1),
525 
526 	/*bank F func2 */
527 	GROUP(clk_32k_in,		2),
528 	GROUP(pwm_e_f,			2),
529 	GROUP(pwm_f_f4,			2),
530 	GROUP(remote_out,		2),
531 	GROUP(spdif_in_f6,		2),
532 	GROUP(spdif_in_f7,		2),
533 	GROUP(pwm_a_hiz_f8,		2),
534 	GROUP(pwm_a_hiz_f10,		2),
535 	GROUP(pwm_d_f,			2),
536 	GROUP(pwm_f_f12,		2),
537 
538 	/*bank F func3 */
539 	GROUP(pwm_c_f3,			3),
540 	GROUP(swclk,			3),
541 	GROUP(swdio,			3),
542 	GROUP(pwm_a_f6,			3),
543 	GROUP(pwm_b_f,			3),
544 	GROUP(pwm_c_f8,			3),
545 	GROUP(clk25,			3),
546 	GROUP(i2c_slave_sck_f,		3),
547 	GROUP(i2c_slave_sda_f,		3),
548 
549 	/*bank F func4 */
550 	GROUP(cec_a,			4),
551 	GROUP(i2c3_sck_f,		4),
552 	GROUP(i2c3_sda_f,		4),
553 	GROUP(pmw_a_hiz_f6,		4),
554 	GROUP(pwm_b_hiz,		4),
555 	GROUP(pwm_c_hiz,		4),
556 	GROUP(i2c0_sck_f9,		4),
557 	GROUP(i2c0_sda_f10,		4),
558 
559 	/*bank F func5 */
560 	GROUP(cec_b,			5),
561 	GROUP(clk12_24,			5),
562 
563 	/*bank F func7 */
564 	GROUP(gen_clk_f10,		7),
565 
566 	/*bank A func1 */
567 	GROUP(mclk_0,			1),
568 	GROUP(tdm_b_sclk,		1),
569 	GROUP(tdm_b_fs,			1),
570 	GROUP(tdm_b_dout0,		1),
571 	GROUP(tdm_b_dout1,		1),
572 	GROUP(tdm_b_dout2,		1),
573 	GROUP(tdm_b_dout3,		1),
574 	GROUP(tdm_b_dout4,		1),
575 	GROUP(tdm_b_dout5,		1),
576 	GROUP(remote_input_a,		1),
577 
578 	/*bank A func2 */
579 	GROUP(pwm_e_a,			2),
580 	GROUP(tdm_b_slv_sclk,		2),
581 	GROUP(tdm_b_slv_fs,		2),
582 	GROUP(tdm_b_din0,		2),
583 	GROUP(tdm_b_din1,		2),
584 	GROUP(tdm_b_din2,		2),
585 	GROUP(i2c1_sda_a,		2),
586 	GROUP(i2c1_sck_a,		2),
587 
588 	/*bank A func3 */
589 	GROUP(i2c2_sck_a4,		3),
590 	GROUP(i2c2_sda_a5,		3),
591 	GROUP(pdm_din2_a,		3),
592 	GROUP(pdm_din1_a,		3),
593 	GROUP(pdm_din0_a,		3),
594 	GROUP(pdm_dclk,			3),
595 	GROUP(pwm_c_a,			3),
596 	GROUP(pwm_b_a,			3),
597 
598 	/*bank A func4 */
599 	GROUP(pwm_a_a,			4),
600 	GROUP(spi_a_mosi_a,		4),
601 	GROUP(spi_a_miso_a,		4),
602 	GROUP(spi_a_ss0_a,		4),
603 	GROUP(spi_a_sclk_a,		4),
604 	GROUP(i2c_slave_sck_a,		4),
605 	GROUP(i2c_slave_sda_a,		4),
606 
607 	/*bank A func5 */
608 	GROUP(mclk_vad,			5),
609 	GROUP(tdm_vad_sclk_a1,		5),
610 	GROUP(tdm_vad_fs_a2,		5),
611 	GROUP(tdm_vad_sclk_a5,		5),
612 	GROUP(tdm_vad_fs_a6,		5),
613 	GROUP(i2c2_sck_a8,		5),
614 	GROUP(i2c2_sda_a9,		5),
615 
616 	/*bank A func6 */
617 	GROUP(tst_out0,			6),
618 	GROUP(tst_out1,			6),
619 	GROUP(tst_out2,			6),
620 	GROUP(tst_out3,			6),
621 	GROUP(tst_out4,			6),
622 	GROUP(tst_out5,			6),
623 	GROUP(tst_out6,			6),
624 	GROUP(tst_out7,			6),
625 	GROUP(tst_out8,			6),
626 	GROUP(tst_out9,			6),
627 	GROUP(tst_out10,		6),
628 	GROUP(tst_out11,		6),
629 
630 	/*bank A func7 */
631 	GROUP(mute_key,			7),
632 	GROUP(mute_en,			7),
633 	GROUP(gen_clk_a,		7),
634 };
635 
636 static const char * const gpio_periphs_groups[] = {
637 	"GPIOP_0", "GPIOP_1", "GPIOP_2", "GPIOP_3", "GPIOP_4",
638 	"GPIOP_5", "GPIOP_6", "GPIOP_7", "GPIOP_8", "GPIOP_9",
639 	"GPIOP_10", "GPIOP_11", "GPIOP_12",
640 
641 	"GPIOB_0", "GPIOB_1", "GPIOB_2", "GPIOB_3", "GPIOB_4",
642 	"GPIOB_5", "GPIOB_6",
643 
644 	"GPIOX_0", "GPIOX_1", "GPIOX_2", "GPIOX_3", "GPIOX_4",
645 	"GPIOX_5", "GPIOX_6", "GPIOX_7", "GPIOX_8", "GPIOX_9",
646 	"GPIOX_10", "GPIOX_11", "GPIOX_12", "GPIOX_13", "GPIOX_14",
647 	"GPIOX_15", "GPIOX_16",
648 
649 	"GPIOF_0", "GPIOF_1", "GPIOF_2", "GPIOF_3", "GPIOF_4",
650 	"GPIOF_5", "GPIOF_6", "GPIOF_7", "GPIOF_8", "GPIOF_9",
651 	"GPIOF_10", "GPIOF_11", "GPIOF_12",
652 
653 	"GPIOA_0", "GPIOA_1", "GPIOA_2", "GPIOA_3", "GPIOA_4",
654 	"GPIOA_5", "GPIOA_6", "GPIOA_7", "GPIOA_8", "GPIOA_9",
655 	"GPIOA_10", "GPIOA_11",
656 };
657 
658 static const char * const psram_groups[] = {
659 	"psram_clkn", "psram_clkp", "psram_ce_n", "psram_rst_n", "psram_adq0",
660 	"psram_adq1", "psram_adq2", "psram_adq3", "psram_adq4", "psram_adq5",
661 	"psram_adq6", "psram_adq7", "psram_dqs_dm",
662 };
663 
664 static const char * const pwm_a_groups[] = {
665 	"pwm_a_x6", "pwm_a_x7", "pwm_a_f10", "pwm_a_f6", "pwm_a_a",
666 };
667 
668 static const char * const pwm_b_groups[] = {
669 	"pwm_b_x", "pwm_b_f", "pwm_b_a",
670 };
671 
672 static const char * const pwm_c_groups[] = {
673 	"pwm_c_x", "pwm_c_f3", "pwm_c_f8", "pwm_c_a",
674 };
675 
676 static const char * const pwm_d_groups[] = {
677 	"pwm_d_x15", "pwm_d_x13", "pwm_d_x10", "pwm_d_f",
678 };
679 
680 static const char * const pwm_e_groups[] = {
681 	"pwm_e_p", "pwm_e_x16", "pwm_e_x14", "pwm_e_x2", "pwm_e_f",
682 	"pwm_e_a",
683 };
684 
685 static const char * const pwm_f_groups[] = {
686 	"pwm_f_b", "pwm_f_x", "pwm_f_f4", "pwm_f_f12",
687 };
688 
689 static const char * const pwm_a_hiz_groups[] = {
690 	"pwm_a_hiz_f8", "pwm_a_hiz_f10", "pwm_a_hiz_f6",
691 };
692 
693 static const char * const pwm_b_hiz_groups[] = {
694 	"pwm_b_hiz",
695 };
696 
697 static const char * const pwm_c_hiz_groups[] = {
698 	"pwm_c_hiz",
699 };
700 
701 static const char * const spif_groups[] = {
702 	"spif_mo", "spif_mi", "spif_wp_n", "spif_hold_n", "spif_clk",
703 	"spif_cs",
704 };
705 
706 static const char * const sdcard_groups[] = {
707 	"sdcard_d0_b", "sdcard_d1_b", "sdcard_d2_b", "sdcard_d3_b",
708 	"sdcard_clk_b", "sdcard_cmd_b",
709 
710 	"sdcard_d0_x", "sdcard_d1_x", "sdcard_d2_x", "sdcard_d3_x",
711 	"sdcard_clk_x", "sdcard_cmd_x",
712 };
713 
714 static const char * const tdm_a_groups[] = {
715 	"tdm_a_din0", "tdm_a_din1",  "tdm_a_fs", "tdm_a_sclk",
716 	"tdm_a_slv_fs", "tdm_a_slv_sclk", "tdm_a_dout0", "tdm_a_dout1",
717 };
718 
719 static const char * const uart_a_groups[] = {
720 	"uart_a_tx", "uart_a_rx", "uart_a_cts", "uart_a_rts",
721 };
722 
723 static const char * const uart_b_groups[] = {
724 	"uart_b_tx_x", "uart_b_rx_x", "uart_b_tx_f", "uart_b_rx_f",
725 };
726 
727 static const char * const uart_c_groups[] = {
728 	"uart_c_tx_x0", "uart_c_rx_x1", "uart_c_cts", "uart_c_rts",
729 	"uart_c_tx_x15", "uart_c_rx_x16",
730 };
731 
732 static const char * const i2c0_groups[] = {
733 	"i2c0_sck_f11", "i2c0_sda_f12", "i2c0_sck_f9", "i2c0_sda_f10",
734 };
735 
736 static const char * const i2c1_groups[] = {
737 	"i2c1_sda_x", "i2c1_sck_x", "i2c1_sda_a", "i2c1_sck_a",
738 };
739 
740 static const char * const i2c2_groups[] = {
741 	"i2c2_sck_x0", "i2c2_sda_x1", "i2c2_sck_x15", "i2c2_sda_x16",
742 	"i2c2_sck_a4", "i2c2_sda_a5", "i2c2_sck_a8", "i2c2_sda_a9",
743 };
744 
745 static const char * const i2c3_groups[] = {
746 	"i2c3_sck_x", "i2c3_sda_x", "i2c3_sck_f", "i2c3_sda_f",
747 };
748 
749 static const char * const spi_a_groups[] = {
750 	"spi_a_mosi_x2", "spi_a_ss0_x3", "spi_a_sclk_x4", "spi_a_miso_x5",
751 	"spi_a_mosi_x7", "spi_a_miso_x8", "spi_a_ss0_x9", "spi_a_sclk_x10",
752 
753 	"spi_a_mosi_a", "spi_a_miso_a", "spi_a_ss0_a", "spi_a_sclk_a",
754 };
755 
756 static const char * const pdm_groups[] = {
757 	"pdm_din0_x", "pdm_din1_x", "pdm_din2_x", "pdm_dclk_x", "pdm_din2_a",
758 	"pdm_din1_a", "pdm_din0_a", "pdm_dclk",
759 };
760 
761 static const char * const gen_clk_groups[] = {
762 	"gen_clk_x", "gen_clk_f8", "gen_clk_f10", "gen_clk_a",
763 };
764 
765 static const char * const remote_input_groups[] = {
766 	"remote_input_f",
767 	"remote_input_a",
768 };
769 
770 static const char * const jtag_a_groups[] = {
771 	"jtag_a_clk", "jtag_a_tms", "jtag_a_tdi", "jtag_a_tdo",
772 };
773 
774 static const char * const clk_32k_in_groups[] = {
775 	"clk_32k_in",
776 };
777 
778 static const char * const remote_out_groups[] = {
779 	"remote_out",
780 };
781 
782 static const char * const spdif_in_groups[] = {
783 	"spdif_in_f6", "spdif_in_f7",
784 };
785 
786 static const char * const sw_groups[] = {
787 	"swclk", "swdio",
788 };
789 
790 static const char * const clk25_groups[] = {
791 	"clk_25",
792 };
793 
794 static const char * const cec_a_groups[] = {
795 	"cec_a",
796 };
797 
798 static const char * const cec_b_groups[] = {
799 	"cec_b",
800 };
801 
802 static const char * const clk12_24_groups[] = {
803 	"clk12_24",
804 };
805 
806 static const char * const mclk_0_groups[] = {
807 	"mclk_0",
808 };
809 
810 static const char * const tdm_b_groups[] = {
811 	"tdm_b_din0", "tdm_b_din1", "tdm_b_din2",
812 	"tdm_b_sclk", "tdm_b_fs", "tdm_b_dout0", "tdm_b_dout1",
813 	"tdm_b_dout2", "tdm_b_dout3", "tdm_b_dout4", "tdm_b_dout5",
814 	"tdm_b_slv_sclk", "tdm_b_slv_fs",
815 };
816 
817 static const char * const mclk_vad_groups[] = {
818 	"mclk_vad",
819 };
820 
821 static const char * const tdm_vad_groups[] = {
822 	"tdm_vad_sclk_a1", "tdm_vad_fs_a2", "tdm_vad_sclk_a5", "tdm_vad_fs_a6",
823 };
824 
825 static const char * const tst_out_groups[] = {
826 	"tst_out0", "tst_out1", "tst_out2", "tst_out3",
827 	"tst_out4", "tst_out5", "tst_out6", "tst_out7",
828 	"tst_out8", "tst_out9", "tst_out10", "tst_out11",
829 };
830 
831 static const char * const mute_groups[] = {
832 	"mute_key", "mute_en",
833 };
834 
835 static struct meson_pmx_func meson_a1_periphs_functions[] = {
836 	FUNCTION(gpio_periphs),
837 	FUNCTION(psram),
838 	FUNCTION(pwm_a),
839 	FUNCTION(pwm_b),
840 	FUNCTION(pwm_c),
841 	FUNCTION(pwm_d),
842 	FUNCTION(pwm_e),
843 	FUNCTION(pwm_f),
844 	FUNCTION(pwm_a_hiz),
845 	FUNCTION(pwm_b_hiz),
846 	FUNCTION(pwm_c_hiz),
847 	FUNCTION(spif),
848 	FUNCTION(sdcard),
849 	FUNCTION(tdm_a),
850 	FUNCTION(uart_a),
851 	FUNCTION(uart_b),
852 	FUNCTION(uart_c),
853 	FUNCTION(i2c0),
854 	FUNCTION(i2c1),
855 	FUNCTION(i2c2),
856 	FUNCTION(i2c3),
857 	FUNCTION(spi_a),
858 	FUNCTION(pdm),
859 	FUNCTION(gen_clk),
860 	FUNCTION(remote_input),
861 	FUNCTION(jtag_a),
862 	FUNCTION(clk_32k_in),
863 	FUNCTION(remote_out),
864 	FUNCTION(spdif_in),
865 	FUNCTION(sw),
866 	FUNCTION(clk25),
867 	FUNCTION(cec_a),
868 	FUNCTION(cec_b),
869 	FUNCTION(clk12_24),
870 	FUNCTION(mclk_0),
871 	FUNCTION(tdm_b),
872 	FUNCTION(mclk_vad),
873 	FUNCTION(tdm_vad),
874 	FUNCTION(tst_out),
875 	FUNCTION(mute),
876 };
877 
878 static struct meson_bank meson_a1_periphs_banks[] = {
879 	/* name  first  last  irq  pullen  pull  dir  out  in  ds*/
880 	BANK_DS("P",  GPIOP_0,  GPIOP_12,  0,  12, 0x3,  0,  0x4,  0,
881 		0x2,  0,  0x1,  0,  0x0,  0,  0x5,  0),
882 	BANK_DS("B",  GPIOB_0,    GPIOB_6,   13,  19,  0x13,  0,  0x14,  0,
883 		0x12,  0,  0x11,  0,  0x10,  0,  0x15,  0),
884 	BANK_DS("X",  GPIOX_0,    GPIOX_16,  20,  36,  0x23,  0,  0x24,  0,
885 		0x22,  0,  0x21,  0,  0x20,  0,  0x25,  0),
886 	BANK_DS("F",  GPIOF_0,    GPIOF_12,  37,  49,  0x33,  0,  0x34,  0,
887 		0x32,  0,  0x31,  0,  0x30,  0,  0x35,  0),
888 	BANK_DS("A",  GPIOA_0,    GPIOA_11,  50,  61,  0x43,  0,  0x44,  0,
889 		0x42,  0,  0x41,  0,  0x40,  0,  0x45,  0),
890 };
891 
892 static struct meson_pmx_bank meson_a1_periphs_pmx_banks[] = {
893 	/*  name	 first	    lask    reg	offset  */
894 	BANK_PMX("P",    GPIOP_0, GPIOP_12, 0x0, 0),
895 	BANK_PMX("B",    GPIOB_0, GPIOB_6,  0x2, 0),
896 	BANK_PMX("X",    GPIOX_0, GPIOX_16, 0x3, 0),
897 	BANK_PMX("F",    GPIOF_0, GPIOF_12, 0x6, 0),
898 	BANK_PMX("A",    GPIOA_0, GPIOA_11, 0x8, 0),
899 };
900 
901 static struct meson_axg_pmx_data meson_a1_periphs_pmx_banks_data = {
902 	.pmx_banks	= meson_a1_periphs_pmx_banks,
903 	.num_pmx_banks	= ARRAY_SIZE(meson_a1_periphs_pmx_banks),
904 };
905 
906 static struct meson_pinctrl_data meson_a1_periphs_pinctrl_data = {
907 	.name		= "periphs-banks",
908 	.pins		= meson_a1_periphs_pins,
909 	.groups		= meson_a1_periphs_groups,
910 	.funcs		= meson_a1_periphs_functions,
911 	.banks		= meson_a1_periphs_banks,
912 	.num_pins	= ARRAY_SIZE(meson_a1_periphs_pins),
913 	.num_groups	= ARRAY_SIZE(meson_a1_periphs_groups),
914 	.num_funcs	= ARRAY_SIZE(meson_a1_periphs_functions),
915 	.num_banks	= ARRAY_SIZE(meson_a1_periphs_banks),
916 	.pmx_ops	= &meson_axg_pmx_ops,
917 	.pmx_data	= &meson_a1_periphs_pmx_banks_data,
918 	.parse_dt	= &meson_a1_parse_dt_extra,
919 };
920 
921 static const struct of_device_id meson_a1_pinctrl_dt_match[] = {
922 	{
923 		.compatible = "amlogic,meson-a1-periphs-pinctrl",
924 		.data = &meson_a1_periphs_pinctrl_data,
925 	},
926 	{ },
927 };
928 
929 static struct platform_driver meson_a1_pinctrl_driver = {
930 	.probe  = meson_pinctrl_probe,
931 	.driver = {
932 		.name	= "meson-a1-pinctrl",
933 		.of_match_table = meson_a1_pinctrl_dt_match,
934 	},
935 };
936 
937 builtin_platform_driver(meson_a1_pinctrl_driver);
938