aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2008-01-13 09:18:05 -0500
committerJeff Garzik <jeff@garzik.org>2008-01-18 14:44:33 -0500
commit96d768517eef3c10d4a82bd121caa42f584082cb (patch)
tree73db62f409ef98bfedfcc209835d0c4a80320b31 /drivers
parent21b645e4c2531631992dc127cf676631a70046c8 (diff)
dl2k: BMSR fixes
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/dl2k.c32
-rw-r--r--drivers/net/dl2k.h22
2 files changed, 16 insertions, 38 deletions
diff --git a/drivers/net/dl2k.c b/drivers/net/dl2k.c
index afeea88a520a..4468e0f5d16e 100644
--- a/drivers/net/dl2k.c
+++ b/drivers/net/dl2k.c
@@ -1435,7 +1435,7 @@ mii_write (struct net_device *dev, int phy_addr, int reg_num, u16 data)
1435static int 1435static int
1436mii_wait_link (struct net_device *dev, int wait) 1436mii_wait_link (struct net_device *dev, int wait)
1437{ 1437{
1438 BMSR_t bmsr; 1438 __u16 bmsr;
1439 int phy_addr; 1439 int phy_addr;
1440 struct netdev_private *np; 1440 struct netdev_private *np;
1441 1441
@@ -1443,8 +1443,8 @@ mii_wait_link (struct net_device *dev, int wait)
1443 phy_addr = np->phy_addr; 1443 phy_addr = np->phy_addr;
1444 1444
1445 do { 1445 do {
1446 bmsr.image = mii_read (dev, phy_addr, MII_BMSR); 1446 bmsr = mii_read (dev, phy_addr, MII_BMSR);
1447 if (bmsr.bits.link_status) 1447 if (bmsr & MII_BMSR_LINK_STATUS)
1448 return 0; 1448 return 0;
1449 mdelay (1); 1449 mdelay (1);
1450 } while (--wait > 0); 1450 } while (--wait > 0);
@@ -1454,7 +1454,7 @@ static int
1454mii_get_media (struct net_device *dev) 1454mii_get_media (struct net_device *dev)
1455{ 1455{
1456 __u16 negotiate; 1456 __u16 negotiate;
1457 BMSR_t bmsr; 1457 __u16 bmsr;
1458 MSCR_t mscr; 1458 MSCR_t mscr;
1459 MSSR_t mssr; 1459 MSSR_t mssr;
1460 int phy_addr; 1460 int phy_addr;
@@ -1463,9 +1463,9 @@ mii_get_media (struct net_device *dev)
1463 np = netdev_priv(dev); 1463 np = netdev_priv(dev);
1464 phy_addr = np->phy_addr; 1464 phy_addr = np->phy_addr;
1465 1465
1466 bmsr.image = mii_read (dev, phy_addr, MII_BMSR); 1466 bmsr = mii_read (dev, phy_addr, MII_BMSR);
1467 if (np->an_enable) { 1467 if (np->an_enable) {
1468 if (!bmsr.bits.an_complete) { 1468 if (!(bmsr & MII_BMSR_AN_COMPLETE)) {
1469 /* Auto-Negotiation not completed */ 1469 /* Auto-Negotiation not completed */
1470 return -1; 1470 return -1;
1471 } 1471 }
@@ -1541,7 +1541,7 @@ mii_set_media (struct net_device *dev)
1541{ 1541{
1542 PHY_SCR_t pscr; 1542 PHY_SCR_t pscr;
1543 __u16 bmcr; 1543 __u16 bmcr;
1544 BMSR_t bmsr; 1544 __u16 bmsr;
1545 __u16 anar; 1545 __u16 anar;
1546 int phy_addr; 1546 int phy_addr;
1547 struct netdev_private *np; 1547 struct netdev_private *np;
@@ -1551,22 +1551,22 @@ mii_set_media (struct net_device *dev)
1551 /* Does user set speed? */ 1551 /* Does user set speed? */
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 = mii_read (dev, phy_addr, MII_BMSR);
1555 anar = mii_read (dev, phy_addr, MII_ANAR) & 1555 anar = mii_read (dev, phy_addr, MII_ANAR) &
1556 ~MII_ANAR_100BX_FD & 1556 ~MII_ANAR_100BX_FD &
1557 ~MII_ANAR_100BX_HD & 1557 ~MII_ANAR_100BX_HD &
1558 ~MII_ANAR_100BT4 & 1558 ~MII_ANAR_100BT4 &
1559 ~MII_ANAR_10BT_FD & 1559 ~MII_ANAR_10BT_FD &
1560 ~MII_ANAR_10BT_HD; 1560 ~MII_ANAR_10BT_HD;
1561 if (bmsr.bits.media_100BX_FD) 1561 if (bmsr & MII_BMSR_100BX_FD)
1562 anar |= MII_ANAR_100BX_FD; 1562 anar |= MII_ANAR_100BX_FD;
1563 if (bmsr.bits.media_100BX_HD) 1563 if (bmsr & MII_BMSR_100BX_HD)
1564 anar |= MII_ANAR_100BX_HD; 1564 anar |= MII_ANAR_100BX_HD;
1565 if (bmsr.bits.media_100BT4) 1565 if (bmsr & MII_BMSR_100BT4)
1566 anar |= MII_ANAR_100BT4; 1566 anar |= MII_ANAR_100BT4;
1567 if (bmsr.bits.media_10BT_FD) 1567 if (bmsr & MII_BMSR_10BT_FD)
1568 anar |= MII_ANAR_10BT_FD; 1568 anar |= MII_ANAR_10BT_FD;
1569 if (bmsr.bits.media_10BT_HD) 1569 if (bmsr & MII_BMSR_10BT_HD)
1570 anar |= MII_ANAR_10BT_HD; 1570 anar |= MII_ANAR_10BT_HD;
1571 anar |= MII_ANAR_PAUSE | MII_ANAR_ASYMMETRIC; 1571 anar |= MII_ANAR_PAUSE | MII_ANAR_ASYMMETRIC;
1572 mii_write (dev, phy_addr, MII_ANAR, anar); 1572 mii_write (dev, phy_addr, MII_ANAR, anar);
@@ -1631,16 +1631,16 @@ static int
1631mii_get_media_pcs (struct net_device *dev) 1631mii_get_media_pcs (struct net_device *dev)
1632{ 1632{
1633 __u16 negotiate; 1633 __u16 negotiate;
1634 BMSR_t bmsr; 1634 __u16 bmsr;
1635 int phy_addr; 1635 int phy_addr;
1636 struct netdev_private *np; 1636 struct netdev_private *np;
1637 1637
1638 np = netdev_priv(dev); 1638 np = netdev_priv(dev);
1639 phy_addr = np->phy_addr; 1639 phy_addr = np->phy_addr;
1640 1640
1641 bmsr.image = mii_read (dev, phy_addr, PCS_BMSR); 1641 bmsr = mii_read (dev, phy_addr, PCS_BMSR);
1642 if (np->an_enable) { 1642 if (np->an_enable) {
1643 if (!bmsr.bits.an_complete) { 1643 if (!(bmsr & MII_BMSR_AN_COMPLETE)) {
1644 /* Auto-Negotiation not completed */ 1644 /* Auto-Negotiation not completed */
1645 return -1; 1645 return -1;
1646 } 1646 }
diff --git a/drivers/net/dl2k.h b/drivers/net/dl2k.h
index e6623085e834..c8aacf2ff8da 100644
--- a/drivers/net/dl2k.h
+++ b/drivers/net/dl2k.h
@@ -316,28 +316,6 @@ enum _mii_bmcr {
316}; 316};
317 317
318/* Basic Mode Status Register */ 318/* Basic Mode Status Register */
319typedef union t_MII_BMSR {
320 u16 image;
321 struct {
322 u16 ext_capability:1; // bit 0
323 u16 japper_detect:1; // bit 1
324 u16 link_status:1; // bit 2
325 u16 an_ability:1; // bit 3
326 u16 remote_fault:1; // bit 4
327 u16 an_complete:1; // bit 5
328 u16 preamble_supp:1; // bit 6
329 u16 _bit_7:1; // bit 7
330 u16 ext_status:1; // bit 8
331 u16 media_100BT2_HD:1; // bit 9
332 u16 media_100BT2_FD:1; // bit 10
333 u16 media_10BT_HD:1; // bit 11
334 u16 media_10BT_FD:1; // bit 12
335 u16 media_100BX_HD:1; // bit 13
336 u16 media_100BX_FD:1; // bit 14
337 u16 media_100BT4:1; // bit 15
338 } bits;
339} BMSR_t, *PBMSR_t;
340
341enum _mii_bmsr { 319enum _mii_bmsr {
342 MII_BMSR_100BT4 = 0x8000, 320 MII_BMSR_100BT4 = 0x8000,
343 MII_BMSR_100BX_FD = 0x4000, 321 MII_BMSR_100BX_FD = 0x4000,