From d3bba0bc439dd497cb9e0f11559296ae29be4477 Mon Sep 17 00:00:00 2001 From: Hyacinthe Cartiaux Date: Wed, 14 Sep 2022 15:04:30 +0200 Subject: [PATCH] Add 2.16.3 release --- r8152.c | 433 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 268 insertions(+), 165 deletions(-) diff --git a/r8152.c b/r8152.c index 0ad82d4..9c2bd16 100644 --- a/r8152.c +++ b/r8152.c @@ -32,7 +32,7 @@ #include "compatibility.h" /* Version Information */ -#define DRIVER_VERSION "v2.16.1 (2022/04/12)" +#define DRIVER_VERSION "v2.16.3 (2022/07/06)" #define DRIVER_AUTHOR "Realtek nic sw " #define DRIVER_DESC "Realtek RTL8152/RTL8153 Based USB Ethernet Adapters" #define MODULENAME "r8152" @@ -8937,6 +8937,7 @@ static void r8153_enter_oob(struct r8152 *tp) wait_oob_link_list_ready(tp); ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, mtu_to_size(tp->netdev->mtu)); + ocp_write_byte(tp, MCU_TYPE_PLA, PLA_MTPS, MTPS_DEFAULT); switch (tp->version) { case RTL_VER_03: @@ -8972,6 +8973,10 @@ static void r8153_enter_oob(struct r8152 *tp) ocp_data |= NOW_IS_OOB | DIS_MCU_CLROOB; ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); + ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7); + ocp_data |= MCU_BORW_EN; + ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data); + rxdy_gated_en(tp, false); ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); @@ -9876,17 +9881,18 @@ static int rtl_s5_wol(struct r8152 *tp) u32 ocp_data; if (!tp->saved_wolopts) - return 0; + return -EOPNOTSUPP; switch (tp->version) { case RTL_VER_01: case RTL_VER_02: + case RTL_VER_07: + return -EOPNOTSUPP; case RTL_VER_03: case RTL_VER_04: case RTL_VER_05: case RTL_VER_06: - case RTL_VER_07: - return -EOPNOTSUPP; + goto remote_wake; default: break; } @@ -9898,6 +9904,7 @@ static int rtl_s5_wol(struct r8152 *tp) ocp_data |= BIT(1); ocp_write_byte(tp, MCU_TYPE_PLA, PLA_INDICATE_FALG, ocp_data); +remote_wake: /* usb_enable_remote_wakeup */ if (udev->speed < USB_SPEED_SUPER) return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), @@ -9921,20 +9928,24 @@ int rtl_reboot_notifier(struct notifier_block *nb, unsigned long action, switch (action) { case SYS_POWER_OFF: - if (usb_autopm_get_interface(tp->intf) < 0) - break; + if (test_and_clear_bit(WORK_ENABLE, &tp->flags)) { + int ret; - mutex_lock(&tp->control); - if (rtl_s5_wol(tp) >= 0) { - clear_bit(WORK_ENABLE, &tp->flags); + if (usb_autopm_get_interface(tp->intf) < 0) + break; + + mutex_lock(&tp->control); tp->rtl_ops.down(tp); - netif_info(tp, drv, tp->netdev, "Enable S5 WOL\n"); - } else { - netif_info(tp, drv, tp->netdev, - "The device doesn't support S5 WOL\n"); + ret = rtl_s5_wol(tp); + if (ret < 0) + netif_info(tp, drv, tp->netdev, + "S5 WOL is not enabled, %d\n", ret); + else + netif_info(tp, drv, tp->netdev, "Enable S5 WOL\n"); + + mutex_unlock(&tp->control); + usb_autopm_put_interface(tp->intf); } - mutex_unlock(&tp->control); - usb_autopm_put_interface(tp->intf); break; case SYS_RESTART: @@ -10064,12 +10075,16 @@ static int rtl8152_close(struct net_device *netdev) } else { mutex_lock(&tp->control); + tp->rtl_ops.down(tp); + #if defined(RTL8152_S5_WOL) && defined(CONFIG_PM) - rtl_s5_wol(tp); + if (rtl_s5_wol(tp) < 0) + netif_info(tp, drv, tp->netdev, + "S5 WOL is not enabled\n"); + else + netif_info(tp, drv, tp->netdev, "Enable S5 WOL\n"); #endif /* defined(RTL8152_S5_WOL) && defined(CONFIG_PM) */ - tp->rtl_ops.down(tp); - if (tp->version == RTL_VER_01) rtl8152_set_speed(tp, AUTONEG_ENABLE, 0, 0, 3); else @@ -11277,9 +11292,9 @@ static void r8156_patch_code(struct r8152 *tp) 0x52, 0xe0, 0xff, 0xe0, 0x02, 0xe1, 0x06, 0xe1, 0x16, 0xe1, 0x18, 0xe1, - 0x1a, 0xe1, 0x1c, 0xe1, - 0x1e, 0xe1, 0x20, 0xe1, - 0x22, 0xe1, 0x24, 0xe1, + 0x39, 0xe1, 0x52, 0xe1, + 0x54, 0xe1, 0x56, 0xe1, + 0x58, 0xe1, 0x5a, 0xe1, 0x13, 0xc3, 0x60, 0x70, 0x8b, 0x49, 0x0d, 0xf1, 0x10, 0xc3, 0x60, 0x60, @@ -11416,10 +11431,37 @@ static void r8156_patch_code(struct r8152 *tp) 0xf4, 0xe7, 0x02, 0xc0, 0x00, 0xb8, 0x0e, 0x28, 0x02, 0xc7, 0x00, 0xbf, - 0x48, 0x31, 0x02, 0xc0, - 0x00, 0xb8, 0x00, 0x00, - 0x02, 0xc0, 0x00, 0xb8, - 0x00, 0x00, 0x02, 0xc0, + 0x48, 0x31, 0x1c, 0xc6, + 0xc0, 0x61, 0x04, 0x11, + 0x15, 0xf1, 0x19, 0xc6, + 0xc0, 0x61, 0x9c, 0x20, + 0x9c, 0x24, 0x09, 0x11, + 0x0f, 0xf1, 0x14, 0xc6, + 0x01, 0x19, 0xc0, 0x89, + 0x13, 0xc1, 0x13, 0xc6, + 0x24, 0x9e, 0x00, 0x1e, + 0x26, 0x8e, 0x26, 0x76, + 0xef, 0x49, 0xfe, 0xf1, + 0x22, 0x76, 0x08, 0xc1, + 0x22, 0x9e, 0x07, 0xc6, + 0x02, 0xc1, 0x00, 0xb9, + 0xae, 0x09, 0x18, 0xb4, + 0x4a, 0xb4, 0xe0, 0xcc, + 0x80, 0xd4, 0x08, 0xdc, + 0x10, 0xe8, 0xfc, 0xc6, + 0xc0, 0x67, 0xf0, 0x49, + 0x13, 0xf0, 0xf0, 0x48, + 0xc0, 0x8f, 0xc2, 0x77, + 0xf7, 0xc1, 0xf7, 0xc6, + 0x24, 0x9e, 0x22, 0x9f, + 0x8c, 0x1e, 0x26, 0x8e, + 0x26, 0x76, 0xef, 0x49, + 0xfe, 0xf1, 0xfb, 0x49, + 0x05, 0xf0, 0x07, 0xc6, + 0xc0, 0x61, 0x10, 0x48, + 0xc0, 0x89, 0x02, 0xc6, + 0x00, 0xbe, 0x06, 0x5f, + 0x6c, 0xb4, 0x02, 0xc0, 0x00, 0xb8, 0x00, 0x00, 0x02, 0xc0, 0x00, 0xb8, 0x00, 0x00, 0x02, 0xc0, @@ -11430,8 +11472,8 @@ static void r8156_patch_code(struct r8152 *tp) static u8 pla_patch_13[] = { 0x08, 0xe0, 0x14, 0xe0, 0x18, 0xe0, 0x32, 0xe0, - 0xbf, 0xe0, 0xcb, 0xe0, - 0x05, 0xe1, 0x07, 0xe1, + 0xc8, 0xe0, 0xd4, 0xe0, + 0x0e, 0xe1, 0x10, 0xe1, 0x0c, 0xc4, 0x04, 0x40, 0x05, 0xf0, 0x8c, 0x26, 0x0b, 0x15, 0x02, 0xf0, @@ -11455,158 +11497,168 @@ static void r8156_patch_code(struct r8152 *tp) 0x6f, 0x48, 0xe4, 0x9e, 0x02, 0xc6, 0x00, 0xbe, 0x62, 0x2a, 0x87, 0x49, - 0x5a, 0xf0, 0x03, 0x1b, - 0x58, 0x41, 0x2b, 0xf0, - 0x20, 0x73, 0x76, 0xc5, + 0x62, 0xf0, 0x03, 0x1b, + 0x58, 0x41, 0x33, 0xf0, + 0x20, 0x73, 0x0b, 0xc5, 0xa4, 0x74, 0xc0, 0x49, - 0x13, 0xf1, 0x7f, 0xc4, - 0x14, 0x40, 0x03, 0xf1, - 0xa0, 0x9b, 0x21, 0xe0, + 0x1b, 0xf1, 0x08, 0xc4, + 0x14, 0x40, 0x07, 0xf1, + 0x01, 0x1c, 0xa6, 0x9c, + 0xa0, 0x9b, 0x27, 0xe0, + 0xb8, 0xd3, 0x6c, 0xe8, 0x2c, 0x26, 0x0b, 0x14, - 0x0b, 0xf1, 0x77, 0xc4, - 0x80, 0x73, 0xa2, 0x9b, - 0xa0, 0x73, 0x80, 0x9b, + 0x0f, 0xf1, 0x70, 0xc4, + 0xa6, 0x73, 0xb0, 0x49, + 0x08, 0xf0, 0xb0, 0x48, + 0xa6, 0x9b, 0xa0, 0x73, + 0x80, 0x9b, 0x20, 0x73, + 0x40, 0x83, 0x17, 0xe0, 0x20, 0x73, 0x40, 0x83, - 0xa2, 0x73, 0x80, 0x9b, - 0x14, 0xe0, 0x6f, 0xc4, + 0x14, 0xe0, 0x70, 0xc4, 0x22, 0x40, 0x0a, 0xf1, 0x38, 0x22, 0x48, 0x26, 0xe8, 0x14, 0x06, 0xfb, - 0x6a, 0xc4, 0x80, 0x74, + 0x6b, 0xc4, 0x80, 0x74, 0xca, 0x49, 0x02, 0xf1, 0xbe, 0x48, 0x40, 0x83, - 0x54, 0xc4, 0x22, 0x40, - 0x55, 0xf0, 0x52, 0xc4, - 0x22, 0x40, 0x55, 0xf0, + 0x56, 0xc4, 0x22, 0x40, + 0x57, 0xf0, 0x54, 0xc4, + 0x22, 0x40, 0x57, 0xf0, 0x0c, 0x1b, 0x58, 0x41, - 0x55, 0xf0, 0x02, 0x24, + 0x57, 0xf0, 0x02, 0x24, 0x03, 0x1b, 0x58, 0x41, - 0x51, 0xf0, 0x46, 0xc5, + 0x53, 0xf0, 0x47, 0xc5, 0xa4, 0x74, 0xc0, 0x49, 0x0e, 0xf1, 0x2c, 0x26, 0x0b, 0x14, 0x0b, 0xf1, - 0x4c, 0xc4, 0x80, 0x73, + 0x41, 0xc4, 0x80, 0x73, 0xa2, 0x9b, 0xa0, 0x73, 0x80, 0x9b, 0x22, 0x73, 0x42, 0x83, 0xa2, 0x73, - 0x80, 0x9b, 0x40, 0xe0, - 0x22, 0x73, 0x44, 0xc4, + 0x80, 0x9b, 0x42, 0xe0, + 0x22, 0x73, 0x45, 0xc4, 0x22, 0x40, 0x0a, 0xf1, 0x39, 0x22, 0x4e, 0x26, 0x03, 0x14, 0x06, 0xf1, - 0x3e, 0xc4, 0x80, 0x74, + 0x3f, 0xc4, 0x80, 0x74, 0xca, 0x49, 0x02, 0xf1, 0xbe, 0x48, 0x42, 0x83, - 0x28, 0xc4, 0x22, 0x40, - 0x2f, 0xf1, 0x27, 0xc4, - 0x82, 0x83, 0x2c, 0xe0, - 0x21, 0xc5, 0xa4, 0x74, - 0xc0, 0x49, 0x11, 0xf1, + 0x2a, 0xc4, 0x22, 0x40, + 0x31, 0xf1, 0x29, 0xc4, + 0x82, 0x83, 0x2e, 0xe0, + 0x22, 0xc5, 0xa4, 0x74, + 0xc0, 0x49, 0x12, 0xf1, 0x2c, 0x26, 0x0b, 0x14, - 0x0e, 0xf1, 0x1a, 0xc5, - 0x26, 0xc4, 0x80, 0x73, - 0xa2, 0x9b, 0xa0, 0x73, - 0x80, 0x9b, 0x40, 0x73, - 0x20, 0x9b, 0x42, 0x73, - 0x22, 0x9b, 0xa2, 0x73, - 0x80, 0x9b, 0x18, 0xe0, - 0x86, 0x49, 0x03, 0xf0, - 0x84, 0x49, 0x03, 0xf0, + 0x0f, 0xf1, 0x1b, 0xc5, + 0x1b, 0xc4, 0xa6, 0x73, + 0xb0, 0x49, 0x05, 0xf0, + 0xb0, 0x48, 0xa6, 0x9b, + 0xa0, 0x73, 0x80, 0x9b, 0x40, 0x73, 0x20, 0x9b, - 0x86, 0x49, 0x03, 0xf0, - 0x85, 0x49, 0x0e, 0xf0, 0x42, 0x73, 0x22, 0x9b, - 0x0b, 0xe0, 0xb8, 0xd3, + 0x19, 0xe0, 0x86, 0x49, + 0x03, 0xf0, 0x84, 0x49, + 0x03, 0xf0, 0x40, 0x73, + 0x20, 0x9b, 0x86, 0x49, + 0x03, 0xf0, 0x85, 0x49, + 0x0f, 0xf0, 0x42, 0x73, + 0x22, 0x9b, 0x0c, 0xe0, + 0xb8, 0xd3, 0x6c, 0xe8, 0x00, 0xc0, 0x04, 0xc0, 0x82, 0xcc, 0xff, 0xc4, - 0x80, 0x83, 0xad, 0xe7, + 0x80, 0x83, 0xab, 0xe7, 0xfc, 0xc4, 0x84, 0x83, - 0xaa, 0xe7, 0x02, 0xc5, + 0xa8, 0xe7, 0x02, 0xc5, 0x00, 0xbd, 0x66, 0x0a, - 0x6c, 0xe8, 0x00, 0xea, - 0x04, 0xdd, 0x02, 0xdd, - 0x5a, 0xe8, 0x04, 0xe8, + 0x00, 0xea, 0x04, 0xdd, + 0x02, 0xdd, 0x5a, 0xe8, + 0x04, 0xe8, 0x02, 0xc1, + 0x00, 0xb9, 0xac, 0x35, + 0x08, 0xc1, 0x20, 0x70, + 0x87, 0x48, 0x20, 0x98, + 0x36, 0x70, 0x80, 0x48, + 0x36, 0x98, 0x80, 0xff, + 0xd4, 0xb5, 0x04, 0x10, + 0x07, 0xf1, 0x27, 0xc1, + 0x32, 0x70, 0x89, 0x48, + 0x32, 0x98, 0xf1, 0xef, + 0x18, 0xe0, 0x05, 0x10, + 0x07, 0xf1, 0x1f, 0xc1, + 0x32, 0x70, 0x89, 0x48, + 0x32, 0x98, 0x1d, 0xe8, + 0x10, 0xe0, 0x06, 0x10, + 0x07, 0xf1, 0x17, 0xc1, + 0x32, 0x70, 0x09, 0x48, + 0x32, 0x98, 0x15, 0xe8, + 0x08, 0xe0, 0x07, 0x10, + 0x0d, 0xf1, 0x0f, 0xc1, + 0x32, 0x70, 0x09, 0x48, + 0x32, 0x98, 0x15, 0xe8, + 0x0b, 0xc1, 0x28, 0x70, + 0x09, 0x48, 0x28, 0x98, 0x02, 0xc1, 0x00, 0xb9, - 0xac, 0x35, 0x08, 0xc1, - 0x20, 0x70, 0x87, 0x48, - 0x20, 0x98, 0x36, 0x70, - 0x80, 0x48, 0x36, 0x98, - 0x80, 0xff, 0xd4, 0xb5, - 0x04, 0x10, 0x07, 0xf1, - 0x27, 0xc1, 0x32, 0x70, - 0x89, 0x48, 0x32, 0x98, - 0xf1, 0xef, 0x18, 0xe0, - 0x05, 0x10, 0x07, 0xf1, - 0x1f, 0xc1, 0x32, 0x70, - 0x89, 0x48, 0x32, 0x98, - 0x1d, 0xe8, 0x10, 0xe0, - 0x06, 0x10, 0x07, 0xf1, - 0x17, 0xc1, 0x32, 0x70, - 0x09, 0x48, 0x32, 0x98, - 0x15, 0xe8, 0x08, 0xe0, - 0x07, 0x10, 0x0d, 0xf1, - 0x0f, 0xc1, 0x32, 0x70, - 0x09, 0x48, 0x32, 0x98, - 0x15, 0xe8, 0x0b, 0xc1, - 0x28, 0x70, 0x09, 0x48, - 0x28, 0x98, 0x02, 0xc1, - 0x00, 0xb9, 0x44, 0x36, - 0x02, 0xc1, 0x00, 0xb9, - 0x52, 0x36, 0x00, 0xb4, - 0x20, 0xb4, 0xd4, 0xc1, - 0x20, 0x70, 0x87, 0x48, - 0x20, 0x98, 0x36, 0x70, - 0x00, 0x48, 0x36, 0x98, - 0x80, 0xff, 0xcc, 0xc1, - 0x20, 0x70, 0x07, 0x48, - 0x20, 0x98, 0x36, 0x70, - 0x00, 0x48, 0x36, 0x98, - 0x80, 0xff, 0x02, 0xc0, - 0x00, 0xb8, 0x3a, 0x4e, + 0x44, 0x36, 0x02, 0xc1, + 0x00, 0xb9, 0x52, 0x36, + 0x00, 0xb4, 0x20, 0xb4, + 0xd4, 0xc1, 0x20, 0x70, + 0x87, 0x48, 0x20, 0x98, + 0x36, 0x70, 0x00, 0x48, + 0x36, 0x98, 0x80, 0xff, + 0xcc, 0xc1, 0x20, 0x70, + 0x07, 0x48, 0x20, 0x98, + 0x36, 0x70, 0x00, 0x48, + 0x36, 0x98, 0x80, 0xff, 0x02, 0xc0, 0x00, 0xb8, - 0x3a, 0x4e, 0x00, 0x00}; - - rtl_clear_bp(tp, MCU_TYPE_USB); - - generic_ocp_write(tp, 0xe600, 0xff, sizeof(usb_patch_13), - usb_patch_13, MCU_TYPE_USB); - - ocp_write_word(tp, MCU_TYPE_USB, USB_BP_BA, 0xc000); - ocp_write_word(tp, MCU_TYPE_USB, USB_BP_0, 0x0fba); - ocp_write_word(tp, MCU_TYPE_USB, USB_BP_1, 0x3660); - ocp_write_word(tp, MCU_TYPE_USB, USB_BP_2, 0x1478); - ocp_write_word(tp, MCU_TYPE_USB, USB_BP_3, 0x77ae); - ocp_write_word(tp, MCU_TYPE_USB, USB_BP_4, 0x60e0); - ocp_write_word(tp, MCU_TYPE_USB, USB_BP_5, 0x6d94); - ocp_write_word(tp, MCU_TYPE_USB, USB_BP_6, 0x284e); - ocp_write_word(tp, MCU_TYPE_USB, USB_BP_7, 0x27f6); - ocp_write_word(tp, MCU_TYPE_USB, USB_BP_8, 0x3140); - ocp_write_word(tp, MCU_TYPE_USB, USB_BP_9, 0x0000); - ocp_write_word(tp, MCU_TYPE_USB, USB_BP_10, 0x0000); - ocp_write_word(tp, MCU_TYPE_USB, USB_BP_11, 0x0000); - ocp_write_word(tp, MCU_TYPE_USB, USB_BP_12, 0x0000); - ocp_write_word(tp, MCU_TYPE_USB, USB_BP_13, 0x0000); - ocp_write_word(tp, MCU_TYPE_USB, USB_BP_14, 0x0000); - ocp_write_word(tp, MCU_TYPE_USB, USB_BP_15, 0x0000); - ocp_write_word(tp, MCU_TYPE_USB, USB_BP2_EN, 0x01ff); - ocp_write_byte(tp, MCU_TYPE_USB, 0xcfd7, 0x03); - - rtl_clear_bp(tp, MCU_TYPE_PLA); - - generic_ocp_write(tp, 0xf800, 0xff, sizeof(pla_patch_13), - pla_patch_13, MCU_TYPE_PLA); + 0x3a, 0x4e, 0x02, 0xc0, + 0x00, 0xb8, 0x3a, 0x4e}; + + if (ocp_read_byte(tp, MCU_TYPE_USB, 0xcfd7) < 0x04) { + rtl_clear_bp(tp, MCU_TYPE_USB); + + generic_ocp_write(tp, 0xe600, 0xff, + sizeof(usb_patch_13), + usb_patch_13, MCU_TYPE_USB); + + ocp_write_word(tp, MCU_TYPE_USB, USB_BP_BA, 0xc000); + ocp_write_word(tp, MCU_TYPE_USB, USB_BP_0, 0x0fba); + ocp_write_word(tp, MCU_TYPE_USB, USB_BP_1, 0x3660); + ocp_write_word(tp, MCU_TYPE_USB, USB_BP_2, 0x1478); + ocp_write_word(tp, MCU_TYPE_USB, USB_BP_3, 0x77ae); + ocp_write_word(tp, MCU_TYPE_USB, USB_BP_4, 0x60e0); + ocp_write_word(tp, MCU_TYPE_USB, USB_BP_5, 0x6d94); + ocp_write_word(tp, MCU_TYPE_USB, USB_BP_6, 0x284e); + ocp_write_word(tp, MCU_TYPE_USB, USB_BP_7, 0x27f6); + ocp_write_word(tp, MCU_TYPE_USB, USB_BP_8, 0x3140); + ocp_write_word(tp, MCU_TYPE_USB, USB_BP_9, 0x09ac); + ocp_write_word(tp, MCU_TYPE_USB, USB_BP_10, 0x5e2a); + ocp_write_word(tp, MCU_TYPE_USB, USB_BP_11, 0x0000); + ocp_write_word(tp, MCU_TYPE_USB, USB_BP_12, 0x0000); + ocp_write_word(tp, MCU_TYPE_USB, USB_BP_13, 0x0000); + ocp_write_word(tp, MCU_TYPE_USB, USB_BP_14, 0x0000); + ocp_write_word(tp, MCU_TYPE_USB, USB_BP_15, 0x0000); + ocp_write_word(tp, MCU_TYPE_USB, USB_BP2_EN, 0x07ff); + ocp_write_byte(tp, MCU_TYPE_USB, 0xcfd7, 0x04); + } - ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_BA, 0x8000); - ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_0, 0x374e); - ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_1, 0x27dc); - ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_2, 0x2a5c); - ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_3, 0x09d0); - ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_4, 0x359e); - ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_5, 0x35b6); - ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_6, 0x0000); - ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_7, 0x0000); - ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_EN, 0x003f); - ocp_write_byte(tp, MCU_TYPE_USB, 0xcfd6, 0x05); + if (ocp_read_byte(tp, MCU_TYPE_USB, 0xcfd6) < 0x06) { + rtl_clear_bp(tp, MCU_TYPE_PLA); + + generic_ocp_write(tp, 0xf800, 0xff, + sizeof(pla_patch_13), + pla_patch_13, MCU_TYPE_PLA); + + ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_BA, 0x8000); + ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_0, 0x374e); + ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_1, 0x27dc); + ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_2, 0x2a5c); + ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_3, 0x09d0); + ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_4, 0x359e); + ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_5, 0x35b6); + ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_6, 0x0000); + ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_7, 0x0000); + ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_EN, 0x003f); + ocp_write_byte(tp, MCU_TYPE_USB, 0xcfd6, 0x06); + } } rtl_reset_ocp_base(tp); @@ -11647,9 +11699,9 @@ static void rtl_ram_code_speed_up(struct r8152 *tp, bool wait) 0x38, 0xb4, 0x00, 0x18, 0x38, 0xb4, 0x6d, 0x80, 0x38, 0xb4, 0x00, 0x18, - 0x38, 0xb4, 0x79, 0x80, + 0x38, 0xb4, 0x71, 0x80, 0x38, 0xb4, 0x00, 0x18, - 0x38, 0xb4, 0x7e, 0x80, + 0x38, 0xb4, 0xb1, 0x80, 0x38, 0xb4, 0x93, 0xd0, 0x38, 0xb4, 0xc4, 0xd1, 0x38, 0xb4, 0x00, 0x10, @@ -11743,11 +11795,67 @@ static void rtl_ram_code_speed_up(struct r8152 *tp, bool wait) 0x38, 0xb4, 0x19, 0x09, 0x38, 0xb4, 0x00, 0x18, 0x38, 0xb4, 0x16, 0x09, + 0x38, 0xb4, 0x90, 0xd0, + 0x38, 0xb4, 0xc9, 0xd1, + 0x38, 0xb4, 0x00, 0x18, + 0x38, 0xb4, 0x64, 0x10, + 0x38, 0xb4, 0x96, 0xd0, + 0x38, 0xb4, 0xa9, 0xd1, + 0x38, 0xb4, 0x03, 0xd5, + 0x38, 0xb4, 0x04, 0xa1, + 0x38, 0xb4, 0x07, 0x0c, + 0x38, 0xb4, 0x02, 0x09, + 0x38, 0xb4, 0x00, 0xd5, + 0x38, 0xb4, 0x10, 0xbc, + 0x38, 0xb4, 0x01, 0xd5, + 0x38, 0xb4, 0x01, 0xce, + 0x38, 0xb4, 0x01, 0xa2, + 0x38, 0xb4, 0x01, 0x82, + 0x38, 0xb4, 0x00, 0xce, + 0x38, 0xb4, 0x00, 0xd5, + 0x38, 0xb4, 0x84, 0xc4, + 0x38, 0xb4, 0x03, 0xd5, + 0x38, 0xb4, 0x02, 0xcc, + 0x38, 0xb4, 0x0d, 0xcd, + 0x38, 0xb4, 0x01, 0xaf, + 0x38, 0xb4, 0x00, 0xd5, + 0x38, 0xb4, 0x03, 0xd7, + 0x38, 0xb4, 0x71, 0x43, + 0x38, 0xb4, 0x08, 0xbd, + 0x38, 0xb4, 0x00, 0x10, + 0x38, 0xb4, 0x5c, 0x13, + 0x38, 0xb4, 0x5e, 0xd7, + 0x38, 0xb4, 0xb3, 0x5f, + 0x38, 0xb4, 0x03, 0xd5, + 0x38, 0xb4, 0xf5, 0xd0, + 0x38, 0xb4, 0xc6, 0xd1, + 0x38, 0xb4, 0xf0, 0x0c, + 0x38, 0xb4, 0x50, 0x0e, + 0x38, 0xb4, 0x04, 0xd7, + 0x38, 0xb4, 0x1c, 0x40, + 0x38, 0xb4, 0xf5, 0xd0, + 0x38, 0xb4, 0xc6, 0xd1, + 0x38, 0xb4, 0xf0, 0x0c, + 0x38, 0xb4, 0xa0, 0x0e, + 0x38, 0xb4, 0x1c, 0x40, + 0x38, 0xb4, 0x7b, 0xd0, + 0x38, 0xb4, 0xc5, 0xd1, + 0x38, 0xb4, 0xf0, 0x8e, + 0x38, 0xb4, 0x1c, 0x40, + 0x38, 0xb4, 0x08, 0x9d, + 0x38, 0xb4, 0x00, 0x10, + 0x38, 0xb4, 0x5c, 0x13, + 0x38, 0xb4, 0x5e, 0xd7, + 0x38, 0xb4, 0xb3, 0x7f, + 0x38, 0xb4, 0x00, 0x10, + 0x38, 0xb4, 0x5c, 0x13, + 0x38, 0xb4, 0x5e, 0xd7, + 0x38, 0xb4, 0xad, 0x5f, 0x38, 0xb4, 0x00, 0x10, 0x38, 0xb4, 0xc5, 0x14, 0x38, 0xb4, 0x03, 0xd7, 0x38, 0xb4, 0x81, 0x31, - 0x38, 0xb4, 0x77, 0x80, + 0x38, 0xb4, 0xaf, 0x80, 0x38, 0xb4, 0xad, 0x60, 0x38, 0xb4, 0x00, 0x10, 0x38, 0xb4, 0x5c, 0x13, @@ -11755,11 +11863,6 @@ static void rtl_ram_code_speed_up(struct r8152 *tp, bool wait) 0x38, 0xb4, 0xba, 0x5f, 0x38, 0xb4, 0x00, 0x18, 0x38, 0xb4, 0xc7, 0x0c, - 0x38, 0xb4, 0x96, 0xd0, - 0x38, 0xb4, 0xa9, 0xd1, - 0x38, 0xb4, 0x03, 0xd5, - 0x38, 0xb4, 0x00, 0x18, - 0x38, 0xb4, 0x94, 0x0c, 0x38, 0xb4, 0x02, 0xa8, 0x38, 0xb4, 0x01, 0xa3, 0x38, 0xb4, 0x01, 0xa8, @@ -11773,7 +11876,7 @@ static void rtl_ram_code_speed_up(struct r8152 *tp, bool wait) 0x36, 0xb4, 0x24, 0xa0, 0x38, 0xb4, 0x93, 0x0c, 0x36, 0xb4, 0x22, 0xa0, - 0x38, 0xb4, 0xc5, 0x0c, + 0x38, 0xb4, 0x62, 0x10, 0x36, 0xb4, 0x20, 0xa0, 0x38, 0xb4, 0x15, 0x09, 0x36, 0xb4, 0x06, 0xa0, @@ -12081,6 +12184,7 @@ static void rtl_ram_code_speed_up(struct r8152 *tp, bool wait) 0x38, 0xb4, 0x7d, 0x6e, 0x38, 0xb4, 0x88, 0xbf, 0x38, 0xb4, 0x02, 0x5a, + 0xff, 0xff, 0xff, 0xff, 0x38, 0xb4, 0x7d, 0x6e, 0x38, 0xb4, 0x85, 0xe1, 0x38, 0xb4, 0xef, 0xa0, @@ -12132,7 +12236,6 @@ static void rtl_ram_code_speed_up(struct r8152 *tp, bool wait) 0x38, 0xb4, 0xe1, 0xfa, 0x38, 0xb4, 0xfb, 0x8f, 0x38, 0xb4, 0x88, 0xbf, - 0xff, 0xff, 0xff, 0xff, 0x38, 0xb4, 0x02, 0x60, 0x38, 0xb4, 0x7d, 0x6e, 0x38, 0xb4, 0x8f, 0xe0, @@ -12593,6 +12696,7 @@ static void rtl_ram_code_speed_up(struct r8152 *tp, bool wait) 0x36, 0xb4, 0x1e, 0xb8, 0x38, 0xb4, 0xff, 0xff, 0x36, 0xb4, 0x50, 0xb8, + 0xff, 0xff, 0xff, 0xff, 0x38, 0xb4, 0xff, 0xff, 0x36, 0xb4, 0x52, 0xb8, 0x38, 0xb4, 0xff, 0xff, @@ -12608,14 +12712,13 @@ static void rtl_ram_code_speed_up(struct r8152 *tp, bool wait) 0x38, 0xb4, 0x00, 0x00, 0x36, 0xb4, 0x24, 0x80, 0x38, 0xb4, 0x00, 0x00, + 0x36, 0xb4, 0x1e, 0x80, + 0x38, 0xb4, 0x21, 0x00, 0x6c, 0xe8, 0x00, 0xb0, 0x20, 0xb8, 0x00, 0x00, - 0x6c, 0xe8, 0x00, 0xa0, - 0x36, 0xb4, 0x1e, 0x80, - 0x38, 0xb4, 0x20, 0x00, 0xff, 0xff, 0xff, 0xff}; - if (sram_read(tp, SRAM_GPHY_FW_VER) < 0x0020) { + if (sram_read(tp, SRAM_GPHY_FW_VER) < 0x0021) { data = ram13; len = sizeof(ram13); } @@ -19775,12 +19878,12 @@ ocp_show(struct device *dev, struct device_attribute *attr, char *buf) case RTL_VER_13: case RTL_VER_15: strcat(buf, "RTL_VER_13\n"); - strcat(buf, "GPHY_ramcode_v20_usb_20210324\n"); + strcat(buf, "tgphy_ramcode_v21_usb_20220324\n"); strcat(buf, "\n"); strcat(buf, "\n"); strcat(buf, "\n"); - strcat(buf, "USB_patch_code_20200914_v3\n"); - strcat(buf, "PLA_patch_code_20201028_v5\n"); + strcat(buf, "USB_patch_code_20220314_v4\n"); + strcat(buf, "PLA_SVN8948_20220330_v06\n"); break; case RTL_VER_14: strcat(buf, "RTL_VER_14\n");