diff options
Diffstat (limited to 'drivers/net')
| -rw-r--r-- | drivers/net/fs_enet/fs_enet-main.c | 69 | ||||
| -rw-r--r-- | drivers/net/fs_enet/mii-bitbang.c | 29 | ||||
| -rw-r--r-- | drivers/net/fs_enet/mii-fec.c | 26 |
3 files changed, 14 insertions, 110 deletions
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c index a9cbc3191a2..9604aaed61d 100644 --- a/drivers/net/fs_enet/fs_enet-main.c +++ b/drivers/net/fs_enet/fs_enet-main.c | |||
| @@ -36,6 +36,8 @@ | |||
| 36 | #include <linux/fs.h> | 36 | #include <linux/fs.h> |
| 37 | #include <linux/platform_device.h> | 37 | #include <linux/platform_device.h> |
| 38 | #include <linux/phy.h> | 38 | #include <linux/phy.h> |
| 39 | #include <linux/of.h> | ||
| 40 | #include <linux/of_mdio.h> | ||
| 39 | #include <linux/of_platform.h> | 41 | #include <linux/of_platform.h> |
| 40 | #include <linux/of_gpio.h> | 42 | #include <linux/of_gpio.h> |
| 41 | 43 | ||
| @@ -752,9 +754,10 @@ static int fs_init_phy(struct net_device *dev) | |||
| 752 | fep->oldlink = 0; | 754 | fep->oldlink = 0; |
| 753 | fep->oldspeed = 0; | 755 | fep->oldspeed = 0; |
| 754 | fep->oldduplex = -1; | 756 | fep->oldduplex = -1; |
| 755 | if(fep->fpi->bus_id) | 757 | if(fep->fpi->phy_node) |
| 756 | phydev = phy_connect(dev, fep->fpi->bus_id, &fs_adjust_link, 0, | 758 | phydev = of_phy_connect(dev, fep->fpi->phy_node, |
| 757 | PHY_INTERFACE_MODE_MII); | 759 | &fs_adjust_link, 0, |
| 760 | PHY_INTERFACE_MODE_MII); | ||
| 758 | else { | 761 | else { |
| 759 | printk("No phy bus ID specified in BSP code\n"); | 762 | printk("No phy bus ID specified in BSP code\n"); |
| 760 | return -EINVAL; | 763 | return -EINVAL; |
| @@ -962,57 +965,6 @@ static void cleanup_immap(void) | |||
| 962 | 965 | ||
| 963 | /**************************************************************************************/ | 966 | /**************************************************************************************/ |
| 964 | 967 | ||
| 965 | static int __devinit find_phy(struct device_node *np, | ||
| 966 | struct fs_platform_info *fpi) | ||
| 967 | { | ||
| 968 | struct device_node *phynode, *mdionode; | ||
| 969 | int ret = 0, len, bus_id; | ||
| 970 | const u32 *data; | ||
| 971 | |||
| 972 | data = of_get_property(np, "fixed-link", NULL); | ||
| 973 | if (data) { | ||
| 974 | snprintf(fpi->bus_id, 16, "%x:%02x", 0, *data); | ||
| 975 | return 0; | ||
| 976 | } | ||
| 977 | |||
| 978 | data = of_get_property(np, "phy-handle", &len); | ||
| 979 | if (!data || len != 4) | ||
| 980 | return -EINVAL; | ||
| 981 | |||
| 982 | phynode = of_find_node_by_phandle(*data); | ||
| 983 | if (!phynode) | ||
| 984 | return -EINVAL; | ||
| 985 | |||
| 986 | data = of_get_property(phynode, "reg", &len); | ||
| 987 | if (!data || len != 4) { | ||
| 988 | ret = -EINVAL; | ||
| 989 | goto out_put_phy; | ||
| 990 | } | ||
| 991 | |||
| 992 | mdionode = of_get_parent(phynode); | ||
| 993 | if (!mdionode) { | ||
| 994 | ret = -EINVAL; | ||
| 995 | goto out_put_phy; | ||
| 996 | } | ||
| 997 | |||
| 998 | bus_id = of_get_gpio(mdionode, 0); | ||
| 999 | if (bus_id < 0) { | ||
| 1000 | struct resource res; | ||
| 1001 | ret = of_address_to_resource(mdionode, 0, &res); | ||
| 1002 | if (ret) | ||
| 1003 | goto out_put_mdio; | ||
| 1004 | bus_id = res.start; | ||
| 1005 | } | ||
| 1006 | |||
| 1007 | snprintf(fpi->bus_id, 16, "%x:%02x", bus_id, *data); | ||
| 1008 | |||
| 1009 | out_put_mdio: | ||
| 1010 | of_node_put(mdionode); | ||
| 1011 | out_put_phy: | ||
| 1012 | of_node_put(phynode); | ||
| 1013 | return ret; | ||
| 1014 | } | ||
| 1015 | |||
| 1016 | #ifdef CONFIG_FS_ENET_HAS_FEC | 968 | #ifdef CONFIG_FS_ENET_HAS_FEC |
| 1017 | #define IS_FEC(match) ((match)->data == &fs_fec_ops) | 969 | #define IS_FEC(match) ((match)->data == &fs_fec_ops) |
| 1018 | #else | 970 | #else |
| @@ -1062,9 +1014,9 @@ static int __devinit fs_enet_probe(struct of_device *ofdev, | |||
| 1062 | fpi->rx_copybreak = 240; | 1014 | fpi->rx_copybreak = 240; |
| 1063 | fpi->use_napi = 1; | 1015 | fpi->use_napi = 1; |
| 1064 | fpi->napi_weight = 17; | 1016 | fpi->napi_weight = 17; |
| 1065 | 1017 | fpi->phy_node = of_parse_phandle(ofdev->node, "phy-handle", 0); | |
| 1066 | ret = find_phy(ofdev->node, fpi); | 1018 | if ((!fpi->phy_node) && (!of_get_property(ofdev->node, "fixed-link", |
| 1067 | if (ret) | 1019 | NULL))) |
| 1068 | goto out_free_fpi; | 1020 | goto out_free_fpi; |
| 1069 | 1021 | ||
| 1070 | privsize = sizeof(*fep) + | 1022 | privsize = sizeof(*fep) + |
| @@ -1136,6 +1088,7 @@ out_cleanup_data: | |||
| 1136 | out_free_dev: | 1088 | out_free_dev: |
| 1137 | free_netdev(ndev); | 1089 | free_netdev(ndev); |
| 1138 | dev_set_drvdata(&ofdev->dev, NULL); | 1090 | dev_set_drvdata(&ofdev->dev, NULL); |
| 1091 | of_node_put(fpi->phy_node); | ||
| 1139 | out_free_fpi: | 1092 | out_free_fpi: |
| 1140 | kfree(fpi); | 1093 | kfree(fpi); |
| 1141 | return ret; | 1094 | return ret; |
| @@ -1151,7 +1104,7 @@ static int fs_enet_remove(struct of_device *ofdev) | |||
| 1151 | fep->ops->free_bd(ndev); | 1104 | fep->ops->free_bd(ndev); |
| 1152 | fep->ops->cleanup_data(ndev); | 1105 | fep->ops->cleanup_data(ndev); |
| 1153 | dev_set_drvdata(fep->dev, NULL); | 1106 | dev_set_drvdata(fep->dev, NULL); |
| 1154 | 1107 | of_node_put(fep->fpi->phy_node); | |
| 1155 | free_netdev(ndev); | 1108 | free_netdev(ndev); |
| 1156 | return 0; | 1109 | return 0; |
| 1157 | } | 1110 | } |
diff --git a/drivers/net/fs_enet/mii-bitbang.c b/drivers/net/fs_enet/mii-bitbang.c index 49b6645d7e0..93b481b0e3c 100644 --- a/drivers/net/fs_enet/mii-bitbang.c +++ b/drivers/net/fs_enet/mii-bitbang.c | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include <linux/mii.h> | 22 | #include <linux/mii.h> |
| 23 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
| 24 | #include <linux/mdio-bitbang.h> | 24 | #include <linux/mdio-bitbang.h> |
| 25 | #include <linux/of_mdio.h> | ||
| 25 | #include <linux/of_platform.h> | 26 | #include <linux/of_platform.h> |
| 26 | 27 | ||
| 27 | #include "fs_enet.h" | 28 | #include "fs_enet.h" |
| @@ -149,31 +150,12 @@ static int __devinit fs_mii_bitbang_init(struct mii_bus *bus, | |||
| 149 | return 0; | 150 | return 0; |
| 150 | } | 151 | } |
| 151 | 152 | ||
| 152 | static void __devinit add_phy(struct mii_bus *bus, struct device_node *np) | ||
| 153 | { | ||
| 154 | const u32 *data; | ||
| 155 | int len, id, irq; | ||
| 156 | |||
| 157 | data = of_get_property(np, "reg", &len); | ||
| 158 | if (!data || len != 4) | ||
| 159 | return; | ||
| 160 | |||
| 161 | id = *data; | ||
| 162 | bus->phy_mask &= ~(1 << id); | ||
| 163 | |||
| 164 | irq = of_irq_to_resource(np, 0, NULL); | ||
| 165 | if (irq != NO_IRQ) | ||
| 166 | bus->irq[id] = irq; | ||
| 167 | } | ||
| 168 | |||
| 169 | static int __devinit fs_enet_mdio_probe(struct of_device *ofdev, | 153 | static int __devinit fs_enet_mdio_probe(struct of_device *ofdev, |
| 170 | const struct of_device_id *match) | 154 | const struct of_device_id *match) |
| 171 | { | 155 | { |
| 172 | struct device_node *np = NULL; | ||
| 173 | struct mii_bus *new_bus; | 156 | struct mii_bus *new_bus; |
| 174 | struct bb_info *bitbang; | 157 | struct bb_info *bitbang; |
| 175 | int ret = -ENOMEM; | 158 | int ret = -ENOMEM; |
| 176 | int i; | ||
| 177 | 159 | ||
| 178 | bitbang = kzalloc(sizeof(struct bb_info), GFP_KERNEL); | 160 | bitbang = kzalloc(sizeof(struct bb_info), GFP_KERNEL); |
| 179 | if (!bitbang) | 161 | if (!bitbang) |
| @@ -196,17 +178,10 @@ static int __devinit fs_enet_mdio_probe(struct of_device *ofdev, | |||
| 196 | if (!new_bus->irq) | 178 | if (!new_bus->irq) |
| 197 | goto out_unmap_regs; | 179 | goto out_unmap_regs; |
| 198 | 180 | ||
| 199 | for (i = 0; i < PHY_MAX_ADDR; i++) | ||
| 200 | new_bus->irq[i] = -1; | ||
| 201 | |||
| 202 | while ((np = of_get_next_child(ofdev->node, np))) | ||
| 203 | if (!strcmp(np->type, "ethernet-phy")) | ||
| 204 | add_phy(new_bus, np); | ||
| 205 | |||
| 206 | new_bus->parent = &ofdev->dev; | 181 | new_bus->parent = &ofdev->dev; |
| 207 | dev_set_drvdata(&ofdev->dev, new_bus); | 182 | dev_set_drvdata(&ofdev->dev, new_bus); |
| 208 | 183 | ||
| 209 | ret = mdiobus_register(new_bus); | 184 | ret = of_mdiobus_register(new_bus, ofdev->node); |
| 210 | if (ret) | 185 | if (ret) |
| 211 | goto out_free_irqs; | 186 | goto out_free_irqs; |
| 212 | 187 | ||
diff --git a/drivers/net/fs_enet/mii-fec.c b/drivers/net/fs_enet/mii-fec.c index 61aaae444b4..75a09994d66 100644 --- a/drivers/net/fs_enet/mii-fec.c +++ b/drivers/net/fs_enet/mii-fec.c | |||
| @@ -100,23 +100,6 @@ static int fs_enet_fec_mii_reset(struct mii_bus *bus) | |||
| 100 | return 0; | 100 | return 0; |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | static void __devinit add_phy(struct mii_bus *bus, struct device_node *np) | ||
| 104 | { | ||
| 105 | const u32 *data; | ||
| 106 | int len, id, irq; | ||
| 107 | |||
| 108 | data = of_get_property(np, "reg", &len); | ||
| 109 | if (!data || len != 4) | ||
| 110 | return; | ||
| 111 | |||
| 112 | id = *data; | ||
| 113 | bus->phy_mask &= ~(1 << id); | ||
| 114 | |||
| 115 | irq = of_irq_to_resource(np, 0, NULL); | ||
| 116 | if (irq != NO_IRQ) | ||
| 117 | bus->irq[id] = irq; | ||
| 118 | } | ||
| 119 | |||
| 120 | static int __devinit fs_enet_mdio_probe(struct of_device *ofdev, | 103 | static int __devinit fs_enet_mdio_probe(struct of_device *ofdev, |
| 121 | const struct of_device_id *match) | 104 | const struct of_device_id *match) |
| 122 | { | 105 | { |
| @@ -163,17 +146,10 @@ static int __devinit fs_enet_mdio_probe(struct of_device *ofdev, | |||
| 163 | if (!new_bus->irq) | 146 | if (!new_bus->irq) |
| 164 | goto out_unmap_regs; | 147 | goto out_unmap_regs; |
| 165 | 148 | ||
| 166 | for (i = 0; i < PHY_MAX_ADDR; i++) | ||
| 167 | new_bus->irq[i] = -1; | ||
| 168 | |||
| 169 | while ((np = of_get_next_child(ofdev->node, np))) | ||
| 170 | if (!strcmp(np->type, "ethernet-phy")) | ||
| 171 | add_phy(new_bus, np); | ||
| 172 | |||
| 173 | new_bus->parent = &ofdev->dev; | 149 | new_bus->parent = &ofdev->dev; |
| 174 | dev_set_drvdata(&ofdev->dev, new_bus); | 150 | dev_set_drvdata(&ofdev->dev, new_bus); |
| 175 | 151 | ||
| 176 | ret = mdiobus_register(new_bus); | 152 | ret = of_mdiobus_register(new_bus, ofdev->node); |
| 177 | if (ret) | 153 | if (ret) |
| 178 | goto out_free_irqs; | 154 | goto out_free_irqs; |
| 179 | 155 | ||
