Merge branches 'kbuild', 'packaging' and 'misc' of git://git.kernel.org/pub/scm/linux...
[deliverable/linux.git] / drivers / net / r8169.c
index 1d2508834415c5748a5d2391bae52b3bb7ee0c44..7d9c650f395e1399a7185c9338f26b5fd8713db7 100644 (file)
@@ -286,7 +286,6 @@ enum rtl_registers {
 #define        RXCFG_DMA_SHIFT                 8
                                        /* Unlimited maximum PCI burst. */
 #define        RX_DMA_BURST                    (7 << RXCFG_DMA_SHIFT)
-#define RTL_RX_CONFIG_MASK             0xff7e1880u
 
        RxMissed        = 0x4c,
        Cfg9346         = 0x50,
@@ -436,6 +435,7 @@ enum rtl_register_content {
        AcceptMulticast = 0x04,
        AcceptMyPhys    = 0x02,
        AcceptAllPhys   = 0x01,
+#define RX_CONFIG_ACCEPT_MASK          0x3f
 
        /* TxConfigBits */
        TxInterFrameGapShift = 24,
@@ -694,7 +694,7 @@ struct rtl8169_private {
                        size_t size;
                } phy_action;
        } *rtl_fw;
-#define RTL_FIRMWARE_UNKNOWN   ERR_PTR(-EAGAIN);
+#define RTL_FIRMWARE_UNKNOWN   ERR_PTR(-EAGAIN)
 };
 
 MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>");
@@ -728,8 +728,6 @@ static void rtl8169_down(struct net_device *dev);
 static void rtl8169_rx_clear(struct rtl8169_private *tp);
 static int rtl8169_poll(struct napi_struct *napi, int budget);
 
-static const unsigned int rtl8169_rx_config = RX_FIFO_THRESH | RX_DMA_BURST;
-
 static u32 ocp_read(struct rtl8169_private *tp, u8 mask, u16 reg)
 {
        void __iomem *ioaddr = tp->mmio_addr;
@@ -2162,12 +2160,9 @@ static void rtl8169sb_hw_phy_config(struct rtl8169_private *tp)
 static void rtl8169scd_hw_phy_config_quirk(struct rtl8169_private *tp)
 {
        struct pci_dev *pdev = tp->pci_dev;
-       u16 vendor_id, device_id;
-
-       pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &vendor_id);
-       pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &device_id);
 
-       if ((vendor_id != PCI_VENDOR_ID_GIGABYTE) || (device_id != 0xe000))
+       if ((pdev->subsystem_vendor != PCI_VENDOR_ID_GIGABYTE) ||
+           (pdev->subsystem_device != 0xe000))
                return;
 
        rtl_writephy(tp, 0x1f, 0x0001);
@@ -3503,6 +3498,42 @@ static void __devinit rtl_init_pll_power_ops(struct rtl8169_private *tp)
        }
 }
 
+static void rtl_init_rxcfg(struct rtl8169_private *tp)
+{
+       void __iomem *ioaddr = tp->mmio_addr;
+
+       switch (tp->mac_version) {
+       case RTL_GIGA_MAC_VER_01:
+       case RTL_GIGA_MAC_VER_02:
+       case RTL_GIGA_MAC_VER_03:
+       case RTL_GIGA_MAC_VER_04:
+       case RTL_GIGA_MAC_VER_05:
+       case RTL_GIGA_MAC_VER_06:
+       case RTL_GIGA_MAC_VER_10:
+       case RTL_GIGA_MAC_VER_11:
+       case RTL_GIGA_MAC_VER_12:
+       case RTL_GIGA_MAC_VER_13:
+       case RTL_GIGA_MAC_VER_14:
+       case RTL_GIGA_MAC_VER_15:
+       case RTL_GIGA_MAC_VER_16:
+       case RTL_GIGA_MAC_VER_17:
+               RTL_W32(RxConfig, RX_FIFO_THRESH | RX_DMA_BURST);
+               break;
+       case RTL_GIGA_MAC_VER_18:
+       case RTL_GIGA_MAC_VER_19:
+       case RTL_GIGA_MAC_VER_20:
+       case RTL_GIGA_MAC_VER_21:
+       case RTL_GIGA_MAC_VER_22:
+       case RTL_GIGA_MAC_VER_23:
+       case RTL_GIGA_MAC_VER_24:
+               RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST);
+               break;
+       default:
+               RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST);
+               break;
+       }
+}
+
 static void rtl8169_init_ring_indexes(struct rtl8169_private *tp)
 {
        tp->dirty_tx = tp->dirty_rx = tp->cur_tx = tp->cur_rx = 0;
@@ -3630,6 +3661,11 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (!pci_is_pcie(pdev))
                netif_info(tp, probe, dev, "not PCI Express\n");
 
+       /* Identify chip attached to board */
+       rtl8169_get_mac_version(tp, dev, cfg->default_ver);
+
+       rtl_init_rxcfg(tp);
+
        RTL_W16(IntrMask, 0x0000);
 
        rtl_hw_reset(tp);
@@ -3638,9 +3674,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        pci_set_master(pdev);
 
-       /* Identify chip attached to board */
-       rtl8169_get_mac_version(tp, dev, cfg->default_ver);
-
        /*
         * Pretend we are using VLANs; This bypasses a nasty bug where
         * Interrupts stop flowing on high load on 8110SCd controllers.
@@ -3908,11 +3941,8 @@ err_pm_runtime_put:
 static void rtl_rx_close(struct rtl8169_private *tp)
 {
        void __iomem *ioaddr = tp->mmio_addr;
-       u32 rxcfg = RTL_R32(RxConfig);
 
-       rxcfg &= ~(AcceptErr | AcceptRunt | AcceptBroadcast | AcceptMulticast |
-                  AcceptMyPhys | AcceptAllPhys);
-       RTL_W32(RxConfig, rxcfg);
+       RTL_W32(RxConfig, RTL_R32(RxConfig) & ~RX_CONFIG_ACCEPT_MASK);
 }
 
 static void rtl8169_hw_reset(struct rtl8169_private *tp)
@@ -3943,10 +3973,6 @@ static void rtl8169_hw_reset(struct rtl8169_private *tp)
 static void rtl_set_rx_tx_config_registers(struct rtl8169_private *tp)
 {
        void __iomem *ioaddr = tp->mmio_addr;
-       u32 cfg = rtl8169_rx_config;
-
-       cfg |= (RTL_R32(RxConfig) & RTL_RX_CONFIG_MASK);
-       RTL_W32(RxConfig, cfg);
 
        /* Set DMA burst size and Interframe Gap Time */
        RTL_W32(TxConfig, (TX_DMA_BURST << TxDMAShift) |
@@ -4034,6 +4060,8 @@ static void rtl_hw_start_8169(struct net_device *dev)
            tp->mac_version == RTL_GIGA_MAC_VER_04)
                RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
 
+       rtl_init_rxcfg(tp);
+
        RTL_W8(EarlyTxThres, NoEarlyTx);
 
        rtl_set_rx_max_size(ioaddr, rx_buf_sz);
@@ -5553,8 +5581,7 @@ static void rtl_set_rx_mode(struct net_device *dev)
 
        spin_lock_irqsave(&tp->lock, flags);
 
-       tmp = rtl8169_rx_config | rx_mode |
-             (RTL_R32(RxConfig) & RTL_RX_CONFIG_MASK);
+       tmp = (RTL_R32(RxConfig) & ~RX_CONFIG_ACCEPT_MASK) | rx_mode;
 
        if (tp->mac_version > RTL_GIGA_MAC_VER_06) {
                u32 data = mc_filter[0];
@@ -5729,8 +5756,11 @@ static void rtl_shutdown(struct pci_dev *pdev)
        spin_unlock_irq(&tp->lock);
 
        if (system_state == SYSTEM_POWER_OFF) {
-               /* WoL fails with some 8168 when the receiver is disabled. */
-               if (tp->features & RTL_FEATURE_WOL) {
+               /* WoL fails with 8168b when the receiver is disabled. */
+               if ((tp->mac_version == RTL_GIGA_MAC_VER_11 ||
+                    tp->mac_version == RTL_GIGA_MAC_VER_12 ||
+                    tp->mac_version == RTL_GIGA_MAC_VER_17) &&
+                   (tp->features & RTL_FEATURE_WOL)) {
                        pci_clear_master(pdev);
 
                        RTL_W8(ChipCmd, CmdRxEnb);
This page took 0.034404 seconds and 5 git commands to generate.