diff mbox series

[net,6/6] net: phy: vitesse: repair vsc73xx autonegotiation

Message ID 20240802080403.739509-7-paweldembicki@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: vsc73xx: fix MDIO bus access and PHY operations | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 29 this patch: 29
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 29 this patch: 29
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 29 this patch: 29
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 37 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Pawel Dembicki Aug. 2, 2024, 8:04 a.m. UTC
When the vsc73xx mdio bus work properly, the generic autonegotiation
configuration works well.

Vsc73xx have auto MDI-X disabled by default in forced mode. This commit
enables it.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
---
This patch came from net-next series[0].
Changes since net-next:
  - rebased to netdev/main only

[0] https://patchwork.kernel.org/project/netdevbpf/patch/20240729210615.279952-6-paweldembicki@gmail.com/
---
 drivers/net/phy/vitesse.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

Comments

Russell King (Oracle) Aug. 2, 2024, 1:03 p.m. UTC | #1
On Fri, Aug 02, 2024 at 10:04:03AM +0200, Pawel Dembicki wrote:
> When the vsc73xx mdio bus work properly, the generic autonegotiation
> configuration works well.
> 
> Vsc73xx have auto MDI-X disabled by default in forced mode. This commit
> enables it.

Why not implement proper MDI(-X) configuration support so that the user
can configure it as desired?
Pawel Dembicki Aug. 2, 2024, 8:40 p.m. UTC | #2
pt., 2 sie 2024 o 15:03 Russell King (Oracle) <linux@armlinux.org.uk>
napisał(a):
>
> On Fri, Aug 02, 2024 at 10:04:03AM +0200, Pawel Dembicki wrote:
> > When the vsc73xx mdio bus work properly, the generic autonegotiation
> > configuration works well.
> >
> > Vsc73xx have auto MDI-X disabled by default in forced mode. This commit
> > enables it.
>
> Why not implement proper MDI(-X) configuration support so that the user
> can configure it as desired?
>

This approach is a copy of an idea from other PHYs in the 'vitesse' driver.
I can implement MDI(-X) configuration and status.
But the question is: Should I do it in this patch series or send a
separate patch to net-next after this series gets merged?
Linus Walleij Aug. 2, 2024, 9:08 p.m. UTC | #3
On Fri, Aug 2, 2024 at 10:04 AM Pawel Dembicki <paweldembicki@gmail.com> wrote:

> When the vsc73xx mdio bus work properly, the generic autonegotiation
> configuration works well.
>
> Vsc73xx have auto MDI-X disabled by default in forced mode. This commit
> enables it.
>
> Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>

Looks good to me, as Russell points out there are further improvements
we can make but this patch stands on its own as well.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c
index 897b979ec03c..19b7bf189be5 100644
--- a/drivers/net/phy/vitesse.c
+++ b/drivers/net/phy/vitesse.c
@@ -60,6 +60,11 @@ 
 /* Vitesse Extended Page Access Register */
 #define MII_VSC82X4_EXT_PAGE_ACCESS	0x1f
 
+/* VSC73XX PHY_BYPASS_CTRL register*/
+#define MII_VSC73XX_PHY_BYPASS_CTRL		MII_DCOUNTER
+#define MII_PBC_FORCED_SPEED_AUTO_MDIX_DIS	BIT(7)
+#define MII_VSC73XX_PBC_AUTO_NP_EXCHANGE_DIS	BIT(1)
+
 /* Vitesse VSC8601 Extended PHY Control Register 1 */
 #define MII_VSC8601_EPHY_CTL		0x17
 #define MII_VSC8601_EPHY_CTL_RGMII_SKEW	(1 << 8)
@@ -239,12 +244,20 @@  static int vsc739x_config_init(struct phy_device *phydev)
 
 static int vsc73xx_config_aneg(struct phy_device *phydev)
 {
-	/* The VSC73xx switches does not like to be instructed to
-	 * do autonegotiation in any way, it prefers that you just go
-	 * with the power-on/reset defaults. Writing some registers will
-	 * just make autonegotiation permanently fail.
-	 */
-	return 0;
+	int ret;
+
+	/* Enable Auto MDI-X in forced 10/100 mode */
+	if (phydev->autoneg != AUTONEG_ENABLE && phydev->speed <= SPEED_100) {
+		ret = genphy_setup_forced(phydev);
+
+		if (ret < 0) /* error */
+			return ret;
+
+		return phy_clear_bits(phydev, MII_VSC73XX_PHY_BYPASS_CTRL,
+				      MII_PBC_FORCED_SPEED_AUTO_MDIX_DIS);
+	}
+
+	return genphy_config_aneg(phydev);
 }
 
 /* This adds a skew for both TX and RX clocks, so the skew should only be