1 From 1ca8311949aec5c9447645731ef1c6bc5bd71350 Mon Sep 17 00:00:00 2001
2 From: Ansuel Smith <ansuelsmth@gmail.com>
3 Date: Sun, 10 Oct 2021 00:46:16 +0200
4 Subject: net: phy: at803x: add DAC amplitude fix for 8327 phy
6 QCA8327 internal phy require DAC amplitude adjustement set to +6% with
7 100m speed. Also add additional define to report a change of the same
8 reg in QCA8337. (different scope it does set 1000m voltage)
9 Add link_change_notify function to set the proper amplitude adjustement
10 on PHY_RUNNING state and disable on any other state.
12 Fixes: b4df02b562f4 ("net: phy: at803x: add support for qca 8327 A variant internal phy")
13 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
14 Signed-off-by: David S. Miller <davem@davemloft.net>
16 drivers/net/phy/at803x.c | 33 +++++++++++++++++++++++++++++++++
17 1 file changed, 33 insertions(+)
19 --- a/drivers/net/phy/at803x.c
20 +++ b/drivers/net/phy/at803x.c
22 #define AT803X_PSSR_MR_AN_COMPLETE 0x0200
24 #define AT803X_DEBUG_REG_0 0x00
25 +#define QCA8327_DEBUG_MANU_CTRL_EN BIT(2)
26 +#define QCA8337_DEBUG_MANU_CTRL_EN GENMASK(3, 2)
27 #define AT803X_DEBUG_RX_CLK_DLY_EN BIT(15)
29 #define AT803X_DEBUG_REG_5 0x05
30 @@ -1314,9 +1316,37 @@ static int qca83xx_config_init(struct ph
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_REG_0,
41 + QCA8327_DEBUG_MANU_CTRL_EN, 0);
46 +static void qca83xx_link_change_notify(struct phy_device *phydev)
48 + /* QCA8337 doesn't require DAC Amplitude adjustement */
49 + if (phydev->drv->phy_id == QCA8337_PHY_ID)
52 + /* Set DAC Amplitude adjustment to +6% for 100m on link running */
53 + if (phydev->state == PHY_RUNNING) {
54 + if (phydev->speed == SPEED_100)
55 + at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0,
56 + QCA8327_DEBUG_MANU_CTRL_EN,
57 + QCA8327_DEBUG_MANU_CTRL_EN);
59 + /* Reset DAC Amplitude adjustment */
60 + at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0,
61 + QCA8327_DEBUG_MANU_CTRL_EN, 0);
65 static int qca83xx_resume(struct phy_device *phydev)
68 @@ -1471,6 +1501,7 @@ static struct phy_driver at803x_driver[]
69 .phy_id_mask = QCA8K_PHY_ID_MASK,
70 .name = "Qualcomm Atheros 8337 internal PHY",
71 /* PHY_GBIT_FEATURES */
72 + .link_change_notify = qca83xx_link_change_notify,
73 .probe = at803x_probe,
74 .flags = PHY_IS_INTERNAL,
75 .config_init = qca83xx_config_init,
76 @@ -1486,6 +1517,7 @@ static struct phy_driver at803x_driver[]
77 .phy_id_mask = QCA8K_PHY_ID_MASK,
78 .name = "Qualcomm Atheros 8327-A internal PHY",
79 /* PHY_GBIT_FEATURES */
80 + .link_change_notify = qca83xx_link_change_notify,
81 .probe = at803x_probe,
82 .flags = PHY_IS_INTERNAL,
83 .config_init = qca83xx_config_init,
84 @@ -1501,6 +1533,7 @@ static struct phy_driver at803x_driver[]
85 .phy_id_mask = QCA8K_PHY_ID_MASK,
86 .name = "Qualcomm Atheros 8327-B internal PHY",
87 /* PHY_GBIT_FEATURES */
88 + .link_change_notify = qca83xx_link_change_notify,
89 .probe = at803x_probe,
90 .flags = PHY_IS_INTERNAL,
91 .config_init = qca83xx_config_init,