Commit e5c266a6 authored by Hayes Wang's avatar Hayes Wang Committed by Jakub Kicinski

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: default avatarHayes Wang <hayeswang@realtek.com>
Link: https://lore.kernel.org/r/20230726030808.9093-419-nic_swsd@realtek.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 57df0fb9
...@@ -3978,29 +3978,10 @@ static void rtl_reset_bmu(struct r8152 *tp) ...@@ -3978,29 +3978,10 @@ static void rtl_reset_bmu(struct r8152 *tp)
/* Clear the bp to stop the firmware before loading a new one */ /* Clear the bp to stop the firmware before loading a new one */
static void rtl_clear_bp(struct r8152 *tp, u16 type) static void rtl_clear_bp(struct r8152 *tp, u16 type)
{ {
switch (tp->version) { u16 bp[16] = {0};
case RTL_VER_01: u16 bp_num;
case RTL_VER_02:
case RTL_VER_07:
break;
case RTL_VER_03:
case RTL_VER_04:
case RTL_VER_05:
case RTL_VER_06:
ocp_write_byte(tp, type, PLA_BP_EN, 0);
break;
case RTL_VER_14:
ocp_write_word(tp, type, USB_BP2_EN, 0);
ocp_write_word(tp, type, USB_BP_8, 0); switch (tp->version) {
ocp_write_word(tp, type, USB_BP_9, 0);
ocp_write_word(tp, type, USB_BP_10, 0);
ocp_write_word(tp, type, USB_BP_11, 0);
ocp_write_word(tp, type, USB_BP_12, 0);
ocp_write_word(tp, type, USB_BP_13, 0);
ocp_write_word(tp, type, USB_BP_14, 0);
ocp_write_word(tp, type, USB_BP_15, 0);
break;
case RTL_VER_08: case RTL_VER_08:
case RTL_VER_09: case RTL_VER_09:
case RTL_VER_10: case RTL_VER_10:
...@@ -4008,32 +3989,31 @@ static void rtl_clear_bp(struct r8152 *tp, u16 type) ...@@ -4008,32 +3989,31 @@ static void rtl_clear_bp(struct r8152 *tp, u16 type)
case RTL_VER_12: case RTL_VER_12:
case RTL_VER_13: case RTL_VER_13:
case RTL_VER_15: case RTL_VER_15:
default:
if (type == MCU_TYPE_USB) { if (type == MCU_TYPE_USB) {
ocp_write_word(tp, MCU_TYPE_USB, USB_BP2_EN, 0); ocp_write_word(tp, MCU_TYPE_USB, USB_BP2_EN, 0);
bp_num = 16;
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_8, 0); break;
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_9, 0);
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_10, 0);
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_11, 0);
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_12, 0);
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_13, 0);
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_14, 0);
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_15, 0);
} else {
ocp_write_byte(tp, MCU_TYPE_PLA, PLA_BP_EN, 0);
} }
fallthrough;
case RTL_VER_03:
case RTL_VER_04:
case RTL_VER_05:
case RTL_VER_06:
ocp_write_byte(tp, type, PLA_BP_EN, 0);
fallthrough;
case RTL_VER_01:
case RTL_VER_02:
case RTL_VER_07:
bp_num = 8;
break;
case RTL_VER_14:
default:
ocp_write_word(tp, type, USB_BP2_EN, 0);
bp_num = 16;
break; break;
} }
ocp_write_word(tp, type, PLA_BP_0, 0); generic_ocp_write(tp, PLA_BP_0, BYTE_EN_DWORD, bp_num << 1, bp, type);
ocp_write_word(tp, type, PLA_BP_1, 0);
ocp_write_word(tp, type, PLA_BP_2, 0);
ocp_write_word(tp, type, PLA_BP_3, 0);
ocp_write_word(tp, type, PLA_BP_4, 0);
ocp_write_word(tp, type, PLA_BP_5, 0);
ocp_write_word(tp, type, PLA_BP_6, 0);
ocp_write_word(tp, type, PLA_BP_7, 0);
/* wait 3 ms to make sure the firmware is stopped */ /* wait 3 ms to make sure the firmware is stopped */
usleep_range(3000, 6000); usleep_range(3000, 6000);
...@@ -5007,10 +4987,9 @@ static void rtl8152_fw_phy_nc_apply(struct r8152 *tp, struct fw_phy_nc *phy) ...@@ -5007,10 +4987,9 @@ static void rtl8152_fw_phy_nc_apply(struct r8152 *tp, struct fw_phy_nc *phy)
static void rtl8152_fw_mac_apply(struct r8152 *tp, struct fw_mac *mac) static void rtl8152_fw_mac_apply(struct r8152 *tp, struct fw_mac *mac)
{ {
u16 bp_en_addr, bp_index, type, bp_num, fw_ver_reg; u16 bp_en_addr, type, fw_ver_reg;
u32 length; u32 length;
u8 *data; u8 *data;
int i;
switch (__le32_to_cpu(mac->blk_hdr.type)) { switch (__le32_to_cpu(mac->blk_hdr.type)) {
case RTL_FW_PLA: case RTL_FW_PLA:
...@@ -5052,12 +5031,8 @@ static void rtl8152_fw_mac_apply(struct r8152 *tp, struct fw_mac *mac) ...@@ -5052,12 +5031,8 @@ static void rtl8152_fw_mac_apply(struct r8152 *tp, struct fw_mac *mac)
ocp_write_word(tp, type, __le16_to_cpu(mac->bp_ba_addr), ocp_write_word(tp, type, __le16_to_cpu(mac->bp_ba_addr),
__le16_to_cpu(mac->bp_ba_value)); __le16_to_cpu(mac->bp_ba_value));
bp_index = __le16_to_cpu(mac->bp_start); generic_ocp_write(tp, __le16_to_cpu(mac->bp_start), BYTE_EN_DWORD,
bp_num = __le16_to_cpu(mac->bp_num); __le16_to_cpu(mac->bp_num) << 1, mac->bp, type);
for (i = 0; i < bp_num; i++) {
ocp_write_word(tp, type, bp_index, __le16_to_cpu(mac->bp[i]));
bp_index += 2;
}
bp_en_addr = __le16_to_cpu(mac->bp_en_addr); bp_en_addr = __le16_to_cpu(mac->bp_en_addr);
if (bp_en_addr) if (bp_en_addr)
......
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