|
35 | 35 | #define MUX_FUNC(pinconf) (((pinconf) & MUX_FUNC_MASK) >> MUX_FUNC_OFFS) |
36 | 36 |
|
37 | 37 | /* PIN capabilities */ |
38 | | -#define PIN_CFG_IOLH BIT(0) |
39 | | -#define PIN_CFG_SR BIT(1) |
40 | | -#define PIN_CFG_IEN BIT(2) |
41 | | -#define PIN_CFG_PUPD BIT(3) |
42 | | -#define PIN_CFG_IO_VMC_SD0 BIT(4) |
43 | | -#define PIN_CFG_IO_VMC_SD1 BIT(5) |
44 | | -#define PIN_CFG_IO_VMC_QSPI BIT(6) |
45 | | -#define PIN_CFG_IO_VMC_ETH0 BIT(7) |
46 | | -#define PIN_CFG_IO_VMC_ETH1 BIT(8) |
47 | | -#define PIN_CFG_FILONOFF BIT(9) |
48 | | -#define PIN_CFG_FILNUM BIT(10) |
49 | | -#define PIN_CFG_FILCLKSEL BIT(11) |
50 | | - |
51 | | -#define RZG2L_MPXED_PIN_FUNCS (PIN_CFG_IOLH | \ |
| 38 | +#define PIN_CFG_IOLH_A BIT(0) |
| 39 | +#define PIN_CFG_IOLH_B BIT(1) |
| 40 | +#define PIN_CFG_SR BIT(2) |
| 41 | +#define PIN_CFG_IEN BIT(3) |
| 42 | +#define PIN_CFG_PUPD BIT(4) |
| 43 | +#define PIN_CFG_IO_VMC_SD0 BIT(5) |
| 44 | +#define PIN_CFG_IO_VMC_SD1 BIT(6) |
| 45 | +#define PIN_CFG_IO_VMC_QSPI BIT(7) |
| 46 | +#define PIN_CFG_IO_VMC_ETH0 BIT(8) |
| 47 | +#define PIN_CFG_IO_VMC_ETH1 BIT(9) |
| 48 | +#define PIN_CFG_FILONOFF BIT(10) |
| 49 | +#define PIN_CFG_FILNUM BIT(11) |
| 50 | +#define PIN_CFG_FILCLKSEL BIT(12) |
| 51 | + |
| 52 | +#define RZG2L_MPXED_PIN_FUNCS (PIN_CFG_IOLH_A | \ |
52 | 53 | PIN_CFG_SR | \ |
53 | 54 | PIN_CFG_PUPD | \ |
54 | 55 | PIN_CFG_FILONOFF | \ |
|
86 | 87 | #define PMC(n) (0x0200 + 0x10 + (n)) |
87 | 88 | #define PFC(n) (0x0400 + 0x40 + (n) * 4) |
88 | 89 | #define PIN(n) (0x0800 + 0x10 + (n)) |
| 90 | +#define IOLH(n) (0x1000 + (n) * 8) |
89 | 91 | #define IEN(n) (0x1800 + (n) * 8) |
90 | 92 | #define PWPR (0x3014) |
91 | 93 | #define SD_CH(n) (0x3000 + (n) * 4) |
|
101 | 103 | #define PVDD_MASK 0x01 |
102 | 104 | #define PFC_MASK 0x07 |
103 | 105 | #define IEN_MASK 0x01 |
| 106 | +#define IOLH_MASK 0x03 |
104 | 107 |
|
105 | 108 | #define PM_INPUT 0x1 |
106 | 109 | #define PM_OUTPUT 0x2 |
@@ -138,6 +141,9 @@ struct rzg2l_pinctrl { |
138 | 141 | spinlock_t lock; |
139 | 142 | }; |
140 | 143 |
|
| 144 | +static const unsigned int iolh_groupa_mA[] = { 2, 4, 8, 12 }; |
| 145 | +static const unsigned int iolh_groupb_oi[] = { 100, 66, 50, 33 }; |
| 146 | + |
141 | 147 | static void rzg2l_pinctrl_set_pfc_mode(struct rzg2l_pinctrl *pctrl, |
142 | 148 | u8 port, u8 pin, u8 func) |
143 | 149 | { |
@@ -532,6 +538,28 @@ static int rzg2l_pinctrl_pinconf_get(struct pinctrl_dev *pctldev, |
532 | 538 | break; |
533 | 539 | } |
534 | 540 |
|
| 541 | + case PIN_CONFIG_DRIVE_STRENGTH: { |
| 542 | + unsigned int index; |
| 543 | + |
| 544 | + if (!(cfg & PIN_CFG_IOLH_A)) |
| 545 | + return -EINVAL; |
| 546 | + |
| 547 | + index = rzg2l_read_pin_config(pctrl, IOLH(port_offset), bit, IOLH_MASK); |
| 548 | + arg = iolh_groupa_mA[index]; |
| 549 | + break; |
| 550 | + } |
| 551 | + |
| 552 | + case PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS: { |
| 553 | + unsigned int index; |
| 554 | + |
| 555 | + if (!(cfg & PIN_CFG_IOLH_B)) |
| 556 | + return -EINVAL; |
| 557 | + |
| 558 | + index = rzg2l_read_pin_config(pctrl, IOLH(port_offset), bit, IOLH_MASK); |
| 559 | + arg = iolh_groupb_oi[index]; |
| 560 | + break; |
| 561 | + } |
| 562 | + |
535 | 563 | default: |
536 | 564 | return -ENOTSUPP; |
537 | 565 | } |
@@ -609,6 +637,43 @@ static int rzg2l_pinctrl_pinconf_set(struct pinctrl_dev *pctldev, |
609 | 637 | spin_unlock_irqrestore(&pctrl->lock, flags); |
610 | 638 | break; |
611 | 639 | } |
| 640 | + |
| 641 | + case PIN_CONFIG_DRIVE_STRENGTH: { |
| 642 | + unsigned int arg = pinconf_to_config_argument(_configs[i]); |
| 643 | + unsigned int index; |
| 644 | + |
| 645 | + if (!(cfg & PIN_CFG_IOLH_A)) |
| 646 | + return -EINVAL; |
| 647 | + |
| 648 | + for (index = 0; index < ARRAY_SIZE(iolh_groupa_mA); index++) { |
| 649 | + if (arg == iolh_groupa_mA[index]) |
| 650 | + break; |
| 651 | + } |
| 652 | + if (index >= ARRAY_SIZE(iolh_groupa_mA)) |
| 653 | + return -EINVAL; |
| 654 | + |
| 655 | + rzg2l_rmw_pin_config(pctrl, IOLH(port_offset), bit, IOLH_MASK, index); |
| 656 | + break; |
| 657 | + } |
| 658 | + |
| 659 | + case PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS: { |
| 660 | + unsigned int arg = pinconf_to_config_argument(_configs[i]); |
| 661 | + unsigned int index; |
| 662 | + |
| 663 | + if (!(cfg & PIN_CFG_IOLH_B)) |
| 664 | + return -EINVAL; |
| 665 | + |
| 666 | + for (index = 0; index < ARRAY_SIZE(iolh_groupb_oi); index++) { |
| 667 | + if (arg == iolh_groupb_oi[index]) |
| 668 | + break; |
| 669 | + } |
| 670 | + if (index >= ARRAY_SIZE(iolh_groupb_oi)) |
| 671 | + return -EINVAL; |
| 672 | + |
| 673 | + rzg2l_rmw_pin_config(pctrl, IOLH(port_offset), bit, IOLH_MASK, index); |
| 674 | + break; |
| 675 | + } |
| 676 | + |
612 | 677 | default: |
613 | 678 | return -EOPNOTSUPP; |
614 | 679 | } |
@@ -935,75 +1000,75 @@ static struct rzg2l_dedicated_configs rzg2l_dedicated_pins[] = { |
935 | 1000 | { "NMI", RZG2L_SINGLE_PIN_PACK(0x1, 0, |
936 | 1001 | (PIN_CFG_FILONOFF | PIN_CFG_FILNUM | PIN_CFG_FILCLKSEL)) }, |
937 | 1002 | { "TMS/SWDIO", RZG2L_SINGLE_PIN_PACK(0x2, 0, |
938 | | - (PIN_CFG_SR | PIN_CFG_IOLH | PIN_CFG_IEN)) }, |
| 1003 | + (PIN_CFG_SR | PIN_CFG_IOLH_A | PIN_CFG_IEN)) }, |
939 | 1004 | { "TDO", RZG2L_SINGLE_PIN_PACK(0x3, 0, |
940 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IEN)) }, |
| 1005 | + (PIN_CFG_IOLH_A | PIN_CFG_SR | PIN_CFG_IEN)) }, |
941 | 1006 | { "AUDIO_CLK1", RZG2L_SINGLE_PIN_PACK(0x4, 0, PIN_CFG_IEN) }, |
942 | 1007 | { "AUDIO_CLK2", RZG2L_SINGLE_PIN_PACK(0x4, 1, PIN_CFG_IEN) }, |
943 | 1008 | { "SD0_CLK", RZG2L_SINGLE_PIN_PACK(0x6, 0, |
944 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IO_VMC_SD0)) }, |
| 1009 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IO_VMC_SD0)) }, |
945 | 1010 | { "SD0_CMD", RZG2L_SINGLE_PIN_PACK(0x6, 1, |
946 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD0)) }, |
| 1011 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD0)) }, |
947 | 1012 | { "SD0_RST#", RZG2L_SINGLE_PIN_PACK(0x6, 2, |
948 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IO_VMC_SD0)) }, |
| 1013 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IO_VMC_SD0)) }, |
949 | 1014 | { "SD0_DATA0", RZG2L_SINGLE_PIN_PACK(0x7, 0, |
950 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD0)) }, |
| 1015 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD0)) }, |
951 | 1016 | { "SD0_DATA1", RZG2L_SINGLE_PIN_PACK(0x7, 1, |
952 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD0)) }, |
| 1017 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD0)) }, |
953 | 1018 | { "SD0_DATA2", RZG2L_SINGLE_PIN_PACK(0x7, 2, |
954 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD0)) }, |
| 1019 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD0)) }, |
955 | 1020 | { "SD0_DATA3", RZG2L_SINGLE_PIN_PACK(0x7, 3, |
956 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD0)) }, |
| 1021 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD0)) }, |
957 | 1022 | { "SD0_DATA4", RZG2L_SINGLE_PIN_PACK(0x7, 4, |
958 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD0)) }, |
| 1023 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD0)) }, |
959 | 1024 | { "SD0_DATA5", RZG2L_SINGLE_PIN_PACK(0x7, 5, |
960 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD0)) }, |
| 1025 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD0)) }, |
961 | 1026 | { "SD0_DATA6", RZG2L_SINGLE_PIN_PACK(0x7, 6, |
962 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD0)) }, |
| 1027 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD0)) }, |
963 | 1028 | { "SD0_DATA7", RZG2L_SINGLE_PIN_PACK(0x7, 7, |
964 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD0)) }, |
| 1029 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD0)) }, |
965 | 1030 | { "SD1_CLK", RZG2L_SINGLE_PIN_PACK(0x8, 0, |
966 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IO_VMC_SD1))}, |
| 1031 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IO_VMC_SD1)) }, |
967 | 1032 | { "SD1_CMD", RZG2L_SINGLE_PIN_PACK(0x8, 1, |
968 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD1)) }, |
| 1033 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD1)) }, |
969 | 1034 | { "SD1_DATA0", RZG2L_SINGLE_PIN_PACK(0x9, 0, |
970 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD1)) }, |
| 1035 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD1)) }, |
971 | 1036 | { "SD1_DATA1", RZG2L_SINGLE_PIN_PACK(0x9, 1, |
972 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD1)) }, |
| 1037 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD1)) }, |
973 | 1038 | { "SD1_DATA2", RZG2L_SINGLE_PIN_PACK(0x9, 2, |
974 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD1)) }, |
| 1039 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD1)) }, |
975 | 1040 | { "SD1_DATA3", RZG2L_SINGLE_PIN_PACK(0x9, 3, |
976 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD1)) }, |
| 1041 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IEN | PIN_CFG_IO_VMC_SD1)) }, |
977 | 1042 | { "QSPI0_SPCLK", RZG2L_SINGLE_PIN_PACK(0xa, 0, |
978 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
| 1043 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
979 | 1044 | { "QSPI0_IO0", RZG2L_SINGLE_PIN_PACK(0xa, 1, |
980 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
| 1045 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
981 | 1046 | { "QSPI0_IO1", RZG2L_SINGLE_PIN_PACK(0xa, 2, |
982 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
| 1047 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
983 | 1048 | { "QSPI0_IO2", RZG2L_SINGLE_PIN_PACK(0xa, 3, |
984 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
| 1049 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
985 | 1050 | { "QSPI0_IO3", RZG2L_SINGLE_PIN_PACK(0xa, 4, |
986 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
| 1051 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
987 | 1052 | { "QSPI0_SSL", RZG2L_SINGLE_PIN_PACK(0xa, 5, |
988 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
| 1053 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
989 | 1054 | { "QSPI1_SPCLK", RZG2L_SINGLE_PIN_PACK(0xb, 0, |
990 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
| 1055 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
991 | 1056 | { "QSPI1_IO0", RZG2L_SINGLE_PIN_PACK(0xb, 1, |
992 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
| 1057 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
993 | 1058 | { "QSPI1_IO1", RZG2L_SINGLE_PIN_PACK(0xb, 2, |
994 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
| 1059 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
995 | 1060 | { "QSPI1_IO2", RZG2L_SINGLE_PIN_PACK(0xb, 3, |
996 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
| 1061 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
997 | 1062 | { "QSPI1_IO3", RZG2L_SINGLE_PIN_PACK(0xb, 4, |
998 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
| 1063 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
999 | 1064 | { "QSPI1_SSL", RZG2L_SINGLE_PIN_PACK(0xb, 5, |
1000 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
| 1065 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
1001 | 1066 | { "QSPI_RESET#", RZG2L_SINGLE_PIN_PACK(0xc, 0, |
1002 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
| 1067 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
1003 | 1068 | { "QSPI_WP#", RZG2L_SINGLE_PIN_PACK(0xc, 1, |
1004 | | - (PIN_CFG_IOLH | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
| 1069 | + (PIN_CFG_IOLH_B | PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
1005 | 1070 | { "QSPI_INT#", RZG2L_SINGLE_PIN_PACK(0xc, 2, (PIN_CFG_SR | PIN_CFG_IO_VMC_QSPI)) }, |
1006 | | - { "WDTOVF_PERROUT#", RZG2L_SINGLE_PIN_PACK(0xd, 0, (PIN_CFG_IOLH | PIN_CFG_SR)) }, |
| 1071 | + { "WDTOVF_PERROUT#", RZG2L_SINGLE_PIN_PACK(0xd, 0, (PIN_CFG_IOLH_A | PIN_CFG_SR)) }, |
1007 | 1072 | { "RIIC0_SDA", RZG2L_SINGLE_PIN_PACK(0xe, 0, PIN_CFG_IEN) }, |
1008 | 1073 | { "RIIC0_SCL", RZG2L_SINGLE_PIN_PACK(0xe, 1, PIN_CFG_IEN) }, |
1009 | 1074 | { "RIIC1_SDA", RZG2L_SINGLE_PIN_PACK(0xe, 2, PIN_CFG_IEN) }, |
|
0 commit comments