When wifi radio is reset, some bits in (undocumented) USB registers may
 flip. Patch adds setting them after radio reset (channel change,
 up/down).
 With this patch stability of USB1.1 full-speed devices, connected
 directly to AR9331 host port (no USB2.0 hub) is improved.

See "ar9331's usb stability issue" OpenWrt forum thread for details:
 <https://forum.openwrt.org/viewtopic.php?id=39956>

Based on QCA's Open HAL WAR_USB_DISABLE_PLL_LOCK_DETECT() macro:
<https://github.com/qca/qcamain_open_hal_public/blob/master/hal/ar9300/ar9300_reset.c#L74>

Adapted to Linux mac80211 driver for 8Devices Carambola2 board by Mantas Pucka:
<https://github.com/8devices/carambola2/commit/b08b59ceb4e7f0bad4c0b17e703e1e5c4e168923>

Ported to latest OpenWrt BB branch and tested on TP-Link TL-WR703N by Michel 
Stempin <[email protected]>.

Signed-off-by: Michel Stempin <[email protected]>
---
 .../patches/566-ath9k_usb_hang_workaround.patch    |   58 ++++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 
package/kernel/mac80211/patches/566-ath9k_usb_hang_workaround.patch

diff --git 
a/package/kernel/mac80211/patches/566-ath9k_usb_hang_workaround.patch 
b/package/kernel/mac80211/patches/566-ath9k_usb_hang_workaround.patch
new file mode 100644
index 0000000..4a91964
--- /dev/null
+++ b/package/kernel/mac80211/patches/566-ath9k_usb_hang_workaround.patch
@@ -0,0 +1,58 @@
+--- a/drivers/net/wireless/ath/ath9k/hw.c      2013-11-29 20:12:03.000000000 
+0100
++++ b/drivers/net/wireless/ath/ath9k/hw.c      2013-12-15 17:20:40.727254556 
+0100
+@@ -35,6 +35,16 @@
+ MODULE_SUPPORTED_DEVICE("Atheros 802.11n WLAN cards");
+ MODULE_LICENSE("Dual BSD/GPL");
+ 
++#define WAR_USB_DISABLE_PLL_LOCK_DETECT(_ah) \
++do { \
++      if (AR_SREV_9330(_ah) || AR_SREV_9340(_ah)) { \
++              volatile u_int32_t *usb_ctrl_r1 = (u_int32_t *) 0xb8116c84; \
++              volatile u_int32_t *usb_ctrl_r2 = (u_int32_t *) 0xb8116c88; \
++              *usb_ctrl_r1 = (*usb_ctrl_r1 & 0xffefffff); \
++              *usb_ctrl_r2 = (*usb_ctrl_r2 & 0xfc1fffff) | (1 << 21) | (3 << 
22); \
++      } \
++} while (0)
++
+ static int __init ath9k_init(void)
+ {
+       return 0;
+@@ -1390,6 +1400,8 @@
+       if (AR_SREV_9100(ah))
+               udelay(50);
+ 
++      WAR_USB_DISABLE_PLL_LOCK_DETECT(ah);
++
+       return true;
+ }
+ 
+@@ -1490,6 +1502,8 @@
+               ar9003_hw_internal_regulator_apply(ah);
+       ath9k_hw_init_pll(ah, chan);
+       ath9k_hw_set_rfmode(ah, chan);
++      
++      WAR_USB_DISABLE_PLL_LOCK_DETECT(ah);
+ 
+       return true;
+ }
+@@ -1841,8 +1855,11 @@
+       if (AR_SREV_9271(ah))
+               ar9002_hw_load_ani_reg(ah, chan);
+ 
++      WAR_USB_DISABLE_PLL_LOCK_DETECT(ah);
++
+       return 0;
+ fail:
++      WAR_USB_DISABLE_PLL_LOCK_DETECT(ah);
+       return -EINVAL;
+ }
+ 
+@@ -2052,6 +2069,8 @@
+       if (AR_SREV_9565(ah) && ah->shared_chain_lnadiv)
+               REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV, 
AR_BTCOEX_WL_LNADIV_FORCE_ON);
+ 
++      WAR_USB_DISABLE_PLL_LOCK_DETECT(ah);
++
+       return 0;
+ }
+ EXPORT_SYMBOL(ath9k_hw_reset);
-- 
1.7.10.4
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to