diff options
author | Al Viro <viro@ftp.linux.org.uk> | 2008-01-13 09:17:55 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2008-01-18 14:44:33 -0500 |
commit | 21b645e4c2531631992dc127cf676631a70046c8 (patch) | |
tree | 3afd7065134ccef5312e45010fd2afe4359ab8f5 /drivers/net/dl2k.c | |
parent | d50956af74859b4e9ba544a0211a94bc2621c1d9 (diff) |
dl2k: ANAR, ANLPAR fixes
same story, different registers...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/dl2k.c')
-rw-r--r-- | drivers/net/dl2k.c | 74 |
1 files changed, 42 insertions, 32 deletions
diff --git a/drivers/net/dl2k.c b/drivers/net/dl2k.c index badc60103d34..afeea88a520a 100644 --- a/drivers/net/dl2k.c +++ b/drivers/net/dl2k.c | |||
@@ -1453,7 +1453,7 @@ mii_wait_link (struct net_device *dev, int wait) | |||
1453 | static int | 1453 | static int |
1454 | mii_get_media (struct net_device *dev) | 1454 | mii_get_media (struct net_device *dev) |
1455 | { | 1455 | { |
1456 | ANAR_t negotiate; | 1456 | __u16 negotiate; |
1457 | BMSR_t bmsr; | 1457 | BMSR_t bmsr; |
1458 | MSCR_t mscr; | 1458 | MSCR_t mscr; |
1459 | MSSR_t mssr; | 1459 | MSSR_t mssr; |
@@ -1469,7 +1469,7 @@ mii_get_media (struct net_device *dev) | |||
1469 | /* Auto-Negotiation not completed */ | 1469 | /* Auto-Negotiation not completed */ |
1470 | return -1; | 1470 | return -1; |
1471 | } | 1471 | } |
1472 | negotiate.image = mii_read (dev, phy_addr, MII_ANAR) & | 1472 | negotiate = mii_read (dev, phy_addr, MII_ANAR) & |
1473 | mii_read (dev, phy_addr, MII_ANLPAR); | 1473 | mii_read (dev, phy_addr, MII_ANLPAR); |
1474 | mscr.image = mii_read (dev, phy_addr, MII_MSCR); | 1474 | mscr.image = mii_read (dev, phy_addr, MII_MSCR); |
1475 | mssr.image = mii_read (dev, phy_addr, MII_MSSR); | 1475 | mssr.image = mii_read (dev, phy_addr, MII_MSSR); |
@@ -1481,27 +1481,27 @@ mii_get_media (struct net_device *dev) | |||
1481 | np->speed = 1000; | 1481 | np->speed = 1000; |
1482 | np->full_duplex = 0; | 1482 | np->full_duplex = 0; |
1483 | printk (KERN_INFO "Auto 1000 Mbps, Half duplex\n"); | 1483 | printk (KERN_INFO "Auto 1000 Mbps, Half duplex\n"); |
1484 | } else if (negotiate.bits.media_100BX_FD) { | 1484 | } else if (negotiate & MII_ANAR_100BX_FD) { |
1485 | np->speed = 100; | 1485 | np->speed = 100; |
1486 | np->full_duplex = 1; | 1486 | np->full_duplex = 1; |
1487 | printk (KERN_INFO "Auto 100 Mbps, Full duplex\n"); | 1487 | printk (KERN_INFO "Auto 100 Mbps, Full duplex\n"); |
1488 | } else if (negotiate.bits.media_100BX_HD) { | 1488 | } else if (negotiate & MII_ANAR_100BX_HD) { |
1489 | np->speed = 100; | 1489 | np->speed = 100; |
1490 | np->full_duplex = 0; | 1490 | np->full_duplex = 0; |
1491 | printk (KERN_INFO "Auto 100 Mbps, Half duplex\n"); | 1491 | printk (KERN_INFO "Auto 100 Mbps, Half duplex\n"); |
1492 | } else if (negotiate.bits.media_10BT_FD) { | 1492 | } else if (negotiate & MII_ANAR_10BT_FD) { |
1493 | np->speed = 10; | 1493 | np->speed = 10; |
1494 | np->full_duplex = 1; | 1494 | np->full_duplex = 1; |
1495 | printk (KERN_INFO "Auto 10 Mbps, Full duplex\n"); | 1495 | printk (KERN_INFO "Auto 10 Mbps, Full duplex\n"); |
1496 | } else if (negotiate.bits.media_10BT_HD) { | 1496 | } else if (negotiate & MII_ANAR_10BT_HD) { |
1497 | np->speed = 10; | 1497 | np->speed = 10; |
1498 | np->full_duplex = 0; | 1498 | np->full_duplex = 0; |
1499 | printk (KERN_INFO "Auto 10 Mbps, Half duplex\n"); | 1499 | printk (KERN_INFO "Auto 10 Mbps, Half duplex\n"); |
1500 | } | 1500 | } |
1501 | if (negotiate.bits.pause) { | 1501 | if (negotiate & MII_ANAR_PAUSE) { |
1502 | np->tx_flow &= 1; | 1502 | np->tx_flow &= 1; |
1503 | np->rx_flow &= 1; | 1503 | np->rx_flow &= 1; |
1504 | } else if (negotiate.bits.asymmetric) { | 1504 | } else if (negotiate & MII_ANAR_ASYMMETRIC) { |
1505 | np->tx_flow = 0; | 1505 | np->tx_flow = 0; |
1506 | np->rx_flow &= 1; | 1506 | np->rx_flow &= 1; |
1507 | } | 1507 | } |
@@ -1542,7 +1542,7 @@ mii_set_media (struct net_device *dev) | |||
1542 | PHY_SCR_t pscr; | 1542 | PHY_SCR_t pscr; |
1543 | __u16 bmcr; | 1543 | __u16 bmcr; |
1544 | BMSR_t bmsr; | 1544 | BMSR_t bmsr; |
1545 | ANAR_t anar; | 1545 | __u16 anar; |
1546 | int phy_addr; | 1546 | int phy_addr; |
1547 | struct netdev_private *np; | 1547 | struct netdev_private *np; |
1548 | np = netdev_priv(dev); | 1548 | np = netdev_priv(dev); |
@@ -1552,15 +1552,24 @@ mii_set_media (struct net_device *dev) | |||
1552 | if (np->an_enable) { | 1552 | if (np->an_enable) { |
1553 | /* Advertise capabilities */ | 1553 | /* Advertise capabilities */ |
1554 | bmsr.image = mii_read (dev, phy_addr, MII_BMSR); | 1554 | bmsr.image = mii_read (dev, phy_addr, MII_BMSR); |
1555 | anar.image = mii_read (dev, phy_addr, MII_ANAR); | 1555 | anar = mii_read (dev, phy_addr, MII_ANAR) & |
1556 | anar.bits.media_100BX_FD = bmsr.bits.media_100BX_FD; | 1556 | ~MII_ANAR_100BX_FD & |
1557 | anar.bits.media_100BX_HD = bmsr.bits.media_100BX_HD; | 1557 | ~MII_ANAR_100BX_HD & |
1558 | anar.bits.media_100BT4 = bmsr.bits.media_100BT4; | 1558 | ~MII_ANAR_100BT4 & |
1559 | anar.bits.media_10BT_FD = bmsr.bits.media_10BT_FD; | 1559 | ~MII_ANAR_10BT_FD & |
1560 | anar.bits.media_10BT_HD = bmsr.bits.media_10BT_HD; | 1560 | ~MII_ANAR_10BT_HD; |
1561 | anar.bits.pause = 1; | 1561 | if (bmsr.bits.media_100BX_FD) |
1562 | anar.bits.asymmetric = 1; | 1562 | anar |= MII_ANAR_100BX_FD; |
1563 | mii_write (dev, phy_addr, MII_ANAR, anar.image); | 1563 | if (bmsr.bits.media_100BX_HD) |
1564 | anar |= MII_ANAR_100BX_HD; | ||
1565 | if (bmsr.bits.media_100BT4) | ||
1566 | anar |= MII_ANAR_100BT4; | ||
1567 | if (bmsr.bits.media_10BT_FD) | ||
1568 | anar |= MII_ANAR_10BT_FD; | ||
1569 | if (bmsr.bits.media_10BT_HD) | ||
1570 | anar |= MII_ANAR_10BT_HD; | ||
1571 | anar |= MII_ANAR_PAUSE | MII_ANAR_ASYMMETRIC; | ||
1572 | mii_write (dev, phy_addr, MII_ANAR, anar); | ||
1564 | 1573 | ||
1565 | /* Enable Auto crossover */ | 1574 | /* Enable Auto crossover */ |
1566 | pscr.image = mii_read (dev, phy_addr, MII_PHY_SCR); | 1575 | pscr.image = mii_read (dev, phy_addr, MII_PHY_SCR); |
@@ -1621,7 +1630,7 @@ mii_set_media (struct net_device *dev) | |||
1621 | static int | 1630 | static int |
1622 | mii_get_media_pcs (struct net_device *dev) | 1631 | mii_get_media_pcs (struct net_device *dev) |
1623 | { | 1632 | { |
1624 | ANAR_PCS_t negotiate; | 1633 | __u16 negotiate; |
1625 | BMSR_t bmsr; | 1634 | BMSR_t bmsr; |
1626 | int phy_addr; | 1635 | int phy_addr; |
1627 | struct netdev_private *np; | 1636 | struct netdev_private *np; |
@@ -1635,20 +1644,20 @@ mii_get_media_pcs (struct net_device *dev) | |||
1635 | /* Auto-Negotiation not completed */ | 1644 | /* Auto-Negotiation not completed */ |
1636 | return -1; | 1645 | return -1; |
1637 | } | 1646 | } |
1638 | negotiate.image = mii_read (dev, phy_addr, PCS_ANAR) & | 1647 | negotiate = mii_read (dev, phy_addr, PCS_ANAR) & |
1639 | mii_read (dev, phy_addr, PCS_ANLPAR); | 1648 | mii_read (dev, phy_addr, PCS_ANLPAR); |
1640 | np->speed = 1000; | 1649 | np->speed = 1000; |
1641 | if (negotiate.bits.full_duplex) { | 1650 | if (negotiate & PCS_ANAR_FULL_DUPLEX) { |
1642 | printk (KERN_INFO "Auto 1000 Mbps, Full duplex\n"); | 1651 | printk (KERN_INFO "Auto 1000 Mbps, Full duplex\n"); |
1643 | np->full_duplex = 1; | 1652 | np->full_duplex = 1; |
1644 | } else { | 1653 | } else { |
1645 | printk (KERN_INFO "Auto 1000 Mbps, half duplex\n"); | 1654 | printk (KERN_INFO "Auto 1000 Mbps, half duplex\n"); |
1646 | np->full_duplex = 0; | 1655 | np->full_duplex = 0; |
1647 | } | 1656 | } |
1648 | if (negotiate.bits.pause) { | 1657 | if (negotiate & PCS_ANAR_PAUSE) { |
1649 | np->tx_flow &= 1; | 1658 | np->tx_flow &= 1; |
1650 | np->rx_flow &= 1; | 1659 | np->rx_flow &= 1; |
1651 | } else if (negotiate.bits.asymmetric) { | 1660 | } else if (negotiate & PCS_ANAR_ASYMMETRIC) { |
1652 | np->tx_flow = 0; | 1661 | np->tx_flow = 0; |
1653 | np->rx_flow &= 1; | 1662 | np->rx_flow &= 1; |
1654 | } | 1663 | } |
@@ -1679,7 +1688,7 @@ mii_set_media_pcs (struct net_device *dev) | |||
1679 | { | 1688 | { |
1680 | __u16 bmcr; | 1689 | __u16 bmcr; |
1681 | ESR_t esr; | 1690 | ESR_t esr; |
1682 | ANAR_PCS_t anar; | 1691 | __u16 anar; |
1683 | int phy_addr; | 1692 | int phy_addr; |
1684 | struct netdev_private *np; | 1693 | struct netdev_private *np; |
1685 | np = netdev_priv(dev); | 1694 | np = netdev_priv(dev); |
@@ -1689,14 +1698,15 @@ mii_set_media_pcs (struct net_device *dev) | |||
1689 | if (np->an_enable) { | 1698 | if (np->an_enable) { |
1690 | /* Advertise capabilities */ | 1699 | /* Advertise capabilities */ |
1691 | esr.image = mii_read (dev, phy_addr, PCS_ESR); | 1700 | esr.image = mii_read (dev, phy_addr, PCS_ESR); |
1692 | anar.image = mii_read (dev, phy_addr, MII_ANAR); | 1701 | anar = mii_read (dev, phy_addr, MII_ANAR) & |
1693 | anar.bits.half_duplex = | 1702 | ~PCS_ANAR_HALF_DUPLEX & |
1694 | esr.bits.media_1000BT_HD | esr.bits.media_1000BX_HD; | 1703 | ~PCS_ANAR_FULL_DUPLEX; |
1695 | anar.bits.full_duplex = | 1704 | if (esr.bits.media_1000BT_HD | esr.bits.media_1000BX_HD) |
1696 | esr.bits.media_1000BT_FD | esr.bits.media_1000BX_FD; | 1705 | anar |= PCS_ANAR_HALF_DUPLEX; |
1697 | anar.bits.pause = 1; | 1706 | if (esr.bits.media_1000BT_FD | esr.bits.media_1000BX_FD) |
1698 | anar.bits.asymmetric = 1; | 1707 | anar |= PCS_ANAR_FULL_DUPLEX; |
1699 | mii_write (dev, phy_addr, MII_ANAR, anar.image); | 1708 | anar |= PCS_ANAR_PAUSE | PCS_ANAR_ASYMMETRIC; |
1709 | mii_write (dev, phy_addr, MII_ANAR, anar); | ||
1700 | 1710 | ||
1701 | /* Soft reset PHY */ | 1711 | /* Soft reset PHY */ |
1702 | mii_write (dev, phy_addr, MII_BMCR, MII_BMCR_RESET); | 1712 | mii_write (dev, phy_addr, MII_BMCR, MII_BMCR_RESET); |