diff options
Diffstat (limited to 'drivers/net/r8169.c')
-rw-r--r-- | drivers/net/r8169.c | 71 |
1 files changed, 28 insertions, 43 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index f1c75751cab7..45d3ca431957 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -214,6 +214,7 @@ static struct pci_device_id rtl8169_pci_tbl[] = { | |||
214 | { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_2 }, | 214 | { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_2 }, |
215 | { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 }, | 215 | { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 }, |
216 | { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4300), 0, 0, RTL_CFG_0 }, | 216 | { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4300), 0, 0, RTL_CFG_0 }, |
217 | { PCI_DEVICE(0x1259, 0xc107), 0, 0, RTL_CFG_0 }, | ||
217 | { PCI_DEVICE(0x16ec, 0x0116), 0, 0, RTL_CFG_0 }, | 218 | { PCI_DEVICE(0x16ec, 0x0116), 0, 0, RTL_CFG_0 }, |
218 | { PCI_VENDOR_ID_LINKSYS, 0x1032, | 219 | { PCI_VENDOR_ID_LINKSYS, 0x1032, |
219 | PCI_ANY_ID, 0x0024, 0, 0, RTL_CFG_0 }, | 220 | PCI_ANY_ID, 0x0024, 0, 0, RTL_CFG_0 }, |
@@ -570,8 +571,8 @@ static void rtl8169_xmii_reset_enable(void __iomem *ioaddr) | |||
570 | { | 571 | { |
571 | unsigned int val; | 572 | unsigned int val; |
572 | 573 | ||
573 | val = (mdio_read(ioaddr, MII_BMCR) | BMCR_RESET) & 0xffff; | 574 | mdio_write(ioaddr, MII_BMCR, BMCR_RESET); |
574 | mdio_write(ioaddr, MII_BMCR, val); | 575 | val = mdio_read(ioaddr, MII_BMCR); |
575 | } | 576 | } |
576 | 577 | ||
577 | static void rtl8169_check_link_status(struct net_device *dev, | 578 | static void rtl8169_check_link_status(struct net_device *dev, |
@@ -1396,41 +1397,6 @@ static void rtl8169_netpoll(struct net_device *dev) | |||
1396 | } | 1397 | } |
1397 | #endif | 1398 | #endif |
1398 | 1399 | ||
1399 | static void __rtl8169_set_mac_addr(struct net_device *dev, void __iomem *ioaddr) | ||
1400 | { | ||
1401 | unsigned int i, j; | ||
1402 | |||
1403 | RTL_W8(Cfg9346, Cfg9346_Unlock); | ||
1404 | for (i = 0; i < 2; i++) { | ||
1405 | __le32 l = 0; | ||
1406 | |||
1407 | for (j = 0; j < 4; j++) { | ||
1408 | l <<= 8; | ||
1409 | l |= dev->dev_addr[4*i + j]; | ||
1410 | } | ||
1411 | RTL_W32(MAC0 + 4*i, cpu_to_be32(l)); | ||
1412 | } | ||
1413 | RTL_W8(Cfg9346, Cfg9346_Lock); | ||
1414 | } | ||
1415 | |||
1416 | static int rtl8169_set_mac_addr(struct net_device *dev, void *p) | ||
1417 | { | ||
1418 | struct rtl8169_private *tp = netdev_priv(dev); | ||
1419 | struct sockaddr *addr = p; | ||
1420 | |||
1421 | if (!is_valid_ether_addr(addr->sa_data)) | ||
1422 | return -EINVAL; | ||
1423 | |||
1424 | memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); | ||
1425 | |||
1426 | if (netif_running(dev)) { | ||
1427 | spin_lock_irq(&tp->lock); | ||
1428 | __rtl8169_set_mac_addr(dev, tp->mmio_addr); | ||
1429 | spin_unlock_irq(&tp->lock); | ||
1430 | } | ||
1431 | return 0; | ||
1432 | } | ||
1433 | |||
1434 | static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev, | 1400 | static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev, |
1435 | void __iomem *ioaddr) | 1401 | void __iomem *ioaddr) |
1436 | { | 1402 | { |
@@ -1440,6 +1406,22 @@ static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev, | |||
1440 | free_netdev(dev); | 1406 | free_netdev(dev); |
1441 | } | 1407 | } |
1442 | 1408 | ||
1409 | static void rtl8169_phy_reset(struct net_device *dev, | ||
1410 | struct rtl8169_private *tp) | ||
1411 | { | ||
1412 | void __iomem *ioaddr = tp->mmio_addr; | ||
1413 | int i; | ||
1414 | |||
1415 | tp->phy_reset_enable(ioaddr); | ||
1416 | for (i = 0; i < 100; i++) { | ||
1417 | if (!tp->phy_reset_pending(ioaddr)) | ||
1418 | return; | ||
1419 | msleep(1); | ||
1420 | } | ||
1421 | if (netif_msg_link(tp)) | ||
1422 | printk(KERN_ERR "%s: PHY reset failed.\n", dev->name); | ||
1423 | } | ||
1424 | |||
1443 | static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp) | 1425 | static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp) |
1444 | { | 1426 | { |
1445 | void __iomem *ioaddr = tp->mmio_addr; | 1427 | void __iomem *ioaddr = tp->mmio_addr; |
@@ -1468,6 +1450,8 @@ static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp) | |||
1468 | 1450 | ||
1469 | rtl8169_link_option(board_idx, &autoneg, &speed, &duplex); | 1451 | rtl8169_link_option(board_idx, &autoneg, &speed, &duplex); |
1470 | 1452 | ||
1453 | rtl8169_phy_reset(dev, tp); | ||
1454 | |||
1471 | rtl8169_set_speed(dev, autoneg, speed, duplex); | 1455 | rtl8169_set_speed(dev, autoneg, speed, duplex); |
1472 | 1456 | ||
1473 | if ((RTL_R8(PHYstatus) & TBI_Enable) && netif_msg_link(tp)) | 1457 | if ((RTL_R8(PHYstatus) & TBI_Enable) && netif_msg_link(tp)) |
@@ -1507,8 +1491,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1507 | struct rtl8169_private *tp; | 1491 | struct rtl8169_private *tp; |
1508 | struct net_device *dev; | 1492 | struct net_device *dev; |
1509 | void __iomem *ioaddr; | 1493 | void __iomem *ioaddr; |
1510 | unsigned int i, pm_cap; | 1494 | unsigned int pm_cap; |
1511 | int rc; | 1495 | int i, rc; |
1512 | 1496 | ||
1513 | if (netif_msg_drv(&debug)) { | 1497 | if (netif_msg_drv(&debug)) { |
1514 | printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n", | 1498 | printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n", |
@@ -1680,7 +1664,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1680 | dev->stop = rtl8169_close; | 1664 | dev->stop = rtl8169_close; |
1681 | dev->tx_timeout = rtl8169_tx_timeout; | 1665 | dev->tx_timeout = rtl8169_tx_timeout; |
1682 | dev->set_multicast_list = rtl8169_set_rx_mode; | 1666 | dev->set_multicast_list = rtl8169_set_rx_mode; |
1683 | dev->set_mac_address = rtl8169_set_mac_addr; | ||
1684 | dev->watchdog_timeo = RTL8169_TX_TIMEOUT; | 1667 | dev->watchdog_timeo = RTL8169_TX_TIMEOUT; |
1685 | dev->irq = pdev->irq; | 1668 | dev->irq = pdev->irq; |
1686 | dev->base_addr = (unsigned long) ioaddr; | 1669 | dev->base_addr = (unsigned long) ioaddr; |
@@ -1928,8 +1911,6 @@ rtl8169_hw_start(struct net_device *dev) | |||
1928 | /* Enable all known interrupts by setting the interrupt mask. */ | 1911 | /* Enable all known interrupts by setting the interrupt mask. */ |
1929 | RTL_W16(IntrMask, rtl8169_intr_mask); | 1912 | RTL_W16(IntrMask, rtl8169_intr_mask); |
1930 | 1913 | ||
1931 | __rtl8169_set_mac_addr(dev, ioaddr); | ||
1932 | |||
1933 | netif_start_queue(dev); | 1914 | netif_start_queue(dev); |
1934 | } | 1915 | } |
1935 | 1916 | ||
@@ -2700,6 +2681,7 @@ static void rtl8169_down(struct net_device *dev) | |||
2700 | struct rtl8169_private *tp = netdev_priv(dev); | 2681 | struct rtl8169_private *tp = netdev_priv(dev); |
2701 | void __iomem *ioaddr = tp->mmio_addr; | 2682 | void __iomem *ioaddr = tp->mmio_addr; |
2702 | unsigned int poll_locked = 0; | 2683 | unsigned int poll_locked = 0; |
2684 | unsigned int intrmask; | ||
2703 | 2685 | ||
2704 | rtl8169_delete_timer(dev); | 2686 | rtl8169_delete_timer(dev); |
2705 | 2687 | ||
@@ -2738,8 +2720,11 @@ core_down: | |||
2738 | * 2) dev->change_mtu | 2720 | * 2) dev->change_mtu |
2739 | * -> rtl8169_poll can not be issued again and re-enable the | 2721 | * -> rtl8169_poll can not be issued again and re-enable the |
2740 | * interruptions. Let's simply issue the IRQ down sequence again. | 2722 | * interruptions. Let's simply issue the IRQ down sequence again. |
2723 | * | ||
2724 | * No loop if hotpluged or major error (0xffff). | ||
2741 | */ | 2725 | */ |
2742 | if (RTL_R16(IntrMask)) | 2726 | intrmask = RTL_R16(IntrMask); |
2727 | if (intrmask && (intrmask != 0xffff)) | ||
2743 | goto core_down; | 2728 | goto core_down; |
2744 | 2729 | ||
2745 | rtl8169_tx_clear(tp); | 2730 | rtl8169_tx_clear(tp); |