mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-22 23:12:32 +00:00
74 lines
2.5 KiB
Diff
74 lines
2.5 KiB
Diff
|
From f3db55ae860a82e1224a909072783ef850e5d228 Mon Sep 17 00:00:00 2001
|
||
|
From: Luo Jie <quic_luoj@quicinc.com>
|
||
|
Date: Sun, 16 Jul 2023 16:49:20 +0800
|
||
|
Subject: [PATCH 2/6] net: phy: at803x: merge qca8081 slave seed function
|
||
|
|
||
|
merge the seed enablement and seed value configuration into
|
||
|
one function, since the random seed value is needed to be
|
||
|
configured when the seed is enabled.
|
||
|
|
||
|
Signed-off-by: Luo Jie <quic_luoj@quicinc.com>
|
||
|
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
|
||
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||
|
---
|
||
|
drivers/net/phy/at803x.c | 29 +++++++++--------------------
|
||
|
1 file changed, 9 insertions(+), 20 deletions(-)
|
||
|
|
||
|
--- a/drivers/net/phy/at803x.c
|
||
|
+++ b/drivers/net/phy/at803x.c
|
||
|
@@ -1730,24 +1730,19 @@ static int qca808x_phy_fast_retrain_conf
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
-static int qca808x_phy_ms_random_seed_set(struct phy_device *phydev)
|
||
|
-{
|
||
|
- u16 seed_value = prandom_u32_max(QCA808X_MASTER_SLAVE_SEED_RANGE);
|
||
|
-
|
||
|
- return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED,
|
||
|
- QCA808X_MASTER_SLAVE_SEED_CFG,
|
||
|
- FIELD_PREP(QCA808X_MASTER_SLAVE_SEED_CFG, seed_value));
|
||
|
-}
|
||
|
-
|
||
|
static int qca808x_phy_ms_seed_enable(struct phy_device *phydev, bool enable)
|
||
|
{
|
||
|
- u16 seed_enable = 0;
|
||
|
+ u16 seed_value;
|
||
|
|
||
|
- if (enable)
|
||
|
- seed_enable = QCA808X_MASTER_SLAVE_SEED_ENABLE;
|
||
|
+ if (!enable)
|
||
|
+ return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED,
|
||
|
+ QCA808X_MASTER_SLAVE_SEED_ENABLE, 0);
|
||
|
|
||
|
+ seed_value = prandom_u32_max(QCA808X_MASTER_SLAVE_SEED_RANGE);
|
||
|
return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED,
|
||
|
- QCA808X_MASTER_SLAVE_SEED_ENABLE, seed_enable);
|
||
|
+ QCA808X_MASTER_SLAVE_SEED_CFG | QCA808X_MASTER_SLAVE_SEED_ENABLE,
|
||
|
+ FIELD_PREP(QCA808X_MASTER_SLAVE_SEED_CFG, seed_value) |
|
||
|
+ QCA808X_MASTER_SLAVE_SEED_ENABLE);
|
||
|
}
|
||
|
|
||
|
static int qca808x_config_init(struct phy_device *phydev)
|
||
|
@@ -1771,12 +1766,7 @@ static int qca808x_config_init(struct ph
|
||
|
if (ret)
|
||
|
return ret;
|
||
|
|
||
|
- /* Configure lower ramdom seed to make phy linked as slave mode */
|
||
|
- ret = qca808x_phy_ms_random_seed_set(phydev);
|
||
|
- if (ret)
|
||
|
- return ret;
|
||
|
-
|
||
|
- /* Enable seed */
|
||
|
+ /* Enable seed and configure lower ramdom seed to make phy linked as slave mode */
|
||
|
ret = qca808x_phy_ms_seed_enable(phydev, true);
|
||
|
if (ret)
|
||
|
return ret;
|
||
|
@@ -1821,7 +1811,6 @@ static int qca808x_read_status(struct ph
|
||
|
if (phydev->master_slave_state == MASTER_SLAVE_STATE_ERR) {
|
||
|
qca808x_phy_ms_seed_enable(phydev, false);
|
||
|
} else {
|
||
|
- qca808x_phy_ms_random_seed_set(phydev);
|
||
|
qca808x_phy_ms_seed_enable(phydev, true);
|
||
|
}
|
||
|
}
|