Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 65fd0c3

Browse files
committed
Merge branch 'r8152-fix-bugs'
Hayes Wang says: ==================== r8152: fix bugs Patch #1 fix the issue of force speed mode for RTL8156. Patch #2 fix the issue of unexpected ocp_base. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents d95a562 + b24edca commit 65fd0c3

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

drivers/net/usb/r8152.c

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#define NETNEXT_VERSION "12"
3333

3434
/* Information for net */
35-
#define NET_VERSION "11"
35+
#define NET_VERSION "12"
3636

3737
#define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION
3838
#define DRIVER_AUTHOR "Realtek linux nic maintainers <[email protected]>"
@@ -4016,6 +4016,11 @@ static void rtl_clear_bp(struct r8152 *tp, u16 type)
40164016
ocp_write_word(tp, type, PLA_BP_BA, 0);
40174017
}
40184018

4019+
static inline void rtl_reset_ocp_base(struct r8152 *tp)
4020+
{
4021+
tp->ocp_base = -1;
4022+
}
4023+
40194024
static int rtl_phy_patch_request(struct r8152 *tp, bool request, bool wait)
40204025
{
40214026
u16 data, check;
@@ -4087,8 +4092,6 @@ static int rtl_post_ram_code(struct r8152 *tp, u16 key_addr, bool wait)
40874092

40884093
rtl_phy_patch_request(tp, false, wait);
40894094

4090-
ocp_write_word(tp, MCU_TYPE_PLA, PLA_OCP_GPHY_BASE, tp->ocp_base);
4091-
40924095
return 0;
40934096
}
40944097

@@ -4800,6 +4803,8 @@ static void rtl_ram_code_speed_up(struct r8152 *tp, struct fw_phy_speed_up *phy,
48004803
u32 len;
48014804
u8 *data;
48024805

4806+
rtl_reset_ocp_base(tp);
4807+
48034808
if (sram_read(tp, SRAM_GPHY_FW_VER) >= __le16_to_cpu(phy->version)) {
48044809
dev_dbg(&tp->intf->dev, "PHY firmware has been the newest\n");
48054810
return;
@@ -4845,7 +4850,8 @@ static void rtl_ram_code_speed_up(struct r8152 *tp, struct fw_phy_speed_up *phy,
48454850
}
48464851
}
48474852

4848-
ocp_write_word(tp, MCU_TYPE_PLA, PLA_OCP_GPHY_BASE, tp->ocp_base);
4853+
rtl_reset_ocp_base(tp);
4854+
48494855
rtl_phy_patch_request(tp, false, wait);
48504856

48514857
if (sram_read(tp, SRAM_GPHY_FW_VER) == __le16_to_cpu(phy->version))
@@ -4861,6 +4867,8 @@ static int rtl8152_fw_phy_ver(struct r8152 *tp, struct fw_phy_ver *phy_ver)
48614867
ver_addr = __le16_to_cpu(phy_ver->ver.addr);
48624868
ver = __le16_to_cpu(phy_ver->ver.data);
48634869

4870+
rtl_reset_ocp_base(tp);
4871+
48644872
if (sram_read(tp, ver_addr) >= ver) {
48654873
dev_dbg(&tp->intf->dev, "PHY firmware has been the newest\n");
48664874
return 0;
@@ -4877,6 +4885,8 @@ static void rtl8152_fw_phy_fixup(struct r8152 *tp, struct fw_phy_fixup *fix)
48774885
{
48784886
u16 addr, data;
48794887

4888+
rtl_reset_ocp_base(tp);
4889+
48804890
addr = __le16_to_cpu(fix->setting.addr);
48814891
data = ocp_reg_read(tp, addr);
48824892

@@ -4908,6 +4918,8 @@ static void rtl8152_fw_phy_union_apply(struct r8152 *tp, struct fw_phy_union *ph
49084918
u32 length;
49094919
int i, num;
49104920

4921+
rtl_reset_ocp_base(tp);
4922+
49114923
num = phy->pre_num;
49124924
for (i = 0; i < num; i++)
49134925
sram_write(tp, __le16_to_cpu(phy->pre_set[i].addr),
@@ -4938,6 +4950,8 @@ static void rtl8152_fw_phy_nc_apply(struct r8152 *tp, struct fw_phy_nc *phy)
49384950
u32 length, i, num;
49394951
__le16 *data;
49404952

4953+
rtl_reset_ocp_base(tp);
4954+
49414955
mode_reg = __le16_to_cpu(phy->mode_reg);
49424956
sram_write(tp, mode_reg, __le16_to_cpu(phy->mode_pre));
49434957
sram_write(tp, __le16_to_cpu(phy->ba_reg),
@@ -5107,6 +5121,7 @@ static void rtl8152_apply_firmware(struct r8152 *tp, bool power_cut)
51075121
if (rtl_fw->post_fw)
51085122
rtl_fw->post_fw(tp);
51095123

5124+
rtl_reset_ocp_base(tp);
51105125
strscpy(rtl_fw->version, fw_hdr->version, RTL_VER_SIZE);
51115126
dev_info(&tp->intf->dev, "load %s successfully\n", rtl_fw->version);
51125127
}
@@ -6584,6 +6599,21 @@ static bool rtl8153_in_nway(struct r8152 *tp)
65846599
return true;
65856600
}
65866601

6602+
static void r8156_mdio_force_mode(struct r8152 *tp)
6603+
{
6604+
u16 data;
6605+
6606+
/* Select force mode through 0xa5b4 bit 15
6607+
* 0: MDIO force mode
6608+
* 1: MMD force mode
6609+
*/
6610+
data = ocp_reg_read(tp, 0xa5b4);
6611+
if (data & BIT(15)) {
6612+
data &= ~BIT(15);
6613+
ocp_reg_write(tp, 0xa5b4, data);
6614+
}
6615+
}
6616+
65876617
static void set_carrier(struct r8152 *tp)
65886618
{
65896619
struct net_device *netdev = tp->netdev;
@@ -8016,6 +8046,7 @@ static void r8156_init(struct r8152 *tp)
80168046
ocp_data |= ACT_ODMA;
80178047
ocp_write_byte(tp, MCU_TYPE_USB, USB_BMU_CONFIG, ocp_data);
80188048

8049+
r8156_mdio_force_mode(tp);
80198050
rtl_tally_reset(tp);
80208051

80218052
tp->coalesce = 15000; /* 15 us */
@@ -8145,6 +8176,7 @@ static void r8156b_init(struct r8152 *tp)
81458176
ocp_data &= ~(RX_AGG_DISABLE | RX_ZERO_EN);
81468177
ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data);
81478178

8179+
r8156_mdio_force_mode(tp);
81488180
rtl_tally_reset(tp);
81498181

81508182
tp->coalesce = 15000; /* 15 us */
@@ -8467,6 +8499,8 @@ static int rtl8152_resume(struct usb_interface *intf)
84678499

84688500
mutex_lock(&tp->control);
84698501

8502+
rtl_reset_ocp_base(tp);
8503+
84708504
if (test_bit(SELECTIVE_SUSPEND, &tp->flags))
84718505
ret = rtl8152_runtime_resume(tp);
84728506
else
@@ -8482,6 +8516,7 @@ static int rtl8152_reset_resume(struct usb_interface *intf)
84828516
struct r8152 *tp = usb_get_intfdata(intf);
84838517

84848518
clear_bit(SELECTIVE_SUSPEND, &tp->flags);
8519+
rtl_reset_ocp_base(tp);
84858520
tp->rtl_ops.init(tp);
84868521
queue_delayed_work(system_long_wq, &tp->hw_phy_work, 0);
84878522
set_ethernet_addr(tp, true);

0 commit comments

Comments
 (0)