From dc579fe51a14db8f353f686e5001a14a03c1cbe9 Mon Sep 17 00:00:00 2001 From: Fugang Duan Date: Fri, 21 Mar 2014 08:51:09 +0800 Subject: ENGR00304563-1 net: fec: add fixed phy address support Add fixed phy address support. i.MX6sx has two MACs, and MAC1 mdio bus connects to two phys which means MAC2 share MDIO bus with MAC1. So for any one of the two MACn, which can scan two phy address. For current implementment, it selects the little address for the default address and binding with the phy. For the situation, user can add the fixed phy address to DTS. Signed-off-by: Fugang Duan --- drivers/net/ethernet/freescale/fec.h | 1 + drivers/net/ethernet/freescale/fec_main.c | 28 +++++++++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) (limited to 'drivers/net') diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h index 12c8352900b2..b59992a2d52e 100644 --- a/drivers/net/ethernet/freescale/fec.h +++ b/drivers/net/ethernet/freescale/fec.h @@ -573,6 +573,7 @@ struct fec_enet_private { struct phy_device *phy_dev; int mii_timeout; uint phy_speed; + uint phy_id; phy_interface_t phy_interface; int link; int full_duplex; diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 816e6ae63e5b..489b9de1575f 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -1447,18 +1447,23 @@ static int fec_enet_mii_probe(struct net_device *ndev) fep->phy_dev = NULL; /* check for attached phy */ - for (phy_id = 0; (phy_id < PHY_MAX_ADDR); phy_id++) { - if ((fep->mii_bus->phy_mask & (1 << phy_id))) - continue; - if (fep->mii_bus->phy_map[phy_id] == NULL) - continue; - if (fep->mii_bus->phy_map[phy_id]->phy_id == 0) - continue; - if (dev_id--) - continue; - strncpy(mdio_bus_id, fep->mii_bus->id, MII_BUS_ID_SIZE); - break; + if (IS_ERR(&fep->phy_id) || fep->phy_id >= PHY_MAX_ADDR || + fep->mii_bus->phy_mask & (1 << fep->phy_id)) { + for (phy_id = 0; (phy_id < PHY_MAX_ADDR); phy_id++) { + if ((fep->mii_bus->phy_mask & (1 << phy_id))) + continue; + if (fep->mii_bus->phy_map[phy_id] == NULL) + continue; + if (fep->mii_bus->phy_map[phy_id]->phy_id == 0) + continue; + if (dev_id--) + continue; + break; + } + } else { + phy_id = fep->phy_id; } + strncpy(mdio_bus_id, fep->mii_bus->id, MII_BUS_ID_SIZE); if (phy_id >= PHY_MAX_ADDR) { netdev_info(ndev, "no PHY, assuming direct connection to switch\n"); @@ -2628,6 +2633,7 @@ fec_probe(struct platform_device *pdev) platform_set_drvdata(pdev, ndev); fec_of_init(pdev); + of_property_read_u32(pdev->dev.of_node, "phy-id", &fep->phy_id); ret = of_get_phy_mode(pdev->dev.of_node); if (ret < 0) { pdata = pdev->dev.platform_data; -- cgit v1.2.2