@@ -3978,62 +3978,42 @@ static void rtl_reset_bmu(struct r8152 *tp)
3978
3978
/* Clear the bp to stop the firmware before loading a new one */
3979
3979
static void rtl_clear_bp (struct r8152 * tp , u16 type )
3980
3980
{
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 ;
3994
3983
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 ) {
4004
3985
case RTL_VER_08 :
4005
3986
case RTL_VER_09 :
4006
3987
case RTL_VER_10 :
4007
3988
case RTL_VER_11 :
4008
3989
case RTL_VER_12 :
4009
3990
case RTL_VER_13 :
4010
3991
case RTL_VER_15 :
4011
- default :
4012
3992
if (type == MCU_TYPE_USB ) {
4013
3993
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 ;
4025
3996
}
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 ;
4026
4013
break ;
4027
4014
}
4028
4015
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 );
4037
4017
4038
4018
/* wait 3 ms to make sure the firmware is stopped */
4039
4019
usleep_range (3000 , 6000 );
@@ -5007,10 +4987,9 @@ static void rtl8152_fw_phy_nc_apply(struct r8152 *tp, struct fw_phy_nc *phy)
5007
4987
5008
4988
static void rtl8152_fw_mac_apply (struct r8152 * tp , struct fw_mac * mac )
5009
4989
{
5010
- u16 bp_en_addr , bp_index , type , bp_num , fw_ver_reg ;
4990
+ u16 bp_en_addr , type , fw_ver_reg ;
5011
4991
u32 length ;
5012
4992
u8 * data ;
5013
- int i ;
5014
4993
5015
4994
switch (__le32_to_cpu (mac -> blk_hdr .type )) {
5016
4995
case RTL_FW_PLA :
@@ -5052,12 +5031,8 @@ static void rtl8152_fw_mac_apply(struct r8152 *tp, struct fw_mac *mac)
5052
5031
ocp_write_word (tp , type , __le16_to_cpu (mac -> bp_ba_addr ),
5053
5032
__le16_to_cpu (mac -> bp_ba_value ));
5054
5033
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 );
5061
5036
5062
5037
bp_en_addr = __le16_to_cpu (mac -> bp_en_addr );
5063
5038
if (bp_en_addr )
0 commit comments