@@ -294,8 +294,8 @@ struct rzg2l_pinctrl_data {
294
294
#endif
295
295
void (* pwpr_pfc_lock_unlock )(struct rzg2l_pinctrl * pctrl , bool lock );
296
296
void (* pmc_writeb )(struct rzg2l_pinctrl * pctrl , u8 val , u16 offset );
297
- u32 (* oen_read )(struct rzg2l_pinctrl * pctrl , u32 caps , u32 offset , u8 pin );
298
- int (* oen_write )(struct rzg2l_pinctrl * pctrl , u32 caps , u32 offset , u8 pin , u8 oen );
297
+ u32 (* oen_read )(struct rzg2l_pinctrl * pctrl , unsigned int _pin );
298
+ int (* oen_write )(struct rzg2l_pinctrl * pctrl , unsigned int _pin , u8 oen );
299
299
int (* hw_to_bias_param )(unsigned int val );
300
300
int (* bias_param_to_hw )(enum pin_config_param param );
301
301
};
@@ -999,53 +999,100 @@ static bool rzg2l_ds_is_supported(struct rzg2l_pinctrl *pctrl, u32 caps,
999
999
return false;
1000
1000
}
1001
1001
1002
- static bool rzg2l_oen_is_supported ( u32 caps , u8 pin , u8 max_pin )
1002
+ static int rzg2l_pin_to_oen_bit ( struct rzg2l_pinctrl * pctrl , unsigned int _pin )
1003
1003
{
1004
- if (!(caps & PIN_CFG_OEN ))
1005
- return false;
1004
+ u64 * pin_data = pctrl -> desc .pins [_pin ].drv_data ;
1005
+ u64 caps = FIELD_GET (PIN_CFG_MASK , * pin_data );
1006
+ u8 pin = RZG2L_PIN_ID_TO_PIN (_pin );
1006
1007
1007
- if (pin > max_pin )
1008
- return false ;
1008
+ if (pin > pctrl -> data -> hwcfg -> oen_max_pin )
1009
+ return - EINVAL ;
1009
1010
1010
- return true;
1011
+ /*
1012
+ * We can determine which Ethernet interface we're dealing with from
1013
+ * the caps.
1014
+ */
1015
+ if (caps & PIN_CFG_IO_VMC_ETH0 )
1016
+ return 0 ;
1017
+ if (caps & PIN_CFG_IO_VMC_ETH1 )
1018
+ return 1 ;
1019
+
1020
+ return - EINVAL ;
1011
1021
}
1012
1022
1013
- static u8 rzg2l_pin_to_oen_bit ( u32 offset , u8 pin , u8 max_port )
1023
+ static u32 rzg2l_read_oen ( struct rzg2l_pinctrl * pctrl , unsigned int _pin )
1014
1024
{
1015
- if (pin )
1016
- pin *= 2 ;
1025
+ int bit ;
1017
1026
1018
- if (offset / RZG2L_PINS_PER_PORT == max_port )
1019
- pin += 1 ;
1027
+ bit = rzg2l_pin_to_oen_bit (pctrl , _pin );
1028
+ if (bit < 0 )
1029
+ return 0 ;
1020
1030
1021
- return pin ;
1031
+ return !( readb ( pctrl -> base + ETH_MODE ) & BIT ( bit )) ;
1022
1032
}
1023
1033
1024
- static u32 rzg2l_read_oen (struct rzg2l_pinctrl * pctrl , u32 caps , u32 offset , u8 pin )
1034
+ static int rzg2l_write_oen (struct rzg2l_pinctrl * pctrl , unsigned int _pin , u8 oen )
1025
1035
{
1026
- u8 max_port = pctrl -> data -> hwcfg -> oen_max_port ;
1027
- u8 max_pin = pctrl -> data -> hwcfg -> oen_max_pin ;
1028
- u8 bit ;
1036
+ unsigned long flags ;
1037
+ int bit ;
1038
+ u8 val ;
1029
1039
1030
- if (!rzg2l_oen_is_supported (caps , pin , max_pin ))
1031
- return 0 ;
1040
+ bit = rzg2l_pin_to_oen_bit (pctrl , _pin );
1041
+ if (bit < 0 )
1042
+ return bit ;
1032
1043
1033
- bit = rzg2l_pin_to_oen_bit (offset , pin , max_port );
1044
+ spin_lock_irqsave (& pctrl -> lock , flags );
1045
+ val = readb (pctrl -> base + ETH_MODE );
1046
+ if (oen )
1047
+ val &= ~BIT (bit );
1048
+ else
1049
+ val |= BIT (bit );
1050
+ writeb (val , pctrl -> base + ETH_MODE );
1051
+ spin_unlock_irqrestore (& pctrl -> lock , flags );
1034
1052
1035
- return !( readb ( pctrl -> base + ETH_MODE ) & BIT ( bit )) ;
1053
+ return 0 ;
1036
1054
}
1037
1055
1038
- static int rzg2l_write_oen (struct rzg2l_pinctrl * pctrl , u32 caps , u32 offset , u8 pin , u8 oen )
1056
+ static int rzg3s_pin_to_oen_bit (struct rzg2l_pinctrl * pctrl , unsigned int _pin )
1039
1057
{
1040
- u8 max_port = pctrl -> data -> hwcfg -> oen_max_port ;
1041
- u8 max_pin = pctrl -> data -> hwcfg -> oen_max_pin ;
1042
- unsigned long flags ;
1043
- u8 val , bit ;
1058
+ u64 * pin_data = pctrl -> desc .pins [_pin ].drv_data ;
1059
+ u8 port , pin , bit ;
1044
1060
1045
- if (! rzg2l_oen_is_supported ( caps , pin , max_pin ) )
1061
+ if (* pin_data & RZG2L_SINGLE_PIN )
1046
1062
return - EINVAL ;
1047
1063
1048
- bit = rzg2l_pin_to_oen_bit (offset , pin , max_port );
1064
+ port = RZG2L_PIN_ID_TO_PORT (_pin );
1065
+ pin = RZG2L_PIN_ID_TO_PIN (_pin );
1066
+ if (pin > pctrl -> data -> hwcfg -> oen_max_pin )
1067
+ return - EINVAL ;
1068
+
1069
+ bit = pin * 2 ;
1070
+ if (port == pctrl -> data -> hwcfg -> oen_max_port )
1071
+ bit += 1 ;
1072
+
1073
+ return bit ;
1074
+ }
1075
+
1076
+ static u32 rzg3s_oen_read (struct rzg2l_pinctrl * pctrl , unsigned int _pin )
1077
+ {
1078
+ int bit ;
1079
+
1080
+ bit = rzg3s_pin_to_oen_bit (pctrl , _pin );
1081
+ if (bit < 0 )
1082
+ return bit ;
1083
+
1084
+ return !(readb (pctrl -> base + ETH_MODE ) & BIT (bit ));
1085
+ }
1086
+
1087
+ static int rzg3s_oen_write (struct rzg2l_pinctrl * pctrl , unsigned int _pin , u8 oen )
1088
+ {
1089
+ unsigned long flags ;
1090
+ int bit ;
1091
+ u8 val ;
1092
+
1093
+ bit = rzg3s_pin_to_oen_bit (pctrl , _pin );
1094
+ if (bit < 0 )
1095
+ return bit ;
1049
1096
1050
1097
spin_lock_irqsave (& pctrl -> lock , flags );
1051
1098
val = readb (pctrl -> base + ETH_MODE );
@@ -1124,12 +1171,12 @@ static int rzv2h_bias_param_to_hw(enum pin_config_param param)
1124
1171
return - EINVAL ;
1125
1172
}
1126
1173
1127
- static u8 rzv2h_pin_to_oen_bit (struct rzg2l_pinctrl * pctrl , u32 offset )
1174
+ static u8 rzv2h_pin_to_oen_bit (struct rzg2l_pinctrl * pctrl , unsigned int _pin )
1128
1175
{
1129
1176
static const char * const pin_names [] = { "ET0_TXC_TXCLK" , "ET1_TXC_TXCLK" ,
1130
1177
"XSPI0_RESET0N" , "XSPI0_CS0N" ,
1131
1178
"XSPI0_CKN" , "XSPI0_CKP" };
1132
- const struct pinctrl_pin_desc * pin_desc = & pctrl -> desc .pins [offset ];
1179
+ const struct pinctrl_pin_desc * pin_desc = & pctrl -> desc .pins [_pin ];
1133
1180
unsigned int i ;
1134
1181
1135
1182
for (i = 0 ; i < ARRAY_SIZE (pin_names ); i ++ ) {
@@ -1141,30 +1188,24 @@ static u8 rzv2h_pin_to_oen_bit(struct rzg2l_pinctrl *pctrl, u32 offset)
1141
1188
return 0 ;
1142
1189
}
1143
1190
1144
- static u32 rzv2h_oen_read (struct rzg2l_pinctrl * pctrl , u32 caps , u32 offset , u8 pin )
1191
+ static u32 rzv2h_oen_read (struct rzg2l_pinctrl * pctrl , unsigned int _pin )
1145
1192
{
1146
1193
u8 bit ;
1147
1194
1148
- if (!(caps & PIN_CFG_OEN ))
1149
- return 0 ;
1150
-
1151
- bit = rzv2h_pin_to_oen_bit (pctrl , offset );
1195
+ bit = rzv2h_pin_to_oen_bit (pctrl , _pin );
1152
1196
1153
1197
return !(readb (pctrl -> base + PFC_OEN ) & BIT (bit ));
1154
1198
}
1155
1199
1156
- static int rzv2h_oen_write (struct rzg2l_pinctrl * pctrl , u32 caps , u32 offset , u8 pin , u8 oen )
1200
+ static int rzv2h_oen_write (struct rzg2l_pinctrl * pctrl , unsigned int _pin , u8 oen )
1157
1201
{
1158
1202
const struct rzg2l_hwcfg * hwcfg = pctrl -> data -> hwcfg ;
1159
1203
const struct rzg2l_register_offsets * regs = & hwcfg -> regs ;
1160
1204
unsigned long flags ;
1161
1205
u8 val , bit ;
1162
1206
u8 pwpr ;
1163
1207
1164
- if (!(caps & PIN_CFG_OEN ))
1165
- return - EINVAL ;
1166
-
1167
- bit = rzv2h_pin_to_oen_bit (pctrl , offset );
1208
+ bit = rzv2h_pin_to_oen_bit (pctrl , _pin );
1168
1209
spin_lock_irqsave (& pctrl -> lock , flags );
1169
1210
val = readb (pctrl -> base + PFC_OEN );
1170
1211
if (oen )
@@ -1220,7 +1261,9 @@ static int rzg2l_pinctrl_pinconf_get(struct pinctrl_dev *pctldev,
1220
1261
break ;
1221
1262
1222
1263
case PIN_CONFIG_OUTPUT_ENABLE :
1223
- arg = pctrl -> data -> oen_read (pctrl , cfg , _pin , bit );
1264
+ if (!pctrl -> data -> oen_read || !(cfg & PIN_CFG_OEN ))
1265
+ return - EOPNOTSUPP ;
1266
+ arg = pctrl -> data -> oen_read (pctrl , _pin );
1224
1267
if (!arg )
1225
1268
return - EINVAL ;
1226
1269
break ;
@@ -1359,7 +1402,9 @@ static int rzg2l_pinctrl_pinconf_set(struct pinctrl_dev *pctldev,
1359
1402
1360
1403
case PIN_CONFIG_OUTPUT_ENABLE :
1361
1404
arg = pinconf_to_config_argument (_configs [i ]);
1362
- ret = pctrl -> data -> oen_write (pctrl , cfg , _pin , bit , !!arg );
1405
+ if (!pctrl -> data -> oen_write || !(cfg & PIN_CFG_OEN ))
1406
+ return - EOPNOTSUPP ;
1407
+ ret = pctrl -> data -> oen_write (pctrl , _pin , !!arg );
1363
1408
if (ret )
1364
1409
return ret ;
1365
1410
break ;
@@ -1784,7 +1829,7 @@ static const u64 r9a07g044_gpio_configs[] = {
1784
1829
RZG2L_GPIO_PORT_PACK (3 , 0x21 , RZG2L_MPXED_PIN_FUNCS ),
1785
1830
RZG2L_GPIO_PORT_PACK (2 , 0x22 , RZG2L_MPXED_PIN_FUNCS ),
1786
1831
RZG2L_GPIO_PORT_PACK (2 , 0x23 , RZG2L_MPXED_PIN_FUNCS ),
1787
- RZG2L_GPIO_PORT_PACK (3 , 0x24 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
1832
+ RZG2L_GPIO_PORT_PACK (3 , 0x24 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 ) | PIN_CFG_OEN ),
1788
1833
RZG2L_GPIO_PORT_PACK (2 , 0x25 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
1789
1834
RZG2L_GPIO_PORT_PACK (2 , 0x26 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
1790
1835
RZG2L_GPIO_PORT_PACK (2 , 0x27 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
@@ -1793,7 +1838,7 @@ static const u64 r9a07g044_gpio_configs[] = {
1793
1838
RZG2L_GPIO_PORT_PACK (2 , 0x2a , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
1794
1839
RZG2L_GPIO_PORT_PACK (2 , 0x2b , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
1795
1840
RZG2L_GPIO_PORT_PACK (2 , 0x2c , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
1796
- RZG2L_GPIO_PORT_PACK (2 , 0x2d , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH1 )),
1841
+ RZG2L_GPIO_PORT_PACK (2 , 0x2d , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH1 ) | PIN_CFG_OEN ),
1797
1842
RZG2L_GPIO_PORT_PACK (2 , 0x2e , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH1 )),
1798
1843
RZG2L_GPIO_PORT_PACK (2 , 0x2f , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH1 )),
1799
1844
RZG2L_GPIO_PORT_PACK (2 , 0x30 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH1 )),
@@ -1817,13 +1862,13 @@ static const u64 r9a07g044_gpio_configs[] = {
1817
1862
1818
1863
static const u64 r9a07g043_gpio_configs [] = {
1819
1864
RZG2L_GPIO_PORT_PACK (4 , 0x10 , RZG2L_MPXED_PIN_FUNCS ),
1820
- RZG2L_GPIO_PORT_PACK (5 , 0x11 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
1865
+ RZG2L_GPIO_PORT_PACK (5 , 0x11 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 ) | PIN_CFG_OEN ),
1821
1866
RZG2L_GPIO_PORT_PACK (4 , 0x12 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
1822
1867
RZG2L_GPIO_PORT_PACK (4 , 0x13 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
1823
1868
RZG2L_GPIO_PORT_PACK (6 , 0x14 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
1824
1869
RZG2L_GPIO_PORT_PACK (5 , 0x15 , RZG2L_MPXED_PIN_FUNCS ),
1825
1870
RZG2L_GPIO_PORT_PACK (5 , 0x16 , RZG2L_MPXED_PIN_FUNCS ),
1826
- RZG2L_GPIO_PORT_PACK (5 , 0x17 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH1 )),
1871
+ RZG2L_GPIO_PORT_PACK (5 , 0x17 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH1 ) | PIN_CFG_OEN ),
1827
1872
RZG2L_GPIO_PORT_PACK (5 , 0x18 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH1 )),
1828
1873
RZG2L_GPIO_PORT_PACK (4 , 0x19 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH1 )),
1829
1874
RZG2L_GPIO_PORT_PACK (5 , 0x1a , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH1 )),
@@ -3016,6 +3061,7 @@ static const struct rzg2l_hwcfg rzg2l_hwcfg = {
3016
3061
[RZG2L_IOLH_IDX_3V3 ] = 2000 , 4000 , 8000 , 12000 ,
3017
3062
},
3018
3063
.iolh_groupb_oi = { 100 , 66 , 50 , 33 , },
3064
+ .oen_max_pin = 0 ,
3019
3065
};
3020
3066
3021
3067
static const struct rzg2l_hwcfg rzg3s_hwcfg = {
@@ -3103,8 +3149,8 @@ static struct rzg2l_pinctrl_data r9a08g045_data = {
3103
3149
.hwcfg = & rzg3s_hwcfg ,
3104
3150
.pwpr_pfc_lock_unlock = & rzg2l_pwpr_pfc_lock_unlock ,
3105
3151
.pmc_writeb = & rzg2l_pmc_writeb ,
3106
- .oen_read = & rzg2l_read_oen ,
3107
- .oen_write = & rzg2l_write_oen ,
3152
+ .oen_read = & rzg3s_oen_read ,
3153
+ .oen_write = & rzg3s_oen_write ,
3108
3154
.hw_to_bias_param = & rzg2l_hw_to_bias_param ,
3109
3155
.bias_param_to_hw = & rzg2l_bias_param_to_hw ,
3110
3156
};
0 commit comments