mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/4] net: phy: marvell: add RGMII-to-Copper mode configuration
@ 2026-11-16 15:27 Paul Louvel
  2026-11-16 15:27 ` [PATCH net-next v2 1/4] net: phy: marvell: move mode configuration into standalone function Paul Louvel
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Paul Louvel @ 2026-11-16 15:27 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Chevallier
  Cc: netdev, linux-kernel, Thomas Petazzoni, Miquel Raynal,
	Herve Codina, Paul Louvel (Schneider Electric)

Hi,

This series add the configuration of the RGMII-to-Copper MAC interface
for Marvell 88E1510/88E1518/88E1512/88E1514 PHYs.

Patch #1, #2, #3 are cleanup commits.

Signed-off-by: Paul Louvel (Schneider Electric) <paul.louvel@bootlin.com>
---
Changes in v2:
- Reword patches to be more accurate.
- Added a patch to deduplicate the mode setting code in
  m88e1510_config_init(), as suggested by Marek.
- When setting RGMII system interface, avoid erasing existing mode that
  uses RGMII but a different media interface. This issue was raised by
  Sashiko.
- Added a patch to rework the EEE errata code by using
  phy_select_page() and phy_restore_page(), avoiding useless bus lock.
- Link to v1: https://patch.msgid.link/20261109-marvell-phy-rgmii-v1-0-026979ef4f13@bootlin.com

---
Paul Louvel (4):
      net: phy: marvell: move mode configuration into standalone function
      net: phy: marvell: de-duplicate mode initialization code
      net: phy: marvell: factor out EEE errata initialization
      net: phy: marvell: add RGMII-to-Copper mode configuration

 drivers/net/phy/marvell.c | 127 ++++++++++++++++++++++++++--------------------
 1 file changed, 71 insertions(+), 56 deletions(-)
---
base-commit: 7b6ab4dbc156e2f96419715130b3d5738a306c93
change-id: 20261109-marvell-phy-rgmii-60a8bf619582

Best regards,
--  
Paul Louvel, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


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

* [PATCH net-next v2 1/4] net: phy: marvell: move mode configuration into standalone function
  2026-11-16 15:27 [PATCH net-next v2 0/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
@ 2026-11-16 15:27 ` Paul Louvel
  2026-11-16 15:27 ` [PATCH net-next v2 2/4] net: phy: marvell: de-duplicate mode initialization code Paul Louvel
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Louvel @ 2026-11-16 15:27 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Chevallier
  Cc: netdev, linux-kernel, Thomas Petazzoni, Miquel Raynal,
	Herve Codina, Paul Louvel (Schneider Electric)

Move the configuration of the m88e151x out of the
m88e1510_port_configure_serdes() function, so that other parts of the
driver can use it.

Signed-off-by: Paul Louvel (Schneider Electric) <paul.louvel@bootlin.com>
---
 drivers/net/phy/marvell.c | 38 ++++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 2c688d661297..aef5f8279133 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -1332,6 +1332,27 @@ static int m88e1318_config_init(struct phy_device *phydev)
 	return marvell_config_init(phydev);
 }
 
+static int m88e1510_config_mode(struct phy_device *phydev, u16 mode)
+{
+	int oldpage;
+	int ret = 0;
+
+	oldpage = phy_select_page(phydev, MII_MARVELL_MODE_PAGE);
+	if (oldpage < 0)
+		goto error;
+
+	ret = __phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1,
+			   MII_88E1510_GEN_CTRL_REG_1_MODE_MASK, mode);
+	if (ret < 0)
+		goto error;
+
+	ret = __phy_set_bits(phydev, MII_88E1510_GEN_CTRL_REG_1,
+			     MII_88E1510_GEN_CTRL_REG_1_RESET);
+
+error:
+	return phy_restore_page(phydev, oldpage, ret);
+}
+
 static int m88e1510_config_init(struct phy_device *phydev)
 {
 	static const struct {
@@ -3656,8 +3677,6 @@ static int m88e1510_port_configure_serdes(struct phy_port *port, bool enable,
 {
 	struct phy_device *phydev = port_phydev(port);
 	struct device *dev;
-	int oldpage;
-	int ret = 0;
 	u16 mode;
 
 	dev = &phydev->mdio.dev;
@@ -3685,20 +3704,7 @@ static int m88e1510_port_configure_serdes(struct phy_port *port, bool enable,
 		mode = MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII;
 	}
 
-	oldpage = phy_select_page(phydev, MII_MARVELL_MODE_PAGE);
-	if (oldpage < 0)
-		goto error;
-
-	ret = __phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1,
-			   MII_88E1510_GEN_CTRL_REG_1_MODE_MASK, mode);
-	if (ret < 0)
-		goto error;
-
-	ret = __phy_set_bits(phydev, MII_88E1510_GEN_CTRL_REG_1,
-			     MII_88E1510_GEN_CTRL_REG_1_RESET);
-
-error:
-	return phy_restore_page(phydev, oldpage, ret);
+	return m88e1510_config_mode(phydev, mode);
 }
 
 static const struct phy_port_ops m88e1510_serdes_port_ops = {

-- 
2.56.1


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

* [PATCH net-next v2 2/4] net: phy: marvell: de-duplicate mode initialization code
  2026-11-16 15:27 [PATCH net-next v2 0/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
  2026-11-16 15:27 ` [PATCH net-next v2 1/4] net: phy: marvell: move mode configuration into standalone function Paul Louvel
@ 2026-11-16 15:27 ` Paul Louvel
  2026-11-16 15:27 ` [PATCH net-next v2 3/4] net: phy: marvell: factor out EEE errata initialization Paul Louvel
  2026-11-16 15:27 ` [PATCH net-next v2 4/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Louvel @ 2026-11-16 15:27 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Chevallier
  Cc: netdev, linux-kernel, Thomas Petazzoni, Miquel Raynal,
	Herve Codina, Paul Louvel (Schneider Electric)

The code that initializes the m88e151x PHYs to use the SGMII-to-Copper
interface is duplicated, and does not restore the old page in case of an
error.

Instead, use m88e1510_config_mode().

Signed-off-by: Paul Louvel (Schneider Electric) <paul.louvel@bootlin.com>
---
 drivers/net/phy/marvell.c | 27 ++++-----------------------
 1 file changed, 4 insertions(+), 23 deletions(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index aef5f8279133..d2c5d3c5ce7d 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -1395,30 +1395,11 @@ static int m88e1510_config_init(struct phy_device *phydev)
 		return err;
 
 	/* SGMII-to-Copper mode initialization */
-	if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
-		/* Select page 18 */
-		err = marvell_set_page(phydev, 18);
-		if (err < 0)
-			return err;
-
-		/* In reg 20, write MODE[2:0] = 0x1 (SGMII to Copper) */
-		err = phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1,
-				 MII_88E1510_GEN_CTRL_REG_1_MODE_MASK,
-				 MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII);
-		if (err < 0)
-			return err;
-
-		/* PHY reset is necessary after changing MODE[2:0] */
-		err = phy_set_bits(phydev, MII_88E1510_GEN_CTRL_REG_1,
-				   MII_88E1510_GEN_CTRL_REG_1_RESET);
-		if (err < 0)
-			return err;
+	if (phydev->interface == PHY_INTERFACE_MODE_SGMII)
+		err = m88e1510_config_mode(phydev, MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII);
+	if (err < 0)
+		return err;
 
-		/* Reset page selection */
-		err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE);
-		if (err < 0)
-			return err;
-	}
 	err = m88e1011_set_downshift(phydev, 3);
 	if (err < 0)
 		return err;

-- 
2.56.1


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

* [PATCH net-next v2 3/4] net: phy: marvell: factor out EEE errata initialization
  2026-11-16 15:27 [PATCH net-next v2 0/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
  2026-11-16 15:27 ` [PATCH net-next v2 1/4] net: phy: marvell: move mode configuration into standalone function Paul Louvel
  2026-11-16 15:27 ` [PATCH net-next v2 2/4] net: phy: marvell: de-duplicate mode initialization code Paul Louvel
@ 2026-11-16 15:27 ` Paul Louvel
  2026-11-16 15:27 ` [PATCH net-next v2 4/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Louvel @ 2026-11-16 15:27 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Chevallier
  Cc: netdev, linux-kernel, Thomas Petazzoni, Miquel Raynal,
	Herve Codina, Paul Louvel (Schneider Electric)

The 88E151x EEE errata sequence writes four register pairs on page 0xFF.
Using phy_write() for each access takes and releases the MDIO bus lock
every time, and returning early on error leaves the PHY on the errata
page.

Move the sequence into m88e1510_eee_errata() and use phy_select_page()
and phy_restore_page().
This reduces the number of bus lock/unlock cycles and restores the
previous page if one of the errata writes fails.

Signed-off-by: Paul Louvel (Schneider Electric) <paul.louvel@bootlin.com>
---
 drivers/net/phy/marvell.c | 41 +++++++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 16 deletions(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index d2c5d3c5ce7d..a72d307eaf12 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -1353,7 +1353,7 @@ static int m88e1510_config_mode(struct phy_device *phydev, u16 mode)
 	return phy_restore_page(phydev, oldpage, ret);
 }
 
-static int m88e1510_config_init(struct phy_device *phydev)
+static int m88e1510_eee_errata(struct phy_device *phydev)
 {
 	static const struct {
 		u16 reg17, reg16;
@@ -1363,31 +1363,40 @@ static int m88e1510_config_init(struct phy_device *phydev)
 		{ 0xb233, 0x214d },
 		{ 0xcc0c, 0x2159 },
 	};
-	int err;
-	int i;
+	int i, oldpage, ret = 0;
 
 	/* As per Marvell Release Notes - Alaska 88E1510/88E1518/88E1512/
 	 * 88E1514 Rev A0, Errata Section 5.1:
 	 * If EEE is intended to be used, the following register writes
 	 * must be done once after every hardware reset.
 	 */
-	err = marvell_set_page(phydev, 0x00FF);
-	if (err < 0)
-		return err;
+	oldpage = phy_select_page(phydev, 0x00FF);
+	if (oldpage < 0)
+		goto restore;
 
 	for (i = 0; i < ARRAY_SIZE(errata_vals); ++i) {
-		err = phy_write(phydev, 17, errata_vals[i].reg17);
-		if (err)
-			return err;
-		err = phy_write(phydev, 16, errata_vals[i].reg16);
-		if (err)
-			return err;
+		ret = __phy_write(phydev, 17, errata_vals[i].reg17);
+		if (ret)
+			goto restore;
+
+		ret = __phy_write(phydev, 16, errata_vals[i].reg16);
+		if (ret)
+			goto restore;
 	}
 
-	err = marvell_set_page(phydev, 0x00FB);
-	if (err < 0)
-		return err;
-	err = phy_write(phydev, 07, 0xC00D);
+restore:
+	ret = phy_restore_page(phydev, oldpage, ret);
+	if (ret < 0)
+		return ret;
+
+	return phy_write_paged(phydev, 0x00FB, 07, 0xC00D);
+}
+
+static int m88e1510_config_init(struct phy_device *phydev)
+{
+	int err;
+
+	err = m88e1510_eee_errata(phydev);
 	if (err < 0)
 		return err;
 	err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE);

-- 
2.56.1


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

* [PATCH net-next v2 4/4] net: phy: marvell: add RGMII-to-Copper mode configuration
  2026-11-16 15:27 [PATCH net-next v2 0/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
                   ` (2 preceding siblings ...)
  2026-11-16 15:27 ` [PATCH net-next v2 3/4] net: phy: marvell: factor out EEE errata initialization Paul Louvel
@ 2026-11-16 15:27 ` Paul Louvel
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Louvel @ 2026-11-16 15:27 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Chevallier
  Cc: netdev, linux-kernel, Thomas Petazzoni, Miquel Raynal,
	Herve Codina, Paul Louvel (Schneider Electric)

The driver currently programs the mode only for SGMII-to-Copper, based
on the PHY interface mode.

Some MACs connect to the PHY via RGMII. Add code in
m88e1510_config_init() to configure the device.

Do not overwrite the media interface mode configured via
m88e1510_port_configure_serdes().

Signed-off-by: Paul Louvel (Schneider Electric) <paul.louvel@bootlin.com>
---
 drivers/net/phy/marvell.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index a72d307eaf12..9748fdd843ff 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -1341,6 +1341,23 @@ static int m88e1510_config_mode(struct phy_device *phydev, u16 mode)
 	if (oldpage < 0)
 		goto error;
 
+	ret = __phy_read(phydev, MII_88E1510_GEN_CTRL_REG_1);
+	if (ret < 0)
+		goto error;
+
+	if (mode == MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII) {
+		switch (FIELD_GET(MII_88E1510_GEN_CTRL_REG_1_MODE_MASK, ret)) {
+		case MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII:
+		case MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII_1000X:
+		case MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII_100FX:
+		case MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII_SGMII:
+			ret = 0;
+			goto error;
+		default:
+			break;
+		}
+	}
+
 	ret = __phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1,
 			   MII_88E1510_GEN_CTRL_REG_1_MODE_MASK, mode);
 	if (ret < 0)
@@ -1403,9 +1420,11 @@ static int m88e1510_config_init(struct phy_device *phydev)
 	if (err < 0)
 		return err;
 
-	/* SGMII-to-Copper mode initialization */
+	/* RGMII/SGMII-to-Copper mode initialization */
 	if (phydev->interface == PHY_INTERFACE_MODE_SGMII)
 		err = m88e1510_config_mode(phydev, MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII);
+	else if (phy_interface_is_rgmii(phydev))
+		err = m88e1510_config_mode(phydev, MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII);
 	if (err < 0)
 		return err;
 

-- 
2.56.1


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

end of thread, other threads:[~2026-11-16 15:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 15:27 [PATCH net-next v2 0/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
2026-11-16 15:27 ` [PATCH net-next v2 1/4] net: phy: marvell: move mode configuration into standalone function Paul Louvel
2026-11-16 15:27 ` [PATCH net-next v2 2/4] net: phy: marvell: de-duplicate mode initialization code Paul Louvel
2026-11-16 15:27 ` [PATCH net-next v2 3/4] net: phy: marvell: factor out EEE errata initialization Paul Louvel
2026-11-16 15:27 ` [PATCH net-next v2 4/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®