Commit d70b1137 authored by hayeswang's avatar hayeswang Committed by David S. Miller

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: default avatarHayes Wang <hayeswang@realtek.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b49fe362
...@@ -2019,7 +2019,7 @@ static int rtl8153_enable(struct r8152 *tp) ...@@ -2019,7 +2019,7 @@ static int rtl8153_enable(struct r8152 *tp)
return rtl_enable(tp); return rtl_enable(tp);
} }
static void rtl8152_disable(struct r8152 *tp) static void rtl_disable(struct r8152 *tp)
{ {
u32 ocp_data; u32 ocp_data;
int i; int i;
...@@ -2232,6 +2232,13 @@ static inline void r8152b_enable_aldps(struct r8152 *tp) ...@@ -2232,6 +2232,13 @@ static inline void r8152b_enable_aldps(struct r8152 *tp)
LINKENA | DIS_SDSAVE); LINKENA | DIS_SDSAVE);
} }
static void rtl8152_disable(struct r8152 *tp)
{
r8152b_disable_aldps(tp);
rtl_disable(tp);
r8152b_enable_aldps(tp);
}
static void r8152b_hw_phy_cfg(struct r8152 *tp) static void r8152b_hw_phy_cfg(struct r8152 *tp)
{ {
u16 data; u16 data;
...@@ -2242,11 +2249,8 @@ static void r8152b_hw_phy_cfg(struct r8152 *tp) ...@@ -2242,11 +2249,8 @@ static void r8152b_hw_phy_cfg(struct r8152 *tp)
r8152_mdio_write(tp, MII_BMCR, data); r8152_mdio_write(tp, MII_BMCR, data);
} }
r8152b_disable_aldps(tp);
rtl_clear_bp(tp); rtl_clear_bp(tp);
r8152b_enable_aldps(tp);
set_bit(PHY_RESET, &tp->flags); set_bit(PHY_RESET, &tp->flags);
} }
...@@ -2255,9 +2259,6 @@ static void r8152b_exit_oob(struct r8152 *tp) ...@@ -2255,9 +2259,6 @@ static void r8152b_exit_oob(struct r8152 *tp)
u32 ocp_data; u32 ocp_data;
int i; int i;
if (test_bit(RTL8152_UNPLUG, &tp->flags))
return;
ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR);
ocp_data &= ~RCR_ACPT_ALL; ocp_data &= ~RCR_ACPT_ALL;
ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data);
...@@ -2347,7 +2348,7 @@ static void r8152b_enter_oob(struct r8152 *tp) ...@@ -2347,7 +2348,7 @@ static void r8152b_enter_oob(struct r8152 *tp)
ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL1, RXFIFO_THR2_OOB); ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL1, RXFIFO_THR2_OOB);
ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL2, RXFIFO_THR3_OOB); ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL2, RXFIFO_THR3_OOB);
rtl8152_disable(tp); rtl_disable(tp);
for (i = 0; i < 1000; i++) { for (i = 0; i < 1000; i++) {
ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); 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,9 +2486,6 @@ static void r8153_first_init(struct r8152 *tp)
u32 ocp_data; u32 ocp_data;
int i; int i;
if (test_bit(RTL8152_UNPLUG, &tp->flags))
return;
rxdy_gated_en(tp, true); rxdy_gated_en(tp, true);
r8153_teredo_off(tp); r8153_teredo_off(tp);
...@@ -2560,7 +2558,7 @@ static void r8153_enter_oob(struct r8152 *tp) ...@@ -2560,7 +2558,7 @@ static void r8153_enter_oob(struct r8152 *tp)
ocp_data &= ~NOW_IS_OOB; ocp_data &= ~NOW_IS_OOB;
ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data);
rtl8152_disable(tp); rtl_disable(tp);
for (i = 0; i < 1000; i++) { for (i = 0; i < 1000; i++) {
ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); 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,6 +2622,13 @@ static void r8153_enable_aldps(struct r8152 *tp)
ocp_reg_write(tp, OCP_POWER_CFG, data); ocp_reg_write(tp, OCP_POWER_CFG, data);
} }
static void rtl8153_disable(struct r8152 *tp)
{
r8153_disable_aldps(tp);
rtl_disable(tp);
r8153_enable_aldps(tp);
}
static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u16 speed, u8 duplex) static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u16 speed, u8 duplex)
{ {
u16 bmcr, anar, gbcr; u16 bmcr, anar, gbcr;
...@@ -2714,6 +2719,16 @@ static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u16 speed, u8 duplex) ...@@ -2714,6 +2719,16 @@ static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u16 speed, u8 duplex)
return ret; return ret;
} }
static void rtl8152_up(struct r8152 *tp)
{
if (test_bit(RTL8152_UNPLUG, &tp->flags))
return;
r8152b_disable_aldps(tp);
r8152b_exit_oob(tp);
r8152b_enable_aldps(tp);
}
static void rtl8152_down(struct r8152 *tp) static void rtl8152_down(struct r8152 *tp)
{ {
if (test_bit(RTL8152_UNPLUG, &tp->flags)) { if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
...@@ -2727,6 +2742,16 @@ static void rtl8152_down(struct r8152 *tp) ...@@ -2727,6 +2742,16 @@ static void rtl8152_down(struct r8152 *tp)
r8152b_enable_aldps(tp); r8152b_enable_aldps(tp);
} }
static void rtl8153_up(struct r8152 *tp)
{
if (test_bit(RTL8152_UNPLUG, &tp->flags))
return;
r8153_disable_aldps(tp);
r8153_first_init(tp);
r8153_enable_aldps(tp);
}
static void rtl8153_down(struct r8152 *tp) static void rtl8153_down(struct r8152 *tp)
{ {
if (test_bit(RTL8152_UNPLUG, &tp->flags)) { if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
...@@ -2946,6 +2971,8 @@ static void r8152b_init(struct r8152 *tp) ...@@ -2946,6 +2971,8 @@ static void r8152b_init(struct r8152 *tp)
if (test_bit(RTL8152_UNPLUG, &tp->flags)) if (test_bit(RTL8152_UNPLUG, &tp->flags))
return; return;
r8152b_disable_aldps(tp);
if (tp->version == RTL_VER_01) { if (tp->version == RTL_VER_01) {
ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE); ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE);
ocp_data &= ~LED_MODE_MASK; ocp_data &= ~LED_MODE_MASK;
...@@ -2984,6 +3011,7 @@ static void r8153_init(struct r8152 *tp) ...@@ -2984,6 +3011,7 @@ static void r8153_init(struct r8152 *tp)
if (test_bit(RTL8152_UNPLUG, &tp->flags)) if (test_bit(RTL8152_UNPLUG, &tp->flags))
return; return;
r8153_disable_aldps(tp);
r8153_u1u2en(tp, false); r8153_u1u2en(tp, false);
for (i = 0; i < 500; i++) { 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,7 +3420,7 @@ static int rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id)
ops->init = r8152b_init; ops->init = r8152b_init;
ops->enable = rtl8152_enable; ops->enable = rtl8152_enable;
ops->disable = rtl8152_disable; ops->disable = rtl8152_disable;
ops->up = r8152b_exit_oob; ops->up = rtl8152_up;
ops->down = rtl8152_down; ops->down = rtl8152_down;
ops->unload = rtl8152_unload; ops->unload = rtl8152_unload;
ret = 0; ret = 0;
...@@ -3400,8 +3428,8 @@ static int rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id) ...@@ -3400,8 +3428,8 @@ static int rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id)
case PRODUCT_ID_RTL8153: case PRODUCT_ID_RTL8153:
ops->init = r8153_init; ops->init = r8153_init;
ops->enable = rtl8153_enable; ops->enable = rtl8153_enable;
ops->disable = rtl8152_disable; ops->disable = rtl8153_disable;
ops->up = r8153_first_init; ops->up = rtl8153_up;
ops->down = rtl8153_down; ops->down = rtl8153_down;
ops->unload = rtl8153_unload; ops->unload = rtl8153_unload;
ret = 0; ret = 0;
...@@ -3416,8 +3444,8 @@ static int rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id) ...@@ -3416,8 +3444,8 @@ static int rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id)
case PRODUCT_ID_SAMSUNG: case PRODUCT_ID_SAMSUNG:
ops->init = r8153_init; ops->init = r8153_init;
ops->enable = rtl8153_enable; ops->enable = rtl8153_enable;
ops->disable = rtl8152_disable; ops->disable = rtl8153_disable;
ops->up = r8153_first_init; ops->up = rtl8153_up;
ops->down = rtl8153_down; ops->down = rtl8153_down;
ops->unload = rtl8153_unload; ops->unload = rtl8153_unload;
ret = 0; ret = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment