Commit 053e7e16 authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

phy: phy_{read|write}_mmd_indirect: get addr from phydev

The address of the device can be determined from the phydev structure,
rather than passing it as a parameter.
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 04521bf8
...@@ -184,25 +184,25 @@ int bcm_phy_enable_eee(struct phy_device *phydev) ...@@ -184,25 +184,25 @@ int bcm_phy_enable_eee(struct phy_device *phydev)
/* Enable EEE at PHY level */ /* Enable EEE at PHY level */
val = phy_read_mmd_indirect(phydev, BRCM_CL45VEN_EEE_CONTROL, val = phy_read_mmd_indirect(phydev, BRCM_CL45VEN_EEE_CONTROL,
MDIO_MMD_AN, phydev->addr); MDIO_MMD_AN);
if (val < 0) if (val < 0)
return val; return val;
val |= LPI_FEATURE_EN | LPI_FEATURE_EN_DIG1000X; val |= LPI_FEATURE_EN | LPI_FEATURE_EN_DIG1000X;
phy_write_mmd_indirect(phydev, BRCM_CL45VEN_EEE_CONTROL, phy_write_mmd_indirect(phydev, BRCM_CL45VEN_EEE_CONTROL,
MDIO_MMD_AN, phydev->addr, (u32)val); MDIO_MMD_AN, (u32)val);
/* Advertise EEE */ /* Advertise EEE */
val = phy_read_mmd_indirect(phydev, BCM_CL45VEN_EEE_ADV, val = phy_read_mmd_indirect(phydev, BCM_CL45VEN_EEE_ADV,
MDIO_MMD_AN, phydev->addr); MDIO_MMD_AN);
if (val < 0) if (val < 0)
return val; return val;
val |= (MDIO_AN_EEE_ADV_100TX | MDIO_AN_EEE_ADV_1000T); val |= (MDIO_AN_EEE_ADV_100TX | MDIO_AN_EEE_ADV_1000T);
phy_write_mmd_indirect(phydev, BCM_CL45VEN_EEE_ADV, phy_write_mmd_indirect(phydev, BCM_CL45VEN_EEE_ADV,
MDIO_MMD_AN, phydev->addr, (u32)val); MDIO_MMD_AN, (u32)val);
return 0; return 0;
} }
......
...@@ -160,7 +160,7 @@ static int dp83867_config_init(struct phy_device *phydev) ...@@ -160,7 +160,7 @@ static int dp83867_config_init(struct phy_device *phydev)
if ((phydev->interface >= PHY_INTERFACE_MODE_RGMII_ID) && if ((phydev->interface >= PHY_INTERFACE_MODE_RGMII_ID) &&
(phydev->interface <= PHY_INTERFACE_MODE_RGMII_RXID)) { (phydev->interface <= PHY_INTERFACE_MODE_RGMII_RXID)) {
val = phy_read_mmd_indirect(phydev, DP83867_RGMIICTL, val = phy_read_mmd_indirect(phydev, DP83867_RGMIICTL,
DP83867_DEVADDR, phydev->addr); DP83867_DEVADDR);
if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
val |= (DP83867_RGMII_TX_CLK_DELAY_EN | DP83867_RGMII_RX_CLK_DELAY_EN); val |= (DP83867_RGMII_TX_CLK_DELAY_EN | DP83867_RGMII_RX_CLK_DELAY_EN);
...@@ -172,13 +172,13 @@ static int dp83867_config_init(struct phy_device *phydev) ...@@ -172,13 +172,13 @@ static int dp83867_config_init(struct phy_device *phydev)
val |= DP83867_RGMII_RX_CLK_DELAY_EN; val |= DP83867_RGMII_RX_CLK_DELAY_EN;
phy_write_mmd_indirect(phydev, DP83867_RGMIICTL, phy_write_mmd_indirect(phydev, DP83867_RGMIICTL,
DP83867_DEVADDR, phydev->addr, val); DP83867_DEVADDR, val);
delay = (dp83867->rx_id_delay | delay = (dp83867->rx_id_delay |
(dp83867->tx_id_delay << DP83867_RGMII_TX_CLK_DELAY_SHIFT)); (dp83867->tx_id_delay << DP83867_RGMII_TX_CLK_DELAY_SHIFT));
phy_write_mmd_indirect(phydev, DP83867_RGMIIDCTL, phy_write_mmd_indirect(phydev, DP83867_RGMIIDCTL,
DP83867_DEVADDR, phydev->addr, delay); DP83867_DEVADDR, delay);
} }
return 0; return 0;
......
...@@ -78,10 +78,9 @@ static int lan88xx_probe(struct phy_device *phydev) ...@@ -78,10 +78,9 @@ static int lan88xx_probe(struct phy_device *phydev)
priv->wolopts = 0; priv->wolopts = 0;
/* these values can be used to identify internal PHY */ /* these values can be used to identify internal PHY */
priv->chip_id = phy_read_mmd_indirect(phydev, LAN88XX_MMD3_CHIP_ID, priv->chip_id = phy_read_mmd_indirect(phydev, LAN88XX_MMD3_CHIP_ID, 3);
3, phydev->addr);
priv->chip_rev = phy_read_mmd_indirect(phydev, LAN88XX_MMD3_CHIP_REV, priv->chip_rev = phy_read_mmd_indirect(phydev, LAN88XX_MMD3_CHIP_REV,
3, phydev->addr); 3);
phydev->priv = priv; phydev->priv = priv;
......
...@@ -1029,7 +1029,6 @@ static inline void mmd_phy_indirect(struct mii_bus *bus, int prtad, int devad, ...@@ -1029,7 +1029,6 @@ static inline void mmd_phy_indirect(struct mii_bus *bus, int prtad, int devad,
* @phydev: The PHY device bus * @phydev: The PHY device bus
* @prtad: MMD Address * @prtad: MMD Address
* @devad: MMD DEVAD * @devad: MMD DEVAD
* @addr: PHY address on the MII bus
* *
* Description: it reads data from the MMD registers (clause 22 to access to * Description: it reads data from the MMD registers (clause 22 to access to
* clause 45) of the specified phy address. * clause 45) of the specified phy address.
...@@ -1039,10 +1038,10 @@ static inline void mmd_phy_indirect(struct mii_bus *bus, int prtad, int devad, ...@@ -1039,10 +1038,10 @@ static inline void mmd_phy_indirect(struct mii_bus *bus, int prtad, int devad,
* 3) Write reg 13 // MMD Data Command for MMD DEVAD * 3) Write reg 13 // MMD Data Command for MMD DEVAD
* 3) Read reg 14 // Read MMD data * 3) Read reg 14 // Read MMD data
*/ */
int phy_read_mmd_indirect(struct phy_device *phydev, int prtad, int phy_read_mmd_indirect(struct phy_device *phydev, int prtad, int devad)
int devad, int addr)
{ {
struct phy_driver *phydrv = phydev->drv; struct phy_driver *phydrv = phydev->drv;
int addr = phydev->addr;
int value = -1; int value = -1;
if (!phydrv->read_mmd_indirect) { if (!phydrv->read_mmd_indirect) {
...@@ -1066,7 +1065,6 @@ EXPORT_SYMBOL(phy_read_mmd_indirect); ...@@ -1066,7 +1065,6 @@ EXPORT_SYMBOL(phy_read_mmd_indirect);
* @phydev: The PHY device * @phydev: The PHY device
* @prtad: MMD Address * @prtad: MMD Address
* @devad: MMD DEVAD * @devad: MMD DEVAD
* @addr: PHY address on the MII bus
* @data: data to write in the MMD register * @data: data to write in the MMD register
* *
* Description: Write data from the MMD registers of the specified * Description: Write data from the MMD registers of the specified
...@@ -1078,9 +1076,10 @@ EXPORT_SYMBOL(phy_read_mmd_indirect); ...@@ -1078,9 +1076,10 @@ EXPORT_SYMBOL(phy_read_mmd_indirect);
* 3) Write reg 14 // Write MMD data * 3) Write reg 14 // Write MMD data
*/ */
void phy_write_mmd_indirect(struct phy_device *phydev, int prtad, void phy_write_mmd_indirect(struct phy_device *phydev, int prtad,
int devad, int addr, u32 data) int devad, u32 data)
{ {
struct phy_driver *phydrv = phydev->drv; struct phy_driver *phydrv = phydev->drv;
int addr = phydev->addr;
if (!phydrv->write_mmd_indirect) { if (!phydrv->write_mmd_indirect) {
struct mii_bus *bus = phydev->bus; struct mii_bus *bus = phydev->bus;
...@@ -1130,7 +1129,7 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable) ...@@ -1130,7 +1129,7 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable)
/* First check if the EEE ability is supported */ /* First check if the EEE ability is supported */
eee_cap = phy_read_mmd_indirect(phydev, MDIO_PCS_EEE_ABLE, eee_cap = phy_read_mmd_indirect(phydev, MDIO_PCS_EEE_ABLE,
MDIO_MMD_PCS, phydev->addr); MDIO_MMD_PCS);
if (eee_cap <= 0) if (eee_cap <= 0)
goto eee_exit_err; goto eee_exit_err;
...@@ -1142,12 +1141,12 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable) ...@@ -1142,12 +1141,12 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable)
* the EEE advertising registers. * the EEE advertising registers.
*/ */
eee_lp = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_LPABLE, eee_lp = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_LPABLE,
MDIO_MMD_AN, phydev->addr); MDIO_MMD_AN);
if (eee_lp <= 0) if (eee_lp <= 0)
goto eee_exit_err; goto eee_exit_err;
eee_adv = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_ADV, eee_adv = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_ADV,
MDIO_MMD_AN, phydev->addr); MDIO_MMD_AN);
if (eee_adv <= 0) if (eee_adv <= 0)
goto eee_exit_err; goto eee_exit_err;
...@@ -1161,15 +1160,13 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable) ...@@ -1161,15 +1160,13 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable)
* clock while it is signaling LPI. * clock while it is signaling LPI.
*/ */
int val = phy_read_mmd_indirect(phydev, MDIO_CTRL1, int val = phy_read_mmd_indirect(phydev, MDIO_CTRL1,
MDIO_MMD_PCS, MDIO_MMD_PCS);
phydev->addr);
if (val < 0) if (val < 0)
return val; return val;
val |= MDIO_PCS_CTRL1_CLKSTOP_EN; val |= MDIO_PCS_CTRL1_CLKSTOP_EN;
phy_write_mmd_indirect(phydev, MDIO_CTRL1, phy_write_mmd_indirect(phydev, MDIO_CTRL1,
MDIO_MMD_PCS, phydev->addr, MDIO_MMD_PCS, val);
val);
} }
return 0; /* EEE supported */ return 0; /* EEE supported */
...@@ -1188,8 +1185,7 @@ EXPORT_SYMBOL(phy_init_eee); ...@@ -1188,8 +1185,7 @@ EXPORT_SYMBOL(phy_init_eee);
*/ */
int phy_get_eee_err(struct phy_device *phydev) int phy_get_eee_err(struct phy_device *phydev)
{ {
return phy_read_mmd_indirect(phydev, MDIO_PCS_EEE_WK_ERR, return phy_read_mmd_indirect(phydev, MDIO_PCS_EEE_WK_ERR, MDIO_MMD_PCS);
MDIO_MMD_PCS, phydev->addr);
} }
EXPORT_SYMBOL(phy_get_eee_err); EXPORT_SYMBOL(phy_get_eee_err);
...@@ -1206,22 +1202,19 @@ int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data) ...@@ -1206,22 +1202,19 @@ int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data)
int val; int val;
/* Get Supported EEE */ /* Get Supported EEE */
val = phy_read_mmd_indirect(phydev, MDIO_PCS_EEE_ABLE, val = phy_read_mmd_indirect(phydev, MDIO_PCS_EEE_ABLE, MDIO_MMD_PCS);
MDIO_MMD_PCS, phydev->addr);
if (val < 0) if (val < 0)
return val; return val;
data->supported = mmd_eee_cap_to_ethtool_sup_t(val); data->supported = mmd_eee_cap_to_ethtool_sup_t(val);
/* Get advertisement EEE */ /* Get advertisement EEE */
val = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_ADV, val = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_ADV, MDIO_MMD_AN);
MDIO_MMD_AN, phydev->addr);
if (val < 0) if (val < 0)
return val; return val;
data->advertised = mmd_eee_adv_to_ethtool_adv_t(val); data->advertised = mmd_eee_adv_to_ethtool_adv_t(val);
/* Get LP advertisement EEE */ /* Get LP advertisement EEE */
val = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_LPABLE, val = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_LPABLE, MDIO_MMD_AN);
MDIO_MMD_AN, phydev->addr);
if (val < 0) if (val < 0)
return val; return val;
data->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(val); data->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(val);
...@@ -1241,8 +1234,7 @@ int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data) ...@@ -1241,8 +1234,7 @@ int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
{ {
int val = ethtool_adv_to_mmd_eee_adv_t(data->advertised); int val = ethtool_adv_to_mmd_eee_adv_t(data->advertised);
phy_write_mmd_indirect(phydev, MDIO_AN_EEE_ADV, MDIO_MMD_AN, phy_write_mmd_indirect(phydev, MDIO_AN_EEE_ADV, MDIO_MMD_AN, val);
phydev->addr, val);
return 0; return 0;
} }
......
...@@ -629,14 +629,12 @@ static inline int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum) ...@@ -629,14 +629,12 @@ static inline int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum)
* phy_read_mmd_indirect - reads data from the MMD registers * phy_read_mmd_indirect - reads data from the MMD registers
* @phydev: The PHY device bus * @phydev: The PHY device bus
* @prtad: MMD Address * @prtad: MMD Address
* @devad: MMD DEVAD
* @addr: PHY address on the MII bus * @addr: PHY address on the MII bus
* *
* Description: it reads data from the MMD registers (clause 22 to access to * Description: it reads data from the MMD registers (clause 22 to access to
* clause 45) of the specified phy address. * clause 45) of the specified phy address.
*/ */
int phy_read_mmd_indirect(struct phy_device *phydev, int prtad, int phy_read_mmd_indirect(struct phy_device *phydev, int prtad, int devad);
int devad, int addr);
/** /**
* phy_read - Convenience function for reading a given PHY register * phy_read - Convenience function for reading a given PHY register
...@@ -735,14 +733,13 @@ static inline int phy_write_mmd(struct phy_device *phydev, int devad, ...@@ -735,14 +733,13 @@ static inline int phy_write_mmd(struct phy_device *phydev, int devad,
* @phydev: The PHY device * @phydev: The PHY device
* @prtad: MMD Address * @prtad: MMD Address
* @devad: MMD DEVAD * @devad: MMD DEVAD
* @addr: PHY address on the MII bus
* @data: data to write in the MMD register * @data: data to write in the MMD register
* *
* Description: Write data from the MMD registers of the specified * Description: Write data from the MMD registers of the specified
* phy address. * phy address.
*/ */
void phy_write_mmd_indirect(struct phy_device *phydev, int prtad, void phy_write_mmd_indirect(struct phy_device *phydev, int prtad,
int devad, int addr, u32 data); 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,
......
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