kernel: backport eth_addr_add()
[openwrt/openwrt.git] / target / linux / generic / backport-5.10 / 789-v5.12-r8152-spilt-rtl_set_eee_plus-and-r8153b_green_en.patch
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
5
6 commit 40fa7568ac230446d888b7ad402cff9e20fe3ad5 upstream.
7
8 Add rtl_eee_plus_en() and rtl_green_en().
9
10 Signed-off-by: Hayes Wang <hayeswang@realtek.com>
11 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
12 ---
13 drivers/net/usb/r8152.c | 43 ++++++++++++++++++++++++++---------------
14 1 file changed, 27 insertions(+), 16 deletions(-)
15
16 --- a/drivers/net/usb/r8152.c
17 +++ b/drivers/net/usb/r8152.c
18 @@ -2634,21 +2634,24 @@ static inline u8 rtl8152_get_speed(struc
19 return ocp_read_byte(tp, MCU_TYPE_PLA, PLA_PHYSTATUS);
20 }
21
22 -static void rtl_set_eee_plus(struct r8152 *tp)
23 +static void rtl_eee_plus_en(struct r8152 *tp, bool enable)
24 {
25 u32 ocp_data;
26 - u8 speed;
27
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);
32 + if (enable)
33 ocp_data |= EEEP_CR_EEEP_TX;
34 - ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR, ocp_data);
35 - } else {
36 - ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR);
37 + else
38 ocp_data &= ~EEEP_CR_EEEP_TX;
39 - ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR, ocp_data);
40 - }
41 + ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR, ocp_data);
42 +}
43 +
44 +static void rtl_set_eee_plus(struct r8152 *tp)
45 +{
46 + if (rtl8152_get_speed(tp) & _10bps)
47 + rtl_eee_plus_en(tp, true);
48 + else
49 + rtl_eee_plus_en(tp, false);
50 }
51
52 static void rxdy_gated_en(struct r8152 *tp, bool enable)
53 @@ -3129,10 +3132,22 @@ static void r8153b_ups_flags(struct r815
54 ocp_write_dword(tp, MCU_TYPE_USB, USB_UPS_FLAGS, ups_flags);
55 }
56
57 -static void r8153b_green_en(struct r8152 *tp, bool enable)
58 +static void rtl_green_en(struct r8152 *tp, bool enable)
59 {
60 u16 data;
61
62 + data = sram_read(tp, SRAM_GREEN_CFG);
63 + if (enable)
64 + data |= GREEN_ETH_EN;
65 + else
66 + data &= ~GREEN_ETH_EN;
67 + sram_write(tp, SRAM_GREEN_CFG, data);
68 +
69 + tp->ups_info.green = enable;
70 +}
71 +
72 +static void r8153b_green_en(struct r8152 *tp, bool enable)
73 +{
74 if (enable) {
75 sram_write(tp, 0x8045, 0); /* 10M abiq&ldvbias */
76 sram_write(tp, 0x804d, 0x1222); /* 100M short abiq&ldvbias */
77 @@ -3143,11 +3158,7 @@ static void r8153b_green_en(struct r8152
78 sram_write(tp, 0x805d, 0x2444); /* 1000M short abiq&ldvbias */
79 }
80
81 - data = sram_read(tp, SRAM_GREEN_CFG);
82 - data |= GREEN_ETH_EN;
83 - sram_write(tp, SRAM_GREEN_CFG, data);
84 -
85 - tp->ups_info.green = enable;
86 + rtl_green_en(tp, true);
87 }
88
89 static u16 r8153_phy_status(struct r8152 *tp, u16 desired)