mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-01-26 11:19:45 +07:00
net: phy: bcm54140: use phy_package_shared
Use the new phy_package_shared common storage to ease the package initialization and to access the global registers. Signed-off-by: Michael Walle <michael@walle.cc> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
6349084746
commit
dc9989f173
@ -132,7 +132,6 @@ struct bcm54140_priv {
|
|||||||
int port;
|
int port;
|
||||||
int base_addr;
|
int base_addr;
|
||||||
#if IS_ENABLED(CONFIG_HWMON)
|
#if IS_ENABLED(CONFIG_HWMON)
|
||||||
bool pkg_init;
|
|
||||||
/* protect the alarm bits */
|
/* protect the alarm bits */
|
||||||
struct mutex alarm_lock;
|
struct mutex alarm_lock;
|
||||||
u16 alarm;
|
u16 alarm;
|
||||||
@ -407,36 +406,6 @@ static int bcm54140_enable_monitoring(struct phy_device *phydev)
|
|||||||
return bcm_phy_modify_rdb(phydev, BCM54140_RDB_MON_CTRL, mask, set);
|
return bcm_phy_modify_rdb(phydev, BCM54140_RDB_MON_CTRL, mask, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if one PHY has already done the init of the parts common to all PHYs
|
|
||||||
* in the Quad PHY package.
|
|
||||||
*/
|
|
||||||
static bool bcm54140_is_pkg_init(struct phy_device *phydev)
|
|
||||||
{
|
|
||||||
struct bcm54140_priv *priv = phydev->priv;
|
|
||||||
struct mii_bus *bus = phydev->mdio.bus;
|
|
||||||
int base_addr = priv->base_addr;
|
|
||||||
struct phy_device *phy;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Quad PHY */
|
|
||||||
for (i = 0; i < 4; i++) {
|
|
||||||
phy = mdiobus_get_phy(bus, base_addr + i);
|
|
||||||
if (!phy)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ((phy->phy_id & phydev->drv->phy_id_mask) !=
|
|
||||||
(phydev->drv->phy_id & phydev->drv->phy_id_mask))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
priv = phy->priv;
|
|
||||||
|
|
||||||
if (priv && priv->pkg_init)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int bcm54140_probe_once(struct phy_device *phydev)
|
static int bcm54140_probe_once(struct phy_device *phydev)
|
||||||
{
|
{
|
||||||
struct device *hwmon;
|
struct device *hwmon;
|
||||||
@ -457,38 +426,34 @@ static int bcm54140_probe_once(struct phy_device *phydev)
|
|||||||
|
|
||||||
static int bcm54140_base_read_rdb(struct phy_device *phydev, u16 rdb)
|
static int bcm54140_base_read_rdb(struct phy_device *phydev, u16 rdb)
|
||||||
{
|
{
|
||||||
struct bcm54140_priv *priv = phydev->priv;
|
|
||||||
struct mii_bus *bus = phydev->mdio.bus;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mutex_lock(&bus->mdio_lock);
|
phy_lock_mdio_bus(phydev);
|
||||||
ret = __mdiobus_write(bus, priv->base_addr, MII_BCM54XX_RDB_ADDR, rdb);
|
ret = __phy_package_write(phydev, MII_BCM54XX_RDB_ADDR, rdb);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = __mdiobus_read(bus, priv->base_addr, MII_BCM54XX_RDB_DATA);
|
ret = __phy_package_read(phydev, MII_BCM54XX_RDB_DATA);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&bus->mdio_lock);
|
phy_unlock_mdio_bus(phydev);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bcm54140_base_write_rdb(struct phy_device *phydev,
|
static int bcm54140_base_write_rdb(struct phy_device *phydev,
|
||||||
u16 rdb, u16 val)
|
u16 rdb, u16 val)
|
||||||
{
|
{
|
||||||
struct bcm54140_priv *priv = phydev->priv;
|
|
||||||
struct mii_bus *bus = phydev->mdio.bus;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mutex_lock(&bus->mdio_lock);
|
phy_lock_mdio_bus(phydev);
|
||||||
ret = __mdiobus_write(bus, priv->base_addr, MII_BCM54XX_RDB_ADDR, rdb);
|
ret = __phy_package_write(phydev, MII_BCM54XX_RDB_ADDR, rdb);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = __mdiobus_write(bus, priv->base_addr, MII_BCM54XX_RDB_DATA, val);
|
ret = __phy_package_write(phydev, MII_BCM54XX_RDB_DATA, val);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&bus->mdio_lock);
|
phy_unlock_mdio_bus(phydev);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,16 +583,16 @@ static int bcm54140_probe(struct phy_device *phydev)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
devm_phy_package_join(&phydev->mdio.dev, phydev, priv->base_addr, 0);
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_HWMON)
|
#if IS_ENABLED(CONFIG_HWMON)
|
||||||
mutex_init(&priv->alarm_lock);
|
mutex_init(&priv->alarm_lock);
|
||||||
|
|
||||||
if (!bcm54140_is_pkg_init(phydev)) {
|
if (phy_package_init_once(phydev)) {
|
||||||
ret = bcm54140_probe_once(phydev);
|
ret = bcm54140_probe_once(phydev);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->pkg_init = true;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
phydev_dbg(phydev, "probed (port %d, base PHY address %d)\n",
|
phydev_dbg(phydev, "probed (port %d, base PHY address %d)\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user