Skip to content

Commit f547b0f

Browse files
hayesorzgregkh
authored andcommitted
r8152: sync ocp base
commit b24edca upstream. There are some chances that the actual base of hardware is different from the value recorded by driver, so we have to reset the variable of ocp_base to sync it. Set ocp_base to -1. Then, it would be updated and the new base would be set to the hardware next time. Signed-off-by: Hayes Wang <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5cc8813 commit f547b0f

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

drivers/net/usb/r8152.c

Lines changed: 22 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
}
@@ -8484,6 +8499,8 @@ static int rtl8152_resume(struct usb_interface *intf)
84848499

84858500
mutex_lock(&tp->control);
84868501

8502+
rtl_reset_ocp_base(tp);
8503+
84878504
if (test_bit(SELECTIVE_SUSPEND, &tp->flags))
84888505
ret = rtl8152_runtime_resume(tp);
84898506
else
@@ -8499,6 +8516,7 @@ static int rtl8152_reset_resume(struct usb_interface *intf)
84998516
struct r8152 *tp = usb_get_intfdata(intf);
85008517

85018518
clear_bit(SELECTIVE_SUSPEND, &tp->flags);
8519+
rtl_reset_ocp_base(tp);
85028520
tp->rtl_ops.init(tp);
85038521
queue_delayed_work(system_long_wq, &tp->hw_phy_work, 0);
85048522
set_ethernet_addr(tp, true);

0 commit comments

Comments
 (0)