| From 05ee3af747a7019e321a7b1d78dd9d61a4a8c31c Mon Sep 17 00:00:00 2001 |
| From: Hayes Wang <hayeswang@realtek.com> |
| Date: Wed, 22 Jan 2020 16:02:12 +0800 |
| Subject: [PATCH] r8152: avoid the MCU to clear the lanwake |
| |
| commit 19813162895a696c5814d76e5f8fb6203d70f6e0 upstream. |
| |
| 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> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c |
| index 700a0914288a..881be35eba8d 100644 |
| --- a/drivers/net/usb/r8152.c |
| +++ b/drivers/net/usb/r8152.c |
| @@ -59,6 +59,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 |
| @@ -86,6 +87,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 |
| @@ -282,6 +284,9 @@ |
| #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 |
| @@ -338,6 +343,9 @@ |
| /* PLA_BOOT_CTRL */ |
| #define AUTOLOAD_DONE 0x0002 |
| |
| +/* PLA_LWAKE_CTRL_REG */ |
| +#define LANWAKE_PIN BIT(7) |
| + |
| /* USB_USB2PHY */ |
| #define USB2PHY_SUSPEND 0x0001 |
| #define USB2PHY_L1 0x0002 |
| @@ -3716,6 +3724,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; |
| |
| @@ -3723,6 +3733,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) { |
| @@ -3741,11 +3760,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); |
| @@ -4172,6 +4197,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); |
| -- |
| 2.7.4 |
| |