diff options
author | Francois Romieu <romieu@fr.zoreil.com> | 2012-01-07 16:19:36 -0500 |
---|---|---|
committer | Francois Romieu <romieu@fr.zoreil.com> | 2012-01-07 17:02:37 -0500 |
commit | a384a33bb1c9ec2d99db2046b41f57023fa7d77b (patch) | |
tree | ca829e3546ffa5add0957ab0facb666877bd4666 /drivers/net/ethernet/via | |
parent | 7ab87ff4c770eed71e3777936299292739fcd0fe (diff) |
via-rhine: RHINE_WAIT_FOR macro removal.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Diffstat (limited to 'drivers/net/ethernet/via')
-rw-r--r-- | drivers/net/ethernet/via/via-rhine.c | 74 |
1 files changed, 50 insertions, 24 deletions
diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c index 9a7bacc5c1d7..98ec14ebfef3 100644 --- a/drivers/net/ethernet/via/via-rhine.c +++ b/drivers/net/ethernet/via/via-rhine.c | |||
@@ -501,15 +501,31 @@ static int rhine_vlan_rx_add_vid(struct net_device *dev, unsigned short vid); | |||
501 | static int rhine_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid); | 501 | static int rhine_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid); |
502 | static void rhine_restart_tx(struct net_device *dev); | 502 | static void rhine_restart_tx(struct net_device *dev); |
503 | 503 | ||
504 | #define RHINE_WAIT_FOR(condition) \ | 504 | static void rhine_wait_bit(struct rhine_private *rp, u8 reg, u8 mask, bool high) |
505 | do { \ | 505 | { |
506 | int i = 1024; \ | 506 | void __iomem *ioaddr = rp->base; |
507 | while (!(condition) && --i) \ | 507 | int i; |
508 | ; \ | 508 | |
509 | if (debug > 1 && i < 512) \ | 509 | for (i = 0; i < 1024; i++) { |
510 | pr_info("%4d cycles used @ %s:%d\n", \ | 510 | if (high ^ !!(ioread8(ioaddr + reg) & mask)) |
511 | 1024 - i, __func__, __LINE__); \ | 511 | break; |
512 | } while (0) | 512 | udelay(10); |
513 | } | ||
514 | if (i > 64) { | ||
515 | netdev_dbg(rp->dev, "%s bit wait (%02x/%02x) cycle " | ||
516 | "count: %04d\n", high ? "high" : "low", reg, mask, i); | ||
517 | } | ||
518 | } | ||
519 | |||
520 | static void rhine_wait_bit_high(struct rhine_private *rp, u8 reg, u8 mask) | ||
521 | { | ||
522 | rhine_wait_bit(rp, reg, mask, true); | ||
523 | } | ||
524 | |||
525 | static void rhine_wait_bit_low(struct rhine_private *rp, u8 reg, u8 mask) | ||
526 | { | ||
527 | rhine_wait_bit(rp, reg, mask, false); | ||
528 | } | ||
513 | 529 | ||
514 | static u32 rhine_get_events(struct rhine_private *rp) | 530 | static u32 rhine_get_events(struct rhine_private *rp) |
515 | { | 531 | { |
@@ -609,7 +625,7 @@ static void rhine_chip_reset(struct net_device *dev) | |||
609 | iowrite8(0x40, ioaddr + MiscCmd); | 625 | iowrite8(0x40, ioaddr + MiscCmd); |
610 | 626 | ||
611 | /* Reset can take somewhat longer (rare) */ | 627 | /* Reset can take somewhat longer (rare) */ |
612 | RHINE_WAIT_FOR(!(ioread8(ioaddr + ChipCmd1) & Cmd1Reset)); | 628 | rhine_wait_bit_low(rp, ChipCmd1, Cmd1Reset); |
613 | } | 629 | } |
614 | 630 | ||
615 | if (debug > 1) | 631 | if (debug > 1) |
@@ -641,9 +657,15 @@ static void __devinit rhine_reload_eeprom(long pioaddr, struct net_device *dev) | |||
641 | { | 657 | { |
642 | struct rhine_private *rp = netdev_priv(dev); | 658 | struct rhine_private *rp = netdev_priv(dev); |
643 | void __iomem *ioaddr = rp->base; | 659 | void __iomem *ioaddr = rp->base; |
660 | int i; | ||
644 | 661 | ||
645 | outb(0x20, pioaddr + MACRegEEcsr); | 662 | outb(0x20, pioaddr + MACRegEEcsr); |
646 | RHINE_WAIT_FOR(!(inb(pioaddr + MACRegEEcsr) & 0x20)); | 663 | for (i = 0; i < 1024; i++) { |
664 | if (!(inb(pioaddr + MACRegEEcsr) & 0x20)) | ||
665 | break; | ||
666 | } | ||
667 | if (i > 512) | ||
668 | pr_info("%4d cycles used @ %s:%d\n", i, __func__, __LINE__); | ||
647 | 669 | ||
648 | #ifdef USE_MMIO | 670 | #ifdef USE_MMIO |
649 | /* | 671 | /* |
@@ -770,7 +792,7 @@ static int rhine_napipoll(struct napi_struct *napi, int budget) | |||
770 | u8 cmd; | 792 | u8 cmd; |
771 | 793 | ||
772 | /* Avoid scavenging before Tx engine turned off */ | 794 | /* Avoid scavenging before Tx engine turned off */ |
773 | RHINE_WAIT_FOR(!(ioread8(ioaddr + ChipCmd) & CmdTxOn)); | 795 | rhine_wait_bit_low(rp, ChipCmd, CmdTxOn); |
774 | cmd = ioread8(ioaddr + ChipCmd); | 796 | cmd = ioread8(ioaddr + ChipCmd); |
775 | if ((cmd & CmdTxOn) && (debug > 2)) { | 797 | if ((cmd & CmdTxOn) && (debug > 2)) { |
776 | netdev_warn(dev, "%s: Tx engine still on\n", | 798 | netdev_warn(dev, "%s: Tx engine still on\n", |
@@ -1444,23 +1466,27 @@ static void init_registers(struct net_device *dev) | |||
1444 | } | 1466 | } |
1445 | 1467 | ||
1446 | /* Enable MII link status auto-polling (required for IntrLinkChange) */ | 1468 | /* Enable MII link status auto-polling (required for IntrLinkChange) */ |
1447 | static void rhine_enable_linkmon(void __iomem *ioaddr) | 1469 | static void rhine_enable_linkmon(struct rhine_private *rp) |
1448 | { | 1470 | { |
1471 | void __iomem *ioaddr = rp->base; | ||
1472 | |||
1449 | iowrite8(0, ioaddr + MIICmd); | 1473 | iowrite8(0, ioaddr + MIICmd); |
1450 | iowrite8(MII_BMSR, ioaddr + MIIRegAddr); | 1474 | iowrite8(MII_BMSR, ioaddr + MIIRegAddr); |
1451 | iowrite8(0x80, ioaddr + MIICmd); | 1475 | iowrite8(0x80, ioaddr + MIICmd); |
1452 | 1476 | ||
1453 | RHINE_WAIT_FOR((ioread8(ioaddr + MIIRegAddr) & 0x20)); | 1477 | rhine_wait_bit_high(rp, MIIRegAddr, 0x20); |
1454 | 1478 | ||
1455 | iowrite8(MII_BMSR | 0x40, ioaddr + MIIRegAddr); | 1479 | iowrite8(MII_BMSR | 0x40, ioaddr + MIIRegAddr); |
1456 | } | 1480 | } |
1457 | 1481 | ||
1458 | /* Disable MII link status auto-polling (required for MDIO access) */ | 1482 | /* Disable MII link status auto-polling (required for MDIO access) */ |
1459 | static void rhine_disable_linkmon(void __iomem *ioaddr, u32 quirks) | 1483 | static void rhine_disable_linkmon(struct rhine_private *rp) |
1460 | { | 1484 | { |
1485 | void __iomem *ioaddr = rp->base; | ||
1486 | |||
1461 | iowrite8(0, ioaddr + MIICmd); | 1487 | iowrite8(0, ioaddr + MIICmd); |
1462 | 1488 | ||
1463 | if (quirks & rqRhineI) { | 1489 | if (rp->quirks & rqRhineI) { |
1464 | iowrite8(0x01, ioaddr + MIIRegAddr); // MII_BMSR | 1490 | iowrite8(0x01, ioaddr + MIIRegAddr); // MII_BMSR |
1465 | 1491 | ||
1466 | /* Can be called from ISR. Evil. */ | 1492 | /* Can be called from ISR. Evil. */ |
@@ -1469,13 +1495,13 @@ static void rhine_disable_linkmon(void __iomem *ioaddr, u32 quirks) | |||
1469 | /* 0x80 must be set immediately before turning it off */ | 1495 | /* 0x80 must be set immediately before turning it off */ |
1470 | iowrite8(0x80, ioaddr + MIICmd); | 1496 | iowrite8(0x80, ioaddr + MIICmd); |
1471 | 1497 | ||
1472 | RHINE_WAIT_FOR(ioread8(ioaddr + MIIRegAddr) & 0x20); | 1498 | rhine_wait_bit_high(rp, MIIRegAddr, 0x20); |
1473 | 1499 | ||
1474 | /* Heh. Now clear 0x80 again. */ | 1500 | /* Heh. Now clear 0x80 again. */ |
1475 | iowrite8(0, ioaddr + MIICmd); | 1501 | iowrite8(0, ioaddr + MIICmd); |
1476 | } | 1502 | } |
1477 | else | 1503 | else |
1478 | RHINE_WAIT_FOR(ioread8(ioaddr + MIIRegAddr) & 0x80); | 1504 | rhine_wait_bit_high(rp, MIIRegAddr, 0x80); |
1479 | } | 1505 | } |
1480 | 1506 | ||
1481 | /* Read and write over the MII Management Data I/O (MDIO) interface. */ | 1507 | /* Read and write over the MII Management Data I/O (MDIO) interface. */ |
@@ -1486,16 +1512,16 @@ static int mdio_read(struct net_device *dev, int phy_id, int regnum) | |||
1486 | void __iomem *ioaddr = rp->base; | 1512 | void __iomem *ioaddr = rp->base; |
1487 | int result; | 1513 | int result; |
1488 | 1514 | ||
1489 | rhine_disable_linkmon(ioaddr, rp->quirks); | 1515 | rhine_disable_linkmon(rp); |
1490 | 1516 | ||
1491 | /* rhine_disable_linkmon already cleared MIICmd */ | 1517 | /* rhine_disable_linkmon already cleared MIICmd */ |
1492 | iowrite8(phy_id, ioaddr + MIIPhyAddr); | 1518 | iowrite8(phy_id, ioaddr + MIIPhyAddr); |
1493 | iowrite8(regnum, ioaddr + MIIRegAddr); | 1519 | iowrite8(regnum, ioaddr + MIIRegAddr); |
1494 | iowrite8(0x40, ioaddr + MIICmd); /* Trigger read */ | 1520 | iowrite8(0x40, ioaddr + MIICmd); /* Trigger read */ |
1495 | RHINE_WAIT_FOR(!(ioread8(ioaddr + MIICmd) & 0x40)); | 1521 | rhine_wait_bit_low(rp, MIICmd, 0x40); |
1496 | result = ioread16(ioaddr + MIIData); | 1522 | result = ioread16(ioaddr + MIIData); |
1497 | 1523 | ||
1498 | rhine_enable_linkmon(ioaddr); | 1524 | rhine_enable_linkmon(rp); |
1499 | return result; | 1525 | return result; |
1500 | } | 1526 | } |
1501 | 1527 | ||
@@ -1504,16 +1530,16 @@ static void mdio_write(struct net_device *dev, int phy_id, int regnum, int value | |||
1504 | struct rhine_private *rp = netdev_priv(dev); | 1530 | struct rhine_private *rp = netdev_priv(dev); |
1505 | void __iomem *ioaddr = rp->base; | 1531 | void __iomem *ioaddr = rp->base; |
1506 | 1532 | ||
1507 | rhine_disable_linkmon(ioaddr, rp->quirks); | 1533 | rhine_disable_linkmon(rp); |
1508 | 1534 | ||
1509 | /* rhine_disable_linkmon already cleared MIICmd */ | 1535 | /* rhine_disable_linkmon already cleared MIICmd */ |
1510 | iowrite8(phy_id, ioaddr + MIIPhyAddr); | 1536 | iowrite8(phy_id, ioaddr + MIIPhyAddr); |
1511 | iowrite8(regnum, ioaddr + MIIRegAddr); | 1537 | iowrite8(regnum, ioaddr + MIIRegAddr); |
1512 | iowrite16(value, ioaddr + MIIData); | 1538 | iowrite16(value, ioaddr + MIIData); |
1513 | iowrite8(0x20, ioaddr + MIICmd); /* Trigger write */ | 1539 | iowrite8(0x20, ioaddr + MIICmd); /* Trigger write */ |
1514 | RHINE_WAIT_FOR(!(ioread8(ioaddr + MIICmd) & 0x20)); | 1540 | rhine_wait_bit_low(rp, MIICmd, 0x20); |
1515 | 1541 | ||
1516 | rhine_enable_linkmon(ioaddr); | 1542 | rhine_enable_linkmon(rp); |
1517 | } | 1543 | } |
1518 | 1544 | ||
1519 | static void rhine_task_disable(struct rhine_private *rp) | 1545 | static void rhine_task_disable(struct rhine_private *rp) |