@@ -999,6 +999,60 @@ static bool rzg2l_ds_is_supported(struct rzg2l_pinctrl *pctrl, u32 caps,
999
999
return false;
1000
1000
}
1001
1001
1002
+ static int rzg2l_pin_to_oen_bit (struct rzg2l_pinctrl * pctrl , unsigned int _pin )
1003
+ {
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 );
1007
+
1008
+ if (pin > pctrl -> data -> hwcfg -> oen_max_pin )
1009
+ return - EINVAL ;
1010
+
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 ;
1021
+ }
1022
+
1023
+ static u32 rzg2l_read_oen (struct rzg2l_pinctrl * pctrl , unsigned int _pin )
1024
+ {
1025
+ int bit ;
1026
+
1027
+ bit = rzg2l_pin_to_oen_bit (pctrl , _pin );
1028
+ if (bit < 0 )
1029
+ return 0 ;
1030
+
1031
+ return !(readb (pctrl -> base + ETH_MODE ) & BIT (bit ));
1032
+ }
1033
+
1034
+ static int rzg2l_write_oen (struct rzg2l_pinctrl * pctrl , unsigned int _pin , u8 oen )
1035
+ {
1036
+ unsigned long flags ;
1037
+ int bit ;
1038
+ u8 val ;
1039
+
1040
+ bit = rzg2l_pin_to_oen_bit (pctrl , _pin );
1041
+ if (bit < 0 )
1042
+ return bit ;
1043
+
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 );
1052
+
1053
+ return 0 ;
1054
+ }
1055
+
1002
1056
static int rzg3s_pin_to_oen_bit (struct rzg2l_pinctrl * pctrl , unsigned int _pin )
1003
1057
{
1004
1058
u64 * pin_data = pctrl -> desc .pins [_pin ].drv_data ;
@@ -1775,7 +1829,7 @@ static const u64 r9a07g044_gpio_configs[] = {
1775
1829
RZG2L_GPIO_PORT_PACK (3 , 0x21 , RZG2L_MPXED_PIN_FUNCS ),
1776
1830
RZG2L_GPIO_PORT_PACK (2 , 0x22 , RZG2L_MPXED_PIN_FUNCS ),
1777
1831
RZG2L_GPIO_PORT_PACK (2 , 0x23 , RZG2L_MPXED_PIN_FUNCS ),
1778
- 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 ),
1779
1833
RZG2L_GPIO_PORT_PACK (2 , 0x25 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
1780
1834
RZG2L_GPIO_PORT_PACK (2 , 0x26 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
1781
1835
RZG2L_GPIO_PORT_PACK (2 , 0x27 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
@@ -1784,7 +1838,7 @@ static const u64 r9a07g044_gpio_configs[] = {
1784
1838
RZG2L_GPIO_PORT_PACK (2 , 0x2a , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
1785
1839
RZG2L_GPIO_PORT_PACK (2 , 0x2b , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
1786
1840
RZG2L_GPIO_PORT_PACK (2 , 0x2c , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
1787
- 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 ),
1788
1842
RZG2L_GPIO_PORT_PACK (2 , 0x2e , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH1 )),
1789
1843
RZG2L_GPIO_PORT_PACK (2 , 0x2f , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH1 )),
1790
1844
RZG2L_GPIO_PORT_PACK (2 , 0x30 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH1 )),
@@ -1808,13 +1862,13 @@ static const u64 r9a07g044_gpio_configs[] = {
1808
1862
1809
1863
static const u64 r9a07g043_gpio_configs [] = {
1810
1864
RZG2L_GPIO_PORT_PACK (4 , 0x10 , RZG2L_MPXED_PIN_FUNCS ),
1811
- 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 ),
1812
1866
RZG2L_GPIO_PORT_PACK (4 , 0x12 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
1813
1867
RZG2L_GPIO_PORT_PACK (4 , 0x13 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
1814
1868
RZG2L_GPIO_PORT_PACK (6 , 0x14 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH0 )),
1815
1869
RZG2L_GPIO_PORT_PACK (5 , 0x15 , RZG2L_MPXED_PIN_FUNCS ),
1816
1870
RZG2L_GPIO_PORT_PACK (5 , 0x16 , RZG2L_MPXED_PIN_FUNCS ),
1817
- 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 ),
1818
1872
RZG2L_GPIO_PORT_PACK (5 , 0x18 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH1 )),
1819
1873
RZG2L_GPIO_PORT_PACK (4 , 0x19 , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH1 )),
1820
1874
RZG2L_GPIO_PORT_PACK (5 , 0x1a , RZG2L_MPXED_ETH_PIN_FUNCS (PIN_CFG_IO_VMC_ETH1 )),
@@ -3007,6 +3061,7 @@ static const struct rzg2l_hwcfg rzg2l_hwcfg = {
3007
3061
[RZG2L_IOLH_IDX_3V3 ] = 2000 , 4000 , 8000 , 12000 ,
3008
3062
},
3009
3063
.iolh_groupb_oi = { 100 , 66 , 50 , 33 , },
3064
+ .oen_max_pin = 0 ,
3010
3065
};
3011
3066
3012
3067
static const struct rzg2l_hwcfg rzg3s_hwcfg = {
@@ -3061,6 +3116,8 @@ static struct rzg2l_pinctrl_data r9a07g043_data = {
3061
3116
#endif
3062
3117
.pwpr_pfc_lock_unlock = & rzg2l_pwpr_pfc_lock_unlock ,
3063
3118
.pmc_writeb = & rzg2l_pmc_writeb ,
3119
+ .oen_read = & rzg2l_read_oen ,
3120
+ .oen_write = & rzg2l_write_oen ,
3064
3121
.hw_to_bias_param = & rzg2l_hw_to_bias_param ,
3065
3122
.bias_param_to_hw = & rzg2l_bias_param_to_hw ,
3066
3123
};
@@ -3076,6 +3133,8 @@ static struct rzg2l_pinctrl_data r9a07g044_data = {
3076
3133
.hwcfg = & rzg2l_hwcfg ,
3077
3134
.pwpr_pfc_lock_unlock = & rzg2l_pwpr_pfc_lock_unlock ,
3078
3135
.pmc_writeb = & rzg2l_pmc_writeb ,
3136
+ .oen_read = & rzg2l_read_oen ,
3137
+ .oen_write = & rzg2l_write_oen ,
3079
3138
.hw_to_bias_param = & rzg2l_hw_to_bias_param ,
3080
3139
.bias_param_to_hw = & rzg2l_bias_param_to_hw ,
3081
3140
};
0 commit comments