1 From d43cff3f82336c0bd965ea552232d9f4ddac71a6 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Fri, 8 Dec 2023 15:51:51 +0100
4 Subject: [PATCH 04/13] net: phy: at803x: move qca83xx specific check in
7 Rework qca83xx specific check to dedicated function to tidy things up
8 and drop useless phy_id check.
10 Also drop an useless link_change_notify for QCA8337 as it did nothing an
13 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
14 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
15 Signed-off-by: David S. Miller <davem@davemloft.net>
17 drivers/net/phy/at803x.c | 68 ++++++++++++++++++++++------------------
18 1 file changed, 37 insertions(+), 31 deletions(-)
20 --- a/drivers/net/phy/at803x.c
21 +++ b/drivers/net/phy/at803x.c
22 @@ -1623,27 +1623,26 @@ static int qca83xx_config_init(struct ph
26 + /* Following original QCA sourcecode set port to prefer master */
27 + phy_set_bits(phydev, MII_CTRL1000, CTL1000_PREFER_MASTER);
32 +static int qca8327_config_init(struct phy_device *phydev)
34 /* QCA8327 require DAC amplitude adjustment for 100m set to +6%.
35 * Disable on init and enable only with 100m speed following
36 * qca original source code.
38 - if (phydev->drv->phy_id == QCA8327_A_PHY_ID ||
39 - phydev->drv->phy_id == QCA8327_B_PHY_ID)
40 - at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL,
41 - QCA8327_DEBUG_MANU_CTRL_EN, 0);
42 + at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL,
43 + QCA8327_DEBUG_MANU_CTRL_EN, 0);
45 - /* Following original QCA sourcecode set port to prefer master */
46 - phy_set_bits(phydev, MII_CTRL1000, CTL1000_PREFER_MASTER);
49 + return qca83xx_config_init(phydev);
52 static void qca83xx_link_change_notify(struct phy_device *phydev)
54 - /* QCA8337 doesn't require DAC Amplitude adjustement */
55 - if (phydev->drv->phy_id == QCA8337_PHY_ID)
58 /* Set DAC Amplitude adjustment to +6% for 100m on link running */
59 if (phydev->state == PHY_RUNNING) {
60 if (phydev->speed == SPEED_100)
61 @@ -1686,19 +1685,6 @@ static int qca83xx_resume(struct phy_dev
63 static int qca83xx_suspend(struct phy_device *phydev)
67 - /* Only QCA8337 support actual suspend.
68 - * QCA8327 cause port unreliability when phy suspend
71 - if (phydev->drv->phy_id == QCA8337_PHY_ID) {
72 - genphy_suspend(phydev);
74 - mask |= ~(BMCR_SPEED1000 | BMCR_FULLDPLX);
75 - phy_modify(phydev, MII_BMCR, mask, 0);
78 at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_GREEN,
79 AT803X_DEBUG_GATE_CLK_IN1000, 0);
81 @@ -1709,6 +1695,27 @@ static int qca83xx_suspend(struct phy_de
85 +static int qca8337_suspend(struct phy_device *phydev)
87 + /* Only QCA8337 support actual suspend. */
88 + genphy_suspend(phydev);
90 + return qca83xx_suspend(phydev);
93 +static int qca8327_suspend(struct phy_device *phydev)
97 + /* QCA8327 cause port unreliability when phy suspend
100 + mask |= ~(BMCR_SPEED1000 | BMCR_FULLDPLX);
101 + phy_modify(phydev, MII_BMCR, mask, 0);
103 + return qca83xx_suspend(phydev);
106 static int qca808x_phy_fast_retrain_config(struct phy_device *phydev)
109 @@ -2170,7 +2177,6 @@ static struct phy_driver at803x_driver[]
110 .phy_id_mask = QCA8K_PHY_ID_MASK,
111 .name = "Qualcomm Atheros 8337 internal PHY",
112 /* PHY_GBIT_FEATURES */
113 - .link_change_notify = qca83xx_link_change_notify,
114 .probe = at803x_probe,
115 .flags = PHY_IS_INTERNAL,
116 .config_init = qca83xx_config_init,
117 @@ -2178,7 +2184,7 @@ static struct phy_driver at803x_driver[]
118 .get_sset_count = qca83xx_get_sset_count,
119 .get_strings = qca83xx_get_strings,
120 .get_stats = qca83xx_get_stats,
121 - .suspend = qca83xx_suspend,
122 + .suspend = qca8337_suspend,
123 .resume = qca83xx_resume,
125 /* QCA8327-A from switch QCA8327-AL1A */
126 @@ -2189,12 +2195,12 @@ static struct phy_driver at803x_driver[]
127 .link_change_notify = qca83xx_link_change_notify,
128 .probe = at803x_probe,
129 .flags = PHY_IS_INTERNAL,
130 - .config_init = qca83xx_config_init,
131 + .config_init = qca8327_config_init,
132 .soft_reset = genphy_soft_reset,
133 .get_sset_count = qca83xx_get_sset_count,
134 .get_strings = qca83xx_get_strings,
135 .get_stats = qca83xx_get_stats,
136 - .suspend = qca83xx_suspend,
137 + .suspend = qca8327_suspend,
138 .resume = qca83xx_resume,
140 /* QCA8327-B from switch QCA8327-BL1A */
141 @@ -2205,12 +2211,12 @@ static struct phy_driver at803x_driver[]
142 .link_change_notify = qca83xx_link_change_notify,
143 .probe = at803x_probe,
144 .flags = PHY_IS_INTERNAL,
145 - .config_init = qca83xx_config_init,
146 + .config_init = qca8327_config_init,
147 .soft_reset = genphy_soft_reset,
148 .get_sset_count = qca83xx_get_sset_count,
149 .get_strings = qca83xx_get_strings,
150 .get_stats = qca83xx_get_stats,
151 - .suspend = qca83xx_suspend,
152 + .suspend = qca8327_suspend,
153 .resume = qca83xx_resume,
155 /* Qualcomm QCA8081 */