Commit f3db55ae authored by Luo Jie's avatar Luo Jie Committed by David S. Miller

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: default avatarLuo Jie <quic_luoj@quicinc.com>
Reviewed-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8b8bc13d
...@@ -1725,24 +1725,19 @@ static int qca808x_phy_fast_retrain_config(struct phy_device *phydev) ...@@ -1725,24 +1725,19 @@ static int qca808x_phy_fast_retrain_config(struct phy_device *phydev)
return 0; return 0;
} }
static int qca808x_phy_ms_random_seed_set(struct phy_device *phydev)
{
u16 seed_value = get_random_u32_below(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) static int qca808x_phy_ms_seed_enable(struct phy_device *phydev, bool enable)
{ {
u16 seed_enable = 0; u16 seed_value;
if (enable) if (!enable)
seed_enable = QCA808X_MASTER_SLAVE_SEED_ENABLE; return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED,
QCA808X_MASTER_SLAVE_SEED_ENABLE, 0);
seed_value = get_random_u32_below(QCA808X_MASTER_SLAVE_SEED_RANGE);
return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED, 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) static int qca808x_config_init(struct phy_device *phydev)
...@@ -1766,12 +1761,7 @@ static int qca808x_config_init(struct phy_device *phydev) ...@@ -1766,12 +1761,7 @@ static int qca808x_config_init(struct phy_device *phydev)
if (ret) if (ret)
return ret; return ret;
/* Configure lower ramdom seed to make phy linked as slave mode */ /* Enable seed and 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 */
ret = qca808x_phy_ms_seed_enable(phydev, true); ret = qca808x_phy_ms_seed_enable(phydev, true);
if (ret) if (ret)
return ret; return ret;
...@@ -1816,7 +1806,6 @@ static int qca808x_read_status(struct phy_device *phydev) ...@@ -1816,7 +1806,6 @@ static int qca808x_read_status(struct phy_device *phydev)
if (phydev->master_slave_state == MASTER_SLAVE_STATE_ERR) { if (phydev->master_slave_state == MASTER_SLAVE_STATE_ERR) {
qca808x_phy_ms_seed_enable(phydev, false); qca808x_phy_ms_seed_enable(phydev, false);
} else { } else {
qca808x_phy_ms_random_seed_set(phydev);
qca808x_phy_ms_seed_enable(phydev, true); qca808x_phy_ms_seed_enable(phydev, true);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment