Changeset 6 for gpxe_study
- Timestamp:
- Feb 20, 2008, 2:37:45 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gpxe_study/kernel_2.6.20_src/sis900.c
r5 r6 490 490 sis_priv->mii_info.reg_num_mask = 0x1f; 491 491 492 /* Get Mac address according to the chip revision */ 493 pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &(sis_priv->chipset_rev)); 494 if(netif_msg_probe(sis_priv)) 495 printk(KERN_DEBUG "%s: detected revision %2.2x, " 496 "trying to get MAC address...\n", 497 dev_name, sis_priv->chipset_rev); 498 499 ret = 0; 500 if (sis_priv->chipset_rev == SIS630E_900_REV) 501 ret = sis630e_get_mac_addr(pci_dev, net_dev); 502 else if ((sis_priv->chipset_rev > 0x81) && (sis_priv->chipset_rev <= 0x90) ) 503 ret = sis635_get_mac_addr(pci_dev, net_dev); 504 else if (sis_priv->chipset_rev == SIS96x_900_REV) 505 ret = sis96x_get_mac_addr(pci_dev, net_dev); 506 else 507 ret = sis900_get_mac_addr(pci_dev, net_dev); 508 509 if (ret == 0) { 510 printk(KERN_WARNING "%s: Cannot read MAC address.\n", dev_name); 511 ret = -ENODEV; 512 goto err_unmap_rx; 513 } 514 515 /* 630ET : set the mii access mode as software-mode */ 516 if (sis_priv->chipset_rev == SIS630ET_900_REV) 517 outl(ACCESSMODE | inl(ioaddr + cr), ioaddr + cr); 518 519 /* probe for mii transceiver */ 520 if (sis900_mii_probe(net_dev) == 0) { 492 /* Get Mac address according to the chip revision */ 493 pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &(sis_priv->chipset_rev)); 494 if(netif_msg_probe(sis_priv)) 495 printk(KERN_DEBUG "%s: detected revision %2.2x, " 496 "trying to get MAC address...\n", 497 dev_name, sis_priv->chipset_rev); 498 499 ret = 0; 500 501 if (sis_priv->chipset_rev == SIS630E_900_REV) 502 ret = sis630e_get_mac_addr(pci_dev, net_dev); 503 else if ((sis_priv->chipset_rev > 0x81) && (sis_priv->chipset_rev <= 0x90) ) 504 ret = sis635_get_mac_addr(pci_dev, net_dev); 505 else if (sis_priv->chipset_rev == SIS96x_900_REV) 506 ret = sis96x_get_mac_addr(pci_dev, net_dev); 507 else 508 ret = sis900_get_mac_addr(pci_dev, net_dev); 509 510 if (ret == 0) 511 { 512 printk(KERN_WARNING "%s: Cannot read MAC address.\n", dev_name); 513 ret = -ENODEV; 514 goto err_unmap_rx; 515 } 516 517 /* 630ET : set the mii access mode as software-mode */ 518 if (sis_priv->chipset_rev == SIS630ET_900_REV) 519 outl(ACCESSMODE | inl(ioaddr + cr), ioaddr + cr); 520 521 522 /* probe for mii transceiver */ 523 if (sis900_mii_probe(net_dev) == 0) { 521 524 printk(KERN_WARNING "%s: Error probing MII device.\n", 522 525 dev_name); … … 1405 1408 1406 1409 1410 1411 1412 1413 /* 1414 * sis900_read_mode - read media mode for sis900 internal phy 1415 * @net_dev: the net device to read mode for 1416 * @speed : the transmit speed to be determined 1417 * @duplex : the duplex mode to be determined 1418 * 1419 * The capability of remote end will be put in mii register autorec 1420 * after auto-negotiation. Use AND operation to get the upper bound 1421 * of speed and duplex between two ends. 1422 */ 1423 1424 static void 1425 sis900_read_mode(struct net_device *net_dev, int *speed, int *duplex) 1426 { 1427 int i = 0; 1428 u32 status; 1429 struct sis900_private *sis_priv = net_dev->priv; 1430 struct mii_phy *phy = sis_priv->mii; 1431 int phy_addr = sis_priv->cur_phy; 1432 u16 autoadv, autorec; 1433 1434 while (i++ < 2) 1435 status = mdio_read(net_dev, phy_addr, MII_STATUS); 1436 1437 if (!(status & MII_STAT_LINK)) 1438 return; 1439 /* AutoNegotiate completed */ 1440 autoadv = mdio_read(net_dev, phy_addr, MII_ANADV); 1441 autorec = mdio_read(net_dev, phy_addr, MII_ANLPAR); 1442 status = autoadv & autorec; 1443 *speed = HW_SPEED_10_MBPS; 1444 *duplex = FDX_CAPABLE_HALF_SELECTED; 1445 1446 if (status & (MII_NWAY_TX | MII_NWAY_TX_FDX)) 1447 *speed = HW_SPEED_100_MBPS; 1448 if (status & ( MII_NWAY_TX_FDX | MII_NWAY_T_FDX)) 1449 *duplex = FDX_CAPABLE_FULL_SELECTED; 1450 sis_priv->autong_complete = 1; 1451 1452 /* Workaround for Realtek RTL8201 PHY issue */ 1453 if ((phy->phy_id0 == 0x0000) && ((phy->phy_id1 & 0xFFF0) == 0x8200)) { 1454 if (mdio_read(net_dev, phy_addr, MII_CONTROL) & MII_CNTL_FDX) 1455 *duplex = FDX_CAPABLE_FULL_SELECTED; 1456 if (mdio_read(net_dev, phy_addr, 0x0019) & 0x01) 1457 *speed = HW_SPEED_100_MBPS; 1458 } 1459 1460 if(netif_msg_link(sis_priv)) 1461 printk(KERN_INFO "%s: Media Link On %s %s-duplex \n", 1462 net_dev->name, 1463 *speed == HW_SPEED_100_MBPS ? 1464 "100mbps" : "10mbps", 1465 *duplex == FDX_CAPABLE_FULL_SELECTED ? 1466 "full" : "half"); 1467 } 1468 1469 1470 1471 /** 1472 * sis900_read_mode - read media mode for sis900 internal phy 1473 * @net_dev: the net device to read mode for 1474 * @speed : the transmit speed to be determined 1475 * @duplex : the duplex mode to be determined 1476 * 1477 * The capability of remote end will be put in mii register autorec 1478 * after auto-negotiation. Use AND operation to get the upper bound 1479 * of speed and duplex between two ends. 1480 */ 1481 1482 static void sis900_read_mode(struct net_device *net_dev, int *speed, int *duplex) 1483 { 1484 struct sis900_private *sis_priv = net_dev->priv; 1485 struct mii_phy *phy = sis_priv->mii; 1486 int phy_addr = sis_priv->cur_phy; 1487 u32 status; 1488 u16 autoadv, autorec; 1489 int i = 0; 1490 1491 while (i++ < 2) 1492 status = mdio_read(net_dev, phy_addr, MII_STATUS); 1493 1494 if (!(status & MII_STAT_LINK)) 1495 return; 1496 1497 /* AutoNegotiate completed */ 1498 autoadv = mdio_read(net_dev, phy_addr, MII_ANADV); 1499 autorec = mdio_read(net_dev, phy_addr, MII_ANLPAR); 1500 status = autoadv & autorec; 1501 1502 *speed = HW_SPEED_10_MBPS; 1503 *duplex = FDX_CAPABLE_HALF_SELECTED; 1504 1505 if (status & (MII_NWAY_TX | MII_NWAY_TX_FDX)) 1506 *speed = HW_SPEED_100_MBPS; 1507 if (status & ( MII_NWAY_TX_FDX | MII_NWAY_T_FDX)) 1508 *duplex = FDX_CAPABLE_FULL_SELECTED; 1509 1510 sis_priv->autong_complete = 1; 1511 1512 /* Workaround for Realtek RTL8201 PHY issue */ 1513 if ((phy->phy_id0 == 0x0000) && ((phy->phy_id1 & 0xFFF0) == 0x8200)) { 1514 if (mdio_read(net_dev, phy_addr, MII_CONTROL) & MII_CNTL_FDX) 1515 *duplex = FDX_CAPABLE_FULL_SELECTED; 1516 if (mdio_read(net_dev, phy_addr, 0x0019) & 0x01) 1517 *speed = HW_SPEED_100_MBPS; 1518 } 1519 1520 if(netif_msg_link(sis_priv)) 1521 printk(KERN_INFO "%s: Media Link On %s %s-duplex \n", 1522 net_dev->name, 1523 *speed == HW_SPEED_100_MBPS ? 1524 "100mbps" : "10mbps", 1525 *duplex == FDX_CAPABLE_FULL_SELECTED ? 1526 "full" : "half"); 1527 } 1528 1407 1529 /** 1408 1530 * sis900_timer - sis900 timer routine … … 1554 1676 MII_CNTL_AUTO | MII_CNTL_RST_AUTO); 1555 1677 sis_priv->autong_complete = 0; 1556 }1557 1558 1559 /**1560 * sis900_read_mode - read media mode for sis900 internal phy1561 * @net_dev: the net device to read mode for1562 * @speed : the transmit speed to be determined1563 * @duplex : the duplex mode to be determined1564 *1565 * The capability of remote end will be put in mii register autorec1566 * after auto-negotiation. Use AND operation to get the upper bound1567 * of speed and duplex between two ends.1568 */1569 1570 static void sis900_read_mode(struct net_device *net_dev, int *speed, int *duplex)1571 {1572 struct sis900_private *sis_priv = net_dev->priv;1573 struct mii_phy *phy = sis_priv->mii;1574 int phy_addr = sis_priv->cur_phy;1575 u32 status;1576 u16 autoadv, autorec;1577 int i = 0;1578 1579 while (i++ < 2)1580 status = mdio_read(net_dev, phy_addr, MII_STATUS);1581 1582 if (!(status & MII_STAT_LINK))1583 return;1584 1585 /* AutoNegotiate completed */1586 autoadv = mdio_read(net_dev, phy_addr, MII_ANADV);1587 autorec = mdio_read(net_dev, phy_addr, MII_ANLPAR);1588 status = autoadv & autorec;1589 1590 *speed = HW_SPEED_10_MBPS;1591 *duplex = FDX_CAPABLE_HALF_SELECTED;1592 1593 if (status & (MII_NWAY_TX | MII_NWAY_TX_FDX))1594 *speed = HW_SPEED_100_MBPS;1595 if (status & ( MII_NWAY_TX_FDX | MII_NWAY_T_FDX))1596 *duplex = FDX_CAPABLE_FULL_SELECTED;1597 1598 sis_priv->autong_complete = 1;1599 1600 /* Workaround for Realtek RTL8201 PHY issue */1601 if ((phy->phy_id0 == 0x0000) && ((phy->phy_id1 & 0xFFF0) == 0x8200)) {1602 if (mdio_read(net_dev, phy_addr, MII_CONTROL) & MII_CNTL_FDX)1603 *duplex = FDX_CAPABLE_FULL_SELECTED;1604 if (mdio_read(net_dev, phy_addr, 0x0019) & 0x01)1605 *speed = HW_SPEED_100_MBPS;1606 }1607 1608 if(netif_msg_link(sis_priv))1609 printk(KERN_INFO "%s: Media Link On %s %s-duplex \n",1610 net_dev->name,1611 *speed == HW_SPEED_100_MBPS ?1612 "100mbps" : "10mbps",1613 *duplex == FDX_CAPABLE_FULL_SELECTED ?1614 "full" : "half");1615 1678 } 1616 1679
Note: See TracChangeset
for help on using the changeset viewer.