Commit e5a03bfd authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller
Browse files

phy: Add an mdio_device structure



Not all devices attached to an MDIO bus are phys. So add an
mdio_device structure to represent the generic parts of an mdio
device, and place this structure into the phy_device.

Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e7f4dc35
......@@ -1235,7 +1235,7 @@ static int et131x_mii_read(struct et131x_adapter *adapter, u8 reg, u16 *value)
if (!phydev)
return -EIO;
return et131x_phy_mii_read(adapter, phydev->addr, reg, value);
return et131x_phy_mii_read(adapter, phydev->mdio.addr, reg, value);
}
static int et131x_mii_write(struct et131x_adapter *adapter, u8 addr, u8 reg,
......@@ -1462,7 +1462,7 @@ static void et1310_phy_power_switch(struct et131x_adapter *adapter, bool down)
data &= ~BMCR_PDOWN;
if (down)
data |= BMCR_PDOWN;
et131x_mii_write(adapter, phydev->addr, MII_BMCR, data);
et131x_mii_write(adapter, phydev->mdio.addr, MII_BMCR, data);
}
/* et131x_xcvr_init - Init the phy if we are setting it into force mode */
......@@ -1490,7 +1490,7 @@ static void et131x_xcvr_init(struct et131x_adapter *adapter)
else
lcr2 |= (LED_VAL_LINKON << LED_TXRX_SHIFT);
et131x_mii_write(adapter, phydev->addr, PHY_LED_2, lcr2);
et131x_mii_write(adapter, phydev->mdio.addr, PHY_LED_2, lcr2);
}
}
......@@ -3192,14 +3192,14 @@ static void et131x_adjust_link(struct net_device *netdev)
et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG,
&register18);
et131x_mii_write(adapter, phydev->addr,
et131x_mii_write(adapter, phydev->mdio.addr,
PHY_MPHY_CONTROL_REG,
register18 | 0x4);
et131x_mii_write(adapter, phydev->addr, PHY_INDEX_REG,
register18 | 0x8402);
et131x_mii_write(adapter, phydev->addr, PHY_DATA_REG,
register18 | 511);
et131x_mii_write(adapter, phydev->addr,
et131x_mii_write(adapter, phydev->mdio.addr,
PHY_INDEX_REG, register18 | 0x8402);
et131x_mii_write(adapter, phydev->mdio.addr,
PHY_DATA_REG, register18 | 511);
et131x_mii_write(adapter, phydev->mdio.addr,
PHY_MPHY_CONTROL_REG, register18);
}
......@@ -3212,8 +3212,8 @@ static void et131x_adjust_link(struct net_device *netdev)
et131x_mii_read(adapter, PHY_CONFIG, &reg);
reg &= ~ET_PHY_CONFIG_TX_FIFO_DEPTH;
reg |= ET_PHY_CONFIG_FIFO_DEPTH_32;
et131x_mii_write(adapter, phydev->addr, PHY_CONFIG,
reg);
et131x_mii_write(adapter, phydev->mdio.addr,
PHY_CONFIG, reg);
}
et131x_set_rx_dma_timer(adapter);
......@@ -3226,14 +3226,14 @@ static void et131x_adjust_link(struct net_device *netdev)
et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG,
&register18);
et131x_mii_write(adapter, phydev->addr,
et131x_mii_write(adapter, phydev->mdio.addr,
PHY_MPHY_CONTROL_REG,
register18 | 0x4);
et131x_mii_write(adapter, phydev->addr,
et131x_mii_write(adapter, phydev->mdio.addr,
PHY_INDEX_REG, register18 | 0x8402);
et131x_mii_write(adapter, phydev->addr,
et131x_mii_write(adapter, phydev->mdio.addr,
PHY_DATA_REG, register18 | 511);
et131x_mii_write(adapter, phydev->addr,
et131x_mii_write(adapter, phydev->mdio.addr,
PHY_MPHY_CONTROL_REG, register18);
}
......
......@@ -844,7 +844,7 @@ static int init_phy(struct net_device *dev)
}
netdev_dbg(dev, "attached to PHY %d UID 0x%08x Link = %d\n",
phydev->addr, phydev->phy_id, phydev->link);
phydev->mdio.addr, phydev->phy_id, phydev->link);
priv->phydev = phydev;
return 0;
......
......@@ -2305,7 +2305,7 @@ static int b44_register_phy_one(struct b44 *bp)
bp->phydev = phydev;
bp->old_link = 0;
bp->phy_addr = phydev->addr;
bp->phy_addr = phydev->mdio.addr;
phy_attached_info(phydev);
......
......@@ -401,7 +401,7 @@ int bcmgenet_mii_probe(struct net_device *dev)
* Ethernet MAC ISRs
*/
if (priv->internal_phy)
priv->mii_bus->irq[phydev->addr] = PHY_IGNORE_INTERRUPT;
priv->mii_bus->irq[phydev->mdio.addr] = PHY_IGNORE_INTERRUPT;
return 0;
}
......
......@@ -2366,8 +2366,8 @@ static int sbmac_mii_probe(struct net_device *dev)
return -ENXIO;
}
phy_dev = phy_connect(dev, dev_name(&phy_dev->dev), &sbmac_mii_poll,
PHY_INTERFACE_MODE_GMII);
phy_dev = phy_connect(dev, dev_name(&phy_dev->mdio.dev),
&sbmac_mii_poll, PHY_INTERFACE_MODE_GMII);
if (IS_ERR(phy_dev)) {
printk(KERN_ERR "%s: could not attach to PHY\n", dev->name);
return PTR_ERR(phy_dev);
......
......@@ -1295,7 +1295,7 @@ int dtsec_init(struct fman_mac *dtsec)
err = init(dtsec->regs, dtsec_drv_param, dtsec->phy_if,
dtsec->max_speed, (u8 *)eth_addr, dtsec->exceptions,
dtsec->tbiphy->addr);
dtsec->tbiphy->mdio.addr);
if (err) {
free_init_resources(dtsec);
pr_err("DTSEC version doesn't support this i/f mode\n");
......@@ -1434,11 +1434,11 @@ struct fman_mac *dtsec_config(struct fman_mac_params *params)
dtsec->tbiphy = of_phy_find_device(params->internal_phy_node);
if (!dtsec->tbiphy) {
pr_err("of_phy_find_device (TBI PHY) failed\n");
put_device(&dtsec->tbiphy->dev);
put_device(&dtsec->tbiphy->mdio.dev);
goto err_dtsec_drv_param;
}
put_device(&dtsec->tbiphy->dev);
put_device(&dtsec->tbiphy->mdio.dev);
/* Save FMan revision */
fman_get_revision(dtsec->fm, &dtsec->fm_rev_info);
......
......@@ -1054,15 +1054,15 @@ int memac_init(struct fman_mac *memac)
* register address space and access each one of 4
* ports inside QSGMII.
*/
phy_addr = memac->pcsphy->addr;
phy_addr = memac->pcsphy->mdio.addr;
qsmgii_phy_addr = (u8)((phy_addr << 2) | i);
memac->pcsphy->addr = qsmgii_phy_addr;
memac->pcsphy->mdio.addr = qsmgii_phy_addr;
if (memac->basex_if)
setup_sgmii_internal_phy_base_x(memac);
else
setup_sgmii_internal_phy(memac, fixed_link);
memac->pcsphy->addr = phy_addr;
memac->pcsphy->mdio.addr = phy_addr;
}
}
......
......@@ -254,7 +254,7 @@ static void restart(struct net_device *dev)
int r;
u32 addrhi, addrlo;
struct mii_bus* mii = fep->phydev->bus;
struct mii_bus *mii = fep->phydev->mdio.bus;
struct fec_info* fec_inf = mii->priv;
r = whack_reset(fep->fec.fecp);
......
......@@ -1834,7 +1834,7 @@ static void gfar_configure_serdes(struct net_device *dev)
* several seconds for it to come back.
*/
if (phy_read(tbiphy, MII_BMSR) & BMSR_LSTATUS) {
put_device(&tbiphy->dev);
put_device(&tbiphy->mdio.dev);
return;
}
......@@ -1849,7 +1849,7 @@ static void gfar_configure_serdes(struct net_device *dev)
BMCR_ANENABLE | BMCR_ANRESTART | BMCR_FULLDPLX |
BMCR_SPEED1000);
put_device(&tbiphy->dev);
put_device(&tbiphy->mdio.dev);
}
static int __gfar_is_rx_idle(struct gfar_private *priv)
......
......@@ -1385,7 +1385,7 @@ static int adjust_enet_interface(struct ucc_geth_private *ugeth)
value &= ~0x1000; /* Turn off autonegotiation */
phy_write(tbiphy, ENET_TBI_MII_CR, value);
put_device(&tbiphy->dev);
put_device(&tbiphy->mdio.dev);
}
init_check_frame_length_mode(ug_info->lengthCheckRx, &ug_regs->maccfg2);
......@@ -1705,7 +1705,7 @@ static void uec_configure_serdes(struct net_device *dev)
* several seconds for it to come back.
*/
if (phy_read(tbiphy, ENET_TBI_MII_SR) & TBISR_LSTATUS) {
put_device(&tbiphy->dev);
put_device(&tbiphy->mdio.dev);
return;
}
......
......@@ -71,7 +71,7 @@ static void hns_get_mdix_mode(struct net_device *net_dev,
struct hns_nic_priv *priv = netdev_priv(net_dev);
struct phy_device *phy_dev = priv->phy;
if (!phy_dev || !phy_dev->bus) {
if (!phy_dev || !phy_dev->mdio.bus) {
cmd->eth_tp_mdix_ctrl = ETH_TP_MDI_INVALID;
cmd->eth_tp_mdix = ETH_TP_MDI_INVALID;
return;
......
......@@ -3133,7 +3133,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
if (!mp->phy)
err = -ENODEV;
else
phy_addr_set(mp, mp->phy->addr);
phy_addr_set(mp, mp->phy->mdio.addr);
} else if (pd->phy_addr != MV643XX_ETH_PHY_NONE) {
mp->phy = phy_scan(mp, pd->phy_addr);
......
......@@ -3714,7 +3714,7 @@ static int mvneta_probe(struct platform_device *pdev)
mvneta_fixed_link_update(pp, phy);
put_device(&phy->dev);
put_device(&phy->mdio.dev);
}
return 0;
......
......@@ -864,8 +864,8 @@ static int smsc911x_phy_loopbacktest(struct net_device *dev)
for (i = 0; i < 10; i++) {
/* Set PHY to 10/FD, no ANEG, and loopback mode */
smsc911x_mii_write(phy_dev->bus, phy_dev->addr, MII_BMCR,
BMCR_LOOPBACK | BMCR_FULLDPLX);
smsc911x_mii_write(phy_dev->mdio.bus, phy_dev->mdio.addr,
MII_BMCR, BMCR_LOOPBACK | BMCR_FULLDPLX);
/* Enable MAC tx/rx, FD */
spin_lock_irqsave(&pdata->mac_lock, flags);
......@@ -893,7 +893,7 @@ static int smsc911x_phy_loopbacktest(struct net_device *dev)
spin_unlock_irqrestore(&pdata->mac_lock, flags);
/* Cancel PHY loopback mode */
smsc911x_mii_write(phy_dev->bus, phy_dev->addr, MII_BMCR, 0);
smsc911x_mii_write(phy_dev->mdio.bus, phy_dev->mdio.addr, MII_BMCR, 0);
smsc911x_reg_write(pdata, TX_CFG, 0);
smsc911x_reg_write(pdata, RX_CFG, 0);
......@@ -1021,7 +1021,7 @@ static int smsc911x_mii_probe(struct net_device *dev)
}
SMSC_TRACE(pdata, probe, "PHY: addr %d, phy_id 0x%08X",
phydev->addr, phydev->phy_id);
phydev->mdio.addr, phydev->phy_id);
ret = phy_connect_direct(dev, phydev, &smsc911x_phy_adjust_link,
pdata->config.phy_interface);
......@@ -1988,7 +1988,8 @@ smsc911x_ethtool_getregs(struct net_device *dev, struct ethtool_regs *regs,
}
for (i = 0; i <= 31; i++)
data[j++] = smsc911x_mii_read(phy_dev->bus, phy_dev->addr, i);
data[j++] = smsc911x_mii_read(phy_dev->mdio.bus,
phy_dev->mdio.addr, i);
}
static void smsc911x_eeprom_enable_access(struct smsc911x_data *pdata)
......
......@@ -315,7 +315,8 @@ smsc9420_ethtool_getregs(struct net_device *dev, struct ethtool_regs *regs,
return;
for (i = 0; i <= 31; i++)
data[j++] = smsc9420_mii_read(phy_dev->bus, phy_dev->addr, i);
data[j++] = smsc9420_mii_read(phy_dev->mdio.bus,
phy_dev->mdio.addr, i);
}
static void smsc9420_eeprom_enable_access(struct smsc9420_pdata *pd)
......
......@@ -2050,7 +2050,8 @@ static int cpsw_probe_dt(struct cpsw_priv *priv,
if (!phy_dev)
return -ENODEV;
snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
PHY_ID_FMT, phy_dev->bus->id, phy_dev->addr);
PHY_ID_FMT, phy_dev->mdio.bus->id,
phy_dev->mdio.addr);
} else if (parp) {
u32 phyid;
struct device_node *mdio_node;
......
......@@ -396,7 +396,7 @@ static int davinci_mdio_probe(struct platform_device *pdev)
phy = data->bus->phy_map[addr];
if (phy) {
dev_info(dev, "phy[%d]: device %s, driver %s\n",
phy->addr, phydev_name(phy),
phy->mdio.addr, phydev_name(phy),
phy->drv ? phy->drv->name : "unknown");
}
}
......
......@@ -827,7 +827,7 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
dev_info(dev,
"MDIO of the phy is not registered yet\n");
else
put_device(&phydev->dev);
put_device(&phydev->mdio.dev);
return 0;
}
......
......@@ -190,7 +190,7 @@ static int at803x_resume(struct phy_device *phydev)
static int at803x_probe(struct phy_device *phydev)
{
struct device *dev = &phydev->dev;
struct device *dev = &phydev->mdio.dev;
struct at803x_priv *priv;
struct gpio_desc *gpiod_reset;
......
......@@ -40,10 +40,10 @@ static int bcm87xx_of_reg_init(struct phy_device *phydev)
const __be32 *paddr_end;
int len, ret;
if (!phydev->dev.of_node)
if (!phydev->mdio.dev.of_node)
return 0;
paddr = of_get_property(phydev->dev.of_node,
paddr = of_get_property(phydev->mdio.dev.of_node,
"broadcom,c45-reg-init", &len);
if (!paddr)
return 0;
......
Supports Markdown
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