[package] mac80211: update compat-wireless to 2009-03-04, and refresh patches
[openwrt/svn-archive/archive.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 --- a/drivers/net/wireless/ath9k/initvals.h
51 +++ b/drivers/net/wireless/ath9k/initvals.h
52 @@ -14,7 +14,7 @@
53 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
54 */
55
56 -static const u32 ar5416Modes_9100[][6] = {
57 +static const u32 ar5416Modes[][6] = {
58 { 0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160, 0x000001e0 },
59 { 0x00001070, 0x00000168, 0x000002d0, 0x00000318, 0x0000018c, 0x000001e0 },
60 { 0x000010b0, 0x00000e60, 0x00001cc0, 0x00007c70, 0x00003e38, 0x00001180 },
61 @@ -78,7 +78,7 @@ static const u32 ar5416Modes_9100[][6] =
62 { 0x0000a334, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
63 };
64
65 -static const u32 ar5416Common_9100[][2] = {
66 +static const u32 ar5416Common[][2] = {
67 { 0x0000000c, 0x00000000 },
68 { 0x00000030, 0x00020015 },
69 { 0x00000034, 0x00000005 },
70 @@ -456,12 +456,12 @@ static const u32 ar5416Common_9100[][2]
71 { 0x0000a3e0, 0x000001ce },
72 };
73
74 -static const u32 ar5416Bank0_9100[][2] = {
75 +static const u32 ar5416Bank0[][2] = {
76 { 0x000098b0, 0x1e5795e5 },
77 { 0x000098e0, 0x02008020 },
78 };
79
80 -static const u32 ar5416BB_RfGain_9100[][3] = {
81 +static const u32 ar5416BB_RfGain[][3] = {
82 { 0x00009a00, 0x00000000, 0x00000000 },
83 { 0x00009a04, 0x00000040, 0x00000040 },
84 { 0x00009a08, 0x00000080, 0x00000080 },
85 @@ -528,21 +528,21 @@ static const u32 ar5416BB_RfGain_9100[][
86 { 0x00009afc, 0x000000f9, 0x000000f9 },
87 };
88
89 -static const u32 ar5416Bank1_9100[][2] = {
90 +static const u32 ar5416Bank1[][2] = {
91 { 0x000098b0, 0x02108421 },
92 { 0x000098ec, 0x00000008 },
93 };
94
95 -static const u32 ar5416Bank2_9100[][2] = {
96 +static const u32 ar5416Bank2[][2] = {
97 { 0x000098b0, 0x0e73ff17 },
98 { 0x000098e0, 0x00000420 },
99 };
100
101 -static const u32 ar5416Bank3_9100[][3] = {
102 +static const u32 ar5416Bank3[][3] = {
103 { 0x000098f0, 0x01400018, 0x01c00018 },
104 };
105
106 -static const u32 ar5416Bank6_9100[][3] = {
107 +static const u32 ar5416Bank6[][3] = {
108
109 { 0x0000989c, 0x00000000, 0x00000000 },
110 { 0x0000989c, 0x00000000, 0x00000000 },
111 @@ -579,7 +579,7 @@ static const u32 ar5416Bank6_9100[][3] =
112 { 0x000098d0, 0x0000000f, 0x0010000f },
113 };
114
115 -static const u32 ar5416Bank6TPC_9100[][3] = {
116 +static const u32 ar5416Bank6TPC[][3] = {
117 { 0x0000989c, 0x00000000, 0x00000000 },
118 { 0x0000989c, 0x00000000, 0x00000000 },
119 { 0x0000989c, 0x00000000, 0x00000000 },
120 @@ -615,13 +615,13 @@ static const u32 ar5416Bank6TPC_9100[][3
121 { 0x000098d0, 0x0000000f, 0x0010000f },
122 };
123
124 -static const u32 ar5416Bank7_9100[][2] = {
125 +static const u32 ar5416Bank7[][2] = {
126 { 0x0000989c, 0x00000500 },
127 { 0x0000989c, 0x00000800 },
128 { 0x000098cc, 0x0000000e },
129 };
130
131 -static const u32 ar5416Addac_9100[][2] = {
132 +static const u32 ar5416Addac[][2] = {
133 {0x0000989c, 0x00000000 },
134 {0x0000989c, 0x00000003 },
135 {0x0000989c, 0x00000000 },
136 @@ -661,7 +661,7 @@ static const u32 ar5416Addac_9100[][2] =
137 {0x000098cc, 0x00000000 },
138 };
139
140 -static const u32 ar5416Modes[][6] = {
141 +static const u32 ar5416Modes_9100[][6] = {
142 { 0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160, 0x000001e0 },
143 { 0x00001070, 0x00000168, 0x000002d0, 0x00000318, 0x0000018c, 0x000001e0 },
144 { 0x000010b0, 0x00000e60, 0x00001cc0, 0x00007c70, 0x00003e38, 0x00001180 },
145 @@ -735,7 +735,7 @@ static const u32 ar5416Modes[][6] = {
146 { 0x0000a334, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
147 };
148
149 -static const u32 ar5416Common[][2] = {
150 +static const u32 ar5416Common_9100[][2] = {
151 { 0x0000000c, 0x00000000 },
152 { 0x00000030, 0x00020015 },
153 { 0x00000034, 0x00000005 },
154 @@ -1109,12 +1109,12 @@ static const u32 ar5416Common[][2] = {
155 { 0x0000a3e0, 0x000001ce },
156 };
157
158 -static const u32 ar5416Bank0[][2] = {
159 +static const u32 ar5416Bank0_9100[][2] = {
160 { 0x000098b0, 0x1e5795e5 },
161 { 0x000098e0, 0x02008020 },
162 };
163
164 -static const u32 ar5416BB_RfGain[][3] = {
165 +static const u32 ar5416BB_RfGain_9100[][3] = {
166 { 0x00009a00, 0x00000000, 0x00000000 },
167 { 0x00009a04, 0x00000040, 0x00000040 },
168 { 0x00009a08, 0x00000080, 0x00000080 },
169 @@ -1181,21 +1181,21 @@ static const u32 ar5416BB_RfGain[][3] =
170 { 0x00009afc, 0x000000f9, 0x000000f9 },
171 };
172
173 -static const u32 ar5416Bank1[][2] = {
174 +static const u32 ar5416Bank1_9100[][2] = {
175 { 0x000098b0, 0x02108421},
176 { 0x000098ec, 0x00000008},
177 };
178
179 -static const u32 ar5416Bank2[][2] = {
180 +static const u32 ar5416Bank2_9100[][2] = {
181 { 0x000098b0, 0x0e73ff17},
182 { 0x000098e0, 0x00000420},
183 };
184
185 -static const u32 ar5416Bank3[][3] = {
186 +static const u32 ar5416Bank3_9100[][3] = {
187 { 0x000098f0, 0x01400018, 0x01c00018 },
188 };
189
190 -static const u32 ar5416Bank6[][3] = {
191 +static const u32 ar5416Bank6_9100[][3] = {
192
193 { 0x0000989c, 0x00000000, 0x00000000 },
194 { 0x0000989c, 0x00000000, 0x00000000 },
195 @@ -1233,7 +1233,7 @@ static const u32 ar5416Bank6[][3] = {
196 };
197
198
199 -static const u32 ar5416Bank6TPC[][3] = {
200 +static const u32 ar5416Bank6TPC_9100[][3] = {
201
202 { 0x0000989c, 0x00000000, 0x00000000 },
203 { 0x0000989c, 0x00000000, 0x00000000 },
204 @@ -1270,13 +1270,13 @@ static const u32 ar5416Bank6TPC[][3] = {
205 { 0x000098d0, 0x0000000f, 0x0010000f },
206 };
207
208 -static const u32 ar5416Bank7[][2] = {
209 +static const u32 ar5416Bank7_9100[][2] = {
210 { 0x0000989c, 0x00000500 },
211 { 0x0000989c, 0x00000800 },
212 { 0x000098cc, 0x0000000e },
213 };
214
215 -static const u32 ar5416Addac[][2] = {
216 +static const u32 ar5416Addac_9100[][2] = {
217 {0x0000989c, 0x00000000 },
218 {0x0000989c, 0x00000000 },
219 {0x0000989c, 0x00000000 },
220 --- a/drivers/net/wireless/ath9k/reg.h
221 +++ b/drivers/net/wireless/ath9k/reg.h
222 @@ -158,14 +158,6 @@
223 #define AR_CST_TIMEOUT_LIMIT 0xFFFF0000
224 #define AR_CST_TIMEOUT_LIMIT_S 16
225
226 -#define AR_SREV_VERSION_9100 0x014
227 -
228 -#define AR_SREV_9100(ah) ((ah->hw_version.macVersion) == AR_SREV_VERSION_9100)
229 -#define AR_SREV_5416_V20_OR_LATER(_ah) \
230 - (AR_SREV_9100((_ah)) || AR_SREV_5416_20_OR_LATER(_ah))
231 -#define AR_SREV_5416_V22_OR_LATER(_ah) \
232 - (AR_SREV_9100((_ah)) || AR_SREV_5416_22_OR_LATER(_ah))
233 -
234 #define AR_ISR 0x0080
235 #define AR_ISR_RXOK 0x00000001
236 #define AR_ISR_RXDESC 0x00000002
237 @@ -734,6 +726,7 @@
238 #define AR_SREV_REVISION_5416_10 0
239 #define AR_SREV_REVISION_5416_20 1
240 #define AR_SREV_REVISION_5416_22 2
241 +#define AR_SREV_VERSION_9100 0x14
242 #define AR_SREV_VERSION_9160 0x40
243 #define AR_SREV_REVISION_9160_10 0
244 #define AR_SREV_REVISION_9160_11 1
245 @@ -746,14 +739,23 @@
246 #define AR_SREV_REVISION_9285_11 1
247 #define AR_SREV_REVISION_9285_12 2
248
249 +#define AR_SREV_5416(_ah) \
250 + (((_ah)->hw_version.macVersion == AR_SREV_VERSION_5416_PCIE) || \
251 + ((_ah)->hw_version.macVersion == AR_SREV_VERSION_5416_PCI))
252 +#define AR_SREV_5416_V20_OR_LATER(_ah) \
253 + (((_ah)->hw_version.macVersion > AR_SREV_VERSION_5416_PCIE) || \
254 + ((AR_SREV_5416(_ah)) && \
255 + ((_ah)->hw_version.macRev >= AR_SREV_REVISION_5416_20)))
256 +#define AR_SREV_5416_V22_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_22)))
260 +
261 +#define AR_SREV_9100(ah) \
262 + ((ah->hw_version.macVersion) == AR_SREV_VERSION_9100)
263 #define AR_SREV_9100_OR_LATER(_ah) \
264 - (((_ah)->hw_version.macVersion >= AR_SREV_VERSION_5416_PCIE))
265 -#define AR_SREV_5416_20_OR_LATER(_ah) \
266 - (((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9160) || \
267 - ((_ah)->hw_version.macRev >= AR_SREV_REVISION_5416_20))
268 -#define AR_SREV_5416_22_OR_LATER(_ah) \
269 - (((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9160) || \
270 - ((_ah)->hw_version.macRev >= AR_SREV_REVISION_5416_22))
271 + ((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9100)
272 +
273 #define AR_SREV_9160(_ah) \
274 (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9160))
275 #define AR_SREV_9160_10_OR_LATER(_ah) \