Commit 3b85d8df authored by Russell King's avatar Russell King Committed by David S. Miller

net: phy: remove the indirect MMD read/write methods

Remove the indirect MMD read/write methods which are now no longer
necessary.
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d11437e0
...@@ -22,103 +22,42 @@ static inline void mmd_phy_indirect(struct mii_bus *bus, int prtad, int devad, ...@@ -22,103 +22,42 @@ static inline void mmd_phy_indirect(struct mii_bus *bus, int prtad, int devad,
bus->write(bus, addr, MII_MMD_CTRL, (devad | MII_MMD_CTRL_NOINCR)); bus->write(bus, addr, MII_MMD_CTRL, (devad | MII_MMD_CTRL_NOINCR));
} }
/**
* phy_read_mmd_indirect - reads data from the MMD registers
* @phydev: The PHY device bus
* @prtad: MMD Address
* @devad: MMD DEVAD
*
* Description: it reads data from the MMD registers (clause 22 to access to
* clause 45) of the specified phy address.
* To read these register we have:
* 1) Write reg 13 // DEVAD
* 2) Write reg 14 // MMD Address
* 3) Write reg 13 // MMD Data Command for MMD DEVAD
* 3) Read reg 14 // Read MMD data
*/
int phy_read_mmd_indirect(struct phy_device *phydev, int prtad, int devad)
{
struct phy_driver *phydrv = phydev->drv;
int addr = phydev->mdio.addr;
int value = -1;
if (!phydrv->read_mmd_indirect) {
struct mii_bus *bus = phydev->mdio.bus;
mutex_lock(&bus->mdio_lock);
mmd_phy_indirect(bus, prtad, devad, addr);
/* Read the content of the MMD's selected register */
value = bus->read(bus, addr, MII_MMD_DATA);
mutex_unlock(&bus->mdio_lock);
} else {
value = phydrv->read_mmd_indirect(phydev, prtad, devad, addr);
}
return value;
}
EXPORT_SYMBOL(phy_read_mmd_indirect);
/** /**
* 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.
* @phydev: The phy_device struct * @phydev: The phy_device struct
* @devad: The MMD to read from * @devad: The MMD to read from (0..31)
* @regnum: The register on the MMD to read * @regnum: The register on the MMD to read (0..65535)
* *
* Same rules as for phy_read(); * Same rules as for phy_read();
*/ */
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->read_mmd) if (phydev->drv->read_mmd) {
return phydev->drv->read_mmd(phydev, devad, regnum); val = phydev->drv->read_mmd(phydev, devad, regnum);
} else if (phydev->is_c45) {
if (phydev->is_c45) {
u32 addr = MII_ADDR_C45 | (devad << 16) | (regnum & 0xffff); u32 addr = MII_ADDR_C45 | (devad << 16) | (regnum & 0xffff);
return mdiobus_read(phydev->mdio.bus, phydev->mdio.addr, addr);
}
return phy_read_mmd_indirect(phydev, regnum, devad); val = mdiobus_read(phydev->mdio.bus, phydev->mdio.addr, addr);
} } else {
EXPORT_SYMBOL(phy_read_mmd);
/**
* phy_write_mmd_indirect - writes data to the MMD registers
* @phydev: The PHY device
* @prtad: MMD Address
* @devad: MMD DEVAD
* @data: data to write in the MMD register
*
* Description: Write data from the MMD registers of the specified
* phy address.
* To write these register we have:
* 1) Write reg 13 // DEVAD
* 2) Write reg 14 // MMD Address
* 3) Write reg 13 // MMD Data Command for MMD DEVAD
* 3) Write reg 14 // Write MMD data
*/
void phy_write_mmd_indirect(struct phy_device *phydev, int prtad,
int devad, u32 data)
{
struct phy_driver *phydrv = phydev->drv;
int addr = phydev->mdio.addr;
if (!phydrv->write_mmd_indirect) {
struct mii_bus *bus = phydev->mdio.bus; struct mii_bus *bus = phydev->mdio.bus;
int phy_addr = phydev->mdio.addr;
mutex_lock(&bus->mdio_lock); mutex_lock(&bus->mdio_lock);
mmd_phy_indirect(bus, prtad, devad, addr); mmd_phy_indirect(bus, regnum, devad, phy_addr);
/* Write the data into MMD's selected register */ /* Read the content of the MMD's selected register */
bus->write(bus, addr, MII_MMD_DATA, data); val = bus->read(bus, phy_addr, MII_MMD_DATA);
mutex_unlock(&bus->mdio_lock); mutex_unlock(&bus->mdio_lock);
} else {
phydrv->write_mmd_indirect(phydev, prtad, devad, addr, data);
} }
return val;
} }
EXPORT_SYMBOL(phy_write_mmd_indirect); EXPORT_SYMBOL(phy_read_mmd);
/** /**
* phy_write_mmd - Convenience function for writing a register * phy_write_mmd - Convenience function for writing a register
...@@ -132,21 +71,31 @@ EXPORT_SYMBOL(phy_write_mmd_indirect); ...@@ -132,21 +71,31 @@ EXPORT_SYMBOL(phy_write_mmd_indirect);
*/ */
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->read_mmd) if (phydev->drv->read_mmd) {
return phydev->drv->write_mmd(phydev, devad, regnum, val); ret = phydev->drv->write_mmd(phydev, devad, regnum, val);
} else if (phydev->is_c45) {
if (phydev->is_c45) {
u32 addr = MII_ADDR_C45 | (devad << 16) | (regnum & 0xffff); u32 addr = MII_ADDR_C45 | (devad << 16) | (regnum & 0xffff);
return mdiobus_write(phydev->mdio.bus, phydev->mdio.addr, ret = mdiobus_write(phydev->mdio.bus, phydev->mdio.addr,
addr, val); addr, val);
} } else {
struct mii_bus *bus = phydev->mdio.bus;
int phy_addr = phydev->mdio.addr;
phy_write_mmd_indirect(phydev, regnum, devad, val); mutex_lock(&bus->mdio_lock);
mmd_phy_indirect(bus, regnum, devad, phy_addr);
return 0; /* Write the data into MMD's selected register */
bus->write(bus, phy_addr, MII_MMD_DATA, val);
mutex_unlock(&bus->mdio_lock);
ret = 0;
}
return ret;
} }
EXPORT_SYMBOL(phy_write_mmd); EXPORT_SYMBOL(phy_write_mmd);
...@@ -611,24 +611,6 @@ struct phy_driver { ...@@ -611,24 +611,6 @@ struct phy_driver {
int (*write_mmd)(struct phy_device *dev, int devnum, u16 regnum, int (*write_mmd)(struct phy_device *dev, int devnum, u16 regnum,
u16 val); u16 val);
/* A function provided by a phy specific driver to override the
* the PHY driver framework support for reading a MMD register
* from the PHY. If not supported, return -1. This function is
* optional for PHY specific drivers, if not provided then the
* default MMD read function is used by the PHY framework.
*/
int (*read_mmd_indirect)(struct phy_device *dev, int ptrad,
int devnum, int regnum);
/* A function provided by a phy specific driver to override the
* the PHY driver framework support for writing a MMD register
* from the PHY. This function is optional for PHY specific drivers,
* if not provided then the default MMD read function is used by
* the PHY framework.
*/
void (*write_mmd_indirect)(struct phy_device *dev, int ptrad,
int devnum, int regnum, u32 val);
/* Get the size and type of the eeprom contained within a plug-in /* Get the size and type of the eeprom contained within a plug-in
* module */ * module */
int (*module_info)(struct phy_device *dev, int (*module_info)(struct phy_device *dev,
...@@ -677,17 +659,6 @@ struct phy_fixup { ...@@ -677,17 +659,6 @@ struct phy_fixup {
*/ */
int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum); int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum);
/**
* phy_read_mmd_indirect - reads data from the MMD registers
* @phydev: The PHY device bus
* @prtad: MMD Address
* @addr: PHY address on the MII bus
*
* Description: it reads data from the MMD registers (clause 22 to access to
* clause 45) of the specified phy address.
*/
int phy_read_mmd_indirect(struct phy_device *phydev, int prtad, int devad);
/** /**
* phy_read - Convenience function for reading a given PHY register * phy_read - Convenience function for reading a given PHY register
* @phydev: the phy_device struct * @phydev: the phy_device struct
...@@ -771,19 +742,6 @@ static inline bool phy_is_pseudo_fixed_link(struct phy_device *phydev) ...@@ -771,19 +742,6 @@ static inline bool phy_is_pseudo_fixed_link(struct phy_device *phydev)
*/ */
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);
/**
* phy_write_mmd_indirect - writes data to the MMD registers
* @phydev: The PHY device
* @prtad: MMD Address
* @devad: MMD DEVAD
* @data: data to write in the MMD register
*
* Description: Write data from the MMD registers of the specified
* phy address.
*/
void phy_write_mmd_indirect(struct phy_device *phydev, int prtad,
int devad, u32 data);
struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id, struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id,
bool is_c45, bool is_c45,
struct phy_c45_device_ids *c45_ids); struct phy_c45_device_ids *c45_ids);
......
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