aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorhayeswang <hayeswang@realtek.com>2014-09-19 03:17:18 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-22 14:54:19 -0400
commitd70b1137233836be1d71bd53ae60bec6c9e7203c (patch)
tree3114e8989f90c1875f32391c24646f3e453dc10e /drivers/net
parentb49fe36208b45f76dfbcfcd3afd952a33fa9f5ce (diff)
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>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/usb/r8152.c62
1 files changed, 45 insertions, 17 deletions
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 87f710476217..74760e8143e3 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -2019,7 +2019,7 @@ static int rtl8153_enable(struct r8152 *tp)
2019 return rtl_enable(tp); 2019 return rtl_enable(tp);
2020} 2020}
2021 2021
2022static void rtl8152_disable(struct r8152 *tp) 2022static void rtl_disable(struct r8152 *tp)
2023{ 2023{
2024 u32 ocp_data; 2024 u32 ocp_data;
2025 int i; 2025 int i;
@@ -2232,6 +2232,13 @@ static inline void r8152b_enable_aldps(struct r8152 *tp)
2232 LINKENA | DIS_SDSAVE); 2232 LINKENA | DIS_SDSAVE);
2233} 2233}
2234 2234
2235static void rtl8152_disable(struct r8152 *tp)
2236{
2237 r8152b_disable_aldps(tp);
2238 rtl_disable(tp);
2239 r8152b_enable_aldps(tp);
2240}
2241
2235static void r8152b_hw_phy_cfg(struct r8152 *tp) 2242static void r8152b_hw_phy_cfg(struct r8152 *tp)
2236{ 2243{
2237 u16 data; 2244 u16 data;
@@ -2242,11 +2249,8 @@ static void r8152b_hw_phy_cfg(struct r8152 *tp)
2242 r8152_mdio_write(tp, MII_BMCR, data); 2249 r8152_mdio_write(tp, MII_BMCR, data);
2243 } 2250 }
2244 2251
2245 r8152b_disable_aldps(tp);
2246
2247 rtl_clear_bp(tp); 2252 rtl_clear_bp(tp);
2248 2253
2249 r8152b_enable_aldps(tp);
2250 set_bit(PHY_RESET, &tp->flags); 2254 set_bit(PHY_RESET, &tp->flags);
2251} 2255}
2252 2256
@@ -2255,9 +2259,6 @@ static void r8152b_exit_oob(struct r8152 *tp)
2255 u32 ocp_data; 2259 u32 ocp_data;
2256 int i; 2260 int i;
2257 2261
2258 if (test_bit(RTL8152_UNPLUG, &tp->flags))
2259 return;
2260
2261 ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); 2262 ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR);
2262 ocp_data &= ~RCR_ACPT_ALL; 2263 ocp_data &= ~RCR_ACPT_ALL;
2263 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); 2264 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data);
@@ -2347,7 +2348,7 @@ static void r8152b_enter_oob(struct r8152 *tp)
2347 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL1, RXFIFO_THR2_OOB); 2348 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL1, RXFIFO_THR2_OOB);
2348 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL2, RXFIFO_THR3_OOB); 2349 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL2, RXFIFO_THR3_OOB);
2349 2350
2350 rtl8152_disable(tp); 2351 rtl_disable(tp);
2351 2352
2352 for (i = 0; i < 1000; i++) { 2353 for (i = 0; i < 1000; i++) {
2353 ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); 2354 ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL);
@@ -2485,9 +2486,6 @@ static void r8153_first_init(struct r8152 *tp)
2485 u32 ocp_data; 2486 u32 ocp_data;
2486 int i; 2487 int i;
2487 2488
2488 if (test_bit(RTL8152_UNPLUG, &tp->flags))
2489 return;
2490
2491 rxdy_gated_en(tp, true); 2489 rxdy_gated_en(tp, true);
2492 r8153_teredo_off(tp); 2490 r8153_teredo_off(tp);
2493 2491
@@ -2560,7 +2558,7 @@ static void r8153_enter_oob(struct r8152 *tp)
2560 ocp_data &= ~NOW_IS_OOB; 2558 ocp_data &= ~NOW_IS_OOB;
2561 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); 2559 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data);
2562 2560
2563 rtl8152_disable(tp); 2561 rtl_disable(tp);
2564 2562
2565 for (i = 0; i < 1000; i++) { 2563 for (i = 0; i < 1000; i++) {
2566 ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); 2564 ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL);
@@ -2624,6 +2622,13 @@ static void r8153_enable_aldps(struct r8152 *tp)
2624 ocp_reg_write(tp, OCP_POWER_CFG, data); 2622 ocp_reg_write(tp, OCP_POWER_CFG, data);
2625} 2623}
2626 2624
2625static void rtl8153_disable(struct r8152 *tp)
2626{
2627 r8153_disable_aldps(tp);
2628 rtl_disable(tp);
2629 r8153_enable_aldps(tp);
2630}
2631
2627static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u16 speed, u8 duplex) 2632static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u16 speed, u8 duplex)
2628{ 2633{
2629 u16 bmcr, anar, gbcr; 2634 u16 bmcr, anar, gbcr;
@@ -2714,6 +2719,16 @@ out:
2714 return ret; 2719 return ret;
2715} 2720}
2716 2721
2722static 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
2717static void rtl8152_down(struct r8152 *tp) 2732static void rtl8152_down(struct r8152 *tp)
2718{ 2733{
2719 if (test_bit(RTL8152_UNPLUG, &tp->flags)) { 2734 if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
@@ -2727,6 +2742,16 @@ static void rtl8152_down(struct r8152 *tp)
2727 r8152b_enable_aldps(tp); 2742 r8152b_enable_aldps(tp);
2728} 2743}
2729 2744
2745static 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
2730static void rtl8153_down(struct r8152 *tp) 2755static void rtl8153_down(struct r8152 *tp)
2731{ 2756{
2732 if (test_bit(RTL8152_UNPLUG, &tp->flags)) { 2757 if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
@@ -2946,6 +2971,8 @@ static void r8152b_init(struct r8152 *tp)
2946 if (test_bit(RTL8152_UNPLUG, &tp->flags)) 2971 if (test_bit(RTL8152_UNPLUG, &tp->flags))
2947 return; 2972 return;
2948 2973
2974 r8152b_disable_aldps(tp);
2975
2949 if (tp->version == RTL_VER_01) { 2976 if (tp->version == RTL_VER_01) {
2950 ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE); 2977 ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE);
2951 ocp_data &= ~LED_MODE_MASK; 2978 ocp_data &= ~LED_MODE_MASK;
@@ -2984,6 +3011,7 @@ static void r8153_init(struct r8152 *tp)
2984 if (test_bit(RTL8152_UNPLUG, &tp->flags)) 3011 if (test_bit(RTL8152_UNPLUG, &tp->flags))
2985 return; 3012 return;
2986 3013
3014 r8153_disable_aldps(tp);
2987 r8153_u1u2en(tp, false); 3015 r8153_u1u2en(tp, false);
2988 3016
2989 for (i = 0; i < 500; i++) { 3017 for (i = 0; i < 500; i++) {
@@ -3392,7 +3420,7 @@ static int rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id)
3392 ops->init = r8152b_init; 3420 ops->init = r8152b_init;
3393 ops->enable = rtl8152_enable; 3421 ops->enable = rtl8152_enable;
3394 ops->disable = rtl8152_disable; 3422 ops->disable = rtl8152_disable;
3395 ops->up = r8152b_exit_oob; 3423 ops->up = rtl8152_up;
3396 ops->down = rtl8152_down; 3424 ops->down = rtl8152_down;
3397 ops->unload = rtl8152_unload; 3425 ops->unload = rtl8152_unload;
3398 ret = 0; 3426 ret = 0;
@@ -3400,8 +3428,8 @@ static int rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id)
3400 case PRODUCT_ID_RTL8153: 3428 case PRODUCT_ID_RTL8153:
3401 ops->init = r8153_init; 3429 ops->init = r8153_init;
3402 ops->enable = rtl8153_enable; 3430 ops->enable = rtl8153_enable;
3403 ops->disable = rtl8152_disable; 3431 ops->disable = rtl8153_disable;
3404 ops->up = r8153_first_init; 3432 ops->up = rtl8153_up;
3405 ops->down = rtl8153_down; 3433 ops->down = rtl8153_down;
3406 ops->unload = rtl8153_unload; 3434 ops->unload = rtl8153_unload;
3407 ret = 0; 3435 ret = 0;
@@ -3416,8 +3444,8 @@ static int rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id)
3416 case PRODUCT_ID_SAMSUNG: 3444 case PRODUCT_ID_SAMSUNG:
3417 ops->init = r8153_init; 3445 ops->init = r8153_init;
3418 ops->enable = rtl8153_enable; 3446 ops->enable = rtl8153_enable;
3419 ops->disable = rtl8152_disable; 3447 ops->disable = rtl8153_disable;
3420 ops->up = r8153_first_init; 3448 ops->up = rtl8153_up;
3421 ops->down = rtl8153_down; 3449 ops->down = rtl8153_down;
3422 ops->unload = rtl8153_unload; 3450 ops->unload = rtl8153_unload;
3423 ret = 0; 3451 ret = 0;