OSDN Git Service

r8152: avoid the MCU to clear the lanwake
authorHayes Wang <hayeswang@realtek.com>
Wed, 22 Jan 2020 08:02:12 +0000 (16:02 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 23 Jan 2020 10:20:57 +0000 (11:20 +0100)
Avoid the MCU to clear the lanwake after suspending. It may cause the
WOL fail. Disable LANWAKE_CLR_EN before suspending. Besides,enable it
and reset the lanwake status when resuming or initializing.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/r8152.c

index b1a00f2..c037fc7 100644 (file)
@@ -68,6 +68,7 @@
 #define PLA_LED_FEATURE                0xdd92
 #define PLA_PHYAR              0xde00
 #define PLA_BOOT_CTRL          0xe004
+#define PLA_LWAKE_CTRL_REG     0xe007
 #define PLA_GPHY_INTR_IMR      0xe022
 #define PLA_EEE_CR             0xe040
 #define PLA_EEEP_CR            0xe080
@@ -95,6 +96,7 @@
 #define PLA_TALLYCNT           0xe890
 #define PLA_SFF_STS_7          0xe8de
 #define PLA_PHYSTATUS          0xe908
+#define PLA_CONFIG6            0xe90a /* CONFIG6 */
 #define PLA_BP_BA              0xfc26
 #define PLA_BP_0               0xfc28
 #define PLA_BP_1               0xfc2a
 #define LINK_ON_WAKE_EN                0x0010
 #define LINK_OFF_WAKE_EN       0x0008
 
+/* PLA_CONFIG6 */
+#define LANWAKE_CLR_EN         BIT(0)
+
 /* PLA_CONFIG5 */
 #define BWF_EN                 0x0040
 #define MWF_EN                 0x0020
 /* PLA_BOOT_CTRL */
 #define AUTOLOAD_DONE          0x0002
 
+/* PLA_LWAKE_CTRL_REG */
+#define LANWAKE_PIN            BIT(7)
+
 /* PLA_SUSPEND_FLAG */
 #define LINK_CHG_EVENT         BIT(0)
 
@@ -4968,6 +4976,8 @@ static void rtl8152_down(struct r8152 *tp)
 
 static void rtl8153_up(struct r8152 *tp)
 {
+       u32 ocp_data;
+
        if (test_bit(RTL8152_UNPLUG, &tp->flags))
                return;
 
@@ -4975,6 +4985,15 @@ static void rtl8153_up(struct r8152 *tp)
        r8153_u2p3en(tp, false);
        r8153_aldps_en(tp, false);
        r8153_first_init(tp);
+
+       ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_CONFIG6);
+       ocp_data |= LANWAKE_CLR_EN;
+       ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CONFIG6, ocp_data);
+
+       ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_LWAKE_CTRL_REG);
+       ocp_data &= ~LANWAKE_PIN;
+       ocp_write_byte(tp, MCU_TYPE_PLA, PLA_LWAKE_CTRL_REG, ocp_data);
+
        r8153_aldps_en(tp, true);
 
        switch (tp->version) {
@@ -4993,11 +5012,17 @@ static void rtl8153_up(struct r8152 *tp)
 
 static void rtl8153_down(struct r8152 *tp)
 {
+       u32 ocp_data;
+
        if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
                rtl_drop_queued_tx(tp);
                return;
        }
 
+       ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_CONFIG6);
+       ocp_data &= ~LANWAKE_CLR_EN;
+       ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CONFIG6, ocp_data);
+
        r8153_u1u2en(tp, false);
        r8153_u2p3en(tp, false);
        r8153_power_cut_en(tp, false);
@@ -5458,6 +5483,14 @@ static void r8153_init(struct r8152 *tp)
        r8153_mac_clk_spd(tp, false);
        usb_enable_lpm(tp->udev);
 
+       ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_CONFIG6);
+       ocp_data |= LANWAKE_CLR_EN;
+       ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CONFIG6, ocp_data);
+
+       ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_LWAKE_CTRL_REG);
+       ocp_data &= ~LANWAKE_PIN;
+       ocp_write_byte(tp, MCU_TYPE_PLA, PLA_LWAKE_CTRL_REG, ocp_data);
+
        /* rx aggregation */
        ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL);
        ocp_data &= ~(RX_AGG_DISABLE | RX_ZERO_EN);