summaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorHayes Wang <hayeswang@realtek.com>2019-07-01 03:53:19 -0400
committerDavid S. Miller <davem@davemloft.net>2019-07-01 22:31:57 -0400
commit13e04fbf0b974df6fbf646799fc49f373c9b52d0 (patch)
treeb255145fa1435838697f0f333713921ffdbb8e54 /drivers/net/usb
parentacd3e96d53a24d219f720ed4012b62723ae05da1 (diff)
r8152: fix the setting of detecting the linking change for runtime suspend
1. Rename r8153b_queue_wake() to r8153_queue_wake(). 2. Correct the setting. The enable bit should be 0xd38c bit 0. Besides, the 0xd38a bit 0 and 0xd398 bit 8 have to be cleared for both enabled and disabled. Signed-off-by: Hayes Wang <hayeswang@realtek.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/r8152.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index e0dcb681cfe5..101d1325f3f1 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -53,6 +53,9 @@
53#define PAL_BDC_CR 0xd1a0 53#define PAL_BDC_CR 0xd1a0
54#define PLA_TEREDO_TIMER 0xd2cc 54#define PLA_TEREDO_TIMER 0xd2cc
55#define PLA_REALWOW_TIMER 0xd2e8 55#define PLA_REALWOW_TIMER 0xd2e8
56#define PLA_SUSPEND_FLAG 0xd38a
57#define PLA_INDICATE_FALG 0xd38c
58#define PLA_EXTRA_STATUS 0xd398
56#define PLA_EFUSE_DATA 0xdd00 59#define PLA_EFUSE_DATA 0xdd00
57#define PLA_EFUSE_CMD 0xdd02 60#define PLA_EFUSE_CMD 0xdd02
58#define PLA_LEDSEL 0xdd90 61#define PLA_LEDSEL 0xdd90
@@ -336,6 +339,15 @@
336/* PLA_BOOT_CTRL */ 339/* PLA_BOOT_CTRL */
337#define AUTOLOAD_DONE 0x0002 340#define AUTOLOAD_DONE 0x0002
338 341
342/* PLA_SUSPEND_FLAG */
343#define LINK_CHG_EVENT BIT(0)
344
345/* PLA_INDICATE_FALG */
346#define UPCOMING_RUNTIME_D3 BIT(0)
347
348/* PLA_EXTRA_STATUS */
349#define LINK_CHANGE_FLAG BIT(8)
350
339/* USB_USB2PHY */ 351/* USB_USB2PHY */
340#define USB2PHY_SUSPEND 0x0001 352#define USB2PHY_SUSPEND 0x0001
341#define USB2PHY_L1 0x0002 353#define USB2PHY_L1 0x0002
@@ -2806,20 +2818,24 @@ static void r8153b_power_cut_en(struct r8152 *tp, bool enable)
2806 ocp_write_word(tp, MCU_TYPE_USB, USB_MISC_0, ocp_data); 2818 ocp_write_word(tp, MCU_TYPE_USB, USB_MISC_0, ocp_data);
2807} 2819}
2808 2820
2809static void r8153b_queue_wake(struct r8152 *tp, bool enable) 2821static void r8153_queue_wake(struct r8152 *tp, bool enable)
2810{ 2822{
2811 u32 ocp_data; 2823 u32 ocp_data;
2812 2824
2813 ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, 0xd38a); 2825 ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_INDICATE_FALG);
2814 if (enable) 2826 if (enable)
2815 ocp_data |= BIT(0); 2827 ocp_data |= UPCOMING_RUNTIME_D3;
2816 else 2828 else
2817 ocp_data &= ~BIT(0); 2829 ocp_data &= ~UPCOMING_RUNTIME_D3;
2818 ocp_write_byte(tp, MCU_TYPE_PLA, 0xd38a, ocp_data); 2830 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_INDICATE_FALG, ocp_data);
2831
2832 ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_SUSPEND_FLAG);
2833 ocp_data &= ~LINK_CHG_EVENT;
2834 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_SUSPEND_FLAG, ocp_data);
2819 2835
2820 ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, 0xd38c); 2836 ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EXTRA_STATUS);
2821 ocp_data &= ~BIT(0); 2837 ocp_data &= ~LINK_CHANGE_FLAG;
2822 ocp_write_byte(tp, MCU_TYPE_PLA, 0xd38c, ocp_data); 2838 ocp_write_word(tp, MCU_TYPE_PLA, PLA_EXTRA_STATUS, ocp_data);
2823} 2839}
2824 2840
2825static bool rtl_can_wakeup(struct r8152 *tp) 2841static bool rtl_can_wakeup(struct r8152 *tp)
@@ -2887,14 +2903,14 @@ static void rtl8153_runtime_enable(struct r8152 *tp, bool enable)
2887static void rtl8153b_runtime_enable(struct r8152 *tp, bool enable) 2903static void rtl8153b_runtime_enable(struct r8152 *tp, bool enable)
2888{ 2904{
2889 if (enable) { 2905 if (enable) {
2890 r8153b_queue_wake(tp, true); 2906 r8153_queue_wake(tp, true);
2891 r8153b_u1u2en(tp, false); 2907 r8153b_u1u2en(tp, false);
2892 r8153_u2p3en(tp, false); 2908 r8153_u2p3en(tp, false);
2893 rtl_runtime_suspend_enable(tp, true); 2909 rtl_runtime_suspend_enable(tp, true);
2894 r8153b_ups_en(tp, true); 2910 r8153b_ups_en(tp, true);
2895 } else { 2911 } else {
2896 r8153b_ups_en(tp, false); 2912 r8153b_ups_en(tp, false);
2897 r8153b_queue_wake(tp, false); 2913 r8153_queue_wake(tp, false);
2898 rtl_runtime_suspend_enable(tp, false); 2914 rtl_runtime_suspend_enable(tp, false);
2899 r8153_u2p3en(tp, true); 2915 r8153_u2p3en(tp, true);
2900 r8153b_u1u2en(tp, true); 2916 r8153b_u1u2en(tp, true);
@@ -4221,7 +4237,7 @@ static void r8153b_init(struct r8152 *tp)
4221 4237
4222 r8153b_power_cut_en(tp, false); 4238 r8153b_power_cut_en(tp, false);
4223 r8153b_ups_en(tp, false); 4239 r8153b_ups_en(tp, false);
4224 r8153b_queue_wake(tp, false); 4240 r8153_queue_wake(tp, false);
4225 rtl_runtime_suspend_enable(tp, false); 4241 rtl_runtime_suspend_enable(tp, false);
4226 r8153b_u1u2en(tp, true); 4242 r8153b_u1u2en(tp, true);
4227 usb_enable_lpm(tp->udev); 4243 usb_enable_lpm(tp->udev);