cpmac: add support for fixed PHY

This patch adds support for fixed PHY connected in MII mode
to cpmac. We allow external and dumb_switch module parameters
to override the PHY detection process since they are always connected
with MDIO bus identifier 0. This lets fixed PHYs to be detected
correctly and be connected to the their corresponding MDIO
bus identifier.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Florian Fainelli 2009-08-04 10:52:52 +00:00 committed by David S. Miller
parent 1e2c8d830a
commit 76e61eaa55

View File

@ -1117,22 +1117,23 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
pdata = pdev->dev.platform_data; pdata = pdev->dev.platform_data;
for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) { if (external_switch || dumb_switch) {
if (!(pdata->phy_mask & (1 << phy_id))) strncpy(mdio_bus_id, "0", BUS_ID_SIZE); /* fixed phys bus */
continue; phy_id = pdev->id;
if (!cpmac_mii->phy_map[phy_id]) } else {
continue; for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
break; if (!(pdata->phy_mask & (1 << phy_id)))
continue;
if (!cpmac_mii->phy_map[phy_id])
continue;
strncpy(mdio_bus_id, cpmac_mii->id, BUS_ID_SIZE);
break;
}
} }
if (phy_id == PHY_MAX_ADDR) { if (phy_id == PHY_MAX_ADDR) {
if (external_switch || dumb_switch) { dev_err(&pdev->dev, "no PHY present\n");
strncpy(mdio_bus_id, "0", BUS_ID_SIZE); /* fixed phys bus */ return -ENODEV;
phy_id = pdev->id;
} else {
dev_err(&pdev->dev, "no PHY present\n");
return -ENODEV;
}
} }
dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES); dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES);
@ -1166,8 +1167,11 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
priv->msg_enable = netif_msg_init(debug_level, 0xff); priv->msg_enable = netif_msg_init(debug_level, 0xff);
memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr)); memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr));
priv->phy = phy_connect(dev, dev_name(&cpmac_mii->phy_map[phy_id]->dev), snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id);
&cpmac_adjust_link, 0, PHY_INTERFACE_MODE_MII);
priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0,
PHY_INTERFACE_MODE_MII);
if (IS_ERR(priv->phy)) { if (IS_ERR(priv->phy)) {
if (netif_msg_drv(priv)) if (netif_msg_drv(priv))
printk(KERN_ERR "%s: Could not attach to PHY\n", printk(KERN_ERR "%s: Could not attach to PHY\n",