1 From 260814de2d6cb958767785ffcb2e76915d1be32b Mon Sep 17 00:00:00 2001
2 From: Hayes Wang <hayeswang@realtek.com>
3 Date: Fri, 19 Feb 2021 17:04:43 +0800
4 Subject: [PATCH] r8152: spilt rtl_set_eee_plus and r8153b_green_en
6 commit 40fa7568ac230446d888b7ad402cff9e20fe3ad5 upstream.
8 Add rtl_eee_plus_en() and rtl_green_en().
10 Signed-off-by: Hayes Wang <hayeswang@realtek.com>
11 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
13 drivers/net/usb/r8152.c | 43 ++++++++++++++++++++++++++---------------
14 1 file changed, 27 insertions(+), 16 deletions(-)
16 --- a/drivers/net/usb/r8152.c
17 +++ b/drivers/net/usb/r8152.c
18 @@ -2632,21 +2632,24 @@ static inline u8 rtl8152_get_speed(struc
19 return ocp_read_byte(tp, MCU_TYPE_PLA, PLA_PHYSTATUS);
22 -static void rtl_set_eee_plus(struct r8152 *tp)
23 +static void rtl_eee_plus_en(struct r8152 *tp, bool enable)
28 - speed = rtl8152_get_speed(tp);
29 - if (speed & _10bps) {
30 - ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR);
31 + ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR);
33 ocp_data |= EEEP_CR_EEEP_TX;
34 - ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR, ocp_data);
36 - ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR);
38 ocp_data &= ~EEEP_CR_EEEP_TX;
39 - ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR, ocp_data);
41 + ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR, ocp_data);
44 +static void rtl_set_eee_plus(struct r8152 *tp)
46 + if (rtl8152_get_speed(tp) & _10bps)
47 + rtl_eee_plus_en(tp, true);
49 + rtl_eee_plus_en(tp, false);
52 static void rxdy_gated_en(struct r8152 *tp, bool enable)
53 @@ -3127,10 +3130,22 @@ static void r8153b_ups_flags(struct r815
54 ocp_write_dword(tp, MCU_TYPE_USB, USB_UPS_FLAGS, ups_flags);
57 -static void r8153b_green_en(struct r8152 *tp, bool enable)
58 +static void rtl_green_en(struct r8152 *tp, bool enable)
62 + data = sram_read(tp, SRAM_GREEN_CFG);
64 + data |= GREEN_ETH_EN;
66 + data &= ~GREEN_ETH_EN;
67 + sram_write(tp, SRAM_GREEN_CFG, data);
69 + tp->ups_info.green = enable;
72 +static void r8153b_green_en(struct r8152 *tp, bool enable)
75 sram_write(tp, 0x8045, 0); /* 10M abiq&ldvbias */
76 sram_write(tp, 0x804d, 0x1222); /* 100M short abiq&ldvbias */
77 @@ -3141,11 +3156,7 @@ static void r8153b_green_en(struct r8152
78 sram_write(tp, 0x805d, 0x2444); /* 1000M short abiq&ldvbias */
81 - data = sram_read(tp, SRAM_GREEN_CFG);
82 - data |= GREEN_ETH_EN;
83 - sram_write(tp, SRAM_GREEN_CFG, data);
85 - tp->ups_info.green = enable;
86 + rtl_green_en(tp, true);
89 static u16 r8153_phy_status(struct r8152 *tp, u16 desired)