32
32
#define NETNEXT_VERSION "12"
33
33
34
34
/* Information for net */
35
- #define NET_VERSION "11 "
35
+ #define NET_VERSION "12 "
36
36
37
37
#define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION
38
38
#define DRIVER_AUTHOR "Realtek linux nic maintainers <
[email protected] >"
@@ -4016,6 +4016,11 @@ static void rtl_clear_bp(struct r8152 *tp, u16 type)
4016
4016
ocp_write_word (tp , type , PLA_BP_BA , 0 );
4017
4017
}
4018
4018
4019
+ static inline void rtl_reset_ocp_base (struct r8152 * tp )
4020
+ {
4021
+ tp -> ocp_base = -1 ;
4022
+ }
4023
+
4019
4024
static int rtl_phy_patch_request (struct r8152 * tp , bool request , bool wait )
4020
4025
{
4021
4026
u16 data , check ;
@@ -4087,8 +4092,6 @@ static int rtl_post_ram_code(struct r8152 *tp, u16 key_addr, bool wait)
4087
4092
4088
4093
rtl_phy_patch_request (tp , false, wait );
4089
4094
4090
- ocp_write_word (tp , MCU_TYPE_PLA , PLA_OCP_GPHY_BASE , tp -> ocp_base );
4091
-
4092
4095
return 0 ;
4093
4096
}
4094
4097
@@ -4800,6 +4803,8 @@ static void rtl_ram_code_speed_up(struct r8152 *tp, struct fw_phy_speed_up *phy,
4800
4803
u32 len ;
4801
4804
u8 * data ;
4802
4805
4806
+ rtl_reset_ocp_base (tp );
4807
+
4803
4808
if (sram_read (tp , SRAM_GPHY_FW_VER ) >= __le16_to_cpu (phy -> version )) {
4804
4809
dev_dbg (& tp -> intf -> dev , "PHY firmware has been the newest\n" );
4805
4810
return ;
@@ -4845,7 +4850,8 @@ static void rtl_ram_code_speed_up(struct r8152 *tp, struct fw_phy_speed_up *phy,
4845
4850
}
4846
4851
}
4847
4852
4848
- ocp_write_word (tp , MCU_TYPE_PLA , PLA_OCP_GPHY_BASE , tp -> ocp_base );
4853
+ rtl_reset_ocp_base (tp );
4854
+
4849
4855
rtl_phy_patch_request (tp , false, wait );
4850
4856
4851
4857
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)
4861
4867
ver_addr = __le16_to_cpu (phy_ver -> ver .addr );
4862
4868
ver = __le16_to_cpu (phy_ver -> ver .data );
4863
4869
4870
+ rtl_reset_ocp_base (tp );
4871
+
4864
4872
if (sram_read (tp , ver_addr ) >= ver ) {
4865
4873
dev_dbg (& tp -> intf -> dev , "PHY firmware has been the newest\n" );
4866
4874
return 0 ;
@@ -4877,6 +4885,8 @@ static void rtl8152_fw_phy_fixup(struct r8152 *tp, struct fw_phy_fixup *fix)
4877
4885
{
4878
4886
u16 addr , data ;
4879
4887
4888
+ rtl_reset_ocp_base (tp );
4889
+
4880
4890
addr = __le16_to_cpu (fix -> setting .addr );
4881
4891
data = ocp_reg_read (tp , addr );
4882
4892
@@ -4908,6 +4918,8 @@ static void rtl8152_fw_phy_union_apply(struct r8152 *tp, struct fw_phy_union *ph
4908
4918
u32 length ;
4909
4919
int i , num ;
4910
4920
4921
+ rtl_reset_ocp_base (tp );
4922
+
4911
4923
num = phy -> pre_num ;
4912
4924
for (i = 0 ; i < num ; i ++ )
4913
4925
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)
4938
4950
u32 length , i , num ;
4939
4951
__le16 * data ;
4940
4952
4953
+ rtl_reset_ocp_base (tp );
4954
+
4941
4955
mode_reg = __le16_to_cpu (phy -> mode_reg );
4942
4956
sram_write (tp , mode_reg , __le16_to_cpu (phy -> mode_pre ));
4943
4957
sram_write (tp , __le16_to_cpu (phy -> ba_reg ),
@@ -5107,6 +5121,7 @@ static void rtl8152_apply_firmware(struct r8152 *tp, bool power_cut)
5107
5121
if (rtl_fw -> post_fw )
5108
5122
rtl_fw -> post_fw (tp );
5109
5123
5124
+ rtl_reset_ocp_base (tp );
5110
5125
strscpy (rtl_fw -> version , fw_hdr -> version , RTL_VER_SIZE );
5111
5126
dev_info (& tp -> intf -> dev , "load %s successfully\n" , rtl_fw -> version );
5112
5127
}
@@ -6584,6 +6599,21 @@ static bool rtl8153_in_nway(struct r8152 *tp)
6584
6599
return true;
6585
6600
}
6586
6601
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
+
6587
6617
static void set_carrier (struct r8152 * tp )
6588
6618
{
6589
6619
struct net_device * netdev = tp -> netdev ;
@@ -8016,6 +8046,7 @@ static void r8156_init(struct r8152 *tp)
8016
8046
ocp_data |= ACT_ODMA ;
8017
8047
ocp_write_byte (tp , MCU_TYPE_USB , USB_BMU_CONFIG , ocp_data );
8018
8048
8049
+ r8156_mdio_force_mode (tp );
8019
8050
rtl_tally_reset (tp );
8020
8051
8021
8052
tp -> coalesce = 15000 ; /* 15 us */
@@ -8145,6 +8176,7 @@ static void r8156b_init(struct r8152 *tp)
8145
8176
ocp_data &= ~(RX_AGG_DISABLE | RX_ZERO_EN );
8146
8177
ocp_write_word (tp , MCU_TYPE_USB , USB_USB_CTRL , ocp_data );
8147
8178
8179
+ r8156_mdio_force_mode (tp );
8148
8180
rtl_tally_reset (tp );
8149
8181
8150
8182
tp -> coalesce = 15000 ; /* 15 us */
@@ -8467,6 +8499,8 @@ static int rtl8152_resume(struct usb_interface *intf)
8467
8499
8468
8500
mutex_lock (& tp -> control );
8469
8501
8502
+ rtl_reset_ocp_base (tp );
8503
+
8470
8504
if (test_bit (SELECTIVE_SUSPEND , & tp -> flags ))
8471
8505
ret = rtl8152_runtime_resume (tp );
8472
8506
else
@@ -8482,6 +8516,7 @@ static int rtl8152_reset_resume(struct usb_interface *intf)
8482
8516
struct r8152 * tp = usb_get_intfdata (intf );
8483
8517
8484
8518
clear_bit (SELECTIVE_SUSPEND , & tp -> flags );
8519
+ rtl_reset_ocp_base (tp );
8485
8520
tp -> rtl_ops .init (tp );
8486
8521
queue_delayed_work (system_long_wq , & tp -> hw_phy_work , 0 );
8487
8522
set_ethernet_addr (tp , true);
0 commit comments