Skip to content

Commit f858e2f

Browse files
committed
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: David S. Miller <[email protected]>
2 parents 526f28b + cce8334 commit f858e2f

File tree

1 file changed

+58
-26
lines changed

1 file changed

+58
-26
lines changed

drivers/net/usb/r8152.c

Lines changed: 58 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
#define OCP_EEE_AR 0xa41a
200200
#define OCP_EEE_DATA 0xa41c
201201
#define OCP_PHY_STATUS 0xa420
202+
#define OCP_INTR_EN 0xa424
202203
#define OCP_NCTL_CFG 0xa42c
203204
#define OCP_POWER_CFG 0xa430
204205
#define OCP_EEE_CFG 0xa432
@@ -620,6 +621,9 @@ enum spd_duplex {
620621
#define PHY_STAT_LAN_ON 3
621622
#define PHY_STAT_PWRDN 5
622623

624+
/* OCP_INTR_EN */
625+
#define INTR_SPEED_FORCE BIT(3)
626+
623627
/* OCP_NCTL_CFG */
624628
#define PGA_RETURN_EN BIT(1)
625629

@@ -3023,12 +3027,16 @@ static int rtl_enable(struct r8152 *tp)
30233027
ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CR, ocp_data);
30243028

30253029
switch (tp->version) {
3026-
case RTL_VER_08:
3027-
case RTL_VER_09:
3028-
case RTL_VER_14:
3029-
r8153b_rx_agg_chg_indicate(tp);
3030+
case RTL_VER_01:
3031+
case RTL_VER_02:
3032+
case RTL_VER_03:
3033+
case RTL_VER_04:
3034+
case RTL_VER_05:
3035+
case RTL_VER_06:
3036+
case RTL_VER_07:
30303037
break;
30313038
default:
3039+
r8153b_rx_agg_chg_indicate(tp);
30323040
break;
30333041
}
30343042

@@ -3082,7 +3090,6 @@ static void r8153_set_rx_early_timeout(struct r8152 *tp)
30823090
640 / 8);
30833091
ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EXTRA_AGGR_TMR,
30843092
ocp_data);
3085-
r8153b_rx_agg_chg_indicate(tp);
30863093
break;
30873094

30883095
default:
@@ -3116,7 +3123,6 @@ static void r8153_set_rx_early_size(struct r8152 *tp)
31163123
case RTL_VER_15:
31173124
ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EARLY_SIZE,
31183125
ocp_data / 8);
3119-
r8153b_rx_agg_chg_indicate(tp);
31203126
break;
31213127
default:
31223128
WARN_ON_ONCE(1);
@@ -5986,6 +5992,25 @@ static void rtl8153_disable(struct r8152 *tp)
59865992
r8153_aldps_en(tp, true);
59875993
}
59885994

5995+
static u32 fc_pause_on_auto(struct r8152 *tp)
5996+
{
5997+
return (ALIGN(mtu_to_size(tp->netdev->mtu), 1024) + 6 * 1024);
5998+
}
5999+
6000+
static u32 fc_pause_off_auto(struct r8152 *tp)
6001+
{
6002+
return (ALIGN(mtu_to_size(tp->netdev->mtu), 1024) + 14 * 1024);
6003+
}
6004+
6005+
static void r8156_fc_parameter(struct r8152 *tp)
6006+
{
6007+
u32 pause_on = tp->fc_pause_on ? tp->fc_pause_on : fc_pause_on_auto(tp);
6008+
u32 pause_off = tp->fc_pause_off ? tp->fc_pause_off : fc_pause_off_auto(tp);
6009+
6010+
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_FULL, pause_on / 16);
6011+
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_EMPTY, pause_off / 16);
6012+
}
6013+
59896014
static int rtl8156_enable(struct r8152 *tp)
59906015
{
59916016
u32 ocp_data;
@@ -5994,6 +6019,7 @@ static int rtl8156_enable(struct r8152 *tp)
59946019
if (test_bit(RTL8152_UNPLUG, &tp->flags))
59956020
return -ENODEV;
59966021

6022+
r8156_fc_parameter(tp);
59976023
set_tx_qlen(tp);
59986024
rtl_set_eee_plus(tp);
59996025
r8153_set_rx_early_timeout(tp);
@@ -6025,9 +6051,24 @@ static int rtl8156_enable(struct r8152 *tp)
60256051
ocp_write_word(tp, MCU_TYPE_USB, USB_L1_CTRL, ocp_data);
60266052
}
60276053

6054+
ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_FW_TASK);
6055+
ocp_data &= ~FC_PATCH_TASK;
6056+
ocp_write_word(tp, MCU_TYPE_USB, USB_FW_TASK, ocp_data);
6057+
usleep_range(1000, 2000);
6058+
ocp_data |= FC_PATCH_TASK;
6059+
ocp_write_word(tp, MCU_TYPE_USB, USB_FW_TASK, ocp_data);
6060+
60286061
return rtl_enable(tp);
60296062
}
60306063

6064+
static void rtl8156_disable(struct r8152 *tp)
6065+
{
6066+
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_FULL, 0);
6067+
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_EMPTY, 0);
6068+
6069+
rtl8153_disable(tp);
6070+
}
6071+
60316072
static int rtl8156b_enable(struct r8152 *tp)
60326073
{
60336074
u32 ocp_data;
@@ -6429,25 +6470,6 @@ static void rtl8153c_up(struct r8152 *tp)
64296470
r8153b_u1u2en(tp, true);
64306471
}
64316472

6432-
static inline u32 fc_pause_on_auto(struct r8152 *tp)
6433-
{
6434-
return (ALIGN(mtu_to_size(tp->netdev->mtu), 1024) + 6 * 1024);
6435-
}
6436-
6437-
static inline u32 fc_pause_off_auto(struct r8152 *tp)
6438-
{
6439-
return (ALIGN(mtu_to_size(tp->netdev->mtu), 1024) + 14 * 1024);
6440-
}
6441-
6442-
static void r8156_fc_parameter(struct r8152 *tp)
6443-
{
6444-
u32 pause_on = tp->fc_pause_on ? tp->fc_pause_on : fc_pause_on_auto(tp);
6445-
u32 pause_off = tp->fc_pause_off ? tp->fc_pause_off : fc_pause_off_auto(tp);
6446-
6447-
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_FULL, pause_on / 16);
6448-
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RX_FIFO_EMPTY, pause_off / 16);
6449-
}
6450-
64516473
static void rtl8156_change_mtu(struct r8152 *tp)
64526474
{
64536475
u32 rx_max_size = mtu_to_size(tp->netdev->mtu);
@@ -7538,6 +7560,11 @@ static void r8156_hw_phy_cfg(struct r8152 *tp)
75387560
((swap_a & 0x1f) << 8) |
75397561
((swap_a >> 8) & 0x1f));
75407562
}
7563+
7564+
/* Notify the MAC when the speed is changed to force mode. */
7565+
data = ocp_reg_read(tp, OCP_INTR_EN);
7566+
data |= INTR_SPEED_FORCE;
7567+
ocp_reg_write(tp, OCP_INTR_EN, data);
75417568
break;
75427569
default:
75437570
break;
@@ -7933,6 +7960,11 @@ static void r8156b_hw_phy_cfg(struct r8152 *tp)
79337960
break;
79347961
}
79357962

7963+
/* Notify the MAC when the speed is changed to force mode. */
7964+
data = ocp_reg_read(tp, OCP_INTR_EN);
7965+
data |= INTR_SPEED_FORCE;
7966+
ocp_reg_write(tp, OCP_INTR_EN, data);
7967+
79367968
if (rtl_phy_patch_request(tp, true, true))
79377969
return;
79387970

@@ -9340,7 +9372,7 @@ static int rtl_ops_init(struct r8152 *tp)
93409372
case RTL_VER_10:
93419373
ops->init = r8156_init;
93429374
ops->enable = rtl8156_enable;
9343-
ops->disable = rtl8153_disable;
9375+
ops->disable = rtl8156_disable;
93449376
ops->up = rtl8156_up;
93459377
ops->down = rtl8156_down;
93469378
ops->unload = rtl8153_unload;

0 commit comments

Comments
 (0)