Commit b88219f8 authored by Eugene Konev's avatar Eugene Konev Committed by Jeff Garzik

cpmac: update to new fixed phy driver interface

Use fixed_mdio_get_phydev for obtaining fixed phy instances and adopt to
changed fixed phy device naming.
Signed-off-by: default avatarEugene Konev <ejka@imfi.kspu.ru>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 67d129d1
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/mii.h> #include <linux/mii.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/phy_fixed.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <asm/gpio.h> #include <asm/gpio.h>
...@@ -847,6 +848,15 @@ static void cpmac_adjust_link(struct net_device *dev) ...@@ -847,6 +848,15 @@ static void cpmac_adjust_link(struct net_device *dev)
spin_unlock(&priv->lock); spin_unlock(&priv->lock);
} }
static int cpmac_link_update(struct net_device *dev,
struct fixed_phy_status *status)
{
status->link = 1;
status->speed = 100;
status->duplex = 1;
return 0;
}
static int cpmac_open(struct net_device *dev) static int cpmac_open(struct net_device *dev)
{ {
int i, size, res; int i, size, res;
...@@ -855,15 +865,6 @@ static int cpmac_open(struct net_device *dev) ...@@ -855,15 +865,6 @@ static int cpmac_open(struct net_device *dev)
struct cpmac_desc *desc; struct cpmac_desc *desc;
struct sk_buff *skb; struct sk_buff *skb;
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",
dev->name);
return PTR_ERR(priv->phy);
}
mem = platform_get_resource_byname(priv->pdev, IORESOURCE_MEM, "regs"); mem = platform_get_resource_byname(priv->pdev, IORESOURCE_MEM, "regs");
if (!request_mem_region(mem->start, mem->end - mem->start, dev->name)) { if (!request_mem_region(mem->start, mem->end - mem->start, dev->name)) {
if (netif_msg_drv(priv)) if (netif_msg_drv(priv))
...@@ -950,8 +951,6 @@ static int cpmac_open(struct net_device *dev) ...@@ -950,8 +951,6 @@ static int cpmac_open(struct net_device *dev)
release_mem_region(mem->start, mem->end - mem->start); release_mem_region(mem->start, mem->end - mem->start);
fail_reserve: fail_reserve:
phy_disconnect(priv->phy);
return res; return res;
} }
...@@ -966,8 +965,6 @@ static int cpmac_stop(struct net_device *dev) ...@@ -966,8 +965,6 @@ static int cpmac_stop(struct net_device *dev)
cancel_work_sync(&priv->reset_work); cancel_work_sync(&priv->reset_work);
napi_disable(&priv->napi); napi_disable(&priv->napi);
phy_stop(priv->phy); phy_stop(priv->phy);
phy_disconnect(priv->phy);
priv->phy = NULL;
cpmac_hw_stop(dev); cpmac_hw_stop(dev);
...@@ -1001,11 +998,12 @@ static int external_switch; ...@@ -1001,11 +998,12 @@ static int external_switch;
static int __devinit cpmac_probe(struct platform_device *pdev) static int __devinit cpmac_probe(struct platform_device *pdev)
{ {
int rc, phy_id; int rc, phy_id, i;
struct resource *mem; struct resource *mem;
struct cpmac_priv *priv; struct cpmac_priv *priv;
struct net_device *dev; struct net_device *dev;
struct plat_cpmac_data *pdata; struct plat_cpmac_data *pdata;
struct fixed_info *fixed_phy;
DECLARE_MAC_BUF(mac); DECLARE_MAC_BUF(mac);
pdata = pdev->dev.platform_data; pdata = pdev->dev.platform_data;
...@@ -1064,11 +1062,41 @@ static int __devinit cpmac_probe(struct platform_device *pdev) ...@@ -1064,11 +1062,41 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
priv->ring_size = 64; priv->ring_size = 64;
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));
if (phy_id == 31) { if (phy_id == 31) {
snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, cpmac_mii.id,
cpmac_mii.id, phy_id); phy_id);
} else } else {
snprintf(priv->phy_name, BUS_ID_SIZE, "fixed@%d:%d", 100, 1); /* Let's try to get a free fixed phy... */
for (i = 0; i < MAX_PHY_AMNT; i++) {
fixed_phy = fixed_mdio_get_phydev(i);
if (!fixed_phy)
continue;
if (!fixed_phy->phydev->attached_dev) {
strncpy(priv->phy_name,
fixed_phy->phydev->dev.bus_id,
BUS_ID_SIZE);
fixed_mdio_set_link_update(fixed_phy->phydev,
&cpmac_link_update);
goto phy_found;
}
}
if (netif_msg_drv(priv))
printk(KERN_ERR "%s: Could not find fixed PHY\n",
dev->name);
rc = -ENODEV;
goto fail;
}
phy_found:
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",
dev->name);
return PTR_ERR(priv->phy);
}
if ((rc = register_netdev(dev))) { if ((rc = register_netdev(dev))) {
printk(KERN_ERR "cpmac: error %i registering device %s\n", rc, printk(KERN_ERR "cpmac: error %i registering device %s\n", rc,
......
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