From 5e345a86d5a4b3bd5ac97fea526da6dc4ca8b084 Mon Sep 17 00:00:00 2001 From: kimocoder Date: Sat, 25 Aug 2018 20:37:42 +0200 Subject: [PATCH] Fix USB3 and USB modeswitch function --- os_dep/linux/os_intfs.c | 2 +- os_dep/linux/usb_intf.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index 21497ee..d07bf46 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -306,7 +306,7 @@ int rtw_drv_ant_band_switch = 1; /* 0:OFF , 1:ON, Driver control antenna band sw int rtw_single_ant_path; /*0:main ant , 1:aux ant , Fixed single antenna path, default main ant*/ /* 0: doesn't switch, 1: switch from usb2.0 to usb 3.0 2: switch from usb3.0 to usb 2.0 */ -int rtw_switch_usb_mode = 0; +int rtw_switch_usb_mode = 1; #ifdef CONFIG_USB_AUTOSUSPEND int rtw_enusbss = 1;/* 0:disable,1:enable */ diff --git a/os_dep/linux/usb_intf.c b/os_dep/linux/usb_intf.c index 52d8258..90184e8 100644 --- a/os_dep/linux/usb_intf.c +++ b/os_dep/linux/usb_intf.c @@ -664,7 +664,24 @@ static int usb_reprobe_switch_usb_mode(PADAPTER Adapter) if (registry_par->switch_usb_mode == 0) goto exit; +#if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A) || defined(CONFIG_RTL8814A) + if (IS_HIGH_SPEED_USB(Adapter)) { + if ((rtw_read8(Adapter, 0x74) & (BIT(2)|BIT(3))) != BIT(3)) { + rtw_write8(Adapter, 0x74, 0x8); + rtw_write8(Adapter, 0x70, 0x2); + rtw_write8(Adapter, 0x3e, 0x1); + rtw_write8(Adapter, 0x3d, 0x3); + /* usb disconnect */ + rtw_write8(Adapter, 0x5, 0x80); + ret = _TRUE; + } + } else if (IS_SUPER_SPEED_USB(Adapter)) { + rtw_write8(Adapter, 0x70, rtw_read8(Adapter, 0x70) & (~BIT(1))); + rtw_write8(Adapter, 0x3e, rtw_read8(Adapter, 0x3e) & (~BIT(0))); + } +#else rtw_hal_set_hwreg(Adapter, HW_VAR_USB_MODE, &ret); +#endif exit: return ret;