aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-08-27 03:07:53 -0400
committerDavid S. Miller <davem@davemloft.net>2008-08-29 05:14:43 -0400
commitaf736fede772d92096b52da9aa1b0cf5de62eceb (patch)
tree533fe17f41de7b3dc838539e1957e344a3a821e5 /drivers/net
parentdb1a8611c8733711b40bbce11c87336e3e374634 (diff)
sunlance: Convert to pure OF driver.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/sunlance.c87
1 files changed, 40 insertions, 47 deletions
diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c
index 65758881d7aa..292feb2154b4 100644
--- a/drivers/net/sunlance.c
+++ b/drivers/net/sunlance.c
@@ -92,6 +92,8 @@ static char lancestr[] = "LANCE";
92#include <linux/ethtool.h> 92#include <linux/ethtool.h>
93#include <linux/bitops.h> 93#include <linux/bitops.h>
94#include <linux/dma-mapping.h> 94#include <linux/dma-mapping.h>
95#include <linux/of.h>
96#include <linux/of_device.h>
95 97
96#include <asm/system.h> 98#include <asm/system.h>
97#include <asm/io.h> 99#include <asm/io.h>
@@ -99,7 +101,6 @@ static char lancestr[] = "LANCE";
99#include <asm/pgtable.h> 101#include <asm/pgtable.h>
100#include <asm/byteorder.h> /* Used by the checksum routines */ 102#include <asm/byteorder.h> /* Used by the checksum routines */
101#include <asm/idprom.h> 103#include <asm/idprom.h>
102#include <asm/sbus.h>
103#include <asm/prom.h> 104#include <asm/prom.h>
104#include <asm/auxio.h> /* For tpe-link-test? setting */ 105#include <asm/auxio.h> /* For tpe-link-test? setting */
105#include <asm/irq.h> 106#include <asm/irq.h>
@@ -264,7 +265,8 @@ struct lance_private {
264 char *name; 265 char *name;
265 dma_addr_t init_block_dvma; 266 dma_addr_t init_block_dvma;
266 struct net_device *dev; /* Backpointer */ 267 struct net_device *dev; /* Backpointer */
267 struct sbus_dev *sdev; 268 struct of_device *op;
269 struct of_device *lebuffer;
268 struct timer_list multicast_timer; 270 struct timer_list multicast_timer;
269}; 271};
270 272
@@ -1273,7 +1275,7 @@ static void lance_set_multicast_retry(unsigned long _opaque)
1273static void lance_free_hwresources(struct lance_private *lp) 1275static void lance_free_hwresources(struct lance_private *lp)
1274{ 1276{
1275 if (lp->lregs) 1277 if (lp->lregs)
1276 sbus_iounmap(lp->lregs, LANCE_REG_SIZE); 1278 of_iounmap(&lp->op->resource[0], lp->lregs, LANCE_REG_SIZE);
1277 if (lp->dregs) { 1279 if (lp->dregs) {
1278 struct of_device *ledma = lp->ledma; 1280 struct of_device *ledma = lp->ledma;
1279 1281
@@ -1281,10 +1283,10 @@ static void lance_free_hwresources(struct lance_private *lp)
1281 resource_size(&ledma->resource[0])); 1283 resource_size(&ledma->resource[0]));
1282 } 1284 }
1283 if (lp->init_block_iomem) { 1285 if (lp->init_block_iomem) {
1284 sbus_iounmap(lp->init_block_iomem, 1286 of_iounmap(&lp->lebuffer->resource[0], lp->init_block_iomem,
1285 sizeof(struct lance_init_block)); 1287 sizeof(struct lance_init_block));
1286 } else if (lp->init_block_mem) { 1288 } else if (lp->init_block_mem) {
1287 dma_free_coherent(&lp->sdev->ofdev.dev, 1289 dma_free_coherent(&lp->op->dev,
1288 sizeof(struct lance_init_block), 1290 sizeof(struct lance_init_block),
1289 lp->init_block_mem, 1291 lp->init_block_mem,
1290 lp->init_block_dvma); 1292 lp->init_block_dvma);
@@ -1294,12 +1296,8 @@ static void lance_free_hwresources(struct lance_private *lp)
1294/* Ethtool support... */ 1296/* Ethtool support... */
1295static void sparc_lance_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 1297static void sparc_lance_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1296{ 1298{
1297 struct lance_private *lp = netdev_priv(dev);
1298
1299 strcpy(info->driver, "sunlance"); 1299 strcpy(info->driver, "sunlance");
1300 strcpy(info->version, "2.02"); 1300 strcpy(info->version, "2.02");
1301 sprintf(info->bus_info, "SBUS:%d",
1302 lp->sdev->slot);
1303} 1301}
1304 1302
1305static u32 sparc_lance_get_link(struct net_device *dev) 1303static u32 sparc_lance_get_link(struct net_device *dev)
@@ -1315,16 +1313,16 @@ static const struct ethtool_ops sparc_lance_ethtool_ops = {
1315 .get_link = sparc_lance_get_link, 1313 .get_link = sparc_lance_get_link,
1316}; 1314};
1317 1315
1318static int __devinit sparc_lance_probe_one(struct sbus_dev *sdev, 1316static int __devinit sparc_lance_probe_one(struct of_device *op,
1319 struct of_device *ledma, 1317 struct of_device *ledma,
1320 struct sbus_dev *lebuffer) 1318 struct of_device *lebuffer)
1321{ 1319{
1320 struct device_node *dp = op->node;
1322 static unsigned version_printed; 1321 static unsigned version_printed;
1323 struct device_node *dp = sdev->ofdev.node;
1324 struct net_device *dev;
1325 struct lance_private *lp; 1322 struct lance_private *lp;
1326 int i; 1323 struct net_device *dev;
1327 DECLARE_MAC_BUF(mac); 1324 DECLARE_MAC_BUF(mac);
1325 int i;
1328 1326
1329 dev = alloc_etherdev(sizeof(struct lance_private) + 8); 1327 dev = alloc_etherdev(sizeof(struct lance_private) + 8);
1330 if (!dev) 1328 if (!dev)
@@ -1345,8 +1343,8 @@ static int __devinit sparc_lance_probe_one(struct sbus_dev *sdev,
1345 dev->dev_addr[i] = idprom->id_ethaddr[i]; 1343 dev->dev_addr[i] = idprom->id_ethaddr[i];
1346 1344
1347 /* Get the IO region */ 1345 /* Get the IO region */
1348 lp->lregs = sbus_ioremap(&sdev->resource[0], 0, 1346 lp->lregs = of_ioremap(&op->resource[0], 0,
1349 LANCE_REG_SIZE, lancestr); 1347 LANCE_REG_SIZE, lancestr);
1350 if (!lp->lregs) { 1348 if (!lp->lregs) {
1351 printk(KERN_ERR "SunLance: Cannot map registers.\n"); 1349 printk(KERN_ERR "SunLance: Cannot map registers.\n");
1352 goto fail; 1350 goto fail;
@@ -1364,7 +1362,8 @@ static int __devinit sparc_lance_probe_one(struct sbus_dev *sdev,
1364 } 1362 }
1365 } 1363 }
1366 1364
1367 lp->sdev = sdev; 1365 lp->op = op;
1366 lp->lebuffer = lebuffer;
1368 if (lebuffer) { 1367 if (lebuffer) {
1369 /* sanity check */ 1368 /* sanity check */
1370 if (lebuffer->resource[0].start & 7) { 1369 if (lebuffer->resource[0].start & 7) {
@@ -1372,8 +1371,8 @@ static int __devinit sparc_lance_probe_one(struct sbus_dev *sdev,
1372 goto fail; 1371 goto fail;
1373 } 1372 }
1374 lp->init_block_iomem = 1373 lp->init_block_iomem =
1375 sbus_ioremap(&lebuffer->resource[0], 0, 1374 of_ioremap(&lebuffer->resource[0], 0,
1376 sizeof(struct lance_init_block), "lebuffer"); 1375 sizeof(struct lance_init_block), "lebuffer");
1377 if (!lp->init_block_iomem) { 1376 if (!lp->init_block_iomem) {
1378 printk(KERN_ERR "SunLance: Cannot map PIO buffer.\n"); 1377 printk(KERN_ERR "SunLance: Cannot map PIO buffer.\n");
1379 goto fail; 1378 goto fail;
@@ -1385,10 +1384,10 @@ static int __devinit sparc_lance_probe_one(struct sbus_dev *sdev,
1385 lp->tx = lance_tx_pio; 1384 lp->tx = lance_tx_pio;
1386 } else { 1385 } else {
1387 lp->init_block_mem = 1386 lp->init_block_mem =
1388 dma_alloc_coherent(&sdev->ofdev.dev, 1387 dma_alloc_coherent(&op->dev,
1389 sizeof(struct lance_init_block), 1388 sizeof(struct lance_init_block),
1390 &lp->init_block_dvma, GFP_ATOMIC); 1389 &lp->init_block_dvma, GFP_ATOMIC);
1391 if (!lp->init_block_mem || lp->init_block_dvma == 0) { 1390 if (!lp->init_block_mem) {
1392 printk(KERN_ERR "SunLance: Cannot allocate consistent DMA memory.\n"); 1391 printk(KERN_ERR "SunLance: Cannot allocate consistent DMA memory.\n");
1393 goto fail; 1392 goto fail;
1394 } 1393 }
@@ -1407,8 +1406,9 @@ static int __devinit sparc_lance_probe_one(struct sbus_dev *sdev,
1407 lp->burst_sizes = 0; 1406 lp->burst_sizes = 0;
1408 if (lp->ledma) { 1407 if (lp->ledma) {
1409 struct device_node *ledma_dp = ledma->node; 1408 struct device_node *ledma_dp = ledma->node;
1410 const char *prop; 1409 struct device_node *sbus_dp;
1411 unsigned int sbmask; 1410 unsigned int sbmask;
1411 const char *prop;
1412 u32 csr; 1412 u32 csr;
1413 1413
1414 /* Find burst-size property for ledma */ 1414 /* Find burst-size property for ledma */
@@ -1416,7 +1416,8 @@ static int __devinit sparc_lance_probe_one(struct sbus_dev *sdev,
1416 "burst-sizes", 0); 1416 "burst-sizes", 0);
1417 1417
1418 /* ledma may be capable of fast bursts, but sbus may not. */ 1418 /* ledma may be capable of fast bursts, but sbus may not. */
1419 sbmask = of_getintprop_default(ledma_dp, "burst-sizes", 1419 sbus_dp = ledma_dp->parent;
1420 sbmask = of_getintprop_default(sbus_dp, "burst-sizes",
1420 DMA_BURSTBITS); 1421 DMA_BURSTBITS);
1421 lp->burst_sizes &= sbmask; 1422 lp->burst_sizes &= sbmask;
1422 1423
@@ -1463,7 +1464,7 @@ no_link_test:
1463 lp->dregs = NULL; 1464 lp->dregs = NULL;
1464 1465
1465 lp->dev = dev; 1466 lp->dev = dev;
1466 SET_NETDEV_DEV(dev, &sdev->ofdev.dev); 1467 SET_NETDEV_DEV(dev, &op->dev);
1467 dev->open = &lance_open; 1468 dev->open = &lance_open;
1468 dev->stop = &lance_close; 1469 dev->stop = &lance_close;
1469 dev->hard_start_xmit = &lance_start_xmit; 1470 dev->hard_start_xmit = &lance_start_xmit;
@@ -1472,9 +1473,7 @@ no_link_test:
1472 dev->set_multicast_list = &lance_set_multicast; 1473 dev->set_multicast_list = &lance_set_multicast;
1473 dev->ethtool_ops = &sparc_lance_ethtool_ops; 1474 dev->ethtool_ops = &sparc_lance_ethtool_ops;
1474 1475
1475 dev->irq = sdev->irqs[0]; 1476 dev->irq = op->irqs[0];
1476
1477 dev->dma = 0;
1478 1477
1479 /* We cannot sleep if the chip is busy during a 1478 /* We cannot sleep if the chip is busy during a
1480 * multicast list update event, because such events 1479 * multicast list update event, because such events
@@ -1490,7 +1489,7 @@ no_link_test:
1490 goto fail; 1489 goto fail;
1491 } 1490 }
1492 1491
1493 dev_set_drvdata(&sdev->ofdev.dev, lp); 1492 dev_set_drvdata(&op->dev, lp);
1494 1493
1495 printk(KERN_INFO "%s: LANCE %s\n", 1494 printk(KERN_INFO "%s: LANCE %s\n",
1496 dev->name, print_mac(mac, dev->dev_addr)); 1495 dev->name, print_mac(mac, dev->dev_addr));
@@ -1540,31 +1539,25 @@ static int __exit sunlance_sun4_remove(void)
1540 1539
1541#else /* !CONFIG_SUN4 */ 1540#else /* !CONFIG_SUN4 */
1542 1541
1543static int __devinit sunlance_sbus_probe(struct of_device *dev, const struct of_device_id *match) 1542static int __devinit sunlance_sbus_probe(struct of_device *op, const struct of_device_id *match)
1544{ 1543{
1545 struct sbus_dev *sdev = to_sbus_device(&dev->dev); 1544 struct of_device *parent = to_of_device(op->dev.parent);
1545 struct device_node *parent_dp = parent->node;
1546 int err; 1546 int err;
1547 1547
1548 if (sdev->parent) { 1548 if (!strcmp(parent_dp->name, "ledma")) {
1549 struct device_node *parent_node = sdev->parent->ofdev.node; 1549 err = sparc_lance_probe_one(op, parent, NULL);
1550 struct of_device *parent; 1550 } else if (!strcmp(parent_dp->name, "lebuffer")) {
1551 1551 err = sparc_lance_probe_one(op, NULL, parent);
1552 parent = of_find_device_by_node(parent_node);
1553 if (parent && !strcmp(parent->node->name, "ledma")) {
1554 err = sparc_lance_probe_one(sdev, parent, NULL);
1555 } else if (parent && !strcmp(parent->node->name, "lebuffer")) {
1556 err = sparc_lance_probe_one(sdev, NULL, to_sbus_device(&parent->dev));
1557 } else
1558 err = sparc_lance_probe_one(sdev, NULL, NULL);
1559 } else 1552 } else
1560 err = sparc_lance_probe_one(sdev, NULL, NULL); 1553 err = sparc_lance_probe_one(op, NULL, NULL);
1561 1554
1562 return err; 1555 return err;
1563} 1556}
1564 1557
1565static int __devexit sunlance_sbus_remove(struct of_device *dev) 1558static int __devexit sunlance_sbus_remove(struct of_device *op)
1566{ 1559{
1567 struct lance_private *lp = dev_get_drvdata(&dev->dev); 1560 struct lance_private *lp = dev_get_drvdata(&op->dev);
1568 struct net_device *net_dev = lp->dev; 1561 struct net_device *net_dev = lp->dev;
1569 1562
1570 unregister_netdev(net_dev); 1563 unregister_netdev(net_dev);
@@ -1573,7 +1566,7 @@ static int __devexit sunlance_sbus_remove(struct of_device *dev)
1573 1566
1574 free_netdev(net_dev); 1567 free_netdev(net_dev);
1575 1568
1576 dev_set_drvdata(&dev->dev, NULL); 1569 dev_set_drvdata(&op->dev, NULL);
1577 1570
1578 return 0; 1571 return 0;
1579} 1572}
@@ -1598,7 +1591,7 @@ static struct of_platform_driver sunlance_sbus_driver = {
1598/* Find all the lance cards on the system and initialize them */ 1591/* Find all the lance cards on the system and initialize them */
1599static int __init sparc_lance_init(void) 1592static int __init sparc_lance_init(void)
1600{ 1593{
1601 return of_register_driver(&sunlance_sbus_driver, &sbus_bus_type); 1594 return of_register_driver(&sunlance_sbus_driver, &of_bus_type);
1602} 1595}
1603#endif /* !CONFIG_SUN4 */ 1596#endif /* !CONFIG_SUN4 */
1604 1597