aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/fs_enet/mii-fec.c
diff options
context:
space:
mode:
authorKumar Gala <galak@kernel.crashing.org>2008-06-12 09:32:13 -0400
committerKumar Gala <galak@kernel.crashing.org>2008-07-16 18:57:49 -0400
commitb219108cbacee5f2eaeca63cba013688eeba3bd4 (patch)
tree656039a1d7a4db0605562c5290056a21d98865be /drivers/net/fs_enet/mii-fec.c
parent00262986ceeb5c3358b70491aa898906503a0fe7 (diff)
fs_enet: Remove !CONFIG_PPC_CPM_NEW_BINDING code
Now that arch/ppc is gone we always define CONFIG_PPC_CPM_NEW_BINDING so we can remove all the code associated with !CONFIG_PPC_CPM_NEW_BINDING. Also fixed some asm/of_platform.h to linux/of_platform.h (and of_device.h) Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'drivers/net/fs_enet/mii-fec.c')
-rw-r--r--drivers/net/fs_enet/mii-fec.c144
1 files changed, 1 insertions, 143 deletions
diff --git a/drivers/net/fs_enet/mii-fec.c b/drivers/net/fs_enet/mii-fec.c
index 8f6a43b0e0ff..695f74cc4398 100644
--- a/drivers/net/fs_enet/mii-fec.c
+++ b/drivers/net/fs_enet/mii-fec.c
@@ -31,15 +31,12 @@
31#include <linux/ethtool.h> 31#include <linux/ethtool.h>
32#include <linux/bitops.h> 32#include <linux/bitops.h>
33#include <linux/platform_device.h> 33#include <linux/platform_device.h>
34#include <linux/of_platform.h>
34 35
35#include <asm/pgtable.h> 36#include <asm/pgtable.h>
36#include <asm/irq.h> 37#include <asm/irq.h>
37#include <asm/uaccess.h> 38#include <asm/uaccess.h>
38 39
39#ifdef CONFIG_PPC_CPM_NEW_BINDING
40#include <linux/of_platform.h>
41#endif
42
43#include "fs_enet.h" 40#include "fs_enet.h"
44#include "fec.h" 41#include "fec.h"
45 42
@@ -51,52 +48,6 @@
51 48
52#define FEC_MII_LOOPS 10000 49#define FEC_MII_LOOPS 10000
53 50
54#ifndef CONFIG_PPC_CPM_NEW_BINDING
55static int match_has_phy (struct device *dev, void* data)
56{
57 struct platform_device* pdev = container_of(dev, struct platform_device, dev);
58 struct fs_platform_info* fpi;
59 if(strcmp(pdev->name, (char*)data))
60 {
61 return 0;
62 }
63
64 fpi = pdev->dev.platform_data;
65 if((fpi)&&(fpi->has_phy))
66 return 1;
67 return 0;
68}
69
70static int fs_mii_fec_init(struct fec_info* fec, struct fs_mii_fec_platform_info *fmpi)
71{
72 struct resource *r;
73 fec_t __iomem *fecp;
74 char* name = "fsl-cpm-fec";
75
76 /* we need fec in order to be useful */
77 struct platform_device *fec_pdev =
78 container_of(bus_find_device(&platform_bus_type, NULL, name, match_has_phy),
79 struct platform_device, dev);
80
81 if(fec_pdev == NULL) {
82 printk(KERN_ERR"Unable to find PHY for %s", name);
83 return -ENODEV;
84 }
85
86 r = platform_get_resource_byname(fec_pdev, IORESOURCE_MEM, "regs");
87
88 fec->fecp = fecp = ioremap(r->start,sizeof(fec_t));
89 fec->mii_speed = fmpi->mii_speed;
90
91 setbits32(&fecp->fec_r_cntrl, FEC_RCNTRL_MII_MODE); /* MII enable */
92 setbits32(&fecp->fec_ecntrl, FEC_ECNTRL_PINMUX | FEC_ECNTRL_ETHER_EN);
93 out_be32(&fecp->fec_ievent, FEC_ENET_MII);
94 out_be32(&fecp->fec_mii_speed, fec->mii_speed);
95
96 return 0;
97}
98#endif
99
100static int fs_enet_fec_mii_read(struct mii_bus *bus , int phy_id, int location) 51static int fs_enet_fec_mii_read(struct mii_bus *bus , int phy_id, int location)
101{ 52{
102 struct fec_info* fec = bus->priv; 53 struct fec_info* fec = bus->priv;
@@ -151,7 +102,6 @@ static int fs_enet_fec_mii_reset(struct mii_bus *bus)
151 return 0; 102 return 0;
152} 103}
153 104
154#ifdef CONFIG_PPC_CPM_NEW_BINDING
155static void __devinit add_phy(struct mii_bus *bus, struct device_node *np) 105static void __devinit add_phy(struct mii_bus *bus, struct device_node *np)
156{ 106{
157 const u32 *data; 107 const u32 *data;
@@ -286,95 +236,3 @@ static void fs_enet_mdio_fec_exit(void)
286 236
287module_init(fs_enet_mdio_fec_init); 237module_init(fs_enet_mdio_fec_init);
288module_exit(fs_enet_mdio_fec_exit); 238module_exit(fs_enet_mdio_fec_exit);
289#else
290static int __devinit fs_enet_fec_mdio_probe(struct device *dev)
291{
292 struct platform_device *pdev = to_platform_device(dev);
293 struct fs_mii_fec_platform_info *pdata;
294 struct mii_bus *new_bus;
295 struct fec_info *fec;
296 int err = 0;
297 if (NULL == dev)
298 return -EINVAL;
299 new_bus = kzalloc(sizeof(struct mii_bus), GFP_KERNEL);
300
301 if (NULL == new_bus)
302 return -ENOMEM;
303
304 fec = kzalloc(sizeof(struct fec_info), GFP_KERNEL);
305
306 if (NULL == fec)
307 return -ENOMEM;
308
309 new_bus->name = "FEC MII Bus",
310 new_bus->read = &fs_enet_fec_mii_read,
311 new_bus->write = &fs_enet_fec_mii_write,
312 new_bus->reset = &fs_enet_fec_mii_reset,
313 snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id);
314
315 pdata = (struct fs_mii_fec_platform_info *)pdev->dev.platform_data;
316
317 if (NULL == pdata) {
318 printk(KERN_ERR "fs_enet FEC mdio %d: Missing platform data!\n", pdev->id);
319 return -ENODEV;
320 }
321
322 /*set up workspace*/
323
324 fs_mii_fec_init(fec, pdata);
325 new_bus->priv = fec;
326
327 new_bus->irq = pdata->irq;
328
329 new_bus->dev = dev;
330 dev_set_drvdata(dev, new_bus);
331
332 err = mdiobus_register(new_bus);
333
334 if (0 != err) {
335 printk (KERN_ERR "%s: Cannot register as MDIO bus\n",
336 new_bus->name);
337 goto bus_register_fail;
338 }
339
340 return 0;
341
342bus_register_fail:
343 kfree(new_bus);
344
345 return err;
346}
347
348
349static int fs_enet_fec_mdio_remove(struct device *dev)
350{
351 struct mii_bus *bus = dev_get_drvdata(dev);
352
353 mdiobus_unregister(bus);
354
355 dev_set_drvdata(dev, NULL);
356 kfree(bus->priv);
357
358 bus->priv = NULL;
359 kfree(bus);
360
361 return 0;
362}
363
364static struct device_driver fs_enet_fec_mdio_driver = {
365 .name = "fsl-cpm-fec-mdio",
366 .bus = &platform_bus_type,
367 .probe = fs_enet_fec_mdio_probe,
368 .remove = fs_enet_fec_mdio_remove,
369};
370
371int fs_enet_mdio_fec_init(void)
372{
373 return driver_register(&fs_enet_fec_mdio_driver);
374}
375
376void fs_enet_mdio_fec_exit(void)
377{
378 driver_unregister(&fs_enet_fec_mdio_driver);
379}
380#endif