aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2006-06-23 21:48:04 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-06-24 02:16:02 -0400
commit52a34c7fe43afcbcd0e1ecfdef6b3dfdb9a90180 (patch)
tree8977d6e367aa344e1d7a1ce008265af3a6848370 /drivers
parentc2d81e63ced3e81b8b71087b9af44da26171ba36 (diff)
[NET] sunbmac: Convert over to new SBUS device framework.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/sunbmac.c127
-rw-r--r--drivers/net/sunbmac.h1
2 files changed, 61 insertions, 67 deletions
diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
index cfaf47c63c58..7127f0f36f0e 100644
--- a/drivers/net/sunbmac.c
+++ b/drivers/net/sunbmac.c
@@ -72,8 +72,6 @@ MODULE_LICENSE("GPL");
72#define DIRQ(x) 72#define DIRQ(x)
73#endif 73#endif
74 74
75static struct bigmac *root_bigmac_dev;
76
77#define DEFAULT_JAMSIZE 4 /* Toe jam */ 75#define DEFAULT_JAMSIZE 4 /* Toe jam */
78 76
79#define QEC_RESET_TRIES 200 77#define QEC_RESET_TRIES 200
@@ -491,7 +489,7 @@ static void bigmac_tcvr_init(struct bigmac *bp)
491 } 489 }
492} 490}
493 491
494static int bigmac_init(struct bigmac *, int); 492static int bigmac_init_hw(struct bigmac *, int);
495 493
496static int try_next_permutation(struct bigmac *bp, void __iomem *tregs) 494static int try_next_permutation(struct bigmac *bp, void __iomem *tregs)
497{ 495{
@@ -551,7 +549,7 @@ static void bigmac_timer(unsigned long data)
551 if (ret == -1) { 549 if (ret == -1) {
552 printk(KERN_ERR "%s: Link down, cable problem?\n", 550 printk(KERN_ERR "%s: Link down, cable problem?\n",
553 bp->dev->name); 551 bp->dev->name);
554 ret = bigmac_init(bp, 0); 552 ret = bigmac_init_hw(bp, 0);
555 if (ret) { 553 if (ret) {
556 printk(KERN_ERR "%s: Error, cannot re-init the " 554 printk(KERN_ERR "%s: Error, cannot re-init the "
557 "BigMAC.\n", bp->dev->name); 555 "BigMAC.\n", bp->dev->name);
@@ -621,7 +619,7 @@ static void bigmac_begin_auto_negotiation(struct bigmac *bp)
621 add_timer(&bp->bigmac_timer); 619 add_timer(&bp->bigmac_timer);
622} 620}
623 621
624static int bigmac_init(struct bigmac *bp, int from_irq) 622static int bigmac_init_hw(struct bigmac *bp, int from_irq)
625{ 623{
626 void __iomem *gregs = bp->gregs; 624 void __iomem *gregs = bp->gregs;
627 void __iomem *cregs = bp->creg; 625 void __iomem *cregs = bp->creg;
@@ -752,7 +750,7 @@ static void bigmac_is_medium_rare(struct bigmac *bp, u32 qec_status, u32 bmac_st
752 } 750 }
753 751
754 printk(" RESET\n"); 752 printk(" RESET\n");
755 bigmac_init(bp, 1); 753 bigmac_init_hw(bp, 1);
756} 754}
757 755
758/* BigMAC transmit complete service routines. */ 756/* BigMAC transmit complete service routines. */
@@ -926,7 +924,7 @@ static int bigmac_open(struct net_device *dev)
926 return ret; 924 return ret;
927 } 925 }
928 init_timer(&bp->bigmac_timer); 926 init_timer(&bp->bigmac_timer);
929 ret = bigmac_init(bp, 0); 927 ret = bigmac_init_hw(bp, 0);
930 if (ret) 928 if (ret)
931 free_irq(dev->irq, bp); 929 free_irq(dev->irq, bp);
932 return ret; 930 return ret;
@@ -950,7 +948,7 @@ static void bigmac_tx_timeout(struct net_device *dev)
950{ 948{
951 struct bigmac *bp = (struct bigmac *) dev->priv; 949 struct bigmac *bp = (struct bigmac *) dev->priv;
952 950
953 bigmac_init(bp, 0); 951 bigmac_init_hw(bp, 0);
954 netif_wake_queue(dev); 952 netif_wake_queue(dev);
955} 953}
956 954
@@ -1104,6 +1102,8 @@ static int __init bigmac_ether_init(struct sbus_dev *qec_sdev)
1104 bp->qec_sdev = qec_sdev; 1102 bp->qec_sdev = qec_sdev;
1105 bp->bigmac_sdev = qec_sdev->child; 1103 bp->bigmac_sdev = qec_sdev->child;
1106 1104
1105 SET_NETDEV_DEV(dev, &bp->bigmac_sdev->ofdev.dev);
1106
1107 spin_lock_init(&bp->lock); 1107 spin_lock_init(&bp->lock);
1108 1108
1109 /* Verify the registers we expect, are actually there. */ 1109 /* Verify the registers we expect, are actually there. */
@@ -1226,11 +1226,7 @@ static int __init bigmac_ether_init(struct sbus_dev *qec_sdev)
1226 goto fail_and_cleanup; 1226 goto fail_and_cleanup;
1227 } 1227 }
1228 1228
1229 /* Put us into the list of instances attached for later driver 1229 dev_set_drvdata(&bp->bigmac_sdev->ofdev.dev, bp);
1230 * exit.
1231 */
1232 bp->next_module = root_bigmac_dev;
1233 root_bigmac_dev = bp;
1234 1230
1235 printk(KERN_INFO "%s: BigMAC 100baseT Ethernet ", dev->name); 1231 printk(KERN_INFO "%s: BigMAC 100baseT Ethernet ", dev->name);
1236 for (i = 0; i < 6; i++) 1232 for (i = 0; i < 6; i++)
@@ -1266,69 +1262,68 @@ fail_and_cleanup:
1266/* QEC can be the parent of either QuadEthernet or 1262/* QEC can be the parent of either QuadEthernet or
1267 * a BigMAC. We want the latter. 1263 * a BigMAC. We want the latter.
1268 */ 1264 */
1269static int __init bigmac_match(struct sbus_dev *sdev) 1265static int __devinit bigmac_sbus_probe(struct of_device *dev, const struct of_device_id *match)
1270{ 1266{
1271 struct sbus_dev *child = sdev->child; 1267 struct sbus_dev *sdev = to_sbus_device(&dev->dev);
1268 struct device_node *dp = dev->node;
1272 1269
1273 if (strcmp(sdev->prom_name, "qec") != 0) 1270 if (!strcmp(dp->name, "be"))
1274 return 0; 1271 sdev = sdev->parent;
1275 1272
1276 if (child == NULL) 1273 return bigmac_ether_init(sdev);
1277 return 0;
1278
1279 if (strcmp(child->prom_name, "be") != 0)
1280 return 0;
1281
1282 return 1;
1283} 1274}
1284 1275
1285static int __init bigmac_probe(void) 1276static int __devexit bigmac_sbus_remove(struct of_device *dev)
1286{ 1277{
1287 struct sbus_bus *sbus; 1278 struct bigmac *bp = dev_get_drvdata(&dev->dev);
1288 struct sbus_dev *sdev = NULL; 1279 struct net_device *net_dev = bp->dev;
1289 static int called; 1280
1290 int cards = 0, v; 1281 unregister_netdevice(net_dev);
1291 1282
1292 root_bigmac_dev = NULL; 1283 sbus_iounmap(bp->gregs, GLOB_REG_SIZE);
1293 1284 sbus_iounmap(bp->creg, CREG_REG_SIZE);
1294 if (called) 1285 sbus_iounmap(bp->bregs, BMAC_REG_SIZE);
1295 return -ENODEV; 1286 sbus_iounmap(bp->tregs, TCVR_REG_SIZE);
1296 called++; 1287 sbus_free_consistent(bp->bigmac_sdev,
1297 1288 PAGE_SIZE,
1298 for_each_sbus(sbus) { 1289 bp->bmac_block,
1299 for_each_sbusdev(sdev, sbus) { 1290 bp->bblock_dvma);
1300 if (bigmac_match(sdev)) { 1291
1301 cards++; 1292 free_netdev(net_dev);
1302 if ((v = bigmac_ether_init(sdev))) 1293
1303 return v; 1294 dev_set_drvdata(&dev->dev, NULL);
1304 } 1295
1305 }
1306 }
1307 if (!cards)
1308 return -ENODEV;
1309 return 0; 1296 return 0;
1310} 1297}
1311 1298
1312static void __exit bigmac_cleanup(void) 1299static struct of_device_id bigmac_sbus_match[] = {
1313{ 1300 {
1314 while (root_bigmac_dev) { 1301 .name = "qec",
1315 struct bigmac *bp = root_bigmac_dev; 1302 },
1316 struct bigmac *bp_nxt = root_bigmac_dev->next_module; 1303 {
1304 .name = "be",
1305 },
1306 {},
1307};
1317 1308
1318 sbus_iounmap(bp->gregs, GLOB_REG_SIZE); 1309MODULE_DEVICE_TABLE(of, bigmac_sbus_match);
1319 sbus_iounmap(bp->creg, CREG_REG_SIZE);
1320 sbus_iounmap(bp->bregs, BMAC_REG_SIZE);
1321 sbus_iounmap(bp->tregs, TCVR_REG_SIZE);
1322 sbus_free_consistent(bp->bigmac_sdev,
1323 PAGE_SIZE,
1324 bp->bmac_block,
1325 bp->bblock_dvma);
1326 1310
1327 unregister_netdev(bp->dev); 1311static struct of_platform_driver bigmac_sbus_driver = {
1328 free_netdev(bp->dev); 1312 .name = "sunbmac",
1329 root_bigmac_dev = bp_nxt; 1313 .match_table = bigmac_sbus_match,
1330 } 1314 .probe = bigmac_sbus_probe,
1315 .remove = __devexit_p(bigmac_sbus_remove),
1316};
1317
1318static int __init bigmac_init(void)
1319{
1320 return of_register_driver(&bigmac_sbus_driver, &sbus_bus_type);
1321}
1322
1323static void __exit bigmac_exit(void)
1324{
1325 of_unregister_driver(&bigmac_sbus_driver);
1331} 1326}
1332 1327
1333module_init(bigmac_probe); 1328module_init(bigmac_init);
1334module_exit(bigmac_cleanup); 1329module_exit(bigmac_exit);
diff --git a/drivers/net/sunbmac.h b/drivers/net/sunbmac.h
index b0dbc5187143..b563d3c2993e 100644
--- a/drivers/net/sunbmac.h
+++ b/drivers/net/sunbmac.h
@@ -332,7 +332,6 @@ struct bigmac {
332 struct sbus_dev *qec_sdev; 332 struct sbus_dev *qec_sdev;
333 struct sbus_dev *bigmac_sdev; 333 struct sbus_dev *bigmac_sdev;
334 struct net_device *dev; 334 struct net_device *dev;
335 struct bigmac *next_module;
336}; 335};
337 336
338/* We use this to acquire receive skb's that we can DMA directly into. */ 337/* We use this to acquire receive skb's that we can DMA directly into. */