Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 1 | // 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> |
| 10 | |
| 11 | #include <asm/gpio.h> |
| 12 | |
| 13 | extern U_BOOT_DRIVER(gpio_sunxi); |
| 14 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 15 | /* |
| 16 | * This structure implements a simplified view of the possible pinmux settings: |
| 17 | * Each mux value is assumed to be the same for a given function, across the |
| 18 | * pins in each group (almost universally true, with same rare exceptions not |
| 19 | * relevant to U-Boot), but also across different ports (not true in many |
| 20 | * cases). We ignore the first problem, and work around the latter by just |
| 21 | * supporting one particular port for a each function. This works fine for all |
| 22 | * board configurations so far. If this would need to be revisited, we could |
| 23 | * add a "u8 port;" below and match that, with 0 encoding the "don't care" case. |
| 24 | */ |
| 25 | struct sunxi_pinctrl_function { |
| 26 | const char name[sizeof("gpio_out")]; |
| 27 | u8 mux; |
| 28 | }; |
| 29 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 30 | struct sunxi_pinctrl_desc { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 31 | const struct sunxi_pinctrl_function *functions; |
| 32 | u8 num_functions; |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 33 | u8 first_bank; |
| 34 | u8 num_banks; |
| 35 | }; |
| 36 | |
| 37 | struct sunxi_pinctrl_plat { |
| 38 | struct sunxi_gpio __iomem *base; |
| 39 | }; |
| 40 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 41 | static int sunxi_pinctrl_get_pins_count(struct udevice *dev) |
| 42 | { |
| 43 | const struct sunxi_pinctrl_desc *desc = dev_get_priv(dev); |
| 44 | |
| 45 | return desc->num_banks * SUNXI_GPIOS_PER_BANK; |
| 46 | } |
| 47 | |
| 48 | static const char *sunxi_pinctrl_get_pin_name(struct udevice *dev, |
| 49 | uint pin_selector) |
| 50 | { |
| 51 | const struct sunxi_pinctrl_desc *desc = dev_get_priv(dev); |
| 52 | static char pin_name[sizeof("PN31")]; |
| 53 | |
| 54 | snprintf(pin_name, sizeof(pin_name), "P%c%d", |
| 55 | pin_selector / SUNXI_GPIOS_PER_BANK + desc->first_bank + 'A', |
| 56 | pin_selector % SUNXI_GPIOS_PER_BANK); |
| 57 | |
| 58 | return pin_name; |
| 59 | } |
| 60 | |
| 61 | static int sunxi_pinctrl_get_functions_count(struct udevice *dev) |
| 62 | { |
| 63 | const struct sunxi_pinctrl_desc *desc = dev_get_priv(dev); |
| 64 | |
| 65 | return desc->num_functions; |
| 66 | } |
| 67 | |
| 68 | static const char *sunxi_pinctrl_get_function_name(struct udevice *dev, |
| 69 | uint func_selector) |
| 70 | { |
| 71 | const struct sunxi_pinctrl_desc *desc = dev_get_priv(dev); |
| 72 | |
| 73 | return desc->functions[func_selector].name; |
| 74 | } |
| 75 | |
| 76 | static int sunxi_pinctrl_pinmux_set(struct udevice *dev, uint pin_selector, |
| 77 | uint func_selector) |
| 78 | { |
| 79 | const struct sunxi_pinctrl_desc *desc = dev_get_priv(dev); |
| 80 | struct sunxi_pinctrl_plat *plat = dev_get_plat(dev); |
| 81 | int bank = pin_selector / SUNXI_GPIOS_PER_BANK; |
| 82 | int pin = pin_selector % SUNXI_GPIOS_PER_BANK; |
| 83 | |
| 84 | debug("set mux: %-4s => %s (%d)\n", |
| 85 | sunxi_pinctrl_get_pin_name(dev, pin_selector), |
| 86 | sunxi_pinctrl_get_function_name(dev, func_selector), |
| 87 | desc->functions[func_selector].mux); |
| 88 | |
| 89 | sunxi_gpio_set_cfgbank(plat->base + bank, pin, |
| 90 | desc->functions[func_selector].mux); |
| 91 | |
| 92 | return 0; |
| 93 | } |
| 94 | |
Samuel Holland | de828b4 | 2021-08-28 21:10:47 -0500 | [diff] [blame] | 95 | static const struct pinconf_param sunxi_pinctrl_pinconf_params[] = { |
| 96 | { "bias-disable", PIN_CONFIG_BIAS_DISABLE, 0 }, |
| 97 | { "bias-pull-down", PIN_CONFIG_BIAS_PULL_DOWN, 2 }, |
| 98 | { "bias-pull-up", PIN_CONFIG_BIAS_PULL_UP, 1 }, |
| 99 | { "drive-strength", PIN_CONFIG_DRIVE_STRENGTH, 10 }, |
| 100 | }; |
| 101 | |
| 102 | static int sunxi_pinctrl_pinconf_set_pull(struct sunxi_pinctrl_plat *plat, |
| 103 | uint bank, uint pin, uint bias) |
| 104 | { |
| 105 | struct sunxi_gpio *regs = &plat->base[bank]; |
| 106 | |
| 107 | sunxi_gpio_set_pull_bank(regs, pin, bias); |
| 108 | |
| 109 | return 0; |
| 110 | } |
| 111 | |
| 112 | static int sunxi_pinctrl_pinconf_set_drive(struct sunxi_pinctrl_plat *plat, |
| 113 | uint bank, uint pin, uint drive) |
| 114 | { |
| 115 | struct sunxi_gpio *regs = &plat->base[bank]; |
| 116 | |
| 117 | if (drive < 10 || drive > 40) |
| 118 | return -EINVAL; |
| 119 | |
| 120 | /* Convert mA to the register value, rounding down. */ |
| 121 | sunxi_gpio_set_drv_bank(regs, pin, drive / 10 - 1); |
| 122 | |
| 123 | return 0; |
| 124 | } |
| 125 | |
| 126 | static int sunxi_pinctrl_pinconf_set(struct udevice *dev, uint pin_selector, |
| 127 | uint param, uint val) |
| 128 | { |
| 129 | struct sunxi_pinctrl_plat *plat = dev_get_plat(dev); |
| 130 | int bank = pin_selector / SUNXI_GPIOS_PER_BANK; |
| 131 | int pin = pin_selector % SUNXI_GPIOS_PER_BANK; |
| 132 | |
| 133 | switch (param) { |
| 134 | case PIN_CONFIG_BIAS_DISABLE: |
| 135 | case PIN_CONFIG_BIAS_PULL_DOWN: |
| 136 | case PIN_CONFIG_BIAS_PULL_UP: |
| 137 | return sunxi_pinctrl_pinconf_set_pull(plat, bank, pin, val); |
| 138 | case PIN_CONFIG_DRIVE_STRENGTH: |
| 139 | return sunxi_pinctrl_pinconf_set_drive(plat, bank, pin, val); |
| 140 | } |
| 141 | |
| 142 | return -EINVAL; |
| 143 | } |
| 144 | |
Samuel Holland | 116d523 | 2021-08-17 00:52:00 -0500 | [diff] [blame] | 145 | static int sunxi_pinctrl_get_pin_muxing(struct udevice *dev, uint pin_selector, |
| 146 | char *buf, int size) |
| 147 | { |
| 148 | struct sunxi_pinctrl_plat *plat = dev_get_plat(dev); |
| 149 | int bank = pin_selector / SUNXI_GPIOS_PER_BANK; |
| 150 | int pin = pin_selector % SUNXI_GPIOS_PER_BANK; |
| 151 | int mux = sunxi_gpio_get_cfgbank(plat->base + bank, pin); |
| 152 | |
| 153 | switch (mux) { |
| 154 | case SUNXI_GPIO_INPUT: |
| 155 | strlcpy(buf, "gpio input", size); |
| 156 | break; |
| 157 | case SUNXI_GPIO_OUTPUT: |
| 158 | strlcpy(buf, "gpio output", size); |
| 159 | break; |
| 160 | case SUNXI_GPIO_DISABLE: |
| 161 | strlcpy(buf, "disabled", size); |
| 162 | break; |
| 163 | default: |
| 164 | snprintf(buf, size, "function %d", mux); |
| 165 | break; |
| 166 | } |
| 167 | |
| 168 | return 0; |
| 169 | } |
| 170 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 171 | static const struct pinctrl_ops sunxi_pinctrl_ops = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 172 | .get_pins_count = sunxi_pinctrl_get_pins_count, |
| 173 | .get_pin_name = sunxi_pinctrl_get_pin_name, |
| 174 | .get_functions_count = sunxi_pinctrl_get_functions_count, |
| 175 | .get_function_name = sunxi_pinctrl_get_function_name, |
| 176 | .pinmux_set = sunxi_pinctrl_pinmux_set, |
Samuel Holland | de828b4 | 2021-08-28 21:10:47 -0500 | [diff] [blame] | 177 | .pinconf_num_params = ARRAY_SIZE(sunxi_pinctrl_pinconf_params), |
| 178 | .pinconf_params = sunxi_pinctrl_pinconf_params, |
| 179 | .pinconf_set = sunxi_pinctrl_pinconf_set, |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 180 | .set_state = pinctrl_generic_set_state, |
Samuel Holland | 116d523 | 2021-08-17 00:52:00 -0500 | [diff] [blame] | 181 | .get_pin_muxing = sunxi_pinctrl_get_pin_muxing, |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 182 | }; |
| 183 | |
| 184 | static int sunxi_pinctrl_bind(struct udevice *dev) |
| 185 | { |
| 186 | struct sunxi_pinctrl_plat *plat = dev_get_plat(dev); |
| 187 | struct sunxi_pinctrl_desc *desc; |
| 188 | struct sunxi_gpio_plat *gpio_plat; |
| 189 | struct udevice *gpio_dev; |
| 190 | int i, ret; |
| 191 | |
| 192 | desc = (void *)dev_get_driver_data(dev); |
| 193 | if (!desc) |
| 194 | return -EINVAL; |
| 195 | dev_set_priv(dev, desc); |
| 196 | |
| 197 | plat->base = dev_read_addr_ptr(dev); |
| 198 | |
| 199 | ret = device_bind_driver_to_node(dev, "gpio_sunxi", dev->name, |
| 200 | dev_ofnode(dev), &gpio_dev); |
| 201 | if (ret) |
| 202 | return ret; |
| 203 | |
| 204 | for (i = 0; i < desc->num_banks; ++i) { |
| 205 | gpio_plat = malloc(sizeof(*gpio_plat)); |
| 206 | if (!gpio_plat) |
| 207 | return -ENOMEM; |
| 208 | |
| 209 | gpio_plat->regs = plat->base + i; |
| 210 | gpio_plat->bank_name[0] = 'P'; |
| 211 | gpio_plat->bank_name[1] = 'A' + desc->first_bank + i; |
| 212 | gpio_plat->bank_name[2] = '\0'; |
| 213 | |
| 214 | ret = device_bind(gpio_dev, DM_DRIVER_REF(gpio_sunxi), |
| 215 | gpio_plat->bank_name, gpio_plat, |
| 216 | ofnode_null(), NULL); |
| 217 | if (ret) |
| 218 | return ret; |
| 219 | } |
| 220 | |
| 221 | return 0; |
| 222 | } |
| 223 | |
| 224 | static int sunxi_pinctrl_probe(struct udevice *dev) |
| 225 | { |
| 226 | struct clk *apb_clk; |
| 227 | |
| 228 | apb_clk = devm_clk_get(dev, "apb"); |
| 229 | if (!IS_ERR(apb_clk)) |
| 230 | clk_enable(apb_clk); |
| 231 | |
| 232 | return 0; |
| 233 | } |
| 234 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 235 | static const struct sunxi_pinctrl_function suniv_f1c100s_pinctrl_functions[] = { |
| 236 | { "gpio_in", 0 }, |
| 237 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 238 | { "i2c0", 3 }, /* PE11-PE12 */ |
| 239 | { "i2c1", 3 }, /* PD5-PD6 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 240 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 241 | { "mmc1", 3 }, /* PC0-PC2 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 242 | { "spi0", 2 }, /* PC0-PC3 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 243 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 244 | { "uart0", 3 }, /* PF2-PF4 */ |
| 245 | #else |
| 246 | { "uart0", 5 }, /* PE0-PE1 */ |
| 247 | #endif |
Andre Przywara | 72313dc | 2022-10-05 23:19:54 +0100 | [diff] [blame^] | 248 | { "uart1", 5 }, /* PA0-PA3 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 249 | }; |
| 250 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 251 | static const struct sunxi_pinctrl_desc __maybe_unused suniv_f1c100s_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 252 | .functions = suniv_f1c100s_pinctrl_functions, |
| 253 | .num_functions = ARRAY_SIZE(suniv_f1c100s_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 254 | .first_bank = SUNXI_GPIO_A, |
| 255 | .num_banks = 6, |
| 256 | }; |
| 257 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 258 | static const struct sunxi_pinctrl_function sun4i_a10_pinctrl_functions[] = { |
Samuel Holland | 5d57e05 | 2021-08-28 13:21:36 -0500 | [diff] [blame] | 259 | { "emac", 2 }, /* PA0-PA17 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 260 | { "gpio_in", 0 }, |
| 261 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 262 | { "i2c0", 2 }, /* PB0-PB1 */ |
| 263 | { "i2c1", 2 }, /* PB18-PB19 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 264 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 265 | #if IS_ENABLED(CONFIG_MMC1_PINS_PH) |
| 266 | { "mmc1", 5 }, /* PH22-PH27 */ |
| 267 | #else |
| 268 | { "mmc1", 4 }, /* PG0-PG5 */ |
| 269 | #endif |
| 270 | { "mmc2", 3 }, /* PC6-PC15 */ |
| 271 | { "mmc3", 2 }, /* PI4-PI9 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 272 | { "spi0", 3 }, /* PC0-PC2, PC23 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 273 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 274 | { "uart0", 4 }, /* PF2-PF4 */ |
| 275 | #else |
| 276 | { "uart0", 2 }, /* PB22-PB23 */ |
| 277 | #endif |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 278 | }; |
| 279 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 280 | static const struct sunxi_pinctrl_desc __maybe_unused sun4i_a10_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 281 | .functions = sun4i_a10_pinctrl_functions, |
| 282 | .num_functions = ARRAY_SIZE(sun4i_a10_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 283 | .first_bank = SUNXI_GPIO_A, |
| 284 | .num_banks = 9, |
| 285 | }; |
| 286 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 287 | static const struct sunxi_pinctrl_function sun5i_a13_pinctrl_functions[] = { |
Samuel Holland | 5d57e05 | 2021-08-28 13:21:36 -0500 | [diff] [blame] | 288 | { "emac", 2 }, /* PA0-PA17 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 289 | { "gpio_in", 0 }, |
| 290 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 291 | { "i2c0", 2 }, /* PB0-PB1 */ |
| 292 | { "i2c1", 2 }, /* PB15-PB16 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 293 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 294 | { "mmc1", 2 }, /* PG3-PG8 */ |
| 295 | { "mmc2", 3 }, /* PC6-PC15 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 296 | { "spi0", 3 }, /* PC0-PC3 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 297 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 298 | { "uart0", 4 }, /* PF2-PF4 */ |
| 299 | #else |
| 300 | { "uart0", 2 }, /* PB19-PB20 */ |
| 301 | #endif |
| 302 | { "uart1", 4 }, /* PG3-PG4 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 303 | }; |
| 304 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 305 | static const struct sunxi_pinctrl_desc __maybe_unused sun5i_a13_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 306 | .functions = sun5i_a13_pinctrl_functions, |
| 307 | .num_functions = ARRAY_SIZE(sun5i_a13_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 308 | .first_bank = SUNXI_GPIO_A, |
| 309 | .num_banks = 7, |
| 310 | }; |
| 311 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 312 | static const struct sunxi_pinctrl_function sun6i_a31_pinctrl_functions[] = { |
Samuel Holland | 8181f56 | 2021-08-28 13:13:52 -0500 | [diff] [blame] | 313 | { "gmac", 2 }, /* PA0-PA27 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 314 | { "gpio_in", 0 }, |
| 315 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 316 | { "i2c0", 2 }, /* PH14-PH15 */ |
| 317 | { "i2c1", 2 }, /* PH16-PH17 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 318 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 319 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 320 | { "mmc2", 3 }, /* PC6-PC15, PC24 */ |
| 321 | { "mmc3", 4 }, /* PC6-PC15, PC24 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 322 | { "spi0", 3 }, /* PC0-PC2, PC27 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 323 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 324 | { "uart0", 3 }, /* PF2-PF4 */ |
| 325 | #else |
| 326 | { "uart0", 2 }, /* PH20-PH21 */ |
| 327 | #endif |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 328 | }; |
| 329 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 330 | static const struct sunxi_pinctrl_desc __maybe_unused sun6i_a31_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 331 | .functions = sun6i_a31_pinctrl_functions, |
| 332 | .num_functions = ARRAY_SIZE(sun6i_a31_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 333 | .first_bank = SUNXI_GPIO_A, |
| 334 | .num_banks = 8, |
| 335 | }; |
| 336 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 337 | static const struct sunxi_pinctrl_function sun6i_a31_r_pinctrl_functions[] = { |
| 338 | { "gpio_in", 0 }, |
| 339 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 340 | { "s_i2c", 2 }, /* PL0-PL1 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 341 | { "s_uart", 2 }, /* PL2-PL3 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 342 | }; |
| 343 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 344 | static const struct sunxi_pinctrl_desc __maybe_unused sun6i_a31_r_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 345 | .functions = sun6i_a31_r_pinctrl_functions, |
| 346 | .num_functions = ARRAY_SIZE(sun6i_a31_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 347 | .first_bank = SUNXI_GPIO_L, |
| 348 | .num_banks = 2, |
| 349 | }; |
| 350 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 351 | static const struct sunxi_pinctrl_function sun7i_a20_pinctrl_functions[] = { |
Samuel Holland | 5d57e05 | 2021-08-28 13:21:36 -0500 | [diff] [blame] | 352 | { "emac", 2 }, /* PA0-PA17 */ |
Samuel Holland | 8181f56 | 2021-08-28 13:13:52 -0500 | [diff] [blame] | 353 | { "gmac", 5 }, /* PA0-PA17 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 354 | { "gpio_in", 0 }, |
| 355 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 356 | { "i2c0", 2 }, /* PB0-PB1 */ |
| 357 | { "i2c1", 2 }, /* PB18-PB19 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 358 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 359 | #if IS_ENABLED(CONFIG_MMC1_PINS_PH) |
| 360 | { "mmc1", 5 }, /* PH22-PH27 */ |
| 361 | #else |
| 362 | { "mmc1", 4 }, /* PG0-PG5 */ |
| 363 | #endif |
| 364 | { "mmc2", 3 }, /* PC5-PC15, PC24 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 365 | { "spi0", 3 }, /* PC0-PC2, PC23 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 366 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 367 | { "uart0", 4 }, /* PF2-PF4 */ |
| 368 | #else |
| 369 | { "uart0", 2 }, /* PB22-PB23 */ |
| 370 | #endif |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 371 | }; |
| 372 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 373 | static const struct sunxi_pinctrl_desc __maybe_unused sun7i_a20_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 374 | .functions = sun7i_a20_pinctrl_functions, |
| 375 | .num_functions = ARRAY_SIZE(sun7i_a20_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 376 | .first_bank = SUNXI_GPIO_A, |
| 377 | .num_banks = 9, |
| 378 | }; |
| 379 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 380 | static const struct sunxi_pinctrl_function sun8i_a23_pinctrl_functions[] = { |
| 381 | { "gpio_in", 0 }, |
| 382 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 383 | { "i2c0", 2 }, /* PH2-PH3 */ |
| 384 | { "i2c1", 2 }, /* PH4-PH5 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 385 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 386 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 387 | { "mmc2", 3 }, /* PC5-PC16 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 388 | { "spi0", 3 }, /* PC0-PC3 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 389 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 390 | { "uart0", 3 }, /* PF2-PF4 */ |
| 391 | #endif |
| 392 | { "uart1", 2 }, /* PG6-PG7 */ |
| 393 | { "uart2", 2 }, /* PB0-PB1 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 394 | }; |
| 395 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 396 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a23_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 397 | .functions = sun8i_a23_pinctrl_functions, |
| 398 | .num_functions = ARRAY_SIZE(sun8i_a23_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 399 | .first_bank = SUNXI_GPIO_A, |
| 400 | .num_banks = 8, |
| 401 | }; |
| 402 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 403 | static const struct sunxi_pinctrl_function sun8i_a23_r_pinctrl_functions[] = { |
| 404 | { "gpio_in", 0 }, |
| 405 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 406 | { "s_i2c", 3 }, /* PL0-PL1 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 407 | { "s_uart", 2 }, /* PL2-PL3 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 408 | }; |
| 409 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 410 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a23_r_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 411 | .functions = sun8i_a23_r_pinctrl_functions, |
| 412 | .num_functions = ARRAY_SIZE(sun8i_a23_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 413 | .first_bank = SUNXI_GPIO_L, |
| 414 | .num_banks = 1, |
| 415 | }; |
| 416 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 417 | static const struct sunxi_pinctrl_function sun8i_a33_pinctrl_functions[] = { |
| 418 | { "gpio_in", 0 }, |
| 419 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 420 | { "i2c0", 2 }, /* PH2-PH3 */ |
| 421 | { "i2c1", 2 }, /* PH4-PH5 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 422 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 423 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 424 | { "mmc2", 3 }, /* PC5-PC16 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 425 | { "spi0", 3 }, /* PC0-PC3 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 426 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 427 | { "uart0", 3 }, /* PF2-PF4 */ |
| 428 | #else |
| 429 | { "uart0", 3 }, /* PB0-PB1 */ |
| 430 | #endif |
| 431 | { "uart1", 2 }, /* PG6-PG7 */ |
| 432 | { "uart2", 2 }, /* PB0-PB1 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 433 | }; |
| 434 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 435 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a33_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 436 | .functions = sun8i_a33_pinctrl_functions, |
| 437 | .num_functions = ARRAY_SIZE(sun8i_a33_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 438 | .first_bank = SUNXI_GPIO_A, |
| 439 | .num_banks = 8, |
| 440 | }; |
| 441 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 442 | static const struct sunxi_pinctrl_function sun8i_a83t_pinctrl_functions[] = { |
Samuel Holland | a8cbf47 | 2021-08-28 13:34:29 -0500 | [diff] [blame] | 443 | { "gmac", 4 }, /* PD2-PD23 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 444 | { "gpio_in", 0 }, |
| 445 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 446 | { "i2c0", 2 }, /* PH0-PH1 */ |
| 447 | { "i2c1", 2 }, /* PH2-PH3 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 448 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 449 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 450 | { "mmc2", 3 }, /* PC5-PC16 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 451 | { "spi0", 3 }, /* PC0-PC3 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 452 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 453 | { "uart0", 3 }, /* PF2-PF4 */ |
| 454 | #else |
| 455 | { "uart0", 2 }, /* PB9-PB10 */ |
| 456 | #endif |
| 457 | { "uart1", 2 }, /* PG6-PG7 */ |
| 458 | { "uart2", 2 }, /* PB0-PB1 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 459 | }; |
| 460 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 461 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a83t_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 462 | .functions = sun8i_a83t_pinctrl_functions, |
| 463 | .num_functions = ARRAY_SIZE(sun8i_a83t_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 464 | .first_bank = SUNXI_GPIO_A, |
| 465 | .num_banks = 8, |
| 466 | }; |
| 467 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 468 | static const struct sunxi_pinctrl_function sun8i_a83t_r_pinctrl_functions[] = { |
| 469 | { "gpio_in", 0 }, |
| 470 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 471 | { "s_i2c", 2 }, /* PL8-PL9 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 472 | { "s_uart", 2 }, /* PL2-PL3 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 473 | }; |
| 474 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 475 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a83t_r_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 476 | .functions = sun8i_a83t_r_pinctrl_functions, |
| 477 | .num_functions = ARRAY_SIZE(sun8i_a83t_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 478 | .first_bank = SUNXI_GPIO_L, |
| 479 | .num_banks = 1, |
| 480 | }; |
| 481 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 482 | static const struct sunxi_pinctrl_function sun8i_h3_pinctrl_functions[] = { |
Samuel Holland | a8cbf47 | 2021-08-28 13:34:29 -0500 | [diff] [blame] | 483 | { "emac", 2 }, /* PD0-PD17 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 484 | { "gpio_in", 0 }, |
| 485 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 486 | { "i2c0", 2 }, /* PA11-PA12 */ |
| 487 | { "i2c1", 3 }, /* PA18-PA19 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 488 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 489 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 490 | { "mmc2", 3 }, /* PC5-PC16 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 491 | { "spi0", 3 }, /* PC0-PC3 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 492 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 493 | { "uart0", 3 }, /* PF2-PF4 */ |
| 494 | #else |
| 495 | { "uart0", 2 }, /* PA4-PA5 */ |
| 496 | #endif |
| 497 | { "uart1", 2 }, /* PG6-PG7 */ |
| 498 | { "uart2", 2 }, /* PA0-PA1 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 499 | }; |
| 500 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 501 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_h3_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 502 | .functions = sun8i_h3_pinctrl_functions, |
| 503 | .num_functions = ARRAY_SIZE(sun8i_h3_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 504 | .first_bank = SUNXI_GPIO_A, |
| 505 | .num_banks = 7, |
| 506 | }; |
| 507 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 508 | static const struct sunxi_pinctrl_function sun8i_h3_r_pinctrl_functions[] = { |
| 509 | { "gpio_in", 0 }, |
| 510 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 511 | { "s_i2c", 2 }, /* PL0-PL1 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 512 | { "s_uart", 2 }, /* PL2-PL3 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 513 | }; |
| 514 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 515 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_h3_r_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 516 | .functions = sun8i_h3_r_pinctrl_functions, |
| 517 | .num_functions = ARRAY_SIZE(sun8i_h3_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 518 | .first_bank = SUNXI_GPIO_L, |
| 519 | .num_banks = 1, |
| 520 | }; |
| 521 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 522 | static const struct sunxi_pinctrl_function sun8i_v3s_pinctrl_functions[] = { |
Samuel Holland | a8cbf47 | 2021-08-28 13:34:29 -0500 | [diff] [blame] | 523 | { "emac", 4 }, /* PD0-PD17 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 524 | { "gpio_in", 0 }, |
| 525 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 526 | { "i2c0", 2 }, /* PB6-PB7 */ |
| 527 | { "i2c1", 2 }, /* PB8-PB9 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 528 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 529 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 530 | { "mmc2", 2 }, /* PC0-PC10 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 531 | { "spi0", 3 }, /* PC0-PC3 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 532 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 533 | { "uart0", 3 }, /* PF2-PF4 */ |
| 534 | #else |
| 535 | { "uart0", 3 }, /* PB8-PB9 */ |
| 536 | #endif |
| 537 | { "uart1", 2 }, /* PG6-PG7 */ |
| 538 | { "uart2", 2 }, /* PB0-PB1 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 539 | }; |
| 540 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 541 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_v3s_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 542 | .functions = sun8i_v3s_pinctrl_functions, |
| 543 | .num_functions = ARRAY_SIZE(sun8i_v3s_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 544 | .first_bank = SUNXI_GPIO_A, |
| 545 | .num_banks = 7, |
| 546 | }; |
| 547 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 548 | static const struct sunxi_pinctrl_function sun9i_a80_pinctrl_functions[] = { |
Samuel Holland | 8181f56 | 2021-08-28 13:13:52 -0500 | [diff] [blame] | 549 | { "gmac", 2 }, /* PA0-PA17 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 550 | { "gpio_in", 0 }, |
| 551 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 552 | { "i2c0", 2 }, /* PH0-PH1 */ |
| 553 | { "i2c1", 2 }, /* PH2-PH3 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 554 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 555 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 556 | { "mmc2", 3 }, /* PC6-PC16 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 557 | { "spi0", 3 }, /* PC0-PC2, PC19 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 558 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 559 | { "uart0", 4 }, /* PF2-PF4 */ |
| 560 | #else |
| 561 | { "uart0", 2 }, /* PH12-PH13 */ |
| 562 | #endif |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 563 | }; |
| 564 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 565 | static const struct sunxi_pinctrl_desc __maybe_unused sun9i_a80_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 566 | .functions = sun9i_a80_pinctrl_functions, |
| 567 | .num_functions = ARRAY_SIZE(sun9i_a80_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 568 | .first_bank = SUNXI_GPIO_A, |
| 569 | .num_banks = 8, |
| 570 | }; |
| 571 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 572 | static const struct sunxi_pinctrl_function sun9i_a80_r_pinctrl_functions[] = { |
| 573 | { "gpio_in", 0 }, |
| 574 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 575 | { "s_i2c0", 2 }, /* PN0-PN1 */ |
| 576 | { "s_i2c1", 3 }, /* PM8-PM9 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 577 | { "s_uart", 3 }, /* PL0-PL1 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 578 | }; |
| 579 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 580 | static const struct sunxi_pinctrl_desc __maybe_unused sun9i_a80_r_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 581 | .functions = sun9i_a80_r_pinctrl_functions, |
| 582 | .num_functions = ARRAY_SIZE(sun9i_a80_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 583 | .first_bank = SUNXI_GPIO_L, |
| 584 | .num_banks = 3, |
| 585 | }; |
| 586 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 587 | static const struct sunxi_pinctrl_function sun50i_a64_pinctrl_functions[] = { |
Samuel Holland | a8cbf47 | 2021-08-28 13:34:29 -0500 | [diff] [blame] | 588 | { "emac", 4 }, /* PD8-PD23 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 589 | { "gpio_in", 0 }, |
| 590 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 591 | { "i2c0", 2 }, /* PH0-PH1 */ |
| 592 | { "i2c1", 2 }, /* PH2-PH3 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 593 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 594 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 595 | { "mmc2", 3 }, /* PC1-PC16 */ |
Samuel Holland | 3de641b | 2021-08-28 15:52:52 -0500 | [diff] [blame] | 596 | { "pwm", 2 }, /* PD22 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 597 | { "spi0", 4 }, /* PC0-PC3 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 598 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 599 | { "uart0", 3 }, /* PF2-PF4 */ |
| 600 | #else |
| 601 | { "uart0", 4 }, /* PB8-PB9 */ |
| 602 | #endif |
| 603 | { "uart1", 2 }, /* PG6-PG7 */ |
| 604 | { "uart2", 2 }, /* PB0-PB1 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 605 | }; |
| 606 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 607 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_a64_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 608 | .functions = sun50i_a64_pinctrl_functions, |
| 609 | .num_functions = ARRAY_SIZE(sun50i_a64_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 610 | .first_bank = SUNXI_GPIO_A, |
| 611 | .num_banks = 8, |
| 612 | }; |
| 613 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 614 | static const struct sunxi_pinctrl_function sun50i_a64_r_pinctrl_functions[] = { |
| 615 | { "gpio_in", 0 }, |
| 616 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 617 | { "s_i2c", 2 }, /* PL8-PL9 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 618 | { "s_uart", 2 }, /* PL2-PL3 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 619 | }; |
| 620 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 621 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_a64_r_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 622 | .functions = sun50i_a64_r_pinctrl_functions, |
| 623 | .num_functions = ARRAY_SIZE(sun50i_a64_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 624 | .first_bank = SUNXI_GPIO_L, |
| 625 | .num_banks = 1, |
| 626 | }; |
| 627 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 628 | static const struct sunxi_pinctrl_function sun50i_h5_pinctrl_functions[] = { |
Samuel Holland | a8cbf47 | 2021-08-28 13:34:29 -0500 | [diff] [blame] | 629 | { "emac", 2 }, /* PD0-PD17 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 630 | { "gpio_in", 0 }, |
| 631 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 632 | { "i2c0", 2 }, /* PA11-PA12 */ |
| 633 | { "i2c1", 3 }, /* PA18-PA19 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 634 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 635 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 636 | { "mmc2", 3 }, /* PC1-PC16 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 637 | { "spi0", 3 }, /* PC0-PC3 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 638 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 639 | { "uart0", 3 }, /* PF2-PF4 */ |
| 640 | #else |
| 641 | { "uart0", 2 }, /* PA4-PA5 */ |
| 642 | #endif |
| 643 | { "uart1", 2 }, /* PG6-PG7 */ |
| 644 | { "uart2", 2 }, /* PA0-PA1 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 645 | }; |
| 646 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 647 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h5_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 648 | .functions = sun50i_h5_pinctrl_functions, |
| 649 | .num_functions = ARRAY_SIZE(sun50i_h5_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 650 | .first_bank = SUNXI_GPIO_A, |
| 651 | .num_banks = 7, |
| 652 | }; |
| 653 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 654 | static const struct sunxi_pinctrl_function sun50i_h6_pinctrl_functions[] = { |
Samuel Holland | a8cbf47 | 2021-08-28 13:34:29 -0500 | [diff] [blame] | 655 | { "emac", 5 }, /* PD0-PD20 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 656 | { "gpio_in", 0 }, |
| 657 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 658 | { "i2c0", 2 }, /* PD25-PD26 */ |
| 659 | { "i2c1", 4 }, /* PH5-PH6 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 660 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 661 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 662 | { "mmc2", 3 }, /* PC1-PC14 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 663 | { "spi0", 4 }, /* PC0-PC7 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 664 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 665 | { "uart0", 3 }, /* PF2-PF4 */ |
| 666 | #else |
| 667 | { "uart0", 2 }, /* PH0-PH1 */ |
| 668 | #endif |
| 669 | { "uart1", 2 }, /* PG6-PG7 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 670 | }; |
| 671 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 672 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h6_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 673 | .functions = sun50i_h6_pinctrl_functions, |
| 674 | .num_functions = ARRAY_SIZE(sun50i_h6_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 675 | .first_bank = SUNXI_GPIO_A, |
| 676 | .num_banks = 8, |
| 677 | }; |
| 678 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 679 | static const struct sunxi_pinctrl_function sun50i_h6_r_pinctrl_functions[] = { |
| 680 | { "gpio_in", 0 }, |
| 681 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 682 | { "s_i2c", 3 }, /* PL0-PL1 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 683 | { "s_uart", 2 }, /* PL2-PL3 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 684 | }; |
| 685 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 686 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h6_r_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 687 | .functions = sun50i_h6_r_pinctrl_functions, |
| 688 | .num_functions = ARRAY_SIZE(sun50i_h6_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 689 | .first_bank = SUNXI_GPIO_L, |
| 690 | .num_banks = 2, |
| 691 | }; |
| 692 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 693 | static const struct sunxi_pinctrl_function sun50i_h616_pinctrl_functions[] = { |
Samuel Holland | a8cbf47 | 2021-08-28 13:34:29 -0500 | [diff] [blame] | 694 | { "emac0", 2 }, /* PI0-PI16 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 695 | { "gpio_in", 0 }, |
| 696 | { "gpio_out", 1 }, |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 697 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 698 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 699 | { "mmc2", 3 }, /* PC0-PC16 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 700 | { "spi0", 4 }, /* PC0-PC7, PC15-PC16 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 701 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 702 | { "uart0", 3 }, /* PF2-PF4 */ |
| 703 | #else |
| 704 | { "uart0", 2 }, /* PH0-PH1 */ |
| 705 | #endif |
| 706 | { "uart1", 2 }, /* PG6-PG7 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 707 | }; |
| 708 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 709 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h616_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 710 | .functions = sun50i_h616_pinctrl_functions, |
| 711 | .num_functions = ARRAY_SIZE(sun50i_h616_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 712 | .first_bank = SUNXI_GPIO_A, |
| 713 | .num_banks = 9, |
| 714 | }; |
| 715 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 716 | static const struct sunxi_pinctrl_function sun50i_h616_r_pinctrl_functions[] = { |
| 717 | { "gpio_in", 0 }, |
| 718 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 719 | { "s_i2c", 3 }, /* PL0-PL1 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 720 | { "s_uart", 2 }, /* PL2-PL3 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 721 | }; |
| 722 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 723 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h616_r_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 724 | .functions = sun50i_h616_r_pinctrl_functions, |
| 725 | .num_functions = ARRAY_SIZE(sun50i_h616_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 726 | .first_bank = SUNXI_GPIO_L, |
| 727 | .num_banks = 1, |
| 728 | }; |
| 729 | |
| 730 | static const struct udevice_id sunxi_pinctrl_ids[] = { |
| 731 | #ifdef CONFIG_PINCTRL_SUNIV_F1C100S |
| 732 | { |
| 733 | .compatible = "allwinner,suniv-f1c100s-pinctrl", |
| 734 | .data = (ulong)&suniv_f1c100s_pinctrl_desc, |
| 735 | }, |
| 736 | #endif |
| 737 | #ifdef CONFIG_PINCTRL_SUN4I_A10 |
| 738 | { |
| 739 | .compatible = "allwinner,sun4i-a10-pinctrl", |
| 740 | .data = (ulong)&sun4i_a10_pinctrl_desc, |
| 741 | }, |
| 742 | #endif |
| 743 | #ifdef CONFIG_PINCTRL_SUN5I_A13 |
| 744 | { |
| 745 | .compatible = "allwinner,sun5i-a10s-pinctrl", |
| 746 | .data = (ulong)&sun5i_a13_pinctrl_desc, |
| 747 | }, |
| 748 | { |
| 749 | .compatible = "allwinner,sun5i-a13-pinctrl", |
| 750 | .data = (ulong)&sun5i_a13_pinctrl_desc, |
| 751 | }, |
| 752 | #endif |
| 753 | #ifdef CONFIG_PINCTRL_SUN6I_A31 |
| 754 | { |
| 755 | .compatible = "allwinner,sun6i-a31-pinctrl", |
| 756 | .data = (ulong)&sun6i_a31_pinctrl_desc, |
| 757 | }, |
| 758 | { |
| 759 | .compatible = "allwinner,sun6i-a31s-pinctrl", |
| 760 | .data = (ulong)&sun6i_a31_pinctrl_desc, |
| 761 | }, |
| 762 | #endif |
| 763 | #ifdef CONFIG_PINCTRL_SUN6I_A31_R |
| 764 | { |
| 765 | .compatible = "allwinner,sun6i-a31-r-pinctrl", |
| 766 | .data = (ulong)&sun6i_a31_r_pinctrl_desc, |
| 767 | }, |
| 768 | #endif |
| 769 | #ifdef CONFIG_PINCTRL_SUN7I_A20 |
| 770 | { |
| 771 | .compatible = "allwinner,sun7i-a20-pinctrl", |
| 772 | .data = (ulong)&sun7i_a20_pinctrl_desc, |
| 773 | }, |
| 774 | #endif |
| 775 | #ifdef CONFIG_PINCTRL_SUN8I_A23 |
| 776 | { |
| 777 | .compatible = "allwinner,sun8i-a23-pinctrl", |
| 778 | .data = (ulong)&sun8i_a23_pinctrl_desc, |
| 779 | }, |
| 780 | #endif |
| 781 | #ifdef CONFIG_PINCTRL_SUN8I_A23_R |
| 782 | { |
| 783 | .compatible = "allwinner,sun8i-a23-r-pinctrl", |
| 784 | .data = (ulong)&sun8i_a23_r_pinctrl_desc, |
| 785 | }, |
| 786 | #endif |
| 787 | #ifdef CONFIG_PINCTRL_SUN8I_A33 |
| 788 | { |
| 789 | .compatible = "allwinner,sun8i-a33-pinctrl", |
| 790 | .data = (ulong)&sun8i_a33_pinctrl_desc, |
| 791 | }, |
| 792 | #endif |
| 793 | #ifdef CONFIG_PINCTRL_SUN8I_A83T |
| 794 | { |
| 795 | .compatible = "allwinner,sun8i-a83t-pinctrl", |
| 796 | .data = (ulong)&sun8i_a83t_pinctrl_desc, |
| 797 | }, |
| 798 | #endif |
| 799 | #ifdef CONFIG_PINCTRL_SUN8I_A83T_R |
| 800 | { |
| 801 | .compatible = "allwinner,sun8i-a83t-r-pinctrl", |
| 802 | .data = (ulong)&sun8i_a83t_r_pinctrl_desc, |
| 803 | }, |
| 804 | #endif |
| 805 | #ifdef CONFIG_PINCTRL_SUN8I_H3 |
| 806 | { |
| 807 | .compatible = "allwinner,sun8i-h3-pinctrl", |
| 808 | .data = (ulong)&sun8i_h3_pinctrl_desc, |
| 809 | }, |
| 810 | #endif |
| 811 | #ifdef CONFIG_PINCTRL_SUN8I_H3_R |
| 812 | { |
| 813 | .compatible = "allwinner,sun8i-h3-r-pinctrl", |
| 814 | .data = (ulong)&sun8i_h3_r_pinctrl_desc, |
| 815 | }, |
| 816 | #endif |
| 817 | #ifdef CONFIG_PINCTRL_SUN7I_A20 |
| 818 | { |
| 819 | .compatible = "allwinner,sun8i-r40-pinctrl", |
| 820 | .data = (ulong)&sun7i_a20_pinctrl_desc, |
| 821 | }, |
| 822 | #endif |
| 823 | #ifdef CONFIG_PINCTRL_SUN8I_V3S |
| 824 | { |
| 825 | .compatible = "allwinner,sun8i-v3-pinctrl", |
| 826 | .data = (ulong)&sun8i_v3s_pinctrl_desc, |
| 827 | }, |
| 828 | { |
| 829 | .compatible = "allwinner,sun8i-v3s-pinctrl", |
| 830 | .data = (ulong)&sun8i_v3s_pinctrl_desc, |
| 831 | }, |
| 832 | #endif |
| 833 | #ifdef CONFIG_PINCTRL_SUN9I_A80 |
| 834 | { |
| 835 | .compatible = "allwinner,sun9i-a80-pinctrl", |
| 836 | .data = (ulong)&sun9i_a80_pinctrl_desc, |
| 837 | }, |
| 838 | #endif |
| 839 | #ifdef CONFIG_PINCTRL_SUN9I_A80_R |
| 840 | { |
| 841 | .compatible = "allwinner,sun9i-a80-r-pinctrl", |
| 842 | .data = (ulong)&sun9i_a80_r_pinctrl_desc, |
| 843 | }, |
| 844 | #endif |
| 845 | #ifdef CONFIG_PINCTRL_SUN50I_A64 |
| 846 | { |
| 847 | .compatible = "allwinner,sun50i-a64-pinctrl", |
| 848 | .data = (ulong)&sun50i_a64_pinctrl_desc, |
| 849 | }, |
| 850 | #endif |
| 851 | #ifdef CONFIG_PINCTRL_SUN50I_A64_R |
| 852 | { |
| 853 | .compatible = "allwinner,sun50i-a64-r-pinctrl", |
| 854 | .data = (ulong)&sun50i_a64_r_pinctrl_desc, |
| 855 | }, |
| 856 | #endif |
| 857 | #ifdef CONFIG_PINCTRL_SUN50I_H5 |
| 858 | { |
| 859 | .compatible = "allwinner,sun50i-h5-pinctrl", |
| 860 | .data = (ulong)&sun50i_h5_pinctrl_desc, |
| 861 | }, |
| 862 | #endif |
| 863 | #ifdef CONFIG_PINCTRL_SUN50I_H6 |
| 864 | { |
| 865 | .compatible = "allwinner,sun50i-h6-pinctrl", |
| 866 | .data = (ulong)&sun50i_h6_pinctrl_desc, |
| 867 | }, |
| 868 | #endif |
| 869 | #ifdef CONFIG_PINCTRL_SUN50I_H6_R |
| 870 | { |
| 871 | .compatible = "allwinner,sun50i-h6-r-pinctrl", |
| 872 | .data = (ulong)&sun50i_h6_r_pinctrl_desc, |
| 873 | }, |
| 874 | #endif |
| 875 | #ifdef CONFIG_PINCTRL_SUN50I_H616 |
| 876 | { |
| 877 | .compatible = "allwinner,sun50i-h616-pinctrl", |
| 878 | .data = (ulong)&sun50i_h616_pinctrl_desc, |
| 879 | }, |
| 880 | #endif |
| 881 | #ifdef CONFIG_PINCTRL_SUN50I_H616_R |
| 882 | { |
| 883 | .compatible = "allwinner,sun50i-h616-r-pinctrl", |
| 884 | .data = (ulong)&sun50i_h616_r_pinctrl_desc, |
| 885 | }, |
| 886 | #endif |
| 887 | {} |
| 888 | }; |
| 889 | |
| 890 | U_BOOT_DRIVER(sunxi_pinctrl) = { |
| 891 | .name = "sunxi-pinctrl", |
| 892 | .id = UCLASS_PINCTRL, |
| 893 | .of_match = sunxi_pinctrl_ids, |
| 894 | .bind = sunxi_pinctrl_bind, |
| 895 | .probe = sunxi_pinctrl_probe, |
| 896 | .plat_auto = sizeof(struct sunxi_pinctrl_plat), |
| 897 | .ops = &sunxi_pinctrl_ops, |
| 898 | }; |