Skip to content

Commit e5c266a

Browse files
hayesorzkuba-moo
authored andcommitted
r8152: set bp in bulk
PLA_BP_0 ~ PLA_BP_15 (0xfc28 ~ 0xfc46) are continuous registers, so we could combine the control transfers into one control transfer. Signed-off-by: Hayes Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 57df0fb commit e5c266a

File tree

1 file changed

+25
-50
lines changed

1 file changed

+25
-50
lines changed

drivers/net/usb/r8152.c

Lines changed: 25 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3978,62 +3978,42 @@ static void rtl_reset_bmu(struct r8152 *tp)
39783978
/* Clear the bp to stop the firmware before loading a new one */
39793979
static void rtl_clear_bp(struct r8152 *tp, u16 type)
39803980
{
3981-
switch (tp->version) {
3982-
case RTL_VER_01:
3983-
case RTL_VER_02:
3984-
case RTL_VER_07:
3985-
break;
3986-
case RTL_VER_03:
3987-
case RTL_VER_04:
3988-
case RTL_VER_05:
3989-
case RTL_VER_06:
3990-
ocp_write_byte(tp, type, PLA_BP_EN, 0);
3991-
break;
3992-
case RTL_VER_14:
3993-
ocp_write_word(tp, type, USB_BP2_EN, 0);
3981+
u16 bp[16] = {0};
3982+
u16 bp_num;
39943983

3995-
ocp_write_word(tp, type, USB_BP_8, 0);
3996-
ocp_write_word(tp, type, USB_BP_9, 0);
3997-
ocp_write_word(tp, type, USB_BP_10, 0);
3998-
ocp_write_word(tp, type, USB_BP_11, 0);
3999-
ocp_write_word(tp, type, USB_BP_12, 0);
4000-
ocp_write_word(tp, type, USB_BP_13, 0);
4001-
ocp_write_word(tp, type, USB_BP_14, 0);
4002-
ocp_write_word(tp, type, USB_BP_15, 0);
4003-
break;
3984+
switch (tp->version) {
40043985
case RTL_VER_08:
40053986
case RTL_VER_09:
40063987
case RTL_VER_10:
40073988
case RTL_VER_11:
40083989
case RTL_VER_12:
40093990
case RTL_VER_13:
40103991
case RTL_VER_15:
4011-
default:
40123992
if (type == MCU_TYPE_USB) {
40133993
ocp_write_word(tp, MCU_TYPE_USB, USB_BP2_EN, 0);
4014-
4015-
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_8, 0);
4016-
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_9, 0);
4017-
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_10, 0);
4018-
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_11, 0);
4019-
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_12, 0);
4020-
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_13, 0);
4021-
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_14, 0);
4022-
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_15, 0);
4023-
} else {
4024-
ocp_write_byte(tp, MCU_TYPE_PLA, PLA_BP_EN, 0);
3994+
bp_num = 16;
3995+
break;
40253996
}
3997+
fallthrough;
3998+
case RTL_VER_03:
3999+
case RTL_VER_04:
4000+
case RTL_VER_05:
4001+
case RTL_VER_06:
4002+
ocp_write_byte(tp, type, PLA_BP_EN, 0);
4003+
fallthrough;
4004+
case RTL_VER_01:
4005+
case RTL_VER_02:
4006+
case RTL_VER_07:
4007+
bp_num = 8;
4008+
break;
4009+
case RTL_VER_14:
4010+
default:
4011+
ocp_write_word(tp, type, USB_BP2_EN, 0);
4012+
bp_num = 16;
40264013
break;
40274014
}
40284015

4029-
ocp_write_word(tp, type, PLA_BP_0, 0);
4030-
ocp_write_word(tp, type, PLA_BP_1, 0);
4031-
ocp_write_word(tp, type, PLA_BP_2, 0);
4032-
ocp_write_word(tp, type, PLA_BP_3, 0);
4033-
ocp_write_word(tp, type, PLA_BP_4, 0);
4034-
ocp_write_word(tp, type, PLA_BP_5, 0);
4035-
ocp_write_word(tp, type, PLA_BP_6, 0);
4036-
ocp_write_word(tp, type, PLA_BP_7, 0);
4016+
generic_ocp_write(tp, PLA_BP_0, BYTE_EN_DWORD, bp_num << 1, bp, type);
40374017

40384018
/* wait 3 ms to make sure the firmware is stopped */
40394019
usleep_range(3000, 6000);
@@ -5007,10 +4987,9 @@ static void rtl8152_fw_phy_nc_apply(struct r8152 *tp, struct fw_phy_nc *phy)
50074987

50084988
static void rtl8152_fw_mac_apply(struct r8152 *tp, struct fw_mac *mac)
50094989
{
5010-
u16 bp_en_addr, bp_index, type, bp_num, fw_ver_reg;
4990+
u16 bp_en_addr, type, fw_ver_reg;
50114991
u32 length;
50124992
u8 *data;
5013-
int i;
50144993

50154994
switch (__le32_to_cpu(mac->blk_hdr.type)) {
50164995
case RTL_FW_PLA:
@@ -5052,12 +5031,8 @@ static void rtl8152_fw_mac_apply(struct r8152 *tp, struct fw_mac *mac)
50525031
ocp_write_word(tp, type, __le16_to_cpu(mac->bp_ba_addr),
50535032
__le16_to_cpu(mac->bp_ba_value));
50545033

5055-
bp_index = __le16_to_cpu(mac->bp_start);
5056-
bp_num = __le16_to_cpu(mac->bp_num);
5057-
for (i = 0; i < bp_num; i++) {
5058-
ocp_write_word(tp, type, bp_index, __le16_to_cpu(mac->bp[i]));
5059-
bp_index += 2;
5060-
}
5034+
generic_ocp_write(tp, __le16_to_cpu(mac->bp_start), BYTE_EN_DWORD,
5035+
__le16_to_cpu(mac->bp_num) << 1, mac->bp, type);
50615036

50625037
bp_en_addr = __le16_to_cpu(mac->bp_en_addr);
50635038
if (bp_en_addr)

0 commit comments

Comments
 (0)