28874068ce6c1a082d305d46c613b83143549e25
[openwrt/staging/ldir.git] /
1 From f3db55ae860a82e1224a909072783ef850e5d228 Mon Sep 17 00:00:00 2001
2 From: Luo Jie <quic_luoj@quicinc.com>
3 Date: Sun, 16 Jul 2023 16:49:20 +0800
4 Subject: [PATCH 2/6] net: phy: at803x: merge qca8081 slave seed function
5
6 merge the seed enablement and seed value configuration into
7 one function, since the random seed value is needed to be
8 configured when the seed is enabled.
9
10 Signed-off-by: Luo Jie <quic_luoj@quicinc.com>
11 Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
12 Signed-off-by: David S. Miller <davem@davemloft.net>
13 ---
14 drivers/net/phy/at803x.c | 29 +++++++++--------------------
15 1 file changed, 9 insertions(+), 20 deletions(-)
16
17 --- a/drivers/net/phy/at803x.c
18 +++ b/drivers/net/phy/at803x.c
19 @@ -1730,24 +1730,19 @@ static int qca808x_phy_fast_retrain_conf
20 return 0;
21 }
22
23 -static int qca808x_phy_ms_random_seed_set(struct phy_device *phydev)
24 -{
25 - u16 seed_value = prandom_u32_max(QCA808X_MASTER_SLAVE_SEED_RANGE);
26 -
27 - return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED,
28 - QCA808X_MASTER_SLAVE_SEED_CFG,
29 - FIELD_PREP(QCA808X_MASTER_SLAVE_SEED_CFG, seed_value));
30 -}
31 -
32 static int qca808x_phy_ms_seed_enable(struct phy_device *phydev, bool enable)
33 {
34 - u16 seed_enable = 0;
35 + u16 seed_value;
36
37 - if (enable)
38 - seed_enable = QCA808X_MASTER_SLAVE_SEED_ENABLE;
39 + if (!enable)
40 + return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED,
41 + QCA808X_MASTER_SLAVE_SEED_ENABLE, 0);
42
43 + seed_value = prandom_u32_max(QCA808X_MASTER_SLAVE_SEED_RANGE);
44 return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED,
45 - QCA808X_MASTER_SLAVE_SEED_ENABLE, seed_enable);
46 + QCA808X_MASTER_SLAVE_SEED_CFG | QCA808X_MASTER_SLAVE_SEED_ENABLE,
47 + FIELD_PREP(QCA808X_MASTER_SLAVE_SEED_CFG, seed_value) |
48 + QCA808X_MASTER_SLAVE_SEED_ENABLE);
49 }
50
51 static int qca808x_config_init(struct phy_device *phydev)
52 @@ -1771,12 +1766,7 @@ static int qca808x_config_init(struct ph
53 if (ret)
54 return ret;
55
56 - /* Configure lower ramdom seed to make phy linked as slave mode */
57 - ret = qca808x_phy_ms_random_seed_set(phydev);
58 - if (ret)
59 - return ret;
60 -
61 - /* Enable seed */
62 + /* Enable seed and configure lower ramdom seed to make phy linked as slave mode */
63 ret = qca808x_phy_ms_seed_enable(phydev, true);
64 if (ret)
65 return ret;
66 @@ -1821,7 +1811,6 @@ static int qca808x_read_status(struct ph
67 if (phydev->master_slave_state == MASTER_SLAVE_STATE_ERR) {
68 qca808x_phy_ms_seed_enable(phydev, false);
69 } else {
70 - qca808x_phy_ms_random_seed_set(phydev);
71 qca808x_phy_ms_seed_enable(phydev, true);
72 }
73 }