]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/r8169.c
[PATCH] chelsio: use __netif_rx_schedule_prep
[linux-2.6-omap-h63xx.git] / drivers / net / r8169.c
index f1c75751cab7a4a55e7ba3c6a0800bd50874ef4a..45d3ca431957bc43070cd95400a99cd67bf58537 100644 (file)
@@ -214,6 +214,7 @@ static struct pci_device_id rtl8169_pci_tbl[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_REALTEK,     0x8168), 0, 0, RTL_CFG_2 },
        { PCI_DEVICE(PCI_VENDOR_ID_REALTEK,     0x8169), 0, 0, RTL_CFG_0 },
        { PCI_DEVICE(PCI_VENDOR_ID_DLINK,       0x4300), 0, 0, RTL_CFG_0 },
+       { PCI_DEVICE(0x1259,                    0xc107), 0, 0, RTL_CFG_0 },
        { PCI_DEVICE(0x16ec,                    0x0116), 0, 0, RTL_CFG_0 },
        { PCI_VENDOR_ID_LINKSYS,                0x1032,
                PCI_ANY_ID, 0x0024, 0, 0, RTL_CFG_0 },
@@ -570,8 +571,8 @@ static void rtl8169_xmii_reset_enable(void __iomem *ioaddr)
 {
        unsigned int val;
 
-       val = (mdio_read(ioaddr, MII_BMCR) | BMCR_RESET) & 0xffff;
-       mdio_write(ioaddr, MII_BMCR, val);
+       mdio_write(ioaddr, MII_BMCR, BMCR_RESET);
+       val = mdio_read(ioaddr, MII_BMCR);
 }
 
 static void rtl8169_check_link_status(struct net_device *dev,
@@ -1396,41 +1397,6 @@ static void rtl8169_netpoll(struct net_device *dev)
 }
 #endif
 
-static void __rtl8169_set_mac_addr(struct net_device *dev, void __iomem *ioaddr)
-{
-       unsigned int i, j;
-
-       RTL_W8(Cfg9346, Cfg9346_Unlock);
-       for (i = 0; i < 2; i++) {
-               __le32 l = 0;
-
-               for (j = 0; j < 4; j++) {
-                       l <<= 8;
-                       l |= dev->dev_addr[4*i + j];
-               }
-               RTL_W32(MAC0 + 4*i, cpu_to_be32(l));
-       }
-       RTL_W8(Cfg9346, Cfg9346_Lock);
-}
-
-static int rtl8169_set_mac_addr(struct net_device *dev, void *p)
-{
-       struct rtl8169_private *tp = netdev_priv(dev);
-       struct sockaddr *addr = p;
-
-       if (!is_valid_ether_addr(addr->sa_data))
-               return -EINVAL;
-
-       memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
-
-       if (netif_running(dev)) {
-               spin_lock_irq(&tp->lock);
-               __rtl8169_set_mac_addr(dev, tp->mmio_addr);
-               spin_unlock_irq(&tp->lock);
-       }
-       return 0;
-}
-
 static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev,
                                  void __iomem *ioaddr)
 {
@@ -1440,6 +1406,22 @@ static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev,
        free_netdev(dev);
 }
 
+static void rtl8169_phy_reset(struct net_device *dev,
+                             struct rtl8169_private *tp)
+{
+       void __iomem *ioaddr = tp->mmio_addr;
+       int i;
+
+       tp->phy_reset_enable(ioaddr);
+       for (i = 0; i < 100; i++) {
+               if (!tp->phy_reset_pending(ioaddr))
+                       return;
+               msleep(1);
+       }
+       if (netif_msg_link(tp))
+               printk(KERN_ERR "%s: PHY reset failed.\n", dev->name);
+}
+
 static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp)
 {
        void __iomem *ioaddr = tp->mmio_addr;
@@ -1468,6 +1450,8 @@ static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp)
 
        rtl8169_link_option(board_idx, &autoneg, &speed, &duplex);
 
+       rtl8169_phy_reset(dev, tp);
+
        rtl8169_set_speed(dev, autoneg, speed, duplex);
 
        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)
        struct rtl8169_private *tp;
        struct net_device *dev;
        void __iomem *ioaddr;
-       unsigned int i, pm_cap;
-       int rc;
+       unsigned int pm_cap;
+       int i, rc;
 
        if (netif_msg_drv(&debug)) {
                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)
        dev->stop = rtl8169_close;
        dev->tx_timeout = rtl8169_tx_timeout;
        dev->set_multicast_list = rtl8169_set_rx_mode;
-       dev->set_mac_address = rtl8169_set_mac_addr;
        dev->watchdog_timeo = RTL8169_TX_TIMEOUT;
        dev->irq = pdev->irq;
        dev->base_addr = (unsigned long) ioaddr;
@@ -1928,8 +1911,6 @@ rtl8169_hw_start(struct net_device *dev)
        /* Enable all known interrupts by setting the interrupt mask. */
        RTL_W16(IntrMask, rtl8169_intr_mask);
 
-       __rtl8169_set_mac_addr(dev, ioaddr);
-
        netif_start_queue(dev);
 }
 
@@ -2700,6 +2681,7 @@ static void rtl8169_down(struct net_device *dev)
        struct rtl8169_private *tp = netdev_priv(dev);
        void __iomem *ioaddr = tp->mmio_addr;
        unsigned int poll_locked = 0;
+       unsigned int intrmask;
 
        rtl8169_delete_timer(dev);
 
@@ -2738,8 +2720,11 @@ core_down:
         * 2) dev->change_mtu
         *    -> rtl8169_poll can not be issued again and re-enable the
         *       interruptions. Let's simply issue the IRQ down sequence again.
+        *
+        * No loop if hotpluged or major error (0xffff).
         */
-       if (RTL_R16(IntrMask))
+       intrmask = RTL_R16(IntrMask);
+       if (intrmask && (intrmask != 0xffff))
                goto core_down;
 
        rtl8169_tx_clear(tp);