diff mbox series

[U-Boot] net: phy: micrel: make sure the factory test bit is cleared

Message ID 1571827241-20555-1-git-send-email-eugen.hristev@microchip.com
State Accepted
Commit b2f2643b39
Delegated to: Joe Hershberger
Headers show
Series [U-Boot] net: phy: micrel: make sure the factory test bit is cleared | expand

Commit Message

Eugen Hristev Oct. 23, 2019, 10:46 a.m. UTC
From: Nicolas Ferre <nicolas.ferre@microchip.com>

The KSZ8081 PHY has a factory test mode which is set at the de-assertion
of the reset line based on the RXER (KSZ8081RNA/RND) or TXC
(KSZ8081MNX/RNB) pin. If a pull-down is missing, or if the pin has a
pull-up, the factory test mode should be cleared by manually writing a 0
(according to the datasheet).
Create another ksz8081_config function to handle this case.

Suggested-by: Antoine Tenart <antoine.tenart@bootlin.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
---
 drivers/net/phy/micrel_ksz8xxx.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

Comments

Joe Hershberger Nov. 30, 2019, 1:22 a.m. UTC | #1
On Wed, Oct 23, 2019 at 5:47 AM <Eugen.Hristev@microchip.com> wrote:
>
> From: Nicolas Ferre <nicolas.ferre@microchip.com>
>
> The KSZ8081 PHY has a factory test mode which is set at the de-assertion
> of the reset line based on the RXER (KSZ8081RNA/RND) or TXC
> (KSZ8081MNX/RNB) pin. If a pull-down is missing, or if the pin has a
> pull-up, the factory test mode should be cleared by manually writing a 0
> (according to the datasheet).
> Create another ksz8081_config function to handle this case.
>
> Suggested-by: Antoine Tenart <antoine.tenart@bootlin.com>
> Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
diff mbox series

Patch

diff --git a/drivers/net/phy/micrel_ksz8xxx.c b/drivers/net/phy/micrel_ksz8xxx.c
index daa57ce..5340ea0 100644
--- a/drivers/net/phy/micrel_ksz8xxx.c
+++ b/drivers/net/phy/micrel_ksz8xxx.c
@@ -24,6 +24,7 @@  static struct phy_driver KSZ804_driver = {
 };
 
 #define MII_KSZPHY_OMSO		0x16
+#define KSZPHY_OMSO_FACTORY_TEST	(1 << 15)
 #define KSZPHY_OMSO_B_CAST_OFF	(1 << 9)
 
 static int ksz_genconfig_bcastoff(struct phy_device *phydev)
@@ -80,12 +81,30 @@  static struct phy_driver KSZ8051_driver = {
 	.shutdown = &genphy_shutdown,
 };
 
+static int ksz8081_config(struct phy_device *phydev)
+{
+	int ret;
+
+	ret = phy_read(phydev, MDIO_DEVAD_NONE, MII_KSZPHY_OMSO);
+	if (ret < 0)
+		return ret;
+
+	ret &= ~KSZPHY_OMSO_FACTORY_TEST;
+
+	ret = phy_write(phydev, MDIO_DEVAD_NONE, MII_KSZPHY_OMSO,
+			ret | KSZPHY_OMSO_B_CAST_OFF);
+	if (ret < 0)
+		return ret;
+
+	return genphy_config(phydev);
+}
+
 static struct phy_driver KSZ8081_driver = {
 	.name = "Micrel KSZ8081",
 	.uid = 0x221560,
 	.mask = 0xfffff0,
 	.features = PHY_BASIC_FEATURES,
-	.config = &ksz_genconfig_bcastoff,
+	.config = &ksz8081_config,
 	.startup = &genphy_startup,
 	.shutdown = &genphy_shutdown,
 };