Skip to content

Commit d70b113

Browse files
hayesorzdavem330
authored andcommitted
r8152: disable ALDPS
If the hw is in ALDPS mode, the hw may have no response for accessing the most registers. Therefore, the ALDPS should be disabled before accessing the hw in rtl_ops.init(), rtl_ops.disable(), rtl_ops.up(), and rtl_ops.down(). Regardless of rtl_ops.enable(), because the hw wouldn't enter ALDPS mode when linking on. The hw would enter the ALDPS mode after several seconds when link down occurs and the ALDPS is enabled. Signed-off-by: Hayes Wang <hayeswang@realtek.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b49fe36 commit d70b113

File tree

1 file changed

+45
-17
lines changed

1 file changed

+45
-17
lines changed

drivers/net/usb/r8152.c

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,7 +2019,7 @@ static int rtl8153_enable(struct r8152 *tp)
20192019
return rtl_enable(tp);
20202020
}
20212021

2022-
static void rtl8152_disable(struct r8152 *tp)
2022+
static void rtl_disable(struct r8152 *tp)
20232023
{
20242024
u32 ocp_data;
20252025
int i;
@@ -2232,6 +2232,13 @@ static inline void r8152b_enable_aldps(struct r8152 *tp)
22322232
LINKENA | DIS_SDSAVE);
22332233
}
22342234

2235+
static void rtl8152_disable(struct r8152 *tp)
2236+
{
2237+
r8152b_disable_aldps(tp);
2238+
rtl_disable(tp);
2239+
r8152b_enable_aldps(tp);
2240+
}
2241+
22352242
static void r8152b_hw_phy_cfg(struct r8152 *tp)
22362243
{
22372244
u16 data;
@@ -2242,11 +2249,8 @@ static void r8152b_hw_phy_cfg(struct r8152 *tp)
22422249
r8152_mdio_write(tp, MII_BMCR, data);
22432250
}
22442251

2245-
r8152b_disable_aldps(tp);
2246-
22472252
rtl_clear_bp(tp);
22482253

2249-
r8152b_enable_aldps(tp);
22502254
set_bit(PHY_RESET, &tp->flags);
22512255
}
22522256

@@ -2255,9 +2259,6 @@ static void r8152b_exit_oob(struct r8152 *tp)
22552259
u32 ocp_data;
22562260
int i;
22572261

2258-
if (test_bit(RTL8152_UNPLUG, &tp->flags))
2259-
return;
2260-
22612262
ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR);
22622263
ocp_data &= ~RCR_ACPT_ALL;
22632264
ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data);
@@ -2347,7 +2348,7 @@ static void r8152b_enter_oob(struct r8152 *tp)
23472348
ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL1, RXFIFO_THR2_OOB);
23482349
ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL2, RXFIFO_THR3_OOB);
23492350

2350-
rtl8152_disable(tp);
2351+
rtl_disable(tp);
23512352

23522353
for (i = 0; i < 1000; i++) {
23532354
ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL);
@@ -2485,9 +2486,6 @@ static void r8153_first_init(struct r8152 *tp)
24852486
u32 ocp_data;
24862487
int i;
24872488

2488-
if (test_bit(RTL8152_UNPLUG, &tp->flags))
2489-
return;
2490-
24912489
rxdy_gated_en(tp, true);
24922490
r8153_teredo_off(tp);
24932491

@@ -2560,7 +2558,7 @@ static void r8153_enter_oob(struct r8152 *tp)
25602558
ocp_data &= ~NOW_IS_OOB;
25612559
ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data);
25622560

2563-
rtl8152_disable(tp);
2561+
rtl_disable(tp);
25642562

25652563
for (i = 0; i < 1000; i++) {
25662564
ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL);
@@ -2624,6 +2622,13 @@ static void r8153_enable_aldps(struct r8152 *tp)
26242622
ocp_reg_write(tp, OCP_POWER_CFG, data);
26252623
}
26262624

2625+
static void rtl8153_disable(struct r8152 *tp)
2626+
{
2627+
r8153_disable_aldps(tp);
2628+
rtl_disable(tp);
2629+
r8153_enable_aldps(tp);
2630+
}
2631+
26272632
static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u16 speed, u8 duplex)
26282633
{
26292634
u16 bmcr, anar, gbcr;
@@ -2714,6 +2719,16 @@ static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u16 speed, u8 duplex)
27142719
return ret;
27152720
}
27162721

2722+
static void rtl8152_up(struct r8152 *tp)
2723+
{
2724+
if (test_bit(RTL8152_UNPLUG, &tp->flags))
2725+
return;
2726+
2727+
r8152b_disable_aldps(tp);
2728+
r8152b_exit_oob(tp);
2729+
r8152b_enable_aldps(tp);
2730+
}
2731+
27172732
static void rtl8152_down(struct r8152 *tp)
27182733
{
27192734
if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
@@ -2727,6 +2742,16 @@ static void rtl8152_down(struct r8152 *tp)
27272742
r8152b_enable_aldps(tp);
27282743
}
27292744

2745+
static void rtl8153_up(struct r8152 *tp)
2746+
{
2747+
if (test_bit(RTL8152_UNPLUG, &tp->flags))
2748+
return;
2749+
2750+
r8153_disable_aldps(tp);
2751+
r8153_first_init(tp);
2752+
r8153_enable_aldps(tp);
2753+
}
2754+
27302755
static void rtl8153_down(struct r8152 *tp)
27312756
{
27322757
if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
@@ -2946,6 +2971,8 @@ static void r8152b_init(struct r8152 *tp)
29462971
if (test_bit(RTL8152_UNPLUG, &tp->flags))
29472972
return;
29482973

2974+
r8152b_disable_aldps(tp);
2975+
29492976
if (tp->version == RTL_VER_01) {
29502977
ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE);
29512978
ocp_data &= ~LED_MODE_MASK;
@@ -2984,6 +3011,7 @@ static void r8153_init(struct r8152 *tp)
29843011
if (test_bit(RTL8152_UNPLUG, &tp->flags))
29853012
return;
29863013

3014+
r8153_disable_aldps(tp);
29873015
r8153_u1u2en(tp, false);
29883016

29893017
for (i = 0; i < 500; i++) {
@@ -3392,16 +3420,16 @@ static int rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id)
33923420
ops->init = r8152b_init;
33933421
ops->enable = rtl8152_enable;
33943422
ops->disable = rtl8152_disable;
3395-
ops->up = r8152b_exit_oob;
3423+
ops->up = rtl8152_up;
33963424
ops->down = rtl8152_down;
33973425
ops->unload = rtl8152_unload;
33983426
ret = 0;
33993427
break;
34003428
case PRODUCT_ID_RTL8153:
34013429
ops->init = r8153_init;
34023430
ops->enable = rtl8153_enable;
3403-
ops->disable = rtl8152_disable;
3404-
ops->up = r8153_first_init;
3431+
ops->disable = rtl8153_disable;
3432+
ops->up = rtl8153_up;
34053433
ops->down = rtl8153_down;
34063434
ops->unload = rtl8153_unload;
34073435
ret = 0;
@@ -3416,8 +3444,8 @@ static int rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id)
34163444
case PRODUCT_ID_SAMSUNG:
34173445
ops->init = r8153_init;
34183446
ops->enable = rtl8153_enable;
3419-
ops->disable = rtl8152_disable;
3420-
ops->up = r8153_first_init;
3447+
ops->disable = rtl8153_disable;
3448+
ops->up = rtl8153_up;
34213449
ops->down = rtl8153_down;
34223450
ops->unload = rtl8153_unload;
34233451
ret = 0;

0 commit comments

Comments
 (0)