b54a86e5f50bd94e01eb288969f4fcf209bdab86
[openwrt/staging/blocktrron.git] /
1 From df9401ff3e6eeaa42bfb06761967f1b71f5afce7 Mon Sep 17 00:00:00 2001
2 From: Luo Jie <quic_luoj@quicinc.com>
3 Date: Sun, 16 Jul 2023 16:49:23 +0800
4 Subject: [PATCH 5/6] net: phy: at803x: remove qca8081 1G fast retrain and
5 slave seed config
6
7 The fast retrain and slave seed configs are only applicable when the 2.5G
8 ability is supported.
9
10 Signed-off-by: Luo Jie <quic_luoj@quicinc.com>
11 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
12 Signed-off-by: David S. Miller <davem@davemloft.net>
13 ---
14 drivers/net/phy/at803x.c | 50 +++++++++++++++++++++++++---------------
15 1 file changed, 32 insertions(+), 18 deletions(-)
16
17 --- a/drivers/net/phy/at803x.c
18 +++ b/drivers/net/phy/at803x.c
19 @@ -1755,6 +1755,11 @@ static bool qca808x_is_prefer_master(str
20 (phydev->master_slave_get == MASTER_SLAVE_CFG_MASTER_PREFERRED);
21 }
22
23 +static bool qca808x_has_fast_retrain_or_slave_seed(struct phy_device *phydev)
24 +{
25 + return linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported);
26 +}
27 +
28 static int qca808x_config_init(struct phy_device *phydev)
29 {
30 int ret;
31 @@ -1771,20 +1776,24 @@ static int qca808x_config_init(struct ph
32 if (ret)
33 return ret;
34
35 - /* Config the fast retrain for the link 2500M */
36 - ret = qca808x_phy_fast_retrain_config(phydev);
37 - if (ret)
38 - return ret;
39 -
40 - ret = genphy_read_master_slave(phydev);
41 - if (ret < 0)
42 - return ret;
43 -
44 - if (!qca808x_is_prefer_master(phydev)) {
45 - /* Enable seed and configure lower ramdom seed to make phy linked as slave mode */
46 - ret = qca808x_phy_ms_seed_enable(phydev, true);
47 + if (qca808x_has_fast_retrain_or_slave_seed(phydev)) {
48 + /* Config the fast retrain for the link 2500M */
49 + ret = qca808x_phy_fast_retrain_config(phydev);
50 if (ret)
51 return ret;
52 +
53 + ret = genphy_read_master_slave(phydev);
54 + if (ret < 0)
55 + return ret;
56 +
57 + if (!qca808x_is_prefer_master(phydev)) {
58 + /* Enable seed and configure lower ramdom seed to make phy
59 + * linked as slave mode.
60 + */
61 + ret = qca808x_phy_ms_seed_enable(phydev, true);
62 + if (ret)
63 + return ret;
64 + }
65 }
66
67 /* Configure adc threshold as 100mv for the link 10M */
68 @@ -1826,11 +1835,13 @@ static int qca808x_read_status(struct ph
69 * value is configured as the same value, the link can't be up and no link change
70 * occurs.
71 */
72 - if (phydev->master_slave_state == MASTER_SLAVE_STATE_ERR ||
73 - qca808x_is_prefer_master(phydev)) {
74 - qca808x_phy_ms_seed_enable(phydev, false);
75 - } else {
76 - qca808x_phy_ms_seed_enable(phydev, true);
77 + if (qca808x_has_fast_retrain_or_slave_seed(phydev)) {
78 + if (phydev->master_slave_state == MASTER_SLAVE_STATE_ERR ||
79 + qca808x_is_prefer_master(phydev)) {
80 + qca808x_phy_ms_seed_enable(phydev, false);
81 + } else {
82 + qca808x_phy_ms_seed_enable(phydev, true);
83 + }
84 }
85 }
86
87 @@ -1845,7 +1856,10 @@ static int qca808x_soft_reset(struct phy
88 if (ret < 0)
89 return ret;
90
91 - return qca808x_phy_ms_seed_enable(phydev, true);
92 + if (qca808x_has_fast_retrain_or_slave_seed(phydev))
93 + ret = qca808x_phy_ms_seed_enable(phydev, true);
94 +
95 + return ret;
96 }
97
98 static bool qca808x_cdt_fault_length_valid(int cdt_code)