diff mbox

[U-Boot,v2] net: phy: micrel: add an option to disable gigabit for the KSZ9031

Message ID 20170801191725.21471-1-sebastien.bourdelin@savoirfairelinux.com
State Accepted
Commit ef1f61a
Delegated to: Joe Hershberger
Headers show

Commit Message

Sebastien Bourdelin Aug. 1, 2017, 7:17 p.m. UTC
The environment variable "disable_giga" can now be used to disable
1000baseTx on the Micrel's KSZ9031.

Signed-off-by: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>

---
Changes v1 -> v2:
  - move variables declaration in concern block and remove useless
  initialisation (suggested by Joe Hershberger <joe.hershberger@ni.com>
  - v1 acked by Joe Hershberger <joe.hershberger@ni.com>
---
 drivers/net/phy/micrel.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

Joe Hershberger Aug. 7, 2017, 9:08 p.m. UTC | #1
Hi Sebastien,

https://patchwork.ozlabs.org/patch/796357/ was applied to u-boot-net.git.

Thanks!
-Joe
diff mbox

Patch

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 0e4a4ebcc6..ed26294846 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -497,6 +497,33 @@  static int ksz9031_config(struct phy_device *phydev)
 	ret = ksz9031_center_flp_timing(phydev);
 	if (ret)
 		return ret;
+
+	/* add an option to disable the gigabit feature of this PHY */
+	if (getenv("disable_giga")) {
+		unsigned features;
+		unsigned bmcr;
+
+		/* disable speed 1000 in features supported by the PHY */
+		features = phydev->drv->features;
+		features &= ~(SUPPORTED_1000baseT_Half |
+				SUPPORTED_1000baseT_Full);
+		phydev->advertising = phydev->supported = features;
+
+		/* disable speed 1000 in Basic Control Register */
+		bmcr = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMCR);
+		bmcr &= ~(1 << 6);
+		phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, bmcr);
+
+		/* disable speed 1000 in 1000Base-T Control Register */
+		phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, 0);
+
+		/* start autoneg */
+		genphy_config_aneg(phydev);
+		genphy_restart_aneg(phydev);
+
+		return 0;
+	}
+
 	return genphy_config(phydev);
 }