mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-21 14:37:57 +00:00
34d2964554
Fixes issues with RTL8156 2.5G USB adapters - # ethtool eth1 Settings for eth1: Supported ports: [ ] Supported link modes: Not reported Supported pause frame use: No Supports auto-negotiation: No Supported FEC modes: Not reported Advertised link modes: Not reported Advertised pause frame use: No Advertised auto-negotiation: No Advertised FEC modes: Not reported Speed: 2500Mb/s Duplex: Half Port: Twisted Pair PHYAD: 0 Transceiver: internal Auto-negotiation: off MDI-X: Unknown Current message level: 0x00000007 (7) drv probe link Link detected: yes - # - r8152: break the loop when the budget is exhausted - r8152: Block future register access if register access fails - r8152: Rename RTL8152_UNPLUG to RTL8152_INACCESSIBLE - r8152: add vendor/device ID pair for D-Link DUB-E250 - r8152: try to use a normal budget - r8152: set bp in bulk - r8152: adjust generic_ocp_write function - r8152: fix the autosuspend doesn't work - r8152: Add __GFP_NOWARN to big allocations - r8152: reduce the control transfer of rtl8152_get_version() - r8152: remove rtl_vendor_mode function - r8152: avoid to change cfg for all devices - r8152: add USB device driver for config selection - r8152: use napi_gro_frags - cdc_ether: no need to blacklist any r8152 devices - cdc_ether: add u-blox 0x1313 composition Build system: x86_64 Build-tested: bcm2711, rockchip, x86/64 Run-tested: bcm2711/RPi4B, rockchip/nanopi r2s, x86/64 Signed-off-by: Marty Jones <mj8263788@gmail.com>
130 lines
4.0 KiB
Diff
130 lines
4.0 KiB
Diff
From e5c266a61186b462c388c53a3564c375e72f2244 Mon Sep 17 00:00:00 2001
|
|
From: Hayes Wang <hayeswang@realtek.com>
|
|
Date: Wed, 26 Jul 2023 11:08:08 +0800
|
|
Subject: [PATCH] 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 <hayeswang@realtek.com>
|
|
Link: https://lore.kernel.org/r/20230726030808.9093-419-nic_swsd@realtek.com
|
|
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|
---
|
|
drivers/net/usb/r8152.c | 75 ++++++++++++++---------------------------
|
|
1 file changed, 25 insertions(+), 50 deletions(-)
|
|
|
|
--- a/drivers/net/usb/r8152.c
|
|
+++ b/drivers/net/usb/r8152.c
|
|
@@ -3984,29 +3984,10 @@ static void rtl_reset_bmu(struct r8152 *
|
|
/* Clear the bp to stop the firmware before loading a new one */
|
|
static void rtl_clear_bp(struct r8152 *tp, u16 type)
|
|
{
|
|
- switch (tp->version) {
|
|
- case RTL_VER_01:
|
|
- 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);
|
|
+ u16 bp[16] = {0};
|
|
+ u16 bp_num;
|
|
|
|
- ocp_write_word(tp, type, USB_BP_8, 0);
|
|
- 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;
|
|
+ switch (tp->version) {
|
|
case RTL_VER_08:
|
|
case RTL_VER_09:
|
|
case RTL_VER_10:
|
|
@@ -4014,32 +3995,31 @@ static void rtl_clear_bp(struct r8152 *t
|
|
case RTL_VER_12:
|
|
case RTL_VER_13:
|
|
case RTL_VER_15:
|
|
- default:
|
|
if (type == MCU_TYPE_USB) {
|
|
ocp_write_word(tp, MCU_TYPE_USB, USB_BP2_EN, 0);
|
|
-
|
|
- ocp_write_word(tp, MCU_TYPE_USB, USB_BP_8, 0);
|
|
- 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);
|
|
+ bp_num = 16;
|
|
+ break;
|
|
}
|
|
+ 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;
|
|
}
|
|
|
|
- ocp_write_word(tp, type, PLA_BP_0, 0);
|
|
- 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);
|
|
+ generic_ocp_write(tp, PLA_BP_0, BYTE_EN_DWORD, bp_num << 1, bp, type);
|
|
|
|
/* wait 3 ms to make sure the firmware is stopped */
|
|
usleep_range(3000, 6000);
|
|
@@ -5016,10 +4996,9 @@ static void rtl8152_fw_phy_nc_apply(stru
|
|
|
|
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;
|
|
u8 *data;
|
|
- int i;
|
|
|
|
switch (__le32_to_cpu(mac->blk_hdr.type)) {
|
|
case RTL_FW_PLA:
|
|
@@ -5061,12 +5040,8 @@ static void rtl8152_fw_mac_apply(struct
|
|
ocp_write_word(tp, type, __le16_to_cpu(mac->bp_ba_addr),
|
|
__le16_to_cpu(mac->bp_ba_value));
|
|
|
|
- bp_index = __le16_to_cpu(mac->bp_start);
|
|
- bp_num = __le16_to_cpu(mac->bp_num);
|
|
- for (i = 0; i < bp_num; i++) {
|
|
- ocp_write_word(tp, type, bp_index, __le16_to_cpu(mac->bp[i]));
|
|
- bp_index += 2;
|
|
- }
|
|
+ generic_ocp_write(tp, __le16_to_cpu(mac->bp_start), BYTE_EN_DWORD,
|
|
+ __le16_to_cpu(mac->bp_num) << 1, mac->bp, type);
|
|
|
|
bp_en_addr = __le16_to_cpu(mac->bp_en_addr);
|
|
if (bp_en_addr)
|