aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/fs_enet/mii-bitbang.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/fs_enet/mii-bitbang.c')
-rw-r--r--drivers/net/fs_enet/mii-bitbang.c29
1 files changed, 2 insertions, 27 deletions
diff --git a/drivers/net/fs_enet/mii-bitbang.c b/drivers/net/fs_enet/mii-bitbang.c
index 49b6645d7e0c..93b481b0e3c7 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
152static 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
169static int __devinit fs_enet_mdio_probe(struct of_device *ofdev, 153static 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