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