Commit d307eab5 authored by Paolo Abeni's avatar Paolo Abeni

Merge branch 'net-phy-lan87xx-use-genphy_read_master_slave-function'

Arun Ramadoss says:

====================
net: phy: lan87xx: use genphy_read_master_slave function

LAN87xx T1 Phy has the same register field as gigabit phy for reading the
master slave configuration. But the genphy_read_master_slave function has a
check of gigabit phy. So refactored the function in such a way, moved the speed
check to the genphy_read_status function. Analyzed the nxp-tja11xx function for
refactoring, but the register for configuring master/slave is nxp specific
which is not extended phy register.
And analyzed the reusing genphy_setup_master_slave, but for LAN87xx
MASTER_ENABLE is always 1 and Preferred state is always 0. So, I didn't try to
change it.
====================

Link: https://lore.kernel.org/r/20220307161515.14970-1-arun.ramadoss@microchip.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents 6c43a920 f1f3a674
...@@ -674,34 +674,6 @@ static int lan87xx_cable_test_get_status(struct phy_device *phydev, ...@@ -674,34 +674,6 @@ static int lan87xx_cable_test_get_status(struct phy_device *phydev,
return 0; return 0;
} }
static int lan87xx_read_master_slave(struct phy_device *phydev)
{
int rc = 0;
phydev->master_slave_get = MASTER_SLAVE_CFG_UNKNOWN;
phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN;
rc = phy_read(phydev, MII_CTRL1000);
if (rc < 0)
return rc;
if (rc & CTL1000_AS_MASTER)
phydev->master_slave_get = MASTER_SLAVE_CFG_MASTER_FORCE;
else
phydev->master_slave_get = MASTER_SLAVE_CFG_SLAVE_FORCE;
rc = phy_read(phydev, MII_STAT1000);
if (rc < 0)
return rc;
if (rc & LPA_1000MSRES)
phydev->master_slave_state = MASTER_SLAVE_STATE_MASTER;
else
phydev->master_slave_state = MASTER_SLAVE_STATE_SLAVE;
return rc;
}
static int lan87xx_read_status(struct phy_device *phydev) static int lan87xx_read_status(struct phy_device *phydev)
{ {
int rc = 0; int rc = 0;
...@@ -720,7 +692,7 @@ static int lan87xx_read_status(struct phy_device *phydev) ...@@ -720,7 +692,7 @@ static int lan87xx_read_status(struct phy_device *phydev)
phydev->pause = 0; phydev->pause = 0;
phydev->asym_pause = 0; phydev->asym_pause = 0;
rc = lan87xx_read_master_slave(phydev); rc = genphy_read_master_slave(phydev);
if (rc < 0) if (rc < 0)
return rc; return rc;
......
...@@ -2051,17 +2051,11 @@ static int genphy_setup_master_slave(struct phy_device *phydev) ...@@ -2051,17 +2051,11 @@ static int genphy_setup_master_slave(struct phy_device *phydev)
CTL1000_PREFER_MASTER), ctl); CTL1000_PREFER_MASTER), ctl);
} }
static int genphy_read_master_slave(struct phy_device *phydev) int genphy_read_master_slave(struct phy_device *phydev)
{ {
int cfg, state; int cfg, state;
int val; int val;
if (!phydev->is_gigabit_capable) {
phydev->master_slave_get = MASTER_SLAVE_CFG_UNSUPPORTED;
phydev->master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED;
return 0;
}
phydev->master_slave_get = MASTER_SLAVE_CFG_UNKNOWN; phydev->master_slave_get = MASTER_SLAVE_CFG_UNKNOWN;
phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN;
...@@ -2102,6 +2096,7 @@ static int genphy_read_master_slave(struct phy_device *phydev) ...@@ -2102,6 +2096,7 @@ static int genphy_read_master_slave(struct phy_device *phydev)
return 0; return 0;
} }
EXPORT_SYMBOL(genphy_read_master_slave);
/** /**
* genphy_restart_aneg - Enable and Restart Autonegotiation * genphy_restart_aneg - Enable and Restart Autonegotiation
...@@ -2396,14 +2391,18 @@ int genphy_read_status(struct phy_device *phydev) ...@@ -2396,14 +2391,18 @@ int genphy_read_status(struct phy_device *phydev)
if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link)
return 0; return 0;
phydev->master_slave_get = MASTER_SLAVE_CFG_UNSUPPORTED;
phydev->master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED;
phydev->speed = SPEED_UNKNOWN; phydev->speed = SPEED_UNKNOWN;
phydev->duplex = DUPLEX_UNKNOWN; phydev->duplex = DUPLEX_UNKNOWN;
phydev->pause = 0; phydev->pause = 0;
phydev->asym_pause = 0; phydev->asym_pause = 0;
err = genphy_read_master_slave(phydev); if (phydev->is_gigabit_capable) {
if (err < 0) err = genphy_read_master_slave(phydev);
return err; if (err < 0)
return err;
}
err = genphy_read_lpa(phydev); err = genphy_read_lpa(phydev);
if (err < 0) if (err < 0)
......
...@@ -1578,6 +1578,7 @@ int genphy_update_link(struct phy_device *phydev); ...@@ -1578,6 +1578,7 @@ int genphy_update_link(struct phy_device *phydev);
int genphy_read_lpa(struct phy_device *phydev); int genphy_read_lpa(struct phy_device *phydev);
int genphy_read_status_fixed(struct phy_device *phydev); int genphy_read_status_fixed(struct phy_device *phydev);
int genphy_read_status(struct phy_device *phydev); int genphy_read_status(struct phy_device *phydev);
int genphy_read_master_slave(struct phy_device *phydev);
int genphy_suspend(struct phy_device *phydev); int genphy_suspend(struct phy_device *phydev);
int genphy_resume(struct phy_device *phydev); int genphy_resume(struct phy_device *phydev);
int genphy_loopback(struct phy_device *phydev, bool enable); int genphy_loopback(struct phy_device *phydev, bool enable);
......
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