c504c37c84f8ba38628a3466d7d3cbc695cf075b
[openwrt/staging/blogic.git] /
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
5
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.
11
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>
15 ---
16 drivers/net/phy/at803x.c | 33 +++++++++++++++++++++++++++++++++
17 1 file changed, 33 insertions(+)
18
19 --- a/drivers/net/phy/at803x.c
20 +++ b/drivers/net/phy/at803x.c
21 @@ -87,6 +87,8 @@
22 #define AT803X_PSSR_MR_AN_COMPLETE 0x0200
23
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)
28
29 #define AT803X_DEBUG_REG_5 0x05
30 @@ -1306,9 +1308,37 @@ static int qca83xx_config_init(struct ph
31 break;
32 }
33
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.
37 + */
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);
42 +
43 return 0;
44 }
45
46 +static void qca83xx_link_change_notify(struct phy_device *phydev)
47 +{
48 + /* QCA8337 doesn't require DAC Amplitude adjustement */
49 + if (phydev->drv->phy_id == QCA8337_PHY_ID)
50 + return;
51 +
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);
58 + } else {
59 + /* Reset DAC Amplitude adjustment */
60 + at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0,
61 + QCA8327_DEBUG_MANU_CTRL_EN, 0);
62 + }
63 +}
64 +
65 static int qca83xx_resume(struct phy_device *phydev)
66 {
67 int ret, val;
68 @@ -1463,6 +1493,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 @@ -1478,6 +1509,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 @@ -1493,6 +1525,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,