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 | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 95 | static const struct pinctrl_ops sunxi_pinctrl_ops = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 96 | .get_pins_count = sunxi_pinctrl_get_pins_count, |
| 97 | .get_pin_name = sunxi_pinctrl_get_pin_name, |
| 98 | .get_functions_count = sunxi_pinctrl_get_functions_count, |
| 99 | .get_function_name = sunxi_pinctrl_get_function_name, |
| 100 | .pinmux_set = sunxi_pinctrl_pinmux_set, |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 101 | .set_state = pinctrl_generic_set_state, |
| 102 | }; |
| 103 | |
| 104 | static int sunxi_pinctrl_bind(struct udevice *dev) |
| 105 | { |
| 106 | struct sunxi_pinctrl_plat *plat = dev_get_plat(dev); |
| 107 | struct sunxi_pinctrl_desc *desc; |
| 108 | struct sunxi_gpio_plat *gpio_plat; |
| 109 | struct udevice *gpio_dev; |
| 110 | int i, ret; |
| 111 | |
| 112 | desc = (void *)dev_get_driver_data(dev); |
| 113 | if (!desc) |
| 114 | return -EINVAL; |
| 115 | dev_set_priv(dev, desc); |
| 116 | |
| 117 | plat->base = dev_read_addr_ptr(dev); |
| 118 | |
| 119 | ret = device_bind_driver_to_node(dev, "gpio_sunxi", dev->name, |
| 120 | dev_ofnode(dev), &gpio_dev); |
| 121 | if (ret) |
| 122 | return ret; |
| 123 | |
| 124 | for (i = 0; i < desc->num_banks; ++i) { |
| 125 | gpio_plat = malloc(sizeof(*gpio_plat)); |
| 126 | if (!gpio_plat) |
| 127 | return -ENOMEM; |
| 128 | |
| 129 | gpio_plat->regs = plat->base + i; |
| 130 | gpio_plat->bank_name[0] = 'P'; |
| 131 | gpio_plat->bank_name[1] = 'A' + desc->first_bank + i; |
| 132 | gpio_plat->bank_name[2] = '\0'; |
| 133 | |
| 134 | ret = device_bind(gpio_dev, DM_DRIVER_REF(gpio_sunxi), |
| 135 | gpio_plat->bank_name, gpio_plat, |
| 136 | ofnode_null(), NULL); |
| 137 | if (ret) |
| 138 | return ret; |
| 139 | } |
| 140 | |
| 141 | return 0; |
| 142 | } |
| 143 | |
| 144 | static int sunxi_pinctrl_probe(struct udevice *dev) |
| 145 | { |
| 146 | struct clk *apb_clk; |
| 147 | |
| 148 | apb_clk = devm_clk_get(dev, "apb"); |
| 149 | if (!IS_ERR(apb_clk)) |
| 150 | clk_enable(apb_clk); |
| 151 | |
| 152 | return 0; |
| 153 | } |
| 154 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 155 | static const struct sunxi_pinctrl_function suniv_f1c100s_pinctrl_functions[] = { |
| 156 | { "gpio_in", 0 }, |
| 157 | { "gpio_out", 1 }, |
| 158 | }; |
| 159 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 160 | static const struct sunxi_pinctrl_desc __maybe_unused suniv_f1c100s_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 161 | .functions = suniv_f1c100s_pinctrl_functions, |
| 162 | .num_functions = ARRAY_SIZE(suniv_f1c100s_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 163 | .first_bank = SUNXI_GPIO_A, |
| 164 | .num_banks = 6, |
| 165 | }; |
| 166 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 167 | static const struct sunxi_pinctrl_function sun4i_a10_pinctrl_functions[] = { |
| 168 | { "gpio_in", 0 }, |
| 169 | { "gpio_out", 1 }, |
| 170 | }; |
| 171 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 172 | static const struct sunxi_pinctrl_desc __maybe_unused sun4i_a10_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 173 | .functions = sun4i_a10_pinctrl_functions, |
| 174 | .num_functions = ARRAY_SIZE(sun4i_a10_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 175 | .first_bank = SUNXI_GPIO_A, |
| 176 | .num_banks = 9, |
| 177 | }; |
| 178 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 179 | static const struct sunxi_pinctrl_function sun5i_a13_pinctrl_functions[] = { |
| 180 | { "gpio_in", 0 }, |
| 181 | { "gpio_out", 1 }, |
| 182 | }; |
| 183 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 184 | static const struct sunxi_pinctrl_desc __maybe_unused sun5i_a13_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 185 | .functions = sun5i_a13_pinctrl_functions, |
| 186 | .num_functions = ARRAY_SIZE(sun5i_a13_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 187 | .first_bank = SUNXI_GPIO_A, |
| 188 | .num_banks = 7, |
| 189 | }; |
| 190 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 191 | static const struct sunxi_pinctrl_function sun6i_a31_pinctrl_functions[] = { |
| 192 | { "gpio_in", 0 }, |
| 193 | { "gpio_out", 1 }, |
| 194 | }; |
| 195 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 196 | static const struct sunxi_pinctrl_desc __maybe_unused sun6i_a31_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 197 | .functions = sun6i_a31_pinctrl_functions, |
| 198 | .num_functions = ARRAY_SIZE(sun6i_a31_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 199 | .first_bank = SUNXI_GPIO_A, |
| 200 | .num_banks = 8, |
| 201 | }; |
| 202 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 203 | static const struct sunxi_pinctrl_function sun6i_a31_r_pinctrl_functions[] = { |
| 204 | { "gpio_in", 0 }, |
| 205 | { "gpio_out", 1 }, |
| 206 | }; |
| 207 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 208 | 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^] | 209 | .functions = sun6i_a31_r_pinctrl_functions, |
| 210 | .num_functions = ARRAY_SIZE(sun6i_a31_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 211 | .first_bank = SUNXI_GPIO_L, |
| 212 | .num_banks = 2, |
| 213 | }; |
| 214 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 215 | static const struct sunxi_pinctrl_function sun7i_a20_pinctrl_functions[] = { |
| 216 | { "gpio_in", 0 }, |
| 217 | { "gpio_out", 1 }, |
| 218 | }; |
| 219 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 220 | static const struct sunxi_pinctrl_desc __maybe_unused sun7i_a20_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 221 | .functions = sun7i_a20_pinctrl_functions, |
| 222 | .num_functions = ARRAY_SIZE(sun7i_a20_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 223 | .first_bank = SUNXI_GPIO_A, |
| 224 | .num_banks = 9, |
| 225 | }; |
| 226 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 227 | static const struct sunxi_pinctrl_function sun8i_a23_pinctrl_functions[] = { |
| 228 | { "gpio_in", 0 }, |
| 229 | { "gpio_out", 1 }, |
| 230 | }; |
| 231 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 232 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a23_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 233 | .functions = sun8i_a23_pinctrl_functions, |
| 234 | .num_functions = ARRAY_SIZE(sun8i_a23_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 235 | .first_bank = SUNXI_GPIO_A, |
| 236 | .num_banks = 8, |
| 237 | }; |
| 238 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 239 | static const struct sunxi_pinctrl_function sun8i_a23_r_pinctrl_functions[] = { |
| 240 | { "gpio_in", 0 }, |
| 241 | { "gpio_out", 1 }, |
| 242 | }; |
| 243 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 244 | 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^] | 245 | .functions = sun8i_a23_r_pinctrl_functions, |
| 246 | .num_functions = ARRAY_SIZE(sun8i_a23_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 247 | .first_bank = SUNXI_GPIO_L, |
| 248 | .num_banks = 1, |
| 249 | }; |
| 250 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 251 | static const struct sunxi_pinctrl_function sun8i_a33_pinctrl_functions[] = { |
| 252 | { "gpio_in", 0 }, |
| 253 | { "gpio_out", 1 }, |
| 254 | }; |
| 255 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 256 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a33_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 257 | .functions = sun8i_a33_pinctrl_functions, |
| 258 | .num_functions = ARRAY_SIZE(sun8i_a33_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 259 | .first_bank = SUNXI_GPIO_A, |
| 260 | .num_banks = 8, |
| 261 | }; |
| 262 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 263 | static const struct sunxi_pinctrl_function sun8i_a83t_pinctrl_functions[] = { |
| 264 | { "gpio_in", 0 }, |
| 265 | { "gpio_out", 1 }, |
| 266 | }; |
| 267 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 268 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_a83t_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 269 | .functions = sun8i_a83t_pinctrl_functions, |
| 270 | .num_functions = ARRAY_SIZE(sun8i_a83t_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 271 | .first_bank = SUNXI_GPIO_A, |
| 272 | .num_banks = 8, |
| 273 | }; |
| 274 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 275 | static const struct sunxi_pinctrl_function sun8i_a83t_r_pinctrl_functions[] = { |
| 276 | { "gpio_in", 0 }, |
| 277 | { "gpio_out", 1 }, |
| 278 | }; |
| 279 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 280 | 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^] | 281 | .functions = sun8i_a83t_r_pinctrl_functions, |
| 282 | .num_functions = ARRAY_SIZE(sun8i_a83t_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 283 | .first_bank = SUNXI_GPIO_L, |
| 284 | .num_banks = 1, |
| 285 | }; |
| 286 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 287 | static const struct sunxi_pinctrl_function sun8i_h3_pinctrl_functions[] = { |
| 288 | { "gpio_in", 0 }, |
| 289 | { "gpio_out", 1 }, |
| 290 | }; |
| 291 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 292 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_h3_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 293 | .functions = sun8i_h3_pinctrl_functions, |
| 294 | .num_functions = ARRAY_SIZE(sun8i_h3_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 295 | .first_bank = SUNXI_GPIO_A, |
| 296 | .num_banks = 7, |
| 297 | }; |
| 298 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 299 | static const struct sunxi_pinctrl_function sun8i_h3_r_pinctrl_functions[] = { |
| 300 | { "gpio_in", 0 }, |
| 301 | { "gpio_out", 1 }, |
| 302 | }; |
| 303 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 304 | 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^] | 305 | .functions = sun8i_h3_r_pinctrl_functions, |
| 306 | .num_functions = ARRAY_SIZE(sun8i_h3_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 307 | .first_bank = SUNXI_GPIO_L, |
| 308 | .num_banks = 1, |
| 309 | }; |
| 310 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 311 | static const struct sunxi_pinctrl_function sun8i_v3s_pinctrl_functions[] = { |
| 312 | { "gpio_in", 0 }, |
| 313 | { "gpio_out", 1 }, |
| 314 | }; |
| 315 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 316 | static const struct sunxi_pinctrl_desc __maybe_unused sun8i_v3s_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 317 | .functions = sun8i_v3s_pinctrl_functions, |
| 318 | .num_functions = ARRAY_SIZE(sun8i_v3s_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 319 | .first_bank = SUNXI_GPIO_A, |
| 320 | .num_banks = 7, |
| 321 | }; |
| 322 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 323 | static const struct sunxi_pinctrl_function sun9i_a80_pinctrl_functions[] = { |
| 324 | { "gpio_in", 0 }, |
| 325 | { "gpio_out", 1 }, |
| 326 | }; |
| 327 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 328 | static const struct sunxi_pinctrl_desc __maybe_unused sun9i_a80_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 329 | .functions = sun9i_a80_pinctrl_functions, |
| 330 | .num_functions = ARRAY_SIZE(sun9i_a80_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 331 | .first_bank = SUNXI_GPIO_A, |
| 332 | .num_banks = 8, |
| 333 | }; |
| 334 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 335 | static const struct sunxi_pinctrl_function sun9i_a80_r_pinctrl_functions[] = { |
| 336 | { "gpio_in", 0 }, |
| 337 | { "gpio_out", 1 }, |
| 338 | }; |
| 339 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 340 | 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^] | 341 | .functions = sun9i_a80_r_pinctrl_functions, |
| 342 | .num_functions = ARRAY_SIZE(sun9i_a80_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 343 | .first_bank = SUNXI_GPIO_L, |
| 344 | .num_banks = 3, |
| 345 | }; |
| 346 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 347 | static const struct sunxi_pinctrl_function sun50i_a64_pinctrl_functions[] = { |
| 348 | { "gpio_in", 0 }, |
| 349 | { "gpio_out", 1 }, |
| 350 | }; |
| 351 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 352 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_a64_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 353 | .functions = sun50i_a64_pinctrl_functions, |
| 354 | .num_functions = ARRAY_SIZE(sun50i_a64_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 355 | .first_bank = SUNXI_GPIO_A, |
| 356 | .num_banks = 8, |
| 357 | }; |
| 358 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 359 | static const struct sunxi_pinctrl_function sun50i_a64_r_pinctrl_functions[] = { |
| 360 | { "gpio_in", 0 }, |
| 361 | { "gpio_out", 1 }, |
| 362 | }; |
| 363 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 364 | 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^] | 365 | .functions = sun50i_a64_r_pinctrl_functions, |
| 366 | .num_functions = ARRAY_SIZE(sun50i_a64_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 367 | .first_bank = SUNXI_GPIO_L, |
| 368 | .num_banks = 1, |
| 369 | }; |
| 370 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 371 | static const struct sunxi_pinctrl_function sun50i_h5_pinctrl_functions[] = { |
| 372 | { "gpio_in", 0 }, |
| 373 | { "gpio_out", 1 }, |
| 374 | }; |
| 375 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 376 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h5_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 377 | .functions = sun50i_h5_pinctrl_functions, |
| 378 | .num_functions = ARRAY_SIZE(sun50i_h5_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 379 | .first_bank = SUNXI_GPIO_A, |
| 380 | .num_banks = 7, |
| 381 | }; |
| 382 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 383 | static const struct sunxi_pinctrl_function sun50i_h6_pinctrl_functions[] = { |
| 384 | { "gpio_in", 0 }, |
| 385 | { "gpio_out", 1 }, |
| 386 | }; |
| 387 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 388 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h6_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 389 | .functions = sun50i_h6_pinctrl_functions, |
| 390 | .num_functions = ARRAY_SIZE(sun50i_h6_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 391 | .first_bank = SUNXI_GPIO_A, |
| 392 | .num_banks = 8, |
| 393 | }; |
| 394 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 395 | static const struct sunxi_pinctrl_function sun50i_h6_r_pinctrl_functions[] = { |
| 396 | { "gpio_in", 0 }, |
| 397 | { "gpio_out", 1 }, |
| 398 | }; |
| 399 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 400 | 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^] | 401 | .functions = sun50i_h6_r_pinctrl_functions, |
| 402 | .num_functions = ARRAY_SIZE(sun50i_h6_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 403 | .first_bank = SUNXI_GPIO_L, |
| 404 | .num_banks = 2, |
| 405 | }; |
| 406 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 407 | static const struct sunxi_pinctrl_function sun50i_h616_pinctrl_functions[] = { |
| 408 | { "gpio_in", 0 }, |
| 409 | { "gpio_out", 1 }, |
| 410 | }; |
| 411 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 412 | static const struct sunxi_pinctrl_desc __maybe_unused sun50i_h616_pinctrl_desc = { |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 413 | .functions = sun50i_h616_pinctrl_functions, |
| 414 | .num_functions = ARRAY_SIZE(sun50i_h616_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 415 | .first_bank = SUNXI_GPIO_A, |
| 416 | .num_banks = 9, |
| 417 | }; |
| 418 | |
Samuel Holland | ecbbedb | 2021-08-16 23:56:47 -0500 | [diff] [blame^] | 419 | static const struct sunxi_pinctrl_function sun50i_h616_r_pinctrl_functions[] = { |
| 420 | { "gpio_in", 0 }, |
| 421 | { "gpio_out", 1 }, |
| 422 | }; |
| 423 | |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 424 | 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^] | 425 | .functions = sun50i_h616_r_pinctrl_functions, |
| 426 | .num_functions = ARRAY_SIZE(sun50i_h616_r_pinctrl_functions), |
Samuel Holland | e309502 | 2021-08-12 20:09:43 -0500 | [diff] [blame] | 427 | .first_bank = SUNXI_GPIO_L, |
| 428 | .num_banks = 1, |
| 429 | }; |
| 430 | |
| 431 | static const struct udevice_id sunxi_pinctrl_ids[] = { |
| 432 | #ifdef CONFIG_PINCTRL_SUNIV_F1C100S |
| 433 | { |
| 434 | .compatible = "allwinner,suniv-f1c100s-pinctrl", |
| 435 | .data = (ulong)&suniv_f1c100s_pinctrl_desc, |
| 436 | }, |
| 437 | #endif |
| 438 | #ifdef CONFIG_PINCTRL_SUN4I_A10 |
| 439 | { |
| 440 | .compatible = "allwinner,sun4i-a10-pinctrl", |
| 441 | .data = (ulong)&sun4i_a10_pinctrl_desc, |
| 442 | }, |
| 443 | #endif |
| 444 | #ifdef CONFIG_PINCTRL_SUN5I_A13 |
| 445 | { |
| 446 | .compatible = "allwinner,sun5i-a10s-pinctrl", |
| 447 | .data = (ulong)&sun5i_a13_pinctrl_desc, |
| 448 | }, |
| 449 | { |
| 450 | .compatible = "allwinner,sun5i-a13-pinctrl", |
| 451 | .data = (ulong)&sun5i_a13_pinctrl_desc, |
| 452 | }, |
| 453 | #endif |
| 454 | #ifdef CONFIG_PINCTRL_SUN6I_A31 |
| 455 | { |
| 456 | .compatible = "allwinner,sun6i-a31-pinctrl", |
| 457 | .data = (ulong)&sun6i_a31_pinctrl_desc, |
| 458 | }, |
| 459 | { |
| 460 | .compatible = "allwinner,sun6i-a31s-pinctrl", |
| 461 | .data = (ulong)&sun6i_a31_pinctrl_desc, |
| 462 | }, |
| 463 | #endif |
| 464 | #ifdef CONFIG_PINCTRL_SUN6I_A31_R |
| 465 | { |
| 466 | .compatible = "allwinner,sun6i-a31-r-pinctrl", |
| 467 | .data = (ulong)&sun6i_a31_r_pinctrl_desc, |
| 468 | }, |
| 469 | #endif |
| 470 | #ifdef CONFIG_PINCTRL_SUN7I_A20 |
| 471 | { |
| 472 | .compatible = "allwinner,sun7i-a20-pinctrl", |
| 473 | .data = (ulong)&sun7i_a20_pinctrl_desc, |
| 474 | }, |
| 475 | #endif |
| 476 | #ifdef CONFIG_PINCTRL_SUN8I_A23 |
| 477 | { |
| 478 | .compatible = "allwinner,sun8i-a23-pinctrl", |
| 479 | .data = (ulong)&sun8i_a23_pinctrl_desc, |
| 480 | }, |
| 481 | #endif |
| 482 | #ifdef CONFIG_PINCTRL_SUN8I_A23_R |
| 483 | { |
| 484 | .compatible = "allwinner,sun8i-a23-r-pinctrl", |
| 485 | .data = (ulong)&sun8i_a23_r_pinctrl_desc, |
| 486 | }, |
| 487 | #endif |
| 488 | #ifdef CONFIG_PINCTRL_SUN8I_A33 |
| 489 | { |
| 490 | .compatible = "allwinner,sun8i-a33-pinctrl", |
| 491 | .data = (ulong)&sun8i_a33_pinctrl_desc, |
| 492 | }, |
| 493 | #endif |
| 494 | #ifdef CONFIG_PINCTRL_SUN8I_A83T |
| 495 | { |
| 496 | .compatible = "allwinner,sun8i-a83t-pinctrl", |
| 497 | .data = (ulong)&sun8i_a83t_pinctrl_desc, |
| 498 | }, |
| 499 | #endif |
| 500 | #ifdef CONFIG_PINCTRL_SUN8I_A83T_R |
| 501 | { |
| 502 | .compatible = "allwinner,sun8i-a83t-r-pinctrl", |
| 503 | .data = (ulong)&sun8i_a83t_r_pinctrl_desc, |
| 504 | }, |
| 505 | #endif |
| 506 | #ifdef CONFIG_PINCTRL_SUN8I_H3 |
| 507 | { |
| 508 | .compatible = "allwinner,sun8i-h3-pinctrl", |
| 509 | .data = (ulong)&sun8i_h3_pinctrl_desc, |
| 510 | }, |
| 511 | #endif |
| 512 | #ifdef CONFIG_PINCTRL_SUN8I_H3_R |
| 513 | { |
| 514 | .compatible = "allwinner,sun8i-h3-r-pinctrl", |
| 515 | .data = (ulong)&sun8i_h3_r_pinctrl_desc, |
| 516 | }, |
| 517 | #endif |
| 518 | #ifdef CONFIG_PINCTRL_SUN7I_A20 |
| 519 | { |
| 520 | .compatible = "allwinner,sun8i-r40-pinctrl", |
| 521 | .data = (ulong)&sun7i_a20_pinctrl_desc, |
| 522 | }, |
| 523 | #endif |
| 524 | #ifdef CONFIG_PINCTRL_SUN8I_V3S |
| 525 | { |
| 526 | .compatible = "allwinner,sun8i-v3-pinctrl", |
| 527 | .data = (ulong)&sun8i_v3s_pinctrl_desc, |
| 528 | }, |
| 529 | { |
| 530 | .compatible = "allwinner,sun8i-v3s-pinctrl", |
| 531 | .data = (ulong)&sun8i_v3s_pinctrl_desc, |
| 532 | }, |
| 533 | #endif |
| 534 | #ifdef CONFIG_PINCTRL_SUN9I_A80 |
| 535 | { |
| 536 | .compatible = "allwinner,sun9i-a80-pinctrl", |
| 537 | .data = (ulong)&sun9i_a80_pinctrl_desc, |
| 538 | }, |
| 539 | #endif |
| 540 | #ifdef CONFIG_PINCTRL_SUN9I_A80_R |
| 541 | { |
| 542 | .compatible = "allwinner,sun9i-a80-r-pinctrl", |
| 543 | .data = (ulong)&sun9i_a80_r_pinctrl_desc, |
| 544 | }, |
| 545 | #endif |
| 546 | #ifdef CONFIG_PINCTRL_SUN50I_A64 |
| 547 | { |
| 548 | .compatible = "allwinner,sun50i-a64-pinctrl", |
| 549 | .data = (ulong)&sun50i_a64_pinctrl_desc, |
| 550 | }, |
| 551 | #endif |
| 552 | #ifdef CONFIG_PINCTRL_SUN50I_A64_R |
| 553 | { |
| 554 | .compatible = "allwinner,sun50i-a64-r-pinctrl", |
| 555 | .data = (ulong)&sun50i_a64_r_pinctrl_desc, |
| 556 | }, |
| 557 | #endif |
| 558 | #ifdef CONFIG_PINCTRL_SUN50I_H5 |
| 559 | { |
| 560 | .compatible = "allwinner,sun50i-h5-pinctrl", |
| 561 | .data = (ulong)&sun50i_h5_pinctrl_desc, |
| 562 | }, |
| 563 | #endif |
| 564 | #ifdef CONFIG_PINCTRL_SUN50I_H6 |
| 565 | { |
| 566 | .compatible = "allwinner,sun50i-h6-pinctrl", |
| 567 | .data = (ulong)&sun50i_h6_pinctrl_desc, |
| 568 | }, |
| 569 | #endif |
| 570 | #ifdef CONFIG_PINCTRL_SUN50I_H6_R |
| 571 | { |
| 572 | .compatible = "allwinner,sun50i-h6-r-pinctrl", |
| 573 | .data = (ulong)&sun50i_h6_r_pinctrl_desc, |
| 574 | }, |
| 575 | #endif |
| 576 | #ifdef CONFIG_PINCTRL_SUN50I_H616 |
| 577 | { |
| 578 | .compatible = "allwinner,sun50i-h616-pinctrl", |
| 579 | .data = (ulong)&sun50i_h616_pinctrl_desc, |
| 580 | }, |
| 581 | #endif |
| 582 | #ifdef CONFIG_PINCTRL_SUN50I_H616_R |
| 583 | { |
| 584 | .compatible = "allwinner,sun50i-h616-r-pinctrl", |
| 585 | .data = (ulong)&sun50i_h616_r_pinctrl_desc, |
| 586 | }, |
| 587 | #endif |
| 588 | {} |
| 589 | }; |
| 590 | |
| 591 | U_BOOT_DRIVER(sunxi_pinctrl) = { |
| 592 | .name = "sunxi-pinctrl", |
| 593 | .id = UCLASS_PINCTRL, |
| 594 | .of_match = sunxi_pinctrl_ids, |
| 595 | .bind = sunxi_pinctrl_bind, |
| 596 | .probe = sunxi_pinctrl_probe, |
| 597 | .plat_auto = sizeof(struct sunxi_pinctrl_plat), |
| 598 | .ops = &sunxi_pinctrl_ops, |
| 599 | }; |