Commit f858e2fd authored by David S. Miller's avatar David S. Miller

Merge branch 'r8152-fixes'

Hayes Wang says:

====================
r8152: fix 2.5G devices

v3:
For patch #2, modify the comment.

v2:
For patch #1, Remove inline for fc_pause_on_auto() and fc_pause_off_auto(),
and update the commit message.

For patch #2, define the magic value for OCP register 0xa424.

v1:
These patches are used to fix some issues of RTL8156.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 526f28bd cce8334f
...@@ -199,6 +199,7 @@ ...@@ -199,6 +199,7 @@
#define OCP_EEE_AR 0xa41a #define OCP_EEE_AR 0xa41a
#define OCP_EEE_DATA 0xa41c #define OCP_EEE_DATA 0xa41c
#define OCP_PHY_STATUS 0xa420 #define OCP_PHY_STATUS 0xa420
#define OCP_INTR_EN 0xa424
#define OCP_NCTL_CFG 0xa42c #define OCP_NCTL_CFG 0xa42c
#define OCP_POWER_CFG 0xa430 #define OCP_POWER_CFG 0xa430
#define OCP_EEE_CFG 0xa432 #define OCP_EEE_CFG 0xa432
...@@ -620,6 +621,9 @@ enum spd_duplex { ...@@ -620,6 +621,9 @@ enum spd_duplex {
#define PHY_STAT_LAN_ON 3 #define PHY_STAT_LAN_ON 3
#define PHY_STAT_PWRDN 5 #define PHY_STAT_PWRDN 5
/* OCP_INTR_EN */
#define INTR_SPEED_FORCE BIT(3)
/* OCP_NCTL_CFG */ /* OCP_NCTL_CFG */
#define PGA_RETURN_EN BIT(1) #define PGA_RETURN_EN BIT(1)
...@@ -3023,12 +3027,16 @@ static int rtl_enable(struct r8152 *tp) ...@@ -3023,12 +3027,16 @@ static int rtl_enable(struct r8152 *tp)
ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CR, ocp_data); ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CR, ocp_data);
switch (tp->version) { switch (tp->version) {
case RTL_VER_08: case RTL_VER_01:
case RTL_VER_09: case RTL_VER_02:
case RTL_VER_14: case RTL_VER_03:
r8153b_rx_agg_chg_indicate(tp); case RTL_VER_04:
case RTL_VER_05:
case RTL_VER_06:
case RTL_VER_07:
break; break;
default: default:
r8153b_rx_agg_chg_indicate(tp);
break; break;
} }
...@@ -3082,7 +3090,6 @@ static void r8153_set_rx_early_timeout(struct r8152 *tp) ...@@ -3082,7 +3090,6 @@ static void r8153_set_rx_early_timeout(struct r8152 *tp)
640 / 8); 640 / 8);
ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EXTRA_AGGR_TMR, ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EXTRA_AGGR_TMR,
ocp_data); ocp_data);
r8153b_rx_agg_chg_indicate(tp);
break; break;
default: default:
...@@ -3116,7 +3123,6 @@ static void r8153_set_rx_early_size(struct r8152 *tp) ...@@ -3116,7 +3123,6 @@ static void r8153_set_rx_early_size(struct r8152 *tp)
case RTL_VER_15: case RTL_VER_15:
ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EARLY_SIZE, ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EARLY_SIZE,
ocp_data / 8); ocp_data / 8);
r8153b_rx_agg_chg_indicate(tp);
break; break;
default: default:
WARN_ON_ONCE(1); WARN_ON_ONCE(1);
...@@ -5986,6 +5992,25 @@ static void rtl8153_disable(struct r8152 *tp) ...@@ -5986,6 +5992,25 @@ static void rtl8153_disable(struct r8152 *tp)
r8153_aldps_en(tp, true); r8153_aldps_en(tp, true);
} }
static u32 fc_pause_on_auto(struct r8152 *tp)
{
return (ALIGN(mtu_to_size(tp->netdev->mtu), 1024) + 6 * 1024);
}
static u32 fc_pause_off_auto(struct r8152 *tp)
{
return (ALIGN(mtu_to_size(tp->netdev->mtu), 1024) + 14 * 1024);
}
static void r8156_fc_parameter(struct r8152 *tp)
{
u32 pause_on = tp->fc_pause_on ? tp->fc_pause_on : fc_pause_on_auto(tp);
u32 pause_off = tp->fc_pause_off ? tp->fc_pause_off : fc_pause_off_auto(tp);
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_FULL, pause_on / 16);
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_EMPTY, pause_off / 16);
}
static int rtl8156_enable(struct r8152 *tp) static int rtl8156_enable(struct r8152 *tp)
{ {
u32 ocp_data; u32 ocp_data;
...@@ -5994,6 +6019,7 @@ static int rtl8156_enable(struct r8152 *tp) ...@@ -5994,6 +6019,7 @@ static int rtl8156_enable(struct r8152 *tp)
if (test_bit(RTL8152_UNPLUG, &tp->flags)) if (test_bit(RTL8152_UNPLUG, &tp->flags))
return -ENODEV; return -ENODEV;
r8156_fc_parameter(tp);
set_tx_qlen(tp); set_tx_qlen(tp);
rtl_set_eee_plus(tp); rtl_set_eee_plus(tp);
r8153_set_rx_early_timeout(tp); r8153_set_rx_early_timeout(tp);
...@@ -6025,9 +6051,24 @@ static int rtl8156_enable(struct r8152 *tp) ...@@ -6025,9 +6051,24 @@ static int rtl8156_enable(struct r8152 *tp)
ocp_write_word(tp, MCU_TYPE_USB, USB_L1_CTRL, ocp_data); ocp_write_word(tp, MCU_TYPE_USB, USB_L1_CTRL, ocp_data);
} }
ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_FW_TASK);
ocp_data &= ~FC_PATCH_TASK;
ocp_write_word(tp, MCU_TYPE_USB, USB_FW_TASK, ocp_data);
usleep_range(1000, 2000);
ocp_data |= FC_PATCH_TASK;
ocp_write_word(tp, MCU_TYPE_USB, USB_FW_TASK, ocp_data);
return rtl_enable(tp); return rtl_enable(tp);
} }
static void rtl8156_disable(struct r8152 *tp)
{
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_FULL, 0);
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_EMPTY, 0);
rtl8153_disable(tp);
}
static int rtl8156b_enable(struct r8152 *tp) static int rtl8156b_enable(struct r8152 *tp)
{ {
u32 ocp_data; u32 ocp_data;
...@@ -6429,25 +6470,6 @@ static void rtl8153c_up(struct r8152 *tp) ...@@ -6429,25 +6470,6 @@ static void rtl8153c_up(struct r8152 *tp)
r8153b_u1u2en(tp, true); r8153b_u1u2en(tp, true);
} }
static inline u32 fc_pause_on_auto(struct r8152 *tp)
{
return (ALIGN(mtu_to_size(tp->netdev->mtu), 1024) + 6 * 1024);
}
static inline u32 fc_pause_off_auto(struct r8152 *tp)
{
return (ALIGN(mtu_to_size(tp->netdev->mtu), 1024) + 14 * 1024);
}
static void r8156_fc_parameter(struct r8152 *tp)
{
u32 pause_on = tp->fc_pause_on ? tp->fc_pause_on : fc_pause_on_auto(tp);
u32 pause_off = tp->fc_pause_off ? tp->fc_pause_off : fc_pause_off_auto(tp);
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_FULL, pause_on / 16);
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_EMPTY, pause_off / 16);
}
static void rtl8156_change_mtu(struct r8152 *tp) static void rtl8156_change_mtu(struct r8152 *tp)
{ {
u32 rx_max_size = mtu_to_size(tp->netdev->mtu); u32 rx_max_size = mtu_to_size(tp->netdev->mtu);
...@@ -7538,6 +7560,11 @@ static void r8156_hw_phy_cfg(struct r8152 *tp) ...@@ -7538,6 +7560,11 @@ static void r8156_hw_phy_cfg(struct r8152 *tp)
((swap_a & 0x1f) << 8) | ((swap_a & 0x1f) << 8) |
((swap_a >> 8) & 0x1f)); ((swap_a >> 8) & 0x1f));
} }
/* Notify the MAC when the speed is changed to force mode. */
data = ocp_reg_read(tp, OCP_INTR_EN);
data |= INTR_SPEED_FORCE;
ocp_reg_write(tp, OCP_INTR_EN, data);
break; break;
default: default:
break; break;
...@@ -7933,6 +7960,11 @@ static void r8156b_hw_phy_cfg(struct r8152 *tp) ...@@ -7933,6 +7960,11 @@ static void r8156b_hw_phy_cfg(struct r8152 *tp)
break; break;
} }
/* Notify the MAC when the speed is changed to force mode. */
data = ocp_reg_read(tp, OCP_INTR_EN);
data |= INTR_SPEED_FORCE;
ocp_reg_write(tp, OCP_INTR_EN, data);
if (rtl_phy_patch_request(tp, true, true)) if (rtl_phy_patch_request(tp, true, true))
return; return;
...@@ -9340,7 +9372,7 @@ static int rtl_ops_init(struct r8152 *tp) ...@@ -9340,7 +9372,7 @@ static int rtl_ops_init(struct r8152 *tp)
case RTL_VER_10: case RTL_VER_10:
ops->init = r8156_init; ops->init = r8156_init;
ops->enable = rtl8156_enable; ops->enable = rtl8156_enable;
ops->disable = rtl8153_disable; ops->disable = rtl8156_disable;
ops->up = rtl8156_up; ops->up = rtl8156_up;
ops->down = rtl8156_down; ops->down = rtl8156_down;
ops->unload = rtl8153_unload; ops->unload = rtl8153_unload;
......
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