Commit 54f4c257 authored by David S. Miller's avatar David S. Miller

Merge branch 'phy-ackage-addr-mmd-apis'

Christian Marangi says:

====================
net: phy: add PHY package base addr + mmd APIs

This small series is required for the upcoming qca807x PHY that
will make use of PHY package mmd API and the new implementation
with read/write based on base addr.

The MMD PHY package patch currently has no use but it will be
used in the upcoming patch and it does complete what a PHY package
may require in addition to basic read/write to setup global PHY address.

(Changelog for all the revision is present in the single patch)
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents dd784287 d63710fc
...@@ -128,6 +128,10 @@ ...@@ -128,6 +128,10 @@
#define BCM54140_DEFAULT_DOWNSHIFT 5 #define BCM54140_DEFAULT_DOWNSHIFT 5
#define BCM54140_MAX_DOWNSHIFT 9 #define BCM54140_MAX_DOWNSHIFT 9
enum bcm54140_global_phy {
BCM54140_BASE_ADDR = 0,
};
struct bcm54140_priv { struct bcm54140_priv {
int port; int port;
int base_addr; int base_addr;
...@@ -429,11 +433,13 @@ static int bcm54140_base_read_rdb(struct phy_device *phydev, u16 rdb) ...@@ -429,11 +433,13 @@ static int bcm54140_base_read_rdb(struct phy_device *phydev, u16 rdb)
int ret; int ret;
phy_lock_mdio_bus(phydev); phy_lock_mdio_bus(phydev);
ret = __phy_package_write(phydev, MII_BCM54XX_RDB_ADDR, rdb); ret = __phy_package_write(phydev, BCM54140_BASE_ADDR,
MII_BCM54XX_RDB_ADDR, rdb);
if (ret < 0) if (ret < 0)
goto out; goto out;
ret = __phy_package_read(phydev, MII_BCM54XX_RDB_DATA); ret = __phy_package_read(phydev, BCM54140_BASE_ADDR,
MII_BCM54XX_RDB_DATA);
out: out:
phy_unlock_mdio_bus(phydev); phy_unlock_mdio_bus(phydev);
...@@ -446,11 +452,13 @@ static int bcm54140_base_write_rdb(struct phy_device *phydev, ...@@ -446,11 +452,13 @@ static int bcm54140_base_write_rdb(struct phy_device *phydev,
int ret; int ret;
phy_lock_mdio_bus(phydev); phy_lock_mdio_bus(phydev);
ret = __phy_package_write(phydev, MII_BCM54XX_RDB_ADDR, rdb); ret = __phy_package_write(phydev, BCM54140_BASE_ADDR,
MII_BCM54XX_RDB_ADDR, rdb);
if (ret < 0) if (ret < 0)
goto out; goto out;
ret = __phy_package_write(phydev, MII_BCM54XX_RDB_DATA, val); ret = __phy_package_write(phydev, BCM54140_BASE_ADDR,
MII_BCM54XX_RDB_DATA, val);
out: out:
phy_unlock_mdio_bus(phydev); phy_unlock_mdio_bus(phydev);
......
...@@ -416,6 +416,11 @@ struct vsc8531_private { ...@@ -416,6 +416,11 @@ struct vsc8531_private {
* gpio_lock: used for PHC operations. Common for all PHYs as the load/save GPIO * gpio_lock: used for PHC operations. Common for all PHYs as the load/save GPIO
* is shared. * is shared.
*/ */
enum vsc85xx_global_phy {
VSC88XX_BASE_ADDR = 0,
};
struct vsc85xx_shared_private { struct vsc85xx_shared_private {
struct mutex gpio_lock; struct mutex gpio_lock;
}; };
......
...@@ -711,7 +711,7 @@ int phy_base_write(struct phy_device *phydev, u32 regnum, u16 val) ...@@ -711,7 +711,7 @@ int phy_base_write(struct phy_device *phydev, u32 regnum, u16 val)
dump_stack(); dump_stack();
} }
return __phy_package_write(phydev, regnum, val); return __phy_package_write(phydev, VSC88XX_BASE_ADDR, regnum, val);
} }
/* phydev->bus->mdio_lock should be locked when using this function */ /* phydev->bus->mdio_lock should be locked when using this function */
...@@ -722,7 +722,7 @@ int phy_base_read(struct phy_device *phydev, u32 regnum) ...@@ -722,7 +722,7 @@ int phy_base_read(struct phy_device *phydev, u32 regnum)
dump_stack(); dump_stack();
} }
return __phy_package_read(phydev, regnum); return __phy_package_read(phydev, VSC88XX_BASE_ADDR, regnum);
} }
u32 vsc85xx_csr_read(struct phy_device *phydev, u32 vsc85xx_csr_read(struct phy_device *phydev,
......
...@@ -540,6 +540,28 @@ static void mmd_phy_indirect(struct mii_bus *bus, int phy_addr, int devad, ...@@ -540,6 +540,28 @@ static void mmd_phy_indirect(struct mii_bus *bus, int phy_addr, int devad,
devad | MII_MMD_CTRL_NOINCR); devad | MII_MMD_CTRL_NOINCR);
} }
static int mmd_phy_read(struct mii_bus *bus, int phy_addr, bool is_c45,
int devad, u32 regnum)
{
if (is_c45)
return __mdiobus_c45_read(bus, phy_addr, devad, regnum);
mmd_phy_indirect(bus, phy_addr, devad, regnum);
/* Read the content of the MMD's selected register */
return __mdiobus_read(bus, phy_addr, MII_MMD_DATA);
}
static int mmd_phy_write(struct mii_bus *bus, int phy_addr, bool is_c45,
int devad, u32 regnum, u16 val)
{
if (is_c45)
return __mdiobus_c45_write(bus, phy_addr, devad, regnum, val);
mmd_phy_indirect(bus, phy_addr, devad, regnum);
/* Write the data into MMD's selected register */
return __mdiobus_write(bus, phy_addr, MII_MMD_DATA, val);
}
/** /**
* __phy_read_mmd - Convenience function for reading a register * __phy_read_mmd - Convenience function for reading a register
* from an MMD on a given PHY. * from an MMD on a given PHY.
...@@ -551,26 +573,14 @@ static void mmd_phy_indirect(struct mii_bus *bus, int phy_addr, int devad, ...@@ -551,26 +573,14 @@ static void mmd_phy_indirect(struct mii_bus *bus, int phy_addr, int devad,
*/ */
int __phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum) int __phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum)
{ {
int val;
if (regnum > (u16)~0 || devad > 32) if (regnum > (u16)~0 || devad > 32)
return -EINVAL; return -EINVAL;
if (phydev->drv && phydev->drv->read_mmd) { if (phydev->drv && phydev->drv->read_mmd)
val = phydev->drv->read_mmd(phydev, devad, regnum); return phydev->drv->read_mmd(phydev, devad, regnum);
} else if (phydev->is_c45) {
val = __mdiobus_c45_read(phydev->mdio.bus, phydev->mdio.addr,
devad, regnum);
} else {
struct mii_bus *bus = phydev->mdio.bus;
int phy_addr = phydev->mdio.addr;
mmd_phy_indirect(bus, phy_addr, devad, regnum);
/* Read the content of the MMD's selected register */ return mmd_phy_read(phydev->mdio.bus, phydev->mdio.addr,
val = __mdiobus_read(bus, phy_addr, MII_MMD_DATA); phydev->is_c45, devad, regnum);
}
return val;
} }
EXPORT_SYMBOL(__phy_read_mmd); EXPORT_SYMBOL(__phy_read_mmd);
...@@ -607,28 +617,14 @@ EXPORT_SYMBOL(phy_read_mmd); ...@@ -607,28 +617,14 @@ EXPORT_SYMBOL(phy_read_mmd);
*/ */
int __phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val) int __phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val)
{ {
int ret;
if (regnum > (u16)~0 || devad > 32) if (regnum > (u16)~0 || devad > 32)
return -EINVAL; return -EINVAL;
if (phydev->drv && phydev->drv->write_mmd) { if (phydev->drv && phydev->drv->write_mmd)
ret = phydev->drv->write_mmd(phydev, devad, regnum, val); return phydev->drv->write_mmd(phydev, devad, regnum, val);
} else if (phydev->is_c45) {
ret = __mdiobus_c45_write(phydev->mdio.bus, phydev->mdio.addr,
devad, regnum, val);
} else {
struct mii_bus *bus = phydev->mdio.bus;
int phy_addr = phydev->mdio.addr;
mmd_phy_indirect(bus, phy_addr, devad, regnum);
/* Write the data into MMD's selected register */ return mmd_phy_write(phydev->mdio.bus, phydev->mdio.addr,
__mdiobus_write(bus, phy_addr, MII_MMD_DATA, val); phydev->is_c45, devad, regnum, val);
ret = 0;
}
return ret;
} }
EXPORT_SYMBOL(__phy_write_mmd); EXPORT_SYMBOL(__phy_write_mmd);
...@@ -654,6 +650,146 @@ int phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val) ...@@ -654,6 +650,146 @@ int phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val)
} }
EXPORT_SYMBOL(phy_write_mmd); EXPORT_SYMBOL(phy_write_mmd);
/**
* __phy_package_read_mmd - read MMD reg relative to PHY package base addr
* @phydev: The phy_device struct
* @addr_offset: The offset to be added to PHY package base_addr
* @devad: The MMD to read from
* @regnum: The register on the MMD to read
*
* Convenience helper for reading a register of an MMD on a given PHY
* using the PHY package base address. The base address is added to
* the addr_offset value.
*
* Same calling rules as for __phy_read();
*
* NOTE: It's assumed that the entire PHY package is either C22 or C45.
*/
int __phy_package_read_mmd(struct phy_device *phydev,
unsigned int addr_offset, int devad,
u32 regnum)
{
int addr = phy_package_address(phydev, addr_offset);
if (addr < 0)
return addr;
if (regnum > (u16)~0 || devad > 32)
return -EINVAL;
return mmd_phy_read(phydev->mdio.bus, addr, phydev->is_c45, devad,
regnum);
}
EXPORT_SYMBOL(__phy_package_read_mmd);
/**
* phy_package_read_mmd - read MMD reg relative to PHY package base addr
* @phydev: The phy_device struct
* @addr_offset: The offset to be added to PHY package base_addr
* @devad: The MMD to read from
* @regnum: The register on the MMD to read
*
* Convenience helper for reading a register of an MMD on a given PHY
* using the PHY package base address. The base address is added to
* the addr_offset value.
*
* Same calling rules as for phy_read();
*
* NOTE: It's assumed that the entire PHY package is either C22 or C45.
*/
int phy_package_read_mmd(struct phy_device *phydev,
unsigned int addr_offset, int devad,
u32 regnum)
{
int addr = phy_package_address(phydev, addr_offset);
int val;
if (addr < 0)
return addr;
if (regnum > (u16)~0 || devad > 32)
return -EINVAL;
phy_lock_mdio_bus(phydev);
val = mmd_phy_read(phydev->mdio.bus, addr, phydev->is_c45, devad,
regnum);
phy_unlock_mdio_bus(phydev);
return val;
}
EXPORT_SYMBOL(phy_package_read_mmd);
/**
* __phy_package_write_mmd - write MMD reg relative to PHY package base addr
* @phydev: The phy_device struct
* @addr_offset: The offset to be added to PHY package base_addr
* @devad: The MMD to write to
* @regnum: The register on the MMD to write
* @val: value to write to @regnum
*
* Convenience helper for writing a register of an MMD on a given PHY
* using the PHY package base address. The base address is added to
* the addr_offset value.
*
* Same calling rules as for __phy_write();
*
* NOTE: It's assumed that the entire PHY package is either C22 or C45.
*/
int __phy_package_write_mmd(struct phy_device *phydev,
unsigned int addr_offset, int devad,
u32 regnum, u16 val)
{
int addr = phy_package_address(phydev, addr_offset);
if (addr < 0)
return addr;
if (regnum > (u16)~0 || devad > 32)
return -EINVAL;
return mmd_phy_write(phydev->mdio.bus, addr, phydev->is_c45, devad,
regnum, val);
}
EXPORT_SYMBOL(__phy_package_write_mmd);
/**
* phy_package_write_mmd - write MMD reg relative to PHY package base addr
* @phydev: The phy_device struct
* @addr_offset: The offset to be added to PHY package base_addr
* @devad: The MMD to write to
* @regnum: The register on the MMD to write
* @val: value to write to @regnum
*
* Convenience helper for writing a register of an MMD on a given PHY
* using the PHY package base address. The base address is added to
* the addr_offset value.
*
* Same calling rules as for phy_write();
*
* NOTE: It's assumed that the entire PHY package is either C22 or C45.
*/
int phy_package_write_mmd(struct phy_device *phydev,
unsigned int addr_offset, int devad,
u32 regnum, u16 val)
{
int addr = phy_package_address(phydev, addr_offset);
int ret;
if (addr < 0)
return addr;
if (regnum > (u16)~0 || devad > 32)
return -EINVAL;
phy_lock_mdio_bus(phydev);
ret = mmd_phy_write(phydev->mdio.bus, addr, phydev->is_c45, devad,
regnum, val);
phy_unlock_mdio_bus(phydev);
return ret;
}
EXPORT_SYMBOL(phy_package_write_mmd);
/** /**
* phy_modify_changed - Function for modifying a PHY register * phy_modify_changed - Function for modifying a PHY register
* @phydev: the phy_device struct * @phydev: the phy_device struct
......
...@@ -1651,20 +1651,22 @@ EXPORT_SYMBOL_GPL(phy_driver_is_genphy_10g); ...@@ -1651,20 +1651,22 @@ EXPORT_SYMBOL_GPL(phy_driver_is_genphy_10g);
/** /**
* phy_package_join - join a common PHY group * phy_package_join - join a common PHY group
* @phydev: target phy_device struct * @phydev: target phy_device struct
* @addr: cookie and PHY address for global register access * @base_addr: cookie and base PHY address of PHY package for offset
* calculation of global register access
* @priv_size: if non-zero allocate this amount of bytes for private data * @priv_size: if non-zero allocate this amount of bytes for private data
* *
* This joins a PHY group and provides a shared storage for all phydevs in * This joins a PHY group and provides a shared storage for all phydevs in
* this group. This is intended to be used for packages which contain * this group. This is intended to be used for packages which contain
* more than one PHY, for example a quad PHY transceiver. * more than one PHY, for example a quad PHY transceiver.
* *
* The addr parameter serves as a cookie which has to have the same value * The base_addr parameter serves as cookie which has to have the same values
* for all members of one group and as a PHY address to access generic * for all members of one group and as the base PHY address of the PHY package
* registers of a PHY package. Usually, one of the PHY addresses of the * for offset calculation to access generic registers of a PHY package.
* different PHYs in the package provides access to these global registers. * Usually, one of the PHY addresses of the different PHYs in the package
* provides access to these global registers.
* The address which is given here, will be used in the phy_package_read() * The address which is given here, will be used in the phy_package_read()
* and phy_package_write() convenience functions. If your PHY doesn't have * and phy_package_write() convenience functions as base and added to the
* global registers you can just pick any of the PHY addresses. * passed offset in those functions.
* *
* This will set the shared pointer of the phydev to the shared storage. * This will set the shared pointer of the phydev to the shared storage.
* If this is the first call for a this cookie the shared storage will be * If this is the first call for a this cookie the shared storage will be
...@@ -1674,17 +1676,17 @@ EXPORT_SYMBOL_GPL(phy_driver_is_genphy_10g); ...@@ -1674,17 +1676,17 @@ EXPORT_SYMBOL_GPL(phy_driver_is_genphy_10g);
* Returns < 1 on error, 0 on success. Esp. calling phy_package_join() * Returns < 1 on error, 0 on success. Esp. calling phy_package_join()
* with the same cookie but a different priv_size is an error. * with the same cookie but a different priv_size is an error.
*/ */
int phy_package_join(struct phy_device *phydev, int addr, size_t priv_size) int phy_package_join(struct phy_device *phydev, int base_addr, size_t priv_size)
{ {
struct mii_bus *bus = phydev->mdio.bus; struct mii_bus *bus = phydev->mdio.bus;
struct phy_package_shared *shared; struct phy_package_shared *shared;
int ret; int ret;
if (addr < 0 || addr >= PHY_MAX_ADDR) if (base_addr < 0 || base_addr >= PHY_MAX_ADDR)
return -EINVAL; return -EINVAL;
mutex_lock(&bus->shared_lock); mutex_lock(&bus->shared_lock);
shared = bus->shared[addr]; shared = bus->shared[base_addr];
if (!shared) { if (!shared) {
ret = -ENOMEM; ret = -ENOMEM;
shared = kzalloc(sizeof(*shared), GFP_KERNEL); shared = kzalloc(sizeof(*shared), GFP_KERNEL);
...@@ -1696,9 +1698,9 @@ int phy_package_join(struct phy_device *phydev, int addr, size_t priv_size) ...@@ -1696,9 +1698,9 @@ int phy_package_join(struct phy_device *phydev, int addr, size_t priv_size)
goto err_free; goto err_free;
shared->priv_size = priv_size; shared->priv_size = priv_size;
} }
shared->addr = addr; shared->base_addr = base_addr;
refcount_set(&shared->refcnt, 1); refcount_set(&shared->refcnt, 1);
bus->shared[addr] = shared; bus->shared[base_addr] = shared;
} else { } else {
ret = -EINVAL; ret = -EINVAL;
if (priv_size && priv_size != shared->priv_size) if (priv_size && priv_size != shared->priv_size)
...@@ -1736,7 +1738,7 @@ void phy_package_leave(struct phy_device *phydev) ...@@ -1736,7 +1738,7 @@ void phy_package_leave(struct phy_device *phydev)
return; return;
if (refcount_dec_and_mutex_lock(&shared->refcnt, &bus->shared_lock)) { if (refcount_dec_and_mutex_lock(&shared->refcnt, &bus->shared_lock)) {
bus->shared[shared->addr] = NULL; bus->shared[shared->base_addr] = NULL;
mutex_unlock(&bus->shared_lock); mutex_unlock(&bus->shared_lock);
kfree(shared->priv); kfree(shared->priv);
kfree(shared); kfree(shared);
...@@ -1755,7 +1757,8 @@ static void devm_phy_package_leave(struct device *dev, void *res) ...@@ -1755,7 +1757,8 @@ static void devm_phy_package_leave(struct device *dev, void *res)
* devm_phy_package_join - resource managed phy_package_join() * devm_phy_package_join - resource managed phy_package_join()
* @dev: device that is registering this PHY package * @dev: device that is registering this PHY package
* @phydev: target phy_device struct * @phydev: target phy_device struct
* @addr: cookie and PHY address for global register access * @base_addr: cookie and base PHY address of PHY package for offset
* calculation of global register access
* @priv_size: if non-zero allocate this amount of bytes for private data * @priv_size: if non-zero allocate this amount of bytes for private data
* *
* Managed phy_package_join(). Shared storage fetched by this function, * Managed phy_package_join(). Shared storage fetched by this function,
...@@ -1763,7 +1766,7 @@ static void devm_phy_package_leave(struct device *dev, void *res) ...@@ -1763,7 +1766,7 @@ static void devm_phy_package_leave(struct device *dev, void *res)
* phy_package_join() for more information. * phy_package_join() for more information.
*/ */
int devm_phy_package_join(struct device *dev, struct phy_device *phydev, int devm_phy_package_join(struct device *dev, struct phy_device *phydev,
int addr, size_t priv_size) int base_addr, size_t priv_size)
{ {
struct phy_device **ptr; struct phy_device **ptr;
int ret; int ret;
...@@ -1773,7 +1776,7 @@ int devm_phy_package_join(struct device *dev, struct phy_device *phydev, ...@@ -1773,7 +1776,7 @@ int devm_phy_package_join(struct device *dev, struct phy_device *phydev,
if (!ptr) if (!ptr)
return -ENOMEM; return -ENOMEM;
ret = phy_package_join(phydev, addr, priv_size); ret = phy_package_join(phydev, base_addr, priv_size);
if (!ret) { if (!ret) {
*ptr = phydev; *ptr = phydev;
......
...@@ -327,7 +327,8 @@ struct mdio_bus_stats { ...@@ -327,7 +327,8 @@ struct mdio_bus_stats {
/** /**
* struct phy_package_shared - Shared information in PHY packages * struct phy_package_shared - Shared information in PHY packages
* @addr: Common PHY address used to combine PHYs in one package * @base_addr: Base PHY address of PHY package used to combine PHYs
* in one package and for offset calculation of phy_package_read/write
* @refcnt: Number of PHYs connected to this shared data * @refcnt: Number of PHYs connected to this shared data
* @flags: Initialization of PHY package * @flags: Initialization of PHY package
* @priv_size: Size of the shared private data @priv * @priv_size: Size of the shared private data @priv
...@@ -338,7 +339,7 @@ struct mdio_bus_stats { ...@@ -338,7 +339,7 @@ struct mdio_bus_stats {
* phy_package_leave(). * phy_package_leave().
*/ */
struct phy_package_shared { struct phy_package_shared {
int addr; u8 base_addr;
refcount_t refcnt; refcount_t refcnt;
unsigned long flags; unsigned long flags;
size_t priv_size; size_t priv_size;
...@@ -1976,10 +1977,10 @@ int phy_ethtool_get_link_ksettings(struct net_device *ndev, ...@@ -1976,10 +1977,10 @@ int phy_ethtool_get_link_ksettings(struct net_device *ndev,
int phy_ethtool_set_link_ksettings(struct net_device *ndev, int phy_ethtool_set_link_ksettings(struct net_device *ndev,
const struct ethtool_link_ksettings *cmd); const struct ethtool_link_ksettings *cmd);
int phy_ethtool_nway_reset(struct net_device *ndev); int phy_ethtool_nway_reset(struct net_device *ndev);
int phy_package_join(struct phy_device *phydev, int addr, size_t priv_size); int phy_package_join(struct phy_device *phydev, int base_addr, size_t priv_size);
void phy_package_leave(struct phy_device *phydev); void phy_package_leave(struct phy_device *phydev);
int devm_phy_package_join(struct device *dev, struct phy_device *phydev, int devm_phy_package_join(struct device *dev, struct phy_device *phydev,
int addr, size_t priv_size); int base_addr, size_t priv_size);
int __init mdio_bus_init(void); int __init mdio_bus_init(void);
void mdio_bus_exit(void); void mdio_bus_exit(void);
...@@ -2002,48 +2003,83 @@ int __phy_hwtstamp_set(struct phy_device *phydev, ...@@ -2002,48 +2003,83 @@ int __phy_hwtstamp_set(struct phy_device *phydev,
struct kernel_hwtstamp_config *config, struct kernel_hwtstamp_config *config,
struct netlink_ext_ack *extack); struct netlink_ext_ack *extack);
static inline int phy_package_read(struct phy_device *phydev, u32 regnum) static inline int phy_package_address(struct phy_device *phydev,
unsigned int addr_offset)
{ {
struct phy_package_shared *shared = phydev->shared; struct phy_package_shared *shared = phydev->shared;
u8 base_addr = shared->base_addr;
if (!shared) if (addr_offset >= PHY_MAX_ADDR - base_addr)
return -EIO; return -EIO;
return mdiobus_read(phydev->mdio.bus, shared->addr, regnum); /* we know that addr will be in the range 0..31 and thus the
* implicit cast to a signed int is not a problem.
*/
return base_addr + addr_offset;
} }
static inline int __phy_package_read(struct phy_device *phydev, u32 regnum) static inline int phy_package_read(struct phy_device *phydev,
unsigned int addr_offset, u32 regnum)
{ {
struct phy_package_shared *shared = phydev->shared; int addr = phy_package_address(phydev, addr_offset);
if (!shared) if (addr < 0)
return -EIO; return addr;
return mdiobus_read(phydev->mdio.bus, addr, regnum);
}
static inline int __phy_package_read(struct phy_device *phydev,
unsigned int addr_offset, u32 regnum)
{
int addr = phy_package_address(phydev, addr_offset);
if (addr < 0)
return addr;
return __mdiobus_read(phydev->mdio.bus, shared->addr, regnum); return __mdiobus_read(phydev->mdio.bus, addr, regnum);
} }
static inline int phy_package_write(struct phy_device *phydev, static inline int phy_package_write(struct phy_device *phydev,
u32 regnum, u16 val) unsigned int addr_offset, u32 regnum,
u16 val)
{ {
struct phy_package_shared *shared = phydev->shared; int addr = phy_package_address(phydev, addr_offset);
if (!shared) if (addr < 0)
return -EIO; return addr;
return mdiobus_write(phydev->mdio.bus, shared->addr, regnum, val); return mdiobus_write(phydev->mdio.bus, addr, regnum, val);
} }
static inline int __phy_package_write(struct phy_device *phydev, static inline int __phy_package_write(struct phy_device *phydev,
u32 regnum, u16 val) unsigned int addr_offset, u32 regnum,
u16 val)
{ {
struct phy_package_shared *shared = phydev->shared; int addr = phy_package_address(phydev, addr_offset);
if (!shared) if (addr < 0)
return -EIO; return addr;
return __mdiobus_write(phydev->mdio.bus, shared->addr, regnum, val); return __mdiobus_write(phydev->mdio.bus, addr, regnum, val);
} }
int __phy_package_read_mmd(struct phy_device *phydev,
unsigned int addr_offset, int devad,
u32 regnum);
int phy_package_read_mmd(struct phy_device *phydev,
unsigned int addr_offset, int devad,
u32 regnum);
int __phy_package_write_mmd(struct phy_device *phydev,
unsigned int addr_offset, int devad,
u32 regnum, u16 val);
int phy_package_write_mmd(struct phy_device *phydev,
unsigned int addr_offset, int devad,
u32 regnum, u16 val);
static inline bool __phy_package_set_once(struct phy_device *phydev, static inline bool __phy_package_set_once(struct phy_device *phydev,
unsigned int b) unsigned int b)
{ {
......
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