[package] mac80211: add ath9k init values patch
[openwrt.git] / package / mac80211 / patches / 405-ath9k-use-correct-init-values-for-ar9100-devices.patch
1 From 91ada2959c75a3690bf009fd4314dd52454568df Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Tue, 3 Mar 2009 15:21:30 +0100
4 Subject: [RFC] ath9k: use correct init values for ar9100 devices
5
6 Changes-licensed-under: ISC
7
8 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
9 Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
10 ---
11  drivers/net/wireless/ath9k/initvals.h |   44 ++++++++++++++++----------------
12  drivers/net/wireless/ath9k/reg.h      |   32 ++++++++++++-----------
13  2 files changed, 39 insertions(+), 37 deletions(-)
14  
15 Hi,
16
17 Currently I'm trying to resolve the following mysterious issues caused by the
18 ath9k driver on the ar913x based devices:
19
20 1. In some cases the ethernet interface goes down for a short time
21 after'ifconfig wlan0 up'.
22 2. Sometimes the device simply reboots itself after 'ifconfig wlan0 up'.
23
24 After I have added some printk statements into the code, I noticed that the 
25 ar5416 and ar9100 devices use the same initval arrays currently. I assume 
26 that they requires different initialization, because we have different 
27 arrays for them.
28
29 Although I have no detailed knowledge about the evolution of the ath9k devices,
30 but the version checking macros for ther AR5416 cards seemed weird enough, so I
31 have replaced them. Unfortunately, this leaded to very bad performance with the
32 ar5416 cards I have, but the driver was working on the ar913x boards.
33
34 After some digging, I have found an interesting ifdef statement in Sam's current
35 HAL. In his ar5416Common initval array, this ifdef conditionally selects the
36 right RTC register offsets for the ar5416/ar9100 devices. The strange thing,
37 that in the ath9k driver the ar5416 specific RTC register offsets are used in
38 the ar5416Common_ar9100 array, while the ar9100 specific offsets are used in the
39 ar5416Common.
40
41 After I have renamed the arrays and tested the ath9k driver with the new
42 settings on the ar9100 devices, the strange problems I have mentioned above
43 disappeared. Unfortunately I have no ar5418 devices so I can't test them, 
44 but they are using the same array as before so this change should not 
45 cause problems on them.
46
47 Regards,
48 Gabor
49
50 diff --git a/drivers/net/wireless/ath9k/initvals.h b/drivers/net/wireless/ath9k/initvals.h
51 index d492363..4eb8b59 100644
52 --- a/drivers/net/wireless/ath9k/initvals.h
53 +++ b/drivers/net/wireless/ath9k/initvals.h
54 @@ -14,7 +14,7 @@
55   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
56   */
57  
58 -static const u32 ar5416Modes_9100[][6] = {
59 +static const u32 ar5416Modes[][6] = {
60      { 0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160, 0x000001e0 },
61      { 0x00001070, 0x00000168, 0x000002d0, 0x00000318, 0x0000018c, 0x000001e0 },
62      { 0x000010b0, 0x00000e60, 0x00001cc0, 0x00007c70, 0x00003e38, 0x00001180 },
63 @@ -78,7 +78,7 @@ static const u32 ar5416Modes_9100[][6] = {
64      { 0x0000a334, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
65  };
66  
67 -static const u32 ar5416Common_9100[][2] = {
68 +static const u32 ar5416Common[][2] = {
69      { 0x0000000c, 0x00000000 },
70      { 0x00000030, 0x00020015 },
71      { 0x00000034, 0x00000005 },
72 @@ -456,12 +456,12 @@ static const u32 ar5416Common_9100[][2] = {
73      { 0x0000a3e0, 0x000001ce },
74  };
75  
76 -static const u32 ar5416Bank0_9100[][2] = {
77 +static const u32 ar5416Bank0[][2] = {
78      { 0x000098b0, 0x1e5795e5 },
79      { 0x000098e0, 0x02008020 },
80  };
81  
82 -static const u32 ar5416BB_RfGain_9100[][3] = {
83 +static const u32 ar5416BB_RfGain[][3] = {
84      { 0x00009a00, 0x00000000, 0x00000000 },
85      { 0x00009a04, 0x00000040, 0x00000040 },
86      { 0x00009a08, 0x00000080, 0x00000080 },
87 @@ -528,21 +528,21 @@ static const u32 ar5416BB_RfGain_9100[][3] = {
88      { 0x00009afc, 0x000000f9, 0x000000f9 },
89  };
90  
91 -static const u32 ar5416Bank1_9100[][2] = {
92 +static const u32 ar5416Bank1[][2] = {
93      { 0x000098b0, 0x02108421 },
94      { 0x000098ec, 0x00000008 },
95  };
96  
97 -static const u32 ar5416Bank2_9100[][2] = {
98 +static const u32 ar5416Bank2[][2] = {
99      { 0x000098b0, 0x0e73ff17 },
100      { 0x000098e0, 0x00000420 },
101  };
102  
103 -static const u32 ar5416Bank3_9100[][3] = {
104 +static const u32 ar5416Bank3[][3] = {
105      { 0x000098f0, 0x01400018, 0x01c00018 },
106  };
107  
108 -static const u32 ar5416Bank6_9100[][3] = {
109 +static const u32 ar5416Bank6[][3] = {
110  
111      { 0x0000989c, 0x00000000, 0x00000000 },
112      { 0x0000989c, 0x00000000, 0x00000000 },
113 @@ -579,7 +579,7 @@ static const u32 ar5416Bank6_9100[][3] = {
114      { 0x000098d0, 0x0000000f, 0x0010000f },
115  };
116  
117 -static const u32 ar5416Bank6TPC_9100[][3] = {
118 +static const u32 ar5416Bank6TPC[][3] = {
119      { 0x0000989c, 0x00000000, 0x00000000 },
120      { 0x0000989c, 0x00000000, 0x00000000 },
121      { 0x0000989c, 0x00000000, 0x00000000 },
122 @@ -615,13 +615,13 @@ static const u32 ar5416Bank6TPC_9100[][3] = {
123      { 0x000098d0, 0x0000000f, 0x0010000f },
124  };
125  
126 -static const u32 ar5416Bank7_9100[][2] = {
127 +static const u32 ar5416Bank7[][2] = {
128      { 0x0000989c, 0x00000500 },
129      { 0x0000989c, 0x00000800 },
130      { 0x000098cc, 0x0000000e },
131  };
132  
133 -static const u32 ar5416Addac_9100[][2] = {
134 +static const u32 ar5416Addac[][2] = {
135      {0x0000989c,  0x00000000 },
136      {0x0000989c,  0x00000003 },
137      {0x0000989c,  0x00000000 },
138 @@ -661,7 +661,7 @@ static const u32 ar5416Addac_9100[][2] = {
139      {0x000098cc,  0x00000000 },
140  };
141  
142 -static const u32 ar5416Modes[][6] = {
143 +static const u32 ar5416Modes_9100[][6] = {
144      { 0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160, 0x000001e0 },
145      { 0x00001070, 0x00000168, 0x000002d0, 0x00000318, 0x0000018c, 0x000001e0 },
146      { 0x000010b0, 0x00000e60, 0x00001cc0, 0x00007c70, 0x00003e38, 0x00001180 },
147 @@ -735,7 +735,7 @@ static const u32 ar5416Modes[][6] = {
148      { 0x0000a334, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
149  };
150  
151 -static const u32 ar5416Common[][2] = {
152 +static const u32 ar5416Common_9100[][2] = {
153      { 0x0000000c, 0x00000000 },
154      { 0x00000030, 0x00020015 },
155      { 0x00000034, 0x00000005 },
156 @@ -1109,12 +1109,12 @@ static const u32 ar5416Common[][2] = {
157      { 0x0000a3e0, 0x000001ce },
158  };
159  
160 -static const u32 ar5416Bank0[][2] = {
161 +static const u32 ar5416Bank0_9100[][2] = {
162      { 0x000098b0, 0x1e5795e5 },
163      { 0x000098e0, 0x02008020 },
164  };
165  
166 -static const u32 ar5416BB_RfGain[][3] = {
167 +static const u32 ar5416BB_RfGain_9100[][3] = {
168      { 0x00009a00, 0x00000000, 0x00000000 },
169      { 0x00009a04, 0x00000040, 0x00000040 },
170      { 0x00009a08, 0x00000080, 0x00000080 },
171 @@ -1181,21 +1181,21 @@ static const u32 ar5416BB_RfGain[][3] = {
172      { 0x00009afc, 0x000000f9, 0x000000f9 },
173  };
174  
175 -static const u32 ar5416Bank1[][2] = {
176 +static const u32 ar5416Bank1_9100[][2] = {
177      { 0x000098b0, 0x02108421},
178      { 0x000098ec, 0x00000008},
179  };
180  
181 -static const u32 ar5416Bank2[][2] = {
182 +static const u32 ar5416Bank2_9100[][2] = {
183      { 0x000098b0, 0x0e73ff17},
184      { 0x000098e0, 0x00000420},
185  };
186  
187 -static const u32 ar5416Bank3[][3] = {
188 +static const u32 ar5416Bank3_9100[][3] = {
189      { 0x000098f0, 0x01400018, 0x01c00018 },
190  };
191  
192 -static const u32 ar5416Bank6[][3] = {
193 +static const u32 ar5416Bank6_9100[][3] = {
194  
195      { 0x0000989c, 0x00000000, 0x00000000 },
196      { 0x0000989c, 0x00000000, 0x00000000 },
197 @@ -1233,7 +1233,7 @@ static const u32 ar5416Bank6[][3] = {
198  };
199  
200  
201 -static const u32 ar5416Bank6TPC[][3] = {
202 +static const u32 ar5416Bank6TPC_9100[][3] = {
203  
204      { 0x0000989c, 0x00000000, 0x00000000 },
205      { 0x0000989c, 0x00000000, 0x00000000 },
206 @@ -1270,13 +1270,13 @@ static const u32 ar5416Bank6TPC[][3] = {
207      { 0x000098d0, 0x0000000f, 0x0010000f },
208  };
209  
210 -static const u32 ar5416Bank7[][2] = {
211 +static const u32 ar5416Bank7_9100[][2] = {
212      { 0x0000989c, 0x00000500 },
213      { 0x0000989c, 0x00000800 },
214      { 0x000098cc, 0x0000000e },
215  };
216  
217 -static const u32 ar5416Addac[][2] = {
218 +static const u32 ar5416Addac_9100[][2] = {
219      {0x0000989c, 0x00000000 },
220      {0x0000989c, 0x00000000 },
221      {0x0000989c, 0x00000000 },
222 diff --git a/drivers/net/wireless/ath9k/reg.h b/drivers/net/wireless/ath9k/reg.h
223 index 8d85106..22a14a4 100644
224 --- a/drivers/net/wireless/ath9k/reg.h
225 +++ b/drivers/net/wireless/ath9k/reg.h
226 @@ -158,14 +158,6 @@
227  #define AR_CST_TIMEOUT_LIMIT      0xFFFF0000
228  #define AR_CST_TIMEOUT_LIMIT_S    16
229  
230 -#define AR_SREV_VERSION_9100                  0x014
231 -
232 -#define AR_SREV_9100(ah) ((ah->hw_version.macVersion) == AR_SREV_VERSION_9100)
233 -#define AR_SREV_5416_V20_OR_LATER(_ah) \
234 -       (AR_SREV_9100((_ah)) || AR_SREV_5416_20_OR_LATER(_ah))
235 -#define AR_SREV_5416_V22_OR_LATER(_ah) \
236 -       (AR_SREV_9100((_ah)) || AR_SREV_5416_22_OR_LATER(_ah))
237 -
238  #define AR_ISR               0x0080
239  #define AR_ISR_RXOK          0x00000001
240  #define AR_ISR_RXDESC        0x00000002
241 @@ -734,6 +726,7 @@
242  #define AR_SREV_REVISION_5416_10               0
243  #define AR_SREV_REVISION_5416_20               1
244  #define AR_SREV_REVISION_5416_22               2
245 +#define AR_SREV_VERSION_9100                  0x14
246  #define AR_SREV_VERSION_9160                 0x40
247  #define AR_SREV_REVISION_9160_10             0
248  #define AR_SREV_REVISION_9160_11             1
249 @@ -746,14 +739,23 @@
250  #define AR_SREV_REVISION_9285_11              1
251  #define AR_SREV_REVISION_9285_12              2
252  
253 +#define AR_SREV_5416(_ah) \
254 +       (((_ah)->hw_version.macVersion == AR_SREV_VERSION_5416_PCIE) || \
255 +       ((_ah)->hw_version.macVersion == AR_SREV_VERSION_5416_PCI))
256 +#define AR_SREV_5416_V20_OR_LATER(_ah) \
257 +       (((_ah)->hw_version.macVersion > AR_SREV_VERSION_5416_PCIE) || \
258 +       ((AR_SREV_5416(_ah)) && \
259 +       ((_ah)->hw_version.macRev >= AR_SREV_REVISION_5416_20)))
260 +#define AR_SREV_5416_V22_OR_LATER(_ah) \
261 +       (((_ah)->hw_version.macVersion > AR_SREV_VERSION_5416_PCIE) || \
262 +       ((AR_SREV_5416(_ah)) && \
263 +       ((_ah)->hw_version.macRev >= AR_SREV_REVISION_5416_22)))
264 +
265 +#define AR_SREV_9100(ah) \
266 +       ((ah->hw_version.macVersion) == AR_SREV_VERSION_9100)
267  #define AR_SREV_9100_OR_LATER(_ah) \
268 -       (((_ah)->hw_version.macVersion >= AR_SREV_VERSION_5416_PCIE))
269 -#define AR_SREV_5416_20_OR_LATER(_ah) \
270 -       (((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9160) || \
271 -               ((_ah)->hw_version.macRev >= AR_SREV_REVISION_5416_20))
272 -#define AR_SREV_5416_22_OR_LATER(_ah) \
273 -       (((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9160) || \
274 -               ((_ah)->hw_version.macRev >= AR_SREV_REVISION_5416_22))
275 +       ((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9100)
276 +
277  #define AR_SREV_9160(_ah) \
278         (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9160))
279  #define AR_SREV_9160_10_OR_LATER(_ah) \
280 -- 
281 1.5.3.2
282