blob: 37ea93715d1a42b5c8ce7d1d6c072bf3614f7390 [file] [log] [blame]
Samuel Hollande3095022021-08-12 20:09:43 -05001// SPDX-License-Identifier: GPL-2.0
2
3#include <clk.h>
4#include <dm.h>
5#include <dm/device-internal.h>
6#include <dm/lists.h>
7#include <dm/pinctrl.h>
8#include <errno.h>
9#include <malloc.h>
Andre Przywaraf944a612022-09-06 10:36:38 +010010#include <sunxi_gpio.h>
Samuel Hollande3095022021-08-12 20:09:43 -050011
12#include <asm/gpio.h>
13
14extern U_BOOT_DRIVER(gpio_sunxi);
15
Samuel Hollandecbbedb2021-08-16 23:56:47 -050016/*
17 * This structure implements a simplified view of the possible pinmux settings:
18 * Each mux value is assumed to be the same for a given function, across the
19 * pins in each group (almost universally true, with same rare exceptions not
20 * relevant to U-Boot), but also across different ports (not true in many
21 * cases). We ignore the first problem, and work around the latter by just
22 * supporting one particular port for a each function. This works fine for all
23 * board configurations so far. If this would need to be revisited, we could
24 * add a "u8 port;" below and match that, with 0 encoding the "don't care" case.
25 */
26struct sunxi_pinctrl_function {
27 const char name[sizeof("gpio_out")];
28 u8 mux;
29};
30
Samuel Hollande3095022021-08-12 20:09:43 -050031struct sunxi_pinctrl_desc {
Samuel Hollandecbbedb2021-08-16 23:56:47 -050032 const struct sunxi_pinctrl_function *functions;
33 u8 num_functions;
Samuel Hollande3095022021-08-12 20:09:43 -050034 u8 first_bank;
35 u8 num_banks;
36};
37
38struct sunxi_pinctrl_plat {
Andre Przywara841ebfb32022-09-05 18:12:39 +010039 void __iomem *base;
Samuel Hollande3095022021-08-12 20:09:43 -050040};
41
Samuel Hollandecbbedb2021-08-16 23:56:47 -050042static int sunxi_pinctrl_get_pins_count(struct udevice *dev)
43{
44 const struct sunxi_pinctrl_desc *desc = dev_get_priv(dev);
45
46 return desc->num_banks * SUNXI_GPIOS_PER_BANK;
47}
48
49static const char *sunxi_pinctrl_get_pin_name(struct udevice *dev,
50 uint pin_selector)
51{
52 const struct sunxi_pinctrl_desc *desc = dev_get_priv(dev);
Samuel Hollandd478ed82023-10-30 23:57:40 -050053 static char pin_name[sizeof("PN31")] __section(".data");
Samuel Hollandecbbedb2021-08-16 23:56:47 -050054
55 snprintf(pin_name, sizeof(pin_name), "P%c%d",
56 pin_selector / SUNXI_GPIOS_PER_BANK + desc->first_bank + 'A',
57 pin_selector % SUNXI_GPIOS_PER_BANK);
58
59 return pin_name;
60}
61
62static int sunxi_pinctrl_get_functions_count(struct udevice *dev)
63{
64 const struct sunxi_pinctrl_desc *desc = dev_get_priv(dev);
65
66 return desc->num_functions;
67}
68
69static const char *sunxi_pinctrl_get_function_name(struct udevice *dev,
70 uint func_selector)
71{
72 const struct sunxi_pinctrl_desc *desc = dev_get_priv(dev);
73
74 return desc->functions[func_selector].name;
75}
76
77static int sunxi_pinctrl_pinmux_set(struct udevice *dev, uint pin_selector,
78 uint func_selector)
79{
80 const struct sunxi_pinctrl_desc *desc = dev_get_priv(dev);
81 struct sunxi_pinctrl_plat *plat = dev_get_plat(dev);
82 int bank = pin_selector / SUNXI_GPIOS_PER_BANK;
83 int pin = pin_selector % SUNXI_GPIOS_PER_BANK;
84
85 debug("set mux: %-4s => %s (%d)\n",
86 sunxi_pinctrl_get_pin_name(dev, pin_selector),
87 sunxi_pinctrl_get_function_name(dev, func_selector),
88 desc->functions[func_selector].mux);
89
Andre Przywara841ebfb32022-09-05 18:12:39 +010090 sunxi_gpio_set_cfgbank(plat->base + bank * SUNXI_PINCTRL_BANK_SIZE,
91 pin, desc->functions[func_selector].mux);
Samuel Hollandecbbedb2021-08-16 23:56:47 -050092
93 return 0;
94}
95
Samuel Hollandde828b42021-08-28 21:10:47 -050096static const struct pinconf_param sunxi_pinctrl_pinconf_params[] = {
97 { "bias-disable", PIN_CONFIG_BIAS_DISABLE, 0 },
98 { "bias-pull-down", PIN_CONFIG_BIAS_PULL_DOWN, 2 },
99 { "bias-pull-up", PIN_CONFIG_BIAS_PULL_UP, 1 },
100 { "drive-strength", PIN_CONFIG_DRIVE_STRENGTH, 10 },
101};
102
103static int sunxi_pinctrl_pinconf_set_pull(struct sunxi_pinctrl_plat *plat,
104 uint bank, uint pin, uint bias)
105{
Andre Przywara841ebfb32022-09-05 18:12:39 +0100106 void *regs = plat->base + bank * SUNXI_PINCTRL_BANK_SIZE;
Samuel Hollandde828b42021-08-28 21:10:47 -0500107
108 sunxi_gpio_set_pull_bank(regs, pin, bias);
109
110 return 0;
111}
112
113static int sunxi_pinctrl_pinconf_set_drive(struct sunxi_pinctrl_plat *plat,
114 uint bank, uint pin, uint drive)
115{
Andre Przywara841ebfb32022-09-05 18:12:39 +0100116 void *regs = plat->base + bank * SUNXI_PINCTRL_BANK_SIZE;
Samuel Hollandde828b42021-08-28 21:10:47 -0500117
118 if (drive < 10 || drive > 40)
119 return -EINVAL;
120
121 /* Convert mA to the register value, rounding down. */
122 sunxi_gpio_set_drv_bank(regs, pin, drive / 10 - 1);
123
124 return 0;
125}
126
127static int sunxi_pinctrl_pinconf_set(struct udevice *dev, uint pin_selector,
128 uint param, uint val)
129{
130 struct sunxi_pinctrl_plat *plat = dev_get_plat(dev);
131 int bank = pin_selector / SUNXI_GPIOS_PER_BANK;
132 int pin = pin_selector % SUNXI_GPIOS_PER_BANK;
133
134 switch (param) {
135 case PIN_CONFIG_BIAS_DISABLE:
136 case PIN_CONFIG_BIAS_PULL_DOWN:
137 case PIN_CONFIG_BIAS_PULL_UP:
138 return sunxi_pinctrl_pinconf_set_pull(plat, bank, pin, val);
139 case PIN_CONFIG_DRIVE_STRENGTH:
140 return sunxi_pinctrl_pinconf_set_drive(plat, bank, pin, val);
141 }
142
143 return -EINVAL;
144}
145
Samuel Holland116d5232021-08-17 00:52:00 -0500146static int sunxi_pinctrl_get_pin_muxing(struct udevice *dev, uint pin_selector,
147 char *buf, int size)
148{
149 struct sunxi_pinctrl_plat *plat = dev_get_plat(dev);
150 int bank = pin_selector / SUNXI_GPIOS_PER_BANK;
151 int pin = pin_selector % SUNXI_GPIOS_PER_BANK;
Andre Przywara841ebfb32022-09-05 18:12:39 +0100152 int mux = sunxi_gpio_get_cfgbank(plat->base + bank * SUNXI_PINCTRL_BANK_SIZE, pin);
Samuel Holland116d5232021-08-17 00:52:00 -0500153
154 switch (mux) {
155 case SUNXI_GPIO_INPUT:
156 strlcpy(buf, "gpio input", size);
157 break;
158 case SUNXI_GPIO_OUTPUT:
159 strlcpy(buf, "gpio output", size);
160 break;
161 case SUNXI_GPIO_DISABLE:
162 strlcpy(buf, "disabled", size);
163 break;
164 default:
165 snprintf(buf, size, "function %d", mux);
166 break;
167 }
168
169 return 0;
170}
171
Samuel Hollande3095022021-08-12 20:09:43 -0500172static const struct pinctrl_ops sunxi_pinctrl_ops = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500173 .get_pins_count = sunxi_pinctrl_get_pins_count,
174 .get_pin_name = sunxi_pinctrl_get_pin_name,
175 .get_functions_count = sunxi_pinctrl_get_functions_count,
176 .get_function_name = sunxi_pinctrl_get_function_name,
177 .pinmux_set = sunxi_pinctrl_pinmux_set,
Samuel Hollandde828b42021-08-28 21:10:47 -0500178 .pinconf_num_params = ARRAY_SIZE(sunxi_pinctrl_pinconf_params),
179 .pinconf_params = sunxi_pinctrl_pinconf_params,
180 .pinconf_set = sunxi_pinctrl_pinconf_set,
Samuel Hollande3095022021-08-12 20:09:43 -0500181 .set_state = pinctrl_generic_set_state,
Samuel Holland116d5232021-08-17 00:52:00 -0500182 .get_pin_muxing = sunxi_pinctrl_get_pin_muxing,
Samuel Hollande3095022021-08-12 20:09:43 -0500183};
184
185static int sunxi_pinctrl_bind(struct udevice *dev)
186{
187 struct sunxi_pinctrl_plat *plat = dev_get_plat(dev);
188 struct sunxi_pinctrl_desc *desc;
189 struct sunxi_gpio_plat *gpio_plat;
190 struct udevice *gpio_dev;
191 int i, ret;
192
193 desc = (void *)dev_get_driver_data(dev);
194 if (!desc)
195 return -EINVAL;
196 dev_set_priv(dev, desc);
197
198 plat->base = dev_read_addr_ptr(dev);
199
200 ret = device_bind_driver_to_node(dev, "gpio_sunxi", dev->name,
201 dev_ofnode(dev), &gpio_dev);
202 if (ret)
203 return ret;
204
205 for (i = 0; i < desc->num_banks; ++i) {
206 gpio_plat = malloc(sizeof(*gpio_plat));
207 if (!gpio_plat)
208 return -ENOMEM;
209
Andre Przywara841ebfb32022-09-05 18:12:39 +0100210 gpio_plat->regs = plat->base + i * SUNXI_PINCTRL_BANK_SIZE;
Samuel Hollande3095022021-08-12 20:09:43 -0500211 gpio_plat->bank_name[0] = 'P';
212 gpio_plat->bank_name[1] = 'A' + desc->first_bank + i;
213 gpio_plat->bank_name[2] = '\0';
214
215 ret = device_bind(gpio_dev, DM_DRIVER_REF(gpio_sunxi),
216 gpio_plat->bank_name, gpio_plat,
217 ofnode_null(), NULL);
218 if (ret)
219 return ret;
220 }
221
222 return 0;
223}
224
225static int sunxi_pinctrl_probe(struct udevice *dev)
226{
227 struct clk *apb_clk;
228
229 apb_clk = devm_clk_get(dev, "apb");
230 if (!IS_ERR(apb_clk))
231 clk_enable(apb_clk);
232
233 return 0;
234}
235
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500236static const struct sunxi_pinctrl_function suniv_f1c100s_pinctrl_functions[] = {
237 { "gpio_in", 0 },
238 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500239 { "i2c0", 3 }, /* PE11-PE12 */
240 { "i2c1", 3 }, /* PD5-PD6 */
Samuel Holland1c17f412021-08-28 16:51:03 -0500241 { "mmc0", 2 }, /* PF0-PF5 */
242 { "mmc1", 3 }, /* PC0-PC2 */
Samuel Holland96b75d22021-08-28 17:05:35 -0500243 { "spi0", 2 }, /* PC0-PC3 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500244#if IS_ENABLED(CONFIG_UART0_PORT_F)
245 { "uart0", 3 }, /* PF2-PF4 */
246#else
247 { "uart0", 5 }, /* PE0-PE1 */
248#endif
Andre Przywara72313dc2022-10-05 23:19:54 +0100249 { "uart1", 5 }, /* PA0-PA3 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500250};
251
Samuel Hollande3095022021-08-12 20:09:43 -0500252static const struct sunxi_pinctrl_desc __maybe_unused suniv_f1c100s_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500253 .functions = suniv_f1c100s_pinctrl_functions,
254 .num_functions = ARRAY_SIZE(suniv_f1c100s_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500255 .first_bank = SUNXI_GPIO_A,
256 .num_banks = 6,
257};
258
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500259static const struct sunxi_pinctrl_function sun4i_a10_pinctrl_functions[] = {
Samuel Holland5d57e052021-08-28 13:21:36 -0500260 { "emac", 2 }, /* PA0-PA17 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500261 { "gpio_in", 0 },
262 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500263 { "i2c0", 2 }, /* PB0-PB1 */
264 { "i2c1", 2 }, /* PB18-PB19 */
Samuel Holland1c17f412021-08-28 16:51:03 -0500265 { "mmc0", 2 }, /* PF0-PF5 */
266#if IS_ENABLED(CONFIG_MMC1_PINS_PH)
267 { "mmc1", 5 }, /* PH22-PH27 */
268#else
269 { "mmc1", 4 }, /* PG0-PG5 */
270#endif
271 { "mmc2", 3 }, /* PC6-PC15 */
272 { "mmc3", 2 }, /* PI4-PI9 */
Samuel Hollandaba26152023-01-22 16:06:32 -0600273 { "nand0", 2 }, /* PC0-PC24 */
Samuel Holland96b75d22021-08-28 17:05:35 -0500274 { "spi0", 3 }, /* PC0-PC2, PC23 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500275#if IS_ENABLED(CONFIG_UART0_PORT_F)
276 { "uart0", 4 }, /* PF2-PF4 */
277#else
278 { "uart0", 2 }, /* PB22-PB23 */
279#endif
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500280};
281
Samuel Hollande3095022021-08-12 20:09:43 -0500282static const struct sunxi_pinctrl_desc __maybe_unused sun4i_a10_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500283 .functions = sun4i_a10_pinctrl_functions,
284 .num_functions = ARRAY_SIZE(sun4i_a10_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500285 .first_bank = SUNXI_GPIO_A,
286 .num_banks = 9,
287};
288
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500289static const struct sunxi_pinctrl_function sun5i_a13_pinctrl_functions[] = {
Samuel Holland5d57e052021-08-28 13:21:36 -0500290 { "emac", 2 }, /* PA0-PA17 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500291 { "gpio_in", 0 },
292 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500293 { "i2c0", 2 }, /* PB0-PB1 */
294 { "i2c1", 2 }, /* PB15-PB16 */
Samuel Holland1c17f412021-08-28 16:51:03 -0500295 { "mmc0", 2 }, /* PF0-PF5 */
296 { "mmc1", 2 }, /* PG3-PG8 */
297 { "mmc2", 3 }, /* PC6-PC15 */
Samuel Hollandaba26152023-01-22 16:06:32 -0600298 { "nand0", 2 }, /* PC0-PC19 */
Samuel Holland96b75d22021-08-28 17:05:35 -0500299 { "spi0", 3 }, /* PC0-PC3 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500300#if IS_ENABLED(CONFIG_UART0_PORT_F)
301 { "uart0", 4 }, /* PF2-PF4 */
302#else
303 { "uart0", 2 }, /* PB19-PB20 */
304#endif
305 { "uart1", 4 }, /* PG3-PG4 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500306};
307
Samuel Hollande3095022021-08-12 20:09:43 -0500308static const struct sunxi_pinctrl_desc __maybe_unused sun5i_a13_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500309 .functions = sun5i_a13_pinctrl_functions,
310 .num_functions = ARRAY_SIZE(sun5i_a13_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500311 .first_bank = SUNXI_GPIO_A,
312 .num_banks = 7,
313};
314
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500315static const struct sunxi_pinctrl_function sun6i_a31_pinctrl_functions[] = {
Samuel Holland8181f562021-08-28 13:13:52 -0500316 { "gmac", 2 }, /* PA0-PA27 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500317 { "gpio_in", 0 },
318 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500319 { "i2c0", 2 }, /* PH14-PH15 */
320 { "i2c1", 2 }, /* PH16-PH17 */
Samuel Holland1c17f412021-08-28 16:51:03 -0500321 { "mmc0", 2 }, /* PF0-PF5 */
322 { "mmc1", 2 }, /* PG0-PG5 */
323 { "mmc2", 3 }, /* PC6-PC15, PC24 */
324 { "mmc3", 4 }, /* PC6-PC15, PC24 */
Samuel Hollandaba26152023-01-22 16:06:32 -0600325 { "nand0", 2 }, /* PC0-PC26 */
Samuel Holland96b75d22021-08-28 17:05:35 -0500326 { "spi0", 3 }, /* PC0-PC2, PC27 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500327#if IS_ENABLED(CONFIG_UART0_PORT_F)
328 { "uart0", 3 }, /* PF2-PF4 */
329#else
330 { "uart0", 2 }, /* PH20-PH21 */
331#endif
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500332};
333
Samuel Hollande3095022021-08-12 20:09:43 -0500334static const struct sunxi_pinctrl_desc __maybe_unused sun6i_a31_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500335 .functions = sun6i_a31_pinctrl_functions,
336 .num_functions = ARRAY_SIZE(sun6i_a31_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500337 .first_bank = SUNXI_GPIO_A,
338 .num_banks = 8,
339};
340
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500341static const struct sunxi_pinctrl_function sun6i_a31_r_pinctrl_functions[] = {
342 { "gpio_in", 0 },
343 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500344 { "s_i2c", 2 }, /* PL0-PL1 */
Samuel Hollandd98ccb82022-11-17 22:22:27 -0600345 { "s_p2wi", 3 }, /* PL0-PL1 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500346 { "s_uart", 2 }, /* PL2-PL3 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500347};
348
Samuel Hollande3095022021-08-12 20:09:43 -0500349static const struct sunxi_pinctrl_desc __maybe_unused sun6i_a31_r_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500350 .functions = sun6i_a31_r_pinctrl_functions,
351 .num_functions = ARRAY_SIZE(sun6i_a31_r_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500352 .first_bank = SUNXI_GPIO_L,
353 .num_banks = 2,
354};
355
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500356static const struct sunxi_pinctrl_function sun7i_a20_pinctrl_functions[] = {
Samuel Holland5d57e052021-08-28 13:21:36 -0500357 { "emac", 2 }, /* PA0-PA17 */
Samuel Holland8181f562021-08-28 13:13:52 -0500358 { "gmac", 5 }, /* PA0-PA17 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500359 { "gpio_in", 0 },
360 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500361 { "i2c0", 2 }, /* PB0-PB1 */
362 { "i2c1", 2 }, /* PB18-PB19 */
Samuel Holland1c17f412021-08-28 16:51:03 -0500363 { "mmc0", 2 }, /* PF0-PF5 */
364#if IS_ENABLED(CONFIG_MMC1_PINS_PH)
365 { "mmc1", 5 }, /* PH22-PH27 */
366#else
367 { "mmc1", 4 }, /* PG0-PG5 */
368#endif
369 { "mmc2", 3 }, /* PC5-PC15, PC24 */
Samuel Hollandaba26152023-01-22 16:06:32 -0600370 { "nand0", 2 }, /* PC0-PC24 */
Samuel Holland96b75d22021-08-28 17:05:35 -0500371 { "spi0", 3 }, /* PC0-PC2, PC23 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500372#if IS_ENABLED(CONFIG_UART0_PORT_F)
373 { "uart0", 4 }, /* PF2-PF4 */
374#else
375 { "uart0", 2 }, /* PB22-PB23 */
376#endif
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500377};
378
Samuel Hollande3095022021-08-12 20:09:43 -0500379static const struct sunxi_pinctrl_desc __maybe_unused sun7i_a20_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500380 .functions = sun7i_a20_pinctrl_functions,
381 .num_functions = ARRAY_SIZE(sun7i_a20_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500382 .first_bank = SUNXI_GPIO_A,
383 .num_banks = 9,
384};
385
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500386static const struct sunxi_pinctrl_function sun8i_a23_pinctrl_functions[] = {
387 { "gpio_in", 0 },
388 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500389 { "i2c0", 2 }, /* PH2-PH3 */
390 { "i2c1", 2 }, /* PH4-PH5 */
Samuel Holland1c17f412021-08-28 16:51:03 -0500391 { "mmc0", 2 }, /* PF0-PF5 */
392 { "mmc1", 2 }, /* PG0-PG5 */
393 { "mmc2", 3 }, /* PC5-PC16 */
Samuel Hollandaba26152023-01-22 16:06:32 -0600394 { "nand0", 2 }, /* PC0-PC16 */
Samuel Holland96b75d22021-08-28 17:05:35 -0500395 { "spi0", 3 }, /* PC0-PC3 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500396#if IS_ENABLED(CONFIG_UART0_PORT_F)
397 { "uart0", 3 }, /* PF2-PF4 */
398#endif
399 { "uart1", 2 }, /* PG6-PG7 */
400 { "uart2", 2 }, /* PB0-PB1 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500401};
402
Samuel Hollande3095022021-08-12 20:09:43 -0500403static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a23_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500404 .functions = sun8i_a23_pinctrl_functions,
405 .num_functions = ARRAY_SIZE(sun8i_a23_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500406 .first_bank = SUNXI_GPIO_A,
407 .num_banks = 8,
408};
409
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500410static const struct sunxi_pinctrl_function sun8i_a23_r_pinctrl_functions[] = {
411 { "gpio_in", 0 },
412 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500413 { "s_i2c", 3 }, /* PL0-PL1 */
Samuel Hollandd98ccb82022-11-17 22:22:27 -0600414 { "s_rsb", 2 }, /* PL0-PL1 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500415 { "s_uart", 2 }, /* PL2-PL3 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500416};
417
Samuel Hollande3095022021-08-12 20:09:43 -0500418static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a23_r_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500419 .functions = sun8i_a23_r_pinctrl_functions,
420 .num_functions = ARRAY_SIZE(sun8i_a23_r_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500421 .first_bank = SUNXI_GPIO_L,
422 .num_banks = 1,
423};
424
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500425static const struct sunxi_pinctrl_function sun8i_a33_pinctrl_functions[] = {
426 { "gpio_in", 0 },
427 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500428 { "i2c0", 2 }, /* PH2-PH3 */
429 { "i2c1", 2 }, /* PH4-PH5 */
Samuel Holland1c17f412021-08-28 16:51:03 -0500430 { "mmc0", 2 }, /* PF0-PF5 */
431 { "mmc1", 2 }, /* PG0-PG5 */
432 { "mmc2", 3 }, /* PC5-PC16 */
Samuel Hollandaba26152023-01-22 16:06:32 -0600433 { "nand0", 2 }, /* PC0-PC16 */
Samuel Holland96b75d22021-08-28 17:05:35 -0500434 { "spi0", 3 }, /* PC0-PC3 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500435#if IS_ENABLED(CONFIG_UART0_PORT_F)
436 { "uart0", 3 }, /* PF2-PF4 */
437#else
438 { "uart0", 3 }, /* PB0-PB1 */
439#endif
440 { "uart1", 2 }, /* PG6-PG7 */
441 { "uart2", 2 }, /* PB0-PB1 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500442};
443
Samuel Hollande3095022021-08-12 20:09:43 -0500444static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a33_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500445 .functions = sun8i_a33_pinctrl_functions,
446 .num_functions = ARRAY_SIZE(sun8i_a33_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500447 .first_bank = SUNXI_GPIO_A,
448 .num_banks = 8,
449};
450
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500451static const struct sunxi_pinctrl_function sun8i_a83t_pinctrl_functions[] = {
Samuel Hollanda8cbf472021-08-28 13:34:29 -0500452 { "gmac", 4 }, /* PD2-PD23 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500453 { "gpio_in", 0 },
454 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500455 { "i2c0", 2 }, /* PH0-PH1 */
456 { "i2c1", 2 }, /* PH2-PH3 */
Samuel Holland1c17f412021-08-28 16:51:03 -0500457 { "mmc0", 2 }, /* PF0-PF5 */
458 { "mmc1", 2 }, /* PG0-PG5 */
459 { "mmc2", 3 }, /* PC5-PC16 */
Samuel Hollandaba26152023-01-22 16:06:32 -0600460 { "nand0", 2 }, /* PC0-PC18 */
Samuel Holland96b75d22021-08-28 17:05:35 -0500461 { "spi0", 3 }, /* PC0-PC3 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500462#if IS_ENABLED(CONFIG_UART0_PORT_F)
463 { "uart0", 3 }, /* PF2-PF4 */
464#else
465 { "uart0", 2 }, /* PB9-PB10 */
466#endif
467 { "uart1", 2 }, /* PG6-PG7 */
468 { "uart2", 2 }, /* PB0-PB1 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500469};
470
Samuel Hollande3095022021-08-12 20:09:43 -0500471static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a83t_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500472 .functions = sun8i_a83t_pinctrl_functions,
473 .num_functions = ARRAY_SIZE(sun8i_a83t_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500474 .first_bank = SUNXI_GPIO_A,
475 .num_banks = 8,
476};
477
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500478static const struct sunxi_pinctrl_function sun8i_a83t_r_pinctrl_functions[] = {
479 { "gpio_in", 0 },
480 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500481 { "s_i2c", 2 }, /* PL8-PL9 */
Samuel Hollandd98ccb82022-11-17 22:22:27 -0600482 { "s_rsb", 2 }, /* PL0-PL1 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500483 { "s_uart", 2 }, /* PL2-PL3 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500484};
485
Samuel Hollande3095022021-08-12 20:09:43 -0500486static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a83t_r_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500487 .functions = sun8i_a83t_r_pinctrl_functions,
488 .num_functions = ARRAY_SIZE(sun8i_a83t_r_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500489 .first_bank = SUNXI_GPIO_L,
490 .num_banks = 1,
491};
492
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500493static const struct sunxi_pinctrl_function sun8i_h3_pinctrl_functions[] = {
Samuel Hollanda8cbf472021-08-28 13:34:29 -0500494 { "emac", 2 }, /* PD0-PD17 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500495 { "gpio_in", 0 },
496 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500497 { "i2c0", 2 }, /* PA11-PA12 */
498 { "i2c1", 3 }, /* PA18-PA19 */
Samuel Holland1c17f412021-08-28 16:51:03 -0500499 { "mmc0", 2 }, /* PF0-PF5 */
500 { "mmc1", 2 }, /* PG0-PG5 */
501 { "mmc2", 3 }, /* PC5-PC16 */
Samuel Hollandaba26152023-01-22 16:06:32 -0600502 { "nand0", 2 }, /* PC0-PC16 */
Samuel Holland96b75d22021-08-28 17:05:35 -0500503 { "spi0", 3 }, /* PC0-PC3 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500504#if IS_ENABLED(CONFIG_UART0_PORT_F)
505 { "uart0", 3 }, /* PF2-PF4 */
506#else
507 { "uart0", 2 }, /* PA4-PA5 */
508#endif
509 { "uart1", 2 }, /* PG6-PG7 */
510 { "uart2", 2 }, /* PA0-PA1 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500511};
512
Samuel Hollande3095022021-08-12 20:09:43 -0500513static const struct sunxi_pinctrl_desc __maybe_unused sun8i_h3_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500514 .functions = sun8i_h3_pinctrl_functions,
515 .num_functions = ARRAY_SIZE(sun8i_h3_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500516 .first_bank = SUNXI_GPIO_A,
517 .num_banks = 7,
518};
519
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500520static const struct sunxi_pinctrl_function sun8i_h3_r_pinctrl_functions[] = {
521 { "gpio_in", 0 },
522 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500523 { "s_i2c", 2 }, /* PL0-PL1 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500524 { "s_uart", 2 }, /* PL2-PL3 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500525};
526
Samuel Hollande3095022021-08-12 20:09:43 -0500527static const struct sunxi_pinctrl_desc __maybe_unused sun8i_h3_r_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500528 .functions = sun8i_h3_r_pinctrl_functions,
529 .num_functions = ARRAY_SIZE(sun8i_h3_r_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500530 .first_bank = SUNXI_GPIO_L,
531 .num_banks = 1,
532};
533
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500534static const struct sunxi_pinctrl_function sun8i_v3s_pinctrl_functions[] = {
Samuel Hollanda8cbf472021-08-28 13:34:29 -0500535 { "emac", 4 }, /* PD0-PD17 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500536 { "gpio_in", 0 },
537 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500538 { "i2c0", 2 }, /* PB6-PB7 */
539 { "i2c1", 2 }, /* PB8-PB9 */
Samuel Holland1c17f412021-08-28 16:51:03 -0500540 { "mmc0", 2 }, /* PF0-PF5 */
541 { "mmc1", 2 }, /* PG0-PG5 */
542 { "mmc2", 2 }, /* PC0-PC10 */
Samuel Holland96b75d22021-08-28 17:05:35 -0500543 { "spi0", 3 }, /* PC0-PC3 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500544#if IS_ENABLED(CONFIG_UART0_PORT_F)
545 { "uart0", 3 }, /* PF2-PF4 */
546#else
547 { "uart0", 3 }, /* PB8-PB9 */
548#endif
549 { "uart1", 2 }, /* PG6-PG7 */
550 { "uart2", 2 }, /* PB0-PB1 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500551};
552
Samuel Hollande3095022021-08-12 20:09:43 -0500553static const struct sunxi_pinctrl_desc __maybe_unused sun8i_v3s_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500554 .functions = sun8i_v3s_pinctrl_functions,
555 .num_functions = ARRAY_SIZE(sun8i_v3s_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500556 .first_bank = SUNXI_GPIO_A,
557 .num_banks = 7,
558};
559
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500560static const struct sunxi_pinctrl_function sun9i_a80_pinctrl_functions[] = {
Samuel Holland8181f562021-08-28 13:13:52 -0500561 { "gmac", 2 }, /* PA0-PA17 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500562 { "gpio_in", 0 },
563 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500564 { "i2c0", 2 }, /* PH0-PH1 */
565 { "i2c1", 2 }, /* PH2-PH3 */
Samuel Holland1c17f412021-08-28 16:51:03 -0500566 { "mmc0", 2 }, /* PF0-PF5 */
567 { "mmc1", 2 }, /* PG0-PG5 */
568 { "mmc2", 3 }, /* PC6-PC16 */
Samuel Hollandaba26152023-01-22 16:06:32 -0600569 { "nand0", 2 }, /* PC0-PC18 */
Samuel Holland96b75d22021-08-28 17:05:35 -0500570 { "spi0", 3 }, /* PC0-PC2, PC19 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500571#if IS_ENABLED(CONFIG_UART0_PORT_F)
572 { "uart0", 4 }, /* PF2-PF4 */
573#else
574 { "uart0", 2 }, /* PH12-PH13 */
575#endif
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500576};
577
Samuel Hollande3095022021-08-12 20:09:43 -0500578static const struct sunxi_pinctrl_desc __maybe_unused sun9i_a80_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500579 .functions = sun9i_a80_pinctrl_functions,
580 .num_functions = ARRAY_SIZE(sun9i_a80_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500581 .first_bank = SUNXI_GPIO_A,
582 .num_banks = 8,
583};
584
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500585static const struct sunxi_pinctrl_function sun9i_a80_r_pinctrl_functions[] = {
586 { "gpio_in", 0 },
587 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500588 { "s_i2c0", 2 }, /* PN0-PN1 */
589 { "s_i2c1", 3 }, /* PM8-PM9 */
Samuel Hollandd98ccb82022-11-17 22:22:27 -0600590 { "s_rsb", 3 }, /* PN0-PN1 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500591 { "s_uart", 3 }, /* PL0-PL1 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500592};
593
Samuel Hollande3095022021-08-12 20:09:43 -0500594static const struct sunxi_pinctrl_desc __maybe_unused sun9i_a80_r_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500595 .functions = sun9i_a80_r_pinctrl_functions,
596 .num_functions = ARRAY_SIZE(sun9i_a80_r_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500597 .first_bank = SUNXI_GPIO_L,
598 .num_banks = 3,
599};
600
Andre Przywara25841f32022-09-05 16:25:57 +0100601static const struct sunxi_pinctrl_function sun20i_d1_pinctrl_functions[] = {
602 { "emac", 8 }, /* PE0-PE15 */
603 { "gpio_in", 0 },
604 { "gpio_out", 1 },
605 { "i2c0", 4 }, /* PB10-PB11 */
606 { "mmc0", 2 }, /* PF0-PF5 */
607 { "mmc1", 2 }, /* PG0-PG5 */
608 { "mmc2", 3 }, /* PC2-PC7 */
609 { "spi0", 2 }, /* PC2-PC7 */
610#if IS_ENABLED(CONFIG_UART0_PORT_F)
611 { "uart0", 3 }, /* PF2,PF4 */
612#else
613 { "uart0", 6 }, /* PB0-PB1, PB8-PB9, PE2-PE3 */
614#endif
615 { "uart1", 2 }, /* PG6-PG7 */
616 { "uart2", 7 }, /* PB0-PB1 */
617 { "uart3", 7 }, /* PB6-PB7 */
618};
619
620static const struct sunxi_pinctrl_desc __maybe_unused sun20i_d1_pinctrl_desc = {
621 .functions = sun20i_d1_pinctrl_functions,
622 .num_functions = ARRAY_SIZE(sun20i_d1_pinctrl_functions),
623 .first_bank = SUNXI_GPIO_A,
624 .num_banks = 7,
625};
626
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500627static const struct sunxi_pinctrl_function sun50i_a64_pinctrl_functions[] = {
Samuel Hollanda8cbf472021-08-28 13:34:29 -0500628 { "emac", 4 }, /* PD8-PD23 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500629 { "gpio_in", 0 },
630 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500631 { "i2c0", 2 }, /* PH0-PH1 */
632 { "i2c1", 2 }, /* PH2-PH3 */
Samuel Holland1c17f412021-08-28 16:51:03 -0500633 { "mmc0", 2 }, /* PF0-PF5 */
634 { "mmc1", 2 }, /* PG0-PG5 */
635 { "mmc2", 3 }, /* PC1-PC16 */
Samuel Hollandaba26152023-01-22 16:06:32 -0600636 { "nand0", 2 }, /* PC0-PC16 */
Samuel Holland3de641b2021-08-28 15:52:52 -0500637 { "pwm", 2 }, /* PD22 */
Samuel Holland96b75d22021-08-28 17:05:35 -0500638 { "spi0", 4 }, /* PC0-PC3 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500639#if IS_ENABLED(CONFIG_UART0_PORT_F)
640 { "uart0", 3 }, /* PF2-PF4 */
641#else
642 { "uart0", 4 }, /* PB8-PB9 */
643#endif
644 { "uart1", 2 }, /* PG6-PG7 */
645 { "uart2", 2 }, /* PB0-PB1 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500646};
647
Samuel Hollande3095022021-08-12 20:09:43 -0500648static const struct sunxi_pinctrl_desc __maybe_unused sun50i_a64_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500649 .functions = sun50i_a64_pinctrl_functions,
650 .num_functions = ARRAY_SIZE(sun50i_a64_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500651 .first_bank = SUNXI_GPIO_A,
652 .num_banks = 8,
653};
654
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500655static const struct sunxi_pinctrl_function sun50i_a64_r_pinctrl_functions[] = {
656 { "gpio_in", 0 },
657 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500658 { "s_i2c", 2 }, /* PL8-PL9 */
Samuel Hollandd98ccb82022-11-17 22:22:27 -0600659 { "s_rsb", 2 }, /* PL0-PL1 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500660 { "s_uart", 2 }, /* PL2-PL3 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500661};
662
Samuel Hollande3095022021-08-12 20:09:43 -0500663static const struct sunxi_pinctrl_desc __maybe_unused sun50i_a64_r_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500664 .functions = sun50i_a64_r_pinctrl_functions,
665 .num_functions = ARRAY_SIZE(sun50i_a64_r_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500666 .first_bank = SUNXI_GPIO_L,
667 .num_banks = 1,
668};
669
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500670static const struct sunxi_pinctrl_function sun50i_h5_pinctrl_functions[] = {
Samuel Hollanda8cbf472021-08-28 13:34:29 -0500671 { "emac", 2 }, /* PD0-PD17 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500672 { "gpio_in", 0 },
673 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500674 { "i2c0", 2 }, /* PA11-PA12 */
675 { "i2c1", 3 }, /* PA18-PA19 */
Samuel Holland1c17f412021-08-28 16:51:03 -0500676 { "mmc0", 2 }, /* PF0-PF5 */
677 { "mmc1", 2 }, /* PG0-PG5 */
678 { "mmc2", 3 }, /* PC1-PC16 */
Samuel Hollandaba26152023-01-22 16:06:32 -0600679 { "nand0", 2 }, /* PC0-PC16 */
Samuel Holland96b75d22021-08-28 17:05:35 -0500680 { "spi0", 3 }, /* PC0-PC3 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500681#if IS_ENABLED(CONFIG_UART0_PORT_F)
682 { "uart0", 3 }, /* PF2-PF4 */
683#else
684 { "uart0", 2 }, /* PA4-PA5 */
685#endif
686 { "uart1", 2 }, /* PG6-PG7 */
687 { "uart2", 2 }, /* PA0-PA1 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500688};
689
Samuel Hollande3095022021-08-12 20:09:43 -0500690static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h5_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500691 .functions = sun50i_h5_pinctrl_functions,
692 .num_functions = ARRAY_SIZE(sun50i_h5_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500693 .first_bank = SUNXI_GPIO_A,
694 .num_banks = 7,
695};
696
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500697static const struct sunxi_pinctrl_function sun50i_h6_pinctrl_functions[] = {
Samuel Hollanda8cbf472021-08-28 13:34:29 -0500698 { "emac", 5 }, /* PD0-PD20 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500699 { "gpio_in", 0 },
700 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500701 { "i2c0", 2 }, /* PD25-PD26 */
702 { "i2c1", 4 }, /* PH5-PH6 */
Samuel Holland1c17f412021-08-28 16:51:03 -0500703 { "mmc0", 2 }, /* PF0-PF5 */
704 { "mmc1", 2 }, /* PG0-PG5 */
705 { "mmc2", 3 }, /* PC1-PC14 */
Samuel Hollandaba26152023-01-22 16:06:32 -0600706 { "nand0", 2 }, /* PC0-PC16 */
Samuel Holland96b75d22021-08-28 17:05:35 -0500707 { "spi0", 4 }, /* PC0-PC7 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500708#if IS_ENABLED(CONFIG_UART0_PORT_F)
709 { "uart0", 3 }, /* PF2-PF4 */
710#else
711 { "uart0", 2 }, /* PH0-PH1 */
712#endif
713 { "uart1", 2 }, /* PG6-PG7 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500714};
715
Samuel Hollande3095022021-08-12 20:09:43 -0500716static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h6_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500717 .functions = sun50i_h6_pinctrl_functions,
718 .num_functions = ARRAY_SIZE(sun50i_h6_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500719 .first_bank = SUNXI_GPIO_A,
720 .num_banks = 8,
721};
722
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500723static const struct sunxi_pinctrl_function sun50i_h6_r_pinctrl_functions[] = {
724 { "gpio_in", 0 },
725 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500726 { "s_i2c", 3 }, /* PL0-PL1 */
Samuel Hollandd98ccb82022-11-17 22:22:27 -0600727 { "s_rsb", 2 }, /* PL0-PL1 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500728 { "s_uart", 2 }, /* PL2-PL3 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500729};
730
Samuel Hollande3095022021-08-12 20:09:43 -0500731static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h6_r_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500732 .functions = sun50i_h6_r_pinctrl_functions,
733 .num_functions = ARRAY_SIZE(sun50i_h6_r_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500734 .first_bank = SUNXI_GPIO_L,
735 .num_banks = 2,
736};
737
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500738static const struct sunxi_pinctrl_function sun50i_h616_pinctrl_functions[] = {
Samuel Hollanda8cbf472021-08-28 13:34:29 -0500739 { "emac0", 2 }, /* PI0-PI16 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500740 { "gpio_in", 0 },
741 { "gpio_out", 1 },
Samuel Holland1c17f412021-08-28 16:51:03 -0500742 { "mmc0", 2 }, /* PF0-PF5 */
743 { "mmc1", 2 }, /* PG0-PG5 */
744 { "mmc2", 3 }, /* PC0-PC16 */
Samuel Hollandaba26152023-01-22 16:06:32 -0600745 { "nand0", 2 }, /* PC0-PC16 */
Samuel Holland96b75d22021-08-28 17:05:35 -0500746 { "spi0", 4 }, /* PC0-PC7, PC15-PC16 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500747#if IS_ENABLED(CONFIG_UART0_PORT_F)
748 { "uart0", 3 }, /* PF2-PF4 */
749#else
750 { "uart0", 2 }, /* PH0-PH1 */
751#endif
752 { "uart1", 2 }, /* PG6-PG7 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500753};
754
Samuel Hollande3095022021-08-12 20:09:43 -0500755static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h616_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500756 .functions = sun50i_h616_pinctrl_functions,
757 .num_functions = ARRAY_SIZE(sun50i_h616_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500758 .first_bank = SUNXI_GPIO_A,
759 .num_banks = 9,
760};
761
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500762static const struct sunxi_pinctrl_function sun50i_h616_r_pinctrl_functions[] = {
763 { "gpio_in", 0 },
764 { "gpio_out", 1 },
Samuel Holland4b10d252021-08-28 15:17:32 -0500765 { "s_i2c", 3 }, /* PL0-PL1 */
Samuel Hollandd98ccb82022-11-17 22:22:27 -0600766 { "s_rsb", 2 }, /* PL0-PL1 */
Samuel Holland5a08d412021-08-28 13:00:45 -0500767 { "s_uart", 2 }, /* PL2-PL3 */
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500768};
769
Samuel Hollande3095022021-08-12 20:09:43 -0500770static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h616_r_pinctrl_desc = {
Samuel Hollandecbbedb2021-08-16 23:56:47 -0500771 .functions = sun50i_h616_r_pinctrl_functions,
772 .num_functions = ARRAY_SIZE(sun50i_h616_r_pinctrl_functions),
Samuel Hollande3095022021-08-12 20:09:43 -0500773 .first_bank = SUNXI_GPIO_L,
774 .num_banks = 1,
775};
776
777static const struct udevice_id sunxi_pinctrl_ids[] = {
778#ifdef CONFIG_PINCTRL_SUNIV_F1C100S
779 {
780 .compatible = "allwinner,suniv-f1c100s-pinctrl",
781 .data = (ulong)&suniv_f1c100s_pinctrl_desc,
782 },
783#endif
784#ifdef CONFIG_PINCTRL_SUN4I_A10
785 {
786 .compatible = "allwinner,sun4i-a10-pinctrl",
787 .data = (ulong)&sun4i_a10_pinctrl_desc,
788 },
789#endif
790#ifdef CONFIG_PINCTRL_SUN5I_A13
791 {
792 .compatible = "allwinner,sun5i-a10s-pinctrl",
793 .data = (ulong)&sun5i_a13_pinctrl_desc,
794 },
795 {
796 .compatible = "allwinner,sun5i-a13-pinctrl",
797 .data = (ulong)&sun5i_a13_pinctrl_desc,
798 },
799#endif
800#ifdef CONFIG_PINCTRL_SUN6I_A31
801 {
802 .compatible = "allwinner,sun6i-a31-pinctrl",
803 .data = (ulong)&sun6i_a31_pinctrl_desc,
804 },
805 {
806 .compatible = "allwinner,sun6i-a31s-pinctrl",
807 .data = (ulong)&sun6i_a31_pinctrl_desc,
808 },
809#endif
810#ifdef CONFIG_PINCTRL_SUN6I_A31_R
811 {
812 .compatible = "allwinner,sun6i-a31-r-pinctrl",
813 .data = (ulong)&sun6i_a31_r_pinctrl_desc,
814 },
815#endif
816#ifdef CONFIG_PINCTRL_SUN7I_A20
817 {
818 .compatible = "allwinner,sun7i-a20-pinctrl",
819 .data = (ulong)&sun7i_a20_pinctrl_desc,
820 },
821#endif
822#ifdef CONFIG_PINCTRL_SUN8I_A23
823 {
824 .compatible = "allwinner,sun8i-a23-pinctrl",
825 .data = (ulong)&sun8i_a23_pinctrl_desc,
826 },
827#endif
828#ifdef CONFIG_PINCTRL_SUN8I_A23_R
829 {
830 .compatible = "allwinner,sun8i-a23-r-pinctrl",
831 .data = (ulong)&sun8i_a23_r_pinctrl_desc,
832 },
833#endif
834#ifdef CONFIG_PINCTRL_SUN8I_A33
835 {
836 .compatible = "allwinner,sun8i-a33-pinctrl",
837 .data = (ulong)&sun8i_a33_pinctrl_desc,
838 },
839#endif
840#ifdef CONFIG_PINCTRL_SUN8I_A83T
841 {
842 .compatible = "allwinner,sun8i-a83t-pinctrl",
843 .data = (ulong)&sun8i_a83t_pinctrl_desc,
844 },
845#endif
846#ifdef CONFIG_PINCTRL_SUN8I_A83T_R
847 {
848 .compatible = "allwinner,sun8i-a83t-r-pinctrl",
849 .data = (ulong)&sun8i_a83t_r_pinctrl_desc,
850 },
851#endif
852#ifdef CONFIG_PINCTRL_SUN8I_H3
853 {
854 .compatible = "allwinner,sun8i-h3-pinctrl",
855 .data = (ulong)&sun8i_h3_pinctrl_desc,
856 },
857#endif
858#ifdef CONFIG_PINCTRL_SUN8I_H3_R
859 {
860 .compatible = "allwinner,sun8i-h3-r-pinctrl",
861 .data = (ulong)&sun8i_h3_r_pinctrl_desc,
862 },
863#endif
864#ifdef CONFIG_PINCTRL_SUN7I_A20
865 {
866 .compatible = "allwinner,sun8i-r40-pinctrl",
867 .data = (ulong)&sun7i_a20_pinctrl_desc,
868 },
869#endif
870#ifdef CONFIG_PINCTRL_SUN8I_V3S
871 {
872 .compatible = "allwinner,sun8i-v3-pinctrl",
873 .data = (ulong)&sun8i_v3s_pinctrl_desc,
874 },
875 {
876 .compatible = "allwinner,sun8i-v3s-pinctrl",
877 .data = (ulong)&sun8i_v3s_pinctrl_desc,
878 },
879#endif
880#ifdef CONFIG_PINCTRL_SUN9I_A80
881 {
882 .compatible = "allwinner,sun9i-a80-pinctrl",
883 .data = (ulong)&sun9i_a80_pinctrl_desc,
884 },
885#endif
886#ifdef CONFIG_PINCTRL_SUN9I_A80_R
887 {
888 .compatible = "allwinner,sun9i-a80-r-pinctrl",
889 .data = (ulong)&sun9i_a80_r_pinctrl_desc,
890 },
891#endif
Andre Przywara25841f32022-09-05 16:25:57 +0100892#ifdef CONFIG_PINCTRL_SUN20I_D1
893 {
894 .compatible = "allwinner,sun20i-d1-pinctrl",
895 .data = (ulong)&sun20i_d1_pinctrl_desc,
896 },
897#endif
Samuel Hollande3095022021-08-12 20:09:43 -0500898#ifdef CONFIG_PINCTRL_SUN50I_A64
899 {
900 .compatible = "allwinner,sun50i-a64-pinctrl",
901 .data = (ulong)&sun50i_a64_pinctrl_desc,
902 },
903#endif
904#ifdef CONFIG_PINCTRL_SUN50I_A64_R
905 {
906 .compatible = "allwinner,sun50i-a64-r-pinctrl",
907 .data = (ulong)&sun50i_a64_r_pinctrl_desc,
908 },
909#endif
910#ifdef CONFIG_PINCTRL_SUN50I_H5
911 {
912 .compatible = "allwinner,sun50i-h5-pinctrl",
913 .data = (ulong)&sun50i_h5_pinctrl_desc,
914 },
915#endif
916#ifdef CONFIG_PINCTRL_SUN50I_H6
917 {
918 .compatible = "allwinner,sun50i-h6-pinctrl",
919 .data = (ulong)&sun50i_h6_pinctrl_desc,
920 },
921#endif
922#ifdef CONFIG_PINCTRL_SUN50I_H6_R
923 {
924 .compatible = "allwinner,sun50i-h6-r-pinctrl",
925 .data = (ulong)&sun50i_h6_r_pinctrl_desc,
926 },
927#endif
928#ifdef CONFIG_PINCTRL_SUN50I_H616
929 {
930 .compatible = "allwinner,sun50i-h616-pinctrl",
931 .data = (ulong)&sun50i_h616_pinctrl_desc,
932 },
933#endif
934#ifdef CONFIG_PINCTRL_SUN50I_H616_R
935 {
936 .compatible = "allwinner,sun50i-h616-r-pinctrl",
937 .data = (ulong)&sun50i_h616_r_pinctrl_desc,
938 },
939#endif
940 {}
941};
942
943U_BOOT_DRIVER(sunxi_pinctrl) = {
944 .name = "sunxi-pinctrl",
945 .id = UCLASS_PINCTRL,
946 .of_match = sunxi_pinctrl_ids,
947 .bind = sunxi_pinctrl_bind,
948 .probe = sunxi_pinctrl_probe,
949 .plat_auto = sizeof(struct sunxi_pinctrl_plat),
950 .ops = &sunxi_pinctrl_ops,
951};