ath9k: fix spectral scan on AR9285 and newer AR92xx chipsets
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 324-ath9k_hw-fix-spectral-scan-on-AR9285-and-newer.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Mon, 11 Jul 2016 10:34:37 +0200
3 Subject: [PATCH] ath9k_hw: fix spectral scan on AR9285 and newer
4
5 The register layout of AR_PHY_SPECTRAL_SCAN has changed, only AR9280
6 uses the old layout
7
8 Signed-off-by: Felix Fietkau <nbd@nbd.name>
9 ---
10
11 --- a/drivers/net/wireless/ath/ath9k/ar9002_phy.c
12 +++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
13 @@ -476,6 +476,7 @@ static void ar9002_hw_set_bt_ant_diversi
14 static void ar9002_hw_spectral_scan_config(struct ath_hw *ah,
15 struct ath_spec_scan *param)
16 {
17 + u32 repeat_bit;
18 u8 count;
19
20 if (!param->enabled) {
21 @@ -486,12 +487,15 @@ static void ar9002_hw_spectral_scan_conf
22 REG_SET_BIT(ah, AR_PHY_RADAR_0, AR_PHY_RADAR_0_FFT_ENA);
23 REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN, AR_PHY_SPECTRAL_SCAN_ENABLE);
24
25 + if (AR_SREV_9280(ah))
26 + repeat_bit = AR_PHY_SPECTRAL_SCAN_SHORT_REPEAT;
27 + else
28 + repeat_bit = AR_PHY_SPECTRAL_SCAN_SHORT_REPEAT_KIWI;
29 +
30 if (param->short_repeat)
31 - REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN,
32 - AR_PHY_SPECTRAL_SCAN_SHORT_REPEAT);
33 + REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN, repeat_bit);
34 else
35 - REG_CLR_BIT(ah, AR_PHY_SPECTRAL_SCAN,
36 - AR_PHY_SPECTRAL_SCAN_SHORT_REPEAT);
37 + REG_CLR_BIT(ah, AR_PHY_SPECTRAL_SCAN, repeat_bit);
38
39 /* on AR92xx, the highest bit of count will make the the chip send
40 * spectral samples endlessly. Check if this really was intended,
41 @@ -499,15 +503,25 @@ static void ar9002_hw_spectral_scan_conf
42 */
43 count = param->count;
44 if (param->endless) {
45 - if (AR_SREV_9271(ah))
46 - count = 0;
47 - else
48 + if (AR_SREV_9280(ah))
49 count = 0x80;
50 + else
51 + count = 0;
52 } else if (count & 0x80)
53 count = 0x7f;
54 + else if (!count)
55 + count = 1;
56 +
57 + if (AR_SREV_9280(ah)) {
58 + REG_RMW_FIELD(ah, AR_PHY_SPECTRAL_SCAN,
59 + AR_PHY_SPECTRAL_SCAN_COUNT, count);
60 + } else {
61 + REG_RMW_FIELD(ah, AR_PHY_SPECTRAL_SCAN,
62 + AR_PHY_SPECTRAL_SCAN_COUNT_KIWI, count);
63 + REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN,
64 + AR_PHY_SPECTRAL_SCAN_PHYERR_MASK_SELECT);
65 + }
66
67 - REG_RMW_FIELD(ah, AR_PHY_SPECTRAL_SCAN,
68 - AR_PHY_SPECTRAL_SCAN_COUNT, count);
69 REG_RMW_FIELD(ah, AR_PHY_SPECTRAL_SCAN,
70 AR_PHY_SPECTRAL_SCAN_PERIOD, param->period);
71 REG_RMW_FIELD(ah, AR_PHY_SPECTRAL_SCAN,
72 --- a/drivers/net/wireless/ath/ath9k/ar9002_phy.h
73 +++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.h
74 @@ -177,8 +177,11 @@
75 #define AR_PHY_SPECTRAL_SCAN_PERIOD_S 8
76 #define AR_PHY_SPECTRAL_SCAN_COUNT 0x00FF0000 /* Number of reports, reg 68, bits 16-23*/
77 #define AR_PHY_SPECTRAL_SCAN_COUNT_S 16
78 +#define AR_PHY_SPECTRAL_SCAN_COUNT_KIWI 0x0FFF0000 /* Number of reports, reg 68, bits 16-27*/
79 +#define AR_PHY_SPECTRAL_SCAN_COUNT_KIWI_S 16
80 #define AR_PHY_SPECTRAL_SCAN_SHORT_REPEAT 0x01000000 /* Short repeat, reg 68, bit 24*/
81 -#define AR_PHY_SPECTRAL_SCAN_SHORT_REPEAT_S 24 /* Short repeat, reg 68, bit 24*/
82 +#define AR_PHY_SPECTRAL_SCAN_SHORT_REPEAT_KIWI 0x10000000 /* Short repeat, reg 68, bit 28*/
83 +#define AR_PHY_SPECTRAL_SCAN_PHYERR_MASK_SELECT 0x40000000
84
85 #define AR_PHY_RX_DELAY 0x9914
86 #define AR_PHY_SEARCH_START_DELAY 0x9918