Commit 6fcc040f authored by Greg Ungerer's avatar Greg Ungerer Committed by David S. Miller

net: allow FEC driver to use fixed PHY support

At least one board using the FEC driver does not have a conventional
PHY attached to it, it is directly connected to a somewhat simple
ethernet switch (the board is the SnapGear/LITE, and the attached
4-port ethernet switch is a RealTek RTL8305). This switch does not
present the usual register interface of a PHY, it presents nothing.
So a PHY scan will find nothing - it finds ID's of 0 for each PHY
on the attached MII bus.

After the FEC driver was changed to use phylib for supporting PHYs
it no longer works on this particular board/switch setup.

Add code support to use a fixed phy if no PHY is found on the MII bus.
This is based on the way the cpmac.c driver solved this same problem.
Signed-off-by: default avatarGreg Ungerer <gerg@uclinux.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b0057c51
...@@ -678,24 +678,37 @@ static int fec_enet_mii_probe(struct net_device *dev) ...@@ -678,24 +678,37 @@ static int fec_enet_mii_probe(struct net_device *dev)
{ {
struct fec_enet_private *fep = netdev_priv(dev); struct fec_enet_private *fep = netdev_priv(dev);
struct phy_device *phy_dev = NULL; struct phy_device *phy_dev = NULL;
int ret; char mdio_bus_id[MII_BUS_ID_SIZE];
char phy_name[MII_BUS_ID_SIZE + 3];
int phy_id;
fep->phy_dev = NULL; fep->phy_dev = NULL;
/* find the first phy */ /* check for attached phy */
phy_dev = phy_find_first(fep->mii_bus); for (phy_id = 0; (phy_id < PHY_MAX_ADDR); phy_id++) {
if (!phy_dev) { if ((fep->mii_bus->phy_mask & (1 << phy_id)))
printk(KERN_ERR "%s: no PHY found\n", dev->name); continue;
return -ENODEV; if (fep->mii_bus->phy_map[phy_id] == NULL)
continue;
if (fep->mii_bus->phy_map[phy_id]->phy_id == 0)
continue;
strncpy(mdio_bus_id, fep->mii_bus->id, MII_BUS_ID_SIZE);
break;
} }
/* attach the mac to the phy */ if (phy_id >= PHY_MAX_ADDR) {
ret = phy_connect_direct(dev, phy_dev, printk(KERN_INFO "%s: no PHY, assuming direct connection "
&fec_enet_adjust_link, 0, "to switch\n", dev->name);
PHY_INTERFACE_MODE_MII); strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE);
if (ret) { phy_id = 0;
printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name); }
return ret;
snprintf(phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id);
phy_dev = phy_connect(dev, phy_name, &fec_enet_adjust_link, 0,
PHY_INTERFACE_MODE_MII);
if (IS_ERR(phy_dev)) {
printk(KERN_ERR "%s: could not attach to PHY\n", dev->name);
return PTR_ERR(phy_dev);
} }
/* mask with MAC supported features */ /* mask with MAC supported features */
...@@ -738,7 +751,7 @@ static int fec_enet_mii_init(struct platform_device *pdev) ...@@ -738,7 +751,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
fep->mii_bus->read = fec_enet_mdio_read; fep->mii_bus->read = fec_enet_mdio_read;
fep->mii_bus->write = fec_enet_mdio_write; fep->mii_bus->write = fec_enet_mdio_write;
fep->mii_bus->reset = fec_enet_mdio_reset; fep->mii_bus->reset = fec_enet_mdio_reset;
snprintf(fep->mii_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id); snprintf(fep->mii_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id + 1);
fep->mii_bus->priv = fep; fep->mii_bus->priv = fep;
fep->mii_bus->parent = &pdev->dev; fep->mii_bus->parent = &pdev->dev;
......
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