[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20210414222841.82548-2-mail@david-bauer.net>
Date: Thu, 15 Apr 2021 00:28:41 +0200
From: David Bauer <mail@...id-bauer.net>
To: netdev@...r.kernel.org
Cc: andrew@...n.ch
Subject: [PATCH net-next 2/2] net: phy: at803x: select correct page on config init
The Atheros AR8031 and AR8033 expose different registers for SGMII/Fiber
as well as the copper side of the PHY depending on the BT_BX_REG_SEL bit
in the chip configure register.
The driver assumes the copper side is selected on probe, but this might
not be the case depending which page was last selected by the
bootloader. Notably, Ubiquiti UniFi bootloaders show this behavior.
Select the copper page when probing to circumvent this.
Signed-off-by: David Bauer <mail@...id-bauer.net>
---
drivers/net/phy/at803x.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index b3243ad570c7..b63d2c1575bb 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -567,6 +567,7 @@ static int at803x_probe(struct phy_device *phydev)
{
struct device *dev = &phydev->mdio.dev;
struct at803x_priv *priv;
+ int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -574,7 +575,20 @@ static int at803x_probe(struct phy_device *phydev)
phydev->priv = priv;
- return at803x_parse_dt(phydev);
+ ret = at803x_parse_dt(phydev);
+ if (ret)
+ return ret;
+
+ /* Some bootloaders leave the fiber page selected.
+ * Switch to the copper page, as otherwise we read
+ * the PHY capabilities from the fiber side.
+ */
+ if (at803x_match_phy_id(phydev, ATH8031_PHY_ID)) {
+ ret = phy_select_page(phydev, AT803X_PAGE_COPPER);
+ ret = phy_restore_page(phydev, AT803X_PAGE_COPPER, ret);
+ }
+
+ return ret;
}
static void at803x_remove(struct phy_device *phydev)
--
2.31.1
Powered by blists - more mailing lists