net: stmmac: lpc18xx and sti: convert to set_phy_intf_sel()
Subsystems (5)
cover net: stmmac: lpc18xx and sti: convert to set_phy_intf_sel()
This series converts lpc18xx and sti to use the new .set_phy_intf_sel() method.
.../net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c | 42 ++++++++++-------- drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c | 50 ++++++++-------------- 2 files changed, 42 insertions(+), 50 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 1/9 net: stmmac: lpc18xx: convert to PHY_INTF_SEL_x
Use the common dwmac definitions for the PHY interface selection field.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c +2 -2
@@ -22,8 +22,8 @@/* Register defines for CREG syscon */ #define LPC18XX_CREG_CREG6 0x12c# define LPC18XX_CREG_CREG6_ETHMODE_MASK 0x7 -# define LPC18XX_CREG_CREG6_ETHMODE_MII 0x0 -# define LPC18XX_CREG_CREG6_ETHMODE_RMII 0x4 +# define LPC18XX_CREG_CREG6_ETHMODE_MII PHY_INTF_SEL_GMII_MII +# define LPC18XX_CREG_CREG6_ETHMODE_RMII PHY_INTF_SEL_RMIIstatic int lpc18xx_dwmac_probe (struct platform_device *pdev) {
Signature · 1 line
2.47.3
PATCH 2/9 net: stmmac: lpc18xx: use PHY_INTF_SEL_x directly
In reply to Russell King (Oracle)Use the PHY_INTF_SEL_x values directly rather than the driver private LPC18XX_CREG_CREG6_ETHMODE_x definitions, and convert LPC18XX_CREG_CREG6_ETHMODE_MASK to use GENMASK().
--- drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c +3 -5
@@ -21,9 +21,7 @@/* Register defines for CREG syscon */ #define LPC18XX_CREG_CREG6 0x12c -# define LPC18XX_CREG_CREG6_ETHMODE_MASK 0x7 -# define LPC18XX_CREG_CREG6_ETHMODE_MII PHY_INTF_SEL_GMII_MII -# define LPC18XX_CREG_CREG6_ETHMODE_RMII PHY_INTF_SEL_RMII +# define LPC18XX_CREG_CREG6_ETHMODE_MASK GENMASK(2, 0)static int lpc18xx_dwmac_probe (struct platform_device *pdev) {
@@ -50,9 +48,9 @@ static int lpc18xx_dwmac_probe(struct platform_device *pdev) }if (plat_dat->phy_interface ==PHY_INTERFACE_MODE_MII ) { - ethmode =LPC18XX_CREG_CREG6_ETHMODE_MII ; + ethmode =PHY_INTF_SEL_GMII_MII ; }else if (plat_dat->phy_interface ==PHY_INTERFACE_MODE_RMII ) { - ethmode =LPC18XX_CREG_CREG6_ETHMODE_RMII ; + ethmode =PHY_INTF_SEL_RMII ; }else {dev_err (&pdev->dev,"Only MII and RMII mode supported\n" );return -EINVAL ;
Signature · 1 line
2.47.3
PATCH 3/9 net: stmmac: lpc18xx: 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, and use the result to program the ethernet mode.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c +4 -5
@@ -47,15 +47,14 @@ static int lpc18xx_dwmac_probe(struct platform_device *pdev)return PTR_ERR (reg); } -if (plat_dat->phy_interface ==PHY_INTERFACE_MODE_MII ) { - ethmode =PHY_INTF_SEL_GMII_MII ; - }else if (plat_dat->phy_interface ==PHY_INTERFACE_MODE_RMII ) { - ethmode =PHY_INTF_SEL_RMII ; - }else { +if (plat_dat->phy_interface !=PHY_INTERFACE_MODE_MII && + plat_dat->phy_interface !=PHY_INTERFACE_MODE_RMII ) {dev_err (&pdev->dev,"Only MII and RMII mode supported\n" );return -EINVAL ; } + ethmode =stmmac_get_phy_intf_sel (plat_dat->phy_interface); +regmap_update_bits (reg,LPC18XX_CREG_CREG6 ,LPC18XX_CREG_CREG6_ETHMODE_MASK , ethmode);
Signature · 1 line
2.47.3
PATCH 4/9 net: stmmac: lpc18xx: validate phy_intf_sel
In reply to Russell King (Oracle)Validate the phy_intf_sel value rather than the PHY interface mode. This will allow us to transition to the ->set_phy_intf_sel() method. Note that this will allow GMII as well as MII as the phy_intf_sel value is the same for both.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c +3 -4
@@ -47,14 +47,13 @@ static int lpc18xx_dwmac_probe(struct platform_device *pdev)return PTR_ERR (reg); } -if (plat_dat->phy_interface !=PHY_INTERFACE_MODE_MII && - plat_dat->phy_interface !=PHY_INTERFACE_MODE_RMII ) { + ethmode =stmmac_get_phy_intf_sel (plat_dat->phy_interface); +if (ethmode !=PHY_INTF_SEL_GMII_MII && + ethmode !=PHY_INTF_SEL_RMII ) {dev_err (&pdev->dev,"Only MII and RMII mode supported\n" );return -EINVAL ; } - ethmode =stmmac_get_phy_intf_sel (plat_dat->phy_interface); -regmap_update_bits (reg,LPC18XX_CREG_CREG6 ,LPC18XX_CREG_CREG6_ETHMODE_MASK , ethmode);
Signature · 1 line
2.47.3
PATCH 5/9 net: stmmac: lpc18xx: use ->set_phy_intf_sel()
In reply to Russell King (Oracle)Move the configuration of the dwmac PHY interface selection to the new ->set_phy_intf_sel() method.
--- .../ethernet/stmicro/stmmac/dwmac-lpc18xx.c | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c +22 -14
@@ -23,12 +23,27 @@#define LPC18XX_CREG_CREG6 0x12c# define LPC18XX_CREG_CREG6_ETHMODE_MASK GENMASK(2, 0) +static int lpc18xx_set_phy_intf_sel (void *bsp_priv,u8 phy_intf_sel) +{ +struct regmap *reg = bsp_priv; + +if (phy_intf_sel !=PHY_INTF_SEL_GMII_MII && + phy_intf_sel !=PHY_INTF_SEL_RMII ) +return -EINVAL ; + +regmap_update_bits (reg,LPC18XX_CREG_CREG6 , +LPC18XX_CREG_CREG6_ETHMODE_MASK , +FIELD_PREP (LPC18XX_CREG_CREG6_ETHMODE_MASK , + phy_intf_sel)); + +return 0 ; +} +static int lpc18xx_dwmac_probe (struct platform_device *pdev) {struct plat_stmmacenet_data *plat_dat;struct stmmac_resources stmmac_res; -struct regmap *reg; -u8 ethmode; +struct regmap *regmap;int ret; ret =stmmac_get_platform_resources (pdev, &stmmac_res);
@@ -41,21 +56,14 @@ static int lpc18xx_dwmac_probe(struct platform_device *pdev) plat_dat->core_type =DWMAC_CORE_GMAC ; - reg =syscon_regmap_lookup_by_compatible ("nxp,lpc1850-creg" ); -if (IS_ERR (reg)) { + regmap =syscon_regmap_lookup_by_compatible ("nxp,lpc1850-creg" ); +if (IS_ERR (regmap)) {dev_err (&pdev->dev,"syscon lookup failed\n" ); -return PTR_ERR (reg); - } - - ethmode =stmmac_get_phy_intf_sel (plat_dat->phy_interface); -if (ethmode !=PHY_INTF_SEL_GMII_MII && - ethmode !=PHY_INTF_SEL_RMII ) { -dev_err (&pdev->dev,"Only MII and RMII mode supported\n" ); -return -EINVAL ; +return PTR_ERR (regmap); } -regmap_update_bits (reg,LPC18XX_CREG_CREG6 , -LPC18XX_CREG_CREG6_ETHMODE_MASK , ethmode); + plat_dat->bsp_priv = regmap; + plat_dat->set_phy_intf_sel = lpc18xx_set_phy_intf_sel;return stmmac_dvr_probe (&pdev->dev, plat_dat, &stmmac_res); }
Signature · 1 line
2.47.3
PATCH 6/9 net: stmmac: sti: use PHY_INTF_SEL_x to select PHY interface
In reply to Russell King (Oracle)Use the common dwmac definitions for the PHY interface selection field, adding MII_PHY_SEL_VAL() temporarily to avoid line wrapping.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c +7 -5
@@ -77,13 +77,15 @@* 001-RGMII * 010-SGMII * 100-RMII +* These are the DW MAC phy_intf_sel values */ #define MII_PHY_SEL_MASK GENMASK(4, 2) -#define ETH_PHY_SEL_RMII BIT(4) -#define ETH_PHY_SEL_SGMII BIT(3) -#define ETH_PHY_SEL_RGMII BIT(2) -#define ETH_PHY_SEL_GMII 0x0 -#define ETH_PHY_SEL_MII 0x0 +#define MII_PHY_SEL_VAL (val) FIELD_PREP_CONST(MII_PHY_SEL_MASK, val) +#define ETH_PHY_SEL_RMII MII_PHY_SEL_VAL(PHY_INTF_SEL_RMII) +#define ETH_PHY_SEL_SGMII MII_PHY_SEL_VAL(PHY_INTF_SEL_SGMII) +#define ETH_PHY_SEL_RGMII MII_PHY_SEL_VAL(PHY_INTF_SEL_RGMII) +#define ETH_PHY_SEL_GMII MII_PHY_SEL_VAL(PHY_INTF_SEL_GMII_MII) +#define ETH_PHY_SEL_MII MII_PHY_SEL_VAL(PHY_INTF_SEL_GMII_MII)struct sti_dwmac {phy_interface_t interface;/* MII interface */
Signature · 1 line
2.47.3
PATCH 7/9 net: stmmac: sti: use PHY_INTF_SEL_x directly
In reply to Russell King (Oracle)Use the PHY_INTF_SEL_x values directly rather than the driver private ETH_PHY_SEL_x values. Move the FIELD_PREP() into sti_dwmac_set_mode(). Use dwmac->interface directly.
--- .../net/ethernet/stmicro/stmmac/dwmac-sti.c | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c +12 -15
@@ -81,11 +81,6 @@*/ #define MII_PHY_SEL_MASK GENMASK(4, 2)#define MII_PHY_SEL_VAL (val) FIELD_PREP_CONST(MII_PHY_SEL_MASK, val) -#define ETH_PHY_SEL_RMII MII_PHY_SEL_VAL(PHY_INTF_SEL_RMII) -#define ETH_PHY_SEL_SGMII MII_PHY_SEL_VAL(PHY_INTF_SEL_SGMII) -#define ETH_PHY_SEL_RGMII MII_PHY_SEL_VAL(PHY_INTF_SEL_RGMII) -#define ETH_PHY_SEL_GMII MII_PHY_SEL_VAL(PHY_INTF_SEL_GMII_MII) -#define ETH_PHY_SEL_MII MII_PHY_SEL_VAL(PHY_INTF_SEL_GMII_MII)struct sti_dwmac {phy_interface_t interface;/* MII interface */
@@ -104,13 +99,13 @@ struct sti_dwmac_of_data {void (*fix_retime_src)(void *priv,int speed,unsigned int mode); }; -static u32 phy_intf_sels[] = { - [PHY_INTERFACE_MODE_MII ] =ETH_PHY_SEL_MII , - [PHY_INTERFACE_MODE_GMII ] =ETH_PHY_SEL_GMII , - [PHY_INTERFACE_MODE_RGMII ] =ETH_PHY_SEL_RGMII , - [PHY_INTERFACE_MODE_RGMII_ID ] =ETH_PHY_SEL_RGMII , - [PHY_INTERFACE_MODE_SGMII ] =ETH_PHY_SEL_SGMII , - [PHY_INTERFACE_MODE_RMII ] =ETH_PHY_SEL_RMII , +static u8 phy_intf_sels[] = { + [PHY_INTERFACE_MODE_MII ] =PHY_INTF_SEL_GMII_MII , + [PHY_INTERFACE_MODE_GMII ] =PHY_INTF_SEL_GMII_MII , + [PHY_INTERFACE_MODE_RGMII ] =PHY_INTF_SEL_RGMII , + [PHY_INTERFACE_MODE_RGMII_ID ] =PHY_INTF_SEL_RGMII , + [PHY_INTERFACE_MODE_SGMII ] =PHY_INTF_SEL_SGMII , + [PHY_INTERFACE_MODE_RMII ] =PHY_INTF_SEL_RMII , };enum {
@@ -164,16 +159,18 @@ static void stih4xx_fix_retime_src(void *priv, int spd, unsigned int mode)static int sti_dwmac_set_mode (struct sti_dwmac *dwmac) {struct regmap *regmap = dwmac->regmap; -int iface = dwmac->interface;u32 reg = dwmac->ctrl_reg; +u8 phy_intf_sel;u32 val;if (dwmac->gmac_en)regmap_update_bits (regmap, reg,EN_MASK ,EN ); -regmap_update_bits (regmap, reg,MII_PHY_SEL_MASK , phy_intf_sels[iface]); + phy_intf_sel = phy_intf_sels[dwmac->interface]; +regmap_update_bits (regmap, reg,MII_PHY_SEL_MASK , +FIELD_PREP (MII_PHY_SEL_MASK , phy_intf_sel)); - val = (iface ==PHY_INTERFACE_MODE_REVMII ) ?0 :ENMII ; + val = (dwmac->interface ==PHY_INTERFACE_MODE_REVMII ) ?0 :ENMII ;regmap_update_bits (regmap, reg,ENMII_MASK , val); dwmac->fix_retime_src (dwmac, dwmac->speed,0 );
Signature · 1 line
2.47.3
PATCH 8/9 net: stmmac: sti: 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 and use that to set the control register to select the operating mode for the DWMAC core.
Note that when an unsupported interface mode is used, the array would decode this to PHY_INTF_SEL_GMII_MII, so preserve this behaviour.
--- .../net/ethernet/stmicro/stmmac/dwmac-sti.c | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c +9 -13
@@ -77,10 +77,9 @@* 001-RGMII * 010-SGMII * 100-RMII -* These are the DW MAC phy_intf_sel values +* These are the DW MAC phy_intf_sel values. */ #define MII_PHY_SEL_MASK GENMASK(4, 2) -#define MII_PHY_SEL_VAL (val) FIELD_PREP_CONST(MII_PHY_SEL_MASK, val)struct sti_dwmac {phy_interface_t interface;/* MII interface */
@@ -99,15 +98,6 @@ struct sti_dwmac_of_data {void (*fix_retime_src)(void *priv,int speed,unsigned int mode); }; -static u8 phy_intf_sels[] = { - [PHY_INTERFACE_MODE_MII ] =PHY_INTF_SEL_GMII_MII , - [PHY_INTERFACE_MODE_GMII ] =PHY_INTF_SEL_GMII_MII , - [PHY_INTERFACE_MODE_RGMII ] =PHY_INTF_SEL_RGMII , - [PHY_INTERFACE_MODE_RGMII_ID ] =PHY_INTF_SEL_RGMII , - [PHY_INTERFACE_MODE_SGMII ] =PHY_INTF_SEL_SGMII , - [PHY_INTERFACE_MODE_RMII ] =PHY_INTF_SEL_RMII , -}; -enum {TX_RETIME_SRC_NA =0 ,TX_RETIME_SRC_TXCLK =1 ,
@@ -160,13 +150,19 @@ static int sti_dwmac_set_mode(struct sti_dwmac *dwmac) {struct regmap *regmap = dwmac->regmap;u32 reg = dwmac->ctrl_reg; -u8 phy_intf_sel; +int phy_intf_sel;u32 val;if (dwmac->gmac_en)regmap_update_bits (regmap, reg,EN_MASK ,EN ); - phy_intf_sel = phy_intf_sels[dwmac->interface]; + phy_intf_sel =stmmac_get_phy_intf_sel (dwmac->interface); +if (phy_intf_sel !=PHY_INTF_SEL_GMII_MII && + phy_intf_sel !=PHY_INTF_SEL_RGMII && + phy_intf_sel !=PHY_INTF_SEL_SGMII && + phy_intf_sel !=PHY_INTF_SEL_RMII ) + phy_intf_sel =PHY_INTF_SEL_GMII_MII ; +regmap_update_bits (regmap, reg,MII_PHY_SEL_MASK ,FIELD_PREP (MII_PHY_SEL_MASK , phy_intf_sel));
Signature · 1 line
2.47.3
PATCH 9/9 net: stmmac: sti: 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.
--- .../net/ethernet/stmicro/stmmac/dwmac-sti.c | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c +9 -16
@@ -146,17 +146,18 @@ static void stih4xx_fix_retime_src(void *priv, int spd, unsigned int mode) stih4xx_tx_retime_val[src]); } -static int sti_dwmac_set_mode (struct sti_dwmac *dwmac) +static int sti_set_phy_intf_sel (void *bsp_priv,u8 phy_intf_sel) { -struct regmap *regmap = dwmac->regmap; -u32 reg = dwmac->ctrl_reg; -int phy_intf_sel; -u32 val; +struct sti_dwmac *dwmac = bsp_priv; +struct regmap *regmap; +u32 reg, val; + + regmap = dwmac->regmap; + reg = dwmac->ctrl_reg;if (dwmac->gmac_en)regmap_update_bits (regmap, reg,EN_MASK ,EN ); - phy_intf_sel =stmmac_get_phy_intf_sel (dwmac->interface); if (phy_intf_sel != PHY_INTF_SEL_GMII_MII && phy_intf_sel != PHY_INTF_SEL_RGMII && phy_intf_sel != PHY_INTF_SEL_SGMII &&
@@ -231,17 +232,8 @@ static int sti_dwmac_parse_data(struct sti_dwmac *dwmac,static int sti_dwmac_init (struct platform_device *pdev,void *bsp_priv) {struct sti_dwmac *dwmac = bsp_priv; -int ret; - - ret =clk_prepare_enable (dwmac->clk); -if (ret) -return ret; - - ret =sti_dwmac_set_mode (dwmac); -if (ret) -clk_disable_unprepare (dwmac->clk); -return ret; +return clk_prepare_enable (dwmac->clk); }static void sti_dwmac_exit (struct platform_device *pdev,void *bsp_priv)
@@ -286,6 +278,7 @@ static int sti_dwmac_probe(struct platform_device *pdev) dwmac->fix_retime_src = data->fix_retime_src; plat_dat->bsp_priv = dwmac; + plat_dat->set_phy_intf_sel = sti_set_phy_intf_sel; plat_dat->fix_mac_speed = data->fix_retime_src; plat_dat->init = sti_dwmac_init; plat_dat->exit = sti_dwmac_exit;
Signature · 1 line
2.47.3
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 6 lines · On Thu, 6 Nov 2025 11:21:23 +0000 you wrote:
This series converts lpc18xx and sti to use the new .set_phy_intf_sel() method.
.../net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c | 42 ++++++++++-------- drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c | 50 ++++++++-------------- 2 files changed, 42 insertions(+), 50 deletions(-)
Here is the summary with links:
- [net-next,1/9] net: stmmac: lpc18xx: convert to PHY_INTF_SEL_x
https://git.kernel.org/netdev/net-next/c/5636fcdb0211 - [net-next,2/9] net: stmmac: lpc18xx: use PHY_INTF_SEL_x directly https://git.kernel.org/netdev/net-next/c/eb0533c7e63b - [net-next,3/9] net: stmmac: lpc18xx: use stmmac_get_phy_intf_sel() https://git.kernel.org/netdev/net-next/c/9882f1219408 - [net-next,4/9] net: stmmac: lpc18xx: validate phy_intf_sel https://git.kernel.org/netdev/net-next/c/4bad4219249f - [net-next,5/9] net: stmmac: lpc18xx: use ->set_phy_intf_sel() https://git.kernel.org/netdev/net-next/c/7fe0e06a7364 - [net-next,6/9] net: stmmac: sti: use PHY_INTF_SEL_x to select PHY interface https://git.kernel.org/netdev/net-next/c/9cd23c02ac57 - [net-next,7/9] net: stmmac: sti: use PHY_INTF_SEL_x directly https://git.kernel.org/netdev/net-next/c/bd5a68159259 - [net-next,8/9] net: stmmac: sti: use stmmac_get_phy_intf_sel() https://git.kernel.org/netdev/net-next/c/ef5e870be90f - [net-next,9/9] net: stmmac: sti: use ->set_phy_intf_sel() https://git.kernel.org/netdev/net-next/c/e3c8f25cf2aa
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html