mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-22 15:02:32 +00:00
156 lines
4.8 KiB
Diff
156 lines
4.8 KiB
Diff
|
From d43cff3f82336c0bd965ea552232d9f4ddac71a6 Mon Sep 17 00:00:00 2001
|
||
|
From: Christian Marangi <ansuelsmth@gmail.com>
|
||
|
Date: Fri, 8 Dec 2023 15:51:51 +0100
|
||
|
Subject: [PATCH 04/13] net: phy: at803x: move qca83xx specific check in
|
||
|
dedicated functions
|
||
|
|
||
|
Rework qca83xx specific check to dedicated function to tidy things up
|
||
|
and drop useless phy_id check.
|
||
|
|
||
|
Also drop an useless link_change_notify for QCA8337 as it did nothing an
|
||
|
returned early.
|
||
|
|
||
|
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||
|
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||
|
---
|
||
|
drivers/net/phy/at803x.c | 68 ++++++++++++++++++++++------------------
|
||
|
1 file changed, 37 insertions(+), 31 deletions(-)
|
||
|
|
||
|
--- a/drivers/net/phy/at803x.c
|
||
|
+++ b/drivers/net/phy/at803x.c
|
||
|
@@ -1623,27 +1623,26 @@ static int qca83xx_config_init(struct ph
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
+ /* Following original QCA sourcecode set port to prefer master */
|
||
|
+ phy_set_bits(phydev, MII_CTRL1000, CTL1000_PREFER_MASTER);
|
||
|
+
|
||
|
+ return 0;
|
||
|
+}
|
||
|
+
|
||
|
+static int qca8327_config_init(struct phy_device *phydev)
|
||
|
+{
|
||
|
/* QCA8327 require DAC amplitude adjustment for 100m set to +6%.
|
||
|
* Disable on init and enable only with 100m speed following
|
||
|
* qca original source code.
|
||
|
*/
|
||
|
- if (phydev->drv->phy_id == QCA8327_A_PHY_ID ||
|
||
|
- phydev->drv->phy_id == QCA8327_B_PHY_ID)
|
||
|
- at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL,
|
||
|
- QCA8327_DEBUG_MANU_CTRL_EN, 0);
|
||
|
+ at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL,
|
||
|
+ QCA8327_DEBUG_MANU_CTRL_EN, 0);
|
||
|
|
||
|
- /* Following original QCA sourcecode set port to prefer master */
|
||
|
- phy_set_bits(phydev, MII_CTRL1000, CTL1000_PREFER_MASTER);
|
||
|
-
|
||
|
- return 0;
|
||
|
+ return qca83xx_config_init(phydev);
|
||
|
}
|
||
|
|
||
|
static void qca83xx_link_change_notify(struct phy_device *phydev)
|
||
|
{
|
||
|
- /* QCA8337 doesn't require DAC Amplitude adjustement */
|
||
|
- if (phydev->drv->phy_id == QCA8337_PHY_ID)
|
||
|
- return;
|
||
|
-
|
||
|
/* Set DAC Amplitude adjustment to +6% for 100m on link running */
|
||
|
if (phydev->state == PHY_RUNNING) {
|
||
|
if (phydev->speed == SPEED_100)
|
||
|
@@ -1686,19 +1685,6 @@ static int qca83xx_resume(struct phy_dev
|
||
|
|
||
|
static int qca83xx_suspend(struct phy_device *phydev)
|
||
|
{
|
||
|
- u16 mask = 0;
|
||
|
-
|
||
|
- /* Only QCA8337 support actual suspend.
|
||
|
- * QCA8327 cause port unreliability when phy suspend
|
||
|
- * is set.
|
||
|
- */
|
||
|
- if (phydev->drv->phy_id == QCA8337_PHY_ID) {
|
||
|
- genphy_suspend(phydev);
|
||
|
- } else {
|
||
|
- mask |= ~(BMCR_SPEED1000 | BMCR_FULLDPLX);
|
||
|
- phy_modify(phydev, MII_BMCR, mask, 0);
|
||
|
- }
|
||
|
-
|
||
|
at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_GREEN,
|
||
|
AT803X_DEBUG_GATE_CLK_IN1000, 0);
|
||
|
|
||
|
@@ -1709,6 +1695,27 @@ static int qca83xx_suspend(struct phy_de
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
+static int qca8337_suspend(struct phy_device *phydev)
|
||
|
+{
|
||
|
+ /* Only QCA8337 support actual suspend. */
|
||
|
+ genphy_suspend(phydev);
|
||
|
+
|
||
|
+ return qca83xx_suspend(phydev);
|
||
|
+}
|
||
|
+
|
||
|
+static int qca8327_suspend(struct phy_device *phydev)
|
||
|
+{
|
||
|
+ u16 mask = 0;
|
||
|
+
|
||
|
+ /* QCA8327 cause port unreliability when phy suspend
|
||
|
+ * is set.
|
||
|
+ */
|
||
|
+ mask |= ~(BMCR_SPEED1000 | BMCR_FULLDPLX);
|
||
|
+ phy_modify(phydev, MII_BMCR, mask, 0);
|
||
|
+
|
||
|
+ return qca83xx_suspend(phydev);
|
||
|
+}
|
||
|
+
|
||
|
static int qca808x_phy_fast_retrain_config(struct phy_device *phydev)
|
||
|
{
|
||
|
int ret;
|
||
|
@@ -2170,7 +2177,6 @@ static struct phy_driver at803x_driver[]
|
||
|
.phy_id_mask = QCA8K_PHY_ID_MASK,
|
||
|
.name = "Qualcomm Atheros 8337 internal PHY",
|
||
|
/* PHY_GBIT_FEATURES */
|
||
|
- .link_change_notify = qca83xx_link_change_notify,
|
||
|
.probe = at803x_probe,
|
||
|
.flags = PHY_IS_INTERNAL,
|
||
|
.config_init = qca83xx_config_init,
|
||
|
@@ -2178,7 +2184,7 @@ static struct phy_driver at803x_driver[]
|
||
|
.get_sset_count = qca83xx_get_sset_count,
|
||
|
.get_strings = qca83xx_get_strings,
|
||
|
.get_stats = qca83xx_get_stats,
|
||
|
- .suspend = qca83xx_suspend,
|
||
|
+ .suspend = qca8337_suspend,
|
||
|
.resume = qca83xx_resume,
|
||
|
}, {
|
||
|
/* QCA8327-A from switch QCA8327-AL1A */
|
||
|
@@ -2189,12 +2195,12 @@ static struct phy_driver at803x_driver[]
|
||
|
.link_change_notify = qca83xx_link_change_notify,
|
||
|
.probe = at803x_probe,
|
||
|
.flags = PHY_IS_INTERNAL,
|
||
|
- .config_init = qca83xx_config_init,
|
||
|
+ .config_init = qca8327_config_init,
|
||
|
.soft_reset = genphy_soft_reset,
|
||
|
.get_sset_count = qca83xx_get_sset_count,
|
||
|
.get_strings = qca83xx_get_strings,
|
||
|
.get_stats = qca83xx_get_stats,
|
||
|
- .suspend = qca83xx_suspend,
|
||
|
+ .suspend = qca8327_suspend,
|
||
|
.resume = qca83xx_resume,
|
||
|
}, {
|
||
|
/* QCA8327-B from switch QCA8327-BL1A */
|
||
|
@@ -2205,12 +2211,12 @@ static struct phy_driver at803x_driver[]
|
||
|
.link_change_notify = qca83xx_link_change_notify,
|
||
|
.probe = at803x_probe,
|
||
|
.flags = PHY_IS_INTERNAL,
|
||
|
- .config_init = qca83xx_config_init,
|
||
|
+ .config_init = qca8327_config_init,
|
||
|
.soft_reset = genphy_soft_reset,
|
||
|
.get_sset_count = qca83xx_get_sset_count,
|
||
|
.get_strings = qca83xx_get_strings,
|
||
|
.get_stats = qca83xx_get_stats,
|
||
|
- .suspend = qca83xx_suspend,
|
||
|
+ .suspend = qca8327_suspend,
|
||
|
.resume = qca83xx_resume,
|
||
|
}, {
|
||
|
/* Qualcomm QCA8081 */
|