Samuel Holland | b799eab | 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 | 29babfd | 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 | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 30 | struct sunxi_pinctrl_desc { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 31 | const struct sunxi_pinctrl_function *functions; |
| 32 | u8 num_functions; |
Samuel Holland | b799eab | 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 | 29babfd | 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 | 50c195e | 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 | d4b3882 | 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 | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 171 | static const struct pinctrl_ops sunxi_pinctrl_ops = { |
Samuel Holland | 29babfd | 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 | 50c195e | 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 | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 180 | .set_state = pinctrl_generic_set_state, |
Samuel Holland | d4b3882 | 2021-08-17 00:52:00 -0500 | [diff] [blame] | 181 | .get_pin_muxing = sunxi_pinctrl_get_pin_muxing, |
Samuel Holland | b799eab | 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 | 29babfd | 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 }, |
| 238 | }; |
| 239 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 240 | static const struct sunxi_pinctrl_desc __maybe_unused suniv_f1c100s_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 241 | .functions = suniv_f1c100s_pinctrl_functions, |
| 242 | .num_functions = ARRAY_SIZE(suniv_f1c100s_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 243 | .first_bank = SUNXI_GPIO_A, |
| 244 | .num_banks = 6, |
| 245 | }; |
| 246 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 247 | static const struct sunxi_pinctrl_function sun4i_a10_pinctrl_functions[] = { |
| 248 | { "gpio_in", 0 }, |
| 249 | { "gpio_out", 1 }, |
| 250 | }; |
| 251 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 252 | static const struct sunxi_pinctrl_desc __maybe_unused sun4i_a10_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 253 | .functions = sun4i_a10_pinctrl_functions, |
| 254 | .num_functions = ARRAY_SIZE(sun4i_a10_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 255 | .first_bank = SUNXI_GPIO_A, |
| 256 | .num_banks = 9, |
| 257 | }; |
| 258 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 259 | static const struct sunxi_pinctrl_function sun5i_a13_pinctrl_functions[] = { |
| 260 | { "gpio_in", 0 }, |
| 261 | { "gpio_out", 1 }, |
| 262 | }; |
| 263 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 264 | static const struct sunxi_pinctrl_desc __maybe_unused sun5i_a13_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 265 | .functions = sun5i_a13_pinctrl_functions, |
| 266 | .num_functions = ARRAY_SIZE(sun5i_a13_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 267 | .first_bank = SUNXI_GPIO_A, |
| 268 | .num_banks = 7, |
| 269 | }; |
| 270 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 271 | static const struct sunxi_pinctrl_function sun6i_a31_pinctrl_functions[] = { |
| 272 | { "gpio_in", 0 }, |
| 273 | { "gpio_out", 1 }, |
| 274 | }; |
| 275 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 276 | static const struct sunxi_pinctrl_desc __maybe_unused sun6i_a31_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 277 | .functions = sun6i_a31_pinctrl_functions, |
| 278 | .num_functions = ARRAY_SIZE(sun6i_a31_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 279 | .first_bank = SUNXI_GPIO_A, |
| 280 | .num_banks = 8, |
| 281 | }; |
| 282 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 283 | static const struct sunxi_pinctrl_function sun6i_a31_r_pinctrl_functions[] = { |
| 284 | { "gpio_in", 0 }, |
| 285 | { "gpio_out", 1 }, |
| 286 | }; |
| 287 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 288 | static const struct sunxi_pinctrl_desc __maybe_unused sun6i_a31_r_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 289 | .functions = sun6i_a31_r_pinctrl_functions, |
| 290 | .num_functions = ARRAY_SIZE(sun6i_a31_r_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 291 | .first_bank = SUNXI_GPIO_L, |
| 292 | .num_banks = 2, |
| 293 | }; |
| 294 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 295 | static const struct sunxi_pinctrl_function sun7i_a20_pinctrl_functions[] = { |
| 296 | { "gpio_in", 0 }, |
| 297 | { "gpio_out", 1 }, |
| 298 | }; |
| 299 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 300 | static const struct sunxi_pinctrl_desc __maybe_unused sun7i_a20_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 301 | .functions = sun7i_a20_pinctrl_functions, |
| 302 | .num_functions = ARRAY_SIZE(sun7i_a20_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 303 | .first_bank = SUNXI_GPIO_A, |
| 304 | .num_banks = 9, |
| 305 | }; |
| 306 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 307 | static const struct sunxi_pinctrl_function sun8i_a23_pinctrl_functions[] = { |
| 308 | { "gpio_in", 0 }, |
| 309 | { "gpio_out", 1 }, |
| 310 | }; |
| 311 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 312 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a23_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 313 | .functions = sun8i_a23_pinctrl_functions, |
| 314 | .num_functions = ARRAY_SIZE(sun8i_a23_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 315 | .first_bank = SUNXI_GPIO_A, |
| 316 | .num_banks = 8, |
| 317 | }; |
| 318 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 319 | static const struct sunxi_pinctrl_function sun8i_a23_r_pinctrl_functions[] = { |
| 320 | { "gpio_in", 0 }, |
| 321 | { "gpio_out", 1 }, |
| 322 | }; |
| 323 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 324 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a23_r_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 325 | .functions = sun8i_a23_r_pinctrl_functions, |
| 326 | .num_functions = ARRAY_SIZE(sun8i_a23_r_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 327 | .first_bank = SUNXI_GPIO_L, |
| 328 | .num_banks = 1, |
| 329 | }; |
| 330 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 331 | static const struct sunxi_pinctrl_function sun8i_a33_pinctrl_functions[] = { |
| 332 | { "gpio_in", 0 }, |
| 333 | { "gpio_out", 1 }, |
| 334 | }; |
| 335 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 336 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a33_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 337 | .functions = sun8i_a33_pinctrl_functions, |
| 338 | .num_functions = ARRAY_SIZE(sun8i_a33_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 339 | .first_bank = SUNXI_GPIO_A, |
| 340 | .num_banks = 8, |
| 341 | }; |
| 342 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 343 | static const struct sunxi_pinctrl_function sun8i_a83t_pinctrl_functions[] = { |
| 344 | { "gpio_in", 0 }, |
| 345 | { "gpio_out", 1 }, |
| 346 | }; |
| 347 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 348 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a83t_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 349 | .functions = sun8i_a83t_pinctrl_functions, |
| 350 | .num_functions = ARRAY_SIZE(sun8i_a83t_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 351 | .first_bank = SUNXI_GPIO_A, |
| 352 | .num_banks = 8, |
| 353 | }; |
| 354 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 355 | static const struct sunxi_pinctrl_function sun8i_a83t_r_pinctrl_functions[] = { |
| 356 | { "gpio_in", 0 }, |
| 357 | { "gpio_out", 1 }, |
| 358 | }; |
| 359 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 360 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a83t_r_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 361 | .functions = sun8i_a83t_r_pinctrl_functions, |
| 362 | .num_functions = ARRAY_SIZE(sun8i_a83t_r_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 363 | .first_bank = SUNXI_GPIO_L, |
| 364 | .num_banks = 1, |
| 365 | }; |
| 366 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 367 | static const struct sunxi_pinctrl_function sun8i_h3_pinctrl_functions[] = { |
| 368 | { "gpio_in", 0 }, |
| 369 | { "gpio_out", 1 }, |
| 370 | }; |
| 371 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 372 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_h3_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 373 | .functions = sun8i_h3_pinctrl_functions, |
| 374 | .num_functions = ARRAY_SIZE(sun8i_h3_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 375 | .first_bank = SUNXI_GPIO_A, |
| 376 | .num_banks = 7, |
| 377 | }; |
| 378 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 379 | static const struct sunxi_pinctrl_function sun8i_h3_r_pinctrl_functions[] = { |
| 380 | { "gpio_in", 0 }, |
| 381 | { "gpio_out", 1 }, |
| 382 | }; |
| 383 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 384 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_h3_r_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 385 | .functions = sun8i_h3_r_pinctrl_functions, |
| 386 | .num_functions = ARRAY_SIZE(sun8i_h3_r_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 387 | .first_bank = SUNXI_GPIO_L, |
| 388 | .num_banks = 1, |
| 389 | }; |
| 390 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 391 | static const struct sunxi_pinctrl_function sun8i_v3s_pinctrl_functions[] = { |
| 392 | { "gpio_in", 0 }, |
| 393 | { "gpio_out", 1 }, |
| 394 | }; |
| 395 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 396 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_v3s_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 397 | .functions = sun8i_v3s_pinctrl_functions, |
| 398 | .num_functions = ARRAY_SIZE(sun8i_v3s_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 399 | .first_bank = SUNXI_GPIO_A, |
| 400 | .num_banks = 7, |
| 401 | }; |
| 402 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 403 | static const struct sunxi_pinctrl_function sun9i_a80_pinctrl_functions[] = { |
| 404 | { "gpio_in", 0 }, |
| 405 | { "gpio_out", 1 }, |
| 406 | }; |
| 407 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 408 | static const struct sunxi_pinctrl_desc __maybe_unused sun9i_a80_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 409 | .functions = sun9i_a80_pinctrl_functions, |
| 410 | .num_functions = ARRAY_SIZE(sun9i_a80_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 411 | .first_bank = SUNXI_GPIO_A, |
| 412 | .num_banks = 8, |
| 413 | }; |
| 414 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 415 | static const struct sunxi_pinctrl_function sun9i_a80_r_pinctrl_functions[] = { |
| 416 | { "gpio_in", 0 }, |
| 417 | { "gpio_out", 1 }, |
| 418 | }; |
| 419 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 420 | static const struct sunxi_pinctrl_desc __maybe_unused sun9i_a80_r_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 421 | .functions = sun9i_a80_r_pinctrl_functions, |
| 422 | .num_functions = ARRAY_SIZE(sun9i_a80_r_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 423 | .first_bank = SUNXI_GPIO_L, |
| 424 | .num_banks = 3, |
| 425 | }; |
| 426 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 427 | static const struct sunxi_pinctrl_function sun50i_a64_pinctrl_functions[] = { |
| 428 | { "gpio_in", 0 }, |
| 429 | { "gpio_out", 1 }, |
| 430 | }; |
| 431 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 432 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_a64_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 433 | .functions = sun50i_a64_pinctrl_functions, |
| 434 | .num_functions = ARRAY_SIZE(sun50i_a64_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 435 | .first_bank = SUNXI_GPIO_A, |
| 436 | .num_banks = 8, |
| 437 | }; |
| 438 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 439 | static const struct sunxi_pinctrl_function sun50i_a64_r_pinctrl_functions[] = { |
| 440 | { "gpio_in", 0 }, |
| 441 | { "gpio_out", 1 }, |
| 442 | }; |
| 443 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 444 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_a64_r_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 445 | .functions = sun50i_a64_r_pinctrl_functions, |
| 446 | .num_functions = ARRAY_SIZE(sun50i_a64_r_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 447 | .first_bank = SUNXI_GPIO_L, |
| 448 | .num_banks = 1, |
| 449 | }; |
| 450 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 451 | static const struct sunxi_pinctrl_function sun50i_h5_pinctrl_functions[] = { |
| 452 | { "gpio_in", 0 }, |
| 453 | { "gpio_out", 1 }, |
| 454 | }; |
| 455 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 456 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h5_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 457 | .functions = sun50i_h5_pinctrl_functions, |
| 458 | .num_functions = ARRAY_SIZE(sun50i_h5_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 459 | .first_bank = SUNXI_GPIO_A, |
| 460 | .num_banks = 7, |
| 461 | }; |
| 462 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 463 | static const struct sunxi_pinctrl_function sun50i_h6_pinctrl_functions[] = { |
| 464 | { "gpio_in", 0 }, |
| 465 | { "gpio_out", 1 }, |
| 466 | }; |
| 467 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 468 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h6_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 469 | .functions = sun50i_h6_pinctrl_functions, |
| 470 | .num_functions = ARRAY_SIZE(sun50i_h6_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 471 | .first_bank = SUNXI_GPIO_A, |
| 472 | .num_banks = 8, |
| 473 | }; |
| 474 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 475 | static const struct sunxi_pinctrl_function sun50i_h6_r_pinctrl_functions[] = { |
| 476 | { "gpio_in", 0 }, |
| 477 | { "gpio_out", 1 }, |
| 478 | }; |
| 479 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 480 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h6_r_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 481 | .functions = sun50i_h6_r_pinctrl_functions, |
| 482 | .num_functions = ARRAY_SIZE(sun50i_h6_r_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 483 | .first_bank = SUNXI_GPIO_L, |
| 484 | .num_banks = 2, |
| 485 | }; |
| 486 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 487 | static const struct sunxi_pinctrl_function sun50i_h616_pinctrl_functions[] = { |
| 488 | { "gpio_in", 0 }, |
| 489 | { "gpio_out", 1 }, |
| 490 | }; |
| 491 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 492 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h616_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 493 | .functions = sun50i_h616_pinctrl_functions, |
| 494 | .num_functions = ARRAY_SIZE(sun50i_h616_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 495 | .first_bank = SUNXI_GPIO_A, |
| 496 | .num_banks = 9, |
| 497 | }; |
| 498 | |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 499 | static const struct sunxi_pinctrl_function sun50i_h616_r_pinctrl_functions[] = { |
| 500 | { "gpio_in", 0 }, |
| 501 | { "gpio_out", 1 }, |
| 502 | }; |
| 503 | |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 504 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h616_r_pinctrl_desc = { |
Samuel Holland | 29babfd | 2021-08-16 23:56:47 -0500 | [diff] [blame] | 505 | .functions = sun50i_h616_r_pinctrl_functions, |
| 506 | .num_functions = ARRAY_SIZE(sun50i_h616_r_pinctrl_functions), |
Samuel Holland | b799eab | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 507 | .first_bank = SUNXI_GPIO_L, |
| 508 | .num_banks = 1, |
| 509 | }; |
| 510 | |
| 511 | static const struct udevice_id sunxi_pinctrl_ids[] = { |
| 512 | #ifdef CONFIG_PINCTRL_SUNIV_F1C100S |
| 513 | { |
| 514 | .compatible = "allwinner,suniv-f1c100s-pinctrl", |
| 515 | .data = (ulong)&suniv_f1c100s_pinctrl_desc, |
| 516 | }, |
| 517 | #endif |
| 518 | #ifdef CONFIG_PINCTRL_SUN4I_A10 |
| 519 | { |
| 520 | .compatible = "allwinner,sun4i-a10-pinctrl", |
| 521 | .data = (ulong)&sun4i_a10_pinctrl_desc, |
| 522 | }, |
| 523 | #endif |
| 524 | #ifdef CONFIG_PINCTRL_SUN5I_A13 |
| 525 | { |
| 526 | .compatible = "allwinner,sun5i-a10s-pinctrl", |
| 527 | .data = (ulong)&sun5i_a13_pinctrl_desc, |
| 528 | }, |
| 529 | { |
| 530 | .compatible = "allwinner,sun5i-a13-pinctrl", |
| 531 | .data = (ulong)&sun5i_a13_pinctrl_desc, |
| 532 | }, |
| 533 | #endif |
| 534 | #ifdef CONFIG_PINCTRL_SUN6I_A31 |
| 535 | { |
| 536 | .compatible = "allwinner,sun6i-a31-pinctrl", |
| 537 | .data = (ulong)&sun6i_a31_pinctrl_desc, |
| 538 | }, |
| 539 | { |
| 540 | .compatible = "allwinner,sun6i-a31s-pinctrl", |
| 541 | .data = (ulong)&sun6i_a31_pinctrl_desc, |
| 542 | }, |
| 543 | #endif |
| 544 | #ifdef CONFIG_PINCTRL_SUN6I_A31_R |
| 545 | { |
| 546 | .compatible = "allwinner,sun6i-a31-r-pinctrl", |
| 547 | .data = (ulong)&sun6i_a31_r_pinctrl_desc, |
| 548 | }, |
| 549 | #endif |
| 550 | #ifdef CONFIG_PINCTRL_SUN7I_A20 |
| 551 | { |
| 552 | .compatible = "allwinner,sun7i-a20-pinctrl", |
| 553 | .data = (ulong)&sun7i_a20_pinctrl_desc, |
| 554 | }, |
| 555 | #endif |
| 556 | #ifdef CONFIG_PINCTRL_SUN8I_A23 |
| 557 | { |
| 558 | .compatible = "allwinner,sun8i-a23-pinctrl", |
| 559 | .data = (ulong)&sun8i_a23_pinctrl_desc, |
| 560 | }, |
| 561 | #endif |
| 562 | #ifdef CONFIG_PINCTRL_SUN8I_A23_R |
| 563 | { |
| 564 | .compatible = "allwinner,sun8i-a23-r-pinctrl", |
| 565 | .data = (ulong)&sun8i_a23_r_pinctrl_desc, |
| 566 | }, |
| 567 | #endif |
| 568 | #ifdef CONFIG_PINCTRL_SUN8I_A33 |
| 569 | { |
| 570 | .compatible = "allwinner,sun8i-a33-pinctrl", |
| 571 | .data = (ulong)&sun8i_a33_pinctrl_desc, |
| 572 | }, |
| 573 | #endif |
| 574 | #ifdef CONFIG_PINCTRL_SUN8I_A83T |
| 575 | { |
| 576 | .compatible = "allwinner,sun8i-a83t-pinctrl", |
| 577 | .data = (ulong)&sun8i_a83t_pinctrl_desc, |
| 578 | }, |
| 579 | #endif |
| 580 | #ifdef CONFIG_PINCTRL_SUN8I_A83T_R |
| 581 | { |
| 582 | .compatible = "allwinner,sun8i-a83t-r-pinctrl", |
| 583 | .data = (ulong)&sun8i_a83t_r_pinctrl_desc, |
| 584 | }, |
| 585 | #endif |
| 586 | #ifdef CONFIG_PINCTRL_SUN8I_H3 |
| 587 | { |
| 588 | .compatible = "allwinner,sun8i-h3-pinctrl", |
| 589 | .data = (ulong)&sun8i_h3_pinctrl_desc, |
| 590 | }, |
| 591 | #endif |
| 592 | #ifdef CONFIG_PINCTRL_SUN8I_H3_R |
| 593 | { |
| 594 | .compatible = "allwinner,sun8i-h3-r-pinctrl", |
| 595 | .data = (ulong)&sun8i_h3_r_pinctrl_desc, |
| 596 | }, |
| 597 | #endif |
| 598 | #ifdef CONFIG_PINCTRL_SUN7I_A20 |
| 599 | { |
| 600 | .compatible = "allwinner,sun8i-r40-pinctrl", |
| 601 | .data = (ulong)&sun7i_a20_pinctrl_desc, |
| 602 | }, |
| 603 | #endif |
| 604 | #ifdef CONFIG_PINCTRL_SUN8I_V3S |
| 605 | { |
| 606 | .compatible = "allwinner,sun8i-v3-pinctrl", |
| 607 | .data = (ulong)&sun8i_v3s_pinctrl_desc, |
| 608 | }, |
| 609 | { |
| 610 | .compatible = "allwinner,sun8i-v3s-pinctrl", |
| 611 | .data = (ulong)&sun8i_v3s_pinctrl_desc, |
| 612 | }, |
| 613 | #endif |
| 614 | #ifdef CONFIG_PINCTRL_SUN9I_A80 |
| 615 | { |
| 616 | .compatible = "allwinner,sun9i-a80-pinctrl", |
| 617 | .data = (ulong)&sun9i_a80_pinctrl_desc, |
| 618 | }, |
| 619 | #endif |
| 620 | #ifdef CONFIG_PINCTRL_SUN9I_A80_R |
| 621 | { |
| 622 | .compatible = "allwinner,sun9i-a80-r-pinctrl", |
| 623 | .data = (ulong)&sun9i_a80_r_pinctrl_desc, |
| 624 | }, |
| 625 | #endif |
| 626 | #ifdef CONFIG_PINCTRL_SUN50I_A64 |
| 627 | { |
| 628 | .compatible = "allwinner,sun50i-a64-pinctrl", |
| 629 | .data = (ulong)&sun50i_a64_pinctrl_desc, |
| 630 | }, |
| 631 | #endif |
| 632 | #ifdef CONFIG_PINCTRL_SUN50I_A64_R |
| 633 | { |
| 634 | .compatible = "allwinner,sun50i-a64-r-pinctrl", |
| 635 | .data = (ulong)&sun50i_a64_r_pinctrl_desc, |
| 636 | }, |
| 637 | #endif |
| 638 | #ifdef CONFIG_PINCTRL_SUN50I_H5 |
| 639 | { |
| 640 | .compatible = "allwinner,sun50i-h5-pinctrl", |
| 641 | .data = (ulong)&sun50i_h5_pinctrl_desc, |
| 642 | }, |
| 643 | #endif |
| 644 | #ifdef CONFIG_PINCTRL_SUN50I_H6 |
| 645 | { |
| 646 | .compatible = "allwinner,sun50i-h6-pinctrl", |
| 647 | .data = (ulong)&sun50i_h6_pinctrl_desc, |
| 648 | }, |
| 649 | #endif |
| 650 | #ifdef CONFIG_PINCTRL_SUN50I_H6_R |
| 651 | { |
| 652 | .compatible = "allwinner,sun50i-h6-r-pinctrl", |
| 653 | .data = (ulong)&sun50i_h6_r_pinctrl_desc, |
| 654 | }, |
| 655 | #endif |
| 656 | #ifdef CONFIG_PINCTRL_SUN50I_H616 |
| 657 | { |
| 658 | .compatible = "allwinner,sun50i-h616-pinctrl", |
| 659 | .data = (ulong)&sun50i_h616_pinctrl_desc, |
| 660 | }, |
| 661 | #endif |
| 662 | #ifdef CONFIG_PINCTRL_SUN50I_H616_R |
| 663 | { |
| 664 | .compatible = "allwinner,sun50i-h616-r-pinctrl", |
| 665 | .data = (ulong)&sun50i_h616_r_pinctrl_desc, |
| 666 | }, |
| 667 | #endif |
| 668 | {} |
| 669 | }; |
| 670 | |
| 671 | U_BOOT_DRIVER(sunxi_pinctrl) = { |
| 672 | .name = "sunxi-pinctrl", |
| 673 | .id = UCLASS_PINCTRL, |
| 674 | .of_match = sunxi_pinctrl_ids, |
| 675 | .bind = sunxi_pinctrl_bind, |
| 676 | .probe = sunxi_pinctrl_probe, |
| 677 | .plat_auto = sizeof(struct sunxi_pinctrl_plat), |
| 678 | .ops = &sunxi_pinctrl_ops, |
| 679 | }; |