diff options
author | Florian Fainelli <florian@openwrt.org> | 2009-08-04 06:52:52 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-08-05 15:22:10 -0400 |
commit | 76e61eaa55e33ea51205fad633393d1ae10311c5 (patch) | |
tree | f34aeb2da240ae791dcfd78716bb28247fd412ee /drivers/net/cpmac.c | |
parent | 1e2c8d830a74c24ccb25601bd89dcd0dbcb4e9f5 (diff) |
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>
Diffstat (limited to 'drivers/net/cpmac.c')
-rw-r--r-- | drivers/net/cpmac.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c index c951dd43f29b..7b311c6d14ab 100644 --- a/drivers/net/cpmac.c +++ b/drivers/net/cpmac.c | |||
@@ -1117,22 +1117,23 @@ static int __devinit cpmac_probe(struct platform_device *pdev) | |||
1117 | 1117 | ||
1118 | pdata = pdev->dev.platform_data; | 1118 | pdata = pdev->dev.platform_data; |
1119 | 1119 | ||
1120 | for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) { | 1120 | if (external_switch || dumb_switch) { |
1121 | if (!(pdata->phy_mask & (1 << phy_id))) | 1121 | strncpy(mdio_bus_id, "0", BUS_ID_SIZE); /* fixed phys bus */ |
1122 | continue; | 1122 | phy_id = pdev->id; |
1123 | if (!cpmac_mii->phy_map[phy_id]) | 1123 | } else { |
1124 | continue; | 1124 | for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) { |
1125 | break; | 1125 | if (!(pdata->phy_mask & (1 << phy_id))) |
1126 | continue; | ||
1127 | if (!cpmac_mii->phy_map[phy_id]) | ||
1128 | continue; | ||
1129 | strncpy(mdio_bus_id, cpmac_mii->id, BUS_ID_SIZE); | ||
1130 | break; | ||
1131 | } | ||
1126 | } | 1132 | } |
1127 | 1133 | ||
1128 | if (phy_id == PHY_MAX_ADDR) { | 1134 | if (phy_id == PHY_MAX_ADDR) { |
1129 | if (external_switch || dumb_switch) { | 1135 | dev_err(&pdev->dev, "no PHY present\n"); |
1130 | strncpy(mdio_bus_id, "0", BUS_ID_SIZE); /* fixed phys bus */ | 1136 | return -ENODEV; |
1131 | phy_id = pdev->id; | ||
1132 | } else { | ||
1133 | dev_err(&pdev->dev, "no PHY present\n"); | ||
1134 | return -ENODEV; | ||
1135 | } | ||
1136 | } | 1137 | } |
1137 | 1138 | ||
1138 | dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES); | 1139 | dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES); |
@@ -1166,8 +1167,11 @@ static int __devinit cpmac_probe(struct platform_device *pdev) | |||
1166 | priv->msg_enable = netif_msg_init(debug_level, 0xff); | 1167 | priv->msg_enable = netif_msg_init(debug_level, 0xff); |
1167 | memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr)); | 1168 | memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr)); |
1168 | 1169 | ||
1169 | priv->phy = phy_connect(dev, dev_name(&cpmac_mii->phy_map[phy_id]->dev), | 1170 | snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id); |
1170 | &cpmac_adjust_link, 0, PHY_INTERFACE_MODE_MII); | 1171 | |
1172 | priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0, | ||
1173 | PHY_INTERFACE_MODE_MII); | ||
1174 | |||
1171 | if (IS_ERR(priv->phy)) { | 1175 | if (IS_ERR(priv->phy)) { |
1172 | if (netif_msg_drv(priv)) | 1176 | if (netif_msg_drv(priv)) |
1173 | printk(KERN_ERR "%s: Could not attach to PHY\n", | 1177 | printk(KERN_ERR "%s: Could not attach to PHY\n", |