aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bmac.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/bmac.c')
-rw-r--r--drivers/net/bmac.c68
1 files changed, 35 insertions, 33 deletions
diff --git a/drivers/net/bmac.c b/drivers/net/bmac.c
index bbca8ae8018..4adfe7b7703 100644
--- a/drivers/net/bmac.c
+++ b/drivers/net/bmac.c
@@ -7,7 +7,6 @@
7 * May 1999, Al Viro: proper release of /proc/net/bmac entry, switched to 7 * May 1999, Al Viro: proper release of /proc/net/bmac entry, switched to
8 * dynamic procfs inode. 8 * dynamic procfs inode.
9 */ 9 */
10#include <linux/config.h>
11#include <linux/module.h> 10#include <linux/module.h>
12#include <linux/kernel.h> 11#include <linux/kernel.h>
13#include <linux/netdevice.h> 12#include <linux/netdevice.h>
@@ -334,7 +333,7 @@ bmac_init_registers(struct net_device *dev)
334 udelay(10000); 333 udelay(10000);
335 } 334 }
336 335
337 bmwrite(dev, RSEED, (unsigned short)0x1968); 336 bmwrite(dev, RSEED, (unsigned short)0x1968);
338 337
339 regValue = bmread(dev, XIFC); 338 regValue = bmread(dev, XIFC);
340 regValue |= TxOutputEnable; 339 regValue |= TxOutputEnable;
@@ -374,7 +373,7 @@ bmac_init_registers(struct net_device *dev)
374 bmwrite(dev, BHASH2, bp->hash_table_mask[1]); /* bits 31 - 16 */ 373 bmwrite(dev, BHASH2, bp->hash_table_mask[1]); /* bits 31 - 16 */
375 bmwrite(dev, BHASH1, bp->hash_table_mask[2]); /* bits 47 - 32 */ 374 bmwrite(dev, BHASH1, bp->hash_table_mask[2]); /* bits 47 - 32 */
376 bmwrite(dev, BHASH0, bp->hash_table_mask[3]); /* bits 63 - 48 */ 375 bmwrite(dev, BHASH0, bp->hash_table_mask[3]); /* bits 63 - 48 */
377 376
378 pWord16 = (unsigned short *)dev->dev_addr; 377 pWord16 = (unsigned short *)dev->dev_addr;
379 bmwrite(dev, MADD0, *pWord16++); 378 bmwrite(dev, MADD0, *pWord16++);
380 bmwrite(dev, MADD1, *pWord16++); 379 bmwrite(dev, MADD1, *pWord16++);
@@ -412,11 +411,11 @@ bmac_start_chip(struct net_device *dev)
412 /* enable rx dma channel */ 411 /* enable rx dma channel */
413 dbdma_continue(rd); 412 dbdma_continue(rd);
414 413
415 oldConfig = bmread(dev, TXCFG); 414 oldConfig = bmread(dev, TXCFG);
416 bmwrite(dev, TXCFG, oldConfig | TxMACEnable ); 415 bmwrite(dev, TXCFG, oldConfig | TxMACEnable );
417 416
418 /* turn on rx plus any other bits already on (promiscuous possibly) */ 417 /* turn on rx plus any other bits already on (promiscuous possibly) */
419 oldConfig = bmread(dev, RXCFG); 418 oldConfig = bmread(dev, RXCFG);
420 bmwrite(dev, RXCFG, oldConfig | RxMACEnable ); 419 bmwrite(dev, RXCFG, oldConfig | RxMACEnable );
421 udelay(20000); 420 udelay(20000);
422} 421}
@@ -457,12 +456,12 @@ static void bmac_init_chip(struct net_device *dev)
457#ifdef CONFIG_PM 456#ifdef CONFIG_PM
458static int bmac_suspend(struct macio_dev *mdev, pm_message_t state) 457static int bmac_suspend(struct macio_dev *mdev, pm_message_t state)
459{ 458{
460 struct net_device* dev = macio_get_drvdata(mdev); 459 struct net_device* dev = macio_get_drvdata(mdev);
461 struct bmac_data *bp = netdev_priv(dev); 460 struct bmac_data *bp = netdev_priv(dev);
462 unsigned long flags; 461 unsigned long flags;
463 unsigned short config; 462 unsigned short config;
464 int i; 463 int i;
465 464
466 netif_device_detach(dev); 465 netif_device_detach(dev);
467 /* prolly should wait for dma to finish & turn off the chip */ 466 /* prolly should wait for dma to finish & turn off the chip */
468 spin_lock_irqsave(&bp->lock, flags); 467 spin_lock_irqsave(&bp->lock, flags);
@@ -478,7 +477,7 @@ static int bmac_suspend(struct macio_dev *mdev, pm_message_t state)
478 if (bp->opened) { 477 if (bp->opened) {
479 volatile struct dbdma_regs __iomem *rd = bp->rx_dma; 478 volatile struct dbdma_regs __iomem *rd = bp->rx_dma;
480 volatile struct dbdma_regs __iomem *td = bp->tx_dma; 479 volatile struct dbdma_regs __iomem *td = bp->tx_dma;
481 480
482 config = bmread(dev, RXCFG); 481 config = bmread(dev, RXCFG);
483 bmwrite(dev, RXCFG, (config & ~RxMACEnable)); 482 bmwrite(dev, RXCFG, (config & ~RxMACEnable));
484 config = bmread(dev, TXCFG); 483 config = bmread(dev, TXCFG);
@@ -507,7 +506,7 @@ static int bmac_suspend(struct macio_dev *mdev, pm_message_t state)
507 506
508static int bmac_resume(struct macio_dev *mdev) 507static int bmac_resume(struct macio_dev *mdev)
509{ 508{
510 struct net_device* dev = macio_get_drvdata(mdev); 509 struct net_device* dev = macio_get_drvdata(mdev);
511 struct bmac_data *bp = netdev_priv(dev); 510 struct bmac_data *bp = netdev_priv(dev);
512 511
513 /* see if this is enough */ 512 /* see if this is enough */
@@ -856,12 +855,12 @@ crc416(unsigned int curval, unsigned short nxtval)
856 else high_crc_set = 1; 855 else high_crc_set = 1;
857 856
858 cur = cur << 1; 857 cur = cur << 1;
859 858
860 if ((next & 0x0001) == 0) low_data_set = 0; 859 if ((next & 0x0001) == 0) low_data_set = 0;
861 else low_data_set = 1; 860 else low_data_set = 1;
862 861
863 next = next >> 1; 862 next = next >> 1;
864 863
865 /* do the XOR */ 864 /* do the XOR */
866 if (high_crc_set ^ low_data_set) cur = cur ^ ENET_CRCPOLY; 865 if (high_crc_set ^ low_data_set) cur = cur ^ ENET_CRCPOLY;
867 } 866 }
@@ -870,7 +869,7 @@ crc416(unsigned int curval, unsigned short nxtval)
870 869
871static unsigned int 870static unsigned int
872bmac_crc(unsigned short *address) 871bmac_crc(unsigned short *address)
873{ 872{
874 unsigned int newcrc; 873 unsigned int newcrc;
875 874
876 XXDEBUG(("bmac_crc: addr=%#04x, %#04x, %#04x\n", *address, address[1], address[2])); 875 XXDEBUG(("bmac_crc: addr=%#04x, %#04x, %#04x\n", *address, address[1], address[2]));
@@ -888,7 +887,7 @@ bmac_crc(unsigned short *address)
888 887
889static void 888static void
890bmac_addhash(struct bmac_data *bp, unsigned char *addr) 889bmac_addhash(struct bmac_data *bp, unsigned char *addr)
891{ 890{
892 unsigned int crc; 891 unsigned int crc;
893 unsigned short mask; 892 unsigned short mask;
894 893
@@ -903,7 +902,7 @@ bmac_addhash(struct bmac_data *bp, unsigned char *addr)
903 902
904static void 903static void
905bmac_removehash(struct bmac_data *bp, unsigned char *addr) 904bmac_removehash(struct bmac_data *bp, unsigned char *addr)
906{ 905{
907 unsigned int crc; 906 unsigned int crc;
908 unsigned char mask; 907 unsigned char mask;
909 908
@@ -1055,13 +1054,13 @@ static void bmac_set_multicast(struct net_device *dev)
1055 bmwrite(dev, RXCFG, rx_cfg); 1054 bmwrite(dev, RXCFG, rx_cfg);
1056 } else { 1055 } else {
1057 u16 hash_table[4]; 1056 u16 hash_table[4];
1058 1057
1059 rx_cfg = bmread(dev, RXCFG); 1058 rx_cfg = bmread(dev, RXCFG);
1060 rx_cfg &= ~RxPromiscEnable; 1059 rx_cfg &= ~RxPromiscEnable;
1061 bmwrite(dev, RXCFG, rx_cfg); 1060 bmwrite(dev, RXCFG, rx_cfg);
1062 1061
1063 for(i = 0; i < 4; i++) hash_table[i] = 0; 1062 for(i = 0; i < 4; i++) hash_table[i] = 0;
1064 1063
1065 for(i = 0; i < dev->mc_count; i++) { 1064 for(i = 0; i < dev->mc_count; i++) {
1066 addrs = dmi->dmi_addr; 1065 addrs = dmi->dmi_addr;
1067 dmi = dmi->next; 1066 dmi = dmi->next;
@@ -1221,7 +1220,7 @@ bmac_get_station_address(struct net_device *dev, unsigned char *ea)
1221 int i; 1220 int i;
1222 unsigned short data; 1221 unsigned short data;
1223 1222
1224 for (i = 0; i < 6; i++) 1223 for (i = 0; i < 6; i++)
1225 { 1224 {
1226 reset_and_select_srom(dev); 1225 reset_and_select_srom(dev);
1227 data = read_srom(dev, i + EnetAddressOffset/2, SROMAddressBits); 1226 data = read_srom(dev, i + EnetAddressOffset/2, SROMAddressBits);
@@ -1245,7 +1244,7 @@ static void bmac_reset_and_enable(struct net_device *dev)
1245 bmac_start_chip(dev); 1244 bmac_start_chip(dev);
1246 bmwrite(dev, INTDISABLE, EnableNormal); 1245 bmwrite(dev, INTDISABLE, EnableNormal);
1247 bp->sleeping = 0; 1246 bp->sleeping = 0;
1248 1247
1249 /* 1248 /*
1250 * It seems that the bmac can't receive until it's transmitted 1249 * It seems that the bmac can't receive until it's transmitted
1251 * a packet. So we give it a dummy packet to transmit. 1250 * a packet. So we give it a dummy packet to transmit.
@@ -1265,7 +1264,8 @@ static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_i
1265{ 1264{
1266 int j, rev, ret; 1265 int j, rev, ret;
1267 struct bmac_data *bp; 1266 struct bmac_data *bp;
1268 unsigned char *addr; 1267 const unsigned char *prop_addr;
1268 unsigned char addr[6];
1269 struct net_device *dev; 1269 struct net_device *dev;
1270 int is_bmac_plus = ((int)match->data) != 0; 1270 int is_bmac_plus = ((int)match->data) != 0;
1271 1271
@@ -1273,21 +1273,23 @@ static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_i
1273 printk(KERN_ERR "BMAC: can't use, need 3 addrs and 3 intrs\n"); 1273 printk(KERN_ERR "BMAC: can't use, need 3 addrs and 3 intrs\n");
1274 return -ENODEV; 1274 return -ENODEV;
1275 } 1275 }
1276 addr = get_property(macio_get_of_node(mdev), "mac-address", NULL); 1276 prop_addr = get_property(macio_get_of_node(mdev), "mac-address", NULL);
1277 if (addr == NULL) { 1277 if (prop_addr == NULL) {
1278 addr = get_property(macio_get_of_node(mdev), "local-mac-address", NULL); 1278 prop_addr = get_property(macio_get_of_node(mdev),
1279 if (addr == NULL) { 1279 "local-mac-address", NULL);
1280 if (prop_addr == NULL) {
1280 printk(KERN_ERR "BMAC: Can't get mac-address\n"); 1281 printk(KERN_ERR "BMAC: Can't get mac-address\n");
1281 return -ENODEV; 1282 return -ENODEV;
1282 } 1283 }
1283 } 1284 }
1285 memcpy(addr, prop_addr, sizeof(addr));
1284 1286
1285 dev = alloc_etherdev(PRIV_BYTES); 1287 dev = alloc_etherdev(PRIV_BYTES);
1286 if (!dev) { 1288 if (!dev) {
1287 printk(KERN_ERR "BMAC: alloc_etherdev failed, out of memory\n"); 1289 printk(KERN_ERR "BMAC: alloc_etherdev failed, out of memory\n");
1288 return -ENOMEM; 1290 return -ENOMEM;
1289 } 1291 }
1290 1292
1291 bp = netdev_priv(dev); 1293 bp = netdev_priv(dev);
1292 SET_MODULE_OWNER(dev); 1294 SET_MODULE_OWNER(dev);
1293 SET_NETDEV_DEV(dev, &mdev->ofdev.dev); 1295 SET_NETDEV_DEV(dev, &mdev->ofdev.dev);
@@ -1380,7 +1382,7 @@ static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_i
1380 printk("%c%.2x", (j? ':': ' '), dev->dev_addr[j]); 1382 printk("%c%.2x", (j? ':': ' '), dev->dev_addr[j]);
1381 XXDEBUG((", base_addr=%#0lx", dev->base_addr)); 1383 XXDEBUG((", base_addr=%#0lx", dev->base_addr));
1382 printk("\n"); 1384 printk("\n");
1383 1385
1384 return 0; 1386 return 0;
1385 1387
1386err_out_irq2: 1388err_out_irq2:
@@ -1472,7 +1474,7 @@ bmac_start(struct net_device *dev)
1472 1474
1473 if (bp->sleeping) 1475 if (bp->sleeping)
1474 return; 1476 return;
1475 1477
1476 spin_lock_irqsave(&bp->lock, flags); 1478 spin_lock_irqsave(&bp->lock, flags);
1477 while (1) { 1479 while (1) {
1478 i = bp->tx_fill + 1; 1480 i = bp->tx_fill + 1;
@@ -1560,9 +1562,9 @@ static void bmac_tx_timeout(unsigned long data)
1560 } 1562 }
1561 1563
1562 /* turn it back on */ 1564 /* turn it back on */
1563 oldConfig = bmread(dev, RXCFG); 1565 oldConfig = bmread(dev, RXCFG);
1564 bmwrite(dev, RXCFG, oldConfig | RxMACEnable ); 1566 bmwrite(dev, RXCFG, oldConfig | RxMACEnable );
1565 oldConfig = bmread(dev, TXCFG); 1567 oldConfig = bmread(dev, TXCFG);
1566 bmwrite(dev, TXCFG, oldConfig | TxMACEnable ); 1568 bmwrite(dev, TXCFG, oldConfig | TxMACEnable );
1567 1569
1568 spin_unlock_irqrestore(&bp->lock, flags); 1570 spin_unlock_irqrestore(&bp->lock, flags);
@@ -1572,10 +1574,10 @@ static void bmac_tx_timeout(unsigned long data)
1572static void dump_dbdma(volatile struct dbdma_cmd *cp,int count) 1574static void dump_dbdma(volatile struct dbdma_cmd *cp,int count)
1573{ 1575{
1574 int i,*ip; 1576 int i,*ip;
1575 1577
1576 for (i=0;i< count;i++) { 1578 for (i=0;i< count;i++) {
1577 ip = (int*)(cp+i); 1579 ip = (int*)(cp+i);
1578 1580
1579 printk("dbdma req 0x%x addr 0x%x baddr 0x%x xfer/res 0x%x\n", 1581 printk("dbdma req 0x%x addr 0x%x baddr 0x%x xfer/res 0x%x\n",
1580 ld_le32(ip+0), 1582 ld_le32(ip+0),
1581 ld_le32(ip+1), 1583 ld_le32(ip+1),
@@ -1631,7 +1633,7 @@ static int __devexit bmac_remove(struct macio_dev *mdev)
1631 unregister_netdev(dev); 1633 unregister_netdev(dev);
1632 1634
1633 free_irq(dev->irq, dev); 1635 free_irq(dev->irq, dev);
1634 free_irq(bp->tx_dma_intr, dev); 1636 free_irq(bp->tx_dma_intr, dev);
1635 free_irq(bp->rx_dma_intr, dev); 1637 free_irq(bp->rx_dma_intr, dev);
1636 1638
1637 iounmap((void __iomem *)dev->base_addr); 1639 iounmap((void __iomem *)dev->base_addr);
@@ -1645,7 +1647,7 @@ static int __devexit bmac_remove(struct macio_dev *mdev)
1645 return 0; 1647 return 0;
1646} 1648}
1647 1649
1648static struct of_device_id bmac_match[] = 1650static struct of_device_id bmac_match[] =
1649{ 1651{
1650 { 1652 {
1651 .name = "bmac", 1653 .name = "bmac",
@@ -1660,7 +1662,7 @@ static struct of_device_id bmac_match[] =
1660}; 1662};
1661MODULE_DEVICE_TABLE (of, bmac_match); 1663MODULE_DEVICE_TABLE (of, bmac_match);
1662 1664
1663static struct macio_driver bmac_driver = 1665static struct macio_driver bmac_driver =
1664{ 1666{
1665 .name = "bmac", 1667 .name = "bmac",
1666 .match_table = bmac_match, 1668 .match_table = bmac_match,