1
0
Fork 0

net: phy: broadcom: add helper to write/read RDB registers

RDB (Register Data Base) registers are used on newer Broadcom PHYs. Add
helper to read, write and modify these registers.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
alistair/sunxi64-5.8
Michael Walle 2020-04-20 20:21:11 +02:00 committed by David S. Miller
parent b86a037385
commit 0a32f1ff2a
3 changed files with 92 additions and 0 deletions

View File

@ -155,6 +155,86 @@ int bcm_phy_write_shadow(struct phy_device *phydev, u16 shadow,
}
EXPORT_SYMBOL_GPL(bcm_phy_write_shadow);
int __bcm_phy_read_rdb(struct phy_device *phydev, u16 rdb)
{
int val;
val = __phy_write(phydev, MII_BCM54XX_RDB_ADDR, rdb);
if (val < 0)
return val;
return __phy_read(phydev, MII_BCM54XX_RDB_DATA);
}
EXPORT_SYMBOL_GPL(__bcm_phy_read_rdb);
int bcm_phy_read_rdb(struct phy_device *phydev, u16 rdb)
{
int ret;
phy_lock_mdio_bus(phydev);
ret = __bcm_phy_read_rdb(phydev, rdb);
phy_unlock_mdio_bus(phydev);
return ret;
}
EXPORT_SYMBOL_GPL(bcm_phy_read_rdb);
int __bcm_phy_write_rdb(struct phy_device *phydev, u16 rdb, u16 val)
{
int ret;
ret = __phy_write(phydev, MII_BCM54XX_RDB_ADDR, rdb);
if (ret < 0)
return ret;
return __phy_write(phydev, MII_BCM54XX_RDB_DATA, val);
}
EXPORT_SYMBOL_GPL(__bcm_phy_write_rdb);
int bcm_phy_write_rdb(struct phy_device *phydev, u16 rdb, u16 val)
{
int ret;
phy_lock_mdio_bus(phydev);
ret = __bcm_phy_write_rdb(phydev, rdb, val);
phy_unlock_mdio_bus(phydev);
return ret;
}
EXPORT_SYMBOL_GPL(bcm_phy_write_rdb);
int __bcm_phy_modify_rdb(struct phy_device *phydev, u16 rdb, u16 mask, u16 set)
{
int new, ret;
ret = __phy_write(phydev, MII_BCM54XX_RDB_ADDR, rdb);
if (ret < 0)
return ret;
ret = __phy_read(phydev, MII_BCM54XX_RDB_DATA);
if (ret < 0)
return ret;
new = (ret & ~mask) | set;
if (new == ret)
return 0;
return __phy_write(phydev, MII_BCM54XX_RDB_DATA, new);
}
EXPORT_SYMBOL_GPL(__bcm_phy_modify_rdb);
int bcm_phy_modify_rdb(struct phy_device *phydev, u16 rdb, u16 mask, u16 set)
{
int ret;
phy_lock_mdio_bus(phydev);
ret = __bcm_phy_modify_rdb(phydev, rdb, mask, set);
phy_unlock_mdio_bus(phydev);
return ret;
}
EXPORT_SYMBOL_GPL(bcm_phy_modify_rdb);
int bcm_phy_enable_apd(struct phy_device *phydev, bool dll_pwr_down)
{
int val;

View File

@ -48,6 +48,15 @@ int bcm_phy_write_shadow(struct phy_device *phydev, u16 shadow,
u16 val);
int bcm_phy_read_shadow(struct phy_device *phydev, u16 shadow);
int __bcm_phy_write_rdb(struct phy_device *phydev, u16 rdb, u16 val);
int bcm_phy_write_rdb(struct phy_device *phydev, u16 rdb, u16 val);
int __bcm_phy_read_rdb(struct phy_device *phydev, u16 rdb);
int bcm_phy_read_rdb(struct phy_device *phydev, u16 rdb);
int __bcm_phy_modify_rdb(struct phy_device *phydev, u16 rdb, u16 mask,
u16 set);
int bcm_phy_modify_rdb(struct phy_device *phydev, u16 rdb, u16 mask,
u16 set);
int bcm_phy_ack_intr(struct phy_device *phydev);
int bcm_phy_config_intr(struct phy_device *phydev);

View File

@ -115,6 +115,9 @@
#define MII_BCM54XX_SHD_VAL(x) ((x & 0x1f) << 10)
#define MII_BCM54XX_SHD_DATA(x) ((x & 0x3ff) << 0)
#define MII_BCM54XX_RDB_ADDR 0x1e
#define MII_BCM54XX_RDB_DATA 0x1f
/*
* AUXILIARY CONTROL SHADOW ACCESS REGISTERS. (PHY REG 0x18)
*/