Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
0002 /*
0003  * Pin controller and GPIO driver for Amlogic Meson A1 SoC.
0004  *
0005  * Copyright (c) 2019 Amlogic, Inc. All rights reserved.
0006  * Author: Qianggui Song <qianggui.song@amlogic.com>
0007  */
0008 
0009 #include <dt-bindings/gpio/meson-a1-gpio.h>
0010 #include "pinctrl-meson.h"
0011 #include "pinctrl-meson-axg-pmx.h"
0012 
0013 static const struct pinctrl_pin_desc meson_a1_periphs_pins[] = {
0014     MESON_PIN(GPIOP_0),
0015     MESON_PIN(GPIOP_1),
0016     MESON_PIN(GPIOP_2),
0017     MESON_PIN(GPIOP_3),
0018     MESON_PIN(GPIOP_4),
0019     MESON_PIN(GPIOP_5),
0020     MESON_PIN(GPIOP_6),
0021     MESON_PIN(GPIOP_7),
0022     MESON_PIN(GPIOP_8),
0023     MESON_PIN(GPIOP_9),
0024     MESON_PIN(GPIOP_10),
0025     MESON_PIN(GPIOP_11),
0026     MESON_PIN(GPIOP_12),
0027     MESON_PIN(GPIOB_0),
0028     MESON_PIN(GPIOB_1),
0029     MESON_PIN(GPIOB_2),
0030     MESON_PIN(GPIOB_3),
0031     MESON_PIN(GPIOB_4),
0032     MESON_PIN(GPIOB_5),
0033     MESON_PIN(GPIOB_6),
0034     MESON_PIN(GPIOX_0),
0035     MESON_PIN(GPIOX_1),
0036     MESON_PIN(GPIOX_2),
0037     MESON_PIN(GPIOX_3),
0038     MESON_PIN(GPIOX_4),
0039     MESON_PIN(GPIOX_5),
0040     MESON_PIN(GPIOX_6),
0041     MESON_PIN(GPIOX_7),
0042     MESON_PIN(GPIOX_8),
0043     MESON_PIN(GPIOX_9),
0044     MESON_PIN(GPIOX_10),
0045     MESON_PIN(GPIOX_11),
0046     MESON_PIN(GPIOX_12),
0047     MESON_PIN(GPIOX_13),
0048     MESON_PIN(GPIOX_14),
0049     MESON_PIN(GPIOX_15),
0050     MESON_PIN(GPIOX_16),
0051     MESON_PIN(GPIOF_0),
0052     MESON_PIN(GPIOF_1),
0053     MESON_PIN(GPIOF_2),
0054     MESON_PIN(GPIOF_3),
0055     MESON_PIN(GPIOF_4),
0056     MESON_PIN(GPIOF_5),
0057     MESON_PIN(GPIOF_6),
0058     MESON_PIN(GPIOF_7),
0059     MESON_PIN(GPIOF_8),
0060     MESON_PIN(GPIOF_9),
0061     MESON_PIN(GPIOF_10),
0062     MESON_PIN(GPIOF_11),
0063     MESON_PIN(GPIOF_12),
0064     MESON_PIN(GPIOA_0),
0065     MESON_PIN(GPIOA_1),
0066     MESON_PIN(GPIOA_2),
0067     MESON_PIN(GPIOA_3),
0068     MESON_PIN(GPIOA_4),
0069     MESON_PIN(GPIOA_5),
0070     MESON_PIN(GPIOA_6),
0071     MESON_PIN(GPIOA_7),
0072     MESON_PIN(GPIOA_8),
0073     MESON_PIN(GPIOA_9),
0074     MESON_PIN(GPIOA_10),
0075     MESON_PIN(GPIOA_11),
0076 };
0077 
0078 /* psram */
0079 static const unsigned int psram_clkn_pins[]     = { GPIOP_0 };
0080 static const unsigned int psram_clkp_pins[]     = { GPIOP_1 };
0081 static const unsigned int psram_ce_n_pins[]     = { GPIOP_2 };
0082 static const unsigned int psram_rst_n_pins[]        = { GPIOP_3 };
0083 static const unsigned int psram_adq0_pins[]     = { GPIOP_4 };
0084 static const unsigned int psram_adq1_pins[]     = { GPIOP_5 };
0085 static const unsigned int psram_adq2_pins[]     = { GPIOP_6 };
0086 static const unsigned int psram_adq3_pins[]     = { GPIOP_7 };
0087 static const unsigned int psram_adq4_pins[]     = { GPIOP_8 };
0088 static const unsigned int psram_adq5_pins[]     = { GPIOP_9 };
0089 static const unsigned int psram_adq6_pins[]     = { GPIOP_10 };
0090 static const unsigned int psram_adq7_pins[]     = { GPIOP_11 };
0091 static const unsigned int psram_dqs_dm_pins[]       = { GPIOP_12 };
0092 
0093 /* sdcard */
0094 static const unsigned int sdcard_d0_b_pins[]        = { GPIOB_0 };
0095 static const unsigned int sdcard_d1_b_pins[]        = { GPIOB_1 };
0096 static const unsigned int sdcard_d2_b_pins[]        = { GPIOB_2 };
0097 static const unsigned int sdcard_d3_b_pins[]        = { GPIOB_3 };
0098 static const unsigned int sdcard_clk_b_pins[]       = { GPIOB_4 };
0099 static const unsigned int sdcard_cmd_b_pins[]       = { GPIOB_5 };
0100 
0101 static const unsigned int sdcard_d0_x_pins[]        = { GPIOX_0 };
0102 static const unsigned int sdcard_d1_x_pins[]        = { GPIOX_1 };
0103 static const unsigned int sdcard_d2_x_pins[]        = { GPIOX_2 };
0104 static const unsigned int sdcard_d3_x_pins[]        = { GPIOX_3 };
0105 static const unsigned int sdcard_clk_x_pins[]       = { GPIOX_4 };
0106 static const unsigned int sdcard_cmd_x_pins[]       = { GPIOX_5 };
0107 
0108 /* spif */
0109 static const unsigned int spif_mo_pins[]        = { GPIOB_0 };
0110 static const unsigned int spif_mi_pins[]        = { GPIOB_1 };
0111 static const unsigned int spif_wp_n_pins[]      = { GPIOB_2 };
0112 static const unsigned int spif_hold_n_pins[]        = { GPIOB_3 };
0113 static const unsigned int spif_clk_pins[]       = { GPIOB_4 };
0114 static const unsigned int spif_cs_pins[]        = { GPIOB_5 };
0115 
0116 /* i2c0 */
0117 static const unsigned int i2c0_sck_f9_pins[]        = { GPIOF_9 };
0118 static const unsigned int i2c0_sda_f10_pins[]       = { GPIOF_10 };
0119 static const unsigned int i2c0_sck_f11_pins[]       = { GPIOF_11 };
0120 static const unsigned int i2c0_sda_f12_pins[]       = { GPIOF_12 };
0121 
0122 /* i2c1 */
0123 static const unsigned int i2c1_sda_x_pins[]     = { GPIOX_9 };
0124 static const unsigned int i2c1_sck_x_pins[]     = { GPIOX_10 };
0125 static const unsigned int i2c1_sda_a_pins[]     = { GPIOA_10 };
0126 static const unsigned int i2c1_sck_a_pins[]     = { GPIOA_11 };
0127 
0128 /* i2c2 */
0129 static const unsigned int i2c2_sck_x0_pins[]        = { GPIOX_0 };
0130 static const unsigned int i2c2_sda_x1_pins[]        = { GPIOX_1 };
0131 static const unsigned int i2c2_sck_x15_pins[]       = { GPIOX_15 };
0132 static const unsigned int i2c2_sda_x16_pins[]       = { GPIOX_16 };
0133 static const unsigned int i2c2_sck_a4_pins[]        = { GPIOA_4 };
0134 static const unsigned int i2c2_sda_a5_pins[]        = { GPIOA_5 };
0135 static const unsigned int i2c2_sck_a8_pins[]        = { GPIOA_8 };
0136 static const unsigned int i2c2_sda_a9_pins[]        = { GPIOA_9 };
0137 
0138 /* i2c3 */
0139 static const unsigned int i2c3_sck_f_pins[]     = { GPIOF_4 };
0140 static const unsigned int i2c3_sda_f_pins[]     = { GPIOF_5 };
0141 static const unsigned int i2c3_sck_x_pins[]     = { GPIOX_11 };
0142 static const unsigned int i2c3_sda_x_pins[]     = { GPIOX_12 };
0143 
0144 /* i2c slave */
0145 static const unsigned int i2c_slave_sck_a_pins[]    = { GPIOA_10 };
0146 static const unsigned int i2c_slave_sda_a_pins[]    = { GPIOA_11 };
0147 static const unsigned int i2c_slave_sck_f_pins[]    = { GPIOF_11 };
0148 static const unsigned int i2c_slave_sda_f_pins[]    = { GPIOF_12 };
0149 
0150 /* uart_a */
0151 static const unsigned int uart_a_tx_pins[]      = { GPIOX_11 };
0152 static const unsigned int uart_a_rx_pins[]      = { GPIOX_12 };
0153 static const unsigned int uart_a_cts_pins[]     = { GPIOX_13 };
0154 static const unsigned int uart_a_rts_pins[]     = { GPIOX_14 };
0155 
0156 /* uart_b */
0157 static const unsigned int uart_b_tx_x_pins[]        = { GPIOX_7 };
0158 static const unsigned int uart_b_rx_x_pins[]        = { GPIOX_8 };
0159 static const unsigned int uart_b_tx_f_pins[]        = { GPIOF_0 };
0160 static const unsigned int uart_b_rx_f_pins[]        = { GPIOF_1 };
0161 
0162 /* uart_c */
0163 static const unsigned int uart_c_tx_x0_pins[]       = { GPIOX_0 };
0164 static const unsigned int uart_c_rx_x1_pins[]       = { GPIOX_1 };
0165 static const unsigned int uart_c_cts_pins[]     = { GPIOX_2 };
0166 static const unsigned int uart_c_rts_pins[]     = { GPIOX_3 };
0167 static const unsigned int uart_c_tx_x15_pins[]      = { GPIOX_15 };
0168 static const unsigned int uart_c_rx_x16_pins[]      = { GPIOX_16 };
0169 
0170 /* pmw_a */
0171 static const unsigned int pwm_a_x6_pins[]       = { GPIOX_6 };
0172 static const unsigned int pwm_a_x7_pins[]       = { GPIOX_7 };
0173 static const unsigned int pwm_a_f6_pins[]       = { GPIOF_6 };
0174 static const unsigned int pwm_a_f10_pins[]      = { GPIOF_10 };
0175 static const unsigned int pwm_a_a_pins[]        = { GPIOA_5 };
0176 
0177 /* pmw_b */
0178 static const unsigned int pwm_b_x_pins[]        = { GPIOX_8 };
0179 static const unsigned int pwm_b_f_pins[]        = { GPIOF_7 };
0180 static const unsigned int pwm_b_a_pins[]        = { GPIOA_11 };
0181 
0182 /* pmw_c */
0183 static const unsigned int pwm_c_x_pins[]        = { GPIOX_9 };
0184 static const unsigned int pwm_c_f3_pins[]       = { GPIOF_3 };
0185 static const unsigned int pwm_c_f8_pins[]       = { GPIOF_8 };
0186 static const unsigned int pwm_c_a_pins[]        = { GPIOA_10 };
0187 
0188 /* pwm_d */
0189 static const unsigned int pwm_d_x10_pins[]      = { GPIOX_10 };
0190 static const unsigned int pwm_d_x13_pins[]      = { GPIOX_13 };
0191 static const unsigned int pwm_d_x15_pins[]      = { GPIOX_15 };
0192 static const unsigned int pwm_d_f_pins[]        = { GPIOF_11 };
0193 
0194 /* pwm_e */
0195 static const unsigned int pwm_e_p_pins[]        = { GPIOP_3 };
0196 static const unsigned int pwm_e_x2_pins[]       = { GPIOX_2 };
0197 static const unsigned int pwm_e_x14_pins[]      = { GPIOX_14 };
0198 static const unsigned int pwm_e_x16_pins[]      = { GPIOX_16 };
0199 static const unsigned int pwm_e_f_pins[]        = { GPIOF_3 };
0200 static const unsigned int pwm_e_a_pins[]        = { GPIOA_0 };
0201 
0202 /* pwm_f */
0203 static const unsigned int pwm_f_b_pins[]        = { GPIOB_6 };
0204 static const unsigned int pwm_f_x_pins[]        = { GPIOX_3 };
0205 static const unsigned int pwm_f_f4_pins[]       = { GPIOF_4 };
0206 static const unsigned int pwm_f_f12_pins[]      = { GPIOF_12 };
0207 
0208 /* pwm_a_hiz */
0209 static const unsigned int pwm_a_hiz_f8_pins[]       = { GPIOF_8 };
0210 static const unsigned int pwm_a_hiz_f10_pins[]      = { GPIOF_10 };
0211 static const unsigned int pmw_a_hiz_f6_pins[]       = { GPIOF_6 };
0212 
0213 /* pwm_b_hiz */
0214 static const unsigned int pwm_b_hiz_pins[]      = { GPIOF_7 };
0215 
0216 /* pmw_c_hiz */
0217 static const unsigned int pwm_c_hiz_pins[]      = { GPIOF_8 };
0218 
0219 /* tdm_a */
0220 static const unsigned int tdm_a_dout1_pins[]        = { GPIOX_7 };
0221 static const unsigned int tdm_a_dout0_pins[]        = { GPIOX_8 };
0222 static const unsigned int tdm_a_fs_pins[]       = { GPIOX_9 };
0223 static const unsigned int tdm_a_sclk_pins[]     = { GPIOX_10 };
0224 static const unsigned int tdm_a_din1_pins[]     = { GPIOX_7 };
0225 static const unsigned int tdm_a_din0_pins[]     = { GPIOX_8 };
0226 static const unsigned int tdm_a_slv_fs_pins[]       = { GPIOX_9 };
0227 static const unsigned int tdm_a_slv_sclk_pins[]     = { GPIOX_10 };
0228 
0229 /* spi_a */
0230 static const unsigned int spi_a_mosi_x2_pins[]      = { GPIOX_2 };
0231 static const unsigned int spi_a_ss0_x3_pins[]       = { GPIOX_3 };
0232 static const unsigned int spi_a_sclk_x4_pins[]      = { GPIOX_4 };
0233 static const unsigned int spi_a_miso_x5_pins[]      = { GPIOX_5 };
0234 static const unsigned int spi_a_mosi_x7_pins[]      = { GPIOX_7 };
0235 static const unsigned int spi_a_miso_x8_pins[]      = { GPIOX_8 };
0236 static const unsigned int spi_a_ss0_x9_pins[]       = { GPIOX_9 };
0237 static const unsigned int spi_a_sclk_x10_pins[]     = { GPIOX_10 };
0238 
0239 static const unsigned int spi_a_mosi_a_pins[]       = { GPIOA_6 };
0240 static const unsigned int spi_a_miso_a_pins[]       = { GPIOA_7 };
0241 static const unsigned int spi_a_ss0_a_pins[]        = { GPIOA_8 };
0242 static const unsigned int spi_a_sclk_a_pins[]       = { GPIOA_9 };
0243 
0244 /* pdm */
0245 static const unsigned int pdm_din0_x_pins[]     = { GPIOX_7 };
0246 static const unsigned int pdm_din1_x_pins[]     = { GPIOX_8 };
0247 static const unsigned int pdm_din2_x_pins[]     = { GPIOX_9 };
0248 static const unsigned int pdm_dclk_x_pins[]     = { GPIOX_10 };
0249 
0250 static const unsigned int pdm_din2_a_pins[]     = { GPIOA_6 };
0251 static const unsigned int pdm_din1_a_pins[]     = { GPIOA_7 };
0252 static const unsigned int pdm_din0_a_pins[]     = { GPIOA_8 };
0253 static const unsigned int pdm_dclk_pins[]       = { GPIOA_9 };
0254 
0255 /* gen_clk */
0256 static const unsigned int gen_clk_x_pins[]      = { GPIOX_7 };
0257 static const unsigned int gen_clk_f8_pins[]     = { GPIOF_8 };
0258 static const unsigned int gen_clk_f10_pins[]        = { GPIOF_10 };
0259 static const unsigned int gen_clk_a_pins[]      = { GPIOA_11 };
0260 
0261 /* jtag_a */
0262 static const unsigned int jtag_a_clk_pins[]     = { GPIOF_4 };
0263 static const unsigned int jtag_a_tms_pins[]     = { GPIOF_5 };
0264 static const unsigned int jtag_a_tdi_pins[]     = { GPIOF_6 };
0265 static const unsigned int jtag_a_tdo_pins[]     = { GPIOF_7 };
0266 
0267 /* clk_32_in */
0268 static const unsigned int clk_32k_in_pins[]     = { GPIOF_2 };
0269 
0270 /* ir in */
0271 static const unsigned int remote_input_f_pins[]     = { GPIOF_3 };
0272 static const unsigned int remote_input_a_pins[]     = { GPIOA_11 };
0273 
0274 /* ir out */
0275 static const unsigned int remote_out_pins[]     = { GPIOF_5 };
0276 
0277 /* spdif */
0278 static const unsigned int spdif_in_f6_pins[]        = { GPIOF_6 };
0279 static const unsigned int spdif_in_f7_pins[]        = { GPIOF_7 };
0280 
0281 /* sw */
0282 static const unsigned int swclk_pins[]          = { GPIOF_4 };
0283 static const unsigned int swdio_pins[]          = { GPIOF_5 };
0284 
0285 /* clk_25 */
0286 static const unsigned int clk25_pins[]          = { GPIOF_10 };
0287 
0288 /* cec_a */
0289 static const unsigned int cec_a_pins[]          = { GPIOF_2 };
0290 
0291 /* cec_b */
0292 static const unsigned int cec_b_pins[]          = { GPIOF_2 };
0293 
0294 /* clk12_24 */
0295 static const unsigned int clk12_24_pins[]       = { GPIOF_10 };
0296 
0297 /* mclk_0 */
0298 static const unsigned int mclk_0_pins[]         = { GPIOA_0 };
0299 
0300 /* tdm_b */
0301 static const unsigned int tdm_b_sclk_pins[]     = { GPIOA_1 };
0302 static const unsigned int tdm_b_fs_pins[]       = { GPIOA_2 };
0303 static const unsigned int tdm_b_dout0_pins[]        = { GPIOA_3 };
0304 static const unsigned int tdm_b_dout1_pins[]        = { GPIOA_4 };
0305 static const unsigned int tdm_b_dout2_pins[]        = { GPIOA_5 };
0306 static const unsigned int tdm_b_dout3_pins[]        = { GPIOA_6 };
0307 static const unsigned int tdm_b_dout4_pins[]        = { GPIOA_7 };
0308 static const unsigned int tdm_b_dout5_pins[]        = { GPIOA_8 };
0309 static const unsigned int tdm_b_slv_sclk_pins[]     = { GPIOA_5 };
0310 static const unsigned int tdm_b_slv_fs_pins[]       = { GPIOA_6 };
0311 static const unsigned int tdm_b_din0_pins[]     = { GPIOA_7 };
0312 static const unsigned int tdm_b_din1_pins[]     = { GPIOA_8 };
0313 static const unsigned int tdm_b_din2_pins[]     = { GPIOA_9 };
0314 
0315 /* mclk_vad */
0316 static const unsigned int mclk_vad_pins[]       = { GPIOA_0 };
0317 
0318 /* tdm_vad */
0319 static const unsigned int tdm_vad_sclk_a1_pins[]    = { GPIOA_1 };
0320 static const unsigned int tdm_vad_fs_a2_pins[]      = { GPIOA_2 };
0321 static const unsigned int tdm_vad_sclk_a5_pins[]    = { GPIOA_5 };
0322 static const unsigned int tdm_vad_fs_a6_pins[]      = { GPIOA_6 };
0323 
0324 /* tst_out */
0325 static const unsigned int tst_out0_pins[]       = { GPIOA_0 };
0326 static const unsigned int tst_out1_pins[]       = { GPIOA_1 };
0327 static const unsigned int tst_out2_pins[]       = { GPIOA_2 };
0328 static const unsigned int tst_out3_pins[]       = { GPIOA_3 };
0329 static const unsigned int tst_out4_pins[]       = { GPIOA_4 };
0330 static const unsigned int tst_out5_pins[]       = { GPIOA_5 };
0331 static const unsigned int tst_out6_pins[]       = { GPIOA_6 };
0332 static const unsigned int tst_out7_pins[]       = { GPIOA_7 };
0333 static const unsigned int tst_out8_pins[]       = { GPIOA_8 };
0334 static const unsigned int tst_out9_pins[]       = { GPIOA_9 };
0335 static const unsigned int tst_out10_pins[]      = { GPIOA_10 };
0336 static const unsigned int tst_out11_pins[]      = { GPIOA_11 };
0337 
0338 /* mute */
0339 static const unsigned int mute_key_pins[]       = { GPIOA_4 };
0340 static const unsigned int mute_en_pins[]        = { GPIOA_5 };
0341 
0342 static struct meson_pmx_group meson_a1_periphs_groups[] = {
0343     GPIO_GROUP(GPIOP_0),
0344     GPIO_GROUP(GPIOP_1),
0345     GPIO_GROUP(GPIOP_2),
0346     GPIO_GROUP(GPIOP_3),
0347     GPIO_GROUP(GPIOP_4),
0348     GPIO_GROUP(GPIOP_5),
0349     GPIO_GROUP(GPIOP_6),
0350     GPIO_GROUP(GPIOP_7),
0351     GPIO_GROUP(GPIOP_8),
0352     GPIO_GROUP(GPIOP_9),
0353     GPIO_GROUP(GPIOP_10),
0354     GPIO_GROUP(GPIOP_11),
0355     GPIO_GROUP(GPIOP_12),
0356     GPIO_GROUP(GPIOB_0),
0357     GPIO_GROUP(GPIOB_1),
0358     GPIO_GROUP(GPIOB_2),
0359     GPIO_GROUP(GPIOB_3),
0360     GPIO_GROUP(GPIOB_4),
0361     GPIO_GROUP(GPIOB_5),
0362     GPIO_GROUP(GPIOB_6),
0363     GPIO_GROUP(GPIOX_0),
0364     GPIO_GROUP(GPIOX_1),
0365     GPIO_GROUP(GPIOX_2),
0366     GPIO_GROUP(GPIOX_3),
0367     GPIO_GROUP(GPIOX_4),
0368     GPIO_GROUP(GPIOX_5),
0369     GPIO_GROUP(GPIOX_6),
0370     GPIO_GROUP(GPIOX_7),
0371     GPIO_GROUP(GPIOX_8),
0372     GPIO_GROUP(GPIOX_9),
0373     GPIO_GROUP(GPIOX_10),
0374     GPIO_GROUP(GPIOX_11),
0375     GPIO_GROUP(GPIOX_12),
0376     GPIO_GROUP(GPIOX_13),
0377     GPIO_GROUP(GPIOX_14),
0378     GPIO_GROUP(GPIOX_15),
0379     GPIO_GROUP(GPIOX_16),
0380     GPIO_GROUP(GPIOF_0),
0381     GPIO_GROUP(GPIOF_1),
0382     GPIO_GROUP(GPIOF_2),
0383     GPIO_GROUP(GPIOF_3),
0384     GPIO_GROUP(GPIOF_4),
0385     GPIO_GROUP(GPIOF_5),
0386     GPIO_GROUP(GPIOF_6),
0387     GPIO_GROUP(GPIOF_7),
0388     GPIO_GROUP(GPIOF_8),
0389     GPIO_GROUP(GPIOF_9),
0390     GPIO_GROUP(GPIOF_10),
0391     GPIO_GROUP(GPIOF_11),
0392     GPIO_GROUP(GPIOF_12),
0393     GPIO_GROUP(GPIOA_0),
0394     GPIO_GROUP(GPIOA_1),
0395     GPIO_GROUP(GPIOA_2),
0396     GPIO_GROUP(GPIOA_3),
0397     GPIO_GROUP(GPIOA_4),
0398     GPIO_GROUP(GPIOA_5),
0399     GPIO_GROUP(GPIOA_6),
0400     GPIO_GROUP(GPIOA_7),
0401     GPIO_GROUP(GPIOA_8),
0402     GPIO_GROUP(GPIOA_9),
0403     GPIO_GROUP(GPIOA_10),
0404     GPIO_GROUP(GPIOA_11),
0405 
0406     /* bank P func1 */
0407     GROUP(psram_clkn,       1),
0408     GROUP(psram_clkp,       1),
0409     GROUP(psram_ce_n,       1),
0410     GROUP(psram_rst_n,      1),
0411     GROUP(psram_adq0,       1),
0412     GROUP(psram_adq1,       1),
0413     GROUP(psram_adq2,       1),
0414     GROUP(psram_adq3,       1),
0415     GROUP(psram_adq4,       1),
0416     GROUP(psram_adq5,       1),
0417     GROUP(psram_adq6,       1),
0418     GROUP(psram_adq7,       1),
0419     GROUP(psram_dqs_dm,     1),
0420 
0421     /*bank P func2 */
0422     GROUP(pwm_e_p,          2),
0423 
0424     /*bank B func1 */
0425     GROUP(spif_mo,          1),
0426     GROUP(spif_mi,          1),
0427     GROUP(spif_wp_n,        1),
0428     GROUP(spif_hold_n,      1),
0429     GROUP(spif_clk,         1),
0430     GROUP(spif_cs,          1),
0431     GROUP(pwm_f_b,          1),
0432 
0433     /*bank B func2 */
0434     GROUP(sdcard_d0_b,      2),
0435     GROUP(sdcard_d1_b,      2),
0436     GROUP(sdcard_d2_b,      2),
0437     GROUP(sdcard_d3_b,      2),
0438     GROUP(sdcard_clk_b,     2),
0439     GROUP(sdcard_cmd_b,     2),
0440 
0441     /*bank X func1 */
0442     GROUP(sdcard_d0_x,      1),
0443     GROUP(sdcard_d1_x,      1),
0444     GROUP(sdcard_d2_x,      1),
0445     GROUP(sdcard_d3_x,      1),
0446     GROUP(sdcard_clk_x,     1),
0447     GROUP(sdcard_cmd_x,     1),
0448     GROUP(pwm_a_x6,         1),
0449     GROUP(tdm_a_dout1,      1),
0450     GROUP(tdm_a_dout0,      1),
0451     GROUP(tdm_a_fs,         1),
0452     GROUP(tdm_a_sclk,       1),
0453     GROUP(uart_a_tx,        1),
0454     GROUP(uart_a_rx,        1),
0455     GROUP(uart_a_cts,       1),
0456     GROUP(uart_a_rts,       1),
0457     GROUP(pwm_d_x15,        1),
0458     GROUP(pwm_e_x16,        1),
0459 
0460     /*bank X func2 */
0461     GROUP(i2c2_sck_x0,      2),
0462     GROUP(i2c2_sda_x1,      2),
0463     GROUP(spi_a_mosi_x2,        2),
0464     GROUP(spi_a_ss0_x3,     2),
0465     GROUP(spi_a_sclk_x4,        2),
0466     GROUP(spi_a_miso_x5,        2),
0467     GROUP(tdm_a_din1,       2),
0468     GROUP(tdm_a_din0,       2),
0469     GROUP(tdm_a_slv_fs,     2),
0470     GROUP(tdm_a_slv_sclk,       2),
0471     GROUP(i2c3_sck_x,       2),
0472     GROUP(i2c3_sda_x,       2),
0473     GROUP(pwm_d_x13,        2),
0474     GROUP(pwm_e_x14,        2),
0475     GROUP(i2c2_sck_x15,     2),
0476     GROUP(i2c2_sda_x16,     2),
0477 
0478     /*bank X func3 */
0479     GROUP(uart_c_tx_x0,     3),
0480     GROUP(uart_c_rx_x1,     3),
0481     GROUP(uart_c_cts,       3),
0482     GROUP(uart_c_rts,       3),
0483     GROUP(pdm_din0_x,       3),
0484     GROUP(pdm_din1_x,       3),
0485     GROUP(pdm_din2_x,       3),
0486     GROUP(pdm_dclk_x,       3),
0487     GROUP(uart_c_tx_x15,        3),
0488     GROUP(uart_c_rx_x16,        3),
0489 
0490     /*bank X func4 */
0491     GROUP(pwm_e_x2,         4),
0492     GROUP(pwm_f_x,          4),
0493     GROUP(spi_a_mosi_x7,        4),
0494     GROUP(spi_a_miso_x8,        4),
0495     GROUP(spi_a_ss0_x9,     4),
0496     GROUP(spi_a_sclk_x10,       4),
0497 
0498     /*bank X func5 */
0499     GROUP(uart_b_tx_x,      5),
0500     GROUP(uart_b_rx_x,      5),
0501     GROUP(i2c1_sda_x,       5),
0502     GROUP(i2c1_sck_x,       5),
0503 
0504     /*bank X func6 */
0505     GROUP(pwm_a_x7,         6),
0506     GROUP(pwm_b_x,          6),
0507     GROUP(pwm_c_x,          6),
0508     GROUP(pwm_d_x10,        6),
0509 
0510     /*bank X func7 */
0511     GROUP(gen_clk_x,        7),
0512 
0513     /*bank F func1 */
0514     GROUP(uart_b_tx_f,      1),
0515     GROUP(uart_b_rx_f,      1),
0516     GROUP(remote_input_f,       1),
0517     GROUP(jtag_a_clk,       1),
0518     GROUP(jtag_a_tms,       1),
0519     GROUP(jtag_a_tdi,       1),
0520     GROUP(jtag_a_tdo,       1),
0521     GROUP(gen_clk_f8,       1),
0522     GROUP(pwm_a_f10,        1),
0523     GROUP(i2c0_sck_f11,     1),
0524     GROUP(i2c0_sda_f12,     1),
0525 
0526     /*bank F func2 */
0527     GROUP(clk_32k_in,       2),
0528     GROUP(pwm_e_f,          2),
0529     GROUP(pwm_f_f4,         2),
0530     GROUP(remote_out,       2),
0531     GROUP(spdif_in_f6,      2),
0532     GROUP(spdif_in_f7,      2),
0533     GROUP(pwm_a_hiz_f8,     2),
0534     GROUP(pwm_a_hiz_f10,        2),
0535     GROUP(pwm_d_f,          2),
0536     GROUP(pwm_f_f12,        2),
0537 
0538     /*bank F func3 */
0539     GROUP(pwm_c_f3,         3),
0540     GROUP(swclk,            3),
0541     GROUP(swdio,            3),
0542     GROUP(pwm_a_f6,         3),
0543     GROUP(pwm_b_f,          3),
0544     GROUP(pwm_c_f8,         3),
0545     GROUP(clk25,            3),
0546     GROUP(i2c_slave_sck_f,      3),
0547     GROUP(i2c_slave_sda_f,      3),
0548 
0549     /*bank F func4 */
0550     GROUP(cec_a,            4),
0551     GROUP(i2c3_sck_f,       4),
0552     GROUP(i2c3_sda_f,       4),
0553     GROUP(pmw_a_hiz_f6,     4),
0554     GROUP(pwm_b_hiz,        4),
0555     GROUP(pwm_c_hiz,        4),
0556     GROUP(i2c0_sck_f9,      4),
0557     GROUP(i2c0_sda_f10,     4),
0558 
0559     /*bank F func5 */
0560     GROUP(cec_b,            5),
0561     GROUP(clk12_24,         5),
0562 
0563     /*bank F func7 */
0564     GROUP(gen_clk_f10,      7),
0565 
0566     /*bank A func1 */
0567     GROUP(mclk_0,           1),
0568     GROUP(tdm_b_sclk,       1),
0569     GROUP(tdm_b_fs,         1),
0570     GROUP(tdm_b_dout0,      1),
0571     GROUP(tdm_b_dout1,      1),
0572     GROUP(tdm_b_dout2,      1),
0573     GROUP(tdm_b_dout3,      1),
0574     GROUP(tdm_b_dout4,      1),
0575     GROUP(tdm_b_dout5,      1),
0576     GROUP(remote_input_a,       1),
0577 
0578     /*bank A func2 */
0579     GROUP(pwm_e_a,          2),
0580     GROUP(tdm_b_slv_sclk,       2),
0581     GROUP(tdm_b_slv_fs,     2),
0582     GROUP(tdm_b_din0,       2),
0583     GROUP(tdm_b_din1,       2),
0584     GROUP(tdm_b_din2,       2),
0585     GROUP(i2c1_sda_a,       2),
0586     GROUP(i2c1_sck_a,       2),
0587 
0588     /*bank A func3 */
0589     GROUP(i2c2_sck_a4,      3),
0590     GROUP(i2c2_sda_a5,      3),
0591     GROUP(pdm_din2_a,       3),
0592     GROUP(pdm_din1_a,       3),
0593     GROUP(pdm_din0_a,       3),
0594     GROUP(pdm_dclk,         3),
0595     GROUP(pwm_c_a,          3),
0596     GROUP(pwm_b_a,          3),
0597 
0598     /*bank A func4 */
0599     GROUP(pwm_a_a,          4),
0600     GROUP(spi_a_mosi_a,     4),
0601     GROUP(spi_a_miso_a,     4),
0602     GROUP(spi_a_ss0_a,      4),
0603     GROUP(spi_a_sclk_a,     4),
0604     GROUP(i2c_slave_sck_a,      4),
0605     GROUP(i2c_slave_sda_a,      4),
0606 
0607     /*bank A func5 */
0608     GROUP(mclk_vad,         5),
0609     GROUP(tdm_vad_sclk_a1,      5),
0610     GROUP(tdm_vad_fs_a2,        5),
0611     GROUP(tdm_vad_sclk_a5,      5),
0612     GROUP(tdm_vad_fs_a6,        5),
0613     GROUP(i2c2_sck_a8,      5),
0614     GROUP(i2c2_sda_a9,      5),
0615 
0616     /*bank A func6 */
0617     GROUP(tst_out0,         6),
0618     GROUP(tst_out1,         6),
0619     GROUP(tst_out2,         6),
0620     GROUP(tst_out3,         6),
0621     GROUP(tst_out4,         6),
0622     GROUP(tst_out5,         6),
0623     GROUP(tst_out6,         6),
0624     GROUP(tst_out7,         6),
0625     GROUP(tst_out8,         6),
0626     GROUP(tst_out9,         6),
0627     GROUP(tst_out10,        6),
0628     GROUP(tst_out11,        6),
0629 
0630     /*bank A func7 */
0631     GROUP(mute_key,         7),
0632     GROUP(mute_en,          7),
0633     GROUP(gen_clk_a,        7),
0634 };
0635 
0636 static const char * const gpio_periphs_groups[] = {
0637     "GPIOP_0", "GPIOP_1", "GPIOP_2", "GPIOP_3", "GPIOP_4",
0638     "GPIOP_5", "GPIOP_6", "GPIOP_7", "GPIOP_8", "GPIOP_9",
0639     "GPIOP_10", "GPIOP_11", "GPIOP_12",
0640 
0641     "GPIOB_0", "GPIOB_1", "GPIOB_2", "GPIOB_3", "GPIOB_4",
0642     "GPIOB_5", "GPIOB_6",
0643 
0644     "GPIOX_0", "GPIOX_1", "GPIOX_2", "GPIOX_3", "GPIOX_4",
0645     "GPIOX_5", "GPIOX_6", "GPIOX_7", "GPIOX_8", "GPIOX_9",
0646     "GPIOX_10", "GPIOX_11", "GPIOX_12", "GPIOX_13", "GPIOX_14",
0647     "GPIOX_15", "GPIOX_16",
0648 
0649     "GPIOF_0", "GPIOF_1", "GPIOF_2", "GPIOF_3", "GPIOF_4",
0650     "GPIOF_5", "GPIOF_6", "GPIOF_7", "GPIOF_8", "GPIOF_9",
0651     "GPIOF_10", "GPIOF_11", "GPIOF_12",
0652 
0653     "GPIOA_0", "GPIOA_1", "GPIOA_2", "GPIOA_3", "GPIOA_4",
0654     "GPIOA_5", "GPIOA_6", "GPIOA_7", "GPIOA_8", "GPIOA_9",
0655     "GPIOA_10", "GPIOA_11",
0656 };
0657 
0658 static const char * const psram_groups[] = {
0659     "psram_clkn", "psram_clkp", "psram_ce_n", "psram_rst_n", "psram_adq0",
0660     "psram_adq1", "psram_adq2", "psram_adq3", "psram_adq4", "psram_adq5",
0661     "psram_adq6", "psram_adq7", "psram_dqs_dm",
0662 };
0663 
0664 static const char * const pwm_a_groups[] = {
0665     "pwm_a_x6", "pwm_a_x7", "pwm_a_f10", "pwm_a_f6", "pwm_a_a",
0666 };
0667 
0668 static const char * const pwm_b_groups[] = {
0669     "pwm_b_x", "pwm_b_f", "pwm_b_a",
0670 };
0671 
0672 static const char * const pwm_c_groups[] = {
0673     "pwm_c_x", "pwm_c_f3", "pwm_c_f8", "pwm_c_a",
0674 };
0675 
0676 static const char * const pwm_d_groups[] = {
0677     "pwm_d_x15", "pwm_d_x13", "pwm_d_x10", "pwm_d_f",
0678 };
0679 
0680 static const char * const pwm_e_groups[] = {
0681     "pwm_e_p", "pwm_e_x16", "pwm_e_x14", "pwm_e_x2", "pwm_e_f",
0682     "pwm_e_a",
0683 };
0684 
0685 static const char * const pwm_f_groups[] = {
0686     "pwm_f_b", "pwm_f_x", "pwm_f_f4", "pwm_f_f12",
0687 };
0688 
0689 static const char * const pwm_a_hiz_groups[] = {
0690     "pwm_a_hiz_f8", "pwm_a_hiz_f10", "pwm_a_hiz_f6",
0691 };
0692 
0693 static const char * const pwm_b_hiz_groups[] = {
0694     "pwm_b_hiz",
0695 };
0696 
0697 static const char * const pwm_c_hiz_groups[] = {
0698     "pwm_c_hiz",
0699 };
0700 
0701 static const char * const spif_groups[] = {
0702     "spif_mo", "spif_mi", "spif_wp_n", "spif_hold_n", "spif_clk",
0703     "spif_cs",
0704 };
0705 
0706 static const char * const sdcard_groups[] = {
0707     "sdcard_d0_b", "sdcard_d1_b", "sdcard_d2_b", "sdcard_d3_b",
0708     "sdcard_clk_b", "sdcard_cmd_b",
0709 
0710     "sdcard_d0_x", "sdcard_d1_x", "sdcard_d2_x", "sdcard_d3_x",
0711     "sdcard_clk_x", "sdcard_cmd_x",
0712 };
0713 
0714 static const char * const tdm_a_groups[] = {
0715     "tdm_a_din0", "tdm_a_din1",  "tdm_a_fs", "tdm_a_sclk",
0716     "tdm_a_slv_fs", "tdm_a_slv_sclk", "tdm_a_dout0", "tdm_a_dout1",
0717 };
0718 
0719 static const char * const uart_a_groups[] = {
0720     "uart_a_tx", "uart_a_rx", "uart_a_cts", "uart_a_rts",
0721 };
0722 
0723 static const char * const uart_b_groups[] = {
0724     "uart_b_tx_x", "uart_b_rx_x", "uart_b_tx_f", "uart_b_rx_f",
0725 };
0726 
0727 static const char * const uart_c_groups[] = {
0728     "uart_c_tx_x0", "uart_c_rx_x1", "uart_c_cts", "uart_c_rts",
0729     "uart_c_tx_x15", "uart_c_rx_x16",
0730 };
0731 
0732 static const char * const i2c0_groups[] = {
0733     "i2c0_sck_f11", "i2c0_sda_f12", "i2c0_sck_f9", "i2c0_sda_f10",
0734 };
0735 
0736 static const char * const i2c1_groups[] = {
0737     "i2c1_sda_x", "i2c1_sck_x", "i2c1_sda_a", "i2c1_sck_a",
0738 };
0739 
0740 static const char * const i2c2_groups[] = {
0741     "i2c2_sck_x0", "i2c2_sda_x1", "i2c2_sck_x15", "i2c2_sda_x16",
0742     "i2c2_sck_a4", "i2c2_sda_a5", "i2c2_sck_a8", "i2c2_sda_a9",
0743 };
0744 
0745 static const char * const i2c3_groups[] = {
0746     "i2c3_sck_x", "i2c3_sda_x", "i2c3_sck_f", "i2c3_sda_f",
0747 };
0748 
0749 static const char * const spi_a_groups[] = {
0750     "spi_a_mosi_x2", "spi_a_ss0_x3", "spi_a_sclk_x4", "spi_a_miso_x5",
0751     "spi_a_mosi_x7", "spi_a_miso_x8", "spi_a_ss0_x9", "spi_a_sclk_x10",
0752 
0753     "spi_a_mosi_a", "spi_a_miso_a", "spi_a_ss0_a", "spi_a_sclk_a",
0754 };
0755 
0756 static const char * const pdm_groups[] = {
0757     "pdm_din0_x", "pdm_din1_x", "pdm_din2_x", "pdm_dclk_x", "pdm_din2_a",
0758     "pdm_din1_a", "pdm_din0_a", "pdm_dclk",
0759 };
0760 
0761 static const char * const gen_clk_groups[] = {
0762     "gen_clk_x", "gen_clk_f8", "gen_clk_f10", "gen_clk_a",
0763 };
0764 
0765 static const char * const remote_input_groups[] = {
0766     "remote_input_f",
0767     "remote_input_a",
0768 };
0769 
0770 static const char * const jtag_a_groups[] = {
0771     "jtag_a_clk", "jtag_a_tms", "jtag_a_tdi", "jtag_a_tdo",
0772 };
0773 
0774 static const char * const clk_32k_in_groups[] = {
0775     "clk_32k_in",
0776 };
0777 
0778 static const char * const remote_out_groups[] = {
0779     "remote_out",
0780 };
0781 
0782 static const char * const spdif_in_groups[] = {
0783     "spdif_in_f6", "spdif_in_f7",
0784 };
0785 
0786 static const char * const sw_groups[] = {
0787     "swclk", "swdio",
0788 };
0789 
0790 static const char * const clk25_groups[] = {
0791     "clk_25",
0792 };
0793 
0794 static const char * const cec_a_groups[] = {
0795     "cec_a",
0796 };
0797 
0798 static const char * const cec_b_groups[] = {
0799     "cec_b",
0800 };
0801 
0802 static const char * const clk12_24_groups[] = {
0803     "clk12_24",
0804 };
0805 
0806 static const char * const mclk_0_groups[] = {
0807     "mclk_0",
0808 };
0809 
0810 static const char * const tdm_b_groups[] = {
0811     "tdm_b_din0", "tdm_b_din1", "tdm_b_din2",
0812     "tdm_b_sclk", "tdm_b_fs", "tdm_b_dout0", "tdm_b_dout1",
0813     "tdm_b_dout2", "tdm_b_dout3", "tdm_b_dout4", "tdm_b_dout5",
0814     "tdm_b_slv_sclk", "tdm_b_slv_fs",
0815 };
0816 
0817 static const char * const mclk_vad_groups[] = {
0818     "mclk_vad",
0819 };
0820 
0821 static const char * const tdm_vad_groups[] = {
0822     "tdm_vad_sclk_a1", "tdm_vad_fs_a2", "tdm_vad_sclk_a5", "tdm_vad_fs_a6",
0823 };
0824 
0825 static const char * const tst_out_groups[] = {
0826     "tst_out0", "tst_out1", "tst_out2", "tst_out3",
0827     "tst_out4", "tst_out5", "tst_out6", "tst_out7",
0828     "tst_out8", "tst_out9", "tst_out10", "tst_out11",
0829 };
0830 
0831 static const char * const mute_groups[] = {
0832     "mute_key", "mute_en",
0833 };
0834 
0835 static struct meson_pmx_func meson_a1_periphs_functions[] = {
0836     FUNCTION(gpio_periphs),
0837     FUNCTION(psram),
0838     FUNCTION(pwm_a),
0839     FUNCTION(pwm_b),
0840     FUNCTION(pwm_c),
0841     FUNCTION(pwm_d),
0842     FUNCTION(pwm_e),
0843     FUNCTION(pwm_f),
0844     FUNCTION(pwm_a_hiz),
0845     FUNCTION(pwm_b_hiz),
0846     FUNCTION(pwm_c_hiz),
0847     FUNCTION(spif),
0848     FUNCTION(sdcard),
0849     FUNCTION(tdm_a),
0850     FUNCTION(uart_a),
0851     FUNCTION(uart_b),
0852     FUNCTION(uart_c),
0853     FUNCTION(i2c0),
0854     FUNCTION(i2c1),
0855     FUNCTION(i2c2),
0856     FUNCTION(i2c3),
0857     FUNCTION(spi_a),
0858     FUNCTION(pdm),
0859     FUNCTION(gen_clk),
0860     FUNCTION(remote_input),
0861     FUNCTION(jtag_a),
0862     FUNCTION(clk_32k_in),
0863     FUNCTION(remote_out),
0864     FUNCTION(spdif_in),
0865     FUNCTION(sw),
0866     FUNCTION(clk25),
0867     FUNCTION(cec_a),
0868     FUNCTION(cec_b),
0869     FUNCTION(clk12_24),
0870     FUNCTION(mclk_0),
0871     FUNCTION(tdm_b),
0872     FUNCTION(mclk_vad),
0873     FUNCTION(tdm_vad),
0874     FUNCTION(tst_out),
0875     FUNCTION(mute),
0876 };
0877 
0878 static struct meson_bank meson_a1_periphs_banks[] = {
0879     /* name  first  last  irq  pullen  pull  dir  out  in  ds*/
0880     BANK_DS("P",  GPIOP_0,  GPIOP_12,  0,  12, 0x3,  0,  0x4,  0,
0881         0x2,  0,  0x1,  0,  0x0,  0,  0x5,  0),
0882     BANK_DS("B",  GPIOB_0,    GPIOB_6,   13,  19,  0x13,  0,  0x14,  0,
0883         0x12,  0,  0x11,  0,  0x10,  0,  0x15,  0),
0884     BANK_DS("X",  GPIOX_0,    GPIOX_16,  20,  36,  0x23,  0,  0x24,  0,
0885         0x22,  0,  0x21,  0,  0x20,  0,  0x25,  0),
0886     BANK_DS("F",  GPIOF_0,    GPIOF_12,  37,  49,  0x33,  0,  0x34,  0,
0887         0x32,  0,  0x31,  0,  0x30,  0,  0x35,  0),
0888     BANK_DS("A",  GPIOA_0,    GPIOA_11,  50,  61,  0x43,  0,  0x44,  0,
0889         0x42,  0,  0x41,  0,  0x40,  0,  0x45,  0),
0890 };
0891 
0892 static struct meson_pmx_bank meson_a1_periphs_pmx_banks[] = {
0893     /*  name     first      lask    reg offset  */
0894     BANK_PMX("P",    GPIOP_0, GPIOP_12, 0x0, 0),
0895     BANK_PMX("B",    GPIOB_0, GPIOB_6,  0x2, 0),
0896     BANK_PMX("X",    GPIOX_0, GPIOX_16, 0x3, 0),
0897     BANK_PMX("F",    GPIOF_0, GPIOF_12, 0x6, 0),
0898     BANK_PMX("A",    GPIOA_0, GPIOA_11, 0x8, 0),
0899 };
0900 
0901 static struct meson_axg_pmx_data meson_a1_periphs_pmx_banks_data = {
0902     .pmx_banks  = meson_a1_periphs_pmx_banks,
0903     .num_pmx_banks  = ARRAY_SIZE(meson_a1_periphs_pmx_banks),
0904 };
0905 
0906 static struct meson_pinctrl_data meson_a1_periphs_pinctrl_data = {
0907     .name       = "periphs-banks",
0908     .pins       = meson_a1_periphs_pins,
0909     .groups     = meson_a1_periphs_groups,
0910     .funcs      = meson_a1_periphs_functions,
0911     .banks      = meson_a1_periphs_banks,
0912     .num_pins   = ARRAY_SIZE(meson_a1_periphs_pins),
0913     .num_groups = ARRAY_SIZE(meson_a1_periphs_groups),
0914     .num_funcs  = ARRAY_SIZE(meson_a1_periphs_functions),
0915     .num_banks  = ARRAY_SIZE(meson_a1_periphs_banks),
0916     .pmx_ops    = &meson_axg_pmx_ops,
0917     .pmx_data   = &meson_a1_periphs_pmx_banks_data,
0918     .parse_dt   = &meson_a1_parse_dt_extra,
0919 };
0920 
0921 static const struct of_device_id meson_a1_pinctrl_dt_match[] = {
0922     {
0923         .compatible = "amlogic,meson-a1-periphs-pinctrl",
0924         .data = &meson_a1_periphs_pinctrl_data,
0925     },
0926     { },
0927 };
0928 MODULE_DEVICE_TABLE(of, meson_a1_pinctrl_dt_match);
0929 
0930 static struct platform_driver meson_a1_pinctrl_driver = {
0931     .probe  = meson_pinctrl_probe,
0932     .driver = {
0933         .name   = "meson-a1-pinctrl",
0934         .of_match_table = meson_a1_pinctrl_dt_match,
0935     },
0936 };
0937 
0938 module_platform_driver(meson_a1_pinctrl_driver);
0939 MODULE_LICENSE("Dual BSD/GPL");