linux-amlogic.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel()
@ 2025-11-07 14:27 Russell King (Oracle)
  2025-11-07 14:28 ` [PATCH net-next 01/16] net: stmmac: loongson1: use PHY_INTF_SEL_x Russell King (Oracle)
                   ` (15 more replies)
  0 siblings, 16 replies; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-07 14:27 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Emil Renner Berthing, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

This series converts the remaining glue drivers that support
multi-interface to use stmmac_get_phy_intf_sel(). The reason these
drivers are not converted to the set_phy_intf_sel() method is
because it is unclear whether there are ordering dependencies that
would prevent it.

For example, reading the stm32mp2 documentation, it is required to
set the ETH1_SEL field while the dwmac core is in reset and before
clocks are enabled. This requirement can not be satsified at the
moment (but could with further changes.)

 .../net/ethernet/stmicro/stmmac/dwmac-loongson1.c  | 18 ++---
 .../net/ethernet/stmicro/stmmac/dwmac-mediatek.c   | 77 ++++++++--------------
 .../net/ethernet/stmicro/stmmac/dwmac-meson8b.c    | 30 +++------
 .../net/ethernet/stmicro/stmmac/dwmac-starfive.c   | 26 +++-----
 drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c  | 44 +++++++------
 .../net/ethernet/stmicro/stmmac/dwmac-visconti.c   | 26 ++------
 6 files changed, 82 insertions(+), 139 deletions(-)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH net-next 01/16] net: stmmac: loongson1: use PHY_INTF_SEL_x
  2025-11-07 14:27 [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel() Russell King (Oracle)
@ 2025-11-07 14:28 ` Russell King (Oracle)
  2025-11-07 14:28 ` [PATCH net-next 02/16] net: stmmac: loongson1: use PHY_INTF_SEL_x directly Russell King (Oracle)
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-07 14:28 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Emil Renner Berthing, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

Use PHY_INTF_SEL_x definitions for phy_intf_sel bitfield.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
index 32b5d1492e2e..09e2af1d778a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
@@ -38,8 +38,8 @@
 #define GMAC_SHUT		BIT(6)
 
 #define PHY_INTF_SELI		GENMASK(30, 28)
-#define PHY_INTF_MII		FIELD_PREP(PHY_INTF_SELI, 0)
-#define PHY_INTF_RMII		FIELD_PREP(PHY_INTF_SELI, 4)
+#define PHY_INTF_MII		FIELD_PREP(PHY_INTF_SELI, PHY_INTF_SEL_GMII_MII)
+#define PHY_INTF_RMII		FIELD_PREP(PHY_INTF_SELI, PHY_INTF_SEL_RMII)
 
 struct ls1x_dwmac {
 	struct plat_stmmacenet_data *plat_dat;
-- 
2.47.3


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH net-next 02/16] net: stmmac: loongson1: use PHY_INTF_SEL_x directly
  2025-11-07 14:27 [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel() Russell King (Oracle)
  2025-11-07 14:28 ` [PATCH net-next 01/16] net: stmmac: loongson1: use PHY_INTF_SEL_x Russell King (Oracle)
@ 2025-11-07 14:28 ` Russell King (Oracle)
  2025-11-07 14:28 ` [PATCH net-next 03/16] net: stmmac: loongson1: use stmmac_get_phy_intf_sel() Russell King (Oracle)
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-07 14:28 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Emil Renner Berthing, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

Use the PHY_INTF_SEL_xx values directly in ls1c_dwmac_syscon_init(),
converting them to the PHY_INTF_SELI bitfield when calling
regmap_update_bits().

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
index 09e2af1d778a..5f9f66fbc191 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
@@ -38,8 +38,6 @@
 #define GMAC_SHUT		BIT(6)
 
 #define PHY_INTF_SELI		GENMASK(30, 28)
-#define PHY_INTF_MII		FIELD_PREP(PHY_INTF_SELI, PHY_INTF_SEL_GMII_MII)
-#define PHY_INTF_RMII		FIELD_PREP(PHY_INTF_SELI, PHY_INTF_SEL_RMII)
 
 struct ls1x_dwmac {
 	struct plat_stmmacenet_data *plat_dat;
@@ -140,15 +138,14 @@ static int ls1c_dwmac_syscon_init(struct platform_device *pdev, void *priv)
 	struct ls1x_dwmac *dwmac = priv;
 	struct plat_stmmacenet_data *plat = dwmac->plat_dat;
 	struct regmap *regmap = dwmac->regmap;
+	int phy_intf_sel;
 
 	switch (plat->phy_interface) {
 	case PHY_INTERFACE_MODE_MII:
-		regmap_update_bits(regmap, LS1X_SYSCON1, PHY_INTF_SELI,
-				   PHY_INTF_MII);
+		phy_intf_sel = PHY_INTF_SEL_GMII_MII;
 		break;
 	case PHY_INTERFACE_MODE_RMII:
-		regmap_update_bits(regmap, LS1X_SYSCON1, PHY_INTF_SELI,
-				   PHY_INTF_RMII);
+		phy_intf_sel = PHY_INTF_SEL_RMII;
 		break;
 	default:
 		dev_err(&pdev->dev, "Unsupported PHY-mode %u\n",
@@ -156,6 +153,8 @@ static int ls1c_dwmac_syscon_init(struct platform_device *pdev, void *priv)
 		return -EOPNOTSUPP;
 	}
 
+	regmap_update_bits(regmap, LS1X_SYSCON1, PHY_INTF_SELI,
+			   FIELD_PREP(PHY_INTF_SELI, phy_intf_sel));
 	regmap_update_bits(regmap, LS1X_SYSCON0, GMAC0_SHUT, 0);
 
 	return 0;
-- 
2.47.3


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH net-next 03/16] net: stmmac: loongson1: use stmmac_get_phy_intf_sel()
  2025-11-07 14:27 [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel() Russell King (Oracle)
  2025-11-07 14:28 ` [PATCH net-next 01/16] net: stmmac: loongson1: use PHY_INTF_SEL_x Russell King (Oracle)
  2025-11-07 14:28 ` [PATCH net-next 02/16] net: stmmac: loongson1: use PHY_INTF_SEL_x directly Russell King (Oracle)
@ 2025-11-07 14:28 ` Russell King (Oracle)
  2025-11-07 14:28 ` [PATCH net-next 04/16] net: stmmac: mediatek: use PHY_INTF_SEL_xxx Russell King (Oracle)
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-07 14:28 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Emil Renner Berthing, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

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.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
index 5f9f66fbc191..894ee66f5c9b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
@@ -140,14 +140,9 @@ static int ls1c_dwmac_syscon_init(struct platform_device *pdev, void *priv)
 	struct regmap *regmap = dwmac->regmap;
 	int phy_intf_sel;
 
-	switch (plat->phy_interface) {
-	case PHY_INTERFACE_MODE_MII:
-		phy_intf_sel = PHY_INTF_SEL_GMII_MII;
-		break;
-	case PHY_INTERFACE_MODE_RMII:
-		phy_intf_sel = PHY_INTF_SEL_RMII;
-		break;
-	default:
+	phy_intf_sel = stmmac_get_phy_intf_sel(plat->phy_interface);
+	if (phy_intf_sel != PHY_INTF_SEL_GMII_MII &&
+	    phy_intf_sel != PHY_INTF_SEL_RMII) {
 		dev_err(&pdev->dev, "Unsupported PHY-mode %u\n",
 			plat->phy_interface);
 		return -EOPNOTSUPP;
-- 
2.47.3


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH net-next 04/16] net: stmmac: mediatek: use PHY_INTF_SEL_xxx
  2025-11-07 14:27 [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel() Russell King (Oracle)
                   ` (2 preceding siblings ...)
  2025-11-07 14:28 ` [PATCH net-next 03/16] net: stmmac: loongson1: use stmmac_get_phy_intf_sel() Russell King (Oracle)
@ 2025-11-07 14:28 ` Russell King (Oracle)
  2025-11-07 14:28 ` [PATCH net-next 05/16] net: stmmac: mediatek: use stmmac_get_phy_intf_sel() Russell King (Oracle)
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-07 14:28 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Emil Renner Berthing, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

Use PHY_INTF_SEL_xxx definitions for the fields that correspond to the
phy_intf_sel inputs to the dwmac core.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../ethernet/stmicro/stmmac/dwmac-mediatek.c   | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
index f1b36f0a401d..dcdf28418fec 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
@@ -17,9 +17,6 @@
 
 /* Peri Configuration register for mt2712 */
 #define PERI_ETH_PHY_INTF_SEL	0x418
-#define PHY_INTF_MII		0
-#define PHY_INTF_RGMII		1
-#define PHY_INTF_RMII		4
 #define RMII_CLK_SRC_RXC	BIT(4)
 #define RMII_CLK_SRC_INTERNAL	BIT(5)
 
@@ -118,16 +115,16 @@ static int mt2712_set_interface(struct mediatek_dwmac_plat_data *plat)
 	/* select phy interface in top control domain */
 	switch (plat->phy_mode) {
 	case PHY_INTERFACE_MODE_MII:
-		intf_val |= PHY_INTF_MII;
+		intf_val |= PHY_INTF_SEL_GMII_MII;
 		break;
 	case PHY_INTERFACE_MODE_RMII:
-		intf_val |= (PHY_INTF_RMII | rmii_rxc | rmii_clk_from_mac);
+		intf_val |= PHY_INTF_SEL_RMII | rmii_rxc | rmii_clk_from_mac;
 		break;
 	case PHY_INTERFACE_MODE_RGMII:
 	case PHY_INTERFACE_MODE_RGMII_TXID:
 	case PHY_INTERFACE_MODE_RGMII_RXID:
 	case PHY_INTERFACE_MODE_RGMII_ID:
-		intf_val |= PHY_INTF_RGMII;
+		intf_val |= PHY_INTF_SEL_RGMII;
 		break;
 	default:
 		dev_err(plat->dev, "phy interface not supported\n");
@@ -297,17 +294,18 @@ static int mt8195_set_interface(struct mediatek_dwmac_plat_data *plat)
 	/* select phy interface in top control domain */
 	switch (plat->phy_mode) {
 	case PHY_INTERFACE_MODE_MII:
-		intf_val |= FIELD_PREP(MT8195_ETH_INTF_SEL, PHY_INTF_MII);
+		intf_val |= FIELD_PREP(MT8195_ETH_INTF_SEL,
+				       PHY_INTF_SEL_GMII_MII);
 		break;
 	case PHY_INTERFACE_MODE_RMII:
-		intf_val |= (rmii_rxc | rmii_clk_from_mac);
-		intf_val |= FIELD_PREP(MT8195_ETH_INTF_SEL, PHY_INTF_RMII);
+		intf_val |= rmii_rxc | rmii_clk_from_mac;
+		intf_val |= FIELD_PREP(MT8195_ETH_INTF_SEL, PHY_INTF_SEL_RMII);
 		break;
 	case PHY_INTERFACE_MODE_RGMII:
 	case PHY_INTERFACE_MODE_RGMII_TXID:
 	case PHY_INTERFACE_MODE_RGMII_RXID:
 	case PHY_INTERFACE_MODE_RGMII_ID:
-		intf_val |= FIELD_PREP(MT8195_ETH_INTF_SEL, PHY_INTF_RGMII);
+		intf_val |= FIELD_PREP(MT8195_ETH_INTF_SEL, PHY_INTF_SEL_RGMII);
 		break;
 	default:
 		dev_err(plat->dev, "phy interface not supported\n");
-- 
2.47.3


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH net-next 05/16] net: stmmac: mediatek: use stmmac_get_phy_intf_sel()
  2025-11-07 14:27 [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel() Russell King (Oracle)
                   ` (3 preceding siblings ...)
  2025-11-07 14:28 ` [PATCH net-next 04/16] net: stmmac: mediatek: use PHY_INTF_SEL_xxx Russell King (Oracle)
@ 2025-11-07 14:28 ` Russell King (Oracle)
  2025-11-07 14:28 ` [PATCH net-next 06/16] net: stmmac: mediatek: simplify set_interface() methods Russell King (Oracle)
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-07 14:28 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Emil Renner Berthing, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

Use stmmac_get_phy_intf_sel() to decode the PHY interface mode to the
phy_intf_sel value, validate the result, and pass that into the
implementation specific ->dwmac_set_phy_interface() method. Use this
to configure the PHY interface selection field.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../ethernet/stmicro/stmmac/dwmac-mediatek.c  | 43 +++++++++++--------
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
index dcdf28418fec..0f32732efb75 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
@@ -85,7 +85,8 @@ struct mediatek_dwmac_plat_data {
 };
 
 struct mediatek_dwmac_variant {
-	int (*dwmac_set_phy_interface)(struct mediatek_dwmac_plat_data *plat);
+	int (*dwmac_set_phy_interface)(struct mediatek_dwmac_plat_data *plat,
+				       u8 phy_intf_sel);
 	int (*dwmac_set_delay)(struct mediatek_dwmac_plat_data *plat);
 
 	/* clock ids to be requested */
@@ -106,25 +107,25 @@ static const char * const mt8195_dwmac_clk_l[] = {
 	"axi", "apb", "mac_cg", "mac_main", "ptp_ref"
 };
 
-static int mt2712_set_interface(struct mediatek_dwmac_plat_data *plat)
+static int mt2712_set_interface(struct mediatek_dwmac_plat_data *plat,
+				u8 phy_intf_sel)
 {
 	int rmii_clk_from_mac = plat->rmii_clk_from_mac ? RMII_CLK_SRC_INTERNAL : 0;
 	int rmii_rxc = plat->rmii_rxc ? RMII_CLK_SRC_RXC : 0;
-	u32 intf_val = 0;
+	u32 intf_val;
+
+	intf_val = phy_intf_sel;
 
 	/* select phy interface in top control domain */
 	switch (plat->phy_mode) {
-	case PHY_INTERFACE_MODE_MII:
-		intf_val |= PHY_INTF_SEL_GMII_MII;
-		break;
 	case PHY_INTERFACE_MODE_RMII:
-		intf_val |= PHY_INTF_SEL_RMII | rmii_rxc | rmii_clk_from_mac;
+		intf_val |= rmii_rxc | rmii_clk_from_mac;
 		break;
+	case PHY_INTERFACE_MODE_MII:
 	case PHY_INTERFACE_MODE_RGMII:
 	case PHY_INTERFACE_MODE_RGMII_TXID:
 	case PHY_INTERFACE_MODE_RGMII_RXID:
 	case PHY_INTERFACE_MODE_RGMII_ID:
-		intf_val |= PHY_INTF_SEL_RGMII;
 		break;
 	default:
 		dev_err(plat->dev, "phy interface not supported\n");
@@ -285,27 +286,25 @@ static const struct mediatek_dwmac_variant mt2712_gmac_variant = {
 		.tx_delay_max = 17600,
 };
 
-static int mt8195_set_interface(struct mediatek_dwmac_plat_data *plat)
+static int mt8195_set_interface(struct mediatek_dwmac_plat_data *plat,
+				u8 phy_intf_sel)
 {
 	int rmii_clk_from_mac = plat->rmii_clk_from_mac ? MT8195_RMII_CLK_SRC_INTERNAL : 0;
 	int rmii_rxc = plat->rmii_rxc ? MT8195_RMII_CLK_SRC_RXC : 0;
-	u32 intf_val = 0;
+	u32 intf_val;
+
+	intf_val = FIELD_PREP(MT8195_ETH_INTF_SEL, phy_intf_sel);
 
 	/* select phy interface in top control domain */
 	switch (plat->phy_mode) {
-	case PHY_INTERFACE_MODE_MII:
-		intf_val |= FIELD_PREP(MT8195_ETH_INTF_SEL,
-				       PHY_INTF_SEL_GMII_MII);
-		break;
 	case PHY_INTERFACE_MODE_RMII:
 		intf_val |= rmii_rxc | rmii_clk_from_mac;
-		intf_val |= FIELD_PREP(MT8195_ETH_INTF_SEL, PHY_INTF_SEL_RMII);
 		break;
+	case PHY_INTERFACE_MODE_MII:
 	case PHY_INTERFACE_MODE_RGMII:
 	case PHY_INTERFACE_MODE_RGMII_TXID:
 	case PHY_INTERFACE_MODE_RGMII_RXID:
 	case PHY_INTERFACE_MODE_RGMII_ID:
-		intf_val |= FIELD_PREP(MT8195_ETH_INTF_SEL, PHY_INTF_SEL_RGMII);
 		break;
 	default:
 		dev_err(plat->dev, "phy interface not supported\n");
@@ -525,10 +524,18 @@ static int mediatek_dwmac_init(struct device *dev, void *priv)
 {
 	struct mediatek_dwmac_plat_data *plat = priv;
 	const struct mediatek_dwmac_variant *variant = plat->variant;
-	int ret;
+	int phy_intf_sel, ret;
 
 	if (variant->dwmac_set_phy_interface) {
-		ret = variant->dwmac_set_phy_interface(plat);
+		phy_intf_sel = stmmac_get_phy_intf_sel(plat->phy_mode);
+		if (phy_intf_sel != PHY_INTF_SEL_GMII_MII &&
+		    phy_intf_sel != PHY_INTF_SEL_RGMII &&
+		    phy_intf_sel != PHY_INTF_SEL_RMII) {
+			dev_err(plat->dev, "phy interface not supported\n");
+			return phy_intf_sel < 0 ? phy_intf_sel : -EINVAL;
+		}
+
+		ret = variant->dwmac_set_phy_interface(plat, phy_intf_sel);
 		if (ret) {
 			dev_err(dev, "failed to set phy interface, err = %d\n", ret);
 			return ret;
-- 
2.47.3


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH net-next 06/16] net: stmmac: mediatek: simplify set_interface() methods
  2025-11-07 14:27 [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel() Russell King (Oracle)
                   ` (4 preceding siblings ...)
  2025-11-07 14:28 ` [PATCH net-next 05/16] net: stmmac: mediatek: use stmmac_get_phy_intf_sel() Russell King (Oracle)
@ 2025-11-07 14:28 ` Russell King (Oracle)
  2025-11-07 14:28 ` [PATCH net-next 07/16] net: stmmac: meson8b: use PHY_INTF_SEL_xxx Russell King (Oracle)
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-07 14:28 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Emil Renner Berthing, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

Use the phy_intf_sel field value when deciding what other options to
apply for the configuration register.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../ethernet/stmicro/stmmac/dwmac-mediatek.c  | 50 +++++--------------
 1 file changed, 12 insertions(+), 38 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
index 0f32732efb75..1f2d7d19ca56 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
@@ -110,26 +110,13 @@ static const char * const mt8195_dwmac_clk_l[] = {
 static int mt2712_set_interface(struct mediatek_dwmac_plat_data *plat,
 				u8 phy_intf_sel)
 {
-	int rmii_clk_from_mac = plat->rmii_clk_from_mac ? RMII_CLK_SRC_INTERNAL : 0;
-	int rmii_rxc = plat->rmii_rxc ? RMII_CLK_SRC_RXC : 0;
-	u32 intf_val;
+	u32 intf_val = phy_intf_sel;
 
-	intf_val = phy_intf_sel;
-
-	/* select phy interface in top control domain */
-	switch (plat->phy_mode) {
-	case PHY_INTERFACE_MODE_RMII:
-		intf_val |= rmii_rxc | rmii_clk_from_mac;
-		break;
-	case PHY_INTERFACE_MODE_MII:
-	case PHY_INTERFACE_MODE_RGMII:
-	case PHY_INTERFACE_MODE_RGMII_TXID:
-	case PHY_INTERFACE_MODE_RGMII_RXID:
-	case PHY_INTERFACE_MODE_RGMII_ID:
-		break;
-	default:
-		dev_err(plat->dev, "phy interface not supported\n");
-		return -EINVAL;
+	if (phy_intf_sel == PHY_INTF_SEL_RMII) {
+		if (plat->rmii_clk_from_mac)
+			intf_val |= RMII_CLK_SRC_INTERNAL;
+		if (plat->rmii_rxc)
+			intf_val |= RMII_CLK_SRC_RXC;
 	}
 
 	regmap_write(plat->peri_regmap, PERI_ETH_PHY_INTF_SEL, intf_val);
@@ -289,26 +276,13 @@ static const struct mediatek_dwmac_variant mt2712_gmac_variant = {
 static int mt8195_set_interface(struct mediatek_dwmac_plat_data *plat,
 				u8 phy_intf_sel)
 {
-	int rmii_clk_from_mac = plat->rmii_clk_from_mac ? MT8195_RMII_CLK_SRC_INTERNAL : 0;
-	int rmii_rxc = plat->rmii_rxc ? MT8195_RMII_CLK_SRC_RXC : 0;
-	u32 intf_val;
+	u32 intf_val = FIELD_PREP(MT8195_ETH_INTF_SEL, phy_intf_sel);
 
-	intf_val = FIELD_PREP(MT8195_ETH_INTF_SEL, phy_intf_sel);
-
-	/* select phy interface in top control domain */
-	switch (plat->phy_mode) {
-	case PHY_INTERFACE_MODE_RMII:
-		intf_val |= rmii_rxc | rmii_clk_from_mac;
-		break;
-	case PHY_INTERFACE_MODE_MII:
-	case PHY_INTERFACE_MODE_RGMII:
-	case PHY_INTERFACE_MODE_RGMII_TXID:
-	case PHY_INTERFACE_MODE_RGMII_RXID:
-	case PHY_INTERFACE_MODE_RGMII_ID:
-		break;
-	default:
-		dev_err(plat->dev, "phy interface not supported\n");
-		return -EINVAL;
+	if (phy_intf_sel == PHY_INTF_SEL_RMII) {
+		if (plat->rmii_clk_from_mac)
+			intf_val |= MT8195_RMII_CLK_SRC_INTERNAL;
+		if (plat->rmii_rxc)
+			intf_val |= MT8195_RMII_CLK_SRC_RXC;
 	}
 
 	/* MT8195 only support external PHY */
-- 
2.47.3


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH net-next 07/16] net: stmmac: meson8b: use PHY_INTF_SEL_xxx
  2025-11-07 14:27 [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel() Russell King (Oracle)
                   ` (5 preceding siblings ...)
  2025-11-07 14:28 ` [PATCH net-next 06/16] net: stmmac: mediatek: simplify set_interface() methods Russell King (Oracle)
@ 2025-11-07 14:28 ` Russell King (Oracle)
  2025-11-08 12:30   ` Martin Blumenstingl
  2025-11-07 14:28 ` [PATCH net-next 08/16] net: stmmac: meson8b: use phy_intf_sel directly Russell King (Oracle)
                   ` (8 subsequent siblings)
  15 siblings, 1 reply; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-07 14:28 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Emil Renner Berthing, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
index a50782994b97..f485b9b858bf 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
@@ -26,8 +26,8 @@
 #define PRG_ETH0_RGMII_MODE		BIT(0)
 
 #define PRG_ETH0_EXT_PHY_MODE_MASK	GENMASK(2, 0)
-#define PRG_ETH0_EXT_RGMII_MODE		1
-#define PRG_ETH0_EXT_RMII_MODE		4
+#define PRG_ETH0_EXT_RGMII_MODE		PHY_INTF_SEL_RGMII
+#define PRG_ETH0_EXT_RMII_MODE		PHY_INTF_SEL_RMII
 
 /* mux to choose between fclk_div2 (bit unset) and mpll2 (bit set) */
 #define PRG_ETH0_CLK_M250_SEL_MASK	GENMASK(4, 4)
-- 
2.47.3


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH net-next 08/16] net: stmmac: meson8b: use phy_intf_sel directly
  2025-11-07 14:27 [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel() Russell King (Oracle)
                   ` (6 preceding siblings ...)
  2025-11-07 14:28 ` [PATCH net-next 07/16] net: stmmac: meson8b: use PHY_INTF_SEL_xxx Russell King (Oracle)
@ 2025-11-07 14:28 ` Russell King (Oracle)
  2025-11-08 12:30   ` Martin Blumenstingl
  2025-11-07 14:28 ` [PATCH net-next 09/16] net: stmmac: meson8b: use stmmac_get_phy_intf_sel() Russell King (Oracle)
                   ` (7 subsequent siblings)
  15 siblings, 1 reply; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-07 14:28 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Emil Renner Berthing, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

Rearrange meson_axg_set_phy_mode() to use phy_intf_sel directly,
converting it to the register field for meson8b_dwmac_mask_bits().

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../net/ethernet/stmicro/stmmac/dwmac-meson8b.c  | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
index f485b9b858bf..865cd6166134 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
@@ -26,8 +26,6 @@
 #define PRG_ETH0_RGMII_MODE		BIT(0)
 
 #define PRG_ETH0_EXT_PHY_MODE_MASK	GENMASK(2, 0)
-#define PRG_ETH0_EXT_RGMII_MODE		PHY_INTF_SEL_RGMII
-#define PRG_ETH0_EXT_RMII_MODE		PHY_INTF_SEL_RMII
 
 /* mux to choose between fclk_div2 (bit unset) and mpll2 (bit set) */
 #define PRG_ETH0_CLK_M250_SEL_MASK	GENMASK(4, 4)
@@ -238,21 +236,19 @@ static int meson8b_set_phy_mode(struct meson8b_dwmac *dwmac)
 
 static int meson_axg_set_phy_mode(struct meson8b_dwmac *dwmac)
 {
+	int phy_intf_sel;
+
 	switch (dwmac->phy_mode) {
 	case PHY_INTERFACE_MODE_RGMII:
 	case PHY_INTERFACE_MODE_RGMII_RXID:
 	case PHY_INTERFACE_MODE_RGMII_ID:
 	case PHY_INTERFACE_MODE_RGMII_TXID:
 		/* enable RGMII mode */
-		meson8b_dwmac_mask_bits(dwmac, PRG_ETH0,
-					PRG_ETH0_EXT_PHY_MODE_MASK,
-					PRG_ETH0_EXT_RGMII_MODE);
+		phy_intf_sel = PHY_INTF_SEL_RGMII;
 		break;
 	case PHY_INTERFACE_MODE_RMII:
 		/* disable RGMII mode -> enables RMII mode */
-		meson8b_dwmac_mask_bits(dwmac, PRG_ETH0,
-					PRG_ETH0_EXT_PHY_MODE_MASK,
-					PRG_ETH0_EXT_RMII_MODE);
+		phy_intf_sel = PHY_INTF_SEL_RMII;
 		break;
 	default:
 		dev_err(dwmac->dev, "fail to set phy-mode %s\n",
@@ -260,6 +256,10 @@ static int meson_axg_set_phy_mode(struct meson8b_dwmac *dwmac)
 		return -EINVAL;
 	}
 
+	meson8b_dwmac_mask_bits(dwmac, PRG_ETH0, PRG_ETH0_EXT_PHY_MODE_MASK,
+				FIELD_PREP(PRG_ETH0_EXT_PHY_MODE_MASK,
+					   phy_intf_sel));
+
 	return 0;
 }
 
-- 
2.47.3


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH net-next 09/16] net: stmmac: meson8b: use stmmac_get_phy_intf_sel()
  2025-11-07 14:27 [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel() Russell King (Oracle)
                   ` (7 preceding siblings ...)
  2025-11-07 14:28 ` [PATCH net-next 08/16] net: stmmac: meson8b: use phy_intf_sel directly Russell King (Oracle)
@ 2025-11-07 14:28 ` Russell King (Oracle)
  2025-11-08 12:31   ` Martin Blumenstingl
  2025-11-07 14:28 ` [PATCH net-next 10/16] net: stmmac: starfive: use PHY_INTF_SEL_xxx to select PHY interface Russell King (Oracle)
                   ` (6 subsequent siblings)
  15 siblings, 1 reply; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-07 14:28 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Emil Renner Berthing, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

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.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../ethernet/stmicro/stmmac/dwmac-meson8b.c    | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
index 865cd6166134..e4d5c41294f4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
@@ -238,22 +238,12 @@ static int meson_axg_set_phy_mode(struct meson8b_dwmac *dwmac)
 {
 	int phy_intf_sel;
 
-	switch (dwmac->phy_mode) {
-	case PHY_INTERFACE_MODE_RGMII:
-	case PHY_INTERFACE_MODE_RGMII_RXID:
-	case PHY_INTERFACE_MODE_RGMII_ID:
-	case PHY_INTERFACE_MODE_RGMII_TXID:
-		/* enable RGMII mode */
-		phy_intf_sel = PHY_INTF_SEL_RGMII;
-		break;
-	case PHY_INTERFACE_MODE_RMII:
-		/* disable RGMII mode -> enables RMII mode */
-		phy_intf_sel = PHY_INTF_SEL_RMII;
-		break;
-	default:
+	phy_intf_sel = stmmac_get_phy_intf_sel(dwmac->phy_mode);
+	if (phy_intf_sel != PHY_INTF_SEL_RGMII &&
+	    phy_intf_sel != PHY_INTF_SEL_RMII) {
 		dev_err(dwmac->dev, "fail to set phy-mode %s\n",
 			phy_modes(dwmac->phy_mode));
-		return -EINVAL;
+		return phy_intf_sel < 0 ? phy_intf_sel : -EINVAL;
 	}
 
 	meson8b_dwmac_mask_bits(dwmac, PRG_ETH0, PRG_ETH0_EXT_PHY_MODE_MASK,
-- 
2.47.3


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH net-next 10/16] net: stmmac: starfive: use PHY_INTF_SEL_xxx to select PHY interface
  2025-11-07 14:27 [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel() Russell King (Oracle)
                   ` (8 preceding siblings ...)
  2025-11-07 14:28 ` [PATCH net-next 09/16] net: stmmac: meson8b: use stmmac_get_phy_intf_sel() Russell King (Oracle)
@ 2025-11-07 14:28 ` Russell King (Oracle)
  2025-11-07 14:28 ` [PATCH net-next 11/16] net: stmmac: starfive: use stmmac_get_phy_intf_sel() Russell King (Oracle)
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-07 14:28 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Emil Renner Berthing, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

Use the common dwmac definitions for the PHY interface selection field.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
index 6938dd2a79b7..1ef72576c6f1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
@@ -15,8 +15,8 @@
 
 #include "stmmac_platform.h"
 
-#define STARFIVE_DWMAC_PHY_INFT_RGMII		0x1
-#define STARFIVE_DWMAC_PHY_INFT_RMII		0x4
+#define STARFIVE_DWMAC_PHY_INFT_RGMII		PHY_INTF_SEL_RGMII
+#define STARFIVE_DWMAC_PHY_INFT_RMII		PHY_INTF_SEL_RMII
 #define STARFIVE_DWMAC_PHY_INFT_FIELD		0x7U
 
 #define JH7100_SYSMAIN_REGISTER49_DLYCHAIN	0xc8
-- 
2.47.3


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH net-next 11/16] net: stmmac: starfive: use stmmac_get_phy_intf_sel()
  2025-11-07 14:27 [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel() Russell King (Oracle)
                   ` (9 preceding siblings ...)
  2025-11-07 14:28 ` [PATCH net-next 10/16] net: stmmac: starfive: use PHY_INTF_SEL_xxx to select PHY interface Russell King (Oracle)
@ 2025-11-07 14:28 ` Russell King (Oracle)
  2025-11-07 16:00   ` Emil Renner Berthing
  2025-11-07 14:29 ` [PATCH net-next 12/16] net: stmmac: stm32: use PHY_INTF_SEL_x to select PHY interface Russell King (Oracle)
                   ` (4 subsequent siblings)
  15 siblings, 1 reply; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-07 14:28 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Emil Renner Berthing, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

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.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../ethernet/stmicro/stmmac/dwmac-starfive.c  | 22 +++++--------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
index 1ef72576c6f1..00078b7a6486 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
@@ -35,25 +35,15 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
 	struct starfive_dwmac *dwmac = plat_dat->bsp_priv;
 	struct regmap *regmap;
 	unsigned int args[2];
-	unsigned int mode;
+	int phy_intf_sel;
 	int err;
 
-	switch (plat_dat->phy_interface) {
-	case PHY_INTERFACE_MODE_RMII:
-		mode = STARFIVE_DWMAC_PHY_INFT_RMII;
-		break;
-
-	case PHY_INTERFACE_MODE_RGMII:
-	case PHY_INTERFACE_MODE_RGMII_ID:
-	case PHY_INTERFACE_MODE_RGMII_RXID:
-	case PHY_INTERFACE_MODE_RGMII_TXID:
-		mode = STARFIVE_DWMAC_PHY_INFT_RGMII;
-		break;
-
-	default:
+	phy_intf_sel = stmmac_get_phy_intf_sel(plat_dat->phy_interface);
+	if (phy_intf_sel != PHY_INTF_SEL_RGMII &&
+	    phy_intf_sel != PHY_INTF_SEL_RMII) {
 		dev_err(dwmac->dev, "unsupported interface %s\n",
 			phy_modes(plat_dat->phy_interface));
-		return -EINVAL;
+		return phy_intf_sel < 0 ? phy_intf_sel : -EINVAL;
 	}
 
 	regmap = syscon_regmap_lookup_by_phandle_args(dwmac->dev->of_node,
@@ -65,7 +55,7 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
 	/* args[0]:offset  args[1]: shift */
 	err = regmap_update_bits(regmap, args[0],
 				 STARFIVE_DWMAC_PHY_INFT_FIELD << args[1],
-				 mode << args[1]);
+				 phy_intf_sel << args[1]);
 	if (err)
 		return dev_err_probe(dwmac->dev, err, "error setting phy mode\n");
 
-- 
2.47.3


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH net-next 12/16] net: stmmac: stm32: use PHY_INTF_SEL_x to select PHY interface
  2025-11-07 14:27 [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel() Russell King (Oracle)
                   ` (10 preceding siblings ...)
  2025-11-07 14:28 ` [PATCH net-next 11/16] net: stmmac: starfive: use stmmac_get_phy_intf_sel() Russell King (Oracle)
@ 2025-11-07 14:29 ` Russell King (Oracle)
  2025-11-07 14:29 ` [PATCH net-next 13/16] net: stmmac: stm32: use PHY_INTF_SEL_x directly Russell King (Oracle)
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-07 14:29 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Emil Renner Berthing, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

Convert dwmac-stm32 to use the PHY_INTF_SEL_x definitions.

For stm32mp1, the original definitions used constant 0 (GMII, 0 << 21),
BIT(21) (RGMII, 1 << 21) and BIT(23) (RMII, 4 << 21) to define these,
but from the values it can be clearly seen that these are the
PHY_INTF_SEL_x inputs to the dwmac.

For stm32mp2, the original definitions cover a bitfield 6:4 in the
SYSCFG Ethernet1 control register (according to documentation) and use
the PHY_INTF_SEL_x values.

Use the common dwmac definitions for the PHY interface selection field
by adding the bitfield mask, and using FIELD_PREP() for the bitfield
values.

This removes this incorrect use of BIT().

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../net/ethernet/stmicro/stmmac/dwmac-stm32.c | 20 +++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
index 6c179911ef3f..1545772419d5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
@@ -47,9 +47,13 @@
  *------------------------------------------
  */
 #define SYSCFG_PMCR_ETH_SEL_MII		BIT(20)
-#define SYSCFG_PMCR_ETH_SEL_RGMII	BIT(21)
-#define SYSCFG_PMCR_ETH_SEL_RMII	BIT(23)
-#define SYSCFG_PMCR_ETH_SEL_GMII	0
+#define SYSCFG_PMCR_PHY_INTF_SEL_MASK	GENMASK(23, 21)
+#define SYSCFG_PMCR_ETH_SEL_RGMII	\
+	FIELD_PREP(SYSCFG_PMCR_PHY_INTF_SEL_MASK, PHY_INTF_SEL_RGMII)
+#define SYSCFG_PMCR_ETH_SEL_RMII	\
+	FIELD_PREP(SYSCFG_PMCR_PHY_INTF_SEL_MASK, PHY_INTF_SEL_RMII)
+#define SYSCFG_PMCR_ETH_SEL_GMII	\
+	FIELD_PREP(SYSCFG_PMCR_PHY_INTF_SEL_MASK, PHY_INTF_SEL_GMII_MII)
 #define SYSCFG_MCU_ETH_SEL_MII		0
 #define SYSCFG_MCU_ETH_SEL_RMII		1
 
@@ -60,9 +64,13 @@
 #define SYSCFG_ETHCR_ETH_CLK_SEL	BIT(1)
 #define SYSCFG_ETHCR_ETH_REF_CLK_SEL	BIT(0)
 
-#define SYSCFG_ETHCR_ETH_SEL_MII	0
-#define SYSCFG_ETHCR_ETH_SEL_RGMII	BIT(4)
-#define SYSCFG_ETHCR_ETH_SEL_RMII	BIT(6)
+#define SYSCFG_ETHCR_ETH_SEL_MASK	GENMASK(6, 4)
+#define SYSCFG_ETHCR_ETH_SEL_MII	FIELD_PREP(SYSCFG_ETHCR_ETH_SEL_MASK, \
+						   PHY_INTF_SEL_GMII_MII)
+#define SYSCFG_ETHCR_ETH_SEL_RGMII	FIELD_PREP(SYSCFG_ETHCR_ETH_SEL_MASK, \
+						   PHY_INTF_SEL_RGMII)
+#define SYSCFG_ETHCR_ETH_SEL_RMII	FIELD_PREP(SYSCFG_ETHCR_ETH_SEL_MASK, \
+						   PHY_INTF_SEL_RMII)
 
 /* STM32MPx register definitions
  *
-- 
2.47.3


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH net-next 13/16] net: stmmac: stm32: use PHY_INTF_SEL_x directly
  2025-11-07 14:27 [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel() Russell King (Oracle)
                   ` (11 preceding siblings ...)
  2025-11-07 14:29 ` [PATCH net-next 12/16] net: stmmac: stm32: use PHY_INTF_SEL_x to select PHY interface Russell King (Oracle)
@ 2025-11-07 14:29 ` Russell King (Oracle)
  2025-11-07 14:29 ` [PATCH net-next 14/16] net: stmmac: stm32: use stmmac_get_phy_intf_sel() Russell King (Oracle)
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-07 14:29 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Emil Renner Berthing, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

Rather than defining separate constants for each, use the
PHY_INTF_SEL_x definitions in the switch()es configuring the
control register, and use one FIELD_PREP() to convert phy_intf_sel
to the register value.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../net/ethernet/stmicro/stmmac/dwmac-stm32.c | 32 ++++++++-----------
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
index 1545772419d5..18d26f096f5f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
@@ -48,30 +48,17 @@
  */
 #define SYSCFG_PMCR_ETH_SEL_MII		BIT(20)
 #define SYSCFG_PMCR_PHY_INTF_SEL_MASK	GENMASK(23, 21)
-#define SYSCFG_PMCR_ETH_SEL_RGMII	\
-	FIELD_PREP(SYSCFG_PMCR_PHY_INTF_SEL_MASK, PHY_INTF_SEL_RGMII)
-#define SYSCFG_PMCR_ETH_SEL_RMII	\
-	FIELD_PREP(SYSCFG_PMCR_PHY_INTF_SEL_MASK, PHY_INTF_SEL_RMII)
-#define SYSCFG_PMCR_ETH_SEL_GMII	\
-	FIELD_PREP(SYSCFG_PMCR_PHY_INTF_SEL_MASK, PHY_INTF_SEL_GMII_MII)
 #define SYSCFG_MCU_ETH_SEL_MII		0
 #define SYSCFG_MCU_ETH_SEL_RMII		1
 
 /* STM32MP2 register definitions */
 #define SYSCFG_MP2_ETH_MASK		GENMASK(31, 0)
 
+#define SYSCFG_ETHCR_ETH_SEL_MASK	GENMASK(6, 4)
 #define SYSCFG_ETHCR_ETH_PTP_CLK_SEL	BIT(2)
 #define SYSCFG_ETHCR_ETH_CLK_SEL	BIT(1)
 #define SYSCFG_ETHCR_ETH_REF_CLK_SEL	BIT(0)
 
-#define SYSCFG_ETHCR_ETH_SEL_MASK	GENMASK(6, 4)
-#define SYSCFG_ETHCR_ETH_SEL_MII	FIELD_PREP(SYSCFG_ETHCR_ETH_SEL_MASK, \
-						   PHY_INTF_SEL_GMII_MII)
-#define SYSCFG_ETHCR_ETH_SEL_RGMII	FIELD_PREP(SYSCFG_ETHCR_ETH_SEL_MASK, \
-						   PHY_INTF_SEL_RGMII)
-#define SYSCFG_ETHCR_ETH_SEL_RMII	FIELD_PREP(SYSCFG_ETHCR_ETH_SEL_MASK, \
-						   PHY_INTF_SEL_RMII)
-
 /* STM32MPx register definitions
  *
  * Below table summarizes the clock requirement and clock sources for
@@ -244,10 +231,12 @@ static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat)
 {
 	struct stm32_dwmac *dwmac = plat_dat->bsp_priv;
 	u32 reg = dwmac->mode_reg;
+	u8 phy_intf_sel;
 	int val = 0;
 
 	switch (plat_dat->phy_interface) {
 	case PHY_INTERFACE_MODE_MII:
+		phy_intf_sel = PHY_INTF_SEL_GMII_MII;
 		/*
 		 * STM32MP15xx supports both MII and GMII, STM32MP13xx MII only.
 		 * SYSCFG_PMCSETR ETH_SELMII is present only on STM32MP15xx and
@@ -258,12 +247,12 @@ static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat)
 			val |= SYSCFG_PMCR_ETH_SEL_MII;
 		break;
 	case PHY_INTERFACE_MODE_GMII:
-		val = SYSCFG_PMCR_ETH_SEL_GMII;
+		phy_intf_sel = PHY_INTF_SEL_GMII_MII;
 		if (dwmac->enable_eth_ck)
 			val |= SYSCFG_PMCR_ETH_CLK_SEL;
 		break;
 	case PHY_INTERFACE_MODE_RMII:
-		val = SYSCFG_PMCR_ETH_SEL_RMII;
+		phy_intf_sel = PHY_INTF_SEL_RMII;
 		if (dwmac->enable_eth_ck)
 			val |= SYSCFG_PMCR_ETH_REF_CLK_SEL;
 		break;
@@ -271,7 +260,7 @@ static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat)
 	case PHY_INTERFACE_MODE_RGMII_ID:
 	case PHY_INTERFACE_MODE_RGMII_RXID:
 	case PHY_INTERFACE_MODE_RGMII_TXID:
-		val = SYSCFG_PMCR_ETH_SEL_RGMII;
+		phy_intf_sel = PHY_INTF_SEL_RGMII;
 		if (dwmac->enable_eth_ck)
 			val |= SYSCFG_PMCR_ETH_CLK_SEL;
 		break;
@@ -284,6 +273,8 @@ static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat)
 
 	dev_dbg(dwmac->dev, "Mode %s", phy_modes(plat_dat->phy_interface));
 
+	val |= FIELD_PREP(SYSCFG_PMCR_PHY_INTF_SEL_MASK, phy_intf_sel);
+
 	/* Shift value at correct ethernet MAC offset in SYSCFG_PMCSETR */
 	val <<= ffs(dwmac->mode_mask) - ffs(SYSCFG_MP1_ETH_MASK);
 
@@ -299,6 +290,7 @@ static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat)
 static int stm32mp2_configure_syscfg(struct plat_stmmacenet_data *plat_dat)
 {
 	struct stm32_dwmac *dwmac = plat_dat->bsp_priv;
+	u8 phy_intf_sel = PHY_INTF_SEL_GMII_MII;
 	u32 reg = dwmac->mode_reg;
 	int val = 0;
 
@@ -307,7 +299,7 @@ static int stm32mp2_configure_syscfg(struct plat_stmmacenet_data *plat_dat)
 		/* ETH_REF_CLK_SEL bit in SYSCFG register is not applicable in MII mode */
 		break;
 	case PHY_INTERFACE_MODE_RMII:
-		val = SYSCFG_ETHCR_ETH_SEL_RMII;
+		phy_intf_sel = PHY_INTF_SEL_RMII;
 		if (dwmac->enable_eth_ck) {
 			/* Internal clock ETH_CLK of 50MHz from RCC is used */
 			val |= SYSCFG_ETHCR_ETH_REF_CLK_SEL;
@@ -317,7 +309,7 @@ static int stm32mp2_configure_syscfg(struct plat_stmmacenet_data *plat_dat)
 	case PHY_INTERFACE_MODE_RGMII_ID:
 	case PHY_INTERFACE_MODE_RGMII_RXID:
 	case PHY_INTERFACE_MODE_RGMII_TXID:
-		val = SYSCFG_ETHCR_ETH_SEL_RGMII;
+		phy_intf_sel = PHY_INTF_SEL_RGMII;
 		fallthrough;
 	case PHY_INTERFACE_MODE_GMII:
 		if (dwmac->enable_eth_ck) {
@@ -334,6 +326,8 @@ static int stm32mp2_configure_syscfg(struct plat_stmmacenet_data *plat_dat)
 
 	dev_dbg(dwmac->dev, "Mode %s", phy_modes(plat_dat->phy_interface));
 
+	val |= FIELD_PREP(SYSCFG_ETHCR_ETH_SEL_MASK, phy_intf_sel);
+
 	/* Select PTP (IEEE1588) clock selection from RCC (ck_ker_ethxptp) */
 	val |= SYSCFG_ETHCR_ETH_PTP_CLK_SEL;
 
-- 
2.47.3


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH net-next 14/16] net: stmmac: stm32: use stmmac_get_phy_intf_sel()
  2025-11-07 14:27 [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel() Russell King (Oracle)
                   ` (12 preceding siblings ...)
  2025-11-07 14:29 ` [PATCH net-next 13/16] net: stmmac: stm32: use PHY_INTF_SEL_x directly Russell King (Oracle)
@ 2025-11-07 14:29 ` Russell King (Oracle)
  2025-11-07 14:29 ` [PATCH net-next 15/16] net: stmmac: visconti: use PHY_INTF_SEL_x to select PHY interface Russell King (Oracle)
  2025-11-07 14:29 ` [PATCH net-next 16/16] net: stmmac: visconti: use stmmac_get_phy_intf_sel() Russell King (Oracle)
  15 siblings, 0 replies; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-07 14:29 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Emil Renner Berthing, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

Use stmmac_get_phy_intf_sel() to decode the PHY interface mode to the
phy_intf_sel value. As both configure functions would end up with the
same code, call this from stm32mp1_set_mode(), validate the result and
pass the resulting value into the stm32 configure function. Use this
value to set the operating mode for the DWMAC core.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../net/ethernet/stmicro/stmmac/dwmac-stm32.c | 42 ++++++++++---------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
index 18d26f096f5f..e1b260ed4790 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
@@ -227,16 +227,17 @@ static int stm32mp1_validate_ethck_rate(struct plat_stmmacenet_data *plat_dat)
 	return -EINVAL;
 }
 
-static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat)
+static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat,
+				   u8 phy_intf_sel)
 {
 	struct stm32_dwmac *dwmac = plat_dat->bsp_priv;
 	u32 reg = dwmac->mode_reg;
-	u8 phy_intf_sel;
-	int val = 0;
+	int val;
+
+	val = FIELD_PREP(SYSCFG_PMCR_PHY_INTF_SEL_MASK, phy_intf_sel);
 
 	switch (plat_dat->phy_interface) {
 	case PHY_INTERFACE_MODE_MII:
-		phy_intf_sel = PHY_INTF_SEL_GMII_MII;
 		/*
 		 * STM32MP15xx supports both MII and GMII, STM32MP13xx MII only.
 		 * SYSCFG_PMCSETR ETH_SELMII is present only on STM32MP15xx and
@@ -247,12 +248,10 @@ static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat)
 			val |= SYSCFG_PMCR_ETH_SEL_MII;
 		break;
 	case PHY_INTERFACE_MODE_GMII:
-		phy_intf_sel = PHY_INTF_SEL_GMII_MII;
 		if (dwmac->enable_eth_ck)
 			val |= SYSCFG_PMCR_ETH_CLK_SEL;
 		break;
 	case PHY_INTERFACE_MODE_RMII:
-		phy_intf_sel = PHY_INTF_SEL_RMII;
 		if (dwmac->enable_eth_ck)
 			val |= SYSCFG_PMCR_ETH_REF_CLK_SEL;
 		break;
@@ -260,7 +259,6 @@ static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat)
 	case PHY_INTERFACE_MODE_RGMII_ID:
 	case PHY_INTERFACE_MODE_RGMII_RXID:
 	case PHY_INTERFACE_MODE_RGMII_TXID:
-		phy_intf_sel = PHY_INTF_SEL_RGMII;
 		if (dwmac->enable_eth_ck)
 			val |= SYSCFG_PMCR_ETH_CLK_SEL;
 		break;
@@ -273,8 +271,6 @@ static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat)
 
 	dev_dbg(dwmac->dev, "Mode %s", phy_modes(plat_dat->phy_interface));
 
-	val |= FIELD_PREP(SYSCFG_PMCR_PHY_INTF_SEL_MASK, phy_intf_sel);
-
 	/* Shift value at correct ethernet MAC offset in SYSCFG_PMCSETR */
 	val <<= ffs(dwmac->mode_mask) - ffs(SYSCFG_MP1_ETH_MASK);
 
@@ -287,19 +283,20 @@ static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat)
 				 dwmac->mode_mask, val);
 }
 
-static int stm32mp2_configure_syscfg(struct plat_stmmacenet_data *plat_dat)
+static int stm32mp2_configure_syscfg(struct plat_stmmacenet_data *plat_dat,
+				     u8 phy_intf_sel)
 {
 	struct stm32_dwmac *dwmac = plat_dat->bsp_priv;
-	u8 phy_intf_sel = PHY_INTF_SEL_GMII_MII;
 	u32 reg = dwmac->mode_reg;
-	int val = 0;
+	int val;
+
+	val = FIELD_PREP(SYSCFG_ETHCR_ETH_SEL_MASK, phy_intf_sel);
 
 	switch (plat_dat->phy_interface) {
 	case PHY_INTERFACE_MODE_MII:
 		/* ETH_REF_CLK_SEL bit in SYSCFG register is not applicable in MII mode */
 		break;
 	case PHY_INTERFACE_MODE_RMII:
-		phy_intf_sel = PHY_INTF_SEL_RMII;
 		if (dwmac->enable_eth_ck) {
 			/* Internal clock ETH_CLK of 50MHz from RCC is used */
 			val |= SYSCFG_ETHCR_ETH_REF_CLK_SEL;
@@ -309,8 +306,6 @@ static int stm32mp2_configure_syscfg(struct plat_stmmacenet_data *plat_dat)
 	case PHY_INTERFACE_MODE_RGMII_ID:
 	case PHY_INTERFACE_MODE_RGMII_RXID:
 	case PHY_INTERFACE_MODE_RGMII_TXID:
-		phy_intf_sel = PHY_INTF_SEL_RGMII;
-		fallthrough;
 	case PHY_INTERFACE_MODE_GMII:
 		if (dwmac->enable_eth_ck) {
 			/* Internal clock ETH_CLK of 125MHz from RCC is used */
@@ -326,8 +321,6 @@ static int stm32mp2_configure_syscfg(struct plat_stmmacenet_data *plat_dat)
 
 	dev_dbg(dwmac->dev, "Mode %s", phy_modes(plat_dat->phy_interface));
 
-	val |= FIELD_PREP(SYSCFG_ETHCR_ETH_SEL_MASK, phy_intf_sel);
-
 	/* Select PTP (IEEE1588) clock selection from RCC (ck_ker_ethxptp) */
 	val |= SYSCFG_ETHCR_ETH_PTP_CLK_SEL;
 
@@ -339,7 +332,7 @@ static int stm32mp2_configure_syscfg(struct plat_stmmacenet_data *plat_dat)
 static int stm32mp1_set_mode(struct plat_stmmacenet_data *plat_dat)
 {
 	struct stm32_dwmac *dwmac = plat_dat->bsp_priv;
-	int ret;
+	int phy_intf_sel, ret;
 
 	ret = stm32mp1_select_ethck_external(plat_dat);
 	if (ret)
@@ -349,10 +342,19 @@ static int stm32mp1_set_mode(struct plat_stmmacenet_data *plat_dat)
 	if (ret)
 		return ret;
 
+	phy_intf_sel = stmmac_get_phy_intf_sel(plat_dat->phy_interface);
+	if (phy_intf_sel != PHY_INTF_SEL_GMII_MII &&
+	    phy_intf_sel != PHY_INTF_SEL_RGMII &&
+	    phy_intf_sel != PHY_INTF_SEL_RMII) {
+		dev_err(dwmac->dev, "Mode %s not supported\n",
+			phy_modes(plat_dat->phy_interface));
+		return phy_intf_sel < 0 ? phy_intf_sel : -EINVAL;
+	}
+
 	if (!dwmac->ops->is_mp2)
-		return stm32mp1_configure_pmcr(plat_dat);
+		return stm32mp1_configure_pmcr(plat_dat, phy_intf_sel);
 	else
-		return stm32mp2_configure_syscfg(plat_dat);
+		return stm32mp2_configure_syscfg(plat_dat, phy_intf_sel);
 }
 
 static int stm32mcu_set_mode(struct plat_stmmacenet_data *plat_dat)
-- 
2.47.3


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH net-next 15/16] net: stmmac: visconti: use PHY_INTF_SEL_x to select PHY interface
  2025-11-07 14:27 [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel() Russell King (Oracle)
                   ` (13 preceding siblings ...)
  2025-11-07 14:29 ` [PATCH net-next 14/16] net: stmmac: stm32: use stmmac_get_phy_intf_sel() Russell King (Oracle)
@ 2025-11-07 14:29 ` Russell King (Oracle)
  2025-11-07 14:29 ` [PATCH net-next 16/16] net: stmmac: visconti: use stmmac_get_phy_intf_sel() Russell King (Oracle)
  15 siblings, 0 replies; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-07 14:29 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Emil Renner Berthing, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

Convert dwmac-visconti to use the PHY_INTF_SEL_x definitions. The
original definitions used constant 0, BIT(0) (==1) and BIT(2) (==4)
to define these, but the values of the bits corresponds with the
PHY_INTF_SEL_x values, so it is highly likely that these are not
individual bits, but the PHY_INTF_SEL_x bitfield.

This removes this incorrect use of BIT().

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
index bd65d4239054..7b6b048e1be0 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
@@ -42,9 +42,9 @@
 
 #define ETHER_CLK_SEL_RX_TX_CLK_EN (ETHER_CLK_SEL_RX_CLK_EN | ETHER_CLK_SEL_TX_CLK_EN)
 
-#define ETHER_CONFIG_INTF_MII 0
-#define ETHER_CONFIG_INTF_RGMII BIT(0)
-#define ETHER_CONFIG_INTF_RMII BIT(2)
+#define ETHER_CONFIG_INTF_MII	PHY_INTF_SEL_GMII_MII
+#define ETHER_CONFIG_INTF_RGMII	PHY_INTF_SEL_RGMII
+#define ETHER_CONFIG_INTF_RMII	PHY_INTF_SEL_RMII
 
 struct visconti_eth {
 	void __iomem *reg;
-- 
2.47.3


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH net-next 16/16] net: stmmac: visconti: use stmmac_get_phy_intf_sel()
  2025-11-07 14:27 [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel() Russell King (Oracle)
                   ` (14 preceding siblings ...)
  2025-11-07 14:29 ` [PATCH net-next 15/16] net: stmmac: visconti: use PHY_INTF_SEL_x to select PHY interface Russell King (Oracle)
@ 2025-11-07 14:29 ` Russell King (Oracle)
  2025-11-07 18:23   ` Maxime Chevallier
  15 siblings, 1 reply; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-07 14:29 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Emil Renner Berthing, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

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.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../ethernet/stmicro/stmmac/dwmac-visconti.c  | 26 +++++--------------
 1 file changed, 6 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
index 7b6b048e1be0..9497b13a5753 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
@@ -42,10 +42,6 @@
 
 #define ETHER_CLK_SEL_RX_TX_CLK_EN (ETHER_CLK_SEL_RX_CLK_EN | ETHER_CLK_SEL_TX_CLK_EN)
 
-#define ETHER_CONFIG_INTF_MII	PHY_INTF_SEL_GMII_MII
-#define ETHER_CONFIG_INTF_RGMII	PHY_INTF_SEL_RGMII
-#define ETHER_CONFIG_INTF_RMII	PHY_INTF_SEL_RMII
-
 struct visconti_eth {
 	void __iomem *reg;
 	struct clk *phy_ref_clk;
@@ -150,22 +146,12 @@ static int visconti_eth_init_hw(struct platform_device *pdev, struct plat_stmmac
 {
 	struct visconti_eth *dwmac = plat_dat->bsp_priv;
 	unsigned int clk_sel_val;
-	u32 phy_intf_sel;
-
-	switch (plat_dat->phy_interface) {
-	case PHY_INTERFACE_MODE_RGMII:
-	case PHY_INTERFACE_MODE_RGMII_ID:
-	case PHY_INTERFACE_MODE_RGMII_RXID:
-	case PHY_INTERFACE_MODE_RGMII_TXID:
-		phy_intf_sel = ETHER_CONFIG_INTF_RGMII;
-		break;
-	case PHY_INTERFACE_MODE_MII:
-		phy_intf_sel = ETHER_CONFIG_INTF_MII;
-		break;
-	case PHY_INTERFACE_MODE_RMII:
-		phy_intf_sel = ETHER_CONFIG_INTF_RMII;
-		break;
-	default:
+	int phy_intf_sel;
+
+	phy_intf_sel = stmmac_get_phy_intf_sel(plat_dat->phy_interface);
+	if (phy_intf_sel != PHY_INTF_SEL_GMII_MII &&
+	    phy_intf_sel != PHY_INTF_SEL_RGMII &&
+	    phy_intf_sel != PHY_INTF_SEL_RMII) {
 		dev_err(&pdev->dev, "Unsupported phy-mode (%d)\n", plat_dat->phy_interface);
 		return -EOPNOTSUPP;
 	}
-- 
2.47.3


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [PATCH net-next 11/16] net: stmmac: starfive: use stmmac_get_phy_intf_sel()
  2025-11-07 14:28 ` [PATCH net-next 11/16] net: stmmac: starfive: use stmmac_get_phy_intf_sel() Russell King (Oracle)
@ 2025-11-07 16:00   ` Emil Renner Berthing
  2025-11-07 16:08     ` Russell King (Oracle)
  0 siblings, 1 reply; 25+ messages in thread
From: Emil Renner Berthing @ 2025-11-07 16:00 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King (Oracle)
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Jerome Brunet,
	Keguang Zhang, Kevin Hilman, linux-amlogic, linux-arm-kernel,
	linux-mediatek, linux-mips, linux-stm32, Martin Blumenstingl,
	Matthias Brugger, Maxime Coquelin, Minda Chen, Neil Armstrong,
	netdev, Nobuhiro Iwamatsu, Paolo Abeni

Quoting Russell King (Oracle) (2025-11-07 15:28:55)
> 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.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
>  .../ethernet/stmicro/stmmac/dwmac-starfive.c  | 22 +++++--------------
>  1 file changed, 6 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
> index 1ef72576c6f1..00078b7a6486 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
> @@ -35,25 +35,15 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
>         struct starfive_dwmac *dwmac = plat_dat->bsp_priv;
>         struct regmap *regmap;
>         unsigned int args[2];
> -       unsigned int mode;
> +       int phy_intf_sel;
>         int err;
>
> -       switch (plat_dat->phy_interface) {
> -       case PHY_INTERFACE_MODE_RMII:
> -               mode = STARFIVE_DWMAC_PHY_INFT_RMII;
> -               break;
> -
> -       case PHY_INTERFACE_MODE_RGMII:
> -       case PHY_INTERFACE_MODE_RGMII_ID:
> -       case PHY_INTERFACE_MODE_RGMII_RXID:
> -       case PHY_INTERFACE_MODE_RGMII_TXID:
> -               mode = STARFIVE_DWMAC_PHY_INFT_RGMII;
> -               break;

After these two patches the STARFIVE_DWMAC_PHY_INFT_RMII and ..RGMII macros are
left unused. Maybe just squash the patches and remove the definitions?

/Emil

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH net-next 11/16] net: stmmac: starfive: use stmmac_get_phy_intf_sel()
  2025-11-07 16:00   ` Emil Renner Berthing
@ 2025-11-07 16:08     ` Russell King (Oracle)
  0 siblings, 0 replies; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-07 16:08 UTC (permalink / raw)
  To: Emil Renner Berthing
  Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
	AngeloGioacchino Del Regno, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

On Fri, Nov 07, 2025 at 11:00:35AM -0500, Emil Renner Berthing wrote:
> Quoting Russell King (Oracle) (2025-11-07 15:28:55)
> > 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.
> >
> > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> > ---
> >  .../ethernet/stmicro/stmmac/dwmac-starfive.c  | 22 +++++--------------
> >  1 file changed, 6 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
> > index 1ef72576c6f1..00078b7a6486 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
> > @@ -35,25 +35,15 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
> >         struct starfive_dwmac *dwmac = plat_dat->bsp_priv;
> >         struct regmap *regmap;
> >         unsigned int args[2];
> > -       unsigned int mode;
> > +       int phy_intf_sel;
> >         int err;
> >
> > -       switch (plat_dat->phy_interface) {
> > -       case PHY_INTERFACE_MODE_RMII:
> > -               mode = STARFIVE_DWMAC_PHY_INFT_RMII;
> > -               break;
> > -
> > -       case PHY_INTERFACE_MODE_RGMII:
> > -       case PHY_INTERFACE_MODE_RGMII_ID:
> > -       case PHY_INTERFACE_MODE_RGMII_RXID:
> > -       case PHY_INTERFACE_MODE_RGMII_TXID:
> > -               mode = STARFIVE_DWMAC_PHY_INFT_RGMII;
> > -               break;
> 
> After these two patches the STARFIVE_DWMAC_PHY_INFT_RMII and ..RGMII macros are
> left unused.

Thanks, I'll remove them in this patch.

> Maybe just squash the patches and remove the definitions?

It's two logical changes, thus two patches. Reviewers find that this
makes it easier to review.

Given the number of platform glues that I'm modifying, I don't want
to change some of them using one big all encompassing patch and
others as a set of logical changes - that would be totally insane
to manage.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH net-next 16/16] net: stmmac: visconti: use stmmac_get_phy_intf_sel()
  2025-11-07 14:29 ` [PATCH net-next 16/16] net: stmmac: visconti: use stmmac_get_phy_intf_sel() Russell King (Oracle)
@ 2025-11-07 18:23   ` Maxime Chevallier
  2025-11-08  7:58     ` Russell King (Oracle)
  0 siblings, 1 reply; 25+ messages in thread
From: Maxime Chevallier @ 2025-11-07 18:23 UTC (permalink / raw)
  To: Russell King (Oracle), Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, AngeloGioacchino Del Regno,
	David S. Miller, Emil Renner Berthing, Eric Dumazet,
	Jakub Kicinski, Jerome Brunet, Keguang Zhang, Kevin Hilman,
	linux-amlogic, linux-arm-kernel, linux-mediatek, linux-mips,
	linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

Hi Russell,

On 07/11/2025 15:29, Russell King (Oracle) wrote:
> 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.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
>  .../ethernet/stmicro/stmmac/dwmac-visconti.c  | 26 +++++--------------
>  1 file changed, 6 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
> index 7b6b048e1be0..9497b13a5753 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
> @@ -42,10 +42,6 @@
>  
>  #define ETHER_CLK_SEL_RX_TX_CLK_EN (ETHER_CLK_SEL_RX_CLK_EN | ETHER_CLK_SEL_TX_CLK_EN)
>  
> -#define ETHER_CONFIG_INTF_MII	PHY_INTF_SEL_GMII_MII
> -#define ETHER_CONFIG_INTF_RGMII	PHY_INTF_SEL_RGMII
> -#define ETHER_CONFIG_INTF_RMII	PHY_INTF_SEL_RMII
> -
>  struct visconti_eth {
>  	void __iomem *reg;
>  	struct clk *phy_ref_clk;
> @@ -150,22 +146,12 @@ static int visconti_eth_init_hw(struct platform_device *pdev, struct plat_stmmac
>  {
>  	struct visconti_eth *dwmac = plat_dat->bsp_priv;
>  	unsigned int clk_sel_val;
> -	u32 phy_intf_sel;
> -
> -	switch (plat_dat->phy_interface) {
> -	case PHY_INTERFACE_MODE_RGMII:
> -	case PHY_INTERFACE_MODE_RGMII_ID:
> -	case PHY_INTERFACE_MODE_RGMII_RXID:
> -	case PHY_INTERFACE_MODE_RGMII_TXID:
> -		phy_intf_sel = ETHER_CONFIG_INTF_RGMII;
> -		break;
> -	case PHY_INTERFACE_MODE_MII:
> -		phy_intf_sel = ETHER_CONFIG_INTF_MII;
> -		break;
> -	case PHY_INTERFACE_MODE_RMII:
> -		phy_intf_sel = ETHER_CONFIG_INTF_RMII;
> -		break;
> -	default:
> +	int phy_intf_sel;
> +
> +	phy_intf_sel = stmmac_get_phy_intf_sel(plat_dat->phy_interface);
> +	if (phy_intf_sel != PHY_INTF_SEL_GMII_MII &&
> +	    phy_intf_sel != PHY_INTF_SEL_RGMII &&
> +	    phy_intf_sel != PHY_INTF_SEL_RMII) {
>  		dev_err(&pdev->dev, "Unsupported phy-mode (%d)\n", plat_dat->phy_interface);
>  		return -EOPNOTSUPP;
>  	}

Probably not too big of a deal, but don't we now incorrectly accept the
"gmii" mode ?

Maxime

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH net-next 16/16] net: stmmac: visconti: use stmmac_get_phy_intf_sel()
  2025-11-07 18:23   ` Maxime Chevallier
@ 2025-11-08  7:58     ` Russell King (Oracle)
  2025-11-09 16:38       ` Maxime Chevallier
  0 siblings, 1 reply; 25+ messages in thread
From: Russell King (Oracle) @ 2025-11-08  7:58 UTC (permalink / raw)
  To: Maxime Chevallier
  Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
	AngeloGioacchino Del Regno, David S. Miller, Emil Renner Berthing,
	Eric Dumazet, Jakub Kicinski, Jerome Brunet, Keguang Zhang,
	Kevin Hilman, linux-amlogic, linux-arm-kernel, linux-mediatek,
	linux-mips, linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni

On Fri, Nov 07, 2025 at 07:23:26PM +0100, Maxime Chevallier wrote:
> Hi Russell,
> 
> On 07/11/2025 15:29, Russell King (Oracle) wrote:
> > -	switch (plat_dat->phy_interface) {
> > -	case PHY_INTERFACE_MODE_RGMII:
> > -	case PHY_INTERFACE_MODE_RGMII_ID:
> > -	case PHY_INTERFACE_MODE_RGMII_RXID:
> > -	case PHY_INTERFACE_MODE_RGMII_TXID:
> > -		phy_intf_sel = ETHER_CONFIG_INTF_RGMII;
> > -		break;
> > -	case PHY_INTERFACE_MODE_MII:
> > -		phy_intf_sel = ETHER_CONFIG_INTF_MII;
> > -		break;
> > -	case PHY_INTERFACE_MODE_RMII:
> > -		phy_intf_sel = ETHER_CONFIG_INTF_RMII;
> > -		break;
> > -	default:
> > +	int phy_intf_sel;
> > +
> > +	phy_intf_sel = stmmac_get_phy_intf_sel(plat_dat->phy_interface);
> > +	if (phy_intf_sel != PHY_INTF_SEL_GMII_MII &&
> > +	    phy_intf_sel != PHY_INTF_SEL_RGMII &&
> > +	    phy_intf_sel != PHY_INTF_SEL_RMII) {
> >  		dev_err(&pdev->dev, "Unsupported phy-mode (%d)\n", plat_dat->phy_interface);
> >  		return -EOPNOTSUPP;
> >  	}
> 
> Probably not too big of a deal, but don't we now incorrectly accept the
> "gmii" mode ?

We will accept GMII mode, but (a) does that matter, and (b) shouldn't
the DT binding be checking the phy-mode (we have some bindings that do.)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH net-next 07/16] net: stmmac: meson8b: use PHY_INTF_SEL_xxx
  2025-11-07 14:28 ` [PATCH net-next 07/16] net: stmmac: meson8b: use PHY_INTF_SEL_xxx Russell King (Oracle)
@ 2025-11-08 12:30   ` Martin Blumenstingl
  0 siblings, 0 replies; 25+ messages in thread
From: Martin Blumenstingl @ 2025-11-08 12:30 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
	AngeloGioacchino Del Regno, David S. Miller, Emil Renner Berthing,
	Eric Dumazet, Jakub Kicinski, Jerome Brunet, Keguang Zhang,
	Kevin Hilman, linux-amlogic, linux-arm-kernel, linux-mediatek,
	linux-mips, linux-stm32, Matthias Brugger, Maxime Coquelin,
	Minda Chen, Neil Armstrong, netdev, Nobuhiro Iwamatsu,
	Paolo Abeni

On Fri, Nov 7, 2025 at 3:28 PM Russell King (Oracle)
<rmk+kernel@armlinux.org.uk> wrote:
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH net-next 08/16] net: stmmac: meson8b: use phy_intf_sel directly
  2025-11-07 14:28 ` [PATCH net-next 08/16] net: stmmac: meson8b: use phy_intf_sel directly Russell King (Oracle)
@ 2025-11-08 12:30   ` Martin Blumenstingl
  0 siblings, 0 replies; 25+ messages in thread
From: Martin Blumenstingl @ 2025-11-08 12:30 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
	AngeloGioacchino Del Regno, David S. Miller, Emil Renner Berthing,
	Eric Dumazet, Jakub Kicinski, Jerome Brunet, Keguang Zhang,
	Kevin Hilman, linux-amlogic, linux-arm-kernel, linux-mediatek,
	linux-mips, linux-stm32, Matthias Brugger, Maxime Coquelin,
	Minda Chen, Neil Armstrong, netdev, Nobuhiro Iwamatsu,
	Paolo Abeni

On Fri, Nov 7, 2025 at 3:29 PM Russell King (Oracle)
<rmk+kernel@armlinux.org.uk> wrote:
>
> Rearrange meson_axg_set_phy_mode() to use phy_intf_sel directly,
> converting it to the register field for meson8b_dwmac_mask_bits().
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH net-next 09/16] net: stmmac: meson8b: use stmmac_get_phy_intf_sel()
  2025-11-07 14:28 ` [PATCH net-next 09/16] net: stmmac: meson8b: use stmmac_get_phy_intf_sel() Russell King (Oracle)
@ 2025-11-08 12:31   ` Martin Blumenstingl
  0 siblings, 0 replies; 25+ messages in thread
From: Martin Blumenstingl @ 2025-11-08 12:31 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
	AngeloGioacchino Del Regno, David S. Miller, Emil Renner Berthing,
	Eric Dumazet, Jakub Kicinski, Jerome Brunet, Keguang Zhang,
	Kevin Hilman, linux-amlogic, linux-arm-kernel, linux-mediatek,
	linux-mips, linux-stm32, Matthias Brugger, Maxime Coquelin,
	Minda Chen, Neil Armstrong, netdev, Nobuhiro Iwamatsu,
	Paolo Abeni

On Fri, Nov 7, 2025 at 3:29 PM Russell King (Oracle)
<rmk+kernel@armlinux.org.uk> wrote:
>
> 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.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH net-next 16/16] net: stmmac: visconti: use stmmac_get_phy_intf_sel()
  2025-11-08  7:58     ` Russell King (Oracle)
@ 2025-11-09 16:38       ` Maxime Chevallier
  0 siblings, 0 replies; 25+ messages in thread
From: Maxime Chevallier @ 2025-11-09 16:38 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
	AngeloGioacchino Del Regno, David S. Miller, Emil Renner Berthing,
	Eric Dumazet, Jakub Kicinski, Jerome Brunet, Keguang Zhang,
	Kevin Hilman, linux-amlogic, linux-arm-kernel, linux-mediatek,
	linux-mips, linux-stm32, Martin Blumenstingl, Matthias Brugger,
	Maxime Coquelin, Minda Chen, Neil Armstrong, netdev,
	Nobuhiro Iwamatsu, Paolo Abeni



On 08/11/2025 08:58, Russell King (Oracle) wrote:
> On Fri, Nov 07, 2025 at 07:23:26PM +0100, Maxime Chevallier wrote:
>> Hi Russell,
>>
>> On 07/11/2025 15:29, Russell King (Oracle) wrote:
>>> -	switch (plat_dat->phy_interface) {
>>> -	case PHY_INTERFACE_MODE_RGMII:
>>> -	case PHY_INTERFACE_MODE_RGMII_ID:
>>> -	case PHY_INTERFACE_MODE_RGMII_RXID:
>>> -	case PHY_INTERFACE_MODE_RGMII_TXID:
>>> -		phy_intf_sel = ETHER_CONFIG_INTF_RGMII;
>>> -		break;
>>> -	case PHY_INTERFACE_MODE_MII:
>>> -		phy_intf_sel = ETHER_CONFIG_INTF_MII;
>>> -		break;
>>> -	case PHY_INTERFACE_MODE_RMII:
>>> -		phy_intf_sel = ETHER_CONFIG_INTF_RMII;
>>> -		break;
>>> -	default:
>>> +	int phy_intf_sel;
>>> +
>>> +	phy_intf_sel = stmmac_get_phy_intf_sel(plat_dat->phy_interface);
>>> +	if (phy_intf_sel != PHY_INTF_SEL_GMII_MII &&
>>> +	    phy_intf_sel != PHY_INTF_SEL_RGMII &&
>>> +	    phy_intf_sel != PHY_INTF_SEL_RMII) {
>>>  		dev_err(&pdev->dev, "Unsupported phy-mode (%d)\n", plat_dat->phy_interface);
>>>  		return -EOPNOTSUPP;
>>>  	}
>>
>> Probably not too big of a deal, but don't we now incorrectly accept the
>> "gmii" mode ?
> 
> We will accept GMII mode, but (a) does that matter, and (b) shouldn't
> the DT binding be checking the phy-mode (we have some bindings that do.)

Thanks for the clarification, that's fine by me then :)

Maxime


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2025-11-09 16:39 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-07 14:27 [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel() Russell King (Oracle)
2025-11-07 14:28 ` [PATCH net-next 01/16] net: stmmac: loongson1: use PHY_INTF_SEL_x Russell King (Oracle)
2025-11-07 14:28 ` [PATCH net-next 02/16] net: stmmac: loongson1: use PHY_INTF_SEL_x directly Russell King (Oracle)
2025-11-07 14:28 ` [PATCH net-next 03/16] net: stmmac: loongson1: use stmmac_get_phy_intf_sel() Russell King (Oracle)
2025-11-07 14:28 ` [PATCH net-next 04/16] net: stmmac: mediatek: use PHY_INTF_SEL_xxx Russell King (Oracle)
2025-11-07 14:28 ` [PATCH net-next 05/16] net: stmmac: mediatek: use stmmac_get_phy_intf_sel() Russell King (Oracle)
2025-11-07 14:28 ` [PATCH net-next 06/16] net: stmmac: mediatek: simplify set_interface() methods Russell King (Oracle)
2025-11-07 14:28 ` [PATCH net-next 07/16] net: stmmac: meson8b: use PHY_INTF_SEL_xxx Russell King (Oracle)
2025-11-08 12:30   ` Martin Blumenstingl
2025-11-07 14:28 ` [PATCH net-next 08/16] net: stmmac: meson8b: use phy_intf_sel directly Russell King (Oracle)
2025-11-08 12:30   ` Martin Blumenstingl
2025-11-07 14:28 ` [PATCH net-next 09/16] net: stmmac: meson8b: use stmmac_get_phy_intf_sel() Russell King (Oracle)
2025-11-08 12:31   ` Martin Blumenstingl
2025-11-07 14:28 ` [PATCH net-next 10/16] net: stmmac: starfive: use PHY_INTF_SEL_xxx to select PHY interface Russell King (Oracle)
2025-11-07 14:28 ` [PATCH net-next 11/16] net: stmmac: starfive: use stmmac_get_phy_intf_sel() Russell King (Oracle)
2025-11-07 16:00   ` Emil Renner Berthing
2025-11-07 16:08     ` Russell King (Oracle)
2025-11-07 14:29 ` [PATCH net-next 12/16] net: stmmac: stm32: use PHY_INTF_SEL_x to select PHY interface Russell King (Oracle)
2025-11-07 14:29 ` [PATCH net-next 13/16] net: stmmac: stm32: use PHY_INTF_SEL_x directly Russell King (Oracle)
2025-11-07 14:29 ` [PATCH net-next 14/16] net: stmmac: stm32: use stmmac_get_phy_intf_sel() Russell King (Oracle)
2025-11-07 14:29 ` [PATCH net-next 15/16] net: stmmac: visconti: use PHY_INTF_SEL_x to select PHY interface Russell King (Oracle)
2025-11-07 14:29 ` [PATCH net-next 16/16] net: stmmac: visconti: use stmmac_get_phy_intf_sel() Russell King (Oracle)
2025-11-07 18:23   ` Maxime Chevallier
2025-11-08  7:58     ` Russell King (Oracle)
2025-11-09 16:38       ` Maxime Chevallier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).