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 |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 248 | }; |
| 249 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 250 | static const struct sunxi_pinctrl_desc __maybe_unused suniv_f1c100s_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 251 | .functions = suniv_f1c100s_pinctrl_functions, |
| 252 | .num_functions = ARRAY_SIZE(suniv_f1c100s_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 253 | .first_bank = SUNXI_GPIO_A, |
| 254 | .num_banks = 6, |
| 255 | }; |
| 256 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 257 | static const struct sunxi_pinctrl_function sun4i_a10_pinctrl_functions[] = { |
Samuel Holland | 5d57e05 | 2021-08-28 13:21:36 -0500 | [diff] [blame] | 258 | { "emac", 2 }, /* PA0-PA17 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 259 | { "gpio_in", 0 }, |
| 260 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 261 | { "i2c0", 2 }, /* PB0-PB1 */ |
| 262 | { "i2c1", 2 }, /* PB18-PB19 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 263 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 264 | #if IS_ENABLED(CONFIG_MMC1_PINS_PH) |
| 265 | { "mmc1", 5 }, /* PH22-PH27 */ |
| 266 | #else |
| 267 | { "mmc1", 4 }, /* PG0-PG5 */ |
| 268 | #endif |
| 269 | { "mmc2", 3 }, /* PC6-PC15 */ |
| 270 | { "mmc3", 2 }, /* PI4-PI9 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 271 | { "spi0", 3 }, /* PC0-PC2, PC23 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 272 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 273 | { "uart0", 4 }, /* PF2-PF4 */ |
| 274 | #else |
| 275 | { "uart0", 2 }, /* PB22-PB23 */ |
| 276 | #endif |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 277 | }; |
| 278 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 279 | static const struct sunxi_pinctrl_desc __maybe_unused sun4i_a10_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 280 | .functions = sun4i_a10_pinctrl_functions, |
| 281 | .num_functions = ARRAY_SIZE(sun4i_a10_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 282 | .first_bank = SUNXI_GPIO_A, |
| 283 | .num_banks = 9, |
| 284 | }; |
| 285 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 286 | static const struct sunxi_pinctrl_function sun5i_a13_pinctrl_functions[] = { |
Samuel Holland | 5d57e05 | 2021-08-28 13:21:36 -0500 | [diff] [blame] | 287 | { "emac", 2 }, /* PA0-PA17 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 288 | { "gpio_in", 0 }, |
| 289 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 290 | { "i2c0", 2 }, /* PB0-PB1 */ |
| 291 | { "i2c1", 2 }, /* PB15-PB16 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 292 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 293 | { "mmc1", 2 }, /* PG3-PG8 */ |
| 294 | { "mmc2", 3 }, /* PC6-PC15 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 295 | { "spi0", 3 }, /* PC0-PC3 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 296 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 297 | { "uart0", 4 }, /* PF2-PF4 */ |
| 298 | #else |
| 299 | { "uart0", 2 }, /* PB19-PB20 */ |
| 300 | #endif |
| 301 | { "uart1", 4 }, /* PG3-PG4 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 302 | }; |
| 303 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 304 | static const struct sunxi_pinctrl_desc __maybe_unused sun5i_a13_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 305 | .functions = sun5i_a13_pinctrl_functions, |
| 306 | .num_functions = ARRAY_SIZE(sun5i_a13_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 307 | .first_bank = SUNXI_GPIO_A, |
| 308 | .num_banks = 7, |
| 309 | }; |
| 310 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 311 | static const struct sunxi_pinctrl_function sun6i_a31_pinctrl_functions[] = { |
Samuel Holland | 8181f56 | 2021-08-28 13:13:52 -0500 | [diff] [blame] | 312 | { "gmac", 2 }, /* PA0-PA27 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 313 | { "gpio_in", 0 }, |
| 314 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 315 | { "i2c0", 2 }, /* PH14-PH15 */ |
| 316 | { "i2c1", 2 }, /* PH16-PH17 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 317 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 318 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 319 | { "mmc2", 3 }, /* PC6-PC15, PC24 */ |
| 320 | { "mmc3", 4 }, /* PC6-PC15, PC24 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 321 | { "spi0", 3 }, /* PC0-PC2, PC27 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 322 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 323 | { "uart0", 3 }, /* PF2-PF4 */ |
| 324 | #else |
| 325 | { "uart0", 2 }, /* PH20-PH21 */ |
| 326 | #endif |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 327 | }; |
| 328 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 329 | static const struct sunxi_pinctrl_desc __maybe_unused sun6i_a31_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 330 | .functions = sun6i_a31_pinctrl_functions, |
| 331 | .num_functions = ARRAY_SIZE(sun6i_a31_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 332 | .first_bank = SUNXI_GPIO_A, |
| 333 | .num_banks = 8, |
| 334 | }; |
| 335 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 336 | static const struct sunxi_pinctrl_function sun6i_a31_r_pinctrl_functions[] = { |
| 337 | { "gpio_in", 0 }, |
| 338 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 339 | { "s_i2c", 2 }, /* PL0-PL1 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 340 | { "s_uart", 2 }, /* PL2-PL3 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 341 | }; |
| 342 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 343 | 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] | 344 | .functions = sun6i_a31_r_pinctrl_functions, |
| 345 | .num_functions = ARRAY_SIZE(sun6i_a31_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 346 | .first_bank = SUNXI_GPIO_L, |
| 347 | .num_banks = 2, |
| 348 | }; |
| 349 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 350 | static const struct sunxi_pinctrl_function sun7i_a20_pinctrl_functions[] = { |
Samuel Holland | 5d57e05 | 2021-08-28 13:21:36 -0500 | [diff] [blame] | 351 | { "emac", 2 }, /* PA0-PA17 */ |
Samuel Holland | 8181f56 | 2021-08-28 13:13:52 -0500 | [diff] [blame] | 352 | { "gmac", 5 }, /* PA0-PA17 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 353 | { "gpio_in", 0 }, |
| 354 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 355 | { "i2c0", 2 }, /* PB0-PB1 */ |
| 356 | { "i2c1", 2 }, /* PB18-PB19 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 357 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 358 | #if IS_ENABLED(CONFIG_MMC1_PINS_PH) |
| 359 | { "mmc1", 5 }, /* PH22-PH27 */ |
| 360 | #else |
| 361 | { "mmc1", 4 }, /* PG0-PG5 */ |
| 362 | #endif |
| 363 | { "mmc2", 3 }, /* PC5-PC15, PC24 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 364 | { "spi0", 3 }, /* PC0-PC2, PC23 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 365 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 366 | { "uart0", 4 }, /* PF2-PF4 */ |
| 367 | #else |
| 368 | { "uart0", 2 }, /* PB22-PB23 */ |
| 369 | #endif |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 370 | }; |
| 371 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 372 | static const struct sunxi_pinctrl_desc __maybe_unused sun7i_a20_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 373 | .functions = sun7i_a20_pinctrl_functions, |
| 374 | .num_functions = ARRAY_SIZE(sun7i_a20_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 375 | .first_bank = SUNXI_GPIO_A, |
| 376 | .num_banks = 9, |
| 377 | }; |
| 378 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 379 | static const struct sunxi_pinctrl_function sun8i_a23_pinctrl_functions[] = { |
| 380 | { "gpio_in", 0 }, |
| 381 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 382 | { "i2c0", 2 }, /* PH2-PH3 */ |
| 383 | { "i2c1", 2 }, /* PH4-PH5 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 384 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 385 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 386 | { "mmc2", 3 }, /* PC5-PC16 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 387 | { "spi0", 3 }, /* PC0-PC3 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 388 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 389 | { "uart0", 3 }, /* PF2-PF4 */ |
| 390 | #endif |
| 391 | { "uart1", 2 }, /* PG6-PG7 */ |
| 392 | { "uart2", 2 }, /* PB0-PB1 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 393 | }; |
| 394 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 395 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a23_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 396 | .functions = sun8i_a23_pinctrl_functions, |
| 397 | .num_functions = ARRAY_SIZE(sun8i_a23_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 398 | .first_bank = SUNXI_GPIO_A, |
| 399 | .num_banks = 8, |
| 400 | }; |
| 401 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 402 | static const struct sunxi_pinctrl_function sun8i_a23_r_pinctrl_functions[] = { |
| 403 | { "gpio_in", 0 }, |
| 404 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 405 | { "s_i2c", 3 }, /* PL0-PL1 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 406 | { "s_uart", 2 }, /* PL2-PL3 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 407 | }; |
| 408 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 409 | 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] | 410 | .functions = sun8i_a23_r_pinctrl_functions, |
| 411 | .num_functions = ARRAY_SIZE(sun8i_a23_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 412 | .first_bank = SUNXI_GPIO_L, |
| 413 | .num_banks = 1, |
| 414 | }; |
| 415 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 416 | static const struct sunxi_pinctrl_function sun8i_a33_pinctrl_functions[] = { |
| 417 | { "gpio_in", 0 }, |
| 418 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 419 | { "i2c0", 2 }, /* PH2-PH3 */ |
| 420 | { "i2c1", 2 }, /* PH4-PH5 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 421 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 422 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 423 | { "mmc2", 3 }, /* PC5-PC16 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 424 | { "spi0", 3 }, /* PC0-PC3 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 425 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 426 | { "uart0", 3 }, /* PF2-PF4 */ |
| 427 | #else |
| 428 | { "uart0", 3 }, /* PB0-PB1 */ |
| 429 | #endif |
| 430 | { "uart1", 2 }, /* PG6-PG7 */ |
| 431 | { "uart2", 2 }, /* PB0-PB1 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 432 | }; |
| 433 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 434 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a33_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 435 | .functions = sun8i_a33_pinctrl_functions, |
| 436 | .num_functions = ARRAY_SIZE(sun8i_a33_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 437 | .first_bank = SUNXI_GPIO_A, |
| 438 | .num_banks = 8, |
| 439 | }; |
| 440 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 441 | static const struct sunxi_pinctrl_function sun8i_a83t_pinctrl_functions[] = { |
Samuel Holland | a8cbf47 | 2021-08-28 13:34:29 -0500 | [diff] [blame] | 442 | { "gmac", 4 }, /* PD2-PD23 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 443 | { "gpio_in", 0 }, |
| 444 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 445 | { "i2c0", 2 }, /* PH0-PH1 */ |
| 446 | { "i2c1", 2 }, /* PH2-PH3 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 447 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 448 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 449 | { "mmc2", 3 }, /* PC5-PC16 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 450 | { "spi0", 3 }, /* PC0-PC3 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 451 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 452 | { "uart0", 3 }, /* PF2-PF4 */ |
| 453 | #else |
| 454 | { "uart0", 2 }, /* PB9-PB10 */ |
| 455 | #endif |
| 456 | { "uart1", 2 }, /* PG6-PG7 */ |
| 457 | { "uart2", 2 }, /* PB0-PB1 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 458 | }; |
| 459 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 460 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a83t_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 461 | .functions = sun8i_a83t_pinctrl_functions, |
| 462 | .num_functions = ARRAY_SIZE(sun8i_a83t_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 463 | .first_bank = SUNXI_GPIO_A, |
| 464 | .num_banks = 8, |
| 465 | }; |
| 466 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 467 | static const struct sunxi_pinctrl_function sun8i_a83t_r_pinctrl_functions[] = { |
| 468 | { "gpio_in", 0 }, |
| 469 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 470 | { "s_i2c", 2 }, /* PL8-PL9 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 471 | { "s_uart", 2 }, /* PL2-PL3 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 472 | }; |
| 473 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 474 | 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] | 475 | .functions = sun8i_a83t_r_pinctrl_functions, |
| 476 | .num_functions = ARRAY_SIZE(sun8i_a83t_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 477 | .first_bank = SUNXI_GPIO_L, |
| 478 | .num_banks = 1, |
| 479 | }; |
| 480 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 481 | static const struct sunxi_pinctrl_function sun8i_h3_pinctrl_functions[] = { |
Samuel Holland | a8cbf47 | 2021-08-28 13:34:29 -0500 | [diff] [blame] | 482 | { "emac", 2 }, /* PD0-PD17 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 483 | { "gpio_in", 0 }, |
| 484 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 485 | { "i2c0", 2 }, /* PA11-PA12 */ |
| 486 | { "i2c1", 3 }, /* PA18-PA19 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 487 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 488 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 489 | { "mmc2", 3 }, /* PC5-PC16 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 490 | { "spi0", 3 }, /* PC0-PC3 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 491 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 492 | { "uart0", 3 }, /* PF2-PF4 */ |
| 493 | #else |
| 494 | { "uart0", 2 }, /* PA4-PA5 */ |
| 495 | #endif |
| 496 | { "uart1", 2 }, /* PG6-PG7 */ |
| 497 | { "uart2", 2 }, /* PA0-PA1 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 498 | }; |
| 499 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 500 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_h3_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 501 | .functions = sun8i_h3_pinctrl_functions, |
| 502 | .num_functions = ARRAY_SIZE(sun8i_h3_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 503 | .first_bank = SUNXI_GPIO_A, |
| 504 | .num_banks = 7, |
| 505 | }; |
| 506 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 507 | static const struct sunxi_pinctrl_function sun8i_h3_r_pinctrl_functions[] = { |
| 508 | { "gpio_in", 0 }, |
| 509 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 510 | { "s_i2c", 2 }, /* PL0-PL1 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 511 | { "s_uart", 2 }, /* PL2-PL3 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 512 | }; |
| 513 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 514 | 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] | 515 | .functions = sun8i_h3_r_pinctrl_functions, |
| 516 | .num_functions = ARRAY_SIZE(sun8i_h3_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 517 | .first_bank = SUNXI_GPIO_L, |
| 518 | .num_banks = 1, |
| 519 | }; |
| 520 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 521 | static const struct sunxi_pinctrl_function sun8i_v3s_pinctrl_functions[] = { |
Samuel Holland | a8cbf47 | 2021-08-28 13:34:29 -0500 | [diff] [blame] | 522 | { "emac", 4 }, /* PD0-PD17 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 523 | { "gpio_in", 0 }, |
| 524 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 525 | { "i2c0", 2 }, /* PB6-PB7 */ |
| 526 | { "i2c1", 2 }, /* PB8-PB9 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 527 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 528 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 529 | { "mmc2", 2 }, /* PC0-PC10 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 530 | { "spi0", 3 }, /* PC0-PC3 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 531 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 532 | { "uart0", 3 }, /* PF2-PF4 */ |
| 533 | #else |
| 534 | { "uart0", 3 }, /* PB8-PB9 */ |
| 535 | #endif |
| 536 | { "uart1", 2 }, /* PG6-PG7 */ |
| 537 | { "uart2", 2 }, /* PB0-PB1 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 538 | }; |
| 539 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 540 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_v3s_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 541 | .functions = sun8i_v3s_pinctrl_functions, |
| 542 | .num_functions = ARRAY_SIZE(sun8i_v3s_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 543 | .first_bank = SUNXI_GPIO_A, |
| 544 | .num_banks = 7, |
| 545 | }; |
| 546 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 547 | static const struct sunxi_pinctrl_function sun9i_a80_pinctrl_functions[] = { |
Samuel Holland | 8181f56 | 2021-08-28 13:13:52 -0500 | [diff] [blame] | 548 | { "gmac", 2 }, /* PA0-PA17 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 549 | { "gpio_in", 0 }, |
| 550 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 551 | { "i2c0", 2 }, /* PH0-PH1 */ |
| 552 | { "i2c1", 2 }, /* PH2-PH3 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 553 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 554 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 555 | { "mmc2", 3 }, /* PC6-PC16 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 556 | { "spi0", 3 }, /* PC0-PC2, PC19 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 557 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 558 | { "uart0", 4 }, /* PF2-PF4 */ |
| 559 | #else |
| 560 | { "uart0", 2 }, /* PH12-PH13 */ |
| 561 | #endif |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 562 | }; |
| 563 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 564 | static const struct sunxi_pinctrl_desc __maybe_unused sun9i_a80_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 565 | .functions = sun9i_a80_pinctrl_functions, |
| 566 | .num_functions = ARRAY_SIZE(sun9i_a80_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 567 | .first_bank = SUNXI_GPIO_A, |
| 568 | .num_banks = 8, |
| 569 | }; |
| 570 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 571 | static const struct sunxi_pinctrl_function sun9i_a80_r_pinctrl_functions[] = { |
| 572 | { "gpio_in", 0 }, |
| 573 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 574 | { "s_i2c0", 2 }, /* PN0-PN1 */ |
| 575 | { "s_i2c1", 3 }, /* PM8-PM9 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 576 | { "s_uart", 3 }, /* PL0-PL1 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 577 | }; |
| 578 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 579 | 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] | 580 | .functions = sun9i_a80_r_pinctrl_functions, |
| 581 | .num_functions = ARRAY_SIZE(sun9i_a80_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 582 | .first_bank = SUNXI_GPIO_L, |
| 583 | .num_banks = 3, |
| 584 | }; |
| 585 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 586 | static const struct sunxi_pinctrl_function sun50i_a64_pinctrl_functions[] = { |
Samuel Holland | a8cbf47 | 2021-08-28 13:34:29 -0500 | [diff] [blame] | 587 | { "emac", 4 }, /* PD8-PD23 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 588 | { "gpio_in", 0 }, |
| 589 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 590 | { "i2c0", 2 }, /* PH0-PH1 */ |
| 591 | { "i2c1", 2 }, /* PH2-PH3 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 592 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 593 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 594 | { "mmc2", 3 }, /* PC1-PC16 */ |
Samuel Holland | 3de641b | 2021-08-28 15:52:52 -0500 | [diff] [blame] | 595 | { "pwm", 2 }, /* PD22 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 596 | { "spi0", 4 }, /* PC0-PC3 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 597 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 598 | { "uart0", 3 }, /* PF2-PF4 */ |
| 599 | #else |
| 600 | { "uart0", 4 }, /* PB8-PB9 */ |
| 601 | #endif |
| 602 | { "uart1", 2 }, /* PG6-PG7 */ |
| 603 | { "uart2", 2 }, /* PB0-PB1 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 604 | }; |
| 605 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 606 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_a64_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 607 | .functions = sun50i_a64_pinctrl_functions, |
| 608 | .num_functions = ARRAY_SIZE(sun50i_a64_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 609 | .first_bank = SUNXI_GPIO_A, |
| 610 | .num_banks = 8, |
| 611 | }; |
| 612 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 613 | static const struct sunxi_pinctrl_function sun50i_a64_r_pinctrl_functions[] = { |
| 614 | { "gpio_in", 0 }, |
| 615 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 616 | { "s_i2c", 2 }, /* PL8-PL9 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 617 | { "s_uart", 2 }, /* PL2-PL3 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 618 | }; |
| 619 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 620 | 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] | 621 | .functions = sun50i_a64_r_pinctrl_functions, |
| 622 | .num_functions = ARRAY_SIZE(sun50i_a64_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 623 | .first_bank = SUNXI_GPIO_L, |
| 624 | .num_banks = 1, |
| 625 | }; |
| 626 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 627 | static const struct sunxi_pinctrl_function sun50i_h5_pinctrl_functions[] = { |
Samuel Holland | a8cbf47 | 2021-08-28 13:34:29 -0500 | [diff] [blame] | 628 | { "emac", 2 }, /* PD0-PD17 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 629 | { "gpio_in", 0 }, |
| 630 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 631 | { "i2c0", 2 }, /* PA11-PA12 */ |
| 632 | { "i2c1", 3 }, /* PA18-PA19 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 633 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 634 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 635 | { "mmc2", 3 }, /* PC1-PC16 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 636 | { "spi0", 3 }, /* PC0-PC3 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 637 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 638 | { "uart0", 3 }, /* PF2-PF4 */ |
| 639 | #else |
| 640 | { "uart0", 2 }, /* PA4-PA5 */ |
| 641 | #endif |
| 642 | { "uart1", 2 }, /* PG6-PG7 */ |
| 643 | { "uart2", 2 }, /* PA0-PA1 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 644 | }; |
| 645 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 646 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h5_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 647 | .functions = sun50i_h5_pinctrl_functions, |
| 648 | .num_functions = ARRAY_SIZE(sun50i_h5_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 649 | .first_bank = SUNXI_GPIO_A, |
| 650 | .num_banks = 7, |
| 651 | }; |
| 652 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 653 | static const struct sunxi_pinctrl_function sun50i_h6_pinctrl_functions[] = { |
Samuel Holland | a8cbf47 | 2021-08-28 13:34:29 -0500 | [diff] [blame] | 654 | { "emac", 5 }, /* PD0-PD20 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 655 | { "gpio_in", 0 }, |
| 656 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 657 | { "i2c0", 2 }, /* PD25-PD26 */ |
| 658 | { "i2c1", 4 }, /* PH5-PH6 */ |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 659 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 660 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 661 | { "mmc2", 3 }, /* PC1-PC14 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 662 | { "spi0", 4 }, /* PC0-PC7 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 663 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 664 | { "uart0", 3 }, /* PF2-PF4 */ |
| 665 | #else |
| 666 | { "uart0", 2 }, /* PH0-PH1 */ |
| 667 | #endif |
| 668 | { "uart1", 2 }, /* PG6-PG7 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 669 | }; |
| 670 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 671 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h6_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 672 | .functions = sun50i_h6_pinctrl_functions, |
| 673 | .num_functions = ARRAY_SIZE(sun50i_h6_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 674 | .first_bank = SUNXI_GPIO_A, |
| 675 | .num_banks = 8, |
| 676 | }; |
| 677 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 678 | static const struct sunxi_pinctrl_function sun50i_h6_r_pinctrl_functions[] = { |
| 679 | { "gpio_in", 0 }, |
| 680 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 681 | { "s_i2c", 3 }, /* PL0-PL1 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 682 | { "s_uart", 2 }, /* PL2-PL3 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 683 | }; |
| 684 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 685 | 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] | 686 | .functions = sun50i_h6_r_pinctrl_functions, |
| 687 | .num_functions = ARRAY_SIZE(sun50i_h6_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 688 | .first_bank = SUNXI_GPIO_L, |
| 689 | .num_banks = 2, |
| 690 | }; |
| 691 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 692 | static const struct sunxi_pinctrl_function sun50i_h616_pinctrl_functions[] = { |
Samuel Holland | a8cbf47 | 2021-08-28 13:34:29 -0500 | [diff] [blame] | 693 | { "emac0", 2 }, /* PI0-PI16 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 694 | { "gpio_in", 0 }, |
| 695 | { "gpio_out", 1 }, |
Samuel Holland | 1c17f41 | 2021-08-28 16:51:03 -0500 | [diff] [blame] | 696 | { "mmc0", 2 }, /* PF0-PF5 */ |
| 697 | { "mmc1", 2 }, /* PG0-PG5 */ |
| 698 | { "mmc2", 3 }, /* PC0-PC16 */ |
Samuel Holland | 96b75d2 | 2021-08-28 17:05:35 -0500 | [diff] [blame] | 699 | { "spi0", 4 }, /* PC0-PC7, PC15-PC16 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 700 | #if IS_ENABLED(CONFIG_UART0_PORT_F) |
| 701 | { "uart0", 3 }, /* PF2-PF4 */ |
| 702 | #else |
| 703 | { "uart0", 2 }, /* PH0-PH1 */ |
| 704 | #endif |
| 705 | { "uart1", 2 }, /* PG6-PG7 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 706 | }; |
| 707 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 708 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h616_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 709 | .functions = sun50i_h616_pinctrl_functions, |
| 710 | .num_functions = ARRAY_SIZE(sun50i_h616_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 711 | .first_bank = SUNXI_GPIO_A, |
| 712 | .num_banks = 9, |
| 713 | }; |
| 714 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 715 | static const struct sunxi_pinctrl_function sun50i_h616_r_pinctrl_functions[] = { |
| 716 | { "gpio_in", 0 }, |
| 717 | { "gpio_out", 1 }, |
Samuel Holland | 4b10d25 | 2021-08-28 15:17:32 -0500 | [diff] [blame] | 718 | { "s_i2c", 3 }, /* PL0-PL1 */ |
Samuel Holland | 5a08d41 | 2021-08-28 13:00:45 -0500 | [diff] [blame] | 719 | { "s_uart", 2 }, /* PL2-PL3 */ |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 720 | }; |
| 721 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 722 | 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] | 723 | .functions = sun50i_h616_r_pinctrl_functions, |
| 724 | .num_functions = ARRAY_SIZE(sun50i_h616_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 725 | .first_bank = SUNXI_GPIO_L, |
| 726 | .num_banks = 1, |
| 727 | }; |
| 728 | |
| 729 | static const struct udevice_id sunxi_pinctrl_ids[] = { |
| 730 | #ifdef CONFIG_PINCTRL_SUNIV_F1C100S |
| 731 | { |
| 732 | .compatible = "allwinner,suniv-f1c100s-pinctrl", |
| 733 | .data = (ulong)&suniv_f1c100s_pinctrl_desc, |
| 734 | }, |
| 735 | #endif |
| 736 | #ifdef CONFIG_PINCTRL_SUN4I_A10 |
| 737 | { |
| 738 | .compatible = "allwinner,sun4i-a10-pinctrl", |
| 739 | .data = (ulong)&sun4i_a10_pinctrl_desc, |
| 740 | }, |
| 741 | #endif |
| 742 | #ifdef CONFIG_PINCTRL_SUN5I_A13 |
| 743 | { |
| 744 | .compatible = "allwinner,sun5i-a10s-pinctrl", |
| 745 | .data = (ulong)&sun5i_a13_pinctrl_desc, |
| 746 | }, |
| 747 | { |
| 748 | .compatible = "allwinner,sun5i-a13-pinctrl", |
| 749 | .data = (ulong)&sun5i_a13_pinctrl_desc, |
| 750 | }, |
| 751 | #endif |
| 752 | #ifdef CONFIG_PINCTRL_SUN6I_A31 |
| 753 | { |
| 754 | .compatible = "allwinner,sun6i-a31-pinctrl", |
| 755 | .data = (ulong)&sun6i_a31_pinctrl_desc, |
| 756 | }, |
| 757 | { |
| 758 | .compatible = "allwinner,sun6i-a31s-pinctrl", |
| 759 | .data = (ulong)&sun6i_a31_pinctrl_desc, |
| 760 | }, |
| 761 | #endif |
| 762 | #ifdef CONFIG_PINCTRL_SUN6I_A31_R |
| 763 | { |
| 764 | .compatible = "allwinner,sun6i-a31-r-pinctrl", |
| 765 | .data = (ulong)&sun6i_a31_r_pinctrl_desc, |
| 766 | }, |
| 767 | #endif |
| 768 | #ifdef CONFIG_PINCTRL_SUN7I_A20 |
| 769 | { |
| 770 | .compatible = "allwinner,sun7i-a20-pinctrl", |
| 771 | .data = (ulong)&sun7i_a20_pinctrl_desc, |
| 772 | }, |
| 773 | #endif |
| 774 | #ifdef CONFIG_PINCTRL_SUN8I_A23 |
| 775 | { |
| 776 | .compatible = "allwinner,sun8i-a23-pinctrl", |
| 777 | .data = (ulong)&sun8i_a23_pinctrl_desc, |
| 778 | }, |
| 779 | #endif |
| 780 | #ifdef CONFIG_PINCTRL_SUN8I_A23_R |
| 781 | { |
| 782 | .compatible = "allwinner,sun8i-a23-r-pinctrl", |
| 783 | .data = (ulong)&sun8i_a23_r_pinctrl_desc, |
| 784 | }, |
| 785 | #endif |
| 786 | #ifdef CONFIG_PINCTRL_SUN8I_A33 |
| 787 | { |
| 788 | .compatible = "allwinner,sun8i-a33-pinctrl", |
| 789 | .data = (ulong)&sun8i_a33_pinctrl_desc, |
| 790 | }, |
| 791 | #endif |
| 792 | #ifdef CONFIG_PINCTRL_SUN8I_A83T |
| 793 | { |
| 794 | .compatible = "allwinner,sun8i-a83t-pinctrl", |
| 795 | .data = (ulong)&sun8i_a83t_pinctrl_desc, |
| 796 | }, |
| 797 | #endif |
| 798 | #ifdef CONFIG_PINCTRL_SUN8I_A83T_R |
| 799 | { |
| 800 | .compatible = "allwinner,sun8i-a83t-r-pinctrl", |
| 801 | .data = (ulong)&sun8i_a83t_r_pinctrl_desc, |
| 802 | }, |
| 803 | #endif |
| 804 | #ifdef CONFIG_PINCTRL_SUN8I_H3 |
| 805 | { |
| 806 | .compatible = "allwinner,sun8i-h3-pinctrl", |
| 807 | .data = (ulong)&sun8i_h3_pinctrl_desc, |
| 808 | }, |
| 809 | #endif |
| 810 | #ifdef CONFIG_PINCTRL_SUN8I_H3_R |
| 811 | { |
| 812 | .compatible = "allwinner,sun8i-h3-r-pinctrl", |
| 813 | .data = (ulong)&sun8i_h3_r_pinctrl_desc, |
| 814 | }, |
| 815 | #endif |
| 816 | #ifdef CONFIG_PINCTRL_SUN7I_A20 |
| 817 | { |
| 818 | .compatible = "allwinner,sun8i-r40-pinctrl", |
| 819 | .data = (ulong)&sun7i_a20_pinctrl_desc, |
| 820 | }, |
| 821 | #endif |
| 822 | #ifdef CONFIG_PINCTRL_SUN8I_V3S |
| 823 | { |
| 824 | .compatible = "allwinner,sun8i-v3-pinctrl", |
| 825 | .data = (ulong)&sun8i_v3s_pinctrl_desc, |
| 826 | }, |
| 827 | { |
| 828 | .compatible = "allwinner,sun8i-v3s-pinctrl", |
| 829 | .data = (ulong)&sun8i_v3s_pinctrl_desc, |
| 830 | }, |
| 831 | #endif |
| 832 | #ifdef CONFIG_PINCTRL_SUN9I_A80 |
| 833 | { |
| 834 | .compatible = "allwinner,sun9i-a80-pinctrl", |
| 835 | .data = (ulong)&sun9i_a80_pinctrl_desc, |
| 836 | }, |
| 837 | #endif |
| 838 | #ifdef CONFIG_PINCTRL_SUN9I_A80_R |
| 839 | { |
| 840 | .compatible = "allwinner,sun9i-a80-r-pinctrl", |
| 841 | .data = (ulong)&sun9i_a80_r_pinctrl_desc, |
| 842 | }, |
| 843 | #endif |
| 844 | #ifdef CONFIG_PINCTRL_SUN50I_A64 |
| 845 | { |
| 846 | .compatible = "allwinner,sun50i-a64-pinctrl", |
| 847 | .data = (ulong)&sun50i_a64_pinctrl_desc, |
| 848 | }, |
| 849 | #endif |
| 850 | #ifdef CONFIG_PINCTRL_SUN50I_A64_R |
| 851 | { |
| 852 | .compatible = "allwinner,sun50i-a64-r-pinctrl", |
| 853 | .data = (ulong)&sun50i_a64_r_pinctrl_desc, |
| 854 | }, |
| 855 | #endif |
| 856 | #ifdef CONFIG_PINCTRL_SUN50I_H5 |
| 857 | { |
| 858 | .compatible = "allwinner,sun50i-h5-pinctrl", |
| 859 | .data = (ulong)&sun50i_h5_pinctrl_desc, |
| 860 | }, |
| 861 | #endif |
| 862 | #ifdef CONFIG_PINCTRL_SUN50I_H6 |
| 863 | { |
| 864 | .compatible = "allwinner,sun50i-h6-pinctrl", |
| 865 | .data = (ulong)&sun50i_h6_pinctrl_desc, |
| 866 | }, |
| 867 | #endif |
| 868 | #ifdef CONFIG_PINCTRL_SUN50I_H6_R |
| 869 | { |
| 870 | .compatible = "allwinner,sun50i-h6-r-pinctrl", |
| 871 | .data = (ulong)&sun50i_h6_r_pinctrl_desc, |
| 872 | }, |
| 873 | #endif |
| 874 | #ifdef CONFIG_PINCTRL_SUN50I_H616 |
| 875 | { |
| 876 | .compatible = "allwinner,sun50i-h616-pinctrl", |
| 877 | .data = (ulong)&sun50i_h616_pinctrl_desc, |
| 878 | }, |
| 879 | #endif |
| 880 | #ifdef CONFIG_PINCTRL_SUN50I_H616_R |
| 881 | { |
| 882 | .compatible = "allwinner,sun50i-h616-r-pinctrl", |
| 883 | .data = (ulong)&sun50i_h616_r_pinctrl_desc, |
| 884 | }, |
| 885 | #endif |
| 886 | {} |
| 887 | }; |
| 888 | |
| 889 | U_BOOT_DRIVER(sunxi_pinctrl) = { |
| 890 | .name = "sunxi-pinctrl", |
| 891 | .id = UCLASS_PINCTRL, |
| 892 | .of_match = sunxi_pinctrl_ids, |
| 893 | .bind = sunxi_pinctrl_bind, |
| 894 | .probe = sunxi_pinctrl_probe, |
| 895 | .plat_auto = sizeof(struct sunxi_pinctrl_plat), |
| 896 | .ops = &sunxi_pinctrl_ops, |
| 897 | }; |