net: stmmac: ingenic: convert to set_phy_intf_sel()
Subsystems (4)
v2 cover net: stmmac: ingenic: convert to set_phy_intf_sel()
On Wed, Nov 05, 2025 at 01:25:54PM +0000, Russell King (Oracle) wrote:
Convert ingenic to use the new ->set_phy_intf_sel() method that was recently introduced in net-next.
This is the largest of the conversions, as there is scope for cleanups along with the conversion.
v2: fix build warnings in patch 9 by rearranging the code
.../net/ethernet/stmicro/stmmac/dwmac-ingenic.c | 165 ++++++--------------- 1 file changed, 45 insertions(+), 120 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
PATCH v2 1/11 net: stmmac: ingenic: move ingenic_mac_init()
Move ingenic_mac_init() to between variant specific set_mode() implementations and ingenic_mac_probe(). No code changes.
--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +14 -14
@@ -71,20 +71,6 @@ struct ingenic_soc_info {int (*set_mode)(struct plat_stmmacenet_data *plat_dat); }; -static int ingenic_mac_init (struct platform_device *pdev,void *bsp_priv) -{ -struct ingenic_mac *mac = bsp_priv; -int ret; - -if (mac->soc_info->set_mode) { - ret = mac->soc_info->set_mode (mac->plat_dat); -if (ret) -return ret; - } - -return 0 ; -} -static int jz4775_mac_set_mode (struct plat_stmmacenet_data *plat_dat) {struct ingenic_mac *mac = plat_dat->bsp_priv;
@@ -234,6 +220,20 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); } +static int ingenic_mac_init (struct platform_device *pdev,void *bsp_priv) +{ +struct ingenic_mac *mac = bsp_priv; +int ret; + +if (mac->soc_info->set_mode) { + ret = mac->soc_info->set_mode (mac->plat_dat); +if (ret) +return ret; + } + +return 0 ; +} +static int ingenic_mac_probe (struct platform_device *pdev) {struct plat_stmmacenet_data *plat_dat;
Signature · 1 line
2.47.3
PATCH v2 2/11 net: stmmac: ingenic: simplify jz4775 mac_set_mode()
In reply to Russell King (Oracle)All paths configure the transmit clock as an input. Move this out of the switch() statement to simplify the code.
--- .../net/ethernet/stmicro/stmmac/dwmac-ingenic.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +6 -8
@@ -78,20 +78,17 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_MII : - val =FIELD_PREP (MACPHYC_TXCLK_SEL_MASK ,MACPHYC_TXCLK_SEL_INPUT ) | -FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_MII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_MII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_MII\n" );break ;case PHY_INTERFACE_MODE_GMII : - val =FIELD_PREP (MACPHYC_TXCLK_SEL_MASK ,MACPHYC_TXCLK_SEL_INPUT ) | -FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_GMII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_GMII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_GMII\n" );break ;case PHY_INTERFACE_MODE_RMII : - val =FIELD_PREP (MACPHYC_TXCLK_SEL_MASK ,MACPHYC_TXCLK_SEL_INPUT ) | -FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RMII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RMII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;
@@ -99,8 +96,7 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)case PHY_INTERFACE_MODE_RGMII_ID :case PHY_INTERFACE_MODE_RGMII_TXID :case PHY_INTERFACE_MODE_RGMII_RXID : - val =FIELD_PREP (MACPHYC_TXCLK_SEL_MASK ,MACPHYC_TXCLK_SEL_INPUT ) | -FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RGMII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RGMII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RGMII\n" );break ;
@@ -110,6 +106,8 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return -EINVAL ; } + val |=FIELD_PREP (MACPHYC_TXCLK_SEL_MASK ,MACPHYC_TXCLK_SEL_INPUT ); +/* Update MAC PHY control register */ return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); }
Signature · 1 line
2.47.3
PATCH v2 3/11 net: stmmac: ingenic: use PHY_INTF_SEL_xxx to select PHY interface
In reply to Russell King (Oracle)Use the common dwmac definitions for the PHY interface selection field.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +4 -4
@@ -35,10 +35,10 @@#define MACPHYC_RX_DELAY_MASK GENMASK(10, 4)#define MACPHYC_SOFT_RST_MASK GENMASK(3, 3)#define MACPHYC_PHY_INFT_MASK GENMASK(2, 0) -#define MACPHYC_PHY_INFT_RMII 0x4 -#define MACPHYC_PHY_INFT_RGMII 0x1 -#define MACPHYC_PHY_INFT_GMII 0x0 -#define MACPHYC_PHY_INFT_MII 0x0 +#define MACPHYC_PHY_INFT_RMII PHY_INTF_SEL_RMII +#define MACPHYC_PHY_INFT_RGMII PHY_INTF_SEL_RGMII +#define MACPHYC_PHY_INFT_GMII PHY_INTF_SEL_GMII_MII +#define MACPHYC_PHY_INFT_MII PHY_INTF_SEL_GMII_MII#define MACPHYC_TX_DELAY_PS_MAX 2496#define MACPHYC_TX_DELAY_PS_MIN 20
Signature · 1 line
2.47.3
PATCH v2 4/11 net: stmmac: ingenic: use PHY_INTF_SEL_x directly
In reply to Russell King (Oracle)Use the PHY_INTF_SEL_x values directly in each of the mac_set_mode methods rather than the driver private MACPHYC_PHY_INFT_x definitions. Remove the MACPHYC_PHY_INFT_x definitions.
--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +8 -12
@@ -35,10 +35,6 @@#define MACPHYC_RX_DELAY_MASK GENMASK(10, 4)#define MACPHYC_SOFT_RST_MASK GENMASK(3, 3)#define MACPHYC_PHY_INFT_MASK GENMASK(2, 0) -#define MACPHYC_PHY_INFT_RMII PHY_INTF_SEL_RMII -#define MACPHYC_PHY_INFT_RGMII PHY_INTF_SEL_RGMII -#define MACPHYC_PHY_INFT_GMII PHY_INTF_SEL_GMII_MII -#define MACPHYC_PHY_INFT_MII PHY_INTF_SEL_GMII_MII#define MACPHYC_TX_DELAY_PS_MAX 2496#define MACPHYC_TX_DELAY_PS_MIN 20
@@ -78,17 +74,17 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_MII : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_MII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_GMII_MII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_MII\n" );break ;case PHY_INTERFACE_MODE_GMII : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_GMII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_GMII_MII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_GMII\n" );break ;case PHY_INTERFACE_MODE_RMII : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RMII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RMII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;
@@ -96,7 +92,7 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)case PHY_INTERFACE_MODE_RGMII_ID :case PHY_INTERFACE_MODE_RGMII_TXID :case PHY_INTERFACE_MODE_RGMII_RXID : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RGMII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RGMII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RGMII\n" );break ;
@@ -138,7 +134,7 @@ static int x1600_mac_set_mode(struct plat_stmmacenet_data *plat_dat)switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RMII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RMII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;
@@ -160,7 +156,7 @@ static int x1830_mac_set_mode(struct plat_stmmacenet_data *plat_dat)switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : val =FIELD_PREP (MACPHYC_MODE_SEL_MASK ,MACPHYC_MODE_SEL_RMII ) | -FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RMII ); +FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RMII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;
@@ -183,7 +179,7 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)case PHY_INTERFACE_MODE_RMII : val =FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN ) |FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_ORIGIN ) | -FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RMII ); +FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RMII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;
@@ -191,7 +187,7 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)case PHY_INTERFACE_MODE_RGMII_ID :case PHY_INTERFACE_MODE_RGMII_TXID :case PHY_INTERFACE_MODE_RGMII_RXID : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RGMII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RGMII );if (mac->tx_delay ==0 ) val |=FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN );
Signature · 1 line
2.47.3
PATCH v2 5/11 net: stmmac: ingenic: prep PHY_INTF_SEL_x field after switch()
In reply to Russell King (Oracle)Move the preparation of the PHY_INTF_SEL_x bitfield out of the switch() statement such that it only appears once.
--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +23 -11
@@ -71,20 +71,21 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat) {struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; +u8 phy_intf_sel;switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_MII : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_GMII_MII ); + phy_intf_sel =PHY_INTF_SEL_GMII_MII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_MII\n" );break ;case PHY_INTERFACE_MODE_GMII : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_GMII_MII ); + phy_intf_sel =PHY_INTF_SEL_GMII_MII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_GMII\n" );break ;case PHY_INTERFACE_MODE_RMII : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RMII ); + phy_intf_sel =PHY_INTF_SEL_RMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;
@@ -92,7 +93,7 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)case PHY_INTERFACE_MODE_RGMII_ID :case PHY_INTERFACE_MODE_RGMII_TXID :case PHY_INTERFACE_MODE_RGMII_RXID : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RGMII ); + phy_intf_sel =PHY_INTF_SEL_RGMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RGMII\n" );break ;
@@ -102,7 +103,8 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return -EINVAL ; } - val |=FIELD_PREP (MACPHYC_TXCLK_SEL_MASK ,MACPHYC_TXCLK_SEL_INPUT ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel) | +FIELD_PREP (MACPHYC_TXCLK_SEL_MASK ,MACPHYC_TXCLK_SEL_INPUT );/* Update MAC PHY control register */ return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val);
@@ -131,10 +133,11 @@ static int x1600_mac_set_mode(struct plat_stmmacenet_data *plat_dat) {struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; +u8 phy_intf_sel;switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RMII ); + phy_intf_sel =PHY_INTF_SEL_RMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;
@@ -144,6 +147,8 @@ static int x1600_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return -EINVAL ; } + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel); +/* Update MAC PHY control register */ return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); }
@@ -152,11 +157,12 @@ static int x1830_mac_set_mode(struct plat_stmmacenet_data *plat_dat) {struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; +u8 phy_intf_sel;switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : - val =FIELD_PREP (MACPHYC_MODE_SEL_MASK ,MACPHYC_MODE_SEL_RMII ) | -FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RMII ); + val =FIELD_PREP (MACPHYC_MODE_SEL_MASK ,MACPHYC_MODE_SEL_RMII ); + phy_intf_sel =PHY_INTF_SEL_RMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;
@@ -166,6 +172,8 @@ static int x1830_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return -EINVAL ; } + val |=FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel); +/* Update MAC PHY control register */ return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); }
@@ -174,12 +182,13 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat) {struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; +u8 phy_intf_sel;switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : val =FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN ) | -FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_ORIGIN ) | -FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RMII ); +FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_ORIGIN ); + phy_intf_sel =PHY_INTF_SEL_RMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;
@@ -187,7 +196,8 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)case PHY_INTERFACE_MODE_RGMII_ID :case PHY_INTERFACE_MODE_RGMII_TXID :case PHY_INTERFACE_MODE_RGMII_RXID : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RGMII ); + val =0 ; + phy_intf_sel =PHY_INTF_SEL_RGMII ;if (mac->tx_delay ==0 ) val |=FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN );
@@ -210,6 +220,8 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return -EINVAL ; } + val |=FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel); +/* Update MAC PHY control register */ return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); }
Signature · 1 line
2.47.3
PATCH v2 6/11 net: stmmac: ingenic: use stmmac_get_phy_intf_sel()
In reply to Russell King (Oracle)Use stmmac_get_phy_intf_sel() to decode the PHY interface mode to the phy_intf_sel value, validate the result against the SoC specific supported phy_intf_sel values, and pass into the SoC specific set_mode() methods, replacing the local phy_intf_sel variable. This provides the value for the MACPHYC_PHY_INFT_MASK field.
--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 55 ++++++++++++------- 1 file changed, 34 insertions(+), 21 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +34 -21
@@ -64,28 +64,27 @@ struct ingenic_soc_info {enum ingenic_mac_version version;u32 mask; -int (*set_mode)(struct plat_stmmacenet_data *plat_dat); +int (*set_mode)(struct plat_stmmacenet_data *plat_dat,u8 phy_intf_sel); + +u8 valid_phy_intf_sel; }; -static int jz4775_mac_set_mode (struct plat_stmmacenet_data *plat_dat) +static int jz4775_mac_set_mode (struct plat_stmmacenet_data *plat_dat, +u8 phy_intf_sel) {struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; -u8 phy_intf_sel;switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_MII : - phy_intf_sel =PHY_INTF_SEL_GMII_MII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_MII\n" );break ;case PHY_INTERFACE_MODE_GMII : - phy_intf_sel =PHY_INTF_SEL_GMII_MII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_GMII\n" );break ;case PHY_INTERFACE_MODE_RMII : - phy_intf_sel =PHY_INTF_SEL_RMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;
@@ -93,7 +92,6 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)case PHY_INTERFACE_MODE_RGMII_ID :case PHY_INTERFACE_MODE_RGMII_TXID :case PHY_INTERFACE_MODE_RGMII_RXID : - phy_intf_sel =PHY_INTF_SEL_RGMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RGMII\n" );break ;
@@ -110,7 +108,8 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); } -static int x1000_mac_set_mode (struct plat_stmmacenet_data *plat_dat) +static int x1000_mac_set_mode (struct plat_stmmacenet_data *plat_dat, +u8 phy_intf_sel) {struct ingenic_mac *mac = plat_dat->bsp_priv;
@@ -129,15 +128,14 @@ static int x1000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask,0 ); } -static int x1600_mac_set_mode (struct plat_stmmacenet_data *plat_dat) +static int x1600_mac_set_mode (struct plat_stmmacenet_data *plat_dat, +u8 phy_intf_sel) {struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; -u8 phy_intf_sel;switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : - phy_intf_sel =PHY_INTF_SEL_RMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;
@@ -153,16 +151,15 @@ static int x1600_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); } -static int x1830_mac_set_mode (struct plat_stmmacenet_data *plat_dat) +static int x1830_mac_set_mode (struct plat_stmmacenet_data *plat_dat, +u8 phy_intf_sel) {struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; -u8 phy_intf_sel;switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : val =FIELD_PREP (MACPHYC_MODE_SEL_MASK ,MACPHYC_MODE_SEL_RMII ); - phy_intf_sel =PHY_INTF_SEL_RMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;
@@ -178,17 +175,16 @@ static int x1830_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); } -static int x2000_mac_set_mode (struct plat_stmmacenet_data *plat_dat) +static int x2000_mac_set_mode (struct plat_stmmacenet_data *plat_dat, +u8 phy_intf_sel) {struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; -u8 phy_intf_sel;switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : val =FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN ) |FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_ORIGIN ); - phy_intf_sel =PHY_INTF_SEL_RMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;
@@ -197,8 +193,6 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)case PHY_INTERFACE_MODE_RGMII_TXID :case PHY_INTERFACE_MODE_RGMII_RXID : val =0 ; - phy_intf_sel =PHY_INTF_SEL_RGMII ; -if (mac->tx_delay ==0 ) val |=FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN );else
@@ -229,10 +223,21 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)static int ingenic_mac_init (struct platform_device *pdev,void *bsp_priv) {struct ingenic_mac *mac = bsp_priv; -int ret; +phy_interface_t interface; +int phy_intf_sel, ret;if (mac->soc_info->set_mode) { - ret = mac->soc_info->set_mode (mac->plat_dat); + interface = mac->plat_dat->phy_interface; + + phy_intf_sel =stmmac_get_phy_intf_sel (interface); +if (phy_intf_sel <0 || phy_intf_sel >=BITS_PER_BYTE || + ~mac->soc_info->valid_phy_intf_sel &BIT (phy_intf_sel)) { +dev_err (mac->dev,"unsupported interface %s\n" , +phy_modes (interface)); +return phy_intf_sel <0 ? phy_intf_sel : -EINVAL ; + } + + ret = mac->soc_info->set_mode (mac->plat_dat, phy_intf_sel);if (ret)return ret; }
@@ -309,6 +314,9 @@ static struct ingenic_soc_info jz4775_soc_info = { .mask = MACPHYC_TXCLK_SEL_MASK | MACPHYC_SOFT_RST_MASK | MACPHYC_PHY_INFT_MASK, .set_mode = jz4775_mac_set_mode, + .valid_phy_intf_sel =BIT (PHY_INTF_SEL_GMII_MII ) | +BIT (PHY_INTF_SEL_RGMII ) | + BIT(PHY_INTF_SEL_RMII), };static struct ingenic_soc_info x1000_soc_info = {
@@ -316,6 +324,7 @@ static struct ingenic_soc_info x1000_soc_info = { .mask = MACPHYC_SOFT_RST_MASK, .set_mode = x1000_mac_set_mode, + .valid_phy_intf_sel = BIT(PHY_INTF_SEL_RMII), };static struct ingenic_soc_info x1600_soc_info = {
@@ -323,6 +332,7 @@ static struct ingenic_soc_info x1600_soc_info = { .mask = MACPHYC_SOFT_RST_MASK | MACPHYC_PHY_INFT_MASK, .set_mode = x1600_mac_set_mode, + .valid_phy_intf_sel = BIT(PHY_INTF_SEL_RMII), };static struct ingenic_soc_info x1830_soc_info = {
@@ -330,6 +340,7 @@ static struct ingenic_soc_info x1830_soc_info = { .mask = MACPHYC_MODE_SEL_MASK | MACPHYC_SOFT_RST_MASK | MACPHYC_PHY_INFT_MASK, .set_mode = x1830_mac_set_mode, + .valid_phy_intf_sel = BIT(PHY_INTF_SEL_RMII), };static struct ingenic_soc_info x2000_soc_info = {
@@ -338,6 +349,8 @@ static struct ingenic_soc_info x2000_soc_info = { MACPHYC_RX_DELAY_MASK | MACPHYC_SOFT_RST_MASK | MACPHYC_PHY_INFT_MASK, .set_mode = x2000_mac_set_mode, + .valid_phy_intf_sel =BIT (PHY_INTF_SEL_RGMII ) | + BIT(PHY_INTF_SEL_RMII), };static const struct of_device_id ingenic_mac_of_matches[] = {
Signature · 1 line
2.47.3
PATCH v2 7/11 net: stmmac: ingenic: move "MAC PHY control register" debug
In reply to Russell King (Oracle)Move the printing of the MAC PHY control register interface mode setting into ingenic_set_phy_intf_sel(), and use phy_modes() to print the string rather than using the enum name.
--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +3 -15
@@ -77,22 +77,12 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat,switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_MII : -dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_MII\n" ); -break ; -case PHY_INTERFACE_MODE_GMII : -dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_GMII\n" ); -break ; -case PHY_INTERFACE_MODE_RMII : -dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" ); -break ; -case PHY_INTERFACE_MODE_RGMII :case PHY_INTERFACE_MODE_RGMII_ID :case PHY_INTERFACE_MODE_RGMII_TXID :case PHY_INTERFACE_MODE_RGMII_RXID : -dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RGMII\n" );break ;default :
@@ -115,7 +105,6 @@ static int x1000_mac_set_mode(struct plat_stmmacenet_data *plat_dat,switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : -dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;default :
@@ -136,7 +125,6 @@ static int x1600_mac_set_mode(struct plat_stmmacenet_data *plat_dat,switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : -dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;default :
@@ -160,7 +148,6 @@ static int x1830_mac_set_mode(struct plat_stmmacenet_data *plat_dat,switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : val =FIELD_PREP (MACPHYC_MODE_SEL_MASK ,MACPHYC_MODE_SEL_RMII ); -dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;default :
@@ -185,7 +172,6 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat,case PHY_INTERFACE_MODE_RMII : val =FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN ) |FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_ORIGIN ); -dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;case PHY_INTERFACE_MODE_RGMII :
@@ -205,7 +191,6 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat, val |=FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_DELAY ) |FIELD_PREP (MACPHYC_RX_DELAY_MASK , (mac->rx_delay +9750 ) /19500 -1 ); -dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RGMII\n" );break ;default :
@@ -237,6 +222,9 @@ static int ingenic_mac_init(struct platform_device *pdev, void *bsp_priv)return phy_intf_sel <0 ? phy_intf_sel : -EINVAL ; } +dev_dbg (mac->dev,"MAC PHY control register: interface %s\n" , +phy_modes (interface)); + ret = mac->soc_info->set_mode (mac->plat_dat, phy_intf_sel);if (ret)return ret;
Signature · 1 line
2.47.3
PATCH v2 8/11 net: stmmac: ingenic: simplify mac_set_mode() methods
In reply to Russell King (Oracle)x1000, x1600 and x1830 only accept RMII mode. PHY_INTF_SEL_RMII is only selected with PHY_INTERFACE_MODE_RMII, and PHY_INTF_SEL_RMII has been validated by the SoC's .valid_phy_intf_sel bitmask. Thus, checking the interface mode in these functions becomes unnecessary. Remove these.
jz4775 is similar, except for a greater set of PHY_INTF_SEL_x valies. Also remove the switch statement here.
--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 50 +------------------ 1 file changed, 2 insertions(+), 48 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +2 -48
@@ -75,22 +75,6 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat,struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; -switch (plat_dat->phy_interface) { -case PHY_INTERFACE_MODE_MII : -case PHY_INTERFACE_MODE_GMII : -case PHY_INTERFACE_MODE_RMII : -case PHY_INTERFACE_MODE_RGMII : -case PHY_INTERFACE_MODE_RGMII_ID : -case PHY_INTERFACE_MODE_RGMII_TXID : -case PHY_INTERFACE_MODE_RGMII_RXID : -break ; - -default : -dev_err (mac->dev,"Unsupported interface %s\n" , -phy_modes (plat_dat->phy_interface)); -return -EINVAL ; - } - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel) |FIELD_PREP (MACPHYC_TXCLK_SEL_MASK ,MACPHYC_TXCLK_SEL_INPUT );
@@ -103,16 +87,6 @@ static int x1000_mac_set_mode(struct plat_stmmacenet_data *plat_dat, {struct ingenic_mac *mac = plat_dat->bsp_priv; -switch (plat_dat->phy_interface) { -case PHY_INTERFACE_MODE_RMII : -break ; - -default : -dev_err (mac->dev,"Unsupported interface %s\n" , -phy_modes (plat_dat->phy_interface)); -return -EINVAL ; - } -/* Update MAC PHY control register */ return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask,0 ); }
@@ -123,16 +97,6 @@ static int x1600_mac_set_mode(struct plat_stmmacenet_data *plat_dat,struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; -switch (plat_dat->phy_interface) { -case PHY_INTERFACE_MODE_RMII : -break ; - -default : -dev_err (mac->dev,"Unsupported interface %s\n" , -phy_modes (plat_dat->phy_interface)); -return -EINVAL ; - } - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel);/* Update MAC PHY control register */
@@ -145,18 +109,8 @@ static int x1830_mac_set_mode(struct plat_stmmacenet_data *plat_dat,struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; -switch (plat_dat->phy_interface) { -case PHY_INTERFACE_MODE_RMII : - val =FIELD_PREP (MACPHYC_MODE_SEL_MASK ,MACPHYC_MODE_SEL_RMII ); -break ; - -default : -dev_err (mac->dev,"Unsupported interface %s\n" , -phy_modes (plat_dat->phy_interface)); -return -EINVAL ; - } - - val |=FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel); + val =FIELD_PREP (MACPHYC_MODE_SEL_MASK ,MACPHYC_MODE_SEL_RMII ) | +FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel);/* Update MAC PHY control register */ return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val);
Signature · 1 line
2.47.3
PATCH v2 9/11 net: stmmac: ingenic: simplify x2000 mac_set_mode()
In reply to Russell King (Oracle)As per the previous commit, we have validated that the phy_intf_sel value is one that is permissible for this SoC, so there is no need to handle invalid PHY interface modes. We can also apply the other configuration based upon the phy_intf_sel value rather than the PHY interface mode.
--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +7 -21
@@ -122,39 +122,25 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat,struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; -switch (plat_dat->phy_interface) { -case PHY_INTERFACE_MODE_RMII : - val =FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN ) | -FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_ORIGIN ); -break ; - -case PHY_INTERFACE_MODE_RGMII : -case PHY_INTERFACE_MODE_RGMII_ID : -case PHY_INTERFACE_MODE_RGMII_TXID : -case PHY_INTERFACE_MODE_RGMII_RXID : - val =0 ; + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel); + +if (phy_intf_sel ==PHY_INTF_SEL_RMII ) { + val |=FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN ) | +FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_ORIGIN ); + }else if (phy_intf_sel ==PHY_INTF_SEL_RGMII ) {if (mac->tx_delay ==0 ) val |=FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN );else val |=FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_DELAY ) | -FIELD_PREP (MACPHYC_TX_DELAY_MASK , (mac->tx_delay +9750 ) /19500 -1 ); +FIELD_PREP (MACPHYC_TX_DELAY_MASK , (mac->tx_delay +9750 ) /19500 -1 );if (mac->rx_delay ==0 ) val |=FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_ORIGIN );else val |=FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_DELAY ) |FIELD_PREP (MACPHYC_RX_DELAY_MASK , (mac->rx_delay +9750 ) /19500 -1 ); - -break ; - -default : -dev_err (mac->dev,"Unsupported interface %s\n" , -phy_modes (plat_dat->phy_interface)); -return -EINVAL ; } - val |=FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel); -/* Update MAC PHY control register */ return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); }
Signature · 1 line
2.47.3
PATCH v2 10/11 net: stmmac: ingenic: pass ingenic_mac struct rather than plat_dat
In reply to Russell King (Oracle)It no longer makes sense to pass a pointer to struct plat_stmmacenet_data when calling the set_mode() methods to only use it to get a pointer to the ingenic_mac structure that we already had in the caller. Simplify this by passing the struct ingenic_mac pointer.
--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +7 -18
@@ -64,15 +64,13 @@ struct ingenic_soc_info {enum ingenic_mac_version version;u32 mask; -int (*set_mode)(struct plat_stmmacenet_data *plat_dat,u8 phy_intf_sel); +int (*set_mode)(struct ingenic_mac *mac,u8 phy_intf_sel);u8 valid_phy_intf_sel; }; -static int jz4775_mac_set_mode (struct plat_stmmacenet_data *plat_dat, -u8 phy_intf_sel) +static int jz4775_mac_set_mode (struct ingenic_mac *mac,u8 phy_intf_sel) { -struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; val = FIELD_PREP(MACPHYC_PHY_INFT_MASK, phy_intf_sel) |
@@ -82,19 +80,14 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat,return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); } -static int x1000_mac_set_mode (struct plat_stmmacenet_data *plat_dat, -u8 phy_intf_sel) +static int x1000_mac_set_mode (struct ingenic_mac *mac,u8 phy_intf_sel) { -struct ingenic_mac *mac = plat_dat->bsp_priv; -/* Update MAC PHY control register */ return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask,0 ); } -static int x1600_mac_set_mode (struct plat_stmmacenet_data *plat_dat, -u8 phy_intf_sel) +static int x1600_mac_set_mode (struct ingenic_mac *mac,u8 phy_intf_sel) { -struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; val =FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel);
@@ -103,10 +96,8 @@ static int x1600_mac_set_mode(struct plat_stmmacenet_data *plat_dat,return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); } -static int x1830_mac_set_mode (struct plat_stmmacenet_data *plat_dat, -u8 phy_intf_sel) +static int x1830_mac_set_mode (struct ingenic_mac *mac,u8 phy_intf_sel) { -struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; val = FIELD_PREP(MACPHYC_MODE_SEL_MASK, MACPHYC_MODE_SEL_RMII) |
@@ -116,10 +107,8 @@ static int x1830_mac_set_mode(struct plat_stmmacenet_data *plat_dat,return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); } -static int x2000_mac_set_mode (struct plat_stmmacenet_data *plat_dat, -u8 phy_intf_sel) +static int x2000_mac_set_mode (struct ingenic_mac *mac,u8 phy_intf_sel) { -struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; val =FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel);
@@ -165,7 +154,7 @@ static int ingenic_mac_init(struct platform_device *pdev, void *bsp_priv)dev_dbg (mac->dev,"MAC PHY control register: interface %s\n" ,phy_modes (interface)); - ret = mac->soc_info->set_mode (mac->plat_dat, phy_intf_sel); + ret = mac->soc_info->set_mode (mac, phy_intf_sel);if (ret)return ret; }
Signature · 1 line
2.47.3
PATCH v2 11/11 net: stmmac: ingenic: use ->set_phy_intf_sel()
In reply to Russell King (Oracle)Rather than placing the phy_intf_sel() setup in the ->init() method, move it to the new ->set_phy_intf_sel() method.
--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +11 -22
@@ -134,32 +134,21 @@ static int x2000_mac_set_mode(struct ingenic_mac *mac, u8 phy_intf_sel)return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); } -static int ingenic_mac_init (struct platform_device *pdev,void *bsp_priv) +static int ingenic_set_phy_intf_sel (void *bsp_priv,u8 phy_intf_sel) {struct ingenic_mac *mac = bsp_priv; -phy_interface_t interface; -int phy_intf_sel, ret; - -if (mac->soc_info->set_mode) { - interface = mac->plat_dat->phy_interface; - - phy_intf_sel =stmmac_get_phy_intf_sel (interface); -if (phy_intf_sel <0 || phy_intf_sel >=BITS_PER_BYTE || - ~mac->soc_info->valid_phy_intf_sel &BIT (phy_intf_sel)) { -dev_err (mac->dev,"unsupported interface %s\n" , -phy_modes (interface)); -return phy_intf_sel <0 ? phy_intf_sel : -EINVAL ; - } -dev_dbg (mac->dev,"MAC PHY control register: interface %s\n" , -phy_modes (interface)); +if (!mac->soc_info->set_mode) +return 0 ; - ret = mac->soc_info->set_mode (mac, phy_intf_sel); -if (ret) -return ret; - } +if (phy_intf_sel >=BITS_PER_BYTE || + ~mac->soc_info->valid_phy_intf_sel &BIT (phy_intf_sel)) +return phy_intf_sel <0 ? phy_intf_sel : -EINVAL ; + +dev_dbg (mac->dev,"MAC PHY control register: interface %s\n" , +phy_modes (mac->plat_dat->phy_interface)); -return 0 ; +return mac->soc_info->set_mode (mac, phy_intf_sel); }static int ingenic_mac_probe (struct platform_device *pdev)
@@ -221,7 +210,7 @@ static int ingenic_mac_probe(struct platform_device *pdev) mac->plat_dat = plat_dat; plat_dat->bsp_priv = mac; - plat_dat->init = ingenic_mac_init; + plat_dat->set_phy_intf_sel = ingenic_set_phy_intf_sel;return devm_stmmac_pltfr_probe (pdev, plat_dat, &stmmac_res); }
Signature · 1 line
2.47.3
Maxime Chevallier
maintainerHi Russell,
Quoted 4 lines · Russell King (Oracle)
On Wed, Nov 05, 2025 at 01:25:54PM +0000, Russell King (Oracle) wrote:
Convert ingenic to use the new ->set_phy_intf_sel() method that was recently introduced in net-next.
Quoted 8 lines
This is the largest of the conversions, as there is scope for cleanups along with the conversion.
v2: fix build warnings in patch 9 by rearranging the code
.../net/ethernet/stmicro/stmmac/dwmac-ingenic.c | 165 ++++++--------------- 1 file changed, 45 insertions(+), 120 deletions(-)
Damned, missed that V2 and started reviewing V1... I'll resend the tags for V2.
Maxime
Re: [PATCH net-next v2 01/11] net: stmmac: ingenic: move ingenic_mac_init()
In reply to Russell King (Oracle)Quoted 4 lines · Russell King (Oracle)
Move
ingenic_mac_init()to between variant specificset_mode()implementations andingenic_mac_probe(). No code changes.Signed-off-by Russell King (Oracle) <[email protected]>
Maxime
Quoted 50 lines
--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +14
-14@@ -71,20 +71,6 @@ struct ingenic_soc_info {int (*set_mode)(struct plat_stmmacenet_data *plat_dat); }; -static int ingenic_mac_init (struct platform_device *pdev,void *bsp_priv) -{ -struct ingenic_mac *mac = bsp_priv; -int ret; - -if (mac->soc_info->set_mode) { - ret = mac->soc_info->set_mode (mac->plat_dat); -if (ret) -return ret; - } - -return 0 ; -} -static int jz4775_mac_set_mode (struct plat_stmmacenet_data *plat_dat) {struct ingenic_mac *mac = plat_dat->bsp_priv;@@ -234,6 +220,20 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); } +static int ingenic_mac_init (struct platform_device *pdev,void *bsp_priv) +{ +struct ingenic_mac *mac = bsp_priv; +int ret; + +if (mac->soc_info->set_mode) { + ret = mac->soc_info->set_mode (mac->plat_dat); +if (ret) +return ret; + } + +return 0 ; +} +static int ingenic_mac_probe (struct platform_device *pdev) {struct plat_stmmacenet_data *plat_dat;
Re: [PATCH net-next v2 02/11] net: stmmac: ingenic: simplify jz4775 mac_set_mode()
In reply to Russell King (Oracle)Quoted 4 lines · Russell King (Oracle)
All paths configure the transmit clock as an input. Move this out of the
switch()statement to simplify the code.Signed-off-by Russell King (Oracle) <[email protected]>
Maxime
Quoted 51 lines
--- .../net/ethernet/stmicro/stmmac/dwmac-ingenic.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +6
-8@@ -78,20 +78,17 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_MII : - val =FIELD_PREP (MACPHYC_TXCLK_SEL_MASK ,MACPHYC_TXCLK_SEL_INPUT ) | -FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_MII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_MII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_MII\n" );break ;case PHY_INTERFACE_MODE_GMII : - val =FIELD_PREP (MACPHYC_TXCLK_SEL_MASK ,MACPHYC_TXCLK_SEL_INPUT ) | -FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_GMII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_GMII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_GMII\n" );break ;case PHY_INTERFACE_MODE_RMII : - val =FIELD_PREP (MACPHYC_TXCLK_SEL_MASK ,MACPHYC_TXCLK_SEL_INPUT ) | -FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RMII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RMII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;@@ -99,8 +96,7 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)case PHY_INTERFACE_MODE_RGMII_ID :case PHY_INTERFACE_MODE_RGMII_TXID :case PHY_INTERFACE_MODE_RGMII_RXID : - val =FIELD_PREP (MACPHYC_TXCLK_SEL_MASK ,MACPHYC_TXCLK_SEL_INPUT ) | -FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RGMII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RGMII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RGMII\n" );break ;@@ -110,6 +106,8 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return -EINVAL ; } + val |=FIELD_PREP (MACPHYC_TXCLK_SEL_MASK ,MACPHYC_TXCLK_SEL_INPUT ); +/* Update MAC PHY control register */ return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); }
Re: [PATCH net-next v2 03/11] net: stmmac: ingenic: use PHY_INTF_SEL_xxx to select PHY interface
In reply to Russell King (Oracle)Quoted 3 lines · Russell King (Oracle)
Use the common dwmac definitions for the PHY interface selection field.
Signed-off-by Russell King (Oracle) <[email protected]>
Maxime
Quoted 23 lines
--- drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +4
-4@@ -35,10 +35,10 @@#define MACPHYC_RX_DELAY_MASK GENMASK(10, 4)#define MACPHYC_SOFT_RST_MASK GENMASK(3, 3)#define MACPHYC_PHY_INFT_MASK GENMASK(2, 0) -#define MACPHYC_PHY_INFT_RMII 0x4 -#define MACPHYC_PHY_INFT_RGMII 0x1 -#define MACPHYC_PHY_INFT_GMII 0x0 -#define MACPHYC_PHY_INFT_MII 0x0 +#define MACPHYC_PHY_INFT_RMII PHY_INTF_SEL_RMII +#define MACPHYC_PHY_INFT_RGMII PHY_INTF_SEL_RGMII +#define MACPHYC_PHY_INFT_GMII PHY_INTF_SEL_GMII_MII +#define MACPHYC_PHY_INFT_MII PHY_INTF_SEL_GMII_MII#define MACPHYC_TX_DELAY_PS_MAX 2496#define MACPHYC_TX_DELAY_PS_MIN 20
Re: [PATCH net-next v2 04/11] net: stmmac: ingenic: use PHY_INTF_SEL_x directly
In reply to Russell King (Oracle)Quoted 5 lines · Russell King (Oracle)
Use the
PHY_INTF_SEL_xvalues directly in each of themac_set_modemethods rather than the driver privateMACPHYC_PHY_INFT_xdefinitions. Remove theMACPHYC_PHY_INFT_xdefinitions.Signed-off-by Russell King (Oracle) <[email protected]>
Maxime
Quoted 85 lines
--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +8
-12@@ -35,10 +35,6 @@#define MACPHYC_RX_DELAY_MASK GENMASK(10, 4)#define MACPHYC_SOFT_RST_MASK GENMASK(3, 3)#define MACPHYC_PHY_INFT_MASK GENMASK(2, 0) -#define MACPHYC_PHY_INFT_RMII PHY_INTF_SEL_RMII -#define MACPHYC_PHY_INFT_RGMII PHY_INTF_SEL_RGMII -#define MACPHYC_PHY_INFT_GMII PHY_INTF_SEL_GMII_MIIReviewed-by: Maxime Chevallier <[email protected]> -#define MACPHYC_PHY_INFT_MII PHY_INTF_SEL_GMII_MII#define MACPHYC_TX_DELAY_PS_MAX 2496#define MACPHYC_TX_DELAY_PS_MIN 20@@ -78,17 +74,17 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_MII : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_MII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_GMII_MII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_MII\n" );break ;case PHY_INTERFACE_MODE_GMII : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_GMII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_GMII_MII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_GMII\n" );break ;case PHY_INTERFACE_MODE_RMII : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RMII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RMII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;@@ -96,7 +92,7 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)case PHY_INTERFACE_MODE_RGMII_ID :case PHY_INTERFACE_MODE_RGMII_TXID :case PHY_INTERFACE_MODE_RGMII_RXID : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RGMII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RGMII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RGMII\n" );break ;@@ -138,7 +134,7 @@ static int x1600_mac_set_mode(struct plat_stmmacenet_data *plat_dat)switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RMII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RMII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;@@ -160,7 +156,7 @@ static int x1830_mac_set_mode(struct plat_stmmacenet_data *plat_dat)switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : val =FIELD_PREP (MACPHYC_MODE_SEL_MASK ,MACPHYC_MODE_SEL_RMII ) | -FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RMII ); +FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RMII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;@@ -183,7 +179,7 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)case PHY_INTERFACE_MODE_RMII : val =FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN ) |FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_ORIGIN ) | -FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RMII ); +FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RMII );dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;@@ -191,7 +187,7 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)case PHY_INTERFACE_MODE_RGMII_ID :case PHY_INTERFACE_MODE_RGMII_TXID :case PHY_INTERFACE_MODE_RGMII_RXID : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,MACPHYC_PHY_INFT_RGMII ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RGMII );if (mac->tx_delay ==0 ) val |=FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN );
Re: [PATCH net-next v2 05/11] net: stmmac: ingenic: prep PHY_INTF_SEL_x field after switch()
In reply to Russell King (Oracle)Quoted 4 lines · Russell King (Oracle)
Move the preparation of the
PHY_INTF_SEL_xbitfield out of theswitch()statement such that it only appears once.Signed-off-by Russell King (Oracle) <[email protected]>
Maxime
Quoted 133 lines
--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +23
-11@@ -71,20 +71,21 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat) {struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; +u8 phy_intf_sel;switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_MII : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_GMII_MII ); + phy_intf_sel =PHY_INTF_SEL_GMII_MII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_MII\n" );break ;case PHY_INTERFACE_MODE_GMII : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_GMII_MII ); + phy_intf_sel =PHY_INTF_SEL_GMII_MII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_GMII\n" );break ;case PHY_INTERFACE_MODE_RMII : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RMII ); + phy_intf_sel =PHY_INTF_SEL_RMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;@@ -92,7 +93,7 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)case PHY_INTERFACE_MODE_RGMII_ID :case PHY_INTERFACE_MODE_RGMII_TXID :case PHY_INTERFACE_MODE_RGMII_RXID : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RGMII ); + phy_intf_sel =PHY_INTF_SEL_RGMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RGMII\n" );break ;@@ -102,7 +103,8 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return -EINVAL ; } - val |=FIELD_PREP (MACPHYC_TXCLK_SEL_MASK ,MACPHYC_TXCLK_SEL_INPUT ); + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel) | +FIELD_PREP (MACPHYC_TXCLK_SEL_MASK ,MACPHYC_TXCLK_SEL_INPUT );/* Update MAC PHY control register */ return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val);@@ -131,10 +133,11 @@ static int x1600_mac_set_mode(struct plat_stmmacenet_data *plat_dat) {struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; +u8 phy_intf_sel;switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RMII ); + phy_intf_sel =PHY_INTF_SEL_RMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;@@ -144,6 +147,8 @@ static int x1600_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return -EINVAL ; } + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel); +/* Update MAC PHY control register */ return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); }@@ -152,11 +157,12 @@ static int x1830_mac_set_mode(struct plat_stmmacenet_data *plat_dat) {struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; +u8 phy_intf_sel;switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : - val =FIELD_PREP (MACPHYC_MODE_SEL_MASK ,MACPHYC_MODE_SEL_RMII ) | -FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RMII ); + val =FIELD_PREP (MACPHYC_MODE_SEL_MASK ,MACPHYC_MODE_SEL_RMII ); + phy_intf_sel =PHY_INTF_SEL_RMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;@@ -166,6 +172,8 @@ static int x1830_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return -EINVAL ; } + val |=FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel); +/* Update MAC PHY control register */ return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); }@@ -174,12 +182,13 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat) {struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; +u8 phy_intf_sel;switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : val =FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN ) | -FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_ORIGIN ) | -FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RMII ); +FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_ORIGIN ); + phy_intf_sel =PHY_INTF_SEL_RMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;@@ -187,7 +196,8 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)case PHY_INTERFACE_MODE_RGMII_ID :case PHY_INTERFACE_MODE_RGMII_TXID :case PHY_INTERFACE_MODE_RGMII_RXID : - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK ,PHY_INTF_SEL_RGMII ); + val =0 ; + phy_intf_sel =PHY_INTF_SEL_RGMII ;if (mac->tx_delay ==0 ) val |=FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN );@@ -210,6 +220,8 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return -EINVAL ; } + val |=FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel); +/* Update MAC PHY control register */ return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); }
Re: [PATCH net-next v2 06/11] net: stmmac: ingenic: use stmmac_get_phy_intf_sel()
In reply to Russell King (Oracle)Quoted 7 lines · Russell King (Oracle)
Use
stmmac_get_phy_intf_sel()to decode the PHY interface mode to thephy_intf_selvalue, validate the result against the SoC specific supportedphy_intf_selvalues, and pass into the SoC specificset_mode()methods, replacing the localphy_intf_selvariable. This provides the value for theMACPHYC_PHY_INFT_MASKfield.Signed-off-by Russell King (Oracle) <[email protected]>
This looks correct to me :)
Maxime
Quoted 193 lines
--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 55 ++++++++++++------- 1 file changed, 34 insertions(+), 21 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +34
-21@@ -64,28 +64,27 @@ struct ingenic_soc_info {enum ingenic_mac_version version;u32 mask; -int (*set_mode)(struct plat_stmmacenet_data *plat_dat); +int (*set_mode)(struct plat_stmmacenet_data *plat_dat,u8 phy_intf_sel); + +u8 valid_phy_intf_sel; }; -static int jz4775_mac_set_mode (struct plat_stmmacenet_data *plat_dat) +static int jz4775_mac_set_mode (struct plat_stmmacenet_data *plat_dat, +u8 phy_intf_sel) {struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; -u8 phy_intf_sel;switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_MII : - phy_intf_sel =PHY_INTF_SEL_GMII_MII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_MII\n" );break ;case PHY_INTERFACE_MODE_GMII : - phy_intf_sel =PHY_INTF_SEL_GMII_MII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_GMII\n" );break ;case PHY_INTERFACE_MODE_RMII : - phy_intf_sel =PHY_INTF_SEL_RMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;@@ -93,7 +92,6 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)case PHY_INTERFACE_MODE_RGMII_ID :case PHY_INTERFACE_MODE_RGMII_TXID :case PHY_INTERFACE_MODE_RGMII_RXID : - phy_intf_sel =PHY_INTF_SEL_RGMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RGMII\n" );break ;@@ -110,7 +108,8 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); } -static int x1000_mac_set_mode (struct plat_stmmacenet_data *plat_dat) +static int x1000_mac_set_mode (struct plat_stmmacenet_data *plat_dat, +u8 phy_intf_sel) {struct ingenic_mac *mac = plat_dat->bsp_priv;@@ -129,15 +128,14 @@ static int x1000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask,0 ); } -static int x1600_mac_set_mode (struct plat_stmmacenet_data *plat_dat) +static int x1600_mac_set_mode (struct plat_stmmacenet_data *plat_dat, +u8 phy_intf_sel) {struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; -u8 phy_intf_sel;switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : - phy_intf_sel =PHY_INTF_SEL_RMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;@@ -153,16 +151,15 @@ static int x1600_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); } -static int x1830_mac_set_mode (struct plat_stmmacenet_data *plat_dat) +static int x1830_mac_set_mode (struct plat_stmmacenet_data *plat_dat, +u8 phy_intf_sel) {struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; -u8 phy_intf_sel;switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : val =FIELD_PREP (MACPHYC_MODE_SEL_MASK ,MACPHYC_MODE_SEL_RMII ); - phy_intf_sel =PHY_INTF_SEL_RMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;@@ -178,17 +175,16 @@ static int x1830_mac_set_mode(struct plat_stmmacenet_data *plat_dat)return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); } -static int x2000_mac_set_mode (struct plat_stmmacenet_data *plat_dat) +static int x2000_mac_set_mode (struct plat_stmmacenet_data *plat_dat, +u8 phy_intf_sel) {struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; -u8 phy_intf_sel;switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : val =FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN ) |FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_ORIGIN ); - phy_intf_sel =PHY_INTF_SEL_RMII ;dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;@@ -197,8 +193,6 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)case PHY_INTERFACE_MODE_RGMII_TXID :case PHY_INTERFACE_MODE_RGMII_RXID : val =0 ; - phy_intf_sel =PHY_INTF_SEL_RGMII ; -if (mac->tx_delay ==0 ) val |=FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN );else @@ -229,10 +223,21 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)static int ingenic_mac_init (struct platform_device *pdev,void *bsp_priv) {struct ingenic_mac *mac = bsp_priv; -int ret; +phy_interface_t interface; +int phy_intf_sel, ret;if (mac->soc_info->set_mode) { - ret = mac->soc_info->set_mode (mac->plat_dat); + interface = mac->plat_dat->phy_interface; + + phy_intf_sel =stmmac_get_phy_intf_sel (interface); +if (phy_intf_sel <0 || phy_intf_sel >=BITS_PER_BYTE || + ~mac->soc_info->valid_phy_intf_sel &BIT (phy_intf_sel)) { +dev_err (mac->dev,"unsupported interface %s\n" , +phy_modes (interface)); +return phy_intf_sel <0 ? phy_intf_sel : -EINVAL ; + } + + ret = mac->soc_info->set_mode (mac->plat_dat, phy_intf_sel);if (ret)return ret; }@@ -309,6 +314,9 @@ static struct ingenic_soc_info jz4775_soc_info = { .mask = MACPHYC_TXCLK_SEL_MASK | MACPHYC_SOFT_RST_MASK | MACPHYC_PHY_INFT_MASK, .set_mode = jz4775_mac_set_mode, + .valid_phy_intf_sel =BIT (PHY_INTF_SEL_GMII_MII ) | +BIT (PHY_INTF_SEL_RGMII ) | + BIT(PHY_INTF_SEL_RMII), };static struct ingenic_soc_info x1000_soc_info = {@@ -316,6 +324,7 @@ static struct ingenic_soc_info x1000_soc_info = { .mask = MACPHYC_SOFT_RST_MASK, .set_mode = x1000_mac_set_mode, + .valid_phy_intf_sel = BIT(PHY_INTF_SEL_RMII), };static struct ingenic_soc_info x1600_soc_info = {@@ -323,6 +332,7 @@ static struct ingenic_soc_info x1600_soc_info = { .mask = MACPHYC_SOFT_RST_MASK | MACPHYC_PHY_INFT_MASK, .set_mode = x1600_mac_set_mode, + .valid_phy_intf_sel = BIT(PHY_INTF_SEL_RMII), };static struct ingenic_soc_info x1830_soc_info = {@@ -330,6 +340,7 @@ static struct ingenic_soc_info x1830_soc_info = { .mask = MACPHYC_MODE_SEL_MASK | MACPHYC_SOFT_RST_MASK | MACPHYC_PHY_INFT_MASK, .set_mode = x1830_mac_set_mode, + .valid_phy_intf_sel = BIT(PHY_INTF_SEL_RMII), };static struct ingenic_soc_info x2000_soc_info = {@@ -338,6 +349,8 @@ static struct ingenic_soc_info x2000_soc_info = { MACPHYC_RX_DELAY_MASK | MACPHYC_SOFT_RST_MASK | MACPHYC_PHY_INFT_MASK, .set_mode = x2000_mac_set_mode, + .valid_phy_intf_sel =BIT (PHY_INTF_SEL_RGMII ) | + BIT(PHY_INTF_SEL_RMII), };static const struct of_device_id ingenic_mac_of_matches[] = {
Re: [PATCH net-next v2 07/11] net: stmmac: ingenic: move "MAC PHY control register" debug
In reply to Russell King (Oracle)Quoted 5 lines · Russell King (Oracle)
Move the printing of the MAC PHY control register interface mode setting into
ingenic_set_phy_intf_sel(), and usephy_modes()to print the string rather than using the enum name.Signed-off-by Russell King (Oracle) <[email protected]>
Maxime
Quoted 81 lines
--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +3
-15@@ -77,22 +77,12 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat,switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_MII : -dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_MII\n" ); -break ; -case PHY_INTERFACE_MODE_GMII : -dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_GMII\n" ); -break ; -case PHY_INTERFACE_MODE_RMII : -dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" ); -break ; -case PHY_INTERFACE_MODE_RGMII :case PHY_INTERFACE_MODE_RGMII_ID :case PHY_INTERFACE_MODE_RGMII_TXID :case PHY_INTERFACE_MODE_RGMII_RXID : -dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RGMII\n" );break ;default :@@ -115,7 +105,6 @@ static int x1000_mac_set_mode(struct plat_stmmacenet_data *plat_dat,switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : -dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;default :@@ -136,7 +125,6 @@ static int x1600_mac_set_mode(struct plat_stmmacenet_data *plat_dat,switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : -dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;default :@@ -160,7 +148,6 @@ static int x1830_mac_set_mode(struct plat_stmmacenet_data *plat_dat,switch (plat_dat->phy_interface) {case PHY_INTERFACE_MODE_RMII : val =FIELD_PREP (MACPHYC_MODE_SEL_MASK ,MACPHYC_MODE_SEL_RMII ); -dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;default :@@ -185,7 +172,6 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat,case PHY_INTERFACE_MODE_RMII : val =FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN ) |FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_ORIGIN ); -dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n" );break ;case PHY_INTERFACE_MODE_RGMII :@@ -205,7 +191,6 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat, val |=FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_DELAY ) |FIELD_PREP (MACPHYC_RX_DELAY_MASK , (mac->rx_delay +9750 ) /19500 -1 ); -dev_dbg (mac->dev,"MAC PHY Control Register: PHY_INTERFACE_MODE_RGMII\n" );break ;default :@@ -237,6 +222,9 @@ static int ingenic_mac_init(struct platform_device *pdev, void *bsp_priv)return phy_intf_sel <0 ? phy_intf_sel : -EINVAL ; } +dev_dbg (mac->dev,"MAC PHY control register: interface %s\n" , +phy_modes (interface)); + ret = mac->soc_info->set_mode (mac->plat_dat, phy_intf_sel);if (ret)return ret;
Re: [PATCH net-next v2 08/11] net: stmmac: ingenic: simplify mac_set_mode() methods
In reply to Russell King (Oracle)Quoted 9 lines · Russell King (Oracle)
x1000, x1600 and x1830 only accept RMII mode.
PHY_INTF_SEL_RMIIis only selected withPHY_INTERFACE_MODE_RMII, andPHY_INTF_SEL_RMIIhas been validated by the SoC's .valid_phy_intf_sel bitmask. Thus, checking the interface mode in these functions becomes unnecessary. Remove these.jz4775 is similar, except for a greater set of
PHY_INTF_SEL_xvalies. Also remove the switch statement here.Signed-off-by Russell King (Oracle) <[email protected]>
Maxime
Quoted 86 lines
--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 50 +------------------ 1 file changed, 2 insertions(+), 48 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +2
-48@@ -75,22 +75,6 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat,struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; -switch (plat_dat->phy_interface) { -case PHY_INTERFACE_MODE_MII : -case PHY_INTERFACE_MODE_GMII : -case PHY_INTERFACE_MODE_RMII : -case PHY_INTERFACE_MODE_RGMII : -case PHY_INTERFACE_MODE_RGMII_ID : -case PHY_INTERFACE_MODE_RGMII_TXID : -case PHY_INTERFACE_MODE_RGMII_RXID : -break ; - -default : -dev_err (mac->dev,"Unsupported interface %s\n" , -phy_modes (plat_dat->phy_interface)); -return -EINVAL ; - } - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel) |FIELD_PREP (MACPHYC_TXCLK_SEL_MASK ,MACPHYC_TXCLK_SEL_INPUT );@@ -103,16 +87,6 @@ static int x1000_mac_set_mode(struct plat_stmmacenet_data *plat_dat, {struct ingenic_mac *mac = plat_dat->bsp_priv; -switch (plat_dat->phy_interface) { -case PHY_INTERFACE_MODE_RMII : -break ; - -default : -dev_err (mac->dev,"Unsupported interface %s\n" , -phy_modes (plat_dat->phy_interface)); -return -EINVAL ; - } -/* Update MAC PHY control register */ return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask,0 ); }@@ -123,16 +97,6 @@ static int x1600_mac_set_mode(struct plat_stmmacenet_data *plat_dat,struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; -switch (plat_dat->phy_interface) { -case PHY_INTERFACE_MODE_RMII : -break ; - -default : -dev_err (mac->dev,"Unsupported interface %s\n" , -phy_modes (plat_dat->phy_interface)); -return -EINVAL ; - } - val =FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel);/* Update MAC PHY control register */ @@ -145,18 +109,8 @@ static int x1830_mac_set_mode(struct plat_stmmacenet_data *plat_dat,struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; -switch (plat_dat->phy_interface) { -case PHY_INTERFACE_MODE_RMII : - val =FIELD_PREP (MACPHYC_MODE_SEL_MASK ,MACPHYC_MODE_SEL_RMII ); -break ; - -default : -dev_err (mac->dev,"Unsupported interface %s\n" , -phy_modes (plat_dat->phy_interface)); -return -EINVAL ; - } - - val |=FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel); + val =FIELD_PREP (MACPHYC_MODE_SEL_MASK ,MACPHYC_MODE_SEL_RMII ) | +FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel);/* Update MAC PHY control register */ return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val);
Re: [PATCH net-next v2 09/11] net: stmmac: ingenic: simplify x2000 mac_set_mode()
In reply to Russell King (Oracle)Quoted 7 lines · Russell King (Oracle)
As per the previous commit, we have validated that the
phy_intf_selvalue is one that is permissible for this SoC, so there is no need to handle invalid PHY interface modes. We can also apply the other configuration based upon thephy_intf_selvalue rather than the PHY interface mode.Signed-off-by Russell King (Oracle) <[email protected]>
Maxime
Quoted 55 lines
--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +7
-21@@ -122,39 +122,25 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat,struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; -switch (plat_dat->phy_interface) { -case PHY_INTERFACE_MODE_RMII : - val =FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN ) | -FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_ORIGIN ); -break ; - -case PHY_INTERFACE_MODE_RGMII : -case PHY_INTERFACE_MODE_RGMII_ID : -case PHY_INTERFACE_MODE_RGMII_TXID : -case PHY_INTERFACE_MODE_RGMII_RXID : - val =0 ; + val =FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel); + +if (phy_intf_sel ==PHY_INTF_SEL_RMII ) { + val |=FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN ) | +FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_ORIGIN ); + }else if (phy_intf_sel ==PHY_INTF_SEL_RGMII ) {if (mac->tx_delay ==0 ) val |=FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_ORIGIN );else val |=FIELD_PREP (MACPHYC_TX_SEL_MASK ,MACPHYC_TX_SEL_DELAY ) | -FIELD_PREP (MACPHYC_TX_DELAY_MASK , (mac->tx_delay +9750 ) /19500 -1 ); +FIELD_PREP (MACPHYC_TX_DELAY_MASK , (mac->tx_delay +9750 ) /19500 -1 );if (mac->rx_delay ==0 ) val |=FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_ORIGIN );else val |=FIELD_PREP (MACPHYC_RX_SEL_MASK ,MACPHYC_RX_SEL_DELAY ) |FIELD_PREP (MACPHYC_RX_DELAY_MASK , (mac->rx_delay +9750 ) /19500 -1 ); - -break ; - -default : -dev_err (mac->dev,"Unsupported interface %s\n" , -phy_modes (plat_dat->phy_interface)); -return -EINVAL ; } - val |=FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel); -/* Update MAC PHY control register */ return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); }
Re: [PATCH net-next v2 10/11] net: stmmac: ingenic: pass ingenic_mac struct rather than plat_dat
In reply to Russell King (Oracle)Quoted 6 lines · Russell King (Oracle)
It no longer makes sense to pass a pointer to struct
plat_stmmacenet_datawhen calling theset_mode()methods to only use it to get a pointer to theingenic_macstructure that we already had in the caller. Simplify this by passing the structingenic_macpointer.Signed-off-by Russell King (Oracle) <[email protected]>
Maxime
Quoted 81 lines
--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +7
-18@@ -64,15 +64,13 @@ struct ingenic_soc_info {enum ingenic_mac_version version;u32 mask; -int (*set_mode)(struct plat_stmmacenet_data *plat_dat,u8 phy_intf_sel); +int (*set_mode)(struct ingenic_mac *mac,u8 phy_intf_sel);u8 valid_phy_intf_sel; }; -static int jz4775_mac_set_mode (struct plat_stmmacenet_data *plat_dat, -u8 phy_intf_sel) +static int jz4775_mac_set_mode (struct ingenic_mac *mac,u8 phy_intf_sel) { -struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; val = FIELD_PREP(MACPHYC_PHY_INFT_MASK, phy_intf_sel) |@@ -82,19 +80,14 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat,return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); } -static int x1000_mac_set_mode (struct plat_stmmacenet_data *plat_dat, -u8 phy_intf_sel) +static int x1000_mac_set_mode (struct ingenic_mac *mac,u8 phy_intf_sel) { -struct ingenic_mac *mac = plat_dat->bsp_priv; -/* Update MAC PHY control register */ return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask,0 ); } -static int x1600_mac_set_mode (struct plat_stmmacenet_data *plat_dat, -u8 phy_intf_sel) +static int x1600_mac_set_mode (struct ingenic_mac *mac,u8 phy_intf_sel) { -struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; val =FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel);@@ -103,10 +96,8 @@ static int x1600_mac_set_mode(struct plat_stmmacenet_data *plat_dat,return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); } -static int x1830_mac_set_mode (struct plat_stmmacenet_data *plat_dat, -u8 phy_intf_sel) +static int x1830_mac_set_mode (struct ingenic_mac *mac,u8 phy_intf_sel) { -struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; val = FIELD_PREP(MACPHYC_MODE_SEL_MASK, MACPHYC_MODE_SEL_RMII) |@@ -116,10 +107,8 @@ static int x1830_mac_set_mode(struct plat_stmmacenet_data *plat_dat,return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); } -static int x2000_mac_set_mode (struct plat_stmmacenet_data *plat_dat, -u8 phy_intf_sel) +static int x2000_mac_set_mode (struct ingenic_mac *mac,u8 phy_intf_sel) { -struct ingenic_mac *mac = plat_dat->bsp_priv;unsigned int val; val =FIELD_PREP (MACPHYC_PHY_INFT_MASK , phy_intf_sel);@@ -165,7 +154,7 @@ static int ingenic_mac_init(struct platform_device *pdev, void *bsp_priv)dev_dbg (mac->dev,"MAC PHY control register: interface %s\n" ,phy_modes (interface)); - ret = mac->soc_info->set_mode (mac->plat_dat, phy_intf_sel); + ret = mac->soc_info->set_mode (mac, phy_intf_sel);if (ret)return ret; }
Quoted 10 lines · Maxime Chevallier
Hi Russell,
Quoted 7 lines · Russell King (Oracle)
On Wed, Nov 05, 2025 at 01:25:54PM +0000, Russell King (Oracle) wrote:
Convert ingenic to use the new ->set_phy_intf_sel() method that was recently introduced in net-next.This is the largest of the conversions, as there is scope for cleanups along with the conversion.
Quoted 8 lines
Quoted 5 lines
v2: fix build warnings in patch 9 by rearranging the code
.../net/ethernet/stmicro/stmmac/dwmac-ingenic.c | 165 ++++++--------------- 1 file changed, 45 insertions(+), 120 deletions(-)Damned, missed that V2 and started reviewing V1... I'll resend the tags for V2.
Yes, Jakub reported build warnings on patch 9 last night, followed by the kernel build bot reporting the same thing. The dangers of not building with W=1, but then W=1 is noisy which makes spotting new warnings difficult.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH net-next v2 11/11] net: stmmac: ingenic: use ->set_phy_intf_sel()
In reply to Russell King (Oracle)Quoted 4 lines · Russell King (Oracle)
Rather than placing the
phy_intf_sel()setup in the ->init() method, move it to the new ->set_phy_intf_sel() method.Signed-off-by Russell King (Oracle) <[email protected]>
This looks good to me, but I can't test however :(
BTW this series was very nice to review with all the incremental changes, thanks !
Maxime
Quoted 60 lines
--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +11
-22@@ -134,32 +134,21 @@ static int x2000_mac_set_mode(struct ingenic_mac *mac, u8 phy_intf_sel)return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); } -static int ingenic_mac_init (struct platform_device *pdev,void *bsp_priv) +static int ingenic_set_phy_intf_sel (void *bsp_priv,u8 phy_intf_sel) {struct ingenic_mac *mac = bsp_priv; -phy_interface_t interface; -int phy_intf_sel, ret; - -if (mac->soc_info->set_mode) { - interface = mac->plat_dat->phy_interface; - - phy_intf_sel =stmmac_get_phy_intf_sel (interface); -if (phy_intf_sel <0 || phy_intf_sel >=BITS_PER_BYTE || - ~mac->soc_info->valid_phy_intf_sel &BIT (phy_intf_sel)) { -dev_err (mac->dev,"unsupported interface %s\n" , -phy_modes (interface)); -return phy_intf_sel <0 ? phy_intf_sel : -EINVAL ; - } -dev_dbg (mac->dev,"MAC PHY control register: interface %s\n" , -phy_modes (interface)); +if (!mac->soc_info->set_mode) +return 0 ; - ret = mac->soc_info->set_mode (mac, phy_intf_sel); -if (ret) -return ret; - } +if (phy_intf_sel >=BITS_PER_BYTE || + ~mac->soc_info->valid_phy_intf_sel &BIT (phy_intf_sel)) +return phy_intf_sel <0 ? phy_intf_sel : -EINVAL ; + +dev_dbg (mac->dev,"MAC PHY control register: interface %s\n" , +phy_modes (mac->plat_dat->phy_interface)); -return 0 ; +return mac->soc_info->set_mode (mac, phy_intf_sel); }static int ingenic_mac_probe (struct platform_device *pdev)@@ -221,7 +210,7 @@ static int ingenic_mac_probe(struct platform_device *pdev) mac->plat_dat = plat_dat; plat_dat->bsp_priv = mac; - plat_dat->init = ingenic_mac_init; + plat_dat->set_phy_intf_sel = ingenic_set_phy_intf_sel;return devm_stmmac_pltfr_probe (pdev, plat_dat, &stmmac_res); }
Maxime Chevallier
maintainerQuoted 12 lines
Quoted 12 lines
Quoted 11 lines
Convert ingenic to use the new ->set_phy_intf_sel() method that was recently introduced in net-next.
This is the largest of the conversions, as there is scope for cleanups along with the conversion.
v2: fix build warnings in patch 9 by rearranging the code
.../net/ethernet/stmicro/stmmac/dwmac-ingenic.c | 165 ++++++--------------- 1 file changed, 45 insertions(+), 120 deletions(-)
Quoted 8 lines
Quoted 2 lines
Damned, missed that V2 and started reviewing V1... I'll resend the tags for V2.
Yes, Jakub reported build warnings on patch 9 last night, followed by the kernel build bot reporting the same thing. The dangers of not building with W=1, but then W=1 is noisy which makes spotting new warnings difficult.
I had the same issue, I have recently started using the nipa infra locally for that, which comes with a way to compare the number of warnings before/after for each patch to help sift through these :
https://github.com/linux-netdev/nipa
The setup was actually way easier than I would've thought, and testing a series boils down to running :
cd $nipa
./ingest_mdir.py --mdir /tmp/my-series/ --tree $linux
it still takes a while to run on my workstation though, but at least it doubles as a nice way to heat-up my living room with all the compiling going on :)
Maxime
Simon Horman
reviewerRe: [PATCH net-next v2 11/11] net: stmmac: ingenic: use ->set_phy_intf_sel()
In reply to Russell King (Oracle)Quoted 36 lines · Russell King (Oracle)
Rather than placing the
phy_intf_sel()setup in the ->init() method, move it to the new ->set_phy_intf_sel() method.Signed-off-by Russell King (Oracle) <[email protected]>--- .../ethernet/stmicro/stmmac/dwmac-ingenic.c | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +1
-16@@ -134,32 +134,21 @@ static int x2000_mac_set_mode(struct ingenic_mac *mac, u8 phy_intf_sel)return regmap_update_bits (mac->regmap,0 , mac->soc_info->mask, val); } -static int ingenic_mac_init (struct platform_device *pdev,void *bsp_priv) +static int ingenic_set_phy_intf_sel (void *bsp_priv,u8 phy_intf_sel) {struct ingenic_mac *mac = bsp_priv; -phy_interface_t interface; -int phy_intf_sel, ret; - -if (mac->soc_info->set_mode) { - interface = mac->plat_dat->phy_interface; - - phy_intf_sel =stmmac_get_phy_intf_sel (interface); -if (phy_intf_sel <0 || phy_intf_sel >=BITS_PER_BYTE || - ~mac->soc_info->valid_phy_intf_sel &BIT (phy_intf_sel)) { -dev_err (mac->dev,"unsupported interface %s\n" , -phy_modes (interface)); -return phy_intf_sel <0 ? phy_intf_sel : -EINVAL ; - } -dev_dbg (mac->dev,"MAC PHY control register: interface %s\n" , -phy_modes (interface));
drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c static int x2000_mac_set_mode(struct ingenic_mac *mac, u8 phy_intf_sel) · line 146
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +5
-4+if (!mac->soc_info->set_mode) +return 0 ; - ret = mac->soc_info->set_mode (mac, phy_intf_sel); -if (ret) -return ret; - } +if (phy_intf_sel >=BITS_PER_BYTE || + ~mac->soc_info->valid_phy_intf_sel &BIT (phy_intf_sel)) +return phy_intf_sel <0 ? phy_intf_sel : -EINVAL ;
nit from Smatch: phy_intf_sel is unsigned and thus cannot be negative
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +4
-1+ +dev_dbg (mac->dev,"MAC PHY control register: interface %s\n" , +phy_modes (mac->plat_dat->phy_interface)); -return 0 ; +return mac->soc_info->set_mode (mac, phy_intf_sel); }
...