linux-mips
[Top] [All Lists]

[PATCH 3/5] cpmac: add support for fixed PHY

To: Ralf Baechle <ralf@linux-mips.org>
Subject: [PATCH 3/5] cpmac: add support for fixed PHY
From: Florian Fainelli <florian@openwrt.org>
Date: Tue, 4 Aug 2009 22:52:52 +0200
Cc: linux-mips@linux-mips.org, netdev@vger.kernel.org, David Miller <davem@davemloft.net>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:date:subject :mime-version:x-uid:x-length:to:cc:content-type :content-transfer-encoding:content-disposition:message-id; bh=fwNcuhp3fK4B9Pxtb2MokBAolkvEYbexfYGXd63btec=; b=w/j2aq0fvjasQYECeYs1HTnT56DcTtJD45OAZRFxBRChC8+AWJoUY0Oqm+SkPUCHEU vnxbDTzbELVb6rQzM4f5M1hmZGsJ1D8t1g+k/cdTbz4rNklVXG+lhHmk/V/jv3fpu+TV V248m8plRrb2vXIsS7uubVdRRL5okGJszYvz4=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:date:subject:mime-version:x-uid:x-length:to:cc :content-type:content-transfer-encoding:content-disposition :message-id; b=duDKoLA3YUkpCLfS5nggebBPWofgP229YQHuVXVuOhStspxfzaySGLVrqTkS5I0a/T LlrnAhHBScvUkeuahxyJmDWySDmZg3Ae4Jqs3O9VN8HJgAvNrKqEH5HJIZgtu2Djv/lj W+GCYO0afNW57Lcmk+hS7nwcpWLX9FXUCAYC0=
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
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>
---
diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c
index c951dd4..f2fc722 100644
--- a/drivers/net/cpmac.c
+++ b/drivers/net/cpmac.c
@@ -1117,22 +1117,23 @@ static int __devinit cpmac_probe(struct platform_device 
*pdev)
 
        pdata = pdev->dev.platform_data;
 
-       for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
-               if (!(pdata->phy_mask & (1 << phy_id)))
-                       continue;
-               if (!cpmac_mii->phy_map[phy_id])
-                       continue;
-               break;
+       if (external_switch || dumb_switch) {
+               strncpy(mdio_bus_id, "0", BUS_ID_SIZE); /* fixed phys bus */
+               phy_id = pdev->id;
+       } else {
+               for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
+                       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 (external_switch || dumb_switch) {
-                       strncpy(mdio_bus_id, "0", BUS_ID_SIZE); /* fixed phys 
bus */
-                       phy_id = pdev->id;
-               } else {
-                       dev_err(&pdev->dev, "no PHY present\n");
-                       return -ENODEV;
-               }
+               dev_err(&pdev->dev, "no PHY present\n");
+               return -ENODEV;
        }
 
        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);
        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),
-                               &cpmac_adjust_link, 0, PHY_INTERFACE_MODE_MII);
+       snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id);
+       
+       priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0,
+                                               PHY_INTERFACE_MODE_MII);
+
        if (IS_ERR(priv->phy)) {
                if (netif_msg_drv(priv))
                        printk(KERN_ERR "%s: Could not attach to PHY\n",

<Prev in Thread] Current Thread [Next in Thread>