diff options
author | Eugene Konev <ejka@imfi.kspu.ru> | 2007-10-23 22:42:03 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-10-25 03:31:15 -0400 |
commit | b88219f8a2028a1ca2dd17aa7c9d9b643615646e (patch) | |
tree | a158d226dc96187556fc663cb9605061df4bffb2 /drivers/net/cpmac.c | |
parent | 67d129d14da1555bb3eaca754f6f81c02cacbe0e (diff) |
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: Eugene Konev <ejka@imfi.kspu.ru>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/cpmac.c')
-rw-r--r-- | drivers/net/cpmac.c | 64 |
1 files changed, 46 insertions, 18 deletions
diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c index 486c82b2dab6..6fd95a2c8cec 100644 --- a/drivers/net/cpmac.c +++ b/drivers/net/cpmac.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/skbuff.h> | 34 | #include <linux/skbuff.h> |
35 | #include <linux/mii.h> | 35 | #include <linux/mii.h> |
36 | #include <linux/phy.h> | 36 | #include <linux/phy.h> |
37 | #include <linux/phy_fixed.h> | ||
37 | #include <linux/platform_device.h> | 38 | #include <linux/platform_device.h> |
38 | #include <linux/dma-mapping.h> | 39 | #include <linux/dma-mapping.h> |
39 | #include <asm/gpio.h> | 40 | #include <asm/gpio.h> |
@@ -847,6 +848,15 @@ static void cpmac_adjust_link(struct net_device *dev) | |||
847 | spin_unlock(&priv->lock); | 848 | spin_unlock(&priv->lock); |
848 | } | 849 | } |
849 | 850 | ||
851 | static int cpmac_link_update(struct net_device *dev, | ||
852 | struct fixed_phy_status *status) | ||
853 | { | ||
854 | status->link = 1; | ||
855 | status->speed = 100; | ||
856 | status->duplex = 1; | ||
857 | return 0; | ||
858 | } | ||
859 | |||
850 | static int cpmac_open(struct net_device *dev) | 860 | static int cpmac_open(struct net_device *dev) |
851 | { | 861 | { |
852 | int i, size, res; | 862 | int i, size, res; |
@@ -855,15 +865,6 @@ static int cpmac_open(struct net_device *dev) | |||
855 | struct cpmac_desc *desc; | 865 | struct cpmac_desc *desc; |
856 | struct sk_buff *skb; | 866 | struct sk_buff *skb; |
857 | 867 | ||
858 | priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, | ||
859 | 0, PHY_INTERFACE_MODE_MII); | ||
860 | if (IS_ERR(priv->phy)) { | ||
861 | if (netif_msg_drv(priv)) | ||
862 | printk(KERN_ERR "%s: Could not attach to PHY\n", | ||
863 | dev->name); | ||
864 | return PTR_ERR(priv->phy); | ||
865 | } | ||
866 | |||
867 | mem = platform_get_resource_byname(priv->pdev, IORESOURCE_MEM, "regs"); | 868 | mem = platform_get_resource_byname(priv->pdev, IORESOURCE_MEM, "regs"); |
868 | if (!request_mem_region(mem->start, mem->end - mem->start, dev->name)) { | 869 | if (!request_mem_region(mem->start, mem->end - mem->start, dev->name)) { |
869 | if (netif_msg_drv(priv)) | 870 | if (netif_msg_drv(priv)) |
@@ -950,8 +951,6 @@ fail_remap: | |||
950 | release_mem_region(mem->start, mem->end - mem->start); | 951 | release_mem_region(mem->start, mem->end - mem->start); |
951 | 952 | ||
952 | fail_reserve: | 953 | fail_reserve: |
953 | phy_disconnect(priv->phy); | ||
954 | |||
955 | return res; | 954 | return res; |
956 | } | 955 | } |
957 | 956 | ||
@@ -966,8 +965,6 @@ static int cpmac_stop(struct net_device *dev) | |||
966 | cancel_work_sync(&priv->reset_work); | 965 | cancel_work_sync(&priv->reset_work); |
967 | napi_disable(&priv->napi); | 966 | napi_disable(&priv->napi); |
968 | phy_stop(priv->phy); | 967 | phy_stop(priv->phy); |
969 | phy_disconnect(priv->phy); | ||
970 | priv->phy = NULL; | ||
971 | 968 | ||
972 | cpmac_hw_stop(dev); | 969 | cpmac_hw_stop(dev); |
973 | 970 | ||
@@ -1001,11 +998,12 @@ static int external_switch; | |||
1001 | 998 | ||
1002 | static int __devinit cpmac_probe(struct platform_device *pdev) | 999 | static int __devinit cpmac_probe(struct platform_device *pdev) |
1003 | { | 1000 | { |
1004 | int rc, phy_id; | 1001 | int rc, phy_id, i; |
1005 | struct resource *mem; | 1002 | struct resource *mem; |
1006 | struct cpmac_priv *priv; | 1003 | struct cpmac_priv *priv; |
1007 | struct net_device *dev; | 1004 | struct net_device *dev; |
1008 | struct plat_cpmac_data *pdata; | 1005 | struct plat_cpmac_data *pdata; |
1006 | struct fixed_info *fixed_phy; | ||
1009 | DECLARE_MAC_BUF(mac); | 1007 | DECLARE_MAC_BUF(mac); |
1010 | 1008 | ||
1011 | pdata = pdev->dev.platform_data; | 1009 | pdata = pdev->dev.platform_data; |
@@ -1064,11 +1062,41 @@ static int __devinit cpmac_probe(struct platform_device *pdev) | |||
1064 | priv->ring_size = 64; | 1062 | priv->ring_size = 64; |
1065 | priv->msg_enable = netif_msg_init(debug_level, 0xff); | 1063 | priv->msg_enable = netif_msg_init(debug_level, 0xff); |
1066 | memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr)); | 1064 | memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr)); |
1065 | |||
1067 | if (phy_id == 31) { | 1066 | if (phy_id == 31) { |
1068 | snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, | 1067 | snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, cpmac_mii.id, |
1069 | cpmac_mii.id, phy_id); | 1068 | phy_id); |
1070 | } else | 1069 | } else { |
1071 | snprintf(priv->phy_name, BUS_ID_SIZE, "fixed@%d:%d", 100, 1); | 1070 | /* Let's try to get a free fixed phy... */ |
1071 | for (i = 0; i < MAX_PHY_AMNT; i++) { | ||
1072 | fixed_phy = fixed_mdio_get_phydev(i); | ||
1073 | if (!fixed_phy) | ||
1074 | continue; | ||
1075 | if (!fixed_phy->phydev->attached_dev) { | ||
1076 | strncpy(priv->phy_name, | ||
1077 | fixed_phy->phydev->dev.bus_id, | ||
1078 | BUS_ID_SIZE); | ||
1079 | fixed_mdio_set_link_update(fixed_phy->phydev, | ||
1080 | &cpmac_link_update); | ||
1081 | goto phy_found; | ||
1082 | } | ||
1083 | } | ||
1084 | if (netif_msg_drv(priv)) | ||
1085 | printk(KERN_ERR "%s: Could not find fixed PHY\n", | ||
1086 | dev->name); | ||
1087 | rc = -ENODEV; | ||
1088 | goto fail; | ||
1089 | } | ||
1090 | |||
1091 | phy_found: | ||
1092 | priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0, | ||
1093 | PHY_INTERFACE_MODE_MII); | ||
1094 | if (IS_ERR(priv->phy)) { | ||
1095 | if (netif_msg_drv(priv)) | ||
1096 | printk(KERN_ERR "%s: Could not attach to PHY\n", | ||
1097 | dev->name); | ||
1098 | return PTR_ERR(priv->phy); | ||
1099 | } | ||
1072 | 1100 | ||
1073 | if ((rc = register_netdev(dev))) { | 1101 | if ((rc = register_netdev(dev))) { |
1074 | printk(KERN_ERR "cpmac: error %i registering device %s\n", rc, | 1102 | printk(KERN_ERR "cpmac: error %i registering device %s\n", rc, |